/* 智量资本 (Quality Capital) - Light 主题 */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --layer-stable: #22c55e;
    --layer-growth: #3b82f6;
    --layer-risk: #ef4444;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #22c55e;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
}

/* ========== 顶部导航 ========== */
.topbar {
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    height: 56px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    gap: 8px;
}

.topbar-menu-btn {
    display: none;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-secondary);
    flex-shrink: 0;
    line-height: 1;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 32px;
    flex-shrink: 0;
}

.topbar-logo {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
}

.topbar-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    padding-top: 2px;
}

.topbar-nav {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 4px 0;
}

.topnav-item {
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
    user-select: none;
}

.topnav-item:hover {
    background: #f1f5f9;
    color: var(--text-primary);
}

.topnav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

/* ========== 主内容区 ========== */
.main-content {
    margin-top: 56px;
    padding: 24px;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

/* ========== 页面标题 ========== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

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

/* ========== 卡片 ========== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: box-shadow 0.2s;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

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

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ========== 布局网格 ========== */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.view-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.view-tab {
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.view-tab:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.view-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 600;
}

.account-chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    background: #e0e7ff;
    color: #3730a3;
    margin-right: 4px;
}

.account-card {
    min-height: 120px;
}

.account-metric-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-top: 6px;
    font-size: 13px;
}

.account-metric-row.muted {
    color: var(--text-muted);
    font-size: 12px;
}

.account-metric-label {
    min-width: 56px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
}

.account-metric-value {
    font-weight: 600;
    color: var(--text-primary);
}

.account-metric-extra {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-muted);
}

.account-total-row {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
}

.account-total-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}

.account-total-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
}

.account-total-hint {
    font-size: 10px;
    color: var(--text-muted);
    width: 100%;
}

.account-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.account-card-head .stat-label {
    margin-bottom: 0;
}

.ccy-toggle {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
}

.ccy-btn {
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 600;
    border: none;
    background: var(--bg-card, #fff);
    color: var(--text-muted);
    cursor: pointer;
}

.ccy-btn.active {
    background: var(--accent);
    color: #fff;
}

.ccy-btn:hover:not(.active) {
    background: var(--bg-hover, #f1f5f9);
}

.page-subtitle .ccy-toggle {
    margin-left: 12px;
    vertical-align: middle;
}

/* ========== 统计数值 ========== */
.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 6px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-change {
    font-size: 12px;
    margin-top: 2px;
}

.text-up { color: var(--danger); }
.text-down { color: var(--success); }

/* ========== 颜色（中国习惯：红涨绿跌） ========== */
:root {
    --up: #dc2626;
    --down: #16a34a;
}
.text-up { color: var(--up); }
.text-down { color: var(--down); }

/* ========== 仓位徽章 ========== */
.watch-layer-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
}

/* ========== 表格 ========== */
table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    text-align: left;
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 1px solid var(--border);
}

tbody td {
    padding: 10px 12px;
    font-size: 13px;
    border-bottom: 1px solid #f1f5f9;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: #f8fafc;
}

/* ========== 徽章 ========== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success { background: #dcfce7; color: #16a34a; }
.badge-info { background: #dbeafe; color: #2563eb; }
.badge-danger { background: #fef2f2; color: #dc2626; }
.badge-warning { background: #fef3c7; color: #d97706; }
.badge-muted { background: #f1f5f9; color: #64748b; }

/* ========== 加载/错误 ========== */
.loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

.error-toast {
    position: fixed;
    top: 72px;
    right: 24px;
    background: #fef2f2;
    color: #dc2626;
    padding: 12px 20px;
    border-radius: 10px;
    border: 1px solid #fecaca;
    font-size: 13px;
    z-index: 300;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* ========== 按钮 ========== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid var(--border);
    background: white;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-outline { color: var(--text-secondary); background: transparent; }
.btn-outline:hover { background: #f1f5f9; color: var(--text-primary); }

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .topbar {
        padding: 0 12px;
        height: 52px;
        flex-wrap: wrap;
        height: auto;
        min-height: 52px;
        padding-top: 8px;
        padding-bottom: 8px;
        align-items: flex-start;
    }
    .topbar-menu-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .topbar-left {
        margin-right: 8px;
        flex: 1;
    }
    .topbar-subtitle {
        display: none;
    }
    .topbar-logo {
        font-size: 14px;
    }
    .topbar-nav {
        display: none;
        width: 100%;
        flex-direction: column;
        gap: 2px;
        order: 10;
        padding: 8px 0 4px;
        max-height: 70vh;
        overflow-y: auto;
    }
    .topbar.nav-open .topbar-nav {
        display: flex;
    }
    .topnav-item {
        padding: 10px 12px;
        font-size: 14px;
        width: 100%;
    }
    .topbar-user {
        margin-left: 0 !important;
    }
    .main-content {
        margin-top: 60px;
        padding: 12px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
    .page-title {
        font-size: 18px;
    }
}

/* ========== 监控指标栏 ========== */
.monitor-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e2e8f0;
    align-items: center;
}
.monitor-label {
    font-size: 10px;
    font-weight: 600;
    color: #94a3b8;
    letter-spacing: 0.5px;
    margin-right: 4px;
}
.monitor-item {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    background: #f1f5f9;
    color: #475569;
    white-space: nowrap;
    cursor: default;
}
.monitor-item.triggered {
    background: #fef2f2;
    color: #dc2626;
    font-weight: 500;
}
.monitor-item.more {
    background: #e2e8f0;
    color: #64748b;
    cursor: pointer;
}
.monitor-item.add {
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    border: 1px dashed #cbd5e1;
}
.monitor-item.add:hover {
    background: #f1f5f9;
    color: #475569;
}
