/* Uni-Real Dashboard — soft "clay" SaaS look: white cards, pastel blue, soft shadows. */

:root {
    --bg-top: #E6EEFA;
    --bg-bottom: #F6F8FC;
    --card: #FFFFFF;
    --card-border: rgba(30, 50, 90, 0.07);
    --text: #1C2434;
    --muted: #6A7488;
    --faint: #98A1B3;
    --line: #E8ECF3;
    --hover: #F3F6FB;
    --accent: #2F5BEA;
    --accent-soft: #E9EEFD;
    --good: #1F9D63;
    --good-soft: #E3F5EC;
    --warn: #C98304;
    --warn-soft: #FDF1DC;
    --bad: #D83A3F;
    --bad-soft: #FCE6E7;
    --neutral-soft: #EEF1F6;
    --skeleton: #EDF0F5;
    --skeleton-shine: #F7F9FC;
    --shadow: 0 10px 30px rgba(30, 50, 90, 0.10), 0 2px 6px rgba(30, 50, 90, 0.05);
    --radius: 14px;
    --radius-sm: 10px;
    --gap: 12px;
    --edge: 16px;
    --rail-width: 296px;
    --panel-width: 360px;
    --topbar-height: 52px;
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg-top: #151B28;
    --bg-bottom: #0D111A;
    --card: #1A2131;
    --card-border: rgba(255, 255, 255, 0.07);
    --text: #E6EBF5;
    --muted: #96A1B8;
    --faint: #6B768D;
    --line: #2A3347;
    --hover: #222B3E;
    --accent: #7092FF;
    --accent-soft: rgba(112, 146, 255, 0.16);
    --good: #4CC38A;
    --good-soft: rgba(76, 195, 138, 0.15);
    --warn: #F0B44C;
    --warn-soft: rgba(240, 180, 76, 0.15);
    --bad: #F2777B;
    --bad-soft: rgba(242, 119, 123, 0.15);
    --neutral-soft: rgba(255, 255, 255, 0.06);
    --skeleton: #222A3B;
    --skeleton-shine: #2A3346;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
}

/* No saved choice and no JS: follow the OS. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) {
        --bg-top: #151B28; --bg-bottom: #0D111A; --card: #1A2131; --card-border: rgba(255, 255, 255, 0.07);
        --text: #E6EBF5; --muted: #96A1B8; --line: #2A3347; --accent: #7092FF; --accent-soft: rgba(112, 146, 255, 0.16);
        color-scheme: dark;
    }
}

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

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg-bottom);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.tabular { font-variant-numeric: tabular-nums; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- layout */

.app {
    position: fixed;
    inset: 0;
    overflow: hidden;
    background: radial-gradient(120% 90% at 50% 10%, var(--bg-top) 0%, var(--bg-bottom) 70%);
}

/* z-index makes the scene its own stacking context, so the label renderer's per-label z-indexes
   can never lift 3D labels above the cards. */
.scene { position: absolute; inset: 0; z-index: 0; }
.scene canvas { display: block; outline: none; touch-action: none; }
.scene.is-hovering canvas { cursor: pointer; }
.scene-labels { position: absolute; inset: 0; pointer-events: none; }

.card {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card__title {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.01em;
}

/* ---------------------------------------------------------------- top bar */

.topbar {
    position: absolute;
    top: var(--edge);
    left: var(--edge);
    right: var(--edge);
    min-height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 5px 8px;
    z-index: 5;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 0 1 auto; }
.brand__logo {
    display: grid; place-items: center; flex: none;
    width: 30px; height: 30px; border-radius: 9px;
    background: var(--accent); color: #fff;
}
.brand__text { min-width: 0; }
.brand__name { margin: 0; font-weight: 700; font-size: 14px; letter-spacing: -0.01em; white-space: nowrap; }
.brand__sub { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }

/* "Select Campus" / "Select Term" captions in front of the pickers. */
.picker { display: flex; align-items: center; gap: 8px; min-width: 0; }
.picker--campus { margin: 0 auto; }
.picker__label { font-size: 11.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }

.campus-switch {
    display: flex;
    gap: 2px;
    padding: 3px;
    margin: 0;
    border-radius: 12px;
    background: var(--neutral-soft);
    overflow-x: auto;
    scrollbar-width: none;
}
.campus-switch::-webkit-scrollbar { display: none; }
.campus-switch button {
    flex: none;
    border: 0;
    background: transparent;
    padding: 4px 9px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background-color .15s, color .15s;
}
.campus-switch button:hover { color: var(--text); }
.campus-switch button[aria-pressed="true"] { background: var(--card); color: var(--accent); box-shadow: 0 1px 4px rgba(30, 50, 90, .12); }
.campus-switch .dot { width: 7px; height: 7px; }

.topbar__tools { display: flex; align-items: center; gap: 6px; flex: none; }
.topbar__sep { width: 1px; height: 24px; background: var(--line); margin: 0 2px; }
.toolbar { display: flex; align-items: center; gap: 0; }

.term-select {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.term-select__icon {
    position: absolute; left: 10px; width: 16px; height: 16px;
    fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; pointer-events: none;
}
.term-select select {
    appearance: none;
    -webkit-appearance: none;
    height: 32px;
    padding: 0 28px 0 32px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2398A1B3' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.icon-btn {
    display: grid; place-items: center; flex: none;
    width: 32px; height: 32px;
    border: 0; border-radius: var(--radius-sm);
    background: transparent; color: var(--text); cursor: pointer;
    text-decoration: none;
    transition: background-color .15s, color .15s;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .icon-sun { display: none; }
:root[data-theme="dark"] .icon-btn .icon-sun { display: block; }
:root[data-theme="dark"] .icon-btn .icon-moon { display: none; }
.icon-btn--sm { width: 30px; height: 30px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: 0; border-radius: var(--radius-sm);
    padding: 9px 16px; background: var(--accent); color: #fff;
    font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn--ghost { background: var(--neutral-soft); color: var(--text); }
.btn--small { padding: 6px 12px; font-size: 12.5px; }

/* ---------------------------------------------------------------- left rail: KPI cards, timeline, credits */

.rail {
    position: absolute;
    top: calc(var(--edge) + var(--topbar-height) + var(--gap));
    left: var(--edge);
    bottom: var(--edge);
    width: var(--rail-width);
    display: flex;
    flex-direction: column;
    gap: var(--gap);
    overflow-y: auto;
    scrollbar-width: thin;
    padding: 2px 2px 2px 0;
    z-index: 3;
    pointer-events: none; /* only its cards are interactive, so the map stays draggable in gaps */
}
.rail > * { pointer-events: auto; flex: none; }

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

.kpi-card {
    position: relative;
    text-align: left;
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: var(--shadow);
    padding: 8px 10px 8px;
    cursor: pointer;
    min-height: 84px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
    transition: transform .15s ease, box-shadow .15s ease;
}
.kpi-card:hover { transform: translateY(-1px); box-shadow: 0 0 0 1px var(--accent-soft), var(--shadow); }
.kpi-card__label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 12px; font-weight: 600; }
.kpi-card__value { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.kpi-card__value small { font-size: 11.5px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.kpi-card__sub { color: var(--muted); font-size: 10.5px; margin-top: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-card__status { position: absolute; top: 10px; right: 9px; }

.change {
    display: inline-flex; align-items: center; gap: 3px;
    font-size: 10.5px; font-weight: 600; white-space: nowrap;
    color: var(--muted);
    min-width: 0; overflow: hidden; text-overflow: ellipsis;
}
.change--up { color: var(--good); }
.change--down { color: var(--bad); }
.change svg { width: 10px; height: 10px; fill: currentColor; }

/* Timeline */
.timeline { padding: 9px 10px 8px; }
.timeline__head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; gap: 8px; }
.timeline__term { font-size: 11px; color: var(--muted); }
/* Labels alternate below / above the line (even / odd steps) so each one has two columns of room. */
.timeline__track { position: relative; display: grid; grid-template-columns: repeat(6, 1fr); padding: 25px 0 0; }
.timeline__bar { position: absolute; top: 31px; left: 8.33%; right: 8.33%; height: 3px; border-radius: 3px; background: var(--line); }
.timeline__fill { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: var(--accent); transition: width .5s ease; }
.timeline__step { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; min-height: 46px; }
.timeline__label { display: flex; flex-direction: column; align-items: center; white-space: nowrap; margin-top: 2px; line-height: 1.15; }
/* The track's first child is the bar, so steps 2, 4, 6 are nth-child(odd): their labels go above. */
.timeline__step:nth-child(odd) .timeline__label { position: absolute; bottom: calc(100% + 3px); margin: 0; }
.timeline__step:nth-child(odd) { min-height: 20px; }
.timeline__dot {
    width: 17px; height: 17px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--card); border: 2px solid var(--line); color: transparent; font-size: 10px; font-weight: 700;
}
.timeline__step--done .timeline__dot { background: var(--accent); border-color: var(--accent); color: #fff; }
.timeline__step--current .timeline__dot { border-color: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); background: var(--card); }
.timeline__step--current .timeline__dot::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.timeline__name { font-size: 10px; font-weight: 600; line-height: 1.2; }
.timeline__step--current .timeline__name { color: var(--accent); }
.timeline__date { font-size: 9.5px; color: var(--faint); }
.timeline__note { margin: 6px 0 0; font-size: 11px; color: var(--muted); }

/* Credits */
.credits {
    display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px;
    padding: 6px 11px;
    text-decoration: none; color: var(--text);
    font-size: 11.5px;
    transition: box-shadow .15s;
}
.credits:hover { box-shadow: 0 0 0 1px var(--accent-soft), var(--shadow); }
.credits__label { color: var(--muted); }
.credits__name { font-weight: 700; }
.credits__link { margin-left: auto; color: var(--accent); font-weight: 600; }

/* ---------------------------------------------------------------- tables card (left rail, under the credits) */

/* Fills the rest of the rail; columns are fixed so it never scrolls sideways (only down). */
.rail > .tables {
    flex: 1 1 auto;
    min-height: 210px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.rail > .tables.is-collapsed { flex: none; min-height: 0; height: 40px; }

.tabs { display: flex; align-items: center; gap: 0; padding: 5px 6px 0; border-bottom: 1px solid var(--line); flex: none; }
.tab {
    border: 0; background: transparent; cursor: pointer;
    padding: 6px 7px 7px; font-size: 12px; font-weight: 600; color: var(--muted);
    border-bottom: 2px solid transparent; margin-bottom: -1px;
    display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab__count { font-size: 11px; padding: 1px 6px; border-radius: 99px; background: var(--neutral-soft); color: var(--muted); }
.tab--overview { display: none; }
.tabs__spacer { flex: 1; }
.tables__body { flex: 1; overflow-x: hidden; overflow-y: auto; scrollbar-width: thin; }
.rail .tables .tab__count { display: none; } /* counts are in the column headers there */

.table { width: 100%; border-collapse: collapse; font-size: 11.5px; table-layout: fixed; }
.table th {
    position: sticky; top: 0; z-index: 1;
    background: var(--card);
    text-align: left; font-weight: 600; color: var(--muted); font-size: 10.5px;
    padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 5px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table th:first-child, .table td:first-child { padding-left: 10px; }
.table th:last-child, .table td:last-child { padding-right: 10px; padding-left: 4px; text-align: right; text-overflow: clip; }
.table th.num, .table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover td { background: var(--hover); }
.table tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.table .name { display: flex; align-items: center; gap: 7px; font-weight: 600; min-width: 0; }
.table .name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table .name small { color: var(--muted); font-weight: 500; flex: none; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.muted { color: var(--muted); }

.chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 1px 7px; border-radius: 999px;
    font-size: 10.5px; font-weight: 600; white-space: nowrap;
    background: var(--neutral-soft); color: var(--muted);
}
.chip--good { background: var(--good-soft); color: var(--good); }
.chip--warn { background: var(--warn-soft); color: var(--warn); }
.chip--bad { background: var(--bad-soft); color: var(--bad); }
.chip--accent { background: var(--accent-soft); color: var(--accent); }

.empty-state, .error-state { padding: 26px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.error-state p { margin: 0 0 10px; color: var(--text); }

.overview-body { padding: 12px; display: flex; flex-direction: column; gap: var(--gap); }
.overview-body .timeline, .overview-body .credits { box-shadow: none; }

/* ---------------------------------------------------------------- detail panel (right) */

.panel {
    position: absolute;
    top: calc(var(--edge) + var(--topbar-height) + var(--gap));
    right: var(--edge);
    bottom: var(--edge);
    width: var(--panel-width);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 4;
    animation: panel-in .25s ease;
}
@keyframes panel-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

.panel__head { padding: 12px 14px 10px; border-bottom: 1px solid var(--line); flex: none; }
.panel__top { display: flex; align-items: flex-start; gap: 10px; }
.panel__titles { flex: 1; min-width: 0; }
.panel__eyebrow { font-size: 11.5px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: 0.05em; }
.panel__title { margin: 2px 0 2px; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; }
.panel__sub { margin: 0; color: var(--muted); font-size: 12.5px; }
.panel__stats { display: flex; gap: 6px; margin-top: 8px; }
.stat { flex: 1; padding: 5px 9px; border-radius: var(--radius-sm); background: var(--neutral-soft); }
.stat b { display: block; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; color: var(--muted); }
.panel .tabs { padding: 4px 10px 0; }
.panel__body { flex: 1; overflow-y: auto; padding: 4px 14px 14px; }
.panel__foot { padding: 10px 16px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--muted); flex: none; }

.status-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: 999px;
    font-size: 11.5px; font-weight: 600; white-space: nowrap;
    background: var(--neutral-soft); color: var(--muted);
}
.status-badge--good { background: var(--good-soft); color: var(--good); }
.status-badge--warn { background: var(--warn-soft); color: var(--warn); }
.status-badge--bad { background: var(--bad-soft); color: var(--bad); }

.kpi-list { list-style: none; margin: 0; padding: 0; }
.kpi-row {
    display: grid;
    grid-template-columns: 10px 1fr auto;
    grid-template-areas: "dot name value" ". bar bar" ". meta meta";
    column-gap: 9px; row-gap: 4px;
    align-items: center;
    padding: 6px 8px;
    margin: 0 -8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 0; background: transparent; width: calc(100% + 16px); text-align: left;
}
.kpi-row:hover { background: var(--hover); }
.kpi-row.is-active { background: var(--accent-soft); }
.kpi-row .dot { grid-area: dot; }
.kpi-row__name { grid-area: name; font-size: 12px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-row__value { grid-area: value; font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-row__bar { grid-area: bar; height: 5px; border-radius: 5px; background: var(--line); overflow: hidden; }
.kpi-row__bar span { display: block; height: 100%; border-radius: 5px; background: var(--muted); }
.kpi-row__bar--good span { background: var(--good); }
.kpi-row__bar--warn span { background: var(--warn); }
.kpi-row__bar--bad span { background: var(--bad); }
.kpi-row__meta { grid-area: meta; display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--muted); }

.chart-card { margin: 14px 0 6px; padding: 12px 12px 6px; border: 1px solid var(--line); border-radius: var(--radius); }
.chart-card__head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.chart-card__title { margin: 0; font-size: 13px; font-weight: 600; }
.chart { height: 160px; }

.mix { margin-top: 14px; }
.mix__title { font-size: 12px; font-weight: 600; color: var(--muted); margin: 0 0 8px; }
.stack { display: flex; height: 10px; border-radius: 10px; overflow: hidden; background: var(--line); }
.stack span { height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 7px; font-size: 11.5px; color: var(--muted); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }
.section-gap { height: 12px; }

/* ---------------------------------------------------------------- 3D labels */

.scene-label {
    display: flex; align-items: center; gap: 7px;
    margin-bottom: 8px;
    padding: 5px 9px;
    border-radius: 11px;
    background: var(--card);
    color: var(--text);
    box-shadow: var(--shadow);
    white-space: nowrap;
    font-size: 12px;
    pointer-events: none;
}
.scene-label--selected { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.scene-label strong { display: block; font-size: 12px; font-weight: 600; }
.scene-label small { display: block; color: var(--muted); font-size: 10.5px; }

.campus-label {
    pointer-events: auto;
    display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
    padding: 5px 9px;
    border: 0; border-radius: 10px;
    background: var(--card); color: var(--text);
    box-shadow: var(--shadow);
    cursor: pointer;
    white-space: nowrap;
    transition: transform .15s ease, box-shadow .15s ease;
}
.campus-label:hover { transform: translateY(-2px); box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.campus-label__head { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.campus-label__head b { color: var(--accent); }
.campus-label small { color: var(--muted); font-size: 10.5px; }

.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--faint); display: inline-block; }
.dot--good { background: var(--good); }
.dot--warn { background: var(--warn); }
.dot--bad { background: var(--bad); }

/* ---------------------------------------------------------------- skeletons */

.skeleton {
    border-radius: 8px;
    background: linear-gradient(90deg, var(--skeleton) 25%, var(--skeleton-shine) 50%, var(--skeleton) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.2s infinite linear;
}
.skeleton--text { height: 12px; margin: 6px 0; }
.skeleton--value { height: 26px; width: 60%; margin: 6px 0; }
.skeleton--row { height: 34px; margin: 6px 12px; }
.skeleton--chart { height: 170px; margin-top: 12px; }
.kpi-card.is-loading { cursor: default; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------------------------------------------------------------- loading / error overlay */

.loading {
    position: absolute; inset: 0;
    display: grid; place-items: center;
    background: radial-gradient(120% 90% at 50% 10%, var(--bg-top) 0%, var(--bg-bottom) 70%);
    transition: opacity .4s ease;
    z-index: 20;
}
.loading.is-done { opacity: 0; pointer-events: none; }
.loading__box { text-align: center; max-width: 360px; padding: 0 16px; }
.loading__text { color: var(--muted); margin: 14px 0; }
.loading.is-error .spinner { display: none; }
.loading.is-error .loading__text { color: var(--text); }

.spinner {
    width: 34px; height: 34px; margin: 0 auto;
    border-radius: 50%;
    border: 3px solid var(--accent-soft);
    border-top-color: var(--accent);
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    .spinner { animation-duration: 2s; }
    .skeleton { animation: none; }
    .panel { animation: none; }
}

/* ---------------------------------------------------------------- settings page */

.page { min-height: 100%; background: radial-gradient(120% 90% at 50% 10%, var(--bg-top) 0%, var(--bg-bottom) 70%); }
.page__main { max-width: 560px; margin: 0 auto; padding: 32px 16px; }
.back-link { display: inline-block; margin-bottom: 14px; color: var(--accent); text-decoration: none; font-weight: 600; }
.form-card { padding: 24px; }
.form-card__title { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.form-card__sub { margin: 4px 0 18px; color: var(--muted); }
.form { display: flex; flex-direction: column; gap: 16px; }
.form--signout { margin-top: 16px; align-items: flex-start; }
.form__actions { display: flex; justify-content: flex-end; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field--inline { flex-direction: row; align-items: center; gap: 10px; }
.field__label { font-size: 13px; font-weight: 600; }
.field__hint { font-size: 12px; color: var(--muted); }
.fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.fieldset legend { margin-bottom: 10px; }
.input {
    width: 100%; height: 40px; padding: 0 12px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--card); color: var(--text);
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.code-chip {
    flex: none; width: 52px; text-align: center;
    padding: 9px 0; border-radius: var(--radius-sm);
    background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 12.5px;
}
.alert { margin: 0 0 14px; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; }
.alert--good { background: var(--good-soft); color: var(--good); }
.alert--warn { background: var(--warn-soft); color: var(--warn); }
.alert--bad { background: var(--bad-soft); color: var(--bad); }
code { font-family: ui-monospace, Consolas, monospace; font-size: 0.92em; }

/* ---------------------------------------------------------------- medium widths */

@media (max-width: 1360px) {
    .brand__sub { max-width: 170px; }
    .campus-switch button { padding: 6px 8px; }
}

/* ---------------------------------------------------------------- compact layout (tablets, phones) */

@media (max-width: 1099px) {
    :root { --edge: 8px; --gap: 8px; }

    .topbar {
        flex-wrap: wrap;
        row-gap: 8px;
        padding: 8px;
    }
    .brand { flex: 1 1 auto; }
    .brand__sub { max-width: 46vw; }
    .campus-switch button { flex: 1 0 auto; justify-content: center; }
    .toolbar {
        position: fixed;
        right: var(--edge);
        top: var(--compact-controls-top, 200px);
        flex-direction: column;
        padding: 4px;
        background: var(--card);
        border: 1px solid var(--card-border);
        border-radius: var(--radius);
        box-shadow: var(--shadow);
        z-index: 4;
    }
    .topbar__sep { display: none; }

    .rail {
        top: var(--compact-rail-top, 130px);
        left: 0;
        right: 0;
        bottom: auto;
        width: auto;
        overflow: visible;
        padding: 0;
    }
    .kpi-grid {
        display: flex;
        gap: var(--gap);
        overflow-x: auto;
        padding: 2px var(--edge) 10px;
        scroll-snap-type: x mandatory;
        scrollbar-width: none;
    }
    .kpi-grid::-webkit-scrollbar { display: none; }
    .kpi-card { flex: 0 0 150px; min-height: 80px; scroll-snap-align: start; }
    .rail > .timeline, .rail > .credits { display: none; }

    /* The tables become a bottom sheet. */
    .rail > .tables {
        position: fixed;
        left: var(--edge);
        right: var(--edge);
        bottom: var(--edge);
        flex: none;
        min-height: 0;
        height: min(48vh, 420px);
        transition: height .25s ease;
    }
    .rail > .tables.is-collapsed { height: 44px; }
    .rail .tables .tab__count { display: inline; }
    .picker--campus { order: 3; flex: 1 1 100%; margin: 0; }
    .picker--campus .campus-switch { flex: 1; }
    .tab--overview { display: inline-flex; }

    .panel {
        top: auto;
        left: var(--edge);
        right: var(--edge);
        bottom: var(--edge);
        width: auto;
        height: min(78vh, 680px);
        animation-name: sheet-in;
    }
    .app.panel-open .toolbar { display: none; }
    @keyframes sheet-in { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
}

@media (max-width: 640px) {
    .rail .tables .tab__count { display: none; } /* counts are in the column headers */
    .campus-label { padding: 5px 9px; }
    .campus-label small { display: none; }
}

@media (max-width: 520px) {
    .brand__logo { width: 32px; height: 32px; }
    .brand__name { font-size: 14px; }
    .topbar__tools { flex: 1 1 100%; order: 2; }
    .term-select { flex: 1; }
    .term-select select { width: 100%; padding-right: 26px; }
    .kpi-card { flex-basis: 156px; }
    .kpi-card__value { font-size: 21px; }
}
