/* ======================================================
   REPORT V2 — Analytics Dashboard Styles
   Standalone page (does NOT extend base.html)
   ====================================================== */

/* ---- Full page reset ---- */
html {
    height: 100%;
}
body {
    margin: 0;
    height: 100%;
    box-sizing: border-box;
    overflow: hidden;
    /* Override components.css body padding — navbar is inside .analytics-root */
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

/* ======================================================
   DESIGN TOKENS — LIGHT THEME
   ====================================================== */
.analytics-root {
    --bg-deep:       #f4f2ee;
    --bg-base:       #faf9f7;
    --bg-surface:    #ffffff;
    --bg-elevated:   #ffffff;
    --bg-hover:      #f0eeea;

    --border-subtle: rgba(0,0,0,0.05);
    --border-light:  rgba(0,0,0,0.08);
    --border-med:    rgba(0,0,0,0.12);

    --text-1: #1a1a2e;
    --text-2: #6b6b7b;
    --text-3: #a0a0ab;
    --text-4: #d0d0d5;

    --gold:      #b8860b;
    --gold-soft: rgba(184,134,11,0.08);
    --blue:      #3574d4;
    --cyan:      #2a9d8f;
    --coral:     #d64545;
    --violet:    #7b5ec4;
    --amber:     #d4880f;

    --font-display: 'Cormorant Garamond', Georgia, serif;
    --font-body: -apple-system, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    --font-mono: 'DM Mono', 'Menlo', monospace;

    --sidebar-w: 256px;
    --detail-w: 340px;
    --navbar-h: 52px;
    --sub-nav-h: 44px;
    --ease: cubic-bezier(0.16,1,0.3,1);
    --dur: 0.35s;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.06);
}

/* ======================================================
   LAYOUT ROOT — fills remaining viewport below navbar
   ====================================================== */
.analytics-root {
    background: var(--bg-deep);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    height: calc(100vh - var(--navbar-h));
    margin-top: var(--navbar-h);
}

.analytics-layout {
    font-family: var(--font-body);
    color: var(--text-1);
}

/* Scope box-sizing to analytics-layout only, not navbar */
.analytics-layout *,
.analytics-sidebar-left *,
.analytics-sidebar-right *,
.analytics-main *,
.analytics-detail-inner * { box-sizing: border-box; }

.analytics-root ::-webkit-scrollbar { width: 5px; }
.analytics-root ::-webkit-scrollbar-track { background: transparent; }
.analytics-root ::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 4px; }
.analytics-root ::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.18); }

.analytics-layout a { color: inherit; text-decoration: none; }

/* ======================================================
   PANEL HANDLE TOGGLES
   One handle per side, always visible on panel edge
   ====================================================== */
.analytics-handle {
    position: absolute;
    top: 72px;
    z-index: 1070;
    width: 14px;
    height: 48px;
    padding: 0;
    border: none;
    background: var(--bg-base);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    transition: background 0.2s;
}
.analytics-handle:hover {
    background: var(--bg-hover);
}

.analytics-handle--left {
    right: -14px;
    border-radius: 0 6px 6px 0;
    border-left: none;
    border-right: 1px solid var(--border-subtle);
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
}
.is-closed > .analytics-handle--left {
    right: auto;
    left: 0;
    border-left: none;
    border-right: 1px solid var(--border-subtle);
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
}

.analytics-handle--right {
    left: -14px;
    border-radius: 6px 0 0 6px;
    border-right: none;
    border-left: 1px solid var(--border-subtle);
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
}
.is-closed > .analytics-handle--right {
    left: auto;
    right: 0;
    border-right: none;
    border-left: 1px solid var(--border-subtle);
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
}

.analytics-handle-bar {
    display: block;
    width: 2px;
    height: 18px;
    border-radius: 1px;
    background: var(--border-med);
    transition: background 0.2s;
}
.analytics-handle:hover .analytics-handle-bar {
    background: var(--gold);
}

/* ======================================================
   LAYOUT
   ====================================================== */
.analytics-layout {
    display: flex;
    height: 100%;
    position: relative;
}

.analytics-sub-nav {
    display: none;
    align-items: center;
    height: var(--sub-nav-h);
    padding: 0 var(--space-2, 0.5rem);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}
.analytics-sub-nav-back {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px;
    background: none; border: none;
    font-size: 1.25rem; color: var(--text-1);
    cursor: pointer; border-radius: 0.5rem; padding: 0;
    transition: background 0.15s;
}
.analytics-sub-nav-back:active { background: var(--bg-hover); }
.analytics-sub-nav-title {
    flex: 1; text-align: center;
    font-size: 0.9375rem; font-weight: 600;
    color: var(--text-1); margin-right: 36px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- Left Sidebar ---- */
.analytics-sidebar-left {
    position: relative;
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    height: 100%;
    background: var(--bg-base);
    border-right: 1px solid var(--border-subtle);
    overflow: visible;
    transition: width var(--dur) var(--ease), min-width var(--dur) var(--ease);
    flex-shrink: 0;
}
.analytics-sidebar-left.is-closed {
    width: 0;
    min-width: 0;
    border-right: none;
}
.analytics-sidebar-left.is-closed .analytics-sidebar-inner {
    visibility: hidden;
    opacity: 0;
    overflow: hidden;
    height: 0;
}

.analytics-sidebar-inner {
    position: relative;
    width: var(--sidebar-w);
    height: 100%;
    overflow-y: auto;
    padding: 0.5rem 0 1.25rem;
}

/* ---- Right Sidebar ---- */
.analytics-sidebar-right {
    position: relative;
    width: var(--detail-w);
    min-width: var(--detail-w);
    height: 100%;
    background: var(--bg-base);
    border-left: 1px solid var(--border-subtle);
    overflow: visible;
    transition: width var(--dur) var(--ease), min-width var(--dur) var(--ease);
    flex-shrink: 0;
}
.analytics-sidebar-right.is-closed {
    width: 0;
    min-width: 0;
    border-left: none;
}
.analytics-sidebar-right.is-closed .analytics-detail-inner {
    visibility: hidden;
    opacity: 0;
    overflow: hidden;
    height: 0;
}

.analytics-detail-inner {
    width: var(--detail-w);
    height: 100%;
    overflow-y: auto;
    padding: 1.5rem 1.25rem;
}

/* ---- Main Panel ---- */
.analytics-main-wrapper {
    flex: 1;
    position: relative;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.analytics-main {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2rem 2.5rem 4rem;
    min-width: 0;
    background: var(--bg-deep);
}
.analytics-page-wrap { max-width: 960px; margin: 0 auto; }

/* ======================================================
   NAV ITEMS (LEFT SIDEBAR)
   ====================================================== */
.analytics-nav-section { margin-bottom: 1.75rem; }
.analytics-nav-section-label {
    font-family: var(--font-mono);
    font-size: 0.6rem; font-weight: 500;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.18em;
    padding: 0 1.25rem;
    margin-bottom: 0.6rem;
}

.analytics-nav-item {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.6rem 1.25rem;
    font-size: 0.88rem; color: var(--text-2);
    transition: background 0.15s, color 0.15s;
    cursor: pointer; border: none; background: none; width: 100%;
    text-align: left;
}
.analytics-nav-item:hover { background: var(--bg-hover); color: var(--text-1); }
.analytics-nav-item.active {
    color: var(--gold);
    background: var(--gold-soft);
}
.analytics-nav-item i { font-size: 1rem; width: 1.1rem; text-align: center; }

.analytics-nav-quick {
    display: block;
    padding: 0.4rem 1.25rem 0.4rem 2.65rem;
    font-size: 0.78rem; color: var(--text-3);
    transition: color 0.15s;
    cursor: pointer;
}
.analytics-nav-quick:hover { color: var(--text-2); }

.analytics-nav-divider {
    height: 1px; background: var(--border-light);
    margin: 0.75rem 1.25rem;
}

/* ======================================================
   DETAIL SIDEBAR (RIGHT)
   ====================================================== */
.analytics-detail-label {
    font-family: var(--font-mono);
    font-size: 0.6rem; font-weight: 500;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.18em;
}
.analytics-detail-title {
    font-family: var(--font-display);
    font-size: 1.4rem; font-weight: 400;
    color: var(--text-1);
    margin: 0.5rem 0 0.25rem;
}
.analytics-detail-divider {
    width: 36px; height: 2px;
    background: var(--gold);
    margin: 1rem 0 1.5rem;
    border-radius: 1px;
}
.analytics-detail-section { margin-bottom: 1.5rem; }
.analytics-detail-section h4 {
    font-size: 0.82rem; font-weight: 600;
    color: var(--text-1);
    margin-bottom: 0.45rem;
}
.analytics-detail-section p {
    font-size: 0.78rem; line-height: 1.7;
    color: var(--text-2);
}
.analytics-detail-highlight {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    background: var(--gold-soft);
    color: var(--gold);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    border-radius: 3px;
    font-weight: 500;
}

/* ======================================================
   PAGE HERO
   ====================================================== */
.analytics-page-hero {
    padding: 2.5rem 0 2rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-subtle);
    position: relative;
}
.analytics-page-hero::after {
    content: '';
    position: absolute;
    bottom: -1px; left: 0;
    width: 48px; height: 2px;
    background: var(--gold);
    border-radius: 1px;
}
.analytics-page-number {
    font-family: var(--font-display);
    font-size: 4.5rem; font-weight: 300;
    color: var(--text-4);
    line-height: 1;
    margin-bottom: -0.75rem;
}
.analytics-page-title {
    font-family: var(--font-display);
    font-size: 2.2rem; font-weight: 400;
    color: var(--text-1);
    letter-spacing: 0.01em;
}
.analytics-page-subtitle {
    font-family: var(--font-mono);
    font-size: 0.62rem; font-weight: 400;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.16em;
    margin-top: 0.4rem;
}
.analytics-page-desc {
    font-size: 0.88rem; line-height: 1.65;
    color: var(--text-2);
    max-width: 580px;
    margin-top: 0.75rem;
}

/* ======================================================
   KPI ROW
   ====================================================== */
.analytics-kpi-row {
    display: flex;
    gap: 1.5rem;
    padding: 1.5rem 0;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-subtle);
}
.analytics-kpi-item { flex: 1; min-width: 0; }
.analytics-kpi-label {
    font-family: var(--font-mono);
    font-size: 0.6rem; font-weight: 500;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    margin-bottom: 0.5rem;
}
.analytics-kpi-value {
    font-family: var(--font-mono);
    font-size: 1.75rem; font-weight: 500;
    color: var(--text-1);
    line-height: 1.1;
}
.analytics-kpi-unit {
    font-size: 0.9rem; font-weight: 300;
    color: var(--text-2);
    margin-left: 0.15rem;
}
.analytics-kpi-change {
    font-family: var(--font-mono);
    font-size: 0.7rem; font-weight: 400;
    margin-top: 0.35rem;
}
.analytics-kpi-up { color: var(--cyan); }
.analytics-kpi-down { color: var(--coral); }

/* ======================================================
   CHART SECTIONS
   ====================================================== */
.analytics-chart-section {
    margin-bottom: 3rem;
    scroll-margin-top: calc(var(--navbar-h) + 1.5rem);
}
.analytics-section-header {
    display: flex; align-items: flex-start; gap: 1rem;
    margin-bottom: 1.25rem;
}
.analytics-section-num {
    font-family: var(--font-display);
    font-size: 2.8rem; font-weight: 300;
    color: var(--text-4);
    line-height: 1;
    letter-spacing: -0.02em;
    flex-shrink: 0;
}
.analytics-section-title {
    font-size: 1.05rem; font-weight: 600;
    color: var(--text-1);
    margin: 0;
}
.analytics-section-sub {
    font-family: var(--font-mono);
    font-size: 0.6rem; font-weight: 400;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-top: 0.2rem;
}
.analytics-chart-caption {
    font-size: 0.82rem; line-height: 1.7;
    color: var(--text-2);
    margin-top: 1rem;
    max-width: 720px;
}

/* ======================================================
   CLASS STATS TABLE
   ====================================================== */
.analytics-table-wrap {
    overflow-x: auto;
    margin-top: 0.5rem;
}

.analytics-stats-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--text-1);
}
.analytics-stats-table thead th {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.7rem 1rem;
    border-bottom: 2px solid var(--border-med);
    text-align: left;
    white-space: nowrap;
}
.analytics-stats-table tbody td {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
    vertical-align: middle;
}
.analytics-stats-table tbody tr:hover {
    background: var(--bg-hover);
}
.analytics-stats-table .cell-class {
    font-weight: 600;
    color: var(--text-1);
}
.analytics-stats-table .cell-score strong {
    font-weight: 600;
    color: var(--gold);
}

/* Rank badges */
.analytics-badge-rank {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.badge-rank-top {
    background: rgba(42, 157, 143, 0.12);
    color: #1a7a6d;
}
.badge-rank-mid {
    background: rgba(212, 136, 15, 0.12);
    color: #a06810;
}
.badge-rank-low {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-3);
}

/* ======================================================
   PAGE SWITCH ARROW BUTTONS
   ====================================================== */
.analytics-page-arrow {
    position: absolute;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border-med);
    background: var(--bg-surface);
    color: var(--text-2);
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all 0.2s var(--ease);
    padding: 0;
    outline: none;
}
.analytics-page-arrow:hover {
    background: var(--bg-hover);
    color: var(--gold);
    border-color: var(--gold);
    box-shadow: 0 4px 24px rgba(184,134,11,0.12);
}
.analytics-page-arrow:active {
    transform: scale(0.92);
}
.analytics-page-arrow--prev {
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
}
.analytics-page-arrow--next {
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
}
@media (max-width: 767.98px) {
    .analytics-page-arrow--next {
        bottom: calc(var(--bottom-bar-height, 56px) + env(safe-area-inset-bottom, 0px) + 40px);
    }
}
.analytics-page-arrow--prev:active {
    transform: translateX(-50%) scale(0.92);
}
.analytics-page-arrow--next:active {
    transform: translateX(-50%) scale(0.92);
}

/* Arrow button transition */
.analytics-page-arrow-enter-active {
    transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}
.analytics-page-arrow-leave-active {
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.analytics-page-arrow-enter-from {
    opacity: 0;
    transform: scale(0.6);
}
.analytics-page-arrow-leave-to {
    opacity: 0;
    transform: scale(0.6);
}

/* ======================================================
   MOBILE / RESPONSIVE
   Breakpoint: 768px matches navbar ↔ bottom-tab-bar switch
   ====================================================== */
@media (max-width: 1199px) {
    .analytics-root { --detail-w: 300px; }
}

@media (max-width: 767.98px) {
    .analytics-root {
        margin-top: 0;
        height: 100vh;
        display: flex;
        flex-direction: column;
    }
    .analytics-layout {
        flex: 1;
        min-height: 0;
        height: auto;
    }
    .analytics-sidebar-left, .analytics-sidebar-right {
        position: fixed;
        top: var(--sub-nav-h);
        height: calc(100vh - var(--sub-nav-h));
        z-index: 1050;
        transition: transform var(--dur) var(--ease);
        width: var(--sidebar-w) !important;
        min-width: var(--sidebar-w) !important;
        box-shadow: var(--shadow-md);
        overflow: visible;
    }
    .analytics-sidebar-left { left: 0; transform: translateX(-100%); }
    .analytics-sidebar-left.is-open { transform: translateX(0); }
    .analytics-sidebar-left.is-closed { transform: translateX(-100%); }

    .analytics-sidebar-right { right: 0; transform: translateX(100%); width: var(--detail-w) !important; min-width: var(--detail-w) !important; }
    .analytics-sidebar-right.is-open { transform: translateX(0); }
    .analytics-sidebar-right.is-closed { transform: translateX(100%); }

    .analytics-main { padding: 1.5rem 1.25rem 5rem; }

    .analytics-handle { top: 20px; width: 12px; height: 40px; }
    .analytics-handle-bar { width: 2px; height: 14px; }
    .analytics-handle--left {
        right: -12px;
        left: auto;
    }
    .is-closed > .analytics-handle--left {
        right: -12px;
        left: auto;
    }
    .analytics-handle--right {
        left: -12px;
        right: auto;
    }
    .is-closed > .analytics-handle--right {
        left: -12px;
        right: auto;
    }

    .analytics-sub-nav {
        display: flex;
    }
    .analytics-root .app-navbar {
        display: none !important;
    }
}

@media (max-width: 600px) {
    .analytics-sidebar-left, .analytics-sidebar-right {
        width: 85vw !important;
        min-width: 85vw !important;
    }
    .analytics-kpi-row { flex-wrap: wrap; gap: 1rem; }
    .analytics-kpi-item { flex: 1 1 40%; }
    .analytics-page-number { font-size: 3rem; }
    .analytics-page-title { font-size: 1.6rem; }
    .analytics-main { padding: 1rem 0.85rem 5rem; }
    .analytics-handle { width: 10px; height: 36px; }
    .analytics-handle-bar { width: 1.5px; height: 12px; }
}

/* ---- Backdrop ---- */
.analytics-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.15);
    z-index: 1040;
    backdrop-filter: blur(3px);
}

/* ======================================================
   TRANSITIONS
   ====================================================== */
.analytics-fade-enter-active, .analytics-fade-leave-active {
    transition: opacity 0.22s ease, transform 0.22s ease;
}
.analytics-fade-enter-from { opacity: 0; transform: translateY(8px); }
.analytics-fade-leave-to { opacity: 0; transform: translateY(-4px); }

.analytics-backdrop-enter-active, .analytics-backdrop-leave-active { transition: opacity 0.2s ease; }
.analytics-backdrop-enter-from, .analytics-backdrop-leave-to { opacity: 0; }

/* ======================================================
   SUBTLE GRAIN
   ====================================================== */
.analytics-root::before {
    content: '';
    position: fixed; inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
    opacity: 0.018;
    pointer-events: none;
    z-index: 9999;
}

/* Staggered entrance */
.analytics-stagger-in { opacity: 0; animation: analyticsStaggerFade 0.55s var(--ease) forwards; }
.analytics-stagger-in:nth-child(2) { animation-delay: 0.06s; }
.analytics-stagger-in:nth-child(3) { animation-delay: 0.12s; }
.analytics-stagger-in:nth-child(4) { animation-delay: 0.18s; }
.analytics-stagger-in:nth-child(5) { animation-delay: 0.24s; }
.analytics-stagger-in:nth-child(6) { animation-delay: 0.30s; }

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

/* ======================================================
   TREND PAGE — Controls & Highlights
   ====================================================== */
.analytics-trend-controls {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.analytics-trend-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.85rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-2);
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.analytics-trend-btn:hover {
    background: var(--bg-hover);
    color: var(--text-1);
    border-color: var(--border-med);
}
.analytics-trend-btn.active {
    color: var(--gold);
    background: var(--gold-soft);
    border-color: rgba(184,134,11,0.25);
}
.analytics-trend-btn i { font-size: 0.85rem; }

.analytics-trend-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    padding: 10px 4px 0;
    justify-content: center;
}
.analytics-trend-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-2);
    cursor: pointer;
    transition: opacity 0.2s, color 0.2s;
    user-select: none;
    white-space: nowrap;
}
.analytics-trend-legend-item:hover {
    color: var(--text-1);
}
.analytics-trend-legend-item.is-disabled {
    opacity: 0.4;
}
.analytics-trend-legend-item .legend-line {
    display: inline-block;
    width: 16px;
    height: 3px;
    border-radius: 2px;
    transition: background-color 0.2s;
}

.analytics-trend-current {
    background: var(--gold-soft) !important;
    border-left: 2px solid var(--gold);
    border-right: 2px solid var(--gold);
}
.analytics-trend-table td > div { margin: 1px 0; }
.analytics-trend-table thead th {
    padding: 0.5rem 0.3rem;
    text-align: center;
    font-size: 0.68rem;
    white-space: normal;
    word-break: break-all;
}
.analytics-trend-table thead th:first-child {
    text-align: left;
    padding-left: 0.7rem;
}
.analytics-trend-table tbody td {
    padding: 0.5rem 0.4rem;
    text-align: center;
    font-size: 0.75rem;
}
.analytics-trend-table tbody td:first-child {
    text-align: left;
    padding-left: 0.7rem;
}
.analytics-trend-th-name {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.analytics-trend-th-name span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
}
.analytics-trend-th-date {
    font-size: 0.65rem;
    color: var(--text-3);
    margin-top: 1px;
}
.analytics-trend-table thead th[title] {
    cursor: help;
    min-width: 50px;
}

.analytics-sankey-students-panel {
    margin-top: 1rem;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: var(--bg-surface);
    max-height: 320px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.analytics-sankey-students-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.85rem;
}
.analytics-sankey-students-body {
    overflow-y: auto;
    flex: 1;
    padding: 0.5rem;
}
.analytics-sankey-students-body table {
    margin: 0;
}
.analytics-sankey-students-body th,
.analytics-sankey-students-body td {
    padding: 0.3rem 0.6rem;
    white-space: nowrap;
}

.analytics-sankey-select {
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    background: var(--bg-surface);
    color: var(--text-1);
    font-size: 0.82rem;
    cursor: pointer;
    max-width: 200px;
    outline: none;
    transition: border-color 0.2s;
}
.analytics-sankey-select:focus {
    border-color: var(--blue);
}

/* ======================================================
   QUESTION & KNOWLEDGE ANALYSIS — Shared Styles
   ====================================================== */

/* Toggle label (show rate / show score) */
.analytics-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-2);
    cursor: pointer;
    margin-left: auto;
    white-space: nowrap;
    user-select: none;
}
.analytics-toggle-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--gold);
    cursor: pointer;
}

/* Sortable table headers */
.analytics-sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.analytics-sortable:hover { color: var(--text-1); }
.analytics-sortable.active { color: var(--gold); }
.analytics-sortable i { font-size: 0.7rem; margin-left: 0.2rem; vertical-align: middle; }

/* Rate badges */
.analytics-badge-rate {
    display: inline-block;
    padding: 0.12rem 0.5rem;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.analytics-badge-rate-high {
    background: rgba(42, 157, 143, 0.12);
    color: #1a7a6d;
}
.analytics-badge-rate-mid {
    background: rgba(212, 136, 15, 0.12);
    color: #a06810;
}
.analytics-badge-rate-low {
    background: rgba(214, 69, 69, 0.12);
    color: #b33a3a;
}

/* Inline rate text colors */
.analytics-rate-high { color: var(--cyan); font-weight: 600; }
.analytics-rate-mid { color: var(--amber); font-weight: 600; }
.analytics-rate-low { color: var(--coral); font-weight: 600; }

/* Knowledge / Question table specific */
.analytics-kp-table .cell-class,
.analytics-question-table .cell-class {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ======================================================
   KNOWLEDGE CLOUD (TREEMAP) PAGE
   ====================================================== */
.kp-treemap-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.kp-fullscreen-exit-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(8px);
}

/* Browser Fullscreen API styles */
div:fullscreen {
    background: #fff;
    padding: 0;
}
div:fullscreen .kp-treemap-legend {
    padding: 12px 16px 0;
}
div:fullscreen .kp-treemap-chart {
    height: calc(100vh - 50px) !important;
}
div:fullscreen .kp-fullscreen-exit-btn {
    position: fixed;
    top: 10px;
    right: 10px;
}

.kp-treemap-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-2);
}
.kp-treemap-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.kp-treemap-legend-swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid var(--border-light);
}

.kp-fullscreen-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.3rem 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-2);
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}
.kp-fullscreen-btn:hover {
    background: var(--bg-hover);
    color: var(--text-1);
    border-color: var(--border-med);
}
.kp-fullscreen-btn i { font-size: 0.85rem; }

body.kp-fullscreen-active {
    overflow: hidden !important;
}

/* ======================================================
   STUDENT RANKING PAGE
   ====================================================== */
.analytics-ranking-controls {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
    flex-wrap: wrap;
}
.analytics-search-input {
    padding: 0.3rem 0.65rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-1);
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    outline: none;
    transition: border-color 0.15s;
    min-width: 120px;
}
.analytics-search-input:focus {
    border-color: var(--gold);
}
.analytics-search-input option {
    font-family: var(--font-body);
}

.analytics-radar-class-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 1rem;
    padding: 0.6rem 0.8rem;
    background: var(--bg-deep);
    border-radius: var(--radius);
}
.analytics-radar-class-label {
    font-size: 0.82rem;
    color: var(--text-3);
    font-weight: 600;
    margin-right: 4px;
    white-space: nowrap;
}
.analytics-radar-class-btn {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 16px;
    border: 1px solid var(--border-med);
    background: var(--bg-surface);
    color: var(--text-2);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font-body);
}
.analytics-radar-class-btn:hover {
    border-color: var(--blue);
    color: var(--blue);
}
.analytics-radar-class-btn.active {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
}
.analytics-radar-class-btn--primary {
    background: var(--blue) !important;
    border-color: var(--blue) !important;
    color: #fff !important;
}
.analytics-radar-class-btn--primary:hover:not(:disabled) {
    opacity: 0.9;
}
.analytics-radar-class-btn--primary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.analytics-mode-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border-med);
    background: var(--bg-surface);
    color: var(--text-2);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font-body);
    margin-left: auto;
    white-space: nowrap;
}
.analytics-mode-toggle-btn:hover {
    border-color: var(--blue);
    color: var(--blue);
}
.analytics-mode-toggle-btn i {
    font-size: 0.9rem;
}

.analytics-ranking-table .cell-score strong {
    font-weight: 600;
    color: var(--gold);
}
.analytics-ranking-table .cell-class {
    font-weight: 600;
    color: var(--text-1);
}

/* ======================================================
   SIDEBAR — Report Management Section
   ====================================================== */
.analytics-nav-item--sub {
    font-size: 0.82rem;
    padding: 0.5rem 1.25rem;
}
.analytics-nav-item--sub i {
    font-size: 0.9rem;
    width: 1.1rem;
    text-align: center;
}

/* ======================================================
   REPORT INFO PAGE
   ====================================================== */
.ri-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}
.ri-meta-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    transition: border-color 0.15s;
}
.ri-meta-card:hover {
    border-color: var(--border-med);
}
.ri-meta-icon {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    background: var(--gold-soft);
    color: var(--gold);
    border-radius: 8px;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.ri-meta-label {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.15rem;
}
.ri-meta-value {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-1);
}

.ri-actions-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.ri-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1.2rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 8px;
    border: 1px solid;
    cursor: pointer;
    transition: all 0.15s;
}
.ri-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.ri-action-btn--regen {
    color: #b45309;
    background: #fef3c7;
    border-color: #fcd34d;
}
.ri-action-btn--regen:hover:not(:disabled) {
    background: #fde68a;
    border-color: #fbbf24;
}
.ri-action-btn--delete {
    color: #b91c1c;
    background: #fee2e2;
    border-color: #fca5a5;
}
.ri-action-btn--delete:hover:not(:disabled) {
    background: #fecaca;
    border-color: #f87171;
}

.ri-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.ri-modal {
    background: #fff;
    border-radius: 14px;
    width: 90%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    overflow: hidden;
}
.ri-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
}
.ri-modal-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-1);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.ri-modal-close {
    background: none;
    border: none;
    font-size: 1rem;
    color: var(--text-3);
    cursor: pointer;
    padding: 0.25rem;
}
.ri-modal-close:hover { color: var(--text-1); }
.ri-modal-body {
    padding: 1.25rem 1.5rem;
}
.ri-modal-alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}
.ri-modal-alert--warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}
.ri-modal-alert--info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}
.ri-parent-list {
    margin: 0.5rem 0 0;
    padding-left: 1.2rem;
}
.ri-parent-list li {
    margin-bottom: 0.25rem;
}
.ri-parent-list a {
    color: #1d4ed8;
    text-decoration: none;
}
.ri-parent-list a:hover { text-decoration: underline; }
.ri-radio-group p {
    font-size: 0.88rem;
    color: var(--text-2);
    margin: 0 0 0.75rem;
}
.ri-radio-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    font-size: 0.88rem;
    color: var(--text-2);
    cursor: pointer;
}
.ri-radio-item input[type="radio"] {
    accent-color: var(--gold);
}
.ri-radio-item--disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.ri-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-light);
}
.ri-modal-btn {
    padding: 0.5rem 1.1rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 8px;
    border: 1px solid;
    cursor: pointer;
    transition: all 0.15s;
}
.ri-modal-btn--cancel {
    color: var(--text-2);
    background: var(--bg-surface);
    border-color: var(--border-light);
}
.ri-modal-btn--cancel:hover {
    background: var(--bg-hover);
}
.ri-modal-btn--confirm {
    color: #92400e;
    background: #fef3c7;
    border-color: #fcd34d;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.ri-modal-btn--confirm:hover {
    background: #fde68a;
}

.ri-modal-enter-active,
.ri-modal-leave-active {
    transition: opacity 0.2s ease;
}
.ri-modal-enter-from,
.ri-modal-leave-to {
    opacity: 0;
}

/* ======================================================
   COMPOSITE INFO PAGE
   ====================================================== */
.ci-tree-container {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 1.25rem;
}
.ci-tree-node {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0;
    font-size: 0.88rem;
    line-height: 1.5;
}
.ci-tree-connector {
    color: var(--text-3);
    font-family: var(--font-mono);
    flex-shrink: 0;
    margin-right: 0.25rem;
}
.ci-tree-name {
    font-weight: 600;
    color: var(--text-1);
}
.ci-tree-name--current {
    color: var(--gold);
}
.ci-tree-name--link {
    color: #1d4ed8;
    text-decoration: none;
    transition: color 0.15s;
}
.ci-tree-name--link:hover {
    color: #1e40af;
    text-decoration: underline;
}
.ci-tree-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.1rem 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 500;
    border-radius: 4px;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}
.ci-tree-badge--composite {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}
.ci-tree-badge--single {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}
.ci-tree-subject {
    font-size: 0.78rem;
    color: var(--text-3);
    font-style: italic;
}

.ci-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-3);
}
.ci-empty-state i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}
.ci-empty-state p {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-2);
    margin: 0 0 0.35rem;
}
.ci-empty-state small {
    font-size: 0.82rem;
}

/* ======================================================
   SIDEBAR — Report Info & Badges
   ====================================================== */
.analytics-sidebar-info {
    padding: 0.75rem 1rem 0.5rem;
    border-bottom: 1px solid var(--border-light);
}
.analytics-sidebar-title {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-1);
    line-height: 1.4;
    margin-bottom: 0.5rem;
    word-break: break-all;
}
.analytics-sidebar-badges {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}
.analytics-sbadge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 500;
    border-radius: 4px;
    letter-spacing: 0.02em;
}
.analytics-sbadge--composite {
    background: rgba(251,191,36,0.15);
    color: #b45309;
}
.analytics-sbadge--single {
    background: rgba(59,130,246,0.12);
    color: #2563eb;
}
.analytics-sbadge--subject {
    background: rgba(34,197,94,0.12);
    color: #16a34a;
}
.analytics-sbadge--grade {
    background: rgba(139,92,246,0.12);
    color: #7c3aed;
}

/* Sidebar skeleton loading */
.analytics-skeleton-line {
    border-radius: 4px;
    background: linear-gradient(90deg, var(--border-light) 25%, rgba(0,0,0,0.04) 50%, var(--border-light) 75%);
    background-size: 200% 100%;
    animation: analytics-shimmer 1.5s ease-in-out infinite;
}
.analytics-skeleton-line--title {
    height: 1.15rem;
    width: 75%;
    margin-bottom: 0.5rem;
}
.analytics-skeleton-badge {
    display: inline-block;
    height: 1.1rem;
    width: 2.8rem;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--border-light) 25%, rgba(0,0,0,0.04) 50%, var(--border-light) 75%);
    background-size: 200% 100%;
    animation: analytics-shimmer 1.5s ease-in-out infinite;
}
@keyframes analytics-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ======================================================
   OVERVIEW — Threshold Modal & Sortable Table
   ====================================================== */
.ov-threshold-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.85rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid var(--border-med);
    background: var(--bg-surface);
    color: var(--text-2);
    cursor: pointer;
    transition: all 0.15s;
    margin-left: auto;
    white-space: nowrap;
    flex-shrink: 0;
}
.ov-threshold-btn:hover {
    background: var(--bg-hover);
    border-color: var(--gold);
    color: var(--gold);
}

.ov-threshold-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
@media (max-width: 480px) {
    .ov-threshold-grid { grid-template-columns: 1fr; }
}
.ov-threshold-item {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.ov-threshold-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-2);
}
.ov-threshold-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px; height: 22px;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    border-radius: 4px;
    flex-shrink: 0;
}
.ov-threshold-input {
    width: 100%;
    padding: 0.4rem 0.6rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    background: var(--bg-surface);
    color: var(--text-1);
    outline: none;
    transition: border-color 0.15s;
}
.ov-threshold-input:focus {
    border-color: var(--gold);
}
.ov-threshold-readonly {
    padding: 0.4rem 0.6rem;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--text-3);
    background: var(--bg-hover);
    border-radius: 6px;
}

.ov-sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.ov-sortable:hover {
    color: var(--gold);
}
.ov-sortable i {
    font-size: 0.65rem;
    margin-left: 0.2rem;
    opacity: 0.5;
}
.ov-sortable:hover i {
    opacity: 1;
}

/* ======================================================
   STUDENT PROFILE PAGE
   ====================================================== */
.analytics-profile-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-top: 0.75rem;
}
.analytics-profile-card {
    text-align: center;
    padding: 1rem 0.75rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    transition: border-color 0.15s;
}
.analytics-profile-card:hover {
    border-color: var(--border-med);
}
.analytics-profile-card-value {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-1);
    line-height: 1.3;
}
.analytics-profile-card-label {
    font-size: 0.72rem;
    color: var(--text-3);
    margin-top: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}
.analytics-badge-rank {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 700;
}
.analytics-badge-rank.badge-rank-top {
    background: rgba(251,191,36,0.15);
    color: #b45309;
}
.analytics-badge-rank.badge-rank-mid {
    background: rgba(59,130,246,0.1);
    color: #2563eb;
}
.analytics-badge-rank.badge-rank-low {
    background: rgba(0,0,0,0.04);
    color: var(--text-2);
}
.analytics-student-link {
    color: var(--blue);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.15s;
}
.analytics-student-link:hover {
    color: var(--gold);
    text-decoration: underline;
}
