:root {
    --bg: #f4f6fb;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --sidebar: #0b1220;
    --sidebar-2: #111c32;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --card: #ffffff;
    --shadow: 0 12px 40px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body.app-body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    -webkit-font-smoothing: antialiased;
}

.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    width: 250px;
    flex: 0 0 250px;
    background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 30;
}

.brand { display: flex; gap: 12px; align-items: center; padding: 4px 8px 20px; }
.brand-mark {
    width: 40px; height: 40px; border-radius: 12px;
    background: linear-gradient(135deg, #3b82f6, #10b981);
    color: #fff; font-weight: 700; font-size: 20px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 20px rgba(37, 99, 235, .35);
}
.brand-title { font-size: 17px; font-weight: 700; color: #fff; letter-spacing: .5px; }
.brand-sub { font-size: 11px; color: #94a3b8; letter-spacing: .4px; }

.side-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    color: #cbd5e1; text-decoration: none;
    padding: 10px 12px; border-radius: 10px;
    font-size: 14px; transition: all .18s ease;
}
.nav-item:hover { background: rgba(148, 163, 184, .12); color: #fff; text-decoration: none; }
.nav-item.active {
    background: linear-gradient(90deg, rgba(37, 99, 235, .28), rgba(16, 185, 129, .14));
    color: #fff; box-shadow: inset 3px 0 0 #3b82f6;
}
.nav-dot { width: 6px; height: 6px; border-radius: 50%; background: #475569; flex: 0 0 6px; }
.nav-item.active .nav-dot { background: #38bdf8; box-shadow: 0 0 8px #38bdf8; }
.nav-label {
    font-size: 11px; text-transform: uppercase; letter-spacing: 1.6px;
    color: #64748b; margin: 18px 12px 6px;
}

.sidebar-footer { border-top: 1px solid rgba(148, 163, 184, .15); padding-top: 16px; margin-top: 16px; }
.user-chip { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.avatar {
    width: 36px; height: 36px; border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #06b6d4);
    color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.user-name { color: #f8fafc; font-size: 13px; font-weight: 600; }
.user-email { color: #94a3b8; font-size: 11px; overflow: hidden; text-overflow: ellipsis; max-width: 150px; white-space: nowrap; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
    display: flex; align-items: center; gap: 18px;
    padding: 24px 34px 8px;
}
.page-eyebrow { font-size: 12px; color: var(--muted); letter-spacing: .8px; text-transform: uppercase; }
.page-title { font-size: 26px; font-weight: 700; margin: 2px 0 0; letter-spacing: -.4px; }
.topbar-actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }
.app-content { padding: 14px 34px 30px; }
.app-footer {
    margin-top: auto; padding: 18px 34px 26px; color: #94a3b8; font-size: 12px;
    display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.menu-toggle { display: none; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 7px 11px; }
.sidebar-mask { display: none; }

.btn { border-radius: 9px; font-size: 14px; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-outline-primary { color: var(--primary); border-color: #bfdbfe; }
.btn-outline-primary:hover { background: #eff6ff; color: var(--primary-dark); }
.card {
    background: var(--card); border: 1px solid var(--line); border-radius: 16px;
    box-shadow: var(--shadow); margin-bottom: 20px;
}
.card-header {
    background: transparent; border-bottom: 1px solid var(--line);
    padding: 16px 20px; font-weight: 600; display: flex; align-items: center; justify-content: space-between;
}
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card {
    background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px;
    box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat-card::after {
    content: ""; position: absolute; right: -20px; top: -30px; width: 90px; height: 90px;
    border-radius: 50%; background: radial-gradient(circle, rgba(59,130,246,.16), transparent 70%);
}
.stat-label { font-size: 12px; color: var(--muted); letter-spacing: .5px; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 6px; letter-spacing: -.5px; }
.stat-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat-card.green::after { background: radial-gradient(circle, rgba(16,185,129,.18), transparent 70%); }
.stat-card.amber::after { background: radial-gradient(circle, rgba(245,158,11,.2), transparent 70%); }
.stat-card.violet::after { background: radial-gradient(circle, rgba(139,92,246,.18), transparent 70%); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.chart { width: 100%; height: 320px; }
.chart-sm { width: 100%; height: 260px; }
.chart-lg { width: 100%; height: 380px; }

.table { margin-bottom: 0; }
.table thead th {
    border-top: 0; border-bottom: 1px solid var(--line); color: var(--muted);
    font-size: 12px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase;
    padding: 12px 16px; white-space: nowrap;
}
.table td { padding: 13px 16px; border-color: #f1f5f9; vertical-align: middle; font-size: 14px; }
.table-hover tbody tr:hover { background: #f8fafc; }
.badge-soft { background: #eff6ff; color: #1d4ed8; font-weight: 500; border-radius: 8px; padding: 4px 9px; font-size: 12px; }
.badge-green { background: #ecfdf5; color: #047857; }
.badge-amber { background: #fffbeb; color: #b45309; }
.badge-red { background: #fef2f2; color: #b91c1c; }

.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty-state h3 { font-size: 18px; color: var(--ink); margin-bottom: 8px; }
.form-control, .custom-select { border-radius: 9px; border-color: var(--line); height: auto; padding: 9px 12px; }
.form-control:focus { border-color: #93c5fd; box-shadow: 0 0 0 .2rem rgba(37,99,235,.12); }
.form-group label { font-size: 13px; font-weight: 600; color: #334155; margin-bottom: 6px; }
.help-text { color: var(--muted); font-size: 12px; margin-top: 6px; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filter-bar .form-group { margin-bottom: 0; min-width: 160px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.token-alert { border-radius: 12px; }
.token-plain { display: inline-block; background: #0f172a; color: #7dd3fc; padding: 6px 10px; border-radius: 8px; margin-left: 8px; word-break: break-all; }
.mono { font-family: SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.rank-1 { color: #b45309; font-weight: 700; }
.rank-2 { color: #475569; font-weight: 700; }
.rank-3 { color: #9a3412; font-weight: 700; }

.progress { height: 8px; border-radius: 99px; background: #eef2f7; }
.progress-bar { background: linear-gradient(90deg, #3b82f6, #10b981); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 99px; font-size: 12px; background: #f1f5f9; color: #475569; }
.pill.bad { background: #fef2f2; color: #b91c1c; }
.pill.good { background: #ecfdf5; color: #047857; }
.pill.warn { background: #fffbeb; color: #b45309; }

.auth-body {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: radial-gradient(1200px 600px at 15% 10%, #dbeafe 0%, transparent 55%),
                radial-gradient(900px 500px at 90% 90%, #d1fae5 0%, transparent 55%),
                #f8fafc;
    padding: 30px 16px;
}
.auth-card {
    width: 100%; max-width: 430px; background: #fff; border-radius: 20px;
    border: 1px solid var(--line); box-shadow: 0 30px 80px rgba(15, 23, 42, .12); padding: 34px;
}
.auth-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 26px; }
.auth-title { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.auth-sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.auth-footer { margin-top: 20px; text-align: center; font-size: 13px; color: var(--muted); }
.auth-footer a { color: var(--primary); }

.welcome-hero { max-width: 900px; margin: 0 auto; text-align: center; padding: 80px 20px 40px; }
.welcome-hero h1 { font-size: 46px; font-weight: 800; letter-spacing: -1.5px; }
.welcome-hero p { color: var(--muted); font-size: 17px; max-width: 640px; margin: 18px auto 30px; }
.welcome-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; max-width: 960px; margin: 30px auto 70px; padding: 0 20px; }
.welcome-feature { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 22px; text-align: left; box-shadow: var(--shadow); }
.welcome-feature h3 { font-size: 16px; margin: 10px 0 8px; }
.welcome-feature p { font-size: 13px; color: var(--muted); margin: 0; }
.feature-dot { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #dbeafe, #d1fae5); display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--primary); }

.section-title { font-size: 15px; font-weight: 700; margin: 0 0 14px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }

.analysis-hero {
    background: linear-gradient(120deg, #0f172a, #172554 60%, #064e3b);
    color: #fff; border-radius: 18px; padding: 24px 26px; margin-bottom: 20px;
    display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap;
}
.analysis-hero h2 { margin: 0 0 6px; font-size: 22px; }
.analysis-hero .muted { color: #94a3b8; }
.hero-metrics { display: flex; gap: 28px; flex-wrap: wrap; }
.hero-metric .label { font-size: 11px; color: #94a3b8; letter-spacing: .5px; }
.hero-metric .value { font-size: 22px; font-weight: 700; }

@media (max-width: 1100px) {
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
    .app-sidebar {
        position: fixed; left: -270px; top: 0; bottom: 0; height: 100vh;
        transition: left .22s ease; box-shadow: 20px 0 60px rgba(0,0,0,.25);
    }
    .app-sidebar.open { left: 0; }
    .sidebar-mask {
        display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45);
        opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 25;
    }
    .sidebar-mask.show { opacity: 1; pointer-events: auto; }
    .menu-toggle { display: inline-block; }
    .app-topbar { padding: 18px 18px 6px; }
    .app-content { padding: 12px 18px 24px; }
    .app-footer { padding: 16px 18px 24px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .page-title { font-size: 22px; }
    .welcome-grid { grid-template-columns: 1fr; }
    .welcome-hero h1 { font-size: 34px; }
}

@media (max-width: 560px) {
    .stat-grid { grid-template-columns: 1fr; }
    .hero-metrics { gap: 18px; }
    .analysis-hero { padding: 20px; }
}
