/* eCRF — RSV sentinel surveillance
   Design language: docs/design/ecrf-clinical-mockup.html (the user's
   canonical mockup). All tokens are taken verbatim from that file. Do
   not reinvent tokens; extend this set instead.

   Font: Vazirmatn self-hosted from /static/fonts/. Foreign CDNs
   (fonts.googleapis.com, unpkg.com) were removed because they are
   slow-to-blocked from the university network. */

@font-face {
    font-family: 'Vazirmatn';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/Vazirmatn-Regular.cdc140628f11.woff2") format('woff2');
}
@font-face {
    font-family: 'Vazirmatn';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/Vazirmatn-Medium.dd2193b32cbe.woff2") format('woff2');
}
@font-face {
    font-family: 'Vazirmatn';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("../fonts/Vazirmatn-SemiBold.9260c1927872.woff2") format('woff2');
}
@font-face {
    font-family: 'Vazirmatn';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/Vazirmatn-Bold.7958481fe611.woff2") format('woff2');
}

:root {
    --ink:    #0F2027;
    --ink-2:  #3A4E57;
    --ink-3:  #6B8089;
    --ink-4:  #9DAEB5;
    --canvas: #EDF1F2;
    --card:   #FFFFFF;
    --panel:  #F5F8F8;
    --line:   #DCE4E6;
    --line-2: #C5D2D5;

    --teal:      #0E7C86;
    --teal-bg:   #E2F0F1;
    --teal-line: #9CCACE;
    --teal-dark: #0A6971;

    --red:      #B93B34;
    --red-bg:   #FAE9E7;
    --red-line: #E7B4AE;

    --amber:      #A96B12;
    --amber-bg:   #FBF0DD;
    --amber-line: #E8CB94;

    --green:    #2A6E51;
    --green-bg: #E3F0EA;

    --r:    8px;
    --r-lg: 14px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    font-family: 'Vazirmatn', system-ui, sans-serif;
    background: var(--canvas);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}
body { padding: 28px 20px; }

/* ── shell (fixed 1080px frame, mockup 1:1) ───────────────────────── */
.shell {
    max-width: 1080px;
    margin: 0 auto;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    overflow: hidden;
}

/* ── app bar (dark, sits INSIDE the shell) ────────────────────────── */
.appbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 20px;
    background: var(--ink);
    color: #fff;
    flex-wrap: wrap;
}
.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    text-decoration: none;
    color: inherit;
}
.brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    background: var(--teal);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: -0.02em;
    color: #fff;
}
.brand h1 {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0;
    color: #fff;
}
.brand p {
    font-size: 11.5px;
    color: #9FB4BC;
    font-weight: 400;
    margin: 0;
}
.appbar-side {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 12px;
    color: #B7C7CD;
}
.appbar-side .who {
    display: flex;
    align-items: center;
    gap: 8px;
}
.appbar-clock {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.15;
    padding-inline-end: 10px;
    border-inline-end: 1px solid rgba(255, 255, 255, 0.08);
}
.appbar-clock-date {
    font-size: 11px;
    color: #8FA5AC;
    letter-spacing: 0.2px;
}
.appbar-clock-time {
    font-size: 14px;
    color: #E7F0F2;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}
.nav-badge {
    display: inline-grid;
    place-items: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #F59E0B;
    color: #1F2937;
    font-size: 10.5px;
    font-weight: 700;
    margin-inline-start: 4px;
    font-variant-numeric: tabular-nums;
}
.who-av {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #294049;
    display: grid;
    place-items: center;
    font-size: 10.5px;
    color: #CFDDE1;
    font-weight: 600;
}
.appbar-logout {
    background: transparent;
    border: 1px solid rgba(207, 221, 225, 0.3);
    color: #CFDDE1;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11.5px;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
}
.appbar-logout:hover {
    background: rgba(185, 59, 52, 0.15);
    border-color: rgba(231, 180, 174, 0.4);
    color: #FCA5A5;
}
.appbar-login {
    background: transparent;
    border: 1px solid rgba(207, 221, 225, 0.4);
    color: #fff;
    padding: 5px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
}
.appbar-login:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

/* ── patient band (subject/CRF pages) ─────────────────────────────── */
.band {
    padding: 15px 20px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
}
.band-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}
.pt { display: flex; align-items: center; gap: 12px; }
.pt-av {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--teal-bg);
    border: 1px solid var(--teal-line);
    display: grid;
    place-items: center;
    color: var(--teal);
    font-weight: 700;
    font-size: 12px;
    font-family: "SF Mono", "Menlo", "Consolas", monospace;
    letter-spacing: 0.02em;
}
.pt h2 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.015em;
    margin: 0;
    color: var(--ink);
}
.pt p { font-size: 12px; color: var(--ink-3); margin: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── shell body / main ─────────────────────────────────────────────── */
.main { padding: 17px 20px 20px; }

/* Two-column layout reserved for subject/CRF pages (nav sidebar +
   main). Dashboards + list pages use only .main. */
.body { display: grid; grid-template-columns: 186px minmax(0, 1fr); }
.nav-side {
    border-left: 1px solid var(--line);
    background: var(--panel);
    padding: 14px 11px;
}
.nav-eyebrow {
    font-size: 10.5px;
    color: var(--ink-4);
    font-weight: 600;
    letter-spacing: 0.06em;
    padding: 0 8px;
    margin-bottom: 9px;
    text-transform: uppercase;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 9px;
    border-radius: var(--r);
    font-size: 13px;
    color: var(--ink-2);
    margin-bottom: 1px;
}
.nav-item .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex: none;
    background: #D3DCDE;
}
.nav-item.done .dot { background: var(--green); }
.nav-item.todo { color: var(--ink-4); }
.nav-item.active {
    background: var(--teal);
    color: #fff;
    font-weight: 600;
}
.nav-item.active .dot { background: #fff; }
.nav-item-link { color: inherit; text-decoration: none; }
.nav-item-link:hover { color: var(--teal); }

.prog {
    margin-top: 15px;
    padding: 11px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--r);
}
.prog-row {
    display: flex;
    justify-content: space-between;
    font-size: 11.5px;
    color: var(--ink-3);
    margin-bottom: 7px;
}
.prog-row b { color: var(--ink); font-weight: 600; }
.prog-track {
    height: 5px;
    border-radius: 3px;
    background: #E3EAEB;
    overflow: hidden;
}
.prog-fill {
    height: 100%;
    background: var(--teal);
    border-radius: 3px;
    transition: width 0.25s ease;
}

/* ── field grids (multi-column) ───────────────────────────────────── */
.fields-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 11px;
    margin-top: 4px;
}

/* ── section header (teal accent bar) ─────────────────────────────── */
.sec-head {
    display: flex;
    align-items: baseline;
    gap: 9px;
    margin: 0 0 10px;
}
.sec-head h3 {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0;
}
.sec-head span {
    font-size: 11.5px;
    color: var(--ink-4);
}
.sec-head::before {
    content: "";
    width: 3px;
    height: 13px;
    border-radius: 2px;
    background: var(--teal);
    align-self: center;
}

/* ── form controls ────────────────────────────────────────────────── */
.field { margin-bottom: 12px; }
.field label {
    display: block;
    font-size: 11px;
    color: var(--ink-3);
    margin-bottom: 5px;
    font-weight: 500;
}
.input {
    height: 36px;
    width: 100%;
    border: 1px solid var(--line-2);
    border-radius: var(--r);
    background: #fff;
    padding: 0 11px;
    font-size: 13px;
    color: var(--ink);
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px var(--teal-bg);
}
.input.is-invalid {
    border-color: var(--red);
    box-shadow: 0 0 0 3px var(--red-bg);
}

/* ── chip / pill ──────────────────────────────────────────────────── */
.chip {
    font-size: 11.5px;
    font-weight: 500;
    padding: 4px 11px;
    border-radius: 20px;
    border: 1px solid transparent;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
}
.chip.neutral { background: #fff; border-color: var(--line-2); color: var(--ink-2); }
.chip.teal    { background: var(--teal-bg); border-color: var(--teal-line); color: var(--teal); }
.chip.amber   { background: var(--amber-bg); border-color: var(--amber-line); color: var(--amber); }
.chip.red     { background: var(--red-bg); border-color: var(--red-line); color: var(--red); }
.chip.green   { background: var(--green-bg); color: var(--green); }

.pill {
    font-size: 12px;
    padding: 6px 13px;
    border-radius: 20px;
    border: 1px solid var(--line-2);
    color: var(--ink-4);
    background: #fff;
    font-weight: 400;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.pill:hover { color: var(--ink-2); border-color: var(--ink-4); }
.pill.on { background: var(--teal-bg); border-color: var(--teal-line); color: var(--teal); font-weight: 500; }
.pill.on:hover { color: var(--teal); }

/* ── buttons ──────────────────────────────────────────────────────── */
.btn {
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 9px 18px;
    border-radius: var(--r);
    border: 1px solid var(--teal);
    background: var(--teal);
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--teal-dark); border-color: var(--teal-dark); color: #fff; }
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.btn.ghost { background: #fff; color: var(--ink-2); border-color: var(--line-2); }
.btn.ghost:hover { background: var(--panel); color: var(--ink); border-color: var(--ink-4); }
.btn.block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] {
    background: var(--panel);
    color: var(--ink-4);
    border-color: var(--line);
    cursor: not-allowed;
}
.btn[disabled]:hover, .btn[aria-disabled="true"]:hover {
    background: var(--panel);
    color: var(--ink-4);
    border-color: var(--line);
}

/* ── shell footer (auto-save + primary/ghost actions) ─────────────── */
.foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-top: 1px solid var(--line);
    background: var(--panel);
    flex-wrap: wrap;
}
.foot span { font-size: 11.5px; color: var(--ink-4); }

/* ── page-header row inside the shell (dashboard / list pages) ────── */
.page-head {
    padding: 17px 20px 12px;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 14px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--line);
}
.page-head-title { display: flex; flex-direction: column; gap: 2px; }
.page-head h2 {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.015em;
    margin: 0;
}
.page-head p {
    font-size: 12px;
    color: var(--ink-3);
    margin: 0;
}

/* ── monitoring dashboard (step 7) ────────────────────────────────── */
/* Background motif — anchored to the body so the whole shell lifts
   above it. Extremely low-opacity; must not fight the KPI numbers. */
body.has-monitor-bg { position: relative; }
body.has-monitor-bg::before {
    content: "";
    position: fixed;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(15, 118, 110, 0.10) 0%, rgba(15, 118, 110, 0) 45%),
        url("../img/monitor-bg.b7114547c83b.svg") center/cover no-repeat fixed;
    opacity: 1;
    z-index: 0;
    pointer-events: none;
    /* Very slow drift so the surface feels alive without being distracting. */
    animation: bg-drift 40s ease-in-out infinite alternate;
}
@keyframes bg-drift {
    from { transform: scale(1.02) translate(-6px, -4px); }
    to   { transform: scale(1.05) translate( 6px,  4px); }
}
@media (prefers-reduced-motion: reduce) {
    body.has-monitor-bg::before { animation: none; }
}
body.has-monitor-bg .shell { position: relative; z-index: 1; }

/* Motion — respects prefers-reduced-motion. Cards fade+slide in
   with a staggered delay driven by CSS var --i (set inline). */
@keyframes ecrf-appear {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0);    }
}
.kpi-appear, .chart-card, .alert, .leader, .ranking-section {
    animation: ecrf-appear 480ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.kpi-appear { animation-delay: calc(var(--i, 0) * 80ms); }
.chart-card { animation-delay: 240ms; }
.chart-card + .chart-card { animation-delay: 320ms; }
.chart-card-wide { animation-delay: 400ms; }
.ranking-section { animation-delay: 480ms; }
@media (prefers-reduced-motion: reduce) {
    .kpi-appear, .chart-card, .alert, .leader, .ranking-section {
        animation: none;
    }
}

/* Live-refresh dot in the footer — pulses to signal auto-refresh. */
.live-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    background: #10B981;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.65);
    animation: live-pulse 1.8s ease-out infinite;
    flex-shrink: 0;
}
@keyframes live-pulse {
    0%   { box-shadow: 0 0 0 0    rgba(16, 185, 129, 0.55); }
    70%  { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);    }
    100% { box-shadow: 0 0 0 0    rgba(16, 185, 129, 0);    }
}
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

/* Chart card lift on hover — small tactile feedback. */
.chart-card {
    transition: transform 220ms ease, box-shadow 220ms ease;
}
.chart-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    padding: 20px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}
/* On the monitoring page, let the SVG bleed through around the
   cards instead of being hidden by opaque section backgrounds. */
body.has-monitor-bg .kpi-row,
body.has-monitor-bg .charts-row,
body.has-monitor-bg .ranking-section,
body.has-monitor-bg .alerts-row,
body.has-monitor-bg .leaders-row {
    background: transparent;
    border-bottom-color: rgba(226, 232, 240, 0.5);
}
body.has-monitor-bg .kpi,
body.has-monitor-bg .chart-card,
body.has-monitor-bg .leader,
body.has-monitor-bg .table-wrap {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
body.has-monitor-bg .alert-danger { background: rgba(254, 226, 226, 0.85); }
body.has-monitor-bg .alert-warn   { background: rgba(254, 243, 199, 0.85); }
.kpi {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px 16px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    display: grid;
    grid-template-columns: 1fr 68px;
    gap: 10px;
    align-items: center;
    min-height: 96px;
}
.kpi-copy { min-width: 0; }
.kpi-chart {
    height: 62px;
    display: grid;
    place-items: center;
}
.kpi-chart canvas.mini-chart {
    width: 68px;
    height: 62px;
}
.kpi-chart-dot { justify-self: center; }
.query-dot {
    display: block;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: #E2E8F0;
    box-shadow: 0 0 0 6px rgba(226, 232, 240, 0.4);
}
.query-dot.on {
    background: #F59E0B;
    box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.25);
    animation: query-pulse 2s ease-in-out infinite;
}
@keyframes query-pulse {
    0%, 100% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.25); }
    50%      { box-shadow: 0 0 0 10px rgba(245, 158, 11, 0.10); }
}
@media (prefers-reduced-motion: reduce) { .query-dot.on { animation: none; } }

/* Workflow-status chips (dashboard row + subject band) */
.wf-chip {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1.55;
    border: 1px solid transparent;
    white-space: nowrap;
}
.wf-neutral { background: #F1F5F9; color: #475569; border-color: #E2E8F0; }
.wf-amber   { background: rgba(245, 158, 11, 0.14); color: #B45309; border-color: rgba(245, 158, 11, 0.30); }
.wf-teal    { background: rgba(20, 184, 166, 0.16); color: #0F766E; border-color: rgba(20, 184, 166, 0.30); }
.wf-green   { background: rgba(16, 185, 129, 0.14); color: #047857; border-color: rgba(16, 185, 129, 0.28); }
.wf-red     { background: rgba(239, 68, 68, 0.14);  color: #B91C1C; border-color: rgba(239, 68, 68, 0.28); font-weight: 600; }

/* Danger-styled filter pill (used for "بازآزمایی لازم") */
.filter-pill.filter-pill-danger {
    color: #B91C1C;
    border-color: rgba(239, 68, 68, 0.32);
}
.filter-pill.filter-pill-danger:hover {
    background: rgba(239, 68, 68, 0.08);
}
.filter-pill.filter-pill-danger.on {
    background: #EF4444;
    color: #fff;
    border-color: #EF4444;
}

/* Trend chips inside the ranking table */
.trend {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 11.5px; font-weight: 600;
    padding: 2px 8px; border-radius: 999px;
    border: 1px solid transparent;
}
.trend-up   { color: #047857; background: rgba(16, 185, 129, 0.12); border-color: rgba(16, 185, 129, 0.28); }
.trend-flat { color: #475569; background: #F1F5F9;                border-color: #E2E8F0; }
.trend-warn { color: #B45309; background: rgba(245, 158, 11, 0.14); border-color: rgba(245, 158, 11, 0.30); }
.trend-down { color: #B91C1C; background: rgba(239, 68, 68, 0.12);  border-color: rgba(239, 68, 68, 0.28); }
canvas.site-sparkline { display: block; }
.kpi-label {
    font-size: 12px;
    color: var(--ink-3);
    margin-bottom: 6px;
    letter-spacing: 0.3px;
}
.kpi-value {
    font-size: 26px;
    color: var(--ink-1);
    font-weight: 700;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.kpi-sub {
    font-size: 11.5px;
    color: var(--ink-3);
    margin-top: 6px;
}
.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    padding: 20px;
    background: var(--panel);
}
.chart-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px 16px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    margin: 0;
    height: 320px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.chart-card figcaption {
    font-size: 13px;
    color: var(--ink-2);
    font-weight: 600;
}
.chart-card canvas {
    flex: 1;
    min-height: 0;
}
.chart-card-wide {
    grid-column: 1 / -1;
    height: 260px;
}

/* Alerts row */
.alerts-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 20px 0;
    background: var(--panel);
}
.alert {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--line);
    font-size: 13px;
    line-height: 1.55;
}
.alert-body { display: flex; flex-direction: column; }
.alert-body b { color: var(--ink-1); }
.alert-body span { color: var(--ink-2); }
.alert-icon {
    width: 24px; height: 24px;
    display: grid; place-items: center;
    border-radius: 50%;
    font-weight: 700;
}
.alert-danger { background: var(--red-bg); border-color: var(--red-line); }
.alert-danger .alert-icon { background: var(--red); color: #fff; }
.alert-warn   { background: var(--amber-bg); border-color: var(--amber-line); }
.alert-warn   .alert-icon { background: var(--amber); color: #fff; }

/* Leader chips */
.leaders-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
    padding: 16px 20px 0;
    background: var(--panel);
}
.leader {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "label value" "site site";
    row-gap: 4px;
    column-gap: 12px;
    align-items: baseline;
}
.leader-label { grid-area: label; font-size: 12px; color: var(--ink-3); letter-spacing: 0.3px; }
.leader-value { grid-area: value; font-size: 22px; font-weight: 700; color: var(--teal); font-variant-numeric: tabular-nums; }
.leader-site  { grid-area: site;  font-size: 13px; color: var(--ink-1); font-weight: 600; }

/* Ranking table */
.ranking-section {
    padding: 20px;
    background: var(--panel);
}
.ranking-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 12px;
}
.ranking-head h3 {
    margin: 0;
    font-size: 14px;
    color: var(--ink-1);
    font-weight: 600;
}
.ranking-head span {
    font-size: 12px;
    color: var(--ink-3);
}
.ranking-table .col-num {
    text-align: end;
    font-variant-numeric: tabular-nums;
}
.rank-chip {
    display: inline-grid;
    place-items: center;
    width: 28px; height: 28px;
    border-radius: 999px;
    background: #E2E8F0;
    color: var(--ink-2);
    font-weight: 700;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}
.rank-chip.rank-1 { background: var(--teal); color: #fff; }
.rank-chip.rank-2 { background: #94D5CE; color: #04443F; }
.rank-chip.rank-3 { background: #C7EAE6; color: #04443F; }
.rank-badge {
    color: var(--teal);
    font-weight: 800;
    margin-inline-start: 4px;
    font-size: 12px;
}
.row-muted td { opacity: 0.55; }

/* ── schedule + sampling widget ───────────────────────────────────── */
.schedule-card {
    display: grid;
    grid-template-columns: minmax(180px, auto) 1fr minmax(180px, auto);
    gap: 24px;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
}
.schedule-eyebrow {
    font-size: 11px;
    color: var(--ink-3);
    letter-spacing: 0.4px;
    margin-bottom: 4px;
}
.schedule-date {
    font-size: 14px;
    color: var(--ink-1);
    font-weight: 600;
    margin-bottom: 6px;
}
.schedule-week {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    min-width: 0;
}
.schedule-day {
    text-align: center;
    padding: 8px 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink-3);
    font-size: 11px;
    line-height: 1.35;
}
.schedule-day-name { font-weight: 500; }
.schedule-day-num  { font-size: 15px; color: var(--ink-1); font-weight: 700; margin-top: 2px; }
.schedule-day.on {
    background: var(--teal-bg);
    border-color: var(--teal-line);
    color: var(--teal);
}
.schedule-day.today {
    outline: 2px solid var(--teal);
    outline-offset: -1px;
}
.schedule-quota {
    text-align: end;
}
.schedule-quota-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 12.5px;
    color: var(--ink-2);
    padding: 2px 0;
}
.schedule-quota-row b { color: var(--ink-1); font-variant-numeric: tabular-nums; }

/* ── toolbar (search + filter + clear) ────────────────────────────── */
.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 20px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
    flex-wrap: wrap;
}
.toolbar.toolbar-wide { row-gap: 14px; align-items: flex-end; }
.toolbar-fieldset { display: flex; flex-direction: column; gap: 4px; }
.toolbar-label { font-size: 11px; color: var(--ink-3); letter-spacing: 0.2px; }
.toolbar-break { flex-basis: 100%; height: 0; }
.search { position: relative; flex: 1 1 240px; min-width: 200px; }
.search .input { padding-inline-start: 32px; }
.search-icon {
    position: absolute;
    inset-inline-start: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ink-4);
    pointer-events: none;
    font-size: 14px;
}
.filter {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 3px;
    padding: 3px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 22px;
}
.filter-pill {
    padding: 5px 12px;
    border-radius: 18px;
    font-size: 12px;
    color: var(--ink-3);
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    transition: background 0.12s, color 0.12s;
}
.filter-pill:hover { color: var(--ink); background: var(--panel); }
.filter-pill.on { background: var(--teal); color: #fff; }
.filter-pill.on:hover { background: var(--teal-dark); color: #fff; }
.toolbar-clear {
    font-size: 12px;
    color: var(--ink-4);
    text-decoration: none;
    border-bottom: 1px dashed var(--line-2);
    padding-bottom: 1px;
}
.toolbar-clear:hover { color: var(--red); border-bottom-color: var(--red-line); }

/* ── table ────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}
.table thead th {
    text-align: start;
    font-weight: 600;
    font-size: 10.5px;
    letter-spacing: 0.06em;
    color: var(--ink-4);
    text-transform: uppercase;
    padding: 10px 16px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
    background: var(--card);
}
.table tbody tr:hover td { background: var(--panel); }
.table tbody tr:last-child td { border-bottom: none; }
.col-badge { width: 1%; text-align: center; white-space: nowrap; }
.subj-code {
    font-family: "SF Mono", "Menlo", "Consolas", monospace;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: 0.02em;
}
a.subj-link {
    text-decoration: none;
    border-bottom: 1px dashed transparent;
    transition: color 0.12s, border-color 0.12s;
}
a.subj-link:hover {
    color: var(--teal);
    border-bottom-color: var(--teal-line);
}

/* ── subject-status chip (SubjectStatus keys) ─────────────────────── */
.st {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    border: 1px solid transparent;
    white-space: nowrap;
}
.st-screened      { background: var(--teal-bg); color: var(--teal); border-color: var(--teal-line); }
.st-enrolled      { background: var(--green-bg); color: var(--green); }
.st-screen_failed { background: var(--red-bg); color: var(--red); border-color: var(--red-line); }
.st-withdrawn     { background: var(--amber-bg); color: var(--amber); border-color: var(--amber-line); }
.st-completed     { background: #E7EDEE; color: var(--ink-2); border-color: var(--line-2); }

/* ── completion / query badges ────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 22px;
    padding: 0 7px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid transparent;
}
.badge-ok    { background: var(--green-bg); color: var(--green); }
.badge-muted { background: var(--panel); color: var(--ink-4); border-color: var(--line); }
.badge-warn  { background: var(--amber-bg); color: var(--amber); border-color: var(--amber-line); }

/* ── empty state ──────────────────────────────────────────────────── */
.empty { text-align: center; padding: 48px 16px; color: var(--ink-4); }
.empty-mark {
    font-size: 40px;
    color: var(--teal-line);
    margin-bottom: 8px;
    line-height: 1;
}
.empty-title { font-weight: 600; color: var(--ink-2); margin: 0 0 4px; font-size: 14px; }
.empty-lede  { font-size: 12px; margin: 0; }

/* ── flash messages (django.contrib.messages) ─────────────────────── */
.flash-wrap {
    padding: 12px 20px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.flash {
    padding: 10px 14px;
    border-radius: var(--r);
    font-size: 13px;
    border: 1px solid transparent;
    line-height: 1.5;
}
.flash-success { background: var(--green-bg); color: var(--green); border-color: rgba(42, 110, 81, 0.25); }
.flash-info    { background: var(--teal-bg); color: var(--teal); border-color: var(--teal-line); }
.flash-warning { background: var(--amber-bg); color: var(--amber); border-color: var(--amber-line); }
.flash-error   { background: var(--red-bg); color: var(--red); border-color: var(--red-line); }

/* ── auth pages (login) ───────────────────────────────────────────── */
body.auth-body {
    padding: 0;
    background:
        radial-gradient(1200px 700px at 15% 20%, rgba(15, 118, 110, 0.16), transparent 60%),
        radial-gradient(1000px 600px at 90% 80%, rgba(56, 189, 248, 0.14), transparent 55%),
        linear-gradient(135deg, #E8F3F3 0%, #DDEAEB 100%);
    min-height: 100vh;
    overflow: hidden;
    position: relative;
}
/* Fixed capsid/molecular motif behind everything; slow drift so
   the surface feels alive but doesn't distract. */
body.auth-body::before {
    content: "";
    position: fixed;
    inset: 0;
    background: url("../img/login-bg.6dc134301518.svg") center/cover no-repeat;
    opacity: 0.9;
    z-index: 0;
    pointer-events: none;
    animation: auth-drift 30s ease-in-out infinite alternate;
}
@keyframes auth-drift {
    from { transform: scale(1.03) translate(-10px, -6px); }
    to   { transform: scale(1.06) translate( 10px,  6px); }
}
/* Two large soft "orbs" counter-drifting for depth. */
.auth-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(50px);
    pointer-events: none;
    z-index: 0;
    will-change: transform;
}
.auth-orb-a {
    width: 420px; height: 420px;
    top: -120px; left: -80px;
    background: rgba(15, 118, 110, 0.28);
    animation: orb-a 18s ease-in-out infinite alternate;
}
.auth-orb-b {
    width: 500px; height: 500px;
    bottom: -160px; right: -140px;
    background: rgba(56, 189, 248, 0.22);
    animation: orb-b 22s ease-in-out infinite alternate;
}
@keyframes orb-a {
    from { transform: translate(0, 0)      scale(1);    }
    to   { transform: translate(60px, 40px) scale(1.08); }
}
@keyframes orb-b {
    from { transform: translate(0, 0)        scale(1);    }
    to   { transform: translate(-70px, -50px) scale(1.10); }
}
@media (prefers-reduced-motion: reduce) {
    body.auth-body::before,
    .auth-orb-a, .auth-orb-b { animation: none; }
}
.auth {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    position: relative;
    z-index: 1;
}
.auth-card {
    width: 100%;
    max-width: 380px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: var(--r-lg);
    box-shadow:
        0 30px 60px -20px rgba(15, 32, 39, 0.30),
        0 0 0 1px rgba(15, 118, 110, 0.06);
    padding: 32px 28px 24px;
    animation: auth-card-in 620ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes auth-card-in {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0)    scale(1);    }
}
@media (prefers-reduced-motion: reduce) {
    .auth-card { animation: none; }
}
.auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
}
.auth-mark {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    background: var(--teal);
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.02em;
}
.auth-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
    margin: 0;
    text-align: center;
    letter-spacing: -0.01em;
    line-height: 1.4;
}
.auth-subtitle {
    font-size: 12px;
    color: var(--ink-3);
    margin: 0;
    text-align: center;
}
.auth-field { margin-bottom: 14px; }
.auth-field .label {
    display: block;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--ink-2);
    margin-bottom: 5px;
}
.auth-field .input { height: 40px; }
.auth-error {
    background: var(--red-bg);
    border: 1px solid var(--red-line);
    color: var(--red);
    padding: 10px 12px;
    border-radius: var(--r);
    font-size: 12px;
    margin-bottom: 14px;
}
.auth-inline-error {
    color: var(--red);
    font-size: 11.5px;
    margin-top: 4px;
}
.auth-submit { width: 100%; margin-top: 6px; }
.auth-footer {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    text-align: center;
    font-size: 11.5px;
    color: var(--ink-4);
}

/* ── responsive ───────────────────────────────────────────────────── */
@media (max-width: 720px) {
    body { padding: 14px 10px; }
    .body { grid-template-columns: 1fr; }
    .nav-side {
        border-left: none;
        border-bottom: 1px solid var(--line);
    }
}
