:root {
    --sidebar-bg: #1e2233;
    --sidebar-hover: #2a2f47;
    --sidebar-active: #3b82f6;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --bg: #f5f6f8;
    --card: #ffffff;
    --up: #ef4444;
    --down: #10b981;
    --primary: #3b82f6;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', 'Microsoft YaHei', -apple-system, sans-serif;
    color: var(--text);
    background: var(--bg);
    height: 100%;
}

.layout { display: flex; height: 100vh; overflow: hidden; }

/* ---------- 侧边栏 ---------- */
.sidebar {
    width: 240px;
    min-width: 240px;
    background: var(--sidebar-bg);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px;
    font-size: 17px;
    font-weight: 600;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.06);
}

.brand-logo { color: var(--primary); font-size: 20px; }

.nav { flex: 1; padding: 12px 0; overflow-y: auto; }

.nav-group { margin-bottom: 4px; }

.nav-group summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px 6px;
    font-size: 12px;
    color: #7c8698;
    text-transform: uppercase;
    letter-spacing: .5px;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.nav-group summary::-webkit-details-marker { display: none; }

.nav-group summary::before {
    content: '▸';
    font-size: 10px;
    margin-right: 2px;
    transition: transform .15s;
}

.nav-group[open] summary::before { transform: rotate(90deg); }

.nav-items { display: flex; flex-direction: column; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 14px;
    border-left: 3px solid transparent;
    transition: background .15s, color .15s;
}

.nav-item:hover { background: var(--sidebar-hover); color: #fff; }

.nav-item.active {
    background: var(--sidebar-hover);
    color: #fff;
    border-left-color: var(--primary);
}

.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
    padding: 14px 18px;
    font-size: 12px;
    color: #7c8698;
    border-top: 1px solid rgba(255,255,255,.06);
}

/* ---------- 主内容 ---------- */
.main { flex: 1; overflow-y: auto; }

.content { padding: 28px 32px; max-width: 1280px; }

.page-title { font-size: 24px; font-weight: 700; margin: 0 0 6px; }
.page-desc { color: var(--muted); margin: 0 0 22px; font-size: 14px; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
}

.card h2 { margin: 0 0 14px; font-size: 16px; }

/* ---------- 按钮 / 输入 ---------- */
button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    font-size: 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    cursor: pointer;
    transition: all .15s;
}

button:hover, .btn:hover { border-color: var(--primary); color: var(--primary); }

button.primary, .btn.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

button.primary:hover, .btn.primary:hover { background: #2563eb; color: #fff; }

button:disabled { opacity: .55; cursor: not-allowed; }

input[type=text], input[type=number], textarea, select {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    color: var(--text);
    background: #fff;
}

textarea { resize: vertical; min-height: 180px; line-height: 1.5; }

textarea.code, pre.code {
    font-family: 'Cascadia Code', Consolas, 'Courier New', monospace;
    font-size: 13px;
}

pre.code {
    background: #0f172a;
    color: #e2e8f0;
    padding: 16px;
    border-radius: 10px;
    overflow: auto;
    max-height: 480px;
    white-space: pre-wrap;
    word-break: break-all;
}

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }

/* ---------- 颜色 ---------- */
.up { color: var(--up); font-weight: 600; }
.down { color: var(--down); font-weight: 600; }
.flat { color: var(--muted); }
.muted { color: var(--muted); }

.error { color: #dc2626; background: #fef2f2; border: 1px solid #fecaca; padding: 12px; border-radius: 8px; margin: 12px 0; }
.success { color: #15803d; background: #f0fdf4; border: 1px solid #bbf7d0; padding: 12px; border-radius: 8px; margin: 12px 0; }

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; background: #fafafa; white-space: nowrap; }
tr:hover td { background: #f8fafc; }

/* ---------- 指数卡片 ---------- */
.indices { display: flex; gap: 14px; flex-wrap: wrap; }
.index-card {
    flex: 1;
    min-width: 150px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
}
.index-card .name { color: var(--muted); font-size: 13px; }
.index-card .price { font-size: 22px; font-weight: 700; margin: 6px 0 2px; }
.index-card .change { font-size: 13px; }

/* ---------- 热搜 / 资讯列表 ---------- */
.hot-list { list-style: none; margin: 0; padding: 0; }
.hot-list li { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px dashed var(--border); }
.rank {
    width: 26px; height: 26px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 6px; background: #eef2ff; color: #4f46e5;
    font-size: 13px; font-weight: 700;
}
.rank.top3 { background: #fee2e2; color: #dc2626; }
.hot-word { flex: 1; font-size: 14px; }
.hot-word a { color: var(--text); text-decoration: none; }
.hot-word a:hover { color: var(--primary); }
.hot-heat { color: var(--muted); font-size: 12px; white-space: nowrap; }

.news-list { list-style: none; margin: 0; padding: 0; }
.news-list li { padding: 12px 4px; border-bottom: 1px dashed var(--border); }
.news-title { font-size: 14px; font-weight: 600; }
.news-title a { color: var(--text); text-decoration: none; }
.news-title a:hover { color: var(--primary); }
.news-meta { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ---------- 图片预览 ---------- */
.preview-img {
    max-width: 100%;
    max-height: 480px;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-top: 14px;
}

/* ---------- 弹窗 ---------- */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15,23,42,.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
}
.modal {
    background: #fff;
    border-radius: 14px;
    padding: 24px;
    width: 560px;
    max-width: 92vw;
    max-height: 84vh;
    overflow: auto;
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.modal h3 { margin: 0 0 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

.search-row { display: flex; gap: 10px; }
.search-row input { flex: 1; }

/* ---------- 其他 ---------- */
.spinner {
    display: inline-block;
    width: 18px; height: 18px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.feature-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 22px;
    text-decoration: none;
    color: var(--text);
    transition: all .15s;
}
.feature-card:hover { border-color: var(--primary); box-shadow: 0 6px 18px rgba(59,130,246,.12); transform: translateY(-2px); }
.feature-card .icon { font-size: 30px; }
.feature-card .title { font-size: 16px; font-weight: 700; margin: 10px 0 6px; }
.feature-card .desc { font-size: 13px; color: var(--muted); line-height: 1.5; }

/* ---------- 认证页面 ---------- */
.auth-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e2233 0%, #2a2f47 50%, #3b82f6 130%);
    padding: 24px;
}
.auth-panel { width: 400px; max-width: 94vw; }
.auth-brand {
    color: #fff;
    font-size: 22px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 20px;
}
.auth-card {
    background: #fff;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.auth-card h2 { margin: 0 0 6px; font-size: 20px; }
.auth-card .muted { margin: 0 0 18px; }
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.checkbox { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-bottom: 14px; }
.checkbox input { width: auto; }
.btn-block { width: 100%; margin-top: 6px; }
.auth-links { display: flex; justify-content: space-between; margin-top: 16px; font-size: 13px; flex-wrap: wrap; gap: 8px; }
.auth-alt { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--border); }
.auth-alt-title { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.auth-alt-links { display: flex; gap: 14px; font-size: 13px; flex-wrap: wrap; }
.auth-alt-links a { color: var(--primary); text-decoration: none; }
.auth-alt-links a:hover { text-decoration: underline; }
.auth-links a { color: var(--primary); text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }
.code-row { display: flex; gap: 10px; }
.code-row input { flex: 1; }
.code-row button { white-space: nowrap; }
.qr-wrap {
    display: flex;
    justify-content: center;
    margin: 18px 0 8px;
}
.qr-wrap img { width: 220px; height: 220px; border: 1px solid var(--border); border-radius: 12px; padding: 8px; }

.nav-user {
    padding: 10px 18px 4px;
    font-size: 13px;
    color: #e2e8f0;
    font-weight: 600;
}
.nav-logout {
    width: calc(100% - 36px);
    margin: 6px 18px 4px;
    padding: 9px;
    font-size: 13px;
    background: transparent;
    color: #cbd5e1;
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
}
.nav-logout:hover { background: var(--sidebar-hover); color: #fff; }

/* ---------- 双栏布局（资讯 1/3 + 资金流入 2/3） ---------- */
.panel-row { display: flex; gap: 16px; align-items: stretch; flex-wrap: wrap; }
.panel-1-3 { flex: 1 1 260px; min-width: 260px; }
.panel-2-3 { flex: 2 1 520px; min-width: 340px; }
.panel-row .card { margin-bottom: 16px; }

.hint { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 8px; }

/* 精简资讯 */
.news-list.compact li { padding: 8px 2px; }
.news-list.compact .news-title {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    white-space: normal;
}
.news-list.compact .news-meta { font-size: 11px; }

/* 资金流入表格 */
.fund-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.fund-table th, .fund-table td { padding: 9px 8px; text-align: left; border-bottom: 1px solid var(--border); }
.fund-table th { color: var(--muted); font-weight: 600; background: #fafafa; white-space: nowrap; }
.fund-table tr:hover td { background: #f8fafc; }
.fund-name { font-weight: 600; }
.fund-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px; height: 22px;
    border-radius: 6px;
    background: #eef2ff; color: #4f46e5;
    font-size: 12px; font-weight: 700;
}
.fund-rank.top { background: #fee2e2; color: #dc2626; }
.panel-half { flex: 1 1 420px; min-width: 340px; }

.table-scroll { overflow-x: auto; }

/* 账户管理 */
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
@media (max-width: 640px) { .profile-grid { grid-template-columns: 1fr; } }
.profile-item label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.profile-val { font-size: 15px; font-weight: 600; }

.perm-list { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.perm-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}
.perm-item:hover { background: #f8fafc; }
.perm-item input { width: auto; }

.perm-group { margin-bottom: 8px; }
.perm-group-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin: 10px 0 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

/* 资讯摘要 */
.news-digest {
    font-size: 12px;
    color: var(--muted);
    margin: 3px 0;
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ---------- Work设置 ---------- */
.sidebar-footer { display: flex; flex-direction: column; gap: 4px; padding: 10px 0; }
.settings-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 14px;
    border-radius: 8px;
}
.settings-link:hover { background: var(--sidebar-hover); color: #fff; }
.settings-link.active { background: var(--sidebar-hover); color: #fff; }
.sidebar-copy { font-size: 11px; color: #7c8698; padding: 2px 18px 0; }

.settings-layout { display: flex; gap: 20px; align-items: flex-start; }
.settings-nav {
    width: 180px;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: sticky;
    top: 0;
}
.settings-nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    text-align: left;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
}
.settings-nav-item:hover { background: #f1f5f9; }
.settings-nav-item.active { background: var(--primary); color: #fff; }
.settings-nav-title {
    padding: 12px 14px 4px;
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .5px;
}
.settings-content { flex: 1; min-width: 0; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.checkbox-field { display: flex; align-items: flex-end; padding-bottom: 4px; }
.checkbox-field label { display: flex; align-items: center; gap: 6px; margin: 0; cursor: pointer; }
.checkbox-field input { width: auto; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    background: #eef2ff;
    color: #4f46e5;
    font-weight: 600;
}
