: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; }

/* ---------- 移动端顶栏 / 抽屉 ---------- */
.mobile-topbar { display: none; }
.nav-backdrop { display: none; }

/* ---------- 侧边栏 ---------- */
.sidebar {
    width: 248px;
    min-width: 248px;
    background: linear-gradient(180deg, #1d2233 0%, #171b2b 100%);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
    padding: 18px 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,.07);
}

.brand-logo {
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    border-radius: 10px;
    box-shadow: 0 4px 14px rgba(59,130,246,.45);
}

.brand-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.brand-name { font-size: 16px; font-weight: 700; color: #fff; line-height: 1.2; }
.brand-sub { font-size: 11px; color: #8b93a7; line-height: 1.2; }

.drawer-close { display: none; }

.nav { flex: 1 1 auto; min-height: 0; padding: 10px 0 12px; overflow-y: auto; overflow-x: hidden; }
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 3px; }
.nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.24); }

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

.nav-group summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 20px 6px;
    font-size: 12px;
    font-weight: 600;
    color: #7d8598;
    letter-spacing: .04em;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

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

.nav-group summary::after {
    content: '▸';
    margin-left: auto;
    font-size: 11px;
    color: #6b7280;
    transition: transform .2s ease;
}

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

.nav-items { display: flex; flex-direction: column; gap: 2px; padding: 2px 8px 6px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 14px;
    border-radius: 9px;
    transition: background .16s, color .16s;
}

.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }

.nav-item.active {
    background: linear-gradient(135deg, #3b82f6 0%, #2f6fed 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(59,130,246,.35);
}

.nav-icon { font-size: 17px; width: 22px; text-align: center; flex: 0 0 auto; }

.sidebar-footer {
    flex: 0 0 auto;
    padding: 12px 14px 14px;
    border-top: 1px solid rgba(255,255,255,.07);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 11px;
    background: rgba(255,255,255,.05);
}

.user-avatar {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #3b82f6);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
}

.user-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-name {
    font-size: 13px;
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-role { font-size: 11px; color: #8b93a7; }

.logout-form { margin: 0; flex: 0 0 auto; }
.logout-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #8b93a7;
    font-size: 15px;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.logout-btn:hover { background: rgba(239,68,68,.16); color: #fca5a5; }

/* ---------- 主内容 ---------- */
.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=password], input[type=tel], input[type=email], 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; }

/* ---------- 双栏布局（资讯 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设置 ---------- */
.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;
}

/* ---------- 文生视频 ---------- */
.field-row { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.field-label { width: 72px; flex: 0 0 auto; font-size: 13px; color: var(--muted); padding-top: 8px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; }
.chip {
    padding: 7px 14px;
    font-size: 13px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    cursor: pointer;
    transition: all .15s;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.upload-thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.upload-thumb { position: relative; width: 96px; height: 96px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.upload-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-remove {
    position: absolute; top: 4px; right: 4px;
    width: 22px; height: 22px; padding: 0;
    display: flex; align-items: center; justify-content: center;
    border: none; border-radius: 50%;
    background: rgba(15,23,42,.65); color: #fff;
    font-size: 12px; cursor: pointer;
}
.thumb-remove:hover { background: #dc2626; color: #fff; }

.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.video-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: #fff; }
.video-preview { width: 100%; border-radius: 10px; border: 1px solid var(--border); background: #0f172a; display: block; }
.video-title { font-size: 14px; font-weight: 700; margin: 10px 0 2px; }
.video-desc { font-size: 12px; color: var(--muted); margin-bottom: 10px; }

/* ---------- 移动端适配 ---------- */
@media (max-width: 768px) {
    .mobile-topbar {
        display: flex;
        align-items: center;
        gap: 10px;
        height: 52px;
        padding: 0 14px;
        background: linear-gradient(180deg, #1d2233, #171b2b);
        color: #fff;
    }
    .mobile-logo {
        width: 26px;
        height: 26px;
        flex: 0 0 auto;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 14px;
        color: #fff;
        background: linear-gradient(135deg, #3b82f6, #6366f1);
        border-radius: 7px;
    }
    .mobile-topbar .mobile-title { font-size: 16px; font-weight: 600; }
    .hamburger {
        background: transparent;
        border: none;
        color: #fff;
        font-size: 22px;
        line-height: 1;
        padding: 6px 8px;
        margin-left: -8px;
        border-radius: 8px;
        cursor: pointer;
    }
    .hamburger:hover { border: none; color: #fff; background: rgba(255,255,255,.1); }

    .drawer-close {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 30px;
        height: 30px;
        padding: 0;
        margin-left: auto;
        background: rgba(255,255,255,.08);
        border: none;
        border-radius: 8px;
        color: #cbd5e1;
        font-size: 14px;
        cursor: pointer;
    }
    .drawer-close:hover { background: rgba(255,255,255,.16); color: #fff; border: none; }

    .layout { flex-direction: column; }

    .sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: 264px;
        min-width: 264px;
        z-index: 70;
        transform: translateX(-100%);
        transition: transform .25s ease;
    }
    body.nav-open .sidebar {
        transform: translateX(0);
        box-shadow: 0 0 42px rgba(0,0,0,.45);
    }

    .nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15,23,42,.5);
        backdrop-filter: blur(3px);
        -webkit-backdrop-filter: blur(3px);
        z-index: 65;
        opacity: 0;
        pointer-events: none;
        transition: opacity .25s ease;
    }
    body.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }

    .main { min-height: 0; }

    .content { padding: 18px 14px 28px; }
    .page-title { font-size: 20px; }
    .page-desc { font-size: 13px; }

    .card { padding: 16px; }
    .modal { padding: 18px; }
    .field-row { flex-direction: column; gap: 4px; }
    .field-label { padding-top: 0; width: auto; }

    .settings-layout { flex-direction: column; }
    .settings-nav {
        width: 100%;
        min-width: 0;
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        position: static;
        padding-bottom: 2px;
        gap: 6px;
    }
    .settings-nav-item { white-space: nowrap; flex: 0 0 auto; }
    .settings-nav-title { display: none; }

    /* 移动端表格横向滚动，避免挤压列宽 */
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    .table-scroll { -webkit-overflow-scrolling: touch; }
    .search-row { flex-direction: column; }
    .search-row button { width: 100%; }
    .code-row { flex-wrap: wrap; }

    .auth-card { padding: 24px 20px; }
    .qr-wrap img { width: 180px; height: 180px; }
}
