/* 每日宝 - 基金实时收益 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --dark: #191c1f;
    --white: #ffffff;
    --surface: #f4f4f4;
    --blue: #494fdf;
    --blue-light: #4f55f1;
    --danger: #e23b4a;
    --success: #00a87e;
    --warning: #ec7e00;
    --text: #191c1f;
    --text-secondary: #505a63;
    --text-muted: #8d969e;
    --border: #e5e5e5;
}

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--surface);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.app {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--white);
    position: relative;
}

/* 顶部 */
.header {
    background: var(--dark);
    color: var(--white);
    padding: 20px 20px 16px;
}

.header h1 {
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.header .subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* 总览卡片 */
.overview-card {
    background: var(--dark);
    color: var(--white);
    padding: 16px 20px 12px;
    border-radius: 0 0 16px 16px;
}

.overview-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.overview-main {
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 12px;
}

.overview-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.overview-value {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.overview-value.positive { color: var(--success); }
.overview-value.negative { color: var(--danger); }

.overview-secondary {
    display: flex;
    gap: 0;
    background: rgba(255,255,255,0.08);
    border-radius: 10px;
    padding: 10px 0;
}

.overview-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.overview-label-sm {
    font-size: 11px;
    color: var(--text-muted);
}

.overview-value-sm {
    font-size: 14px;
    font-weight: 600;
}

.overview-divider {
    width: 1px;
    background: rgba(255,255,255,0.15);
}

.overview-divider + .overview-item {
    border-left: none;
}

.pull-indicator {
    text-align: center;
    padding-top: 8px;
    font-size: 11px;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.3s;
}

.pull-indicator.visible {
    opacity: 1;
}

.profit-badge {
    background: var(--success);
    color: var(--white);
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 600;
}

.profit-badge.negative {
    background: var(--danger);
}

/* 持仓区域 */
.holdings-section {
    padding: 20px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-header h2 {
    font-size: 17px;
    font-weight: 600;
}

.holdings-count {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

/* 持仓卡片 */
.holdings-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 15px;
}

.empty-state .hint {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 6px;
}

.holding-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    position: relative;
}

.holding-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.holding-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
}

.holding-code {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.holding-profit-badge {
    background: var(--success);
    color: var(--white);
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 14px;
    font-weight: 700;
}

.holding-profit-badge.positive { background: var(--success); }
.holding-profit-badge.negative { background: var(--danger); }

.holding-today {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
}

.today-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.today-value {
    font-size: 16px;
    font-weight: 700;
}

.today-value.positive { color: var(--success); }
.today-value.negative { color: var(--danger); }

.holding-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.holding-detail {
    display: flex;
    justify-content: space-between;
}

.positive { color: var(--success); }
.negative { color: var(--danger); }

.delete-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    border: none;
    background: var(--surface);
    color: var(--text-muted);
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-btn:active {
    background: var(--danger);
    color: var(--white);
}

/* 底部操作栏 */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 480px;
    margin: 0 auto;
    background: var(--white);
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    display: flex;
    gap: 12px;
    z-index: 50;
}

.nav-btn {
    flex: 1;
    padding: 14px 20px;
    border: none;
    border-radius: 9999px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.nav-btn:active {
    opacity: 0.85;
}

.nav-btn {
    background: var(--dark);
    color: var(--white);
}

.nav-btn.secondary {
    background: var(--surface);
    color: var(--text);
}

/* 悬浮刷新按钮 */
.fab {
    position: fixed;
    bottom: calc(80px + env(safe-area-inset-bottom));
    right: 20px;
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 50%;
    background: var(--blue);
    color: var(--white);
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(73, 79, 223, 0.35);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.fab:active {
    transform: scale(0.95);
}

.fab.spinning {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 弹窗 */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: flex-end;
    justify-content: center;
    z-index: 100;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--white);
    width: 100%;
    max-width: 480px;
    border-radius: 20px 20px 0 0;
    padding: 20px;
    max-height: 85vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.modal-small {
    max-width: 320px;
    border-radius: 20px;
    margin: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--surface);
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-secondary);
}

.delete-message {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 15px;
}

.modal-actions {
    display: flex;
    gap: 12px;
}

/* 表单 */
.add-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.flex-1 {
    flex: 1;
}

.form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--blue);
}

.form-group input[readonly] {
    background: var(--surface);
    color: var(--text-secondary);
}

.btn-search {
    padding: 12px 16px;
    background: var(--blue);
    color: var(--white);
    border: none;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
    white-space: nowrap;
}

.btn-primary {
    padding: 14px 24px;
    background: var(--dark);
    color: var(--white);
    border: none;
    border-radius: 9999px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
}

.btn-primary:active {
    opacity: 0.85;
}

.btn-secondary {
    padding: 14px 24px;
    background: var(--surface);
    color: var(--text);
    border: none;
    border-radius: 9999px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    flex: 1;
}

.btn-danger {
    padding: 14px 24px;
    background: var(--danger);
    color: var(--white);
    border: none;
    border-radius: 9999px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    flex: 1;
}

/* 截图上传 */
.screenshot-area {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 16px;
    padding: 48px 20px;
    text-align: center;
    cursor: pointer;
    position: relative;
    transition: border-color 0.2s, background 0.2s;
}

.upload-zone:hover {
    border-color: var(--blue);
    background: rgba(73, 79, 223, 0.03);
}

.upload-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-hint {
    pointer-events: none;
}

.upload-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
}

.upload-hint p {
    font-size: 15px;
    color: var(--text-secondary);
}

.upload-hint .hint {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

.preview-area {
    text-align: center;
}

.preview-area img {
    max-width: 100%;
    max-height: 250px;
    border-radius: 12px;
    margin-bottom: 16px;
}

.ocr-controls,
.ocr-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.ocr-result {
    background: var(--surface);
    border-radius: 12px;
    padding: 16px;
}

.ocr-result h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
}

.ocr-item {
    background: var(--white);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 14px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 140px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--dark);
    color: var(--white);
    padding: 12px 24px;
    border-radius: 9999px;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
    z-index: 200;
    max-width: 90%;
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

/* PC适配 */
@media (min-width: 520px) {
    body {
        background: #e8e8e8;
        padding: 20px 0;
    }

    .app {
        border-radius: 24px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
        min-height: calc(100vh - 40px);
    }

    .bottom-nav {
        border-radius: 0 0 24px 24px;
    }
}

/* 触摸反馈 */
@media (hover: none) {
    .nav-btn:active,
    .fab:active,
    .btn-primary:active,
    .btn-secondary:active {
        transform: scale(0.98);
    }
}
