:root {
    --navy: #284666;
    --navy-2: #203a55;
    --blue: #486584;
    --sky: #4d75b8;
    --ink: #1f2733;
    --muted: #6c7685;
    --soft: #9aa4b1;
    --line: rgba(28, 42, 58, 0.09);
    --paper: #fff;
    --wash: #f6f7f9;
    --surface: #fafbfd;
    --green: #4b8f73;
    --amber: #c48a3c;
    --rose: #bf5f5f;
    --indigo: #6174a9;
    --radius-sm: 7px;
    --radius-md: 9px;
    --radius-lg: 10px;
    --radius-xl: 12px;
    --shadow: 0 10px 24px rgba(32, 54, 77, 0.06);
    --shadow-soft: 0 1px 2px rgba(26, 38, 55, 0.02);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    background: linear-gradient(180deg, #f5f6f8 0%, #f7f8fa 100%);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    -webkit-font-smoothing: antialiased;
}

.sprite { display: none; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    background: rgba(255,255,255,0.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: saturate(150%) blur(10px);
}

.brand, .top-actions, .filters, .brand-mark, .filter-btn, .ghost-link, .user-pill {
    display: flex;
    align-items: center;
}

.brand {
    gap: 10px;
    color: var(--navy);
    font-size: 16px;
    font-weight: 700;
}

.brand-mark {
    width: 30px;
    height: 30px;
    justify-content: center;
    border-radius: 7px;
    background: var(--navy);
}

.brand-mark svg { width: 17px; height: 17px; fill: white; }
.top-actions { gap: 10px; }

.user-pill, .ghost-link {
    min-height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,0.88);
    color: var(--muted);
    font-size: 13px;
    text-decoration: none;
    white-space: nowrap;
}

.ghost-link { color: var(--navy); font-weight: 600; }
.ghost-link:hover { background: rgba(26,54,93,0.06); }

.dashboard {
    width: min(1420px, 100%);
    margin: 0 auto;
    padding: 18px 24px 44px;
}

.panel {
    background: var(--paper);
    border: 1px solid rgba(28, 42, 58, 0.08);
    border-radius: var(--radius-xl);
    box-shadow: none;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    gap: 22px;
    padding: 16px 18px;
    margin-bottom: 10px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--soft);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

h1, h2 { margin: 0; letter-spacing: -0.025em; }
h1 { font-size: 24px; }
h2 { font-size: 16px; }

.scope-line {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.scope-meta {
    margin: 6px 0 0;
    color: var(--soft);
    font-size: 12px;
}

.filters {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.filters label {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

select {
    width: 156px;
    height: 36px;
    padding: 0 30px 0 10px;
    border: 1px solid rgba(28, 42, 58, 0.11);
    border-radius: var(--radius-sm);
    background: var(--paper);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
}

.filter-btn, .primary-btn {
    border: 0;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

.filter-btn {
    align-self: end;
    gap: 6px;
    height: 36px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    background: var(--navy);
    color: white;
    box-shadow: none;
}

.filter-btn svg { width: 15px; height: 15px; fill: currentColor; }

.tab-strip {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    padding: 6px 8px;
    overflow-x: auto;
}

.tab-btn {
    flex: 0 0 auto;
    min-height: 34px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 13px;
    font-weight: 650;
    cursor: pointer;
    transition: all 0.18s ease;
}

.tab-btn:hover {
    border-color: rgba(77, 117, 184, 0.10);
    background: rgba(77, 117, 184, 0.05);
    color: var(--navy);
}

.tab-btn.active {
    border-color: rgba(77, 117, 184, 0.12);
    background: rgba(77, 117, 184, 0.09);
    color: var(--navy);
    box-shadow: inset 0 -1px 0 rgba(77, 117, 184, 0.25);
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0;
    margin-bottom: 10px;
}

.metric-strip {
    overflow: hidden;
    border: 1px solid rgba(28, 42, 58, 0.08);
    border-radius: var(--radius-xl);
    background: var(--paper);
}

.kpi-card {
    min-height: 78px;
    padding: 11px 15px 10px;
    border-radius: 0;
    background: transparent;
    border: 0;
    border-right: 1px solid rgba(28, 42, 58, 0.08);
    animation: rise 0.45s ease both;
}

.metric-strip .kpi-card:last-child {
    border-right: 0;
}

.kpi-card span, .kpi-card small {
    display: block;
    color: #687383;
    font-size: 12px;
}

.kpi-card strong {
    display: block;
    margin: 6px 0 4px;
    color: var(--navy);
    font-size: 25px;
    line-height: 1.08;
    letter-spacing: -0.04em;
}

.kpi-card.danger strong { color: var(--rose); }
.kpi-card.warning strong { color: var(--amber); }
.kpi-card.success strong { color: var(--green); }
.kpi-card.accent strong { color: var(--indigo); }
.kpi-card small {
    color: #768292;
}
.delta-positive { color: var(--green) !important; }
.delta-negative { color: var(--rose) !important; }

.tab-content {
    min-height: 320px;
}

.tab-view-grid {
    display: grid;
    grid-template-columns: 1.25fr 0.9fr 0.9fr;
    gap: 10px;
}

.wide { grid-column: span 2; }
.chart-panel, .tab-view-grid .panel, .download-panel { padding: 14px; }

.panel-header {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: start;
    margin-bottom: 12px;
}

.meta {
    color: var(--soft);
    font-size: 12px;
}

.panel-tools {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.link-btn, .plain-btn {
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 650;
    white-space: nowrap;
}

.link-btn:hover, .plain-btn:hover { color: var(--navy); }

.chart {
    width: 100%;
    min-height: 250px;
}

.chart-large { height: 304px; }
.chart-compact { height: 248px; }

.dual-list {
    display: grid;
    gap: 14px;
}

.mini-title {
    margin: 0 0 8px;
    color: var(--soft);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.compact-rank .rank-item {
    padding-top: 8px;
    padding-bottom: 8px;
}

.rank-list {
    display: grid;
    gap: 6px;
}

.rank-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    background: var(--surface);
    border: 1px solid rgba(28, 42, 58, 0.05);
}

.rank-name {
    overflow: hidden;
    color: var(--ink);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rank-value {
    color: var(--navy);
    font-weight: 700;
}

.bar-track {
    height: 3px;
    margin-top: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(32, 54, 77, 0.07);
}

.bar-track span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--sky);
}

.empty {
    padding: 18px 12px;
    color: var(--soft);
    font-size: 13px;
    text-align: center;
    border-radius: var(--radius-md);
    background: var(--surface);
}

.compact-table {
    display: grid;
    gap: 8px;
}

.panel-note {
    background: var(--paper);
}

.insight-stack {
    display: grid;
    gap: 8px;
}

.insight-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: var(--surface);
    border: 1px solid rgba(28, 42, 58, 0.05);
    color: var(--muted);
    font-size: 13px;
}

.insight-row strong {
    color: var(--navy);
    font-size: 14px;
}

.restricted-panel {
    display: flex;
    flex-direction: column;
}

.table-row {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr) 72px;
    gap: 8px;
    align-items: center;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    background: var(--surface);
    font-size: 12px;
}

.table-row .muted {
    overflow: hidden;
    color: var(--muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.download-panel { margin-top: 12px; }
.download-grid {
    display: grid;
    gap: 0;
    overflow: hidden;
    border: 1px solid rgba(28, 42, 58, 0.08);
    border-radius: var(--radius-lg);
    background: #fff;
}

.download-card {
    display: grid;
    gap: 12px;
    padding: 16px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    background: white;
}

.download-card h3 { margin: 0; font-size: 15px; }
.download-card p { margin: 0; min-height: 54px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.download-card small { color: var(--soft); font-size: 11px; }

.download-card button {
    height: 36px;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--navy);
    color: white;
    font: inherit;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}

.download-card button:disabled { cursor: not-allowed; opacity: 0.5; }
.download-card.blue button { background: var(--sky); }
.download-card.amber button { background: var(--amber); }
.download-card.green button { background: var(--green); }
.download-card.indigo button { background: var(--indigo); }
.download-card.rose button { background: var(--rose); }

.report-row {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) 190px 112px 210px;
    gap: 16px;
    align-items: center;
    min-height: 58px;
    padding: 9px 14px;
    border-bottom: 1px solid rgba(28, 42, 58, 0.06);
    color: var(--muted);
    font-size: 13px;
}

.report-row:last-child { border-bottom: 0; }
.report-head {
    min-height: 38px;
    background: var(--wash);
    color: var(--soft);
    font-size: 12px;
    font-weight: 800;
}

.report-title {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.report-title strong {
    overflow: hidden;
    color: var(--ink);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.report-title small {
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 7px;
    border-radius: 50%;
    background: var(--soft);
}

.status-dot.ok { background: var(--green); }
.status-dot.muted { background: var(--soft); }

.report-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.download-btn {
    min-width: 78px;
    height: 32px;
    border: 1px solid rgba(28, 42, 58, 0.1);
    border-radius: var(--radius-sm);
    background: var(--wash);
    color: var(--navy);
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
}

.download-btn:hover {
    background: rgba(77, 117, 184, 0.08);
    border-color: rgba(77, 117, 184, 0.16);
}
.download-btn:disabled {
    cursor: not-allowed;
    opacity: 0.48;
}

.watermark {
    position: fixed;
    inset: 0;
    z-index: 100;
    pointer-events: none;
    opacity: 0.016;
    mix-blend-mode: multiply;
}

.watermark.hidden {
    display: none;
}

.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 200;
    transform: translateY(16px);
    opacity: 0;
    max-width: 360px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: rgba(32, 54, 77, 0.94);
    color: white;
    box-shadow: var(--shadow);
    transition: all 0.25s ease;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.is-loading .kpi-card,
.is-loading .chart-panel,
.is-loading .rank-item,
.is-loading .report-row:not(.report-head) {
    transition: opacity 0.18s ease;
    opacity: 0.72;
}

.login-body {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 28px;
}

.login-shell {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    width: min(980px, 100%);
    min-height: 620px;
    overflow: hidden;
    border-radius: 24px;
    background: white;
    box-shadow: var(--shadow);
}

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

    .metric-strip .kpi-card {
        border-right: 1px solid rgba(28, 42, 58, 0.08);
        border-bottom: 1px solid rgba(28, 42, 58, 0.08);
    }

    .metric-strip .kpi-card:nth-child(3n) {
        border-right: 0;
    }

    .metric-strip .kpi-card:nth-last-child(-n + 2) {
        border-bottom: 0;
    }

    .tab-view-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .wide {
        grid-column: span 2;
    }
}

@media (max-width: 860px) {
    .dashboard {
        padding-inline: 14px;
    }

    .toolbar {
        flex-direction: column;
    }

    .filters {
        justify-content: flex-start;
    }

    .filters label,
    select {
        width: 100%;
    }

    .tab-view-grid {
        grid-template-columns: 1fr;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .metric-strip .kpi-card {
        min-height: 82px;
        border-right: 1px solid rgba(28, 42, 58, 0.08);
        border-bottom: 1px solid rgba(28, 42, 58, 0.08);
    }

    .metric-strip .kpi-card:nth-child(2n) {
        border-right: 0;
    }

    .metric-strip .kpi-card:last-child {
        grid-column: span 2;
        border-bottom: 0;
        border-right: 0;
    }

    .wide {
        grid-column: span 1;
    }

    .report-row {
        grid-template-columns: 1fr;
        gap: 8px;
        align-items: start;
    }

    .report-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 360px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .metric-strip .kpi-card,
    .metric-strip .kpi-card:nth-child(2n),
    .metric-strip .kpi-card:last-child {
        grid-column: span 1;
        border-right: 0;
    }
}

.login-visual {
    position: relative;
    padding: 30px;
    background: linear-gradient(145deg, var(--navy), var(--blue));
    overflow: hidden;
}

.login-visual::after {
    content: "";
    position: absolute;
    right: -110px;
    bottom: -120px;
    width: 360px;
    height: 360px;
    border: 54px solid rgba(255,255,255,0.08);
    border-radius: 50%;
}

.visual-frame {
    position: relative;
    z-index: 1;
    height: 100%;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 24px;
}

.visual-mark {
    width: 54px;
    height: 54px;
    margin: 38px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: rgba(255,255,255,0.16);
    border: 1px solid rgba(255,255,255,0.18);
}

.visual-mark svg { width: 28px; height: 28px; fill: white; }

.login-panel {
    display: grid;
    align-items: center;
    padding: 48px;
}

.product-kicker {
    margin: 0 0 8px;
    color: var(--soft);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.login-card h1 { margin-bottom: 8px; }
.login-muted, .security-note {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.7;
}

.login-card label {
    display: block;
    margin: 18px 0 8px;
    font-size: 13px;
    font-weight: 800;
}

.login-card input {
    width: 100%;
    height: 48px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 0 14px;
    font: inherit;
    background: white;
}

.login-card input:focus, select:focus {
    outline: none;
    border-color: rgba(26,54,93,0.35);
    box-shadow: 0 0 0 4px rgba(26,54,93,0.08);
}

.password-field {
    position: relative;
}

.password-field button {
    position: absolute;
    right: 7px;
    top: 7px;
    height: 34px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.primary-btn {
    width: 100%;
    height: 48px;
    margin-top: 22px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--navy), var(--blue));
    color: white;
    box-shadow: 0 12px 26px rgba(26,54,93,0.22);
}

.alert {
    display: none;
    margin-top: 18px;
    padding: 12px;
    border-radius: var(--radius-md);
    border: 1px solid #ffd4cf;
    background: #fff1f0;
    color: var(--rose);
    font-size: 13px;
}

.alert.show { display: block; }

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

@media (max-width: 980px) {
    .toolbar, .topbar { align-items: flex-start; flex-direction: column; height: auto; }
    .content-grid { grid-template-columns: 1fr; }
    .wide { grid-column: span 1; }
    .filters { justify-content: flex-start; }
    select { width: min(260px, 78vw); }
    .chart-large, .chart-compact { height: 280px; }
    .report-head { display: none; }
    .report-row {
        grid-template-columns: 1fr;
        gap: 8px;
        align-items: start;
    }
    .report-actions { justify-content: flex-start; }
    .login-shell { grid-template-columns: 1fr; min-height: 100vh; border-radius: 0; }
    .login-visual { min-height: 220px; }
}
