/* NACABS Portal — design system
   Paper + ink, with OMR answer-sheet bubbles as the signature element. */

:root {
  --brand: #1E3A8A;
  --mark: #C2334D;
  --paper: #F3F5F9;
  --surface: #FFFFFF;
  --surface-2: #F8F9FC;
  --ink: #152033;
  --ink-2: #4B5568;
  --ink-3: #7A8496;
  --line: #E1E5EC;
  --line-2: #CDD3DD;
  --good: #137A4B; --good-bg: #E5F4EC;
  --warn: #9A5B05; --warn-bg: #FDF1DC;
  --bad: #B42318;  --bad-bg: #FCE8E6;
  --info: #1B5EA6; --info-bg: #E6EFFA;
  --neutral-bg: #EDF0F5;
  --brand-soft: color-mix(in srgb, var(--brand) 9%, var(--surface));
  --brand-ink: color-mix(in srgb, var(--brand) 85%, #000);
  --mark-soft: color-mix(in srgb, var(--mark) 10%, var(--surface));
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(21, 32, 51, .06), 0 4px 14px rgba(21, 32, 51, .05);
  --shadow-lg: 0 12px 40px rgba(21, 32, 51, .18);
  --font: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Source Serif 4", Georgia, serif;
  --sidebar: 252px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0E1421; --surface: #161E2E; --surface-2: #1B2436; --ink: #E6EBF4; --ink-2: #B3BCCC; --ink-3: #8691A4;
    --line: #273248; --line-2: #34415A; --good-bg: #123323; --warn-bg: #3A2A0E; --bad-bg: #3D1714; --info-bg: #13294A; --neutral-bg: #222C40;
    --good: #5BD394; --warn: #F2B65A; --bad: #F48B82; --info: #7DB2F2;
    --brand: color-mix(in srgb, var(--brand) 55%, #9DB4FF);
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0E1421; --surface: #161E2E; --surface-2: #1B2436; --ink: #E6EBF4; --ink-2: #B3BCCC; --ink-3: #8691A4;
  --line: #273248; --line-2: #34415A; --good-bg: #123323; --warn-bg: #3A2A0E; --bad-bg: #3D1714; --info-bg: #13294A; --neutral-bg: #222C40;
  --good: #5BD394; --warn: #F2B65A; --bad: #F48B82; --info: #7DB2F2;
  --brand: color-mix(in srgb, var(--brand) 55%, #9DB4FF);
  --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.55; color: var(--ink); background: var(--paper); font-feature-settings: "tnum" 1; }
a { color: var(--brand); text-underline-offset: 2px; }
img, video { max-width: 100%; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5rem; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 650; }
h3 { font-size: 1.02rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.25rem 0; }
small, .muted { color: var(--ink-3); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2.5px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: .5rem 1rem; z-index: 999; border-radius: 6px; }
.skip:focus { left: 8px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88em; }

/* ───── Shell ───── */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar); flex: 0 0 var(--sidebar); background: var(--surface); border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; overflow-y: auto; z-index: 40; }
.brand { display: flex; align-items: center; gap: .7rem; padding: 1.1rem 1.1rem 1rem; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line); }
.brand span { display: flex; flex-direction: column; line-height: 1.2; }
.brand strong { font-size: 1.05rem; letter-spacing: .01em; }
.brand small { font-size: .76rem; color: var(--ink-3); }
.brand-logo { border-radius: 9px; object-fit: cover; }
.nav { padding: .6rem .6rem 1rem; flex: 1; }
.nav-group { margin-top: .7rem; }
.nav-label { display: block; font-size: .74rem; color: var(--ink-3); font-weight: 600; padding: .3rem .7rem; }
.nav a { display: flex; align-items: center; gap: .7rem; padding: .5rem .7rem; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: .93rem; }
.nav a i { font-size: 1.05rem; width: 1.2rem; text-align: center; color: var(--ink-3); }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav a.on i { color: var(--brand); }
.sidebar-foot { padding: .85rem 1.1rem; font-size: .78rem; color: var(--ink-3); border-top: 1px solid var(--line); }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: .75rem; height: 60px; padding: 0 1.5rem; background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar-title { font-weight: 600; display: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .4rem; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; border: 1px solid transparent; background: none; color: var(--ink-2); font-size: 1.15rem; cursor: pointer; text-decoration: none; }
.icon-btn:hover { background: var(--surface); border-color: var(--line); color: var(--ink); }
.icon-btn .dot { position: absolute; top: 3px; right: 2px; min-width: 17px; height: 17px; border-radius: 9px; background: var(--mark); color: #fff; font-size: .66rem; font-weight: 700; display: grid; place-items: center; padding: 0 4px; }
.menu-btn { display: none; }
.usermenu { position: relative; }
.usermenu summary { list-style: none; display: flex; align-items: center; gap: .55rem; padding: .25rem .5rem .25rem .3rem; border-radius: 10px; cursor: pointer; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover { background: var(--surface); }
.usermenu .who { display: flex; flex-direction: column; line-height: 1.15; }
.usermenu .who b { font-size: .87rem; font-weight: 600; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usermenu .who small { font-size: .74rem; }
.usermenu .menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 190px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); padding: .35rem; z-index: 50; }
.usermenu .menu a, .usermenu .menu button { display: flex; width: 100%; gap: .6rem; align-items: center; padding: .55rem .7rem; border-radius: 7px; color: var(--ink); text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.usermenu .menu a:hover, .usermenu .menu button:hover { background: var(--surface-2); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: inline-grid; place-items: center; font-weight: 700; font-size: .8rem; overflow: hidden; flex: 0 0 auto; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 72px; height: 72px; font-size: 1.4rem; }
.avatar.sm { width: 28px; height: 28px; font-size: .7rem; }
.content { padding: 1.5rem 1.75rem 3rem; max-width: 1400px; width: 100%; }
.foot { padding: 1rem 1.75rem 2rem; font-size: .8rem; color: var(--ink-3); }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; font-size: .84rem; color: var(--ink-3); margin-bottom: .6rem; }
.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs i { font-size: .7rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; }
.page-head .sub { color: var(--ink-2); margin: .2rem 0 0; max-width: 70ch; }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.scrim { display: none; }

/* ───── Cards & layout ───── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.card-h { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.card-h h2, .card-h h3 { margin: 0; font-size: 1rem; }
.card-h .sub { margin: .1rem 0 0; font-size: .85rem; color: var(--ink-3); }
.card-b { padding: 1.25rem; }
.card-b.tight { padding: 0; }
.card-f { padding: .85rem 1.25rem; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; }
.grid { display: grid; gap: 1.25rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-side { grid-template-columns: minmax(0, 1fr) 340px; }
.g-side-l { grid-template-columns: 300px minmax(0, 1fr); }
.row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: .75rem; }
.mt { margin-top: 1rem; } .mt2 { margin-top: 1.5rem; } .mb0 { margin-bottom: 0; } .mb { margin-bottom: 1rem; }
.right { text-align: right; } .center { text-align: center; } .nowrap { white-space: nowrap; }
.grow { flex: 1; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { display: flex; gap: .9rem; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.stat > i { font-size: 1.25rem; width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: 0 0 auto; }
.stat.good > i { background: var(--good-bg); color: var(--good); }
.stat.warn > i { background: var(--warn-bg); color: var(--warn); }
.stat.bad > i { background: var(--bad-bg); color: var(--bad); }
.stat > div { display: flex; flex-direction: column; min-width: 0; }
.stat-v { font-size: 1.55rem; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.stat-l { font-size: .84rem; color: var(--ink-2); }
.stat-h { font-size: .78rem; color: var(--ink-3); }

/* ───── Buttons ───── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 40px; padding: .5rem 1rem; border-radius: 9px; border: 1px solid var(--brand); background: var(--brand); color: #fff; font: inherit; font-weight: 600; font-size: .92rem; text-decoration: none; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s; }
.btn:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
.btn:disabled, .btn.disabled { opacity: .5; pointer-events: none; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn-soft { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.btn-soft:hover { background: color-mix(in srgb, var(--brand) 16%, var(--surface)); border-color: transparent; }
.btn-danger { background: var(--bad); border-color: var(--bad); }
.btn-danger:hover { background: color-mix(in srgb, var(--bad) 85%, #000); }
.btn-good { background: var(--good); border-color: var(--good); }
.btn-good:hover { background: color-mix(in srgb, var(--good) 85%, #000); }
.btn-link { background: none; border: 0; color: var(--brand); padding: 0; min-height: 0; font-weight: 600; }
.btn-link:hover { background: none; text-decoration: underline; }
.btn-sm { min-height: 32px; padding: .3rem .7rem; font-size: .84rem; border-radius: 8px; }
.btn-lg { min-height: 50px; padding: .7rem 1.4rem; font-size: 1rem; border-radius: 11px; }
.btn-block { width: 100%; }
.btn-icon { width: 34px; min-height: 34px; padding: 0; }
.btn-group { display: inline-flex; gap: .35rem; flex-wrap: wrap; }

/* ───── Forms ───── */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.25rem; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field > label, .label { font-size: .87rem; font-weight: 600; color: var(--ink); }
.field .hint { font-size: .8rem; color: var(--ink-3); }
.input, input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=time], input[type=search], input[type=tel], input[type=url], select, textarea {
  width: 100%; min-height: 42px; padding: .55rem .75rem; border: 1px solid var(--line-2); border-radius: 9px; background: var(--surface); color: var(--ink); font: inherit; font-size: .94rem;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
input[type=color] { width: 56px; height: 42px; padding: 3px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--surface); }
input[type=file] { font: inherit; font-size: .9rem; max-width: 100%; }
.check { display: flex; gap: .6rem; align-items: flex-start; font-size: .93rem; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: .15rem; accent-color: var(--brand); flex: 0 0 auto; }
.switch { position: relative; display: inline-flex; align-items: center; gap: .7rem; cursor: pointer; font-size: .93rem; }
.switch input { appearance: none; width: 40px; height: 23px; border-radius: 20px; background: var(--line-2); position: relative; cursor: pointer; transition: background .15s; margin: 0; flex: 0 0 auto; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(17px); }
.input-group { display: flex; }
.input-group > :first-child { border-radius: 9px 0 0 9px; }
.input-group > :last-child { border-radius: 0 9px 9px 0; margin-left: -1px; }
.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.filters select, .filters input { width: auto; min-width: 150px; min-height: 38px; }
.filters .search { min-width: 220px; flex: 1; max-width: 360px; }
.req::after { content: " *"; color: var(--bad); }

/* ───── Tables ───── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-weight: 600; font-size: .8rem; color: var(--ink-3); padding: .7rem 1rem; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.table td { padding: .7rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.table .actions { text-align: right; white-space: nowrap; }
.table td .sub { display: block; font-size: .8rem; color: var(--ink-3); }
.table.compact td, .table.compact th { padding: .45rem .7rem; }
.table input[type=number] { width: 88px; min-height: 34px; padding: .3rem .5rem; }
.person { display: flex; align-items: center; gap: .65rem; }
.person b { font-weight: 600; display: block; }

/* ───── Badges, alerts ───── */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .16rem .55rem; border-radius: 20px; font-size: .76rem; font-weight: 600; background: var(--neutral-bg); color: var(--ink-2); white-space: nowrap; }
.b-good { background: var(--good-bg); color: var(--good); }
.b-warn { background: var(--warn-bg); color: var(--warn); }
.b-bad { background: var(--bad-bg); color: var(--bad); }
.b-info { background: var(--info-bg); color: var(--info); }
.b-brand { background: var(--brand-soft); color: var(--brand); }
.alert { display: flex; gap: .75rem; align-items: flex-start; padding: .85rem 1rem; border-radius: 11px; margin-bottom: 1rem; border: 1px solid transparent; font-size: .93rem; }
.alert > i { font-size: 1.1rem; margin-top: .05rem; }
.alert > div { flex: 1; }
.alert-x { background: none; border: 0; font-size: 1.3rem; line-height: 1; cursor: pointer; color: inherit; opacity: .6; }
.alert-success { background: var(--good-bg); color: var(--good); border-color: color-mix(in srgb, var(--good) 25%, transparent); }
.alert-error { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.alert-warning { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.alert-info { background: var(--info-bg); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.callout { padding: 1rem 1.1rem; border-radius: 11px; background: var(--surface-2); border: 1px dashed var(--line-2); font-size: .92rem; color: var(--ink-2); }

/* Tabs */
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--line); margin-bottom: 1.25rem; overflow-x: auto; scrollbar-width: none; }
.tabs a, .tabs button { padding: .7rem .95rem; color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: .9rem; border: 0; background: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; cursor: pointer; display: flex; gap: .45rem; align-items: center; font-family: inherit; }
.tabs a:hover, .tabs button:hover { color: var(--ink); }
.tabs a.on, .tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }
.tabs .count { font-size: .74rem; background: var(--neutral-bg); border-radius: 10px; padding: 0 .45rem; color: var(--ink-2); }

/* Empty */
.empty { text-align: center; padding: 3rem 1.5rem; color: var(--ink-2); }
.empty > i { font-size: 2.2rem; color: var(--ink-3); display: block; margin-bottom: .6rem; }
.empty h2, .empty h3 { color: var(--ink); }
.empty p { max-width: 46ch; margin: 0 auto 1rem; }

/* Progress */
.bar { height: 7px; border-radius: 6px; background: var(--neutral-bg); overflow: hidden; min-width: 60px; }
.bar span { display: block; height: 100%; background: var(--brand); border-radius: 6px; }
.bar.good span { background: var(--good); } .bar.warn span { background: var(--warn); } .bar.bad span { background: var(--bad); }

/* Pager */
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; padding: .9rem 1.25rem; }
.pg { min-width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); text-decoration: none; color: var(--ink-2); font-size: .87rem; padding: 0 .55rem; background: var(--surface); }
.pg.cur { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 700; }
.pg.gap { border: 0; background: none; }
.pg-info { margin-left: auto; font-size: .84rem; color: var(--ink-3); }

/* Dialog */
dialog.modal { border: 0; border-radius: var(--radius-lg); padding: 0; width: min(560px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); }
dialog.modal.wide { width: min(860px, calc(100vw - 2rem)); }
dialog.modal::backdrop { background: rgba(14, 20, 33, .55); }
dialog.modal .card-h { position: sticky; top: 0; background: var(--surface); z-index: 1; }
dialog.modal form { margin: 0; }

/* Toasts */
.toasts { position: fixed; bottom: 1rem; right: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 1000; max-width: min(380px, calc(100vw - 2rem)); }
.toast { background: var(--ink); color: var(--surface); padding: .8rem 1rem; border-radius: 11px; box-shadow: var(--shadow-lg); font-size: .92rem; display: flex; gap: .6rem; align-items: flex-start; animation: toastIn .2s ease-out; }
.toast.bad { background: var(--bad); color: #fff; } .toast.good { background: var(--good); color: #fff; } .toast.warn { background: #8A4E00; color: #fff; }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; gap: .85rem; align-items: center; padding: .85rem 1.25rem; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.list .meta { font-size: .82rem; color: var(--ink-3); }
.list .li-main { flex: 1; min-width: 0; }
.list .li-main b { display: block; font-weight: 600; }
.date-chip { flex: 0 0 auto; width: 48px; text-align: center; border-radius: 9px; border: 1px solid var(--line); overflow: hidden; line-height: 1.1; }
.date-chip span { display: block; background: var(--brand); color: #fff; font-size: .68rem; font-weight: 700; padding: .15rem 0; }
.date-chip b { display: block; font-size: 1.1rem; padding: .2rem 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.25rem; font-size: .92rem; margin: 0; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; font-weight: 500; }

/* ───── OMR bubbles (signature element) ───── */
.bubble { width: 30px; height: 30px; border-radius: 50%; border: 1.8px solid var(--line-2); display: inline-grid; place-items: center; font-weight: 700; font-size: .82rem; color: var(--ink-2); background: var(--surface); flex: 0 0 auto; transition: background .12s, border-color .12s, color .12s; }
.bubble.filled { background: var(--mark); border-color: var(--mark); color: #fff; }
.omr-legend { display: flex; gap: .3rem; }

/* ───── Auth pages ───── */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-side { background: var(--brand); color: #fff; padding: 2.5rem 3rem; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.auth-side .brand { border: 0; padding: 0; color: #fff; }
.auth-side .brand small { color: rgba(255,255,255,.75); }
.auth-side .brand-mark rect { fill: rgba(255,255,255,.14); }
.auth-side h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.9rem, 3.2vw, 2.7rem); line-height: 1.15; margin: auto 0 1rem; max-width: 16ch; letter-spacing: -.015em; }
.auth-side p { color: rgba(255,255,255,.82); max-width: 44ch; font-size: 1.02rem; }
.sheet { position: absolute; right: -40px; top: 90px; display: grid; grid-template-columns: auto repeat(4, 26px); gap: 12px 14px; align-items: center; opacity: .22; transform: rotate(-8deg); pointer-events: none; }
.sheet span { font-size: .8rem; font-weight: 700; text-align: right; }
.sheet i { width: 26px; height: 26px; border: 1.8px solid #fff; border-radius: 50%; display: block; }
.sheet i.f { background: #fff; }
.auth-feats { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: .7rem; }
.auth-feats li { display: flex; gap: .7rem; align-items: center; color: rgba(255,255,255,.9); font-size: .95rem; }
.auth-feats i { font-size: 1.1rem; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; }
.auth-box { width: 100%; max-width: 420px; }
.auth-box h2 { font-size: 1.5rem; }
.auth-box .lead { color: var(--ink-2); margin-bottom: 1.5rem; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--neutral-bg); border-radius: 11px; padding: 4px; margin-bottom: 1.5rem; }
.seg a { text-align: center; padding: .55rem; border-radius: 8px; text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: .92rem; }
.seg a.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.bare-main { min-height: 100vh; }
.pw-wrap { position: relative; }
.pw-wrap button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }

/* ───── Camera widgets ───── */
.cam { position: relative; background: #0b1020; border-radius: 14px; overflow: hidden; aspect-ratio: 4 / 3; width: 100%; max-width: 520px; margin: 0 auto; }
.cam video, .cam canvas.overlay { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.cam .ring { position: absolute; left: 50%; top: 47%; width: 58%; aspect-ratio: 3 / 4; transform: translate(-50%, -50%); border: 3px dashed rgba(255,255,255,.55); border-radius: 50% / 46%; transition: border-color .2s; pointer-events: none; }
.cam .ring.ok { border-style: solid; border-color: #3DDC97; }
.cam .ring.bad { border-color: #FF8A80; }
.cam .cam-msg { position: absolute; left: 0; right: 0; bottom: 0; padding: .9rem 1rem; background: linear-gradient(transparent, rgba(0,0,0,.75)); color: #fff; text-align: center; font-weight: 600; font-size: .98rem; }
.cam .cam-top { position: absolute; top: .7rem; left: .7rem; right: .7rem; display: flex; justify-content: space-between; gap: .5rem; }
.pill { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .65rem; border-radius: 20px; background: rgba(0,0,0,.55); color: #fff; font-size: .78rem; font-weight: 600; }
.pill .rec { width: 8px; height: 8px; border-radius: 50%; background: #FF4D4D; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.steps-dots { display: flex; justify-content: center; gap: .4rem; margin-top: .8rem; }
.steps-dots i { width: 12px; height: 12px; border-radius: 50%; border: 1.8px solid var(--line-2); }
.steps-dots i.f { background: var(--mark); border-color: var(--mark); }
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: .55rem; }
.checklist li { display: flex; gap: .7rem; align-items: center; padding: .7rem .9rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: .93rem; }
.checklist li i { font-size: 1.15rem; color: var(--ink-3); }
.checklist li.ok i { color: var(--good); } .checklist li.bad i { color: var(--bad); } .checklist li.wait i { color: var(--warn); }
.checklist li small { margin-left: auto; text-align: right; }

/* ───── Exam room (candidate) ───── */
body.exam-room { background: var(--paper); }
.xr-top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 1rem; padding: .65rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.xr-top .t { min-width: 0; flex: 1; }
.xr-top .t b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xr-top .t small { display: block; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.25rem; padding: .35rem .85rem; border-radius: 10px; background: var(--neutral-bg); display: flex; gap: .45rem; align-items: center; }
.timer.low { background: var(--bad-bg); color: var(--bad); animation: pulse 1.6s infinite; }
.xr-body { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.25rem; max-width: 1180px; margin: 0 auto; padding: 1.25rem; }
.q-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.6rem 1.75rem; box-shadow: var(--shadow); }
.q-num { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; color: var(--ink-3); font-size: .88rem; font-weight: 600; }
.q-text { font-family: var(--serif); font-size: 1.22rem; line-height: 1.6; margin-bottom: 1.4rem; color: var(--ink); max-width: 70ch; white-space: pre-wrap; }
.q-img { max-height: 320px; border-radius: 10px; border: 1px solid var(--line); margin: 0 0 1.25rem; display: block; }
.opts { display: grid; gap: .6rem; }
.opt { display: flex; gap: .9rem; align-items: center; padding: .8rem 1rem; border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; background: var(--surface); transition: border-color .12s, background .12s; font-size: 1rem; }
.opt:hover { border-color: var(--line-2); background: var(--surface-2); }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt .bubble { width: 34px; height: 34px; }
.opt:has(input:checked) { border-color: var(--mark); background: var(--mark-soft); }
.opt:has(input:checked) .bubble { background: var(--mark); border-color: var(--mark); color: #fff; }
.opt:has(input:focus-visible) { outline: 2.5px solid var(--brand); outline-offset: 2px; }
.opt img { max-height: 120px; border-radius: 8px; }
.q-nav { display: flex; justify-content: space-between; gap: .75rem; margin-top: 1.5rem; flex-wrap: wrap; }
.xr-side { display: flex; flex-direction: column; gap: 1rem; position: sticky; top: 76px; align-self: start; }
.sheet-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1rem; box-shadow: var(--shadow); }
.sheet-card h3 { font-size: .88rem; color: var(--ink-2); display: flex; justify-content: space-between; }
.omr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: .45rem; max-height: 46vh; overflow-y: auto; padding: 2px; }
.omr-grid button { position: relative; width: 36px; height: 36px; border-radius: 50%; border: 1.8px solid var(--line-2); background: var(--surface); color: var(--ink-2); font-weight: 700; font-size: .8rem; cursor: pointer; font-family: inherit; }
.omr-grid button.ans { background: var(--mark); border-color: var(--mark); color: #fff; }
.omr-grid button.cur { box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 40%, transparent); }
.omr-grid button.flag::after { content: ""; position: absolute; top: -3px; right: -3px; width: 10px; height: 10px; border-radius: 50%; background: var(--warn); border: 2px solid var(--surface); }
.legend { display: flex; flex-wrap: wrap; gap: .8rem; font-size: .78rem; color: var(--ink-3); margin-top: .8rem; }
.legend span { display: inline-flex; align-items: center; gap: .3rem; }
.legend i { width: 12px; height: 12px; border-radius: 50%; border: 1.6px solid var(--line-2); display: inline-block; }
.legend i.a { background: var(--mark); border-color: var(--mark); }
.legend i.fl { background: var(--warn); border-color: var(--warn); }
.mini-cam { position: relative; border-radius: 12px; overflow: hidden; background: #0b1020; aspect-ratio: 4/3; }
.mini-cam video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.mini-cam .pill { position: absolute; left: .5rem; top: .5rem; }
.mini-cam .face-state { position: absolute; left: .5rem; bottom: .5rem; top: auto; }
.violations { font-size: .85rem; }
.warn-banner { position: fixed; inset: 0; z-index: 200; background: rgba(14, 20, 33, .78); display: none; align-items: center; justify-content: center; padding: 1rem; }
.warn-banner.show { display: flex; }
.warn-box { background: var(--surface); border-radius: 16px; max-width: 460px; width: 100%; padding: 1.75rem; text-align: center; box-shadow: var(--shadow-lg); }
.warn-box > i { font-size: 2.4rem; color: var(--bad); }
.save-state { font-size: .8rem; color: var(--ink-3); display: flex; align-items: center; gap: .35rem; }
.save-state.err { color: var(--bad); }
textarea.essay { min-height: 260px; font-family: var(--serif); font-size: 1.05rem; }

/* ───── Monitor / evidence ───── */
.cand-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.cand { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.cand .thumb { aspect-ratio: 4/3; background: #0b1020; position: relative; }
.cand .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cand .thumb .pill { position: absolute; left: .5rem; top: .5rem; }
.cand .thumb .vio { position: absolute; right: .5rem; top: .5rem; }
.cand .cb { padding: .7rem .85rem; flex: 1; }
.cand .cb b { display: block; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cand .cf { display: flex; gap: .35rem; padding: .55rem .85rem; border-top: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.cand.alert-ring { border-color: var(--bad); box-shadow: 0 0 0 2px color-mix(in srgb, var(--bad) 35%, transparent); }
.cand.stale .thumb::after { content: "No signal"; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.6); color: #fff; font-weight: 700; }
.player { background: #000; border-radius: 12px; overflow: hidden; }
.player video { width: 100%; display: block; max-height: 62vh; background: #000; }
.timeline { position: relative; height: 34px; margin: .75rem 0 .25rem; background: var(--neutral-bg); border-radius: 8px; cursor: pointer; }
.timeline .tl-prog { position: absolute; left: 0; top: 0; bottom: 0; background: color-mix(in srgb, var(--brand) 22%, transparent); border-radius: 8px 0 0 8px; pointer-events: none; }
.timeline .mk { position: absolute; top: 4px; bottom: 4px; width: 4px; margin-left: -2px; border-radius: 3px; background: var(--warn); border: 0; padding: 0; cursor: pointer; }
.timeline .mk.critical { background: var(--bad); } .timeline .mk.info { background: var(--info); }
.timeline .mk:hover, .timeline .mk:focus-visible { transform: scaleX(1.8); }
.ev-list { max-height: 420px; overflow-y: auto; }
.ev-list li { cursor: pointer; }
.ev-list li.on { background: var(--brand-soft); }
.ev-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--warn); flex: 0 0 auto; }
.ev-dot.critical { background: var(--bad); } .ev-dot.info { background: var(--info); }
.snap-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .5rem; }
.snap-strip figure { margin: 0; font-size: .74rem; color: var(--ink-3); }
.snap-strip img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 8px; display: block; border: 1px solid var(--line); cursor: zoom-in; }

/* Kiosk */
.kiosk { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr); gap: 1.25rem; }
.kiosk .cam { max-width: none; }
.seen-list li { animation: toastIn .25s ease-out; }
.big-msg { text-align: center; padding: 1rem; border-radius: 12px; font-weight: 700; font-size: 1.15rem; }
.big-msg.ok { background: var(--good-bg); color: var(--good); }
.big-msg.bad { background: var(--bad-bg); color: var(--bad); }

/* Charts */
.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 200px; }

/* Matrix */
.matrix td.c { text-align: center; padding: .4rem; }
.mx { display: inline-block; width: 22px; height: 22px; border-radius: 50%; border: 1.6px solid var(--line-2); vertical-align: middle; }
.mx.p { background: var(--good); border-color: var(--good); }
.mx.l { background: var(--warn); border-color: var(--warn); }
.mx.e { background: var(--info-bg); border-color: var(--info); }

/* Print */
@media print {
  .sidebar, .topbar, .page-actions, .tabbar, .foot, .no-print, .filters, .pager, .toasts { display: none !important; }
  body { background: #fff; font-size: 12px; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; }
  .print-head { display: flex !important; }
  .table th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.print-head { display: none; align-items: center; gap: 1rem; margin-bottom: 1rem; border-bottom: 2px solid #000; padding-bottom: .6rem; }
.print-head h2 { margin: 0; }

/* ───── Mobile ───── */
.tabbar { display: none; }
@media (max-width: 1080px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-side, .g-side-l { grid-template-columns: minmax(0, 1fr); }
  .xr-body { grid-template-columns: minmax(0, 1fr); }
  .xr-side { position: static; order: -1; display: grid; grid-template-columns: 1fr 1fr; }
  .kiosk { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: none; visibility: hidden; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); visibility: visible; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(14,20,33,.45); z-index: 35; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 0 .75rem; }
  .topbar-title { display: block; }
  .usermenu .who { display: none; }
  .content { padding: 1.1rem 1rem 6rem; }
  .page-head h1 { font-size: 1.35rem; }
  .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-side { padding: 1.5rem 1.25rem 1.75rem; }
  .auth-side h1 { margin-top: 1.5rem; font-size: 1.7rem; }
  .auth-side p, .auth-feats { display: none; }
  .sheet { display: none; }
  .portal-student .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); padding: .3rem .3rem calc(.3rem + env(safe-area-inset-bottom)); }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .35rem 0; font-size: .7rem; color: var(--ink-3); text-decoration: none; background: none; border: 0; font-family: inherit; font-weight: 600; }
  .tabbar i { font-size: 1.25rem; }
  .tabbar a.on { color: var(--brand); }
  .q-card { padding: 1.15rem; }
  .q-text { font-size: 1.1rem; }
  .xr-top { padding: .55rem .75rem; gap: .5rem; }
  .xr-top .t b { display: none; }
  .xr-top .t small { white-space: nowrap; }
  .save-state .ss-t { display: none; }
  .timer { font-size: 1.05rem; padding: .3rem .6rem; }
  .xr-body { padding: .75rem; }
  .table th, .table td { padding: .6rem .7rem; }
  .filters select, .filters input { min-width: 0; flex: 1 1 140px; }
}
@media (max-width: 560px) {
  .g4 { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .stat { padding: .8rem; gap: .6rem; }
  .stat > i { width: 34px; height: 34px; font-size: 1rem; }
  .stat-v { font-size: 1.25rem; }
  .xr-side { grid-template-columns: minmax(0, 1fr); }
  .card-h, .card-b { padding: 1rem; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
