/* =========================================================================
   SIS design system
   Tokens → base → layout → components → utilities.
   Light/dark via [data-theme] on <html>; defaults to the OS preference.
   ========================================================================= */

:root {
    --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    --sidebar-w: 264px;
    --topbar-h: 64px;

    /* Light palette */
    --bg: #f6f7f9;
    --bg-elev: #ffffff;
    --bg-subtle: #f1f3f6;
    --bg-hover: #eef0f4;
    --border: #e4e7ec;
    --border-strong: #d0d5dd;
    --text: #101828;
    --text-2: #475467;
    --text-3: #667085;
    --text-inv: #ffffff;

    --brand: #c8102e;
    --brand-600: #a90d27;
    --brand-50: #fdf0f2;
    --brand-100: #fadbe0;
    --brand-ink: #8a0b20;

    --success: #079455;  --success-bg: #ecfdf3;  --success-ink: #067647;
    --warning: #dc6803;  --warning-bg: #fffaeb;  --warning-ink: #b54708;
    --danger:  #d92d20;  --danger-bg:  #fef3f2;  --danger-ink:  #b42318;
    --info:    #1570ef;  --info-bg:    #eff8ff;  --info-ink:    #175cd3;
    --violet:  #7a5af8;  --violet-bg:  #f4f3ff;  --violet-ink:  #5925dc;

    --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-md: 0 8px 24px -6px rgba(16, 24, 40, .12), 0 2px 6px rgba(16, 24, 40, .05);
    --shadow-lg: 0 20px 40px -12px rgba(16, 24, 40, .22);
    --ring: 0 0 0 4px rgba(200, 16, 46, .14);

    /* Sidebar: white in light mode, dark in dark mode */
    --sidebar-w-collapsed: 72px;
    --sidebar-bg: #ffffff;
    --sidebar-text: #344054;
    --sidebar-text-dim: #667085;
    --sidebar-strong: #101828;
    --sidebar-hover: #f2f4f7;
    --sidebar-active: var(--brand-50);
    --sidebar-active-text: var(--brand-ink);
    --sidebar-border: #e4e7ec;

    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #0b0e14;
    --bg-elev: #12161f;
    --bg-subtle: #171c27;
    --bg-hover: #1c2230;
    --border: #232a38;
    --border-strong: #2f3848;
    --text: #f2f4f7;
    --text-2: #b4bac6;
    --text-3: #8a93a3;

    --brand: #f04461;
    --brand-600: #ff5c77;
    --brand-50: rgba(240, 68, 97, .10);
    --brand-100: rgba(240, 68, 97, .18);
    --brand-ink: #ff8a9e;

    --success: #47cd89;  --success-bg: rgba(71, 205, 137, .12);  --success-ink: #75e0a7;
    --warning: #fdb022;  --warning-bg: rgba(253, 176, 34, .12);  --warning-ink: #fec84b;
    --danger:  #f97066;  --danger-bg:  rgba(249, 112, 102, .12); --danger-ink:  #fda29b;
    --info:    #53b1fd;  --info-bg:    rgba(83, 177, 253, .12);  --info-ink:    #84caff;
    --violet:  #9b8afb;  --violet-bg:  rgba(155, 138, 251, .12); --violet-ink:  #bdb4fe;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .5);
    --shadow-md: 0 8px 24px -6px rgba(0, 0, 0, .6);
    --shadow-lg: 0 20px 40px -12px rgba(0, 0, 0, .7);
    --ring: 0 0 0 4px rgba(240, 68, 97, .22);

    --sidebar-bg: #0c1018;
    --sidebar-text: #cecfd2;
    --sidebar-text-dim: #85888e;
    --sidebar-strong: #ffffff;
    --sidebar-hover: rgba(255, 255, 255, .06);
    --sidebar-active: rgba(255, 255, 255, .10);
    --sidebar-active-text: #ffffff;
    --sidebar-border: rgba(255, 255, 255, .07);

    color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    font-feature-settings: "cv11", "ss01", "ss03";
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; color: var(--text); letter-spacing: -0.015em; font-weight: 600; }
h1 { font-size: 26px; line-height: 1.25; letter-spacing: -0.025em; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-600); }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.i-sm { width: 15px; height: 15px; }
svg.i-lg { width: 22px; height: 22px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.tabular { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column;
    background: var(--sidebar-bg); color: var(--sidebar-text);
    border-right: 1px solid var(--sidebar-border);
    z-index: 40;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 18px; color: #fff; }
.sidebar-brand:hover { color: #fff; }
.brand-mark {
    width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
    background: linear-gradient(135deg, #e11d48 0%, #9f1239 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 4px 12px rgba(225, 29, 72, .35);
    font-weight: 700; font-size: 13px; letter-spacing: .02em; color: #fff;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15px; font-weight: 650; letter-spacing: -0.01em; }
.brand-text span { font-size: 11.5px; color: var(--sidebar-text-dim); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 6px 12px 16px; }
.nav-section { margin-top: 18px; }
.nav-label { padding: 0 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--sidebar-text-dim); }
.nav-link {
    display: flex; align-items: center; gap: 11px;
    padding: 8px 10px; margin: 1px 0; border-radius: 8px;
    color: var(--sidebar-text); font-weight: 500; font-size: 13.5px;
    transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--sidebar-hover); color: #fff; }
.nav-link.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 2px 0 0 #f43f5e; }
.nav-link .i { color: var(--sidebar-text-dim); }
.nav-link.active .i, .nav-link:hover .i { color: #fff; }
.nav-link .pill { margin-left: auto; font-size: 11px; padding: 1px 7px; border-radius: 99px; background: rgba(255,255,255,.1); color: #fff; }
.nav-link.disabled { opacity: .45; pointer-events: none; }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--sidebar-border); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; }
.user-chip .meta { min-width: 0; flex: 1; }
.user-chip .meta strong { display: block; color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .meta span { display: block; color: var(--sidebar-text-dim); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn-dark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; color: var(--sidebar-text-dim); background: none; border: 0; cursor: pointer; }
.icon-btn-dark:hover { background: var(--sidebar-hover); color: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 30;
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 16px;
    padding: 0 32px;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
}
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 13px; min-width: 0; }
.crumbs a { color: var(--text-3); }
.crumbs a:hover { color: var(--text); }
.crumbs .current { color: var(--text); font-weight: 500; }
.topbar-spacer { flex: 1; }
.search {
    display: flex; align-items: center; gap: 8px;
    width: min(340px, 36vw); height: 38px; padding: 0 12px;
    border: 1px solid var(--border); border-radius: 10px; background: var(--bg-elev);
    color: var(--text-3); box-shadow: var(--shadow-xs);
}
.search input { flex: 1; border: 0; outline: 0; background: none; color: var(--text); font: inherit; min-width: 0; }
.kbd { font-family: var(--font-mono); font-size: 11px; padding: 1px 6px; border: 1px solid var(--border); border-radius: 5px; color: var(--text-3); background: var(--bg-subtle); }
.icon-btn {
    display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
    background: var(--bg-elev); border: 1px solid var(--border); color: var(--text-2); cursor: pointer;
    box-shadow: var(--shadow-xs); position: relative;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn .dot { position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 2px var(--bg-elev); }
.menu-toggle { display: none; }

.content { padding: 28px 32px 56px; max-width: 1440px; width: 100%; margin: 0 auto; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { color: var(--text-3); margin-top: 4px; font-size: 14px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Avatar ---------- */
.avatar {
    width: 36px; height: 36px; border-radius: 50%; flex: none;
    display: grid; place-items: center; overflow: hidden;
    font-weight: 600; font-size: 13px; color: #fff;
    background: linear-gradient(135deg, #f43f5e, #8b5cf6);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 72px; height: 72px; font-size: 24px; }
.avatar-xl { width: 96px; height: 96px; font-size: 32px; border: 4px solid var(--bg-elev); box-shadow: var(--shadow-md); }
.avatar-sm { width: 30px; height: 30px; font-size: 11.5px; }

/* ---------- Cards ---------- */
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 0; }
.card-head p { color: var(--text-3); font-size: 13px; margin-top: 2px; }
.card-body { padding: 18px 20px 20px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; color: var(--text-3); font-size: 13px; }
.card-link { display: inline-flex; align-items: center; gap: 4px; font-weight: 500; font-size: 13px; }

.grid { display: grid; gap: 20px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 20px; }

/* ---------- Hero ---------- */
.hero {
    position: relative; overflow: hidden;
    border-radius: var(--radius-xl); padding: 28px 30px;
    background:
        radial-gradient(1200px 300px at 100% 0%, rgba(244, 63, 94, .35), transparent 60%),
        radial-gradient(800px 300px at 0% 100%, rgba(139, 92, 246, .30), transparent 60%),
        linear-gradient(135deg, #111827 0%, #1f1235 100%);
    color: #fff; margin-bottom: 24px;
    box-shadow: var(--shadow-md);
}
.hero::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background-image: radial-gradient(rgba(255,255,255,.07) 1px, transparent 1px);
    background-size: 18px 18px; mask-image: linear-gradient(90deg, transparent, #000 60%);
}
.hero h1 { color: #fff; font-size: 28px; }
.hero p { color: rgba(255,255,255,.72); margin-top: 6px; max-width: 60ch; }
.hero-row { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.hero-meta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.hero-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 99px; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.12); font-size: 12.5px; color: rgba(255,255,255,.9); backdrop-filter: blur(6px); }
.hero-progress { display: flex; align-items: center; gap: 18px; padding: 14px 18px; border-radius: 16px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12); }
.hero-progress .label { font-size: 12px; color: rgba(255,255,255,.6); }
.hero-progress .value { font-size: 22px; font-weight: 650; }

/* ---------- Stat tiles ---------- */
.stat { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-label { color: var(--text-3); font-size: 13px; font-weight: 500; }
.stat-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; }
.stat-value { font-size: 28px; font-weight: 650; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 15px; color: var(--text-3); font-weight: 500; letter-spacing: 0; }
.stat-sub { color: var(--text-3); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }

.tone-brand   { background: var(--brand-50);   color: var(--brand); }
.tone-success { background: var(--success-bg); color: var(--success); }
.tone-warning { background: var(--warning-bg); color: var(--warning); }
.tone-danger  { background: var(--danger-bg);  color: var(--danger); }
.tone-info    { background: var(--info-bg);    color: var(--info); }
.tone-violet  { background: var(--violet-bg);  color: var(--violet); }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
    padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 500; line-height: 20px;
    border: 1px solid transparent;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge.no-dot::before { display: none; }
.badge-success { background: var(--success-bg); color: var(--success-ink); }
.badge-warning { background: var(--warning-bg); color: var(--warning-ink); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger-ink); }
.badge-info    { background: var(--info-bg);    color: var(--info-ink); }
.badge-violet  { background: var(--violet-bg);  color: var(--violet-ink); }
.badge-neutral { background: var(--bg-subtle);  color: var(--text-2); border-color: var(--border); }
.badge-brand   { background: var(--brand-50);   color: var(--brand-ink); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 38px; padding: 0 14px; border-radius: 10px;
    font: inherit; font-weight: 550; font-size: 13.5px; cursor: pointer; white-space: nowrap;
    border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--text);
    box-shadow: var(--shadow-xs); transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--bg-hover); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 0; box-shadow: var(--ring); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(200,16,46,.3), inset 0 1px 0 rgba(255,255,255,.15); }
.btn-primary:hover { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-hover); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn-lg { height: 46px; padding: 0 20px; font-size: 15px; border-radius: 12px; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 550; font-size: 13px; color: var(--text-2); }
.input, .select {
    height: 42px; padding: 0 13px; width: 100%;
    border: 1px solid var(--border-strong); border-radius: 10px;
    background: var(--bg-elev); color: var(--text); font: inherit; font-size: 14px;
    box-shadow: var(--shadow-xs); transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus { outline: 0; border-color: var(--brand); box-shadow: var(--ring); }
.input-icon { position: relative; }
.input-icon .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.input-icon .input { padding-left: 38px; }
.field-error { color: var(--danger); font-size: 12.5px; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13.5px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }

/* ---------- Alerts ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; font-size: 13.5px; border: 1px solid transparent; margin-bottom: 16px; }
.alert-danger { background: var(--danger-bg); color: var(--danger-ink); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-info { background: var(--info-bg); color: var(--info-ink); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.alert-warning { background: var(--warning-bg); color: var(--warning-ink); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; position: relative; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th {
    text-align: left; font-weight: 550; font-size: 12px; color: var(--text-3);
    text-transform: uppercase; letter-spacing: .04em;
    padding: 10px 16px; background: var(--bg-subtle); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text-2); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover td { background: var(--bg-hover); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .strong { color: var(--text); font-weight: 550; }
.table .muted { color: var(--text-3); font-size: 12.5px; }
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 20px; }
.row-link { cursor: pointer; }
.cell-user { display: flex; align-items: center; gap: 11px; }
.cell-user .who strong { display: block; color: var(--text); font-weight: 550; }
.cell-user .who span { display: block; color: var(--text-3); font-size: 12.5px; }
/* Sortable headers: <th class="sorted" aria-sort="…"><a class="th-sort" href="?sort=…">Name ▲</a></th> */
th .th-sort { color: inherit; text-decoration: none; white-space: nowrap; }
th .th-sort:hover, th .th-sort:focus-visible { color: var(--brand); }
th.sorted .th-sort { color: var(--text); }

/* ---------- Summary strip above lists ---------- */
/* <div class="admin-summary"><div class="is-warning|is-danger"><span>Label</span><strong>Value</strong><small>note</small></div>…</div>;
   a count may link to its filter: <strong><a href="?status=…">12</a></strong>. */
.admin-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-elev); overflow: hidden; margin-bottom: 16px; }
.admin-summary > div { padding: 12px 16px; border-left: 1px solid var(--border); min-width: 0; }
.admin-summary > div:first-child { border-left: 0; }
.admin-summary span { display: block; font-size: 12px; color: var(--text-3); font-weight: 500; }
.admin-summary strong { display: block; font-size: 19px; font-weight: 650; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.admin-summary small { color: var(--text-3); font-size: 12px; }
.admin-summary .is-danger strong { color: var(--danger-ink); }
.admin-summary .is-warning strong { color: var(--warning-ink); }
.admin-summary strong a { color: inherit; text-decoration: none; }
.admin-summary strong a:hover, .admin-summary strong a:focus-visible { color: var(--brand); text-decoration: underline; }
@media (max-width: 640px) {
    .admin-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .admin-summary > div { border-left: 0; border-top: 1px solid var(--border); }
    .admin-summary > div:nth-child(-n+2) { border-top: 0; }
    .admin-summary > div:nth-child(even) { border-left: 1px solid var(--border); }
}

/* ---------- Progress ---------- */
.progress { height: 8px; border-radius: 99px; background: var(--bg-subtle); overflow: hidden; border: 1px solid var(--border); }
.progress > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #f43f5e, #8b5cf6); }
.progress.success > span { background: var(--success); }
.progress.warning > span { background: var(--warning); }
.progress.danger > span { background: var(--danger); }

.ring { --p: 0; --size: 84px; --thick: 9px; --c: #f43f5e;
    width: var(--size); height: var(--size); border-radius: 50%; display: grid; place-items: center; flex: none;
    background: conic-gradient(var(--c) calc(var(--p) * 1%), rgba(255,255,255,.12) 0);
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - var(--thick)), #000 calc(100% - var(--thick) + 1px));
            mask: radial-gradient(farthest-side, transparent calc(100% - var(--thick)), #000 calc(100% - var(--thick) + 1px));
}
.ring-wrap { position: relative; display: grid; place-items: center; }
.ring-wrap .ring-label { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 650; font-size: 17px; }
.ring.on-light { background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--bg-subtle) 0); }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--border); }
.list-item:first-child { border-top: 0; }
.list-item .body { flex: 1; min-width: 0; }
.list-item .title { color: var(--text); font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .sub { color: var(--text-3); font-size: 12.5px; }
.list-item .end { text-align: right; font-variant-numeric: tabular-nums; }
.leading { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none; }

.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 0; }
.kv dt, .kv dd { margin: 0; padding: 11px 0; border-top: 1px solid var(--border); }
.kv dt { color: var(--text-3); font-size: 13px; }
.kv dd { color: var(--text); font-weight: 500; overflow-wrap: anywhere; }
.kv dt:first-of-type, .kv dd:first-of-type { border-top: 0; }

/* ---------- Tabs / segmented ---------- */
.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--bg-subtle); border: 1px solid var(--border); }
.segmented a, .segmented button { padding: 6px 12px; border-radius: 7px; font-size: 13px; font-weight: 500; color: var(--text-2); border: 0; background: none; cursor: pointer; font-family: inherit; }
.segmented a.active, .segmented button.active { background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty .leading { margin: 0 auto 12px; width: 48px; height: 48px; border-radius: 14px; }
.empty h3 { color: var(--text); margin-bottom: 4px; }

/* ---------- Timeline (installments) ---------- */
.timeline { list-style: none; margin: 0; padding: 4px 20px 16px; position: relative; }
.timeline li { position: relative; display: flex; gap: 14px; padding: 10px 0; }
.timeline li::before { content: ""; position: absolute; left: 11px; top: 32px; bottom: -10px; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline .node { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex: none; z-index: 1; }
.timeline .node .i { width: 13px; height: 13px; stroke-width: 2.5; }

/* ---------- Grade pill ---------- */
.grade { display: inline-grid; place-items: center; min-width: 44px; height: 28px; padding: 0 8px; border-radius: 8px; font-weight: 650; font-variant-numeric: tabular-nums; font-size: 13.5px; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.toolbar .input, .toolbar .select { height: 36px; font-size: 13.5px; }
.toolbar .input-icon { flex: 1; min-width: 220px; max-width: 380px; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; border-top: 1px solid var(--border); color: var(--text-3); font-size: 13px; }
.pager .btns { display: flex; gap: 6px; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--bg-elev); }
.auth-aside {
    position: relative; overflow: hidden; color: #fff; padding: 48px;
    display: flex; flex-direction: column; justify-content: space-between;
    background:
        radial-gradient(900px 500px at 110% -10%, rgba(244, 63, 94, .55), transparent 60%),
        radial-gradient(700px 500px at -10% 110%, rgba(139, 92, 246, .45), transparent 60%),
        #0c0a17;
}
.auth-aside::after { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255,255,255,.08) 1px, transparent 1px); background-size: 22px 22px; mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%); pointer-events: none; }
.auth-aside > * { position: relative; z-index: 1; }
.auth-aside h2 { color: #fff; font-size: 38px; line-height: 1.12; letter-spacing: -0.035em; max-width: 16ch; font-weight: 650; }
.auth-aside p { color: rgba(255,255,255,.7); font-size: 16px; max-width: 46ch; margin-top: 14px; }
.auth-features { display: grid; gap: 12px; margin-top: 32px; }
.auth-feature { display: flex; gap: 12px; align-items: center; color: rgba(255,255,255,.85); }
.auth-feature .leading { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); color: #fff; }
.auth-main { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 28px; }
.auth-card .sub { color: var(--text-3); margin: 6px 0 28px; }
.auth-foot { color: rgba(255,255,255,.5); font-size: 12.5px; }
/* SIS logo (navy/red artwork) on a white plate so it reads on the dark aside and in dark mode */
.auth-logo { display: inline-block; background: #fff; border-radius: 14px; padding: 10px 16px; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.auth-logo img { display: block; width: 132px; height: auto; }
.auth-logo-sm { display: none; }

/* ---------- Profile header ---------- */
.profile-cover { height: 120px; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background: radial-gradient(600px 200px at 80% 0%, rgba(244,63,94,.6), transparent 60%), radial-gradient(500px 200px at 10% 100%, rgba(139,92,246,.5), transparent 60%), #151026; }
.profile-head { display: flex; align-items: flex-end; gap: 18px; padding: 0 24px 20px; margin-top: -40px; flex-wrap: wrap; }
.profile-head .who { flex: 1; min-width: 200px; padding-bottom: 4px; }
.profile-head h2 { font-size: 22px; }
.profile-head .who p { color: var(--text-3); margin-top: 2px; }

/* ---------- Utilities ---------- */
.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.fw-600 { font-weight: 600; }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--font-mono); font-size: 12.5px; }

.fade-in { animation: fadeIn .35s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .fade-in { animation: none; } * { transition: none !important; } }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 960px) {
    .app { grid-template-columns: minmax(0, 1fr); }
    .sidebar { position: fixed; left: 0; top: 0; width: var(--sidebar-w); transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow-lg); }
    .app.nav-open .sidebar { transform: none; }
    .app.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 35; }
    .menu-toggle { display: grid; }
    .topbar { padding: 0 16px; }
    .content { padding: 20px 16px 48px; }
    .search { display: none; }
    .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); }
    .auth { grid-template-columns: minmax(0, 1fr); }
    .auth-aside { display: none; }
    .auth-main { align-content: center; justify-items: center; gap: 24px; }
    .auth-logo-sm { display: inline-block; }
    .auth-logo-sm img { width: 112px; }
}
@media (max-width: 560px) {
    .grid-4 { grid-template-columns: minmax(0, 1fr); }
    .hero { padding: 22px 20px; }
    .kv { grid-template-columns: minmax(0, 1fr); }
    .kv dd { padding-top: 0; border-top: 0; }
    .crumbs .hide-sm { display: none; }
}

/* Theme toggle icon swap */
:root[data-theme="dark"] .theme-moon, :root:not([data-theme="dark"]) .theme-sun { display: none; }

/* ---------- Charts ---------- */
.bar-chart { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; height: 220px; align-items: end;
    background-image: linear-gradient(var(--border) 1px, transparent 1px); background-size: 100% 25%; background-position: 0 -1px; padding-top: 4px; }
.bar-col { position: relative; height: 100%; display: flex; flex-direction: column; align-items: center; gap: 8px; outline: 0; }
.bar-track { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; border-bottom: 1px solid var(--border-strong); }
.bar { display: block; width: min(28px, 70%); border-radius: 4px 4px 0 0; background: var(--brand); opacity: .85; transition: opacity .15s; }
.bar-col:hover .bar, .bar-col:focus-visible .bar { opacity: 1; }
.bar-x { font-size: 11px; color: var(--text-3); }
.hbar { margin-bottom: 14px; position: relative; }
.hbar:last-child { margin-bottom: 0; }
.hbar-track { height: 8px; margin-top: 6px; border-radius: 99px; background: var(--bg-subtle); overflow: hidden; }
.hbar-track > span { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--brand); opacity: .85; }
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after {
    content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%);
    padding: 6px 10px; border-radius: 8px; white-space: nowrap; z-index: 10; pointer-events: none;
    background: var(--text); color: var(--bg-elev); font-size: 12px; font-weight: 500; box-shadow: var(--shadow-md);
}
.bar-col[data-tip]:hover::after, .bar-col[data-tip]:focus-visible::after { bottom: auto; top: -8px; transform: translate(-50%, -100%); }

.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }

/* =========================================================================
   Extended components (forms, wizard, tabs, threads, accordion, rating…)
   ========================================================================= */
.textarea { min-height: 120px; padding: 11px 13px; height: auto; resize: vertical; line-height: 1.5; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.field .hint { color: var(--text-3); font-size: 12.5px; }
.field .req { color: var(--danger); margin-left: 2px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; padding-top: 8px; flex-wrap: wrap; }
.form-section { padding-top: 8px; margin-top: 8px; border-top: 1px solid var(--border); }
.form-section > h3 { margin: 14px 0 12px; }
.radio-cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); }
.radio-card { position: relative; display: flex; gap: 10px; padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: 12px; cursor: pointer; background: var(--bg-elev); transition: border-color .15s, box-shadow .15s; }
.radio-card:hover { border-color: var(--brand); }
.radio-card input { accent-color: var(--brand); margin-top: 3px; }
.radio-card:has(input:checked) { border-color: var(--brand); box-shadow: var(--ring); }
.radio-card strong { display: block; font-size: 13.5px; }
.radio-card span { display: block; color: var(--text-3); font-size: 12.5px; }

.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center;
    padding: 28px 16px; border: 1.5px dashed var(--border-strong); border-radius: 14px; background: var(--bg-subtle); color: var(--text-3); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-50); color: var(--text-2); }
.dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone strong { color: var(--text); }
.dropzone .file-name { font-weight: 550; color: var(--brand); }

.steps { display: flex; gap: 0; list-style: none; padding: 0; margin: 0 0 24px; counter-reset: step; }
.steps li { flex: 1; position: relative; display: flex; align-items: center; gap: 10px; color: var(--text-3); font-size: 13px; font-weight: 500; }
.steps li::before { counter-increment: step; content: counter(step); width: 28px; height: 28px; flex: none; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--border-strong); background: var(--bg-elev); font-weight: 600; font-size: 12.5px; }
.steps li:not(:last-child)::after { content: ""; flex: 1; height: 2px; background: var(--border); margin: 0 10px; border-radius: 2px; }
.steps li.done { color: var(--text-2); }
.steps li.done::before { content: "✓"; background: var(--success); border-color: var(--success); color: #fff; }
.steps li.done::after { background: var(--success); }
.steps li.current { color: var(--text); }
.steps li.current::before { border-color: var(--brand); color: var(--brand); box-shadow: var(--ring); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tabs a, .tabs button { padding: 10px 14px; margin-bottom: -1px; border: 0; border-bottom: 2px solid transparent; background: none; font: inherit; font-weight: 550; font-size: 13.5px; color: var(--text-3); cursor: pointer; white-space: nowrap; }
.tabs a:hover, .tabs button:hover { color: var(--text); }
.tabs a.active, .tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--border); background: var(--bg-elev); font-size: 12.5px; color: var(--text-2); }

.thread { display: flex; flex-direction: column; gap: 14px; padding: 20px; }
.msg { display: flex; gap: 10px; max-width: 82%; }
.msg .bubble { padding: 10px 14px; border-radius: 14px; background: var(--bg-subtle); border: 1px solid var(--border); color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .meta { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }
.msg.me { margin-left: auto; flex-direction: row-reverse; }
.msg.me .bubble { background: var(--brand); border-color: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.msg.me .meta { text-align: right; }
.msg:not(.me) .bubble { border-bottom-left-radius: 4px; }
.composer { display: flex; gap: 10px; align-items: flex-end; padding: 14px 20px; border-top: 1px solid var(--border); }
.composer .textarea { min-height: 44px; max-height: 200px; }

.accordion { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--bg-elev); }
.accordion details { border-top: 1px solid var(--border); }
.accordion details:first-child { border-top: 0; }
.accordion summary { list-style: none; cursor: pointer; padding: 14px 18px; font-weight: 550; display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary::after { content: "+"; font-size: 18px; color: var(--text-3); transition: transform .2s; }
.accordion details[open] summary::after { transform: rotate(45deg); }
.accordion summary:hover { background: var(--bg-hover); }
.accordion .acc-body { padding: 0 18px 16px; color: var(--text-2); }

.rating { display: inline-flex; flex-direction: row-reverse; gap: 4px; }
.rating input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.rating label { cursor: pointer; font-size: 26px; line-height: 1; color: var(--border-strong); transition: color .1s, transform .1s; }
.rating label:hover, .rating label:hover ~ label, .rating input:checked ~ label { color: #f5a524; }
.rating label:active { transform: scale(.92); }
.scale { display: flex; gap: 6px; flex-wrap: wrap; }
.scale label { position: relative; }
.scale input { position: absolute; opacity: 0; }
.scale span { display: grid; place-items: center; min-width: 40px; height: 36px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 9px; cursor: pointer; font-weight: 550; font-size: 13px; color: var(--text-2); background: var(--bg-elev); }
.scale input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.scale input:focus-visible + span { box-shadow: var(--ring); }

dialog.modal { border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 0; width: min(520px, calc(100vw - 32px)); background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-lg); }
dialog.modal::backdrop { background: rgba(10, 12, 18, .5); backdrop-filter: blur(2px); }
dialog.modal .modal-head { padding: 18px 20px 0; }
dialog.modal .modal-body { padding: 14px 20px; }
dialog.modal .modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
dialog.modal .modal-head h2 { font-size: 17px; margin: 0; }
dialog.modal[open] { animation: modal-in .16s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { dialog.modal[open] { animation: none; } }
.sis-modal #sis-modal-msg { white-space: pre-line; color: var(--text-2); margin: 0; }
.sis-modal #sis-modal-input { margin-top: 10px; width: 100%; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-ink); border-color: var(--danger-ink); color: #fff; }
@media (max-width: 480px) { dialog.modal .modal-foot { flex-direction: column-reverse; } dialog.modal .modal-foot .btn { width: 100%; justify-content: center; } }

.flash { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-radius: 12px; margin-bottom: 20px; font-weight: 500; font-size: 13.5px; animation: fadeIn .3s ease both; }
.flash-success { background: var(--success-bg); color: var(--success-ink); border: 1px solid color-mix(in srgb, var(--success) 25%, transparent); }
.flash-error { background: var(--danger-bg); color: var(--danger-ink); border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-success { background: var(--success-bg); color: var(--success-ink); border-color: color-mix(in srgb, var(--success) 25%, transparent); }

.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 14px; }
.tile { display: flex; flex-direction: column; gap: 10px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-xs); transition: border-color .15s, box-shadow .15s, transform .15s; }
.tile:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); color: var(--text); }
.tile .leading { width: 40px; height: 40px; }
.tile strong { font-size: 14px; font-weight: 600; }
.tile span { color: var(--text-3); font-size: 12.5px; }

.prose { color: var(--text-2); line-height: 1.65; }
.prose h1, .prose h2, .prose h3 { margin: 1.2em 0 .5em; }
.prose p, .prose ul, .prose ol { margin: 0 0 .9em; }
.prose a { text-decoration: underline; }
.prose img { max-width: 100%; height: auto; border-radius: 8px; }
.prose table { border-collapse: collapse; width: 100%; }
.prose td, .prose th { border: 1px solid var(--border); padding: 6px 8px; }

.photo-frame { width: 160px; height: 160px; border-radius: 20px; overflow: hidden; background: var(--bg-subtle); border: 1px solid var(--border); display: grid; place-items: center; }
.photo-frame img { width: 100%; height: 100%; object-fit: cover; }

@media (max-width: 760px) {
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .steps li span.step-label { display: none; }
    .msg { max-width: 94%; }
}

/* ---------- Admin navigation: 4 sections + favourites/recent, star toggles, "More…" pages, command palette ---------- */
.nav-count { font-size: 10.5px; padding: 0 6px; border-radius: 99px; background: rgba(255,255,255,.08); color: var(--sidebar-text-dim); letter-spacing: 0; font-weight: 500; }
.nav-sec { margin-top: 2px; }
.nav-sec-btn {
    display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px;
    background: none; color: var(--sidebar-strong); font: inherit; font-size: 13.5px; font-weight: 600; text-align: left; cursor: pointer;
}
.nav-sec-btn:hover { background: var(--sidebar-hover); }
.nav-sec-btn .i { color: var(--sidebar-text-dim); }
.nav-sec.is-current > .nav-sec-btn > .i:first-child { color: var(--brand); }
.nav-sec-title { flex: 1; min-width: 0; }
.nav-sec-chev { transition: transform .15s; }
.nav-sec-btn[aria-expanded="true"] .nav-sec-chev { transform: rotate(90deg); }
.nav-sec-body { padding: 0 0 8px; }
.nav-sec-body .nav-link, .nav-personal .nav-link { padding-left: 14px; font-size: 13px; }
.nav-div { height: 1px; margin: 5px 10px 5px 14px; background: var(--sidebar-border); }
.nav-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-hub-chev { opacity: .55; }
.nav-more { color: var(--sidebar-text-dim); }
.nav-personal { margin: 4px 0 8px; }
.nav-personal .nav-label { display: flex; align-items: center; gap: 6px; padding-top: 8px; }
.sidebar :is(.nav-link, .nav-sec-btn, .nav-jump):focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

/* Favourite star (page heads, "More…" pages, home). */
.star-btn {
    display: inline-grid; place-items: center; flex: none; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 8px;
    background: none; color: var(--text-3); cursor: pointer; vertical-align: middle;
}
.star-btn:hover { background: var(--bg-hover); color: var(--text); }
.star-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.star-btn[aria-pressed="true"] { color: #f59e0b; }
.star-btn[aria-pressed="true"] .i { fill: currentColor; }
.page-head h1 .star-btn { margin-left: 4px; position: relative; top: -2px; }

/* "More…" page of a section and the admin home lists. */
.sec-tabs { display: flex; width: max-content; }
.sec-tabs a { display: inline-flex; align-items: center; gap: 6px; }
.sec-toolbar { padding: 0; border: 0; }
.sec-toolbar .sec-search { flex: 1; max-width: 460px; min-width: 0; }
.sec-jump { display: flex; flex-wrap: wrap; gap: 6px; }
.sec-jump .chip:hover { color: var(--text); border-color: var(--border-strong, var(--border)); }
.sec-group .card-head h2 { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.sec-group .card-head .leading, .home-sec .card-head .leading { width: 30px; height: 30px; border-radius: 8px; }
.sec-list { list-style: none; margin: 0; padding: 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 2px 8px; }
.sec-list li { display: flex; align-items: center; gap: 4px; min-width: 0; border-radius: 10px; }
.sec-list li:hover { background: var(--bg-hover); }
.sec-list li > a { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; padding: 9px 8px; color: var(--text); border-radius: 10px; }
.sec-list .leading { width: 32px; height: 32px; border-radius: 9px; flex: none; }
.sec-list .body { display: flex; flex-direction: column; min-width: 0; }
.sec-list .body strong { font-weight: 550; font-size: 14px; }
.sec-list .body span { color: var(--text-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-body .sec-list { padding: 0; }
/* Hub pages (/Admin/Hub/{key}): the legacy hub cards, flowing in columns like the legacy tile walls. */
.hub-grid { columns: 3 340px; column-gap: 16px; }
.hub-card { break-inside: avoid; margin-bottom: 16px; }
.hub-card[hidden] { display: none; }
.hub-card .card-head h2 { font-size: 15px; }
.hub-card .sec-list { grid-template-columns: 1fr; padding: 6px; }
.hub-card .sec-list li > a { padding: 6px 8px; gap: 10px; }
/* Admin home: search box, hub tiles, "my buttons"; "back to hub" link on pages opened from a hub button. */
.home-search { display: flex; align-items: center; gap: 12px; height: 54px; padding: 0 16px; margin-bottom: 20px; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--bg-elev); box-shadow: var(--shadow-xs); color: var(--text-3); cursor: text; }
.home-search:focus-within { border-color: var(--brand); box-shadow: var(--ring); }
.home-search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; font: inherit; font-size: 15.5px; color: var(--text); }
.home-search .kbd { flex: none; }
.hub-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.hub-tile { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-elev); box-shadow: var(--shadow-xs); color: var(--text); transition: border-color .12s, box-shadow .12s, transform .12s; }
.hub-tile:hover, .hub-tile:focus-visible { border-color: var(--brand); box-shadow: var(--shadow-sm); transform: translateY(-1px); text-decoration: none; }
.hub-tile:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.hub-tile .leading { width: 42px; height: 42px; border-radius: 12px; margin-bottom: 4px; }
.hub-tile strong { font-size: 15.5px; font-weight: 600; line-height: 1.3; }
.hub-tile .muted { font-size: 13px; }
.hub-tiles-sm { grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: 10px; margin-top: 14px; }
.hub-tiles-sm .hub-tile { flex-direction: row; align-items: center; gap: 10px; padding: 10px 12px; }
.hub-tiles-sm .hub-tile .leading { width: 30px; height: 30px; border-radius: 8px; margin: 0; flex: none; }
.hub-tiles-sm .hub-tile strong { font-size: 13.5px; font-weight: 550; }
.home-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.home-buttons:empty { display: none; }
.home-btn { display: inline-flex; align-items: center; max-width: 100%; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-subtle); }
.home-btn > a { display: inline-flex; align-items: center; gap: 8px; min-width: 0; padding: 7px 4px 7px 12px; color: var(--text); font-size: 13.5px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-btn > a:hover { color: var(--brand); text-decoration: none; }
.home-btn .star-btn { width: 30px; height: 30px; }
.hub-back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: var(--text-3); }
.hub-back:hover { color: var(--brand); }
@media (max-width: 900px) { .hub-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) {
    .hub-tiles { grid-template-columns: 1fr; gap: 10px; }
    .hub-tiles:not(.hub-tiles-sm) .hub-tile { flex-direction: row; align-items: center; gap: 12px; padding: 12px 14px; }
    .hub-tiles:not(.hub-tiles-sm) .hub-tile .leading { margin: 0; flex: none; }
    .hub-tiles:not(.hub-tiles-sm) .hub-tile .muted { margin-left: auto; flex: none; }
    .home-search .kbd { display: none; }
}
.hub-card .sec-list .leading { width: 28px; height: 28px; border-radius: 8px; }
.hub-card .sec-list .body strong { font-size: 13.5px; }
.hub-card .sec-list .body span { font-size: 12px; -webkit-line-clamp: 1; }
.hub-chev { margin-left: auto; color: var(--text-3); }
.hub-crumbs { display: flex; flex-wrap: wrap; gap: 12px; margin: 0 0 4px; font-size: 13px; }
.hub-crumbs a { display: inline-flex; align-items: center; gap: 4px; color: var(--text-3); }
.hub-crumbs a:hover { color: var(--text); }
.home-sec .card-head h2 { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.home-links { display: flex; flex-wrap: wrap; gap: 6px; }
.home-links .chip:hover { color: var(--text); background: var(--bg-hover); }
.nav-jump { display: flex; align-items: center; gap: 8px; width: 100%; margin: 6px 0 4px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--sidebar-border); background: rgba(255,255,255,.04); color: var(--sidebar-text-dim); font: inherit; font-size: 13px; cursor: pointer; }
.nav-jump:hover { color: #fff; background: var(--sidebar-hover); }
.nav-jump .kbd { margin-left: auto; background: transparent; border-color: var(--sidebar-border); color: var(--sidebar-text-dim); }

dialog.palette { width: min(640px, calc(100vw - 32px)); margin-top: 10vh; }
.palette-search { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--text-3); }
.palette-search input { flex: 1; border: 0; outline: 0; background: none; font: inherit; font-size: 16px; color: var(--text); }
.palette-list { list-style: none; margin: 0; padding: 6px; max-height: min(60vh, 520px); overflow-y: auto; }
.palette-list a { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 10px; color: var(--text); }
.palette-list a:hover, .palette-list a.sel { background: var(--bg-hover); }
.palette-list a.sel { box-shadow: inset 2px 0 0 var(--brand); }
.palette-list .leading { width: 32px; height: 32px; border-radius: 9px; }
.palette-list .body { display: flex; flex-direction: column; min-width: 0; }
.palette-list .body strong { font-weight: 550; font-size: 14px; }
.palette-list .body span { color: var(--text-3); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-empty { padding: 28px; text-align: center; color: var(--text-3); }

/* ---------- In-place navigation (htmx) ---------- */
body::before {
    content: ""; position: fixed; left: 0; top: 0; height: 2px; width: 0; z-index: 100; pointer-events: none;
    background: linear-gradient(90deg, #f43f5e, #8b5cf6); opacity: 0; transition: opacity .2s;
}
body.is-loading::before { opacity: 1; animation: sis-progress 1.2s ease-out forwards; }
@keyframes sis-progress { from { width: 0; } 60% { width: 70%; } to { width: 85%; } }
@media (prefers-reduced-motion: reduce) { body.is-loading::before { animation: none; width: 100%; } }

/* =========================================================================
   Sidebar theming (token-based) + foldable rail
   ========================================================================= */
.sidebar-head { display: flex; align-items: center; gap: 4px; padding-right: 10px; }
.sidebar-head .sidebar-brand { flex: 1; min-width: 0; }
.sidebar-brand, .sidebar-brand:hover { color: var(--sidebar-strong); }
.nav-link:hover, .nav-link:hover .i { color: var(--sidebar-strong); }
.nav-link.active { background: var(--sidebar-active); color: var(--sidebar-active-text); box-shadow: inset 2px 0 0 var(--brand); font-weight: 600; }
.nav-link.active .i { color: var(--sidebar-active-text); }
.nav-link .pill { background: var(--sidebar-hover); color: var(--sidebar-text-dim); }
.user-chip .meta strong { color: var(--sidebar-strong); }
.icon-btn-dark:hover { color: var(--sidebar-strong); }
.nav-count { background: var(--sidebar-hover); }
.nav-jump { background: var(--sidebar-hover); }
.nav-jump:hover { color: var(--sidebar-strong); }
.sidebar ::-webkit-scrollbar { width: 8px; }
.sidebar ::-webkit-scrollbar-thumb { background: var(--sidebar-border); border-radius: 8px; }

.collapse-btn { flex: none; }
.collapse-btn .i { transition: transform .2s; }

/* Collapsed rail (desktop only). State lives on <html data-nav="collapsed"> so it survives page swaps. */
@media (min-width: 961px) {
    .app { transition: grid-template-columns .2s ease; }
    :root[data-nav="collapsed"] .app { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }
    :root[data-nav="collapsed"] .sidebar-head { flex-direction: column; padding: 14px 0 6px; gap: 8px; }
    :root[data-nav="collapsed"] .sidebar-brand { padding: 0; justify-content: center; flex: none; }
    :root[data-nav="collapsed"] .brand-text,
    :root[data-nav="collapsed"] .nav-label,
    :root[data-nav="collapsed"] .nav-count,
    :root[data-nav="collapsed"] .nav-link .pill,
    :root[data-nav="collapsed"] .user-chip .meta,
    :root[data-nav="collapsed"] .nav-jump .kbd { display: none; }
    :root[data-nav="collapsed"] .collapse-btn .i { transform: rotate(180deg); }
    :root[data-nav="collapsed"] .sidebar-nav { padding: 4px 10px 16px; }
    :root[data-nav="collapsed"] .nav-section { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--sidebar-border); }
    :root[data-nav="collapsed"] .nav-section:first-child { border-top: 0; margin-top: 0; }
    :root[data-nav="collapsed"] .nav-link,
    :root[data-nav="collapsed"] .nav-jump { font-size: 0; justify-content: center; padding: 10px 0; gap: 0; }
    :root[data-nav="collapsed"] .nav-link .i, :root[data-nav="collapsed"] .nav-jump .i { width: 19px; height: 19px; }
    :root[data-nav="collapsed"] .nav-link.active { box-shadow: none; }
    :root[data-nav="collapsed"] .nav-sec { border-top: 1px solid var(--sidebar-border); padding-top: 4px; margin-top: 4px; }
    :root[data-nav="collapsed"] .nav-sec-btn { justify-content: center; padding: 10px 0; }
    :root[data-nav="collapsed"] .nav-sec-btn .i { width: 19px; height: 19px; }
    :root[data-nav="collapsed"] .nav-sec-title,
    :root[data-nav="collapsed"] .nav-sec-chev,
    :root[data-nav="collapsed"] .nav-hub-chev,
    :root[data-nav="collapsed"] .nav-div { margin-left: 10px; }
    :root[data-nav="collapsed"] .nav-sec-body .nav-link, :root[data-nav="collapsed"] .nav-personal .nav-link { padding-left: 0; }
    :root[data-nav="collapsed"] .nav-sec-body .nav-link .i, :root[data-nav="collapsed"] .nav-personal .nav-link .i { width: 16px; height: 16px; }
    :root[data-nav="collapsed"] .nav-personal { border-top: 1px solid var(--sidebar-border); }
    :root[data-nav="collapsed"] .user-chip { flex-direction: column; padding: 4px 0; }
    :root[data-nav="collapsed"] .sidebar-foot { padding: 10px 8px; }
}
@media (max-width: 960px) { .collapse-btn { display: none; } }

/* ---------- Mobile hardening (from the mobile audit) ---------- */
.stack > *, .grid > * { min-width: 0; }
.steps li { min-width: 0; }
@media (max-width: 560px) {
    /* Wizard steps: circles only, plus the current step's label. */
    .steps li:not(.current) { font-size: 0; gap: 0; flex: 0 0 auto; }
    .steps li:not(.current):not(:last-child) { flex: 1 1 auto; }
    .steps li::before { font-size: 12.5px; }
    .steps li:not(:last-child)::after { min-width: 12px; }
    .page-head { align-items: flex-start; }
    .page-actions { width: 100%; }
    .toolbar .input-icon { min-width: 0; max-width: none; }
    .hero h1 { font-size: 23px; }
}.card-head { flex-wrap: wrap; }
.segmented { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
.segmented a, .segmented button { white-space: nowrap; flex: none; }
.kv dd, .kv dt { min-width: 0; overflow-wrap: anywhere; }

/* ---------- Admin: legacy top menu (Site.Master navbar) — Shared/Components/AdminNav/Top.cshtml ---------- */
.app.app-top { display: block; }
.app-top .content { max-width: 1480px; }
.lnav { position: sticky; top: 0; z-index: 40; background: var(--bg-elev); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-xs); }
.lnav-inner { display: flex; align-items: center; gap: 8px; min-height: 60px; max-width: 1480px; margin: 0 auto; padding: 0 20px; }
.lnav-brand { display: inline-flex; align-items: center; gap: 10px; margin-right: 10px; color: var(--text); font-weight: 700; font-size: 17px; flex: none; }
.lnav-brand:hover { text-decoration: none; color: var(--text); }
.lnav-collapse { display: flex; align-items: center; flex: 1; min-width: 0; gap: 8px; }
.lnav-menu { display: flex; align-items: center; gap: 2px; list-style: none; margin: 0; padding: 0; }
.lnav-right { margin-left: auto; }
.lnav-top { display: inline-flex; align-items: center; gap: 5px; height: 40px; padding: 0 13px; border: 0; border-radius: 8px; background: none; color: var(--text-2); font: inherit; font-size: 14.5px; font-weight: 550; cursor: pointer; white-space: nowrap; }
.lnav-top:hover, .lnav-top[aria-expanded="true"] { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.lnav-top.active { color: var(--brand); }
.lnav-top .i { opacity: .7; }
.lnav-dd { position: relative; }
.lnav-drop { position: absolute; top: calc(100% + 6px); left: 0; z-index: 50; min-width: 250px; max-height: calc(100vh - 90px); overflow-y: auto; list-style: none; margin: 0; padding: 6px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-elev); box-shadow: var(--shadow-lg, 0 12px 32px rgba(0,0,0,.14)); }
.lnav-drop-right { left: auto; right: 0; }
.lnav-drop a, .lnav-logout { display: block; width: 100%; padding: 7px 12px; border: 0; border-radius: 7px; background: none; color: var(--text); font: inherit; font-size: 14px; text-align: left; white-space: nowrap; cursor: pointer; }
.lnav-drop a:hover, .lnav-drop a:focus-visible, .lnav-logout:hover, .lnav-logout:focus-visible { background: var(--bg-hover); color: var(--brand); text-decoration: none; outline: none; }
.lnav-drop a.active { color: var(--brand); font-weight: 600; }
.lnav-div { height: 1px; margin: 5px 6px; background: var(--border); }
.lnav-who { display: flex; flex-direction: column; padding: 8px 12px 10px; font-weight: 600; font-size: 14px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.lnav-who span { font-weight: 400; font-size: 12.5px; color: var(--text-3); }
.lnav-pill { border: 1px solid var(--border-strong); margin-left: 4px; }
.lnav-icon { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 8px; background: none; color: var(--text-2); cursor: pointer; }
.lnav-icon:hover { background: var(--bg-hover); color: var(--text); }
.lnav-star { width: 38px; height: 38px; }
.lnav-toggle { display: none; margin-left: auto; width: 42px; height: 42px; border: 1px solid var(--border); border-radius: 9px; background: none; color: var(--text); cursor: pointer; }
.lnav :is(.lnav-top, .lnav-icon, .lnav-toggle):focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
@media (max-width: 1100px) {
    .lnav-toggle { display: inline-grid; place-items: center; }
    .lnav-inner { flex-wrap: wrap; padding: 8px 16px; }
    .lnav-collapse { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; padding: 6px 0 10px; max-height: calc(100vh - 70px); overflow-y: auto; }
    .lnav.is-open .lnav-collapse { display: flex; }
    .lnav-menu { flex-direction: column; align-items: stretch; }
    .lnav-right { margin-left: 0; flex-direction: row; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 6px; }
    .lnav-right .lnav-account { flex-basis: 100%; }
    .lnav-top { width: 100%; justify-content: space-between; }
    .lnav-drop { position: static; box-shadow: none; border: 0; border-left: 2px solid var(--border); border-radius: 0; margin: 0 0 6px 12px; max-height: none; min-width: 0; padding: 2px 4px; }
    .lnav-drop a { white-space: normal; }
}

/* ---------- Language picker (student portal, LMS) ---------- */
.lang-menu { position: relative; }
.lang-menu > summary { list-style: none; cursor: pointer; width: auto; gap: 4px; padding: 0 8px; }
.lang-menu > summary::-webkit-details-marker { display: none; }
.lang-code { font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.lang-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 160px; margin: 0; padding: 6px; list-style: none;
    background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); }
.lang-list a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: 14px; }
.lang-list a:hover, .lang-list a:focus-visible { background: var(--bg-hover); }
.lang-list a.active { font-weight: 600; color: var(--brand); }
