/* ==========================================================================
   Lectern — design system
   Calm, native-feeling, content-first. One accent, warm neutral surfaces,
   8px rhythm, restrained motion (160–280ms) that respects reduced motion.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f2f1ed;
  --surface-3: #e9e7e1;
  --hairline: rgba(24, 22, 16, .08);
  --border: rgba(24, 22, 16, .13);
  --border-strong: rgba(24, 22, 16, .22);
  --text: #1d1d1f;
  --text-2: #4f4f55;
  --text-3: #6b6b71;
  --overlay: rgba(14, 14, 16, .32);
  --glass: rgba(246, 245, 242, .78);

  --accent: #2563c9;
  --accent-hover: #1d55b0;
  --accent-press: #194a99;
  --accent-ink: #1d4f9f;
  --accent-soft: rgba(37, 99, 201, .1);
  --accent-softer: rgba(37, 99, 201, .06);
  --on-accent: #ffffff;
  --focus: rgba(37, 99, 201, .45);

  --good: #13753a;      --good-bg: rgba(19, 140, 64, .11);
  --warn: #8a5400;      --warn-bg: rgba(232, 160, 0, .16);
  --serious: #a8441c;   --serious-bg: rgba(236, 131, 90, .17);
  --critical: #b8302d;  --critical-bg: rgba(208, 59, 59, .11);
  --info: #1d4f9f;      --info-bg: rgba(37, 99, 201, .1);
  --violet: #5440c0;    --violet-bg: rgba(98, 80, 214, .11);
  --neutral: #55555b;   --neutral-bg: rgba(24, 22, 16, .07);

  /* chart roles (dataviz reference instance) */
  --series-1: #2a78d6;
  --st-good: #0ca30c; --st-warning: #fab219; --st-serious: #ec835a; --st-critical: #d03b3b;
  --st-neutral: #b9b7b0; --st-muted: #dcdad3;

  --shadow-1: 0 1px 2px rgba(20, 18, 12, .05), 0 0 0 1px rgba(20, 18, 12, .04);
  --shadow-2: 0 1px 2px rgba(20, 18, 12, .04), 0 6px 20px rgba(20, 18, 12, .06), 0 0 0 1px rgba(20, 18, 12, .035);
  --shadow-3: 0 18px 48px rgba(10, 10, 14, .2), 0 2px 10px rgba(10, 10, 14, .08), 0 0 0 1px rgba(10, 10, 14, .05);

  --r-xs: 6px; --r-s: 8px; --r: 12px; --r-l: 16px; --r-xl: 22px; --r-pill: 999px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

  --ease: cubic-bezier(.22, .61, .36, 1);
  --ease-in: cubic-bezier(.4, 0, 1, 1);
  --ease-spring: cubic-bezier(.34, 1.4, .64, 1);
  --ease-sheet: cubic-bezier(.32, .72, 0, 1);
  --d1: 160ms; --d2: 220ms; --d3: 280ms;

  --sidebar: 248px;
  --topbar: 56px;
  --tabbar: 64px;
  --content-max: 1180px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --_dark: 1; }
}
:root[data-theme="dark"] { --_dark: 1; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e0e10; --surface: #1b1b1e; --surface-2: #232327; --surface-3: #2d2d32;
    --hairline: rgba(255, 255, 255, .07); --border: rgba(255, 255, 255, .12); --border-strong: rgba(255, 255, 255, .2);
    --text: #f4f4f6; --text-2: #c2c2c8; --text-3: #9b9ba3; --overlay: rgba(0, 0, 0, .55); --glass: rgba(14, 14, 16, .74);
    --accent: #2f6ee0; --accent-hover: #3d7bec; --accent-press: #2a63c9; --accent-ink: #8ab4ff;
    --accent-soft: rgba(90, 145, 255, .16); --accent-softer: rgba(90, 145, 255, .09); --focus: rgba(110, 160, 255, .55);
    --good: #5fd28a; --good-bg: rgba(60, 200, 110, .14);
    --warn: #f5c04a; --warn-bg: rgba(250, 178, 25, .15);
    --serious: #f49b74; --serious-bg: rgba(236, 131, 90, .16);
    --critical: #ff8580; --critical-bg: rgba(230, 80, 80, .16);
    --info: #8ab4ff; --info-bg: rgba(90, 145, 255, .15);
    --violet: #b3a8ff; --violet-bg: rgba(144, 133, 233, .17);
    --neutral: #b9b9c0; --neutral-bg: rgba(255, 255, 255, .08);
    --series-1: #3987e5; --st-neutral: #6b6b72; --st-muted: #3a3a40;
    --shadow-1: 0 0 0 1px rgba(255, 255, 255, .06);
    --shadow-2: 0 0 0 1px rgba(255, 255, 255, .07), 0 8px 24px rgba(0, 0, 0, .35);
    --shadow-3: 0 0 0 1px rgba(255, 255, 255, .08), 0 24px 64px rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0e10; --surface: #1b1b1e; --surface-2: #232327; --surface-3: #2d2d32;
  --hairline: rgba(255, 255, 255, .07); --border: rgba(255, 255, 255, .12); --border-strong: rgba(255, 255, 255, .2);
  --text: #f4f4f6; --text-2: #c2c2c8; --text-3: #9b9ba3; --overlay: rgba(0, 0, 0, .55); --glass: rgba(14, 14, 16, .74);
  --accent: #2f6ee0; --accent-hover: #3d7bec; --accent-press: #2a63c9; --accent-ink: #8ab4ff;
  --accent-soft: rgba(90, 145, 255, .16); --accent-softer: rgba(90, 145, 255, .09); --focus: rgba(110, 160, 255, .55);
  --good: #5fd28a; --good-bg: rgba(60, 200, 110, .14);
  --warn: #f5c04a; --warn-bg: rgba(250, 178, 25, .15);
  --serious: #f49b74; --serious-bg: rgba(236, 131, 90, .16);
  --critical: #ff8580; --critical-bg: rgba(230, 80, 80, .16);
  --info: #8ab4ff; --info-bg: rgba(90, 145, 255, .15);
  --violet: #b3a8ff; --violet-bg: rgba(144, 133, 233, .17);
  --neutral: #b9b9c0; --neutral-bg: rgba(255, 255, 255, .08);
  --series-1: #3987e5; --st-neutral: #6b6b72; --st-muted: #3a3a40;
  --shadow-1: 0 0 0 1px rgba(255, 255, 255, .06);
  --shadow-2: 0 0 0 1px rgba(255, 255, 255, .07), 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-3: 0 0 0 1px rgba(255, 255, 255, .08), 0 24px 64px rgba(0, 0, 0, .6);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  font: 400 15px/1.47 var(--font); letter-spacing: -0.006em;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}
img, svg, video, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: 32px; line-height: 1.12; font-weight: 700; letter-spacing: -0.024em; }
h2 { font-size: 21px; line-height: 1.2; font-weight: 650; letter-spacing: -0.016em; }
h3 { font-size: 17px; line-height: 1.3; font-weight: 600; letter-spacing: -0.01em; }
h4 { font-size: 13px; line-height: 1.3; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); }
small, .small { font-size: 13px; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.mono { font-family: var(--mono); font-size: .92em; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
::selection { background: var(--accent-soft); }

:focus { outline: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 1000; padding: 10px 14px; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow-2); transition: top var(--d1) var(--ease); }
.skip-link:focus { top: 12px; }

/* ---------- Boot ---------- */
.boot { min-height: 100dvh; display: grid; place-items: center; }
.boot-mark { width: 56px; height: 56px; border-radius: 15px; animation: bootIn 420ms var(--ease) both; }
@keyframes bootIn { from { opacity: 0; transform: scale(.92); } }

/* ---------- App shell ---------- */
.app { min-height: 100dvh; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: var(--s2);
  padding: 18px 14px 14px; border-right: 1px solid var(--hairline); background: var(--bg);
  overflow-y: auto; overscroll-behavior: contain;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; color: var(--text); font-weight: 650; font-size: 17px; letter-spacing: -0.015em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; flex: none; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.brand small { display: block; font-size: 11.5px; font-weight: 500; color: var(--text-3); letter-spacing: 0; margin-top: 1px; }
.nav { display: flex; flex-direction: column; gap: 2px; position: relative; }
.nav-label { padding: 14px 10px 6px; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
.nav-item {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 11px; min-height: 40px; padding: 8px 10px;
  border-radius: 10px; color: var(--text-2); font-weight: 500; transition: color var(--d1) var(--ease), background var(--d1) var(--ease);
}
.nav-item:hover { text-decoration: none; color: var(--text); background: var(--neutral-bg); }
.nav-item[aria-current="page"] { color: var(--text); font-weight: 600; }
.nav-item svg { width: 20px; height: 20px; flex: none; }
.nav-item[aria-current="page"] svg { color: var(--accent); }
.nav-item .count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: var(--on-accent); font-size: 11.5px; font-weight: 650; display: grid; place-items: center; }
.nav-indicator.instant { transition: none; }
.nav-indicator {
  position: absolute; left: 0; right: 0; top: 0; height: 40px; border-radius: 10px; background: var(--surface);
  box-shadow: var(--shadow-1); transition: transform var(--d3) var(--ease), height var(--d3) var(--ease), opacity var(--d1);
  pointer-events: none; z-index: 0;
}
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding-top: 12px; }
.me { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; color: var(--text); }
.me:hover { background: var(--neutral-bg); text-decoration: none; }
.me .ellipsis small { display: block; color: var(--text-3); font-size: 12px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-size: 12.5px; font-weight: 650; color: #fff; background: linear-gradient(135deg, #5b8def, #2563c9); letter-spacing: 0;
}
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar); display: flex; align-items: center; gap: var(--s2);
  padding: 0 var(--s6); background: var(--glass); border-bottom: 1px solid transparent;
  -webkit-backdrop-filter: saturate(180%) blur(14px); backdrop-filter: saturate(180%) blur(14px);
  transition: border-color var(--d2) var(--ease);
}
.topbar.scrolled { border-bottom-color: var(--hairline); }
.topbar-title { font-weight: 600; font-size: 15.5px; opacity: 0; transform: translateY(4px); transition: opacity var(--d2) var(--ease), transform var(--d2) var(--ease); }
.topbar.scrolled .topbar-title { opacity: 1; transform: none; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.topbar .brand-mobile { display: none; }
.content { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: var(--s2) var(--s6) var(--s8); flex: 1; }
.view { animation: viewIn var(--d3) var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } }

.page-head { display: flex; align-items: flex-end; gap: var(--s4); flex-wrap: wrap; margin: var(--s2) 0 var(--s5); }
.page-head .eyebrow { font-size: 13px; font-weight: 600; color: var(--text-3); margin-bottom: 4px; }
.page-head .actions { margin-left: auto; display: flex; gap: var(--s2); flex-wrap: wrap; }

.tabbar { display: none; }

/* ---------- Icon buttons ---------- */
.icon-btn {
  position: relative; width: 40px; height: 40px; border: 0; border-radius: 12px; background: transparent; color: var(--text-2);
  display: grid; place-items: center; transition: background var(--d1) var(--ease), color var(--d1), transform var(--d1) var(--ease);
}
.icon-btn:hover { background: var(--neutral-bg); color: var(--text); }
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 21px; height: 21px; }
.icon-btn .dot {
  position: absolute; top: 6px; right: 6px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--critical); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center;
  box-shadow: 0 0 0 2px var(--bg); animation: pop 360ms var(--ease-spring) both;
}
@keyframes pop { from { transform: scale(0); } }
.icon-btn.spinning svg { animation: spin 900ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Buttons ---------- */
.btn {
  --h: 40px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--h); min-width: 44px;
  padding: 0 16px; border: 1px solid transparent; border-radius: 11px; font-weight: 600; font-size: 14.5px; line-height: 1;
  white-space: nowrap; user-select: none; text-decoration: none !important; position: relative; overflow: hidden;
  transition: background var(--d1) var(--ease), color var(--d1), border-color var(--d1), box-shadow var(--d1), transform 120ms var(--ease), opacity var(--d1);
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 1px 2px rgba(20, 50, 120, .18); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:active:not(:disabled) { background: var(--accent-press); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: 0 1px 1px rgba(0, 0, 0, .03); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-tinted { background: var(--accent-soft); color: var(--accent-ink); }
.btn-tinted:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.btn-plain { background: transparent; color: var(--accent-ink); padding: 0 10px; }
.btn-plain:hover:not(:disabled) { background: var(--accent-softer); }
.btn-danger { background: var(--critical-bg); color: var(--critical); }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--critical) 18%, transparent); }
.btn-danger-solid { background: #c4302c; color: #fff; }
.btn-good { background: #17803f; color: #fff; }
.btn-good:hover:not(:disabled) { background: #136d35; }
.btn-sm { --h: 32px; padding: 0 12px; font-size: 13.5px; border-radius: 9px; }
.btn-lg { --h: 52px; padding: 0 24px; font-size: 16.5px; border-radius: 14px; }
.btn-block { width: 100%; }
.btn .spinner { width: 18px; height: 18px; }
.btn.is-loading > :not(.btn-state) { opacity: 0; }
.btn-state { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.btn.is-done { background: #17803f; color: #fff; }

.spinner { width: 20px; height: 20px; animation: spin 800ms linear infinite; }
.spinner circle { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-dasharray: 44 100; }
.check-draw path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: draw 340ms var(--ease) 40ms forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---------- Cards & lists ---------- */
.card { background: var(--surface); border-radius: var(--r-l); box-shadow: var(--shadow-1); }
.card-pad { padding: var(--s5); }
.card-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--hairline); }
.card-head h3 { font-size: 16px; }
.card-head .actions { margin-left: auto; display: flex; gap: 6px; }
.card-body { padding: var(--s4) var(--s5); }
.card + .card { margin-top: var(--s4); }
.section { margin-top: var(--s6); }
.section-head { display: flex; align-items: baseline; gap: var(--s3); margin-bottom: var(--s3); }
.section-head h2 { font-size: 19px; }
.section-head .actions { margin-left: auto; }
.stagger > * { animation: rise var(--d3) var(--ease) both; animation-delay: calc(min(var(--i, 0), 10) * 32ms); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--r-l); box-shadow: var(--shadow-1); overflow: hidden; }
.list > li + li > .row, .list > .row + .row { border-top: 1px solid var(--hairline); }
.row {
  display: flex; align-items: center; gap: var(--s3); min-height: 56px; padding: 12px var(--s4);
  color: inherit; text-decoration: none !important; background: transparent; width: 100%; border: 0; text-align: left;
  transition: background var(--d1) var(--ease);
}
button.row, a.row { cursor: pointer; }
button.row:hover, a.row:hover { background: var(--surface-2); }
button.row:active, a.row:active { background: var(--surface-3); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; display: flex; align-items: center; gap: 8px; min-width: 0; }
.row-sub { color: var(--text-2); font-size: 13.5px; margin-top: 1px; }
.row-meta { color: var(--text-3); font-size: 13px; white-space: nowrap; text-align: right; }
.row-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--neutral-bg); color: var(--text-2); }
.row-icon svg { width: 19px; height: 19px; }
.row .chev { color: var(--text-3); width: 16px; height: 16px; flex: none; }
.btn.file-btn { max-width: 100%; justify-content: flex-start; }
.btn.file-btn span { overflow: hidden; text-overflow: ellipsis; min-width: 0; }

.grid { display: grid; gap: var(--s4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: var(--s5); align-items: start; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--s3); }
.kpi { background: var(--surface); border-radius: var(--r-l); box-shadow: var(--shadow-1); padding: 16px 18px 15px; min-width: 0; position: relative; }
a.kpi { color: inherit; transition: transform var(--d2) var(--ease), box-shadow var(--d2) var(--ease); }
a.kpi:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-2); }
.kpi-label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.kpi-value { font-size: 30px; line-height: 1.1; font-weight: 650; letter-spacing: -0.025em; margin-top: 6px; }
.kpi-value small { font-size: 16px; font-weight: 600; color: var(--text-3); margin-left: 2px; letter-spacing: 0; }
.kpi-note { font-size: 12.5px; color: var(--text-3); margin-top: 4px; }
.kpi.attention .kpi-value { color: var(--serious); }

/* ---------- Chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: var(--r-pill);
  font-size: 12.5px; font-weight: 600; white-space: nowrap; background: var(--neutral-bg); color: var(--neutral);
  transition: background var(--d2) var(--ease), color var(--d2) var(--ease);
}
.chip svg { width: 13px; height: 13px; flex: none; }
.chip.good { background: var(--good-bg); color: var(--good); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.serious { background: var(--serious-bg); color: var(--serious); }
.chip.critical { background: var(--critical-bg); color: var(--critical); }
.chip.info { background: var(--info-bg); color: var(--info); }
.chip.violet { background: var(--violet-bg); color: var(--violet); }
.chip.outline { background: transparent; box-shadow: inset 0 0 0 1px var(--border); color: var(--text-2); }
.chip.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.6s var(--ease) infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.chip.swap { animation: chipSwap 300ms var(--ease-spring); }
@keyframes chipSwap { from { transform: scale(.85); opacity: .4; } }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ---------- Forms ---------- */
.form { display: grid; gap: var(--s4); }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-size: 13.5px; font-weight: 600; color: var(--text); }
.field .hint { font-size: 12.5px; color: var(--text-3); }
.field .error { font-size: 12.5px; color: var(--critical); display: flex; gap: 5px; align-items: center; animation: rise var(--d2) var(--ease); }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 11px;
  background: var(--surface); color: var(--text); font-size: 15px;
  transition: border-color var(--d1) var(--ease), box-shadow var(--d1) var(--ease), background var(--d1);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.field.invalid .input, .field.invalid .select, .field.invalid .textarea { border-color: var(--critical); box-shadow: 0 0 0 4px var(--critical-bg); }
.textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 18px;
}
.input-group { position: relative; }
.input-group .input { padding-right: 46px; }
.input-group .icon-btn { position: absolute; right: 2px; top: 2px; }
.code-input { font-size: 26px; letter-spacing: .32em; text-align: center; font-family: var(--mono); font-weight: 600; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 14.5px; line-height: 1.4; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 12px; cursor: pointer; min-height: 32px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 46px; height: 28px; border-radius: 14px; background: var(--surface-3); position: relative; flex: none; transition: background var(--d2) var(--ease); }
.switch .track::after {
  content: ""; position: absolute; left: 2px; top: 2px; width: 24px; height: 24px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .18), 0 0 0 .5px rgba(0, 0, 0, .06); transition: transform var(--d3) var(--ease-spring);
}
.switch input:checked + .track { background: #2fb357; }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 3px solid var(--focus); outline-offset: 2px; }
.switch:active .track::after { width: 28px; }
.switch input:checked:active + .track::after { transform: translateX(14px); }

/* Segmented control */
.seg {
  position: relative; display: inline-flex; padding: 3px; border-radius: 11px; background: var(--neutral-bg); gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg button {
  position: relative; z-index: 1; border: 0; background: transparent; min-height: 32px; padding: 0 14px; border-radius: 8px;
  font-size: 13.5px; font-weight: 550; color: var(--text-2); white-space: nowrap; transition: color var(--d1) var(--ease);
}
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { color: var(--text); font-weight: 600; }
.seg button .count { margin-left: 6px; font-size: 12px; color: var(--text-3); font-weight: 600; }
.seg-thumb {
  position: absolute; z-index: 0; top: 3px; bottom: 3px; left: 0; border-radius: 8px; background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .1), 0 0 0 .5px rgba(0, 0, 0, .04); transition: transform var(--d3) var(--ease), width var(--d3) var(--ease);
}

.toolbar { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s4); }
.toolbar .grow { flex: 1; }
.search { position: relative; min-width: 200px; flex: 1; max-width: 360px; }
.search svg { position: absolute; left: 12px; top: 50%; width: 17px; height: 17px; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search .input { padding-left: 38px; min-height: 40px; }
.toolbar .select, .toolbar .input { min-height: 40px; width: auto; }

/* ---------- Tables ---------- */
.table-wrap { background: var(--surface); border-radius: var(--r-l); box-shadow: var(--shadow-1); overflow: hidden; }
.table-scroll { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-weight: 600; font-size: 12.5px; color: var(--text-3); padding: 11px 16px; white-space: nowrap;
  background: var(--surface); border-bottom: 1px solid var(--hairline); position: sticky; top: 0;
}
.table th button { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
.table th button:focus-visible { outline: 2px solid var(--focus); border-radius: 4px; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--d1) var(--ease); }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--surface-2); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table-foot { display: flex; align-items: center; gap: var(--s2); padding: 10px 16px; border-top: 1px solid var(--hairline); font-size: 13px; color: var(--text-2); }
.table-foot .pager { margin-left: auto; display: flex; gap: 4px; }
.table.loading tbody { opacity: .5; transition: opacity var(--d2); }

/* ---------- Banners & callouts ---------- */
.banner {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; font-size: 14px; margin-bottom: var(--s4);
  background: var(--info-bg); color: var(--info); animation: rise var(--d3) var(--ease);
}
.banner svg { width: 18px; height: 18px; flex: none; }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.critical { background: var(--critical-bg); color: var(--critical); }
.banner .btn { margin-left: auto; flex: none; }
a.banner:hover { text-decoration: none; filter: brightness(.98); }
.offline-pill {
  position: fixed; left: 50%; top: 10px; z-index: 90; transform: translate(-50%, -80px); display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: var(--r-pill); background: #1d1d1f; color: #fff; font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow-3); opacity: 0; visibility: hidden; pointer-events: none;
  transition: transform var(--d3) var(--ease-spring), opacity var(--d2) var(--ease), visibility 0s linear var(--d3);
}
.offline-pill.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; transition-delay: 0s; }
.offline-pill svg { width: 16px; height: 16px; }
.callout { border-radius: 14px; padding: 14px 16px; background: var(--surface-2); font-size: 14px; }
.callout.ai { background: linear-gradient(180deg, var(--violet-bg), transparent 140%); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--violet) 18%, transparent); }
.callout-head { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 8px; }
.callout-head svg { width: 18px; height: 18px; color: var(--violet); }
.callout ul { margin: 6px 0 0; padding-left: 18px; }
.callout li + li { margin-top: 3px; }

/* ---------- Empty, skeleton ---------- */
.empty { text-align: center; padding: 48px 24px; color: var(--text-2); }
.empty .empty-icon { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px; display: grid; place-items: center; background: var(--neutral-bg); color: var(--text-3); }
.empty .empty-icon svg { width: 26px; height: 26px; }
.empty h3 { color: var(--text); margin-bottom: 4px; }
.empty .btn { margin-top: 16px; }
.skel { position: relative; overflow: hidden; background: var(--surface-2); border-radius: 8px; }
.skel::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 70%, transparent), transparent);
  animation: shimmer 1.4s var(--ease) infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.skel-line { height: 12px; margin: 8px 0; }
.skel-title { height: 28px; width: 40%; margin-bottom: 16px; }
.skel-card { height: 92px; border-radius: var(--r-l); }

/* ---------- Toasts ---------- */
.toasts[popover] { inset: auto; margin: 0; border: 0; padding: 0; background: transparent; overflow: visible; color: inherit; }
.toasts { position: fixed; z-index: 200; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(440px, calc(100vw - 32px)); }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px 12px 16px; border-radius: 14px;
  background: rgba(30, 30, 32, .94); color: #fff; box-shadow: var(--shadow-3); font-size: 14.5px; font-weight: 500;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  animation: toastIn var(--d3) var(--ease-spring) both;
}
.toast.leaving { animation: toastOut var(--d2) var(--ease-in) both; }
.toast svg { width: 19px; height: 19px; flex: none; }
.toast.good svg { color: #5fd28a; } .toast.critical svg { color: #ff8580; } .toast.warn svg { color: #f5c04a; }
.toast .btn-plain { color: #8ab4ff; margin-left: auto; }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(.97); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- Dialogs, sheets, drawers ---------- */
dialog.sheet {
  border: 0; padding: 0; margin: auto; max-height: min(88dvh, 860px); width: min(560px, calc(100vw - 32px));
  border-radius: var(--r-xl); background: var(--surface); color: var(--text); box-shadow: var(--shadow-3); overflow: hidden;
  display: flex; flex-direction: column;
}
dialog.sheet:not([open]) { display: none; }
dialog.sheet.wide { width: min(880px, calc(100vw - 32px)); }
dialog.sheet::backdrop { background: var(--overlay); animation: fadeIn var(--d2) var(--ease); }
dialog.sheet[open] { animation: sheetIn var(--d3) var(--ease) both; }
dialog.sheet.closing { animation: sheetOut 200ms var(--ease-in) both; }
dialog.sheet.closing::backdrop { animation: fadeOut 200ms var(--ease-in) both; }
@keyframes sheetIn { from { opacity: 0; transform: scale(.965) translateY(8px); } }
@keyframes sheetOut { to { opacity: 0; transform: scale(.98) translateY(4px); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--hairline); }
.sheet-head h2 { font-size: 18px; flex: 1; min-width: 0; }
.sheet-head .sub { font-size: 13px; color: var(--text-2); font-weight: 500; margin-top: 2px; }
.sheet-body { padding: 20px; overflow-y: auto; overscroll-behavior: contain; flex: 1; }
.sheet-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px calc(14px + var(--safe-b)); border-top: 1px solid var(--hairline); background: var(--surface); flex-wrap: wrap; }
.sheet-foot .left { margin-right: auto; }
.grabber { display: none; }

dialog.sheet.drawer {
  margin: 0 0 0 auto; height: 100dvh; max-height: none; width: min(620px, 100vw); border-radius: 0; animation-name: drawerIn;
}
dialog.sheet.drawer.closing { animation-name: drawerOut; }
@keyframes drawerIn { from { transform: translateX(32px); opacity: 0; } }
@keyframes drawerOut { to { transform: translateX(32px); opacity: 0; } }

/* Popover menus */
.menu {
  position: fixed; z-index: 120; min-width: 220px; max-width: min(360px, calc(100vw - 24px)); padding: 6px; border-radius: 14px;
  background: var(--surface); box-shadow: var(--shadow-3); transform-origin: top right; animation: menuIn 200ms var(--ease) both;
}
.menu.leaving { animation: menuOut 140ms var(--ease-in) both; }
@keyframes menuIn { from { opacity: 0; transform: scale(.95) translateY(-4px); } }
@keyframes menuOut { to { opacity: 0; transform: scale(.97); } }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 8px 10px; border: 0; border-radius: 9px; background: transparent; color: var(--text); text-align: left; font-size: 14.5px; }
.menu-item:hover { background: var(--neutral-bg); text-decoration: none; }
.menu-item svg { width: 18px; height: 18px; color: var(--text-2); }
.menu-item.danger { color: var(--critical); }
.menu-item.danger svg { color: var(--critical); }
.menu-sep { height: 1px; background: var(--hairline); margin: 6px 4px; }
.notif-panel { width: min(400px, calc(100vw - 24px)); max-height: min(560px, 80dvh); display: flex; flex-direction: column; padding: 0; }
.notif-panel .menu-head { display: flex; align-items: center; padding: 14px 14px 10px 16px; border-bottom: 1px solid var(--hairline); }
.notif-panel .menu-head h3 { font-size: 16px; flex: 1; }
.notif-list { overflow-y: auto; padding: 6px; }
.notif { display: flex; gap: 10px; padding: 10px; border-radius: 10px; color: inherit; }
.notif:hover { background: var(--neutral-bg); text-decoration: none; }
.notif .dotmark { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 6px; flex: none; }
.notif.read .dotmark { background: transparent; }
.notif-title { font-weight: 600; font-size: 14px; }
.notif-body { font-size: 13px; color: var(--text-2); }
.notif-time { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ---------- Today (faculty) ---------- */
.hero-card {
  position: relative; background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-2); padding: 24px; overflow: hidden;
}
.hero-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--hero-accent, var(--accent));
  transform-origin: left; transform: scaleX(var(--progress, 0)); transition: transform 600ms var(--ease);
}
.hero-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hero-time { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.hero-title { font-size: 26px; font-weight: 700; letter-spacing: -0.022em; margin-top: 10px; line-height: 1.15; }
.hero-sub { color: var(--text-2); margin-top: 4px; font-size: 15px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; align-items: center; }
.hero-actions .btn-lg { min-width: 180px; }
.hero-note { font-size: 13.5px; color: var(--text-2); display: flex; gap: 8px; align-items: center; }
.hero-note svg { width: 16px; height: 16px; }
.steps { display: flex; gap: 6px; margin-top: 20px; }
.step { flex: 1; min-width: 0; }
.step-bar { height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.step-bar i { display: block; height: 100%; width: 0; background: var(--good); border-radius: 2px; transition: width 520ms var(--ease); }
.step.active .step-bar i { width: 55%; background: var(--accent); animation: pulseBar 1.6s var(--ease) infinite; }
.step.done .step-bar i { width: 100%; }
@keyframes pulseBar { 50% { opacity: .55; } }
.step-label { font-size: 12px; font-weight: 600; color: var(--text-3); margin-top: 6px; }
.step.done .step-label, .step.active .step-label { color: var(--text-2); }

.timeline-list { position: relative; }
.session-row .time { width: 76px; flex: none; font-variant-numeric: tabular-nums; }
.session-row .time b { display: block; font-size: 14.5px; }
.session-row .time span { font-size: 12.5px; color: var(--text-3); }
.session-row.now { box-shadow: inset 3px 0 0 var(--accent); }
.row-title .name { color: var(--text-2); font-weight: 500; }

/* Week schedule */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.day-col { min-width: 0; }
.day-head { font-size: 12.5px; font-weight: 600; color: var(--text-3); padding: 0 4px 8px; display: flex; justify-content: space-between; }
.day-head.today { color: var(--accent-ink); }
.day-head .d { font-size: 18px; color: var(--text); font-weight: 650; }
.day-head.today .d { color: #fff; background: var(--accent); border-radius: 50%; width: 28px; height: 28px; display: grid; place-items: center; font-size: 14px; }
.slot {
  display: block; width: 100%; text-align: left; border: 0; padding: 10px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-1);
  margin-bottom: 8px; color: inherit; font-size: 13px; transition: transform var(--d2) var(--ease), box-shadow var(--d2) var(--ease);
  border-left: 3px solid var(--slot, var(--accent));
}
.slot:hover { transform: translateY(-1px); box-shadow: var(--shadow-2); }
.slot b { display: block; font-size: 13.5px; }
.slot .t { color: var(--text-2); font-variant-numeric: tabular-nums; }
.slot .chip { margin-top: 6px; height: 20px; font-size: 11.5px; padding: 0 7px; }

/* Calendar month */
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-radius: var(--r-l); overflow: hidden; background: var(--hairline); gap: 1px; box-shadow: var(--shadow-1); }
.month .dow { background: var(--surface); padding: 8px 10px; font-size: 12px; font-weight: 600; color: var(--text-3); }
.month .cell { background: var(--surface); min-height: 92px; padding: 6px 8px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.month .cell.out { background: var(--surface-2); }
.month .cell .n { font-size: 13px; font-weight: 600; color: var(--text-2); }
.month .cell.today .n { color: #fff; background: var(--accent); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; }
.month .ev { font-size: 11.5px; font-weight: 600; padding: 2px 6px; border-radius: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 0; text-align: left; cursor: pointer; }

/* ---------- Upload & redaction ---------- */
.dropzone {
  position: relative; display: grid; place-items: center; text-align: center; gap: 6px; padding: 28px 16px; border-radius: 16px;
  border: 1.5px dashed var(--border-strong); background: var(--surface-2); color: var(--text-2); cursor: pointer;
  transition: border-color var(--d2) var(--ease), background var(--d2) var(--ease), transform var(--d2) var(--ease);
}
.dropzone:hover { border-color: var(--accent); }
.dropzone.over { border-color: var(--accent); background: var(--accent-softer); transform: scale(1.01); }
.dropzone .dz-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--surface); box-shadow: var(--shadow-1); color: var(--accent); transition: transform var(--d3) var(--ease-spring); }
.dropzone.over .dz-icon { transform: translateY(-3px) scale(1.06); }
.dropzone .dz-icon svg { width: 22px; height: 22px; }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone b { color: var(--text); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; margin-top: 12px; }
.thumb { position: relative; aspect-ratio: 3 / 4; border-radius: 12px; overflow: hidden; background: var(--surface-2); box-shadow: var(--shadow-1); animation: thumbIn 320ms var(--ease-spring) both; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .file-tile { height: 100%; display: grid; place-items: center; align-content: center; gap: 6px; padding: 8px; text-align: center; font-size: 12px; color: var(--text-2); word-break: break-all; }
.thumb .file-tile svg { width: 28px; height: 28px; color: var(--text-3); }
.thumb .tools { position: absolute; inset: auto 6px 6px 6px; display: flex; gap: 6px; justify-content: flex-end; }
.thumb .tools button { width: 30px; height: 30px; border-radius: 50%; border: 0; display: grid; place-items: center; background: rgba(20, 20, 22, .72); color: #fff; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.thumb .tools svg { width: 15px; height: 15px; }
.thumb .badge { position: absolute; left: 6px; top: 6px; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 8px; background: rgba(20, 20, 22, .72); color: #fff; }
@keyframes thumbIn { from { opacity: 0; transform: scale(.88); } }
.progress { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width 200ms linear; }
.redactor { display: grid; gap: 12px; }
.redactor-stage { position: relative; border-radius: 12px; overflow: hidden; background: #111; touch-action: none; cursor: crosshair; max-height: 62dvh; display: grid; place-items: center; }
.redactor-stage canvas { max-width: 100%; max-height: 62dvh; width: auto; height: auto; }

/* ---------- Evidence viewer ---------- */
.evidence-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: var(--s5); }
.shot { display: block; border-radius: 14px; overflow: hidden; background: var(--surface-2); box-shadow: var(--shadow-1); cursor: zoom-in; border: 0; padding: 0; width: 100%; }
.shot img { width: 100%; height: auto; }
.shots { display: grid; gap: 10px; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.pdf-frame { width: 100%; height: 60dvh; border: 0; border-radius: 12px; background: var(--surface-2); }
dialog.lightbox { border: 0; padding: 24px; margin: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; background: transparent; display: grid; place-items: center; cursor: zoom-out; }
dialog.lightbox:not([open]) { display: none; }
dialog.lightbox::backdrop { background: rgba(0, 0, 0, .88); animation: fadeIn var(--d2) var(--ease); }
dialog.lightbox img { max-width: 100%; max-height: calc(100dvh - 48px); border-radius: 8px; animation: sheetIn var(--d3) var(--ease); }

/* Timeline (audit/status history) */
.tl { list-style: none; margin: 0; padding: 0; }
.tl li { position: relative; padding: 0 0 14px 22px; font-size: 13.5px; }
.tl li::before { content: ""; position: absolute; left: 5px; top: 7px; bottom: -7px; width: 2px; background: var(--hairline); }
.tl li:last-child::before { display: none; }
.tl li::after { content: ""; position: absolute; left: 1px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); box-shadow: inset 0 0 0 2px var(--accent); }
.tl .when { color: var(--text-3); font-size: 12.5px; }

/* ---------- Room code / QR ---------- */
.roomcode { text-align: center; display: grid; gap: 18px; justify-items: center; padding: 8px 0 4px; }
.roomcode .qr { width: 220px; height: 220px; padding: 12px; background: #fff; border-radius: 18px; box-shadow: var(--shadow-1); }
.roomcode .digits { font-family: var(--mono); font-size: 44px; font-weight: 700; letter-spacing: .18em; transition: opacity var(--d2); }
.ring { width: 44px; height: 44px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 4; }
.ring .bg { stroke: var(--surface-3); }
.ring .fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 1s linear; }

/* ---------- Camera ---------- */
.camera { position: relative; border-radius: 20px; overflow: hidden; background: #0b0b0c; aspect-ratio: 3 / 4; max-height: 56dvh; margin: 0 auto; width: 100%; max-width: 360px; }
.camera video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.camera .oval { position: absolute; inset: 12% 18%; border-radius: 50%; box-shadow: 0 0 0 2000px rgba(0, 0, 0, .45); border: 2px solid rgba(255, 255, 255, .85); transition: border-color var(--d2); }
.camera .oval.ok { border-color: #5fd28a; }
.camera .prompt { position: absolute; left: 0; right: 0; bottom: 14px; text-align: center; color: #fff; font-weight: 600; text-shadow: 0 1px 3px rgba(0,0,0,.5); }

/* ---------- Charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--hairline); stroke-width: 1; }
.chart .axis-text { fill: var(--text-3); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.chart .series-line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .series-area { fill: var(--series-1); opacity: .1; }
.chart .series-dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.chart .end-label { fill: var(--text); font-size: 12.5px; font-weight: 650; }
.chart .crosshair { stroke: var(--border-strong); stroke-width: 1; }
.chart .draw { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: drawLine 900ms var(--ease) forwards; }
@keyframes drawLine { to { stroke-dashoffset: 0; } }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 120px; padding: 8px 10px; border-radius: 10px; background: var(--surface);
  box-shadow: var(--shadow-3); font-size: 12.5px; transform: translate(-50%, -100%); opacity: 0; transition: opacity 120ms var(--ease);
}
.chart-tip.show { opacity: 1; }
.chart-tip strong { display: block; font-size: 15px; font-variant-numeric: tabular-nums; }
.chart-tip .k { display: inline-block; width: 12px; height: 2px; background: var(--series-1); vertical-align: middle; margin-right: 6px; }
.statusbar { display: flex; gap: 2px; height: 12px; border-radius: 6px; overflow: hidden; background: var(--st-muted); }
.statusbar i { display: block; height: 100%; transition: flex-grow 600ms var(--ease); min-width: 3px; }
.statusbar i:focus-visible { outline: 2px solid var(--text); outline-offset: -2px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 13px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- Auth ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 50% -10%, var(--accent-softer), transparent 70%), var(--bg); }
.auth-card { width: min(400px, 100%); background: var(--surface); border-radius: 24px; box-shadow: var(--shadow-2); padding: 32px 28px 28px; animation: sheetIn 360ms var(--ease) both; }
.auth-card .brand-mark { width: 52px; height: 52px; border-radius: 14px; margin: 0 auto 18px; }
.auth-card h1 { font-size: 24px; text-align: center; }
.auth-card .lead { text-align: center; color: var(--text-2); margin: 6px 0 24px; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 12.5px; color: var(--text-3); }
.shake { animation: shake 420ms var(--ease); }
@keyframes shake { 15%, 55% { transform: translateX(-7px); } 35%, 75% { transform: translateX(6px); } 90% { transform: translateX(-2px); } }
.caps { display: none; font-size: 12.5px; color: var(--warn); }
.caps.show { display: flex; gap: 5px; align-items: center; }

/* ---------- Misc ---------- */
.divider { height: 1px; background: var(--hairline); margin: var(--s4) 0; }
.stack { display: flex; flex-direction: column; gap: var(--s3); }
.hstack { display: flex; align-items: center; gap: var(--s2); }
.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.mt-1 { margin-top: var(--s2); } .mt-2 { margin-top: var(--s4); } .mt-3 { margin-top: var(--s5); }
.pill-count { font-size: 12px; font-weight: 650; color: var(--text-3); background: var(--neutral-bg); padding: 1px 7px; border-radius: 9px; }
.queue-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--warn); }
.diff { font-family: var(--mono); font-size: 12px; background: var(--surface-2); border-radius: 8px; padding: 8px 10px; white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow: auto; }
.prose p + p { margin-top: 8px; }
kbd { font-family: var(--mono); font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; }
.print-only { display: none; }

/* View Transitions (progressive enhancement) */
::view-transition-old(root) { animation: 160ms var(--ease-in) both fadeOut; }
::view-transition-new(root) { animation: 260ms var(--ease) both viewIn; }

/* ---------- Responsive ---------- */
@media (max-width: 1099px) {
  :root { --sidebar: 76px; }
  .sidebar { padding: 16px 10px; align-items: center; }
  .brand { padding: 4px 0 12px; }
  .brand span, .nav-label, .nav-item span, .nav-item .count, .me .ellipsis, .sidebar-foot .nav-item span { display: none; }
  .nav { width: 100%; }
  .nav-item { justify-content: center; padding: 10px; min-height: 44px; }
  .nav-indicator { height: 44px; }
  .content { padding: var(--s2) var(--s5) var(--s7); }
  .topbar { padding: 0 var(--s5); }
  .split { grid-template-columns: minmax(0, 1fr); }
  .evidence-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767px) {
  body { font-size: 15.5px; }
  h1 { font-size: 28px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .topbar { padding: 0 var(--s4); height: 52px; }
  .topbar .brand-mobile { display: flex; }
  .topbar-title { position: absolute; left: 50%; transform: translate(-50%, 4px); max-width: 55vw; }
  .topbar.scrolled .topbar-title { transform: translate(-50%, 0); }
  .topbar.scrolled .brand-mobile { opacity: 0; }
  .brand-mobile { transition: opacity var(--d2); }
  .content { padding: 4px var(--s4) calc(var(--tabbar) + 32px + var(--safe-b)); }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    height: calc(var(--tabbar) + var(--safe-b)); padding-bottom: var(--safe-b); background: var(--glass); border-top: 1px solid var(--hairline);
    -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: none;
    color: var(--text-3); font-size: 10.5px; font-weight: 600; min-height: 44px; position: relative; text-decoration: none !important;
  }
  .tab svg { width: 24px; height: 24px; transition: transform var(--d3) var(--ease-spring); }
  .tab[aria-current="page"] { color: var(--accent); }
  .tab[aria-current="page"] svg { transform: translateY(-1px) scale(1.06); }
  .tab:active svg { transform: scale(.88); }
  .tab .count { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--critical); color: #fff; font-size: 10px; display: grid; place-items: center; }
  .grid-2, .grid-3, .form-row { grid-template-columns: minmax(0, 1fr); }
  .row-title .name { display: none; }
  .session-row .time { width: 62px; }
  .session-row .chip { height: 22px; padding: 0 7px; font-size: 11.5px; }
  .row { gap: 10px; padding: 12px 14px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 26px; }
  .hero-card { padding: 20px; border-radius: 20px; }
  .hero-title { font-size: 23px; }
  .hero-actions .btn-lg { flex: 1; }
  .page-head .actions { margin-left: 0; width: 100%; }
  .card-pad, .card-body { padding: var(--s4); }
  .card-head { padding: 14px var(--s4); }
  .week { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .day-head { padding-top: 12px; }
  .month .cell { min-height: 64px; padding: 4px; }
  .month .ev { font-size: 0; height: 6px; padding: 0; border-radius: 3px; }
  dialog.sheet, dialog.sheet.wide, dialog.sheet.drawer {
    width: 100vw; max-width: 100vw; margin: auto 0 0; max-height: 92dvh; height: auto; border-radius: 22px 22px 0 0; animation-name: sheetUp;
  }
  dialog.sheet.closing, dialog.sheet.drawer.closing { animation-name: sheetDown; }
  @keyframes sheetUp { from { transform: translateY(100%); } }
  @keyframes sheetDown { to { transform: translateY(100%); } }
  dialog.sheet[open] { animation-duration: 340ms; animation-timing-function: var(--ease-sheet); }
  .grabber { display: block; width: 36px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 8px auto -6px; }
  .toasts { bottom: calc(var(--tabbar) + 14px + var(--safe-b)); }
  /* Tables become cards */
  .table.stack-mobile thead { display: none; }
  .table.stack-mobile tr { display: block; padding: 10px 14px; border-bottom: 1px solid var(--hairline); }
  .table.stack-mobile td { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border: 0; text-align: right; }
  .table.stack-mobile td::before { content: attr(data-label); color: var(--text-3); font-size: 13px; text-align: left; font-weight: 500; }
  .table.stack-mobile td.primary { font-weight: 600; font-size: 15px; text-align: left; }
  .table.stack-mobile td.primary::before { display: none; }
  .table.stack-mobile td.actions { justify-content: flex-end; }
  .table.stack-mobile td.actions::before { display: none; }
  .toolbar .search { max-width: none; flex-basis: 100%; }
  .seg { width: 100%; }
  .seg button { flex: 1; padding: 0 10px; }
}
@media (max-width: 380px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .hero-actions .btn { width: 100%; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; animation-delay: 0ms !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
  .skel::after { display: none; }
}

/* ---------- Forced colors ---------- */
@media (forced-colors: active) {
  .chip, .btn, .card, .kpi, .list { border: 1px solid CanvasText; }
  .statusbar i { forced-color-adjust: none; }
}

/* ---------- Print ---------- */
@media print {
  @page { margin: 14mm; }
  :root { --bg: #fff; --surface: #fff; --shadow-1: none; --shadow-2: none; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .sidebar, .topbar, .tabbar, .toolbar, .no-print, .toasts, .offline-pill, .page-head .actions, .btn { display: none !important; }
  .app { display: block; }
  .content { padding: 0; max-width: none; }
  .card, .table-wrap, .list, .kpi { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .table th { position: static; }
  .print-only { display: block; }
  .view { animation: none; }
  a { color: inherit; }
}

@media (min-width: 768px) { .mobile-only { display: none !important; } }
.row-btn { flex: 1; min-width: 0; background: none; border: 0; padding: 0; margin: 0; text-align: left; color: inherit; font: inherit; cursor: pointer; border-radius: 8px; }
/* Settings rows: label left, control right (wraps on narrow screens). */
.row.field { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 18px; }
.row.field > div:last-child { margin-left: auto; }
.row.field .error { flex-basis: 100%; }
