/* ═══════════════════════════════════════════════════════════════
   SQT Portal — Institutional Dashboard Design System
   "Data-Driven, Calm, Trustworthy"
   ═══════════════════════════════════════════════════════════════ */

@import url('/static/fonts/fonts.css');

/* ── Design Tokens ── */
:root {
    --font-display: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', Monaco, Consolas, monospace;
}

:root {
    /* Base Mode (Light by default for a clean SaaS look) */
    --bg-body: #f7f9fc;
    --bg-surface: #ffffff;
    --bg-sidebar: #f1f5f9;
    --bg-elevated: #ffffff;
    --bg-hover: #f1f5f9;
    --bg-active: #e2e8f0;
    --bg-input: #ffffff;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-inverse: #ffffff;

    --border: #dde3ec;
    --border-light: #f1f5f9;
    --border-focus: #94a3b8;

    --primary: #0f62fe;
    --primary-hover: #0353e9;
    --primary-muted: rgba(15, 98, 254, 0.1);

    --accent: #0f62fe; /* Professional blue */
    --accent-hover: #0353e9;
    --accent-muted: rgba(15, 98, 254, 0.1);
    --accent-2: #00c49a; /* Teal data highlight */

    --danger: #ef4444;
    --danger-hover: #dc2626;
    --danger-muted: rgba(239, 68, 68, 0.1);

    --success: #10b981;
    --success-muted: rgba(16, 185, 129, 0.1);

    --warning: #f59e0b;
    --warning-muted: rgba(245, 158, 11, 0.1);

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 2px rgba(0,0,0,0.05), 0 4px 12px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);

    --radius-xs: 6px;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --sidebar-w: 240px;
    --topbar-h: 52px;

    color-scheme: light;
}

[data-theme="dark"] {
    --bg-body: #060a14;
    --bg-surface: #0d1424;
    --bg-sidebar: #080c1a;
    --bg-elevated: #121929;
    --bg-hover: #162032;
    --bg-active: #1e2d45;
    --bg-input: #0d1424;

    --text-primary: #f1f5fb;
    --text-secondary: #b0c4e8;
    --text-muted: #7b8fad;
    --text-inverse: #ffffff;

    --border: #1e2d45;
    --border-light: #162032;
    --border-focus: #2d4270;

    --primary: #4f9cff;
    --primary-hover: #6eaeff;
    --primary-muted: rgba(79, 156, 255, 0.12);

    --accent: #4f9cff;
    --accent-hover: #6eaeff;
    --accent-muted: rgba(79, 156, 255, 0.15);
    --accent-2: #00d4aa; /* Teal for success states / data highlights */

    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.6);
    --shadow: 0 1px 3px 0 rgba(0,0,0,0.6);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.6);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.6);

    color-scheme: dark;
}

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

body {
    font-family: var(--font-body);
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.5;
    font-size: 14px;
    font-weight: 400;
    letter-spacing: 0.01em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Typography & Links ── */
a { color: var(--text-primary); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent); }
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 800;
    letter-spacing: -0.03em;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-focus); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ═══════════════════ SIDEBAR ═══════════════════ */
.sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: var(--sidebar-w);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    z-index: 40;
}
[data-theme="dark"] .sidebar {
    background: linear-gradient(180deg, #080c1a 0%, #060a14 100%);
    border-right: 1px solid rgba(79,156,255,0.08);
}

.sidebar-brand {
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 10px;
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
}
.brand-logo-box {
    width: 28px; height: 28px;
    background-color: var(--primary);
    color: var(--text-inverse);
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px;
}
.brand-text { font-size: 15px; font-weight: 600; letter-spacing: -0.02em; }
.brand-light { color: var(--text-secondary); font-weight: 400; }

.sidebar-nav {
    flex: 1; padding: 12px 10px; overflow-y: auto;
    display: flex; flex-direction: column; gap: 2px;
}

.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    border-left: 2px solid transparent;
    transition: all 0.2s ease;
}
.nav-item:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    border-left-color: var(--border-focus);
}
.nav-item.active {
    background-color: var(--bg-active);
    color: var(--text-primary);
    font-weight: 700;
    border-left-color: var(--primary);
}
.nav-item svg { flex-shrink: 0; color: var(--text-muted); }
.nav-item.active svg { color: var(--text-primary); }

/* ── Nav Groups ── */
.nav-group {
    margin-bottom: 4px;
}
.nav-group-title {
    padding: 14px 14px 4px 14px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    text-transform: uppercase;
    user-select: none;
}
.nav-group:first-child .nav-group-title {
    padding-top: 4px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.user-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background-color: var(--primary-muted);
    border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 13px; color: var(--text-primary);
}
.user-detail { min-width: 0; display: flex; flex-direction: column; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { margin-top: 2px; }

.btn-logout {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; padding: 6px; border-radius: var(--radius-sm);
    transition: all 0.2s;
}
.btn-logout:hover { color: var(--text-primary); background-color: var(--bg-hover); }

/* ═══════════════════ MAIN CONTENT ═══════════════════ */
.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex; flex-direction: column;
}
[data-theme="dark"] .main-content {
    background:
        radial-gradient(ellipse 80% 50% at 70% 10%, rgba(79,156,255,0.06) 0%, transparent 60%),
        radial-gradient(ellipse 50% 40% at 20% 80%, rgba(0,212,170,0.04) 0%, transparent 50%),
        #060a14;
}

.top-bar {
    height: var(--topbar-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 32px;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 30;
    background: var(--bg-body);
    gap: 16px;
    flex-shrink: 0;
}
[data-theme="dark"] .top-bar {
    background: rgba(6,10,20,0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(79,156,255,0.1);
}
.page-title {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    margin: 0;
}
[data-theme="dark"] .page-title {
    background: linear-gradient(135deg, #e8edf5 0%, #93c5fd 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.theme-toggle-btn {
    background: transparent; border: 1px solid var(--border);
    color: var(--text-muted); cursor: pointer;
    width: 32px; height: 32px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s ease;
}
.theme-toggle-btn:hover { background-color: var(--bg-hover); color: var(--text-primary); border-color: var(--border-focus); }

.content-body { padding: 20px 24px; flex: 1; overflow: auto; }

/* ═══════════════════ CARDS ═══════════════════ */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: box-shadow 0.2s, border-color 0.2s;
}
[data-theme="dark"] .card {
    background: linear-gradient(145deg, #0d1424 0%, #0a1020 100%);
    border-color: rgba(79,156,255,0.12);
    box-shadow: 0 1px 0 0 rgba(79,156,255,0.08) inset, 0 4px 24px rgba(0,0,0,0.4);
}
[data-theme="dark"] .card:hover {
    border-color: rgba(79,156,255,0.22);
    box-shadow: 0 1px 0 0 rgba(79,156,255,0.12) inset, 0 8px 32px rgba(0,0,0,0.5);
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px;
}
.card-header h3 { font-size: 16px; margin: 0; }

/* ═══════════════════ TABLES ═══════════════════ */
.table-responsive { overflow-x: auto; margin: -12px; padding: 12px; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table thead tr { background: var(--bg-elevated); }
.data-table th {
    padding: 10px 14px;
    font-size: 11px; font-weight: 700;
    letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: 9px 14px;
    font-weight: 400;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}
.data-table tbody tr { transition: background 0.1s; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-hover); cursor: default; }
.data-table tbody tr:hover td { background-color: var(--bg-hover); color: var(--text-primary); }
/* Zebra stripe */
.data-table tbody tr:nth-child(even) { background: rgba(0,0,0,0.015); }
[data-theme="dark"] .data-table tbody tr:nth-child(even) { background: rgba(255,255,255,0.015); }
/* Numeric utility column */
.num-cell { font-family: 'JetBrains Mono', monospace; font-weight: 600; text-align: right; }

/* ═══════════════════ BUTTONS ═══════════════════ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600; letter-spacing: 0.02em;
    border: 1px solid transparent;
    user-select: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:not(:disabled):hover { transform: translateY(-1px); }

.btn-primary { background-color: var(--primary); color: var(--text-inverse); box-shadow: var(--shadow-sm); font-weight: 700; letter-spacing: 0.02em; }
.btn-primary:hover:not(:disabled) { background-color: var(--primary-hover); }

.btn-danger { background-color: var(--danger); color: white; box-shadow: var(--shadow-sm); }
.btn-danger:hover:not(:disabled) { background-color: var(--danger-hover); }

.btn-outline { background-color: transparent; border-color: var(--border); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.btn-outline:hover:not(:disabled) { background-color: var(--bg-hover); border-color: var(--border-focus); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; border-color: var(--border); background-color: var(--bg-surface); color: var(--text-secondary); box-shadow: none; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.btn-group .btn:hover { background-color: var(--bg-hover); z-index: 1; }
.btn-group .btn.active { background-color: var(--primary); color: var(--text-inverse); border-color: var(--primary); z-index: 2; }

/* ═══════════════════ FORMS ═══════════════════ */
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block; font-size: 13px; font-weight: 500;
    color: var(--text-primary); margin-bottom: 8px;
}
input[type="text"], input[type="password"], input[type="email"],
input[type="number"], input[type="search"], select, textarea {
    width: 100%; padding: 10px 12px;
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary); font-size: 14px;
    font-family: inherit;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }

/* ═══════════════════ BADGES ═══════════════════ */
.badge {
    display: inline-flex; align-items: center;
    padding: 3px 10px; border-radius: 9999px;
    font-size: 11px; font-weight: 700; line-height: 1.5;
}
.badge-super_admin { background-color: var(--danger-muted); color: var(--danger); }
.badge-admin { background-color: var(--accent-muted); color: var(--accent); }
.badge-user { background-color: var(--primary-muted); color: var(--text-secondary); }

/* ═══════════════════ MODALS ═══════════════════ */
.modal-overlay {
    display: none; position: fixed; inset: 0; z-index: 1000;
    background-color: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
    align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.2s ease;
}
.modal-overlay.show { display: flex; opacity: 1; }

.modal {
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%; max-width: 480px; max-height: 90vh;
    box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column;
    transform: scale(0.95); transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-overlay.show .modal { transform: scale(1); }
.modal-wide { max-width: 800px; }

.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; margin: 0; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; border-radius: var(--radius-sm); transition: background-color 0.2s; }
.modal-close:hover { background-color: var(--bg-hover); color: var(--text-primary); }
.modal-body { padding: 24px; overflow-y: auto; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 12px; background-color: var(--bg-sidebar); border-bottom-left-radius: var(--radius-lg); border-bottom-right-radius: var(--radius-lg); }

/* ═══════════════════ TOAST ═══════════════════ */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
    padding: 12px 16px; background-color: var(--bg-elevated);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    font-size: 13px; font-weight: 500; color: var(--text-primary);
    pointer-events: auto; cursor: pointer;
    min-width: 280px; max-width: 400px;
    transform: translateY(100%); opacity: 0; transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast.toast-visible { transform: translateY(0); opacity: 1; }
.toast.toast-exit { transform: scale(0.9); opacity: 0; }
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-info { border-left: 3px solid var(--accent); }

/* ═══════════════════ GRIDS ═══════════════════ */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ═══════════════════ PAGE COMPONENTS ═══════════════════ */

/* Page Header */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}
.page-header-info {
    flex: 1;
    min-width: 0;
}
.page-header-title {
    font-family: var(--font-display) !important;
    font-size: 28px !important;
    font-weight: 900 !important;
    letter-spacing: -0.04em !important;
    line-height: 1.1 !important;
    color: var(--text-primary);
    margin: 0;
}
[data-theme="dark"] .page-header-title {
    background: linear-gradient(135deg, #e8edf5 0%, #93c5fd 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.page-header-desc {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 4px;
    letter-spacing: 0.01em;
    line-height: 1.4;
}
.page-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Summary Strip */
.summary-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

/* Section Card */
.section-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}
.section-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.section-card-body {
    padding: 16px;
}
.section-card-body:empty {
    display: none;
}

/* Empty & Error States */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    color: var(--text-muted);
    gap: 12px;
    text-align: center;
}
.empty-state svg { opacity: 0.3; }
.empty-state p { font-size: 14px; }

.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    color: var(--danger);
    gap: 12px;
    text-align: center;
}
.error-state p { font-size: 14px; color: var(--text-secondary); }

/* ═══════════════════ STAT CARDS ═══════════════════ */
.stat-card {
    padding: 20px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column;
}
.stat-card .stat-icon { color: var(--text-muted); margin-bottom: 12px; }
.stat-label { font-size: 11px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; font-family: 'JetBrains Mono', monospace; letter-spacing: -0.02em; }

/* ═══════════════════ LOGIN PAGE ═══════════════════ */
.login-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
    background-color: var(--bg-sidebar);
    padding: 24px;
    /* 不要让 footer 影响卡片居中 */
}
.login-container {
    width: 100%; max-width: 400px;
    display: flex; flex-direction: column; align-items: center;
}
.login-card {
    width: 100%;
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-lg);
}
.login-footer {
    margin-top: 24px; font-size: 11px; color: var(--text-muted); text-align: center;
    /* footer 在卡片下方，不影响居中 */
}
.login-brand { display: flex; flex-direction: column; align-items: center; margin-bottom: 32px; text-align: center; }
.login-logo {
    width: 48px; height: 48px; background-color: var(--primary); color: var(--text-inverse);
    border-radius: 12px; display: flex; align-items: center; justify-content: center;
    font-size: 24px; font-weight: 700; margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}
.login-brand h1 { font-size: 20px; color: var(--text-primary); }
.login-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.login-error { color: var(--danger); font-size: 13px; text-align: center; min-height: 20px; margin-bottom: 16px; }

/* ═══════════════════ DOCUMENT EDITOR ═══════════════════ */
.doc-layout { display: flex; height: calc(100vh - var(--topbar-h) - 64px); border: 1px solid var(--border); border-radius: var(--radius-lg); background-color: var(--bg-surface); overflow: hidden; box-shadow: var(--shadow-sm); }
.doc-sidebar { width: 280px; border-right: 1px solid var(--border); display: flex; flex-direction: column; background-color: var(--bg-sidebar); }
.doc-sidebar-header { padding: 16px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.category-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-btn { padding: 4px 10px; font-size: 12px; font-weight: 500; border-radius: 9999px; background-color: transparent; color: var(--text-secondary); border: 1px solid transparent; cursor: pointer; transition: all 0.2s; }
.filter-btn:hover { background-color: var(--bg-hover); color: var(--text-primary); }
.filter-btn.active { background-color: var(--primary); color: var(--text-inverse); }

.doc-list { flex: 1; overflow-y: auto; padding: 12px; }
.doc-item { padding: 12px; border-radius: var(--radius-sm); cursor: pointer; margin-bottom: 4px; transition: background 0.2s; }
.doc-item:hover { background-color: var(--bg-hover); }
.doc-item.active { background-color: var(--bg-active); }
.doc-item-title { font-size: 14px; font-weight: 500; color: var(--text-primary); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-item-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); }
.cat-badge { font-weight: 500; color: var(--text-secondary); }

.doc-editor-area { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.doc-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.doc-empty-inner { text-align: center; }
.doc-empty-inner p { margin-top: 16px; font-size: 14px; }
.doc-editor-container { display: none; flex-direction: column; flex: 1; overflow: hidden; }
.doc-editor-container.show { display: flex; }
.doc-editor-toolbar {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
}
.doc-editor-toolbar #docTitle {
    flex: 1 1 100%;
    font-size: 20px; font-weight: 600;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 6px);
    background-color: var(--bg-input, #fff);
    color: var(--text-primary);
    min-width: 0;
}
.doc-editor-toolbar #docTitle:focus {
    border-color: var(--accent, #2563eb);
    outline: none;
    box-shadow: 0 0 0 1px var(--accent, #2563eb);
}
.doc-editor-toolbar #docCategory {
    width: auto; min-width: 120px;
}
.toolbar-actions { display: flex; gap: 6px; flex-shrink: 0; }
.doc-editor-body { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.doc-editor-body .ql-container.ql-snow { border: none !important; flex: 1; overflow-y: auto; font-size: 15px; font-family: inherit; min-height: 0; }
.doc-editor-body .ql-editor { padding: 24px 32px; line-height: 1.8; color: var(--text-secondary); min-height: 200px; }

/* File upload */
.file-drop-zone { border: 1px dashed var(--border-focus); border-radius: var(--radius); padding: 32px; text-align: center; color: var(--text-secondary); cursor: pointer; transition: all 0.2s; margin-bottom: 16px; background-color: var(--bg-sidebar); }
.file-drop-zone:hover, .file-drop-zone.dragover { border-color: var(--primary); background-color: var(--bg-hover); }
.attachment-list { display: flex; flex-direction: column; gap: 8px; }
.attachment-item { display: flex; align-items: center; justify-content: space-between; padding: 12px; background-color: var(--bg-sidebar); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; }

/* ═══════════════════ ATTACHMENT MANAGER (双栏) ═══════════════════ */
.att-manager-modal { max-width: 1100px; width: 95vw; height: 78vh; display: flex; flex-direction: column; }
.att-manager-body { display: flex; flex: 1; min-height: 0; overflow: hidden; }

/* 左栏 */
.att-sidebar { width: 320px; min-width: 280px; border-right: 1px solid var(--border); display: flex; flex-direction: column; background-color: var(--bg-sidebar); }
.att-upload-zone {
    display: flex; align-items: center; gap: 8px; padding: 12px 16px; margin: 12px; cursor: pointer;
    border: 1px dashed var(--border-focus); border-radius: var(--radius-sm);
    color: var(--text-secondary); font-size: 13px; transition: all 0.2s;
}
.att-upload-zone:hover { border-color: var(--primary); background-color: var(--bg-hover); color: var(--text-primary); }
.att-file-list { flex: 1; overflow-y: auto; padding: 0 12px 12px; }

.att-list-item {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    border-radius: var(--radius-sm); cursor: pointer; transition: background 0.15s;
    margin-bottom: 2px; border: 1px solid transparent;
}
.att-list-item:hover { background-color: var(--bg-hover); }
.att-list-item.att-item-active { background-color: var(--bg-active); border-color: var(--border); }
.att-item-icon { flex-shrink: 0; color: var(--text-muted); }
.att-item-info { flex: 1; min-width: 0; }
.att-item-name { font-size: 13px; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-item-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.att-item-actions { display: flex; gap: 4px; flex-shrink: 0; opacity: 0; transition: opacity 0.15s; }
.att-list-item:hover .att-item-actions { opacity: 1; }

/* 右栏: 预览 */
.att-preview-panel { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.att-preview-head {
    padding: 12px 20px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px; min-height: 48px;
}
.att-ph-name { font-size: 14px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-ph-meta { font-size: 12px; color: var(--text-muted); flex-shrink: 0; }
.att-ph-actions { margin-left: auto; display: flex; gap: 6px; flex-shrink: 0; }
.att-preview-body { flex: 1; overflow-y: auto; padding: 0; position: relative; }
.att-preview-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-muted); font-size: 14px; }
.att-preview-loading { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-muted); }

/* 预览 tabs */
.att-preview-tabs { display: flex; border-bottom: 1px solid var(--border); padding: 0 20px; }
.att-tab { padding: 8px 16px; font-size: 13px; font-weight: 500; color: var(--text-muted); background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer; transition: all 0.2s; }
.att-tab:hover { color: var(--text-primary); }
.att-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.att-tab-panel { padding: 20px; overflow-y: auto; max-height: calc(78vh - 160px); }

/* 代码查看器 */
.att-code-view {
    white-space: pre-wrap; word-break: break-all;
    padding: 20px; margin: 0;
    font-family: 'JetBrains Mono', 'SF Mono', Monaco, Consolas, monospace;
    font-size: 13px; line-height: 1.6;
    background-color: var(--bg-input); color: var(--text-primary);
    border-radius: var(--radius-sm); border: 1px solid var(--border);
    overflow-y: auto; max-height: calc(78vh - 180px);
}

/* ══ Attachment Markdown Preview — rich rendering ══ */
/* Uses .att-md-content class, shares visual style with docs-content */
.att-md-content {
    padding: 20px 24px;
    font-family: 'DM Sans', -apple-system, sans-serif;
    font-size: 14.5px;
    line-height: 1.7;
    color: var(--text-primary);
}
.att-md-content h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 12px; padding-bottom: 8px; border-bottom: 2px solid var(--border); }
.att-md-content h2 { font-size: 18px; font-weight: 600; margin: 22px 0 10px; padding-bottom: 5px; border-bottom: 1px solid var(--border); }
.att-md-content h3 { font-size: 16px; font-weight: 600; margin: 18px 0 8px; }
.att-md-content h4 { font-size: 14.5px; font-weight: 600; margin: 14px 0 6px; }
.att-md-content p  { margin: 0 0 12px; }
.att-md-content ul, .att-md-content ol { margin: 0 0 12px; padding-left: 22px; }
.att-md-content li { margin-bottom: 4px; }
.att-md-content blockquote {
    border-left: 3px solid var(--primary);
    padding: 8px 14px; margin: 0 0 12px;
    background: var(--bg-sidebar); border-radius: 0 6px 6px 0;
    font-size: 13.5px; color: var(--text-secondary);
}
.att-md-content table { border-collapse: collapse; width: 100%; margin: 0 0 12px; font-size: 13px; }
.att-md-content th, .att-md-content td { border: 1px solid var(--border); padding: 6px 12px; text-align: left; }
.att-md-content th { background: var(--bg-elevated); font-weight: 600; }
.att-md-content tr:nth-child(even) td { background: var(--bg-hover); }
.att-md-content hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.att-md-content a  { color: var(--primary); text-decoration: none; }
.att-md-content a:hover { text-decoration: underline; }
.att-md-content strong { font-weight: 700; }
.att-md-content em    { font-style: italic; }

/* inline code in attachment preview */
.att-md-content code {
    font-family: 'JetBrains Mono', Consolas, monospace;
    font-size: 12.5px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    padding: 1px 5px; border-radius: 4px;
    color: var(--primary);
}

/* ── VSCode-style syntax tokens (used in both att + docs code blocks) ── */
.sl-kw   { color: #569cd6; }        /* keywords */
.sl-str  { color: #ce9178; }        /* strings */
.sl-num  { color: #b5cea8; }        /* numbers */
.sl-cmt  { color: #6a9955; font-style: italic; }  /* comments */
.sl-fn   { color: #dcdcaa; }        /* functions */
.sl-type { color: #4ec9b0; }        /* types / builtins */
.sl-op   { color: #d4d4d4; }        /* operators */
.sl-re   { color: #d16969; }        /* regex / special */
.sl-bool { color: #569cd6; font-weight: 600; }     /* true/false/null */
.sl-attr { color: #9cdcfe; }        /* object keys / attributes */
.sl-punc { color: #d4d4d4; }        /* punctuation */


@media (max-width: 768px) {
    .att-manager-modal { height: 90vh; }
    .att-manager-body { flex-direction: column; }
    .att-sidebar { width: 100%; min-width: 0; max-height: 40%; border-right: none; border-bottom: 1px solid var(--border); }
}

/* ═══════════════════ MONITOR ═══════════════════ */
.conn-status { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px; background-color: var(--bg-surface); border: 1px solid var(--border); border-radius: 9999px; font-size: 12px; font-weight: 500; margin-bottom: 24px; box-shadow: var(--shadow-sm); }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; }
.conn-dot.connected { background-color: var(--success); box-shadow: 0 0 0 3px var(--success-muted); }
.conn-dot.disconnected { background-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-muted); }

.monitor-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; margin-bottom: 32px; }
.chart-container { height: 320px; position: relative; margin-top: 16px; }

.risk-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px; }
.risk-item { padding: 16px; background-color: var(--bg-sidebar); border-radius: var(--radius-sm); border: 1px solid var(--border); text-align: center; }
.risk-value { font-size: 18px; font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.risk-label { font-size: 11px; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500; }

.account-card { background-color: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.account-card-header { padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; transition: background 0.2s; }
.account-card-header:hover { background-color: var(--bg-hover); }
.account-name { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.exchange-badge { padding: 3px 10px; border-radius: 4px; font-size: 11px; font-weight: 600; border: 1px solid var(--border); background-color: var(--bg-sidebar); margin-left: 8px; }
.account-card-body { padding: 20px; border-top: 1px solid var(--border); display: none; }
.account-card-body.open { display: block; }
.account-stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px; margin-bottom: 24px; }
.account-stat { border-left: 2px solid var(--border); padding-left: 12px; }

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

/* ═══════════════════ API PANEL ═══════════════════ */
.quota-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 32px; }
.quota-card {
    background-color: var(--bg-surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm);
}
.quota-icon { margin-bottom: 12px; color: var(--text-muted); }
.quota-value { font-size: 24px; font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.quota-label { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

.tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tab-item { padding: 12px 16px; font-size: 14px; font-weight: 500; color: var(--text-secondary); background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer; transition: all 0.2s; margin-bottom: -1px; }
.tab-item:hover { color: var(--text-primary); }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }

.token-key { font-family: 'JetBrains Mono', monospace; font-size: 12px; padding: 2px 6px; background-color: var(--bg-sidebar); border: 1px solid var(--border); border-radius: 4px; color: var(--text-secondary); }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.status-dot.active { background-color: var(--success); }
.status-dot.disabled { background-color: var(--text-muted); }
.log-model { font-family: 'JetBrains Mono', monospace; font-size: 12px; }

/* Responsive */
@media (max-width: 1024px) {
    .grid-3, .grid-4, .monitor-summary, .risk-grid { grid-template-columns: repeat(2, 1fr); }
    .account-stats { grid-template-columns: repeat(3, 1fr); }
}
.mobile-menu-btn { display: none; }
.mobile-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 49; }
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .mobile-menu-btn { display: block; position: fixed; top: 12px; left: 16px; z-index: 50; background-color: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px; box-shadow: var(--shadow-sm); cursor: pointer; }
    .mobile-overlay.active { display: block; }
    .main-content { margin-left: 0; }
    .top-bar { padding-left: 64px; }
    .content-body { padding: 16px; }
    .grid-2, .grid-3, .grid-4, .monitor-summary, .risk-grid, .account-stats { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; gap: 12px; }
    .page-header-actions { width: 100%; }
    .summary-strip { grid-template-columns: repeat(2, 1fr); }
    .module-grid { grid-template-columns: 1fr; }
    .doc-layout { flex-direction: column; height: auto; min-height: calc(100vh - 120px); }
    .doc-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
}

/* ═══════════════════════════════════════════════════════════════
   PATCH — Dark Mode Completeness + Layout Shift Prevention
   Applied: 2026-04-04
   ═══════════════════════════════════════════════════════════════ */

/* ── 1a. Data tables — sticky thead transparency fix ── */
[data-theme="dark"] .data-table thead th {
    background-color: var(--bg-elevated);
}
[data-theme="dark"] .data-table tr:hover td {
    background-color: var(--bg-hover);
}

/* ── 1b. Quill editor ── */
[data-theme="dark"] .ql-toolbar.ql-snow {
    background: var(--bg-elevated) !important;
    border-color: var(--border) !important;
}
[data-theme="dark"] .ql-container.ql-snow {
    border-color: var(--border) !important;
}
[data-theme="dark"] .ql-editor {
    color: var(--text-primary) !important;
    background: var(--bg-surface) !important;
}
[data-theme="dark"] .ql-snow .ql-stroke { stroke: var(--text-muted) !important; }
[data-theme="dark"] .ql-snow .ql-fill { fill: var(--text-muted) !important; }
[data-theme="dark"] .ql-snow .ql-picker { color: var(--text-muted) !important; }
[data-theme="dark"] .ql-snow .ql-picker-options {
    background: var(--bg-elevated) !important;
    border-color: var(--border) !important;
}

/* ── 1c. Markdown preview & doc reader ── */
[data-theme="dark"] .md-preview,
[data-theme="dark"] .doc-reader-content {
    color: var(--text-primary);
}
[data-theme="dark"] .md-preview code,
[data-theme="dark"] .doc-reader-content code {
    background: var(--bg-elevated);
    border-color: var(--border-light);
    color: var(--primary);
}
[data-theme="dark"] .md-preview pre,
[data-theme="dark"] .doc-reader-content pre,
[data-theme="dark"] .md-code-block {
    background: var(--bg-elevated);
    border-color: var(--border-light);
    color: var(--text-primary);
}
[data-theme="dark"] .md-preview blockquote,
[data-theme="dark"] .doc-reader-content blockquote {
    background: var(--bg-elevated);
    border-left-color: var(--primary);
    color: var(--text-secondary);
}
[data-theme="dark"] .md-preview th {
    background: var(--bg-elevated);
}
[data-theme="dark"] .md-preview td,
[data-theme="dark"] .md-preview th {
    border-color: var(--border);
}

/* ── 1d. Modal ── */
[data-theme="dark"] .modal {
    background: var(--bg-elevated);
    border-color: var(--border);
}
[data-theme="dark"] .modal-header {
    border-bottom-color: var(--border);
}
[data-theme="dark"] .modal-footer {
    border-top-color: var(--border);
}

/* ── 1e. Select option ── */
[data-theme="dark"] select option {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

/* ── 1f. Chart.js containers ── */
[data-theme="dark"] .fl-chart-section {
    background: var(--bg-elevated);
    border-color: var(--border-light);
}
[data-theme="dark"] .fl-chart-canvas-wrap canvas {
    background: var(--bg-elevated);
}

/* ── 1g. ClickHouse & factor library overview/stat cards ── */
[data-theme="dark"] .ch-overview-card,
[data-theme="dark"] .fl-overview-card {
    background: var(--bg-elevated);
    border-color: var(--border-light);
}
[data-theme="dark"] .ch-stat-card,
[data-theme="dark"] .fl-stat-card {
    background: var(--bg-elevated);
    border-color: var(--border-light);
}

/* ── 1h. Tab content areas ── */
[data-theme="dark"] .ch-tab-content,
[data-theme="dark"] .ch-tabs,
[data-theme="dark"] .fl-tab-body,
[data-theme="dark"] .fl-tabs {
    background: var(--bg-surface);
    border-color: var(--border);
}
[data-theme="dark"] .ch-type-badge,
[data-theme="dark"] .fl-mono {
    background: var(--bg-elevated);
    border-color: var(--border-light);
    color: var(--text-secondary);
}

/* ── 1i. Factor library specific ── */
[data-theme="dark"] .fl-dist-section {
    background: var(--bg-elevated);
    border-color: var(--border-light);
}
[data-theme="dark"] .fl-bar-track {
    background: var(--bg-surface);
}
[data-theme="dark"] .fl-pane {
    background: var(--bg-surface);
}

/* ── 2a. Layout shift prevention — page-header min-height ── */
.page-header {
    min-height: 52px;
}
.page-header-title {
    line-height: 1.3;
}
.page-header-desc {
    min-height: 1.4em;
    line-height: 1.4;
}

/* ── 2c. Sidebar nav item consistent height ── */
.nav-item {
    min-height: 36px;
}

/* ═══════════════════ DARK MODE ENHANCEMENTS ═══════════════════ */
[data-theme="dark"] .card {
    box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.03);
}

/* ═══════════════════ PAGE ENTRANCE ANIMATION ═══════════════════ */
.content-body > * {
    animation: portalFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.content-body > *:nth-child(1) { animation-delay: 0.05s; }
.content-body > *:nth-child(2) { animation-delay: 0.10s; }
.content-body > *:nth-child(3) { animation-delay: 0.15s; }
.content-body > *:nth-child(n+4) { animation-delay: 0.20s; }

@keyframes portalFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@media (prefers-reduced-motion: reduce) {
    .content-body > * { animation: none; }
}

/* ═══════════════════════════════════════════════════════════════
   补充样式 — 模板使用但原 CSS 中缺失的类
   ═══════════════════════════════════════════════════════════════ */

/* ── 通用工具 ── */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }

/* ── 首页 ── */
.home-welcome { margin-bottom: 20px; }
.home-welcome h2 { font-size: 22px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.home-welcome p { font-size: 13px; color: var(--text-muted); }

.kpi-strip { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 20px; }
.kpi-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; text-align: center; }
.kpi-value { font-size: 24px; font-weight: 700; color: var(--text-primary); font-family: var(--font-mono); }
.kpi-label { font-size: 11px; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.05em; }
@media(max-width:900px) { .kpi-strip { grid-template-columns: repeat(3,1fr); } }
@media(max-width:600px) { .kpi-strip { grid-template-columns: repeat(2,1fr); } }

.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-bottom: 20px; }
.module-card { display: flex; align-items: flex-start; gap: 14px; padding: 18px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.module-card:hover { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.module-card h3 { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.module-card p { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.module-icon { width: 40px; height: 40px; border-radius: var(--radius-xs); display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: #fff; }
.module-icon.blue { background: var(--primary); }
.module-icon.green { background: var(--success); }
.module-icon.orange { background: var(--warning); }
.module-icon.red { background: var(--danger); }
.module-icon.purple { background: #8b5cf6; }

.status-bar { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12px; color: var(--text-muted); }
.status-item { display: flex; align-items: center; gap: 6px; }

/* ── 角色徽章 ── */
.role-badge { display: inline-block; padding: 2px 8px; border-radius: 9999px; font-size: 10px; font-weight: 600; letter-spacing: 0.04em; }
.role-super_admin { background: rgba(248,113,113,0.15); color: #fca5a5; border: 1px solid rgba(248,113,113,0.25); }
.role-admin { background: rgba(79,156,255,0.15); color: #93c5fd; border: 1px solid rgba(79,156,255,0.25); }
.role-user { background: rgba(0,212,170,0.12); color: rgba(0,212,170,0.8); border: 1px solid rgba(0,212,170,0.2); }

/* ── 状态点 ── */
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--text-muted); }
.dot.ok, .dot.up { background: var(--success); }
.dot.slow { background: var(--warning); }
.dot.down { background: var(--danger); }
.dot.unknown { background: var(--text-muted); }

/* ── 管理页 ── */
.admin-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.admin-stat-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; text-align: center; }
.admin-stat-val { font-size: 22px; font-weight: 700; color: var(--text-primary); font-family: var(--font-mono); }
.admin-stat-label { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.admin-table-wrap { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.admin-table-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.admin-table-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.admin-table { width: 100%; }
.admin-actions { display: flex; gap: 6px; }
.admin-modal-field { margin-bottom: 12px; }
.admin-modal-field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.perm-list { display: flex; flex-direction: column; gap: 8px; }
.perm-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: var(--bg-elevated); border-radius: var(--radius-xs); }
.perm-item-label { font-size: 13px; color: var(--text-primary); }
@media(max-width:700px) { .admin-stats { grid-template-columns: repeat(2,1fr); } }

/* ── 弹窗 ── */
.modal-box { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); width: 90%; max-width: 500px; max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 16px; border-top: 1px solid var(--border); }

/* ── 服务器 ── */
.srv-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.srv-header-right { display: flex; align-items: center; gap: 8px; }
.srv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.srv-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.srv-card-header { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.srv-card-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
@media(max-width:800px) { .srv-grid { grid-template-columns: 1fr; } }

/* ── VPN ── */
.vpn-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.vpn-header-right { display: flex; align-items: center; gap: 8px; }
.vpn-top-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.vpn-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.vpn-card-title { font-size: 14px; font-weight: 700; color: var(--text-primary); margin-bottom: 12px; }
.vpn-traffic-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.vpn-traffic-item { text-align: center; }
.vpn-traffic-val { font-size: 16px; font-weight: 700; color: var(--text-primary); font-family: var(--font-mono); }
.vpn-traffic-lbl { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.vpn-usage-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.vpn-progress { flex: 1; height: 8px; background: var(--bg-elevated); border-radius: 4px; overflow: hidden; }
.vpn-progress-fill { height: 100%; border-radius: 4px; background: var(--primary); transition: width .3s; }
.vpn-live-speed { display: flex; gap: 16px; }
.vpn-speed-item { text-align: center; flex: 1; }
.vpn-speed-val { font-size: 14px; font-weight: 600; color: var(--text-primary); font-family: var(--font-mono); }
.vpn-current-node { display: flex; align-items: center; gap: 8px; }
.vpn-current-info { font-size: 12px; color: var(--text-muted); }
@media(max-width:768px) { .vpn-top-grid { grid-template-columns: 1fr; } }

/* ── Relay 监测 ── */
.relay-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.relay-header-actions { display: flex; gap: 8px; }
.relay-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 9999px; font-size: 11px; font-weight: 500; background: var(--bg-surface); border: 1px solid var(--border); }
.relay-chip-dot { width: 6px; height: 6px; border-radius: 50%; }
.relay-chip-dot.up { background: var(--success); }
.relay-chip-dot.slow { background: var(--warning); }
.relay-chip-dot.down { background: var(--danger); }
.relay-chip-dot.unknown { background: var(--text-muted); }
.relay-chip-lbl { color: var(--text-muted); }
.relay-chip-val { color: var(--text-primary); font-weight: 600; font-family: var(--font-mono); }
.relay-sync-result { padding: 10px 16px; background: var(--success-muted); border: 1px solid var(--success); border-radius: var(--radius-sm); margin-bottom: 12px; font-size: 13px; color: var(--success); }

/* ── ClickHouse ── */
.ch-layout { display: flex; height: calc(100vh - var(--topbar-h) - 56px); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg-surface); }
.ch-sidebar { width: 260px; flex-shrink: 0; border-right: 1px solid var(--border); overflow-y: auto; padding: 12px; background: var(--bg-sidebar); }
.ch-detail { flex: 1; overflow-y: auto; }
.ch-detail-header { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.ch-detail-body { padding: 16px; }
.ch-search { width: 100%; padding: 6px 10px; font-size: 12px; border: 1px solid var(--border); border-radius: var(--radius-xs); background: var(--bg-input); color: var(--text-primary); margin-bottom: 8px; }
.ch-overview { padding: 24px; }
.ch-overview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.ch-overview-item { background: var(--bg-elevated); border: 1px solid var(--border-light); border-radius: var(--radius-xs); padding: 14px; text-align: center; }
.ch-overview-item .val { font-size: 18px; font-weight: 700; color: var(--text-primary); font-family: var(--font-mono); }
.ch-overview-item .lbl { font-size: 10px; color: var(--text-muted); margin-top: 2px; text-transform: uppercase; }
.ch-tab { display: inline-block; padding: 8px 16px; font-size: 13px; cursor: pointer; color: var(--text-muted); border-bottom: 2px solid transparent; }
.ch-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.ch-status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.ch-status-dot.ok { background: var(--success); }
.ch-status-badge { display: inline-block; padding: 2px 6px; border-radius: 4px; font-size: 10px; background: var(--bg-elevated); color: var(--text-muted); }
.ch-tree-loading, .ch-spinner { display: flex; align-items: center; justify-content: center; padding: 20px; color: var(--text-muted); font-size: 12px; }
.ch-filter-row { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.val { font-size: 16px; font-weight: 700; color: var(--text-primary); font-family: var(--font-mono); }
.lbl { font-size: 10px; color: var(--text-muted); }
.label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }

/* ── Skills 库 ── */
.sk-layout { display: flex; height: calc(100vh - var(--topbar-h) - 56px); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg-surface); }
.sk-sidebar { width: 300px; flex-shrink: 0; border-right: 1px solid var(--border); overflow-y: auto; padding: 12px; background: var(--bg-sidebar); }
.sk-sidebar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sk-sidebar-meta { font-size: 11px; color: var(--text-muted); margin-bottom: 10px; }
.sk-detail { flex: 1; overflow-y: auto; padding: 20px; }
.sk-detail-header { margin-bottom: 16px; }

/* ── 文档系统补充 ── */
.docs-layout { display: flex; height: calc(100vh - var(--topbar-h) - 56px); border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-surface); overflow: hidden; box-shadow: var(--shadow-sm); }
.docs-sidebar { width: 280px; flex-shrink: 0; border-right: 1px solid var(--border); overflow-y: auto; display: flex; flex-direction: column; background: var(--bg-sidebar); }
.docs-sidebar-header { padding: 12px; border-bottom: 1px solid var(--border); }
.docs-sidebar-actions { padding: 8px 12px; display: flex; gap: 8px; }
.docs-reader { flex: 1; overflow-y: auto; }
.docs-reader-inner { padding: 24px 32px; }
.docs-outline-title { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; padding: 12px 16px 8px; }
.doc-save-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.doc-save-dot.saved { background: var(--success); }

/* ── 监控 ── */
.monitor-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.monitor-header-left { display: flex; align-items: center; gap: 10px; }
.time-range-btns { display: flex; gap: 4px; }
.time-range-btns .btn { min-width: 40px; }
.custom-time-row { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.chart-section { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.chart-header { padding: 10px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.chart-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.risk-section { margin-bottom: 16px; }
.summary-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; text-align: center; }
.summary-card .value { font-size: 18px; font-weight: 700; color: var(--text-primary); font-family: var(--font-mono); }
.summary-card .label { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

/* ── API Panel ── */
.api-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.api-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.api-tabs .btn { border-radius: 0; border-bottom: 2px solid transparent; }
.api-tabs .btn.active { border-bottom-color: var(--primary); color: var(--primary); }
.backend-switcher { display: flex; gap: 4px; }

/* ── FactorLib 补充 ── */
.fl-loading, .fl-spinner { display: flex; align-items: center; justify-content: center; padding: 30px; color: var(--text-muted); gap: 8px; font-size: 13px; }
.fl-tab { padding: 12px 20px; font-size: 13px; font-weight: 500; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; transition: color .15s, border-color .15s; }
.fl-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.fl-tab:hover { color: var(--text-primary); }
.fl-detail-name { font-size: 16px; font-weight: 700; color: var(--text-primary); word-break: break-all; }
.fl-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.fl-guide-layout { display: flex; flex: 1; min-height: 0; overflow: hidden; }
.fl-guide-toc { width: 200px; flex-shrink: 0; overflow-y: auto; padding: 20px 12px; border-left: 1px solid var(--border); }
.fl-submit-layout { display: flex; gap: 20px; flex: 1; min-height: 0; overflow: hidden; padding: 20px; }
.fl-submit-form { flex: 0 0 420px; overflow-y: auto; }
.fl-submit-ref { flex: 1; min-width: 0; overflow-y: auto; }

/* ── 登录页 ── */
.login-bg { position: fixed; inset: 0; z-index: -1; }
.login-form { display: flex; flex-direction: column; gap: 16px; }

/* ── 移动端汉堡按钮 ── */
.hamburger { display: none; }
.mobile-header { display: none; }
@media(max-width:768px) {
    .hamburger { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: none; background: none; cursor: pointer; color: var(--text-primary); }
    .mobile-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: var(--bg-sidebar); border-bottom: 1px solid var(--border); }
}


/* ═══════════════════════════════════════════════════════════════
   VISUAL REFINEMENT PATCH — Bloomberg / Datadog / Linear feel
   Applied: 2026-04-10
   Priority: Higher specificity overrides for dark theme polish
   ═══════════════════════════════════════════════════════════════ */

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   1. SIDEBAR — Tighter spacing, proper alignment, clear active
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

/* Nav items: compact, aligned, consistent */
.sidebar .sidebar-nav {
    padding: 8px 8px;
    gap: 1px;
}
.sidebar .nav-item {
    padding: 7px 12px 7px 14px;
    gap: 10px;
    font-size: 13px;
    font-weight: 500;
    min-height: 34px;
    border-radius: 0 6px 6px 0;
    border-left: 2.5px solid transparent;
    position: relative;
    transition: all 0.15s ease;
    letter-spacing: 0.005em;
    line-height: 1.3;
}
.sidebar .nav-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.55;
    transition: opacity 0.15s ease, color 0.15s ease;
}
.sidebar .nav-item span {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Hover */
[data-theme="dark"] .sidebar .nav-item:hover {
    background: rgba(79, 156, 255, 0.06);
    color: var(--text-primary);
    border-left-color: rgba(79, 156, 255, 0.25);
}
[data-theme="dark"] .sidebar .nav-item:hover svg {
    opacity: 0.8;
    color: var(--primary);
}
/* Active — strong left accent + glow */
[data-theme="dark"] .sidebar .nav-item.active {
    border-left-color: var(--primary) !important;
    background: linear-gradient(90deg, rgba(79, 156, 255, 0.12) 0%, rgba(79, 156, 255, 0.03) 100%) !important;
    color: #dce8ff !important;
    font-weight: 600 !important;
    box-shadow: inset 3px 0 12px -4px rgba(79, 156, 255, 0.2);
}
[data-theme="dark"] .sidebar .nav-item.active svg {
    color: var(--primary) !important;
    opacity: 1 !important;
}
/* Light mode active */
.sidebar .nav-item.active {
    border-left-color: var(--primary) !important;
    background: var(--primary-muted) !important;
    color: var(--primary) !important;
    font-weight: 600 !important;
}

/* Nav group titles — brighter, proper spacing */
.sidebar .nav-group {
    margin-bottom: 2px;
}
.sidebar .nav-group-title {
    padding: 16px 14px 5px 16px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    user-select: none;
}
[data-theme="dark"] .sidebar .nav-group-title {
    color: rgba(79, 156, 255, 0.5) !important;
}
.sidebar .nav-group:first-child .nav-group-title {
    padding-top: 6px;
}

/* Sidebar footer — compact */
.sidebar .sidebar-footer {
    padding: 10px 14px;
    gap: 8px;
}
.sidebar .user-avatar {
    width: 30px;
    height: 30px;
    font-size: 12px;
}
.sidebar .user-name {
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.3;
}
.sidebar .user-role {
    margin-top: 1px;
}
.sidebar .user-role .role-badge {
    font-size: 9px;
    padding: 1px 6px;
}
.sidebar .btn-logout {
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sidebar .btn-logout svg {
    width: 14px;
    height: 14px;
}

/* Sidebar brand — tighter */
.sidebar .sidebar-brand {
    height: 48px;
    padding: 0 14px;
    gap: 8px;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   2. KPI CARDS — Bold numbers, color accent, hover lift
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

.kpi-strip {
    gap: 14px;
    margin-bottom: 28px;
}
.kpi-card {
    position: relative;
    padding: 18px 16px 16px;
    border-radius: var(--radius);
    text-align: left;
    overflow: hidden;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
/* Colored top accent line */
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary) 0%, rgba(79, 156, 255, 0.3) 100%);
    border-radius: 3px 3px 0 0;
}
/* Per-card accent colors via nth-child */
.kpi-card:nth-child(1)::before { background: linear-gradient(90deg, #4f9cff, rgba(79, 156, 255, 0.2)); }
.kpi-card:nth-child(2)::before { background: linear-gradient(90deg, #10b981, rgba(16, 185, 129, 0.2)); }
.kpi-card:nth-child(3)::before { background: linear-gradient(90deg, #f59e0b, rgba(245, 158, 11, 0.2)); }
.kpi-card:nth-child(4)::before { background: linear-gradient(90deg, #8b5cf6, rgba(139, 92, 246, 0.2)); }
.kpi-card:nth-child(5)::before { background: linear-gradient(90deg, #00d4aa, rgba(0, 212, 170, 0.2)); }
.kpi-card:nth-child(6)::before { background: linear-gradient(90deg, #ef4444, rgba(239, 68, 68, 0.2)); }

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}
[data-theme="dark"] .kpi-card:hover {
    border-color: rgba(79, 156, 255, 0.25);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(79, 156, 255, 0.1);
}

/* KPI icon row */
.kpi-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    margin-bottom: 10px;
    flex-shrink: 0;
}
.kpi-icon.blue { background: rgba(79, 156, 255, 0.12); color: #4f9cff; }
.kpi-icon.green { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.kpi-icon.orange { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.kpi-icon.purple { background: rgba(139, 92, 246, 0.12); color: #8b5cf6; }
.kpi-icon.teal { background: rgba(0, 212, 170, 0.12); color: #00d4aa; }
.kpi-icon.red { background: rgba(239, 68, 68, 0.12); color: #ef4444; }

.kpi-value {
    font-family: var(--font-mono) !important;
    font-size: 28px !important;
    font-weight: 700 !important;
    letter-spacing: -0.03em;
    line-height: 1.1;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.kpi-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* Dark mode KPI card styling */
[data-theme="dark"] .kpi-card {
    background: linear-gradient(145deg, rgba(13, 20, 36, 0.9) 0%, rgba(10, 16, 32, 0.9) 100%);
    border-color: rgba(79, 156, 255, 0.1);
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   3. MODULE CARDS — Icon + title + desc, hover glow
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

.module-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.module-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 18px 20px;
    border-radius: var(--radius);
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}
.module-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 80px;
    height: 80px;
    background: radial-gradient(circle at top right, rgba(79, 156, 255, 0.04) 0%, transparent 70%);
    pointer-events: none;
}
.module-card:hover {
    transform: translateY(-2px);
    border-color: rgba(79, 156, 255, 0.35) !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(79, 156, 255, 0.15);
}
[data-theme="dark"] .module-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(79, 156, 255, 0.2);
}
.module-card .module-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-bottom: 0;
    transition: transform 0.18s ease;
}
.module-card:hover .module-icon {
    transform: scale(1.05);
}
.module-card .module-info {
    flex: 1;
    min-width: 0;
}
.module-card .module-info h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 4px;
    letter-spacing: -0.01em;
}
.module-card .module-info p {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
}
/* Arrow indicator */
.module-card .module-arrow {
    color: var(--text-muted);
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity 0.18s ease, transform 0.18s ease;
    flex-shrink: 0;
    margin-top: 2px;
}
.module-card:hover .module-arrow {
    opacity: 0.6;
    transform: translateX(0);
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   4. HOME WELCOME AREA — Time display + role badge
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

.home-welcome {
    margin-bottom: 28px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}
.home-welcome-left h2 {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    margin: 0 0 4px;
    line-height: 1.2;
}
[data-theme="dark"] .home-welcome-left h2 {
    background: linear-gradient(135deg, #e8edf5 0%, #93c5fd 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.home-welcome-left p {
    color: var(--text-muted);
    font-size: 13px;
    margin: 0;
}
.home-welcome-left .welcome-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 6px;
}
.home-welcome-left .welcome-time {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}
.home-welcome-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   5. STATUS BAR — Compact, modern
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

.status-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 8px 16px;
    font-size: 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    border: 1px solid var(--border);
}
[data-theme="dark"] .status-bar {
    background: rgba(13, 20, 36, 0.6);
    border-color: rgba(79, 156, 255, 0.08);
}
.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}
.status-item .status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot.ok {
    background: var(--success);
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
}
.status-dot.warn {
    background: var(--warning);
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.4);
}
.status-dot.err {
    background: var(--danger);
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}
.status-dot.unknown {
    background: var(--text-muted);
}
.status-separator {
    width: 1px;
    height: 14px;
    background: var(--border);
    flex-shrink: 0;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   6. GLOBAL — Buttons, tables, forms, modals, progress
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

/* Buttons — micro-gradient + better hover */
.btn {
    transition: all 0.15s ease;
    cursor: pointer;
}
.btn-primary {
    background: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, transparent 100%), var(--primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.btn-primary:hover:not(:disabled) {
    background: linear-gradient(180deg, rgba(255,255,255,0.12) 0%, transparent 100%), var(--primary-hover);
    box-shadow: 0 2px 8px rgba(79, 156, 255, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.btn-danger {
    background: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, transparent 100%), var(--danger);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.btn-danger:hover:not(:disabled) {
    background: linear-gradient(180deg, rgba(255,255,255,0.12) 0%, transparent 100%), var(--danger-hover);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.btn-outline {
    transition: all 0.15s ease;
}
.btn-outline:hover:not(:disabled) {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

/* Data table header — layered feel */
[data-theme="dark"] .data-table thead tr {
    background: linear-gradient(180deg, rgba(18, 25, 41, 0.95) 0%, rgba(13, 20, 36, 0.95) 100%);
}
[data-theme="dark"] .data-table thead th {
    background: transparent;
    border-bottom: 2px solid rgba(79, 156, 255, 0.15);
    color: rgba(79, 156, 255, 0.7);
    font-size: 10px;
    letter-spacing: 0.08em;
}
.data-table th {
    position: relative;
}
.data-table th::after {
    content: '';
    position: absolute;
    right: 0;
    top: 25%;
    bottom: 25%;
    width: 1px;
    background: var(--border-light);
}
.data-table th:last-child::after {
    display: none;
}

/* Form inputs — blue glow on focus */
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(79, 156, 255, 0.15), 0 0 0 1px var(--primary) !important;
}
[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
    box-shadow: 0 0 0 3px rgba(79, 156, 255, 0.12), 0 0 0 1px rgba(79, 156, 255, 0.5) !important;
}

/* Progress bars — rounded */
.vpn-progress,
.vpn-progress-fill,
progress,
[role="progressbar"] {
    border-radius: 6px;
}
.vpn-progress {
    height: 6px;
    border-radius: 6px;
    overflow: hidden;
}
.vpn-progress-fill {
    border-radius: 6px;
    background: linear-gradient(90deg, var(--primary), #6eaeff);
}

/* Modal overlay — enhanced blur */
.modal-overlay {
    backdrop-filter: blur(8px) saturate(1.2);
    -webkit-backdrop-filter: blur(8px) saturate(1.2);
}
[data-theme="dark"] .modal-overlay {
    background-color: rgba(0, 0, 0, 0.65);
}

/* Section headings in home */
.section-heading {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.section-heading::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}
[data-theme="dark"] .section-heading {
    color: rgba(79, 156, 255, 0.45);
}
[data-theme="dark"] .section-heading::after {
    background: linear-gradient(90deg, rgba(79, 156, 255, 0.15), transparent);
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   7. RESPONSIVE — Keep new layout tight on small screens
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

@media (max-width: 768px) {
    .home-welcome {
        flex-direction: column;
        gap: 8px;
    }
    .kpi-strip {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .kpi-value {
        font-size: 22px !important;
    }
    .module-grid {
        grid-template-columns: 1fr;
    }
    .status-bar {
        flex-wrap: wrap;
        gap: 10px;
    }
}


/* ═══════════════════════════════════════════════════════════════
   PAGE-SPECIFIC DARK THEME ENHANCEMENTS
   Applied: 2026-04-10
   Financial terminal / Bloomberg aesthetic
   ═══════════════════════════════════════════════════════════════ */

/* ── Monitor: Connection pulse animation ── */
.conn-dot.connected {
    animation: connGlow 2s ease-in-out infinite;
}
@keyframes connGlow {
    0%, 100% { box-shadow: 0 0 4px var(--success), 0 0 8px rgba(16,185,129,0.3); }
    50% { box-shadow: 0 0 8px var(--success), 0 0 16px rgba(16,185,129,0.5); }
}

/* ── Monitor: PNL value emphasis ── */
.pnl-positive { color: var(--success) !important; font-weight: 700; }
.pnl-negative { color: var(--danger) !important; font-weight: 700; }

/* ── Relay: Latency mono font ── */
.relay-metric-val {
    font-variant-numeric: tabular-nums;
}

/* ── Server: Dynamic progress bar colors ── */
[data-theme="dark"] .srv-progress-fill.low {
    background: linear-gradient(90deg, #059669, #10b981);
    box-shadow: 0 0 8px rgba(16,185,129,0.2);
}
[data-theme="dark"] .srv-progress-fill.mid {
    background: linear-gradient(90deg, #d97706, #f59e0b);
    box-shadow: 0 0 8px rgba(245,158,11,0.2);
}
[data-theme="dark"] .srv-progress-fill.high {
    background: linear-gradient(90deg, #dc2626, #ef4444);
    box-shadow: 0 0 8px rgba(239,68,68,0.2);
}

/* ── Admin: Dark mode stat card glow ── */
[data-theme="dark"] .admin-stat-card:nth-child(1) { border-top: 2px solid rgba(79,156,255,0.3); }
[data-theme="dark"] .admin-stat-card:nth-child(2) { border-top: 2px solid rgba(248,113,113,0.3); }
[data-theme="dark"] .admin-stat-card:nth-child(3) { border-top: 2px solid rgba(168,85,247,0.3); }
[data-theme="dark"] .admin-stat-card:nth-child(4) { border-top: 2px solid rgba(16,185,129,0.3); }

/* ── VPN: Node button grid ── */
[data-theme="dark"] .vpn-node-btn {
    background: rgba(13,20,36,0.6);
    border-color: rgba(79,156,255,0.08);
}
[data-theme="dark"] .vpn-node-btn:hover {
    background: rgba(79,156,255,0.06);
    border-color: rgba(79,156,255,0.25);
}
[data-theme="dark"] .vpn-node-btn.active {
    background: linear-gradient(135deg, rgba(79,156,255,0.9), rgba(59,130,246,0.9));
    border-color: transparent;
    box-shadow: 0 2px 12px rgba(79,156,255,0.35);
}

/* ── Relay: Form inputs in modal ── */
[data-theme="dark"] .relay-card .relay-metric {
    background: rgba(18,25,41,0.6);
    border-color: rgba(79,156,255,0.06);
}

/* ── Generic: Section title decorators ── */
.chart-title::before,
.srv-card-title::before,
.vpn-card-title::before,
.admin-table-title::before,
.srv-section-title::before {
    content: '';
    display: inline-block;
    width: 3px;
    border-radius: 2px;
    background: linear-gradient(180deg, var(--primary), var(--accent-2));
    flex-shrink: 0;
}
.chart-title::before,
.admin-table-title::before { height: 16px; }
.vpn-card-title::before { height: 14px; }
.srv-card-title::before { height: 16px; }
.srv-section-title::before { height: 12px; width: 2px; }

/* ═══════════════════════════════════════════════════════════════
   DOCUMENTS / SKILLS / CLICKHOUSE — Dark Theme Enhancements
   Applied: 2026-04-10
   Purpose: Cohesive dark-mode polish for three-panel layouts
   ═══════════════════════════════════════════════════════════════ */

/* ── ClickHouse: DB icon via CSS pseudo-element (no JS change) ── */
.ch-db-name {
    position: relative;
    padding-left: 20px;
}
.ch-db-name::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%234f9cff' stroke-width='2'%3E%3Cellipse cx='12' cy='5' rx='9' ry='3'/%3E%3Cpath d='M21 12c0 1.66-4 3-9 3s-9-1.34-9-3'/%3E%3Cpath d='M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
    opacity: 0.5;
}
.ch-db-item.open > .ch-db-header .ch-db-name::before {
    opacity: 0.9;
}

/* ── ClickHouse: Data table compact overrides ── */
#chDataScroll .data-table {
    font-size: 12px;
}
#chDataScroll .data-table td {
    padding: 5px 10px;
    white-space: nowrap;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
}
#chDataScroll .data-table th {
    padding: 7px 10px;
    cursor: pointer;
    user-select: none;
}

/* ── ClickHouse: engine badge — fallback for unknown engines ── */
.ch-engine-badge.other {
    background: var(--bg-elevated);
    color: var(--text-muted);
}

/* ── Three-panel sidebars: Dark mode gradient background ── */
[data-theme="dark"] .docs-sidebar,
[data-theme="dark"] .sk-sidebar,
[data-theme="dark"] .ch-sidebar {
    background: linear-gradient(180deg, var(--bg-surface) 0%, rgba(6, 10, 20, 0.95) 100%);
    border-color: rgba(79, 156, 255, 0.08);
}

/* ── Search inputs: Dark mode polish ── */
[data-theme="dark"] .docs-sidebar-header input,
[data-theme="dark"] .sk-sidebar-header input,
[data-theme="dark"] .ch-search input {
    background: rgba(13, 20, 36, 0.6);
    border-color: rgba(79, 156, 255, 0.12);
}
[data-theme="dark"] .docs-sidebar-header input:focus,
[data-theme="dark"] .sk-sidebar-header input:focus,
[data-theme="dark"] .ch-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(79, 156, 255, 0.15);
}

/* ── Group headers: Hover glow ── */
[data-theme="dark"] .doc-group-header:hover,
[data-theme="dark"] .sk-source-header:hover,
[data-theme="dark"] .ch-db-header:hover {
    background: rgba(79, 156, 255, 0.06);
}

/* ── Active items: Subtle inset glow ── */
[data-theme="dark"] .doc-item.active,
[data-theme="dark"] .sk-skill-item.active,
[data-theme="dark"] .ch-table-item.active {
    background: rgba(79, 156, 255, 0.1);
    box-shadow: inset 2px 0 8px -2px rgba(79, 156, 255, 0.2);
}

/* ── Code blocks: Deep dark background ── */
[data-theme="dark"] #docReaderContent pre,
[data-theme="dark"] .sk-markdown pre {
    background: #0c1220;
    border-color: rgba(79, 156, 255, 0.1);
}
[data-theme="dark"] #docReaderContent p code,
[data-theme="dark"] #docReaderContent li code,
[data-theme="dark"] .sk-markdown p code {
    background: rgba(79, 156, 255, 0.08);
    border-color: rgba(79, 156, 255, 0.15);
    color: #6eaeff;
}

/* ── ClickHouse: Overview cards dark mode ── */
[data-theme="dark"] .ch-overview-item {
    background: rgba(13, 20, 36, 0.8);
    border-color: rgba(79, 156, 255, 0.08);
}

/* ── ClickHouse: Stat cards dark mode ── */
[data-theme="dark"] .ch-stat-card {
    background: linear-gradient(145deg, rgba(13, 20, 36, 0.9), rgba(10, 16, 32, 0.9));
    border-color: rgba(79, 156, 255, 0.1);
}
[data-theme="dark"] .ch-stat-card:hover {
    border-color: rgba(79, 156, 255, 0.25);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* ── Tabs: Dark mode polish ── */
[data-theme="dark"] .ch-tab:hover {
    background: rgba(79, 156, 255, 0.06);
    border-color: rgba(79, 156, 255, 0.2);
}
[data-theme="dark"] .ch-tab.active {
    background: linear-gradient(135deg, var(--primary), rgba(79, 156, 255, 0.8));
    box-shadow: 0 2px 8px rgba(79, 156, 255, 0.25);
}

/* ── Quill editor: Dark mode border refinement ── */
[data-theme="dark"] .ql-toolbar {
    border-color: rgba(79, 156, 255, 0.1) !important;
    background: rgba(13, 20, 36, 0.6) !important;
}
[data-theme="dark"] .ql-container {
    border-color: rgba(79, 156, 255, 0.1) !important;
    background: rgba(6, 10, 20, 0.8) !important;
}

/* ── Document breadcrumb: Subtle border ── */
[data-theme="dark"] #docBreadcrumb {
    border-bottom-color: rgba(79, 156, 255, 0.06);
}

/* ── Document prev/next nav buttons ── */
[data-theme="dark"] .docs-nav-btn {
    background: rgba(13, 20, 36, 0.6);
    border-color: rgba(79, 156, 255, 0.1);
}
[data-theme="dark"] .docs-nav-btn:hover {
    background: rgba(79, 156, 255, 0.08);
    border-color: rgba(79, 156, 255, 0.3);
}

/* ── Document outline rail: Active indicator ── */
[data-theme="dark"] .docs-outline-item.active {
    border-left-color: var(--primary);
}

/* ── ClickHouse filter tags ── */
[data-theme="dark"] .ch-filter-tag {
    background: rgba(79, 156, 255, 0.1);
    border-color: rgba(79, 156, 255, 0.2);
}

/* ── Document attachment chips ── */
[data-theme="dark"] .docs-attachment-chip {
    background: rgba(13, 20, 36, 0.6);
    border-color: rgba(79, 156, 255, 0.1);
}
[data-theme="dark"] .docs-attachment-chip:hover {
    background: rgba(79, 156, 255, 0.08);
    border-color: rgba(79, 156, 255, 0.3);
}

/* ── Skills: View toggle dark polish ── */
[data-theme="dark"] .sk-view-toggle {
    background: rgba(13, 20, 36, 0.6);
    border-color: rgba(79, 156, 255, 0.1);
}
[data-theme="dark"] .sk-view-btn:hover {
    background: rgba(79, 156, 255, 0.06);
}
[data-theme="dark"] .sk-view-btn.active {
    background: linear-gradient(135deg, var(--primary), rgba(79, 156, 255, 0.8));
    box-shadow: 0 1px 4px rgba(79, 156, 255, 0.25);
}

/* ── Skills: Detail header dark border ── */
[data-theme="dark"] .sk-detail-header {
    border-bottom-color: rgba(79, 156, 255, 0.08);
}

/* ── Documents: Reader title gradient in dark mode ── */
[data-theme="dark"] #docReaderTitle {
    background: linear-gradient(135deg, #e8edf5 0%, #93c5fd 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── Documents: Heading hierarchy in dark mode ── */
[data-theme="dark"] #docReaderContent h2 {
    border-bottom-color: rgba(79, 156, 255, 0.1);
}
[data-theme="dark"] #docReaderContent h3 {
    color: var(--text-secondary);
}
[data-theme="dark"] #docReaderContent blockquote {
    background: rgba(79, 156, 255, 0.06);
    border-left-color: var(--primary);
}

/* ── ClickHouse: Type badge mono polish ── */
.ch-type-badge {
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

/* ── Count badges in tree sidebars ── */
.doc-group-count,
.doc-subgroup-count,
.sk-source-count,
.sk-cat-count,
.sk-subgroup-count,
.ch-db-count {
    font-variant-numeric: tabular-nums;
    font-family: var(--font-mono);
    font-weight: 600;
}

/* ── Dark mode: count badges subtle border ── */
[data-theme="dark"] .doc-group-count,
[data-theme="dark"] .doc-subgroup-count,
[data-theme="dark"] .sk-source-count,
[data-theme="dark"] .sk-cat-count,
[data-theme="dark"] .sk-subgroup-count,
[data-theme="dark"] .ch-db-count {
    background: rgba(79, 156, 255, 0.08);
    border: 1px solid rgba(79, 156, 255, 0.1);
}
/* ── 文档内嵌附件预览（全宽） ── */
.docs-embed-block {
    margin: 20px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-elevated);
}
.docs-embed-img {
    display: block;
    width: 100%;
    max-height: 80vh;
    object-fit: contain;
    cursor: zoom-in;
    transition: opacity 0.15s;
    background: var(--bg-body);
    padding: 8px;
}
.docs-embed-img:hover {
    opacity: 0.92;
}
.docs-embed-caption {
    padding: 8px 14px;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-light);
    background: var(--bg-surface);
}
.docs-embed-pdf {
    width: 100%;
    height: 70vh;
    min-height: 500px;
    border: none;
    background: #fff;
}

/* 保留旧的缩略图样式做兼容 */
.docs-inline-images {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin: 16px 0;
    padding: 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
}
.docs-inline-image img {
    width: 100%;
    border-radius: 6px;
    border: 1px solid var(--border);
}
.docs-inline-image-name {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
