/* ==========================================================================
   Zenai — UI mockup design system
   Tenant branding is injected at runtime as CSS custom properties
   (--brand, --brand-2, --font-sans, --sidebar-bg) by tenants.js.
   ========================================================================== */

/* ---------- Tokens: light ---------- */
:root {
  color-scheme: light;
  --font-sans: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Tamil", "Nirmala UI", sans-serif;
  --brand: #5b5bd6;
  --brand-2: #8b5cf6;
  --brand-ink: #ffffff;

  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #f1f3f6;
  --border: #e6e8ec;
  --border-strong: #d3d8df;
  --text: #0f172a;
  --text-2: #475467;
  --text-3: #7a8596;

  --brand-soft: color-mix(in oklab, var(--brand) 11%, var(--surface));
  --brand-softer: color-mix(in oklab, var(--brand) 5%, var(--surface));
  --brand-text: color-mix(in oklab, var(--brand) 78%, var(--text));
  --ring: color-mix(in oklab, var(--brand) 40%, transparent);

  /* status (reserved, always paired with icon + label) */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;

  /* charts */
  --series-1: #2a78d6;
  --series-track: #cde2fb;
  --grid: #eceef2;
  --axis: #d3d8df;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .07), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 16px 40px -12px rgba(16, 24, 40, .22), 0 4px 10px -4px rgba(16, 24, 40, .08);
  --overlay: rgba(15, 23, 42, .38);

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --sidebar-w: 272px;
  --topbar-h: 64px;

  /* sidebar defaults (brand style) */
  --sidebar-bg: #111128;
  --sidebar-fg: #eceef8;
  --sidebar-muted: #9da1bd;
  --sidebar-hover: rgba(255, 255, 255, .06);
  --sidebar-active: rgba(255, 255, 255, .11);
  --sidebar-border: rgba(255, 255, 255, .08);
  --sidebar-input: rgba(255, 255, 255, .06);
}

/* ---------- Tokens: dark (OS preference, unless user forced light) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0c0f14;
    --surface: #141820;
    --surface-2: #181d26;
    --surface-3: #1e242f;
    --border: #262d39;
    --border-strong: #343c4a;
    --text: #eef1f6;
    --text-2: #b0b8c6;
    --text-3: #7f8899;
    --brand-soft: color-mix(in oklab, var(--brand) 20%, var(--surface));
    --brand-softer: color-mix(in oklab, var(--brand) 10%, var(--surface));
    --brand-text: color-mix(in oklab, var(--brand) 62%, white);
    --series-1: #3987e5;
    --series-track: #1d3556;
    --grid: #222936;
    --axis: #343c4a;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
    --shadow-lg: 0 18px 44px -12px rgba(0, 0, 0, .6);
    --overlay: rgba(0, 0, 0, .55);
  }
}
/* ---------- Tokens: dark (explicit toggle) ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0f14;
  --surface: #141820;
  --surface-2: #181d26;
  --surface-3: #1e242f;
  --border: #262d39;
  --border-strong: #343c4a;
  --text: #eef1f6;
  --text-2: #b0b8c6;
  --text-3: #7f8899;
  --brand-soft: color-mix(in oklab, var(--brand) 20%, var(--surface));
  --brand-softer: color-mix(in oklab, var(--brand) 10%, var(--surface));
  --brand-text: color-mix(in oklab, var(--brand) 62%, white);
  --series-1: #3987e5;
  --series-track: #1d3556;
  --grid: #222936;
  --axis: #343c4a;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-lg: 0 18px 44px -12px rgba(0, 0, 0, .6);
  --overlay: rgba(0, 0, 0, .55);
}

/* Light-style sidebar (tenant option): follows the page theme */
:root[data-sidebar="light"] {
  --sidebar-bg: var(--surface);
  --sidebar-fg: var(--text);
  --sidebar-muted: var(--text-3);
  --sidebar-hover: var(--surface-3);
  --sidebar-active: var(--brand-soft);
  --sidebar-border: var(--border);
  --sidebar-input: var(--surface-2);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0; }
a { color: var(--brand-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
::selection { background: color-mix(in oklab, var(--brand) 25%, transparent); }
[hidden] { display: none !important; }

.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.strong { font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.hstack { display: flex; align-items: center; gap: 8px; }
.vstack { display: flex; flex-direction: column; gap: 8px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.gap-4 { gap: 4px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.divider { height: 1px; background: var(--border); border: 0; margin: 16px 0; }

/* ---------- Buttons ---------- */
.btn {
  --btn-h: 38px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--btn-h); padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 13.5px; line-height: 1;
  cursor: pointer; white-space: nowrap; text-decoration: none !important;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn i { font-size: 15px; }
.btn-primary { background: var(--brand); border-color: transparent; color: var(--brand-ink); box-shadow: 0 1px 2px color-mix(in oklab, var(--brand) 40%, transparent); }
.btn-primary:hover { background: color-mix(in oklab, var(--brand) 88%, black); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger { color: var(--critical); }
.btn-danger:hover { background: color-mix(in oklab, var(--critical) 9%, var(--surface)); }
.btn-sm { --btn-h: 32px; padding: 0 10px; font-size: 13px; }
.btn-lg { --btn-h: 46px; padding: 0 18px; font-size: 15px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-icon { width: var(--btn-h); padding: 0; }
.btn .spinner { width: 16px; height: 16px; border-width: 2px; }

.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 13px; font-weight: 600; color: var(--text); }
.hint { font-size: 12.5px; color: var(--text-3); }
.error-text { font-size: 12.5px; color: var(--critical); display: flex; align-items: center; gap: 6px; }
.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 88px; padding: 10px 12px; resize: vertical; }
.select { appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%237a8596' viewBox='0 0 16 16'%3E%3Cpath d='M3.2 5.7a.75.75 0 0 1 1.06 0L8 9.44l3.74-3.74a.75.75 0 1 1 1.06 1.06l-4.27 4.27a.75.75 0 0 1-1.06 0L3.2 6.76a.75.75 0 0 1 0-1.06'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: color-mix(in oklab, var(--border-strong) 60%, var(--text-3)); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--ring); }
.input[aria-invalid="true"] { border-color: var(--critical); box-shadow: 0 0 0 4px color-mix(in oklab, var(--critical) 18%, transparent); }
.input-sm, .select-sm { height: 34px; font-size: 13px; }
.input-icon { position: relative; display: flex; align-items: center; }
.input-icon > i { position: absolute; left: 12px; color: var(--text-3); pointer-events: none; font-size: 15px; }
.input-icon > .input { padding-left: 36px; }
.input-icon > .input-action { position: absolute; right: 6px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 13.5px; color: var(--text-2); }
.check input { width: 16px; height: 16px; accent-color: var(--brand); margin: 0; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); min-width: 0; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 0; }
.card-title { font-size: 15px; font-weight: 650; }
.card-sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.card-body { padding: 16px 18px 18px; }
.card-footer { padding: 12px 18px; border-top: 1px solid var(--border); }
.card.flush .card-body { padding: 0; }

/* ---------- Badges / chips / avatars ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.badge i { font-size: 12px; }
.badge.good     { background: color-mix(in oklab, var(--good) 13%, var(--surface));     color: color-mix(in oklab, var(--good) 62%, var(--text)); }
.badge.warning  { background: color-mix(in oklab, var(--warning) 20%, var(--surface));  color: color-mix(in oklab, var(--warning) 45%, var(--text)); }
.badge.serious  { background: color-mix(in oklab, var(--serious) 16%, var(--surface));  color: color-mix(in oklab, var(--serious) 55%, var(--text)); }
.badge.critical { background: color-mix(in oklab, var(--critical) 13%, var(--surface)); color: color-mix(in oklab, var(--critical) 70%, var(--text)); }
.badge.brand    { background: var(--brand-soft); color: var(--brand-text); }
.badge.outline  { background: transparent; border: 1px solid var(--border-strong); }
.badge.good i { color: var(--good); } .badge.warning i { color: color-mix(in oklab, var(--warning) 80%, black); } .badge.serious i { color: var(--serious); } .badge.critical i { color: var(--critical); }
.count-pill { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; font-size: 11.5px; font-weight: 700; display: inline-grid; place-items: center; background: var(--brand); color: var(--brand-ink); }
.code { font-family: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace; font-size: 12px; padding: 1px 6px; border-radius: 5px; background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border); }
kbd { font-family: inherit; font-size: 11px; font-weight: 600; padding: 1px 5px; border-radius: 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; background: var(--surface); color: var(--text-2); }

.avatar {
  --size: 34px;
  width: var(--size); height: var(--size); flex: 0 0 var(--size);
  border-radius: 50%; display: inline-grid; place-items: center;
  font-size: calc(var(--size) * .38); font-weight: 700; letter-spacing: .02em;
  color: var(--av-fg, var(--brand-text)); background: var(--av-bg, var(--brand-soft));
}
.avatar.sm { --size: 28px; } .avatar.lg { --size: 52px; } .avatar.xl { --size: 64px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3);
  padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border);
  white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
.table td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background .12s; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--brand-softer); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; }
.cell-person { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.cell-person .name { font-weight: 600; }
.cell-person .meta { font-size: 12px; color: var(--text-3); }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-2); flex-wrap: wrap; }

/* ---------- Tabs & segmented ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 12px; margin-bottom: -1px;
  border: 0; border-bottom: 2px solid transparent; background: none; cursor: pointer;
  font-weight: 600; font-size: 13.5px; color: var(--text-3); white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--brand); }
.tab .tab-count { font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); }
.tab[aria-selected="true"] .tab-count { background: var(--brand-soft); color: var(--brand-text); }

.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-3); border-radius: 10px; border: 1px solid var(--border); }
.seg button {
  border: 0; background: transparent; cursor: pointer; height: 30px; min-width: 34px; padding: 0 10px;
  border-radius: 7px; font-weight: 600; font-size: 12.5px; color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg.att button[aria-pressed="true"][data-v="P"] { background: color-mix(in oklab, var(--good) 16%, var(--surface)); color: color-mix(in oklab, var(--good) 65%, var(--text)); }
.seg.att button[aria-pressed="true"][data-v="A"] { background: color-mix(in oklab, var(--critical) 14%, var(--surface)); color: color-mix(in oklab, var(--critical) 72%, var(--text)); }
.seg.att button[aria-pressed="true"][data-v="L"] { background: color-mix(in oklab, var(--warning) 24%, var(--surface)); color: color-mix(in oklab, var(--warning) 45%, var(--text)); }
.seg.att button[aria-pressed="true"][data-v="E"] { background: color-mix(in oklab, var(--series-1) 14%, var(--surface)); color: color-mix(in oklab, var(--series-1) 70%, var(--text)); }

/* ---------- App layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sb-backdrop { display: none; position: fixed; inset: 0; background: var(--overlay); z-index: 35; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--sidebar-bg); color: var(--sidebar-fg);
  border-right: 1px solid var(--sidebar-border); z-index: 40;
}
.sb-brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; }
.sb-brand .names { min-width: 0; }
.sb-brand .tenant-name { font-weight: 700; font-size: 14.5px; line-height: 1.2; }
.sb-brand .product { font-size: 11.5px; color: var(--sidebar-muted); }
.sb-scroll { flex: 1 1 auto; overflow-y: auto; padding: 4px 12px 12px; scrollbar-width: thin; }
.sb-section { margin-top: 16px; }
.sb-section-label { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--sidebar-muted); padding: 0 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; height: 38px; padding: 0 10px; border-radius: 9px;
  color: var(--sidebar-fg); opacity: .86; text-decoration: none !important; font-weight: 550; font-size: 13.5px;
  position: relative;
}
.nav-item i { font-size: 16px; width: 18px; text-align: center; color: var(--sidebar-muted); }
.nav-item:hover { background: var(--sidebar-hover); opacity: 1; }
.nav-item[aria-current="page"] { background: var(--sidebar-active); opacity: 1; font-weight: 650; }
.nav-item[aria-current="page"] i { color: var(--sidebar-fg); }
:root[data-sidebar="light"] .nav-item[aria-current="page"] { color: var(--brand-text); }
:root[data-sidebar="light"] .nav-item[aria-current="page"] i { color: var(--brand); }
.nav-item[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); }
.nav-item .nav-badge { margin-left: auto; }
.nav-item .soon { margin-left: auto; font-size: 10.5px; font-weight: 700; color: var(--sidebar-muted); border: 1px solid var(--sidebar-border); padding: 0 6px; border-radius: 999px; }

/* Location picker (sidebar) */
.loc-picker { position: relative; padding: 0 12px 6px; }
.loc-label { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--sidebar-muted); padding: 6px 10px 6px; }
.loc-trigger {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 9px 10px; border-radius: 10px; cursor: pointer;
  background: var(--sidebar-input); border: 1px solid var(--sidebar-border); color: var(--sidebar-fg);
}
.loc-trigger:hover { background: var(--sidebar-hover); }
.loc-trigger[aria-expanded="true"] { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.loc-trigger .loc-ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: 0 0 30px; background: color-mix(in oklab, var(--brand) 26%, transparent); color: var(--sidebar-fg); }
:root[data-sidebar="light"] .loc-trigger .loc-ic { background: var(--brand-soft); color: var(--brand-text); }
.loc-trigger .loc-name { display: block; font-weight: 650; font-size: 13.5px; }
.loc-trigger .loc-sub { display: block; font-size: 11.5px; color: var(--sidebar-muted); }
.loc-trigger > i { margin-left: auto; color: var(--sidebar-muted); }
.loc-pop {
  position: absolute; left: 12px; right: -160px; top: calc(100% + 2px); z-index: 60;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .14s ease-out;
}
@keyframes pop { from { transform: translateY(-4px) scale(.98); } to { transform: none; } }
.loc-search { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.loc-search i { color: var(--text-3); }
.loc-search input { border: 0; outline: 0; background: transparent; width: 100%; height: 26px; font-size: 13.5px; }
.loc-list { max-height: 340px; overflow-y: auto; padding: 6px; }
.loc-opt {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13.5px;
}
.loc-opt .opt-main { min-width: 0; flex: 1; }
.loc-opt .opt-title { font-weight: 600; display: block; }
.loc-opt .opt-sub { font-size: 12px; color: var(--text-3); display: block; }
.loc-opt.session { padding-left: 18px; }
.loc-opt .tick { color: var(--brand); visibility: hidden; }
.loc-opt[aria-selected="true"] .tick { visibility: visible; }
.loc-opt.active, .loc-opt:hover { background: var(--surface-3); }
.loc-opt .ic { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex: 0 0 26px; font-size: 13px; }
.loc-opt.active .ic, .loc-opt:hover .ic { background: var(--surface); }
.loc-empty { padding: 20px 12px; text-align: center; color: var(--text-3); font-size: 13px; }
.loc-foot { display: flex; gap: 6px; align-items: center; padding: 8px 12px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text-3); background: var(--surface-2); }
mark { background: color-mix(in oklab, var(--warning) 35%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

/* Sidebar user card */
.sb-user { border-top: 1px solid var(--sidebar-border); padding: 12px; position: relative; }
.sb-user-btn { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; border: 0; background: transparent; color: var(--sidebar-fg); cursor: pointer; text-align: left; }
.sb-user-btn:hover { background: var(--sidebar-hover); }
.sb-user-btn .uname { font-weight: 650; font-size: 13.5px; display: block; }
.sb-user-btn .urole { font-size: 12px; color: var(--sidebar-muted); display: block; }
.sb-user-btn > i { margin-left: auto; color: var(--sidebar-muted); }

/* Main column */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 24px;
  background: color-mix(in oklab, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(10px); -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-3); min-width: 0; flex: 1 1 auto; }
.topbar .crumbs .here { color: var(--text); font-weight: 650; }
.topbar .search { width: 300px; max-width: 34vw; margin-left: auto; }
.topbar .search .input { height: 36px; background: var(--surface); }
.topbar .search kbd { position: absolute; right: 10px; }
.year-chip { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); font-weight: 600; font-size: 13px; cursor: pointer; }
.year-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.icon-btn { position: relative; width: 36px; height: 36px; border-radius: 10px; border: 1px solid transparent; display: grid; place-items: center; background: transparent; color: var(--text-2); cursor: pointer; font-size: 17px; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn .ping { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--critical); border: 2px solid var(--bg); }
.menu-toggle { display: none; }

.content { padding: 24px; width: 100%; max-width: 1440px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .eyebrow { font-size: 12.5px; color: var(--text-3); font-weight: 600; display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.page-head .lede { color: var(--text-2); margin-top: 4px; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.toolbar .input-icon { flex: 1 1 240px; max-width: 360px; }
.toolbar .select { width: auto; min-width: 150px; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }

/* Context banner (shows active location scope) */
.scope-note { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); padding: 4px 10px; border-radius: 999px; }
.scope-note i { color: var(--brand); }

/* ---------- Stat tiles ---------- */
.stat { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.stat .stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat .stat-label { font-size: 13px; color: var(--text-2); font-weight: 550; }
.stat .stat-ic { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-text); font-size: 15px; }
.stat .stat-value { font-size: 28px; font-weight: 650; letter-spacing: -.02em; line-height: 1.1; }
.stat .stat-mid { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.stat .stat-mid .spark { flex: 0 1 96px; min-width: 48px; margin-bottom: 2px; }
.stat .stat-foot { display: flex; align-items: center; gap: 8px; min-height: 20px; min-width: 0; }
.delta { font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.delta.up-good, .delta.down-good { color: color-mix(in oklab, var(--good) 70%, var(--text)); }
.delta.up-bad, .delta.down-bad { color: color-mix(in oklab, var(--critical) 75%, var(--text)); }
.delta .vs { font-weight: 500; color: var(--text-3); }

/* ---------- Meters ---------- */
.meter-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.meter-row:last-child { border-bottom: 0; }
.meter-row .mr-name { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.meter-row .mr-val { font-size: 12.5px; color: var(--text-2); text-align: right; }
.meter { grid-column: 1 / -1; height: 8px; border-radius: 999px; background: var(--series-track); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--series-1); }
.meter.warning { background: color-mix(in oklab, var(--warning) 26%, var(--surface)); }
.meter.warning > span { background: var(--warning); }
.meter.critical { background: color-mix(in oklab, var(--critical) 18%, var(--surface)); }
.meter.critical > span { background: var(--critical); }
.meter.sm { height: 6px; width: 72px; display: inline-block; vertical-align: middle; }

/* ---------- Charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis-label { font-size: 11.5px; fill: var(--text-3); font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .bar { fill: var(--series-1); transition: opacity .12s; }
.chart.hovering .bar:not(.hot) { opacity: .45; }
.chart .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--series-1); opacity: .1; }
.chart .dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.chart .crosshair { stroke: var(--axis); stroke-width: 1; }
.chart .value-label { font-size: 11.5px; fill: var(--text-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5; transform: translate(-50%, calc(-100% - 10px));
  background: var(--text); color: var(--surface); padding: 6px 10px; border-radius: 8px; font-size: 12px; white-space: nowrap;
  box-shadow: var(--shadow-lg);
}
.chart-tip .tip-title { font-weight: 700; }
.chart-table { width: 100%; font-size: 13px; border-collapse: collapse; }
.chart-table th, .chart-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.chart-table td.num, .chart-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.spark { display: block; }
.spark path { fill: none; stroke: var(--text-3); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { fill: var(--brand); }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); min-width: 0; }
.list-item:last-child { border-bottom: 0; }
.list-item .li-main { flex: 1 1 auto; min-width: 0; }
.list-item .li-title { font-weight: 600; font-size: 13.5px; }
.list-item .li-sub { font-size: 12.5px; color: var(--text-3); }
.date-tile { width: 44px; flex: 0 0 44px; border-radius: 10px; border: 1px solid var(--border); text-align: center; overflow: hidden; background: var(--surface); }
.date-tile .m { font-size: 10px; font-weight: 700; text-transform: uppercase; background: var(--brand-soft); color: var(--brand-text); padding: 2px 0; letter-spacing: .05em; }
.date-tile .d { font-size: 16px; font-weight: 700; padding: 2px 0 3px; }

/* ---------- Popovers / menus ---------- */
.popover {
  position: absolute; z-index: 70; min-width: 220px; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; animation: pop .14s ease-out;
}
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: transparent; border-radius: 8px; cursor: pointer; text-align: left; font-size: 13.5px; color: var(--text); text-decoration: none !important; }
.menu-item:hover { background: var(--surface-3); }
.menu-item i { color: var(--text-3); width: 16px; text-align: center; }
.menu-item .tick { margin-left: auto; color: var(--brand); }
.menu-label { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); padding: 8px 10px 4px; }
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }

/* ---------- Drawer ---------- */
.overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 80; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); z-index: 90;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; animation: slide .22s cubic-bezier(.2, .8, .2, 1);
}
@keyframes slide { from { transform: translateX(24px); } to { transform: none; } }
.drawer-head { display: flex; align-items: flex-start; gap: 14px; padding: 20px 22px 16px; border-bottom: 1px solid var(--border); }
.drawer-body { flex: 1 1 auto; overflow-y: auto; padding: 18px 22px 24px; }
.drawer-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 8px 16px; font-size: 13.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; font-weight: 550; min-width: 0; overflow-wrap: anywhere; }
.section-title { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); margin: 20px 0 10px; }
.section-title:first-child { margin-top: 0; }
.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px; font-size: 13px; background: var(--surface-2); border: 1px solid var(--border); }
.callout i { font-size: 16px; margin-top: 1px; }
.callout.warning { background: color-mix(in oklab, var(--warning) 12%, var(--surface)); border-color: color-mix(in oklab, var(--warning) 35%, var(--border)); }
.callout.warning i { color: color-mix(in oklab, var(--warning) 80%, black); }
.callout.info { background: var(--brand-softer); border-color: color-mix(in oklab, var(--brand) 25%, var(--border)); }
.callout.info i { color: var(--brand); }
.callout.critical { background: color-mix(in oklab, var(--critical) 8%, var(--surface)); border-color: color-mix(in oklab, var(--critical) 30%, var(--border)); }
.callout.critical i { color: var(--critical); }
.pref { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.pref + .pref { margin-top: 8px; }
.pref:has(input:checked) { border-color: var(--brand); background: var(--brand-softer); box-shadow: 0 0 0 3px var(--ring); }
.pref input { accent-color: var(--brand); }
.pref .rank { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 11.5px; font-weight: 700; background: var(--surface-3); color: var(--text-2); }
.doc { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.doc + .doc { margin-top: 8px; }
.doc .doc-ic { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; top: 76px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: 13.5px;
  animation: toast-in .2s ease-out;
}
.toast i { font-size: 17px; margin-top: 1px; }
.toast.good i { color: var(--good); } .toast.warning i { color: color-mix(in oklab, var(--warning) 80%, black); } .toast.critical i { color: var(--critical); } .toast.info i { color: var(--brand); }
.toast .t-title { font-weight: 650; }
.toast .t-body { color: var(--text-2); font-size: 12.5px; }
.toast.out { animation: toast-out .2s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(12px); } }

/* ---------- Skeleton / empty ---------- */
.skel { display: block; border-radius: 6px; background: linear-gradient(90deg, var(--surface-3) 25%, color-mix(in oklab, var(--surface-3) 50%, var(--surface)) 37%, var(--surface-3) 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.empty { text-align: center; padding: 48px 24px; color: var(--text-2); }
.empty .empty-ic { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-text); font-size: 24px; }
.empty h3 { color: var(--text); margin-bottom: 6px; }
.fade-in { animation: rise .25s ease-out; }
@keyframes rise { from { transform: translateY(4px); } to { transform: none; } }

/* ---------- Attendance roster ---------- */
.roster-row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.roster-row:last-child { border-bottom: 0; }
.roster-row .rr-name { flex: 1 1 auto; min-width: 0; }
.roster-row .hist { display: flex; gap: 3px; }
.roster-row .hist span { width: 8px; height: 8px; border-radius: 50%; background: var(--surface-3); }
.roster-row .hist span.P { background: var(--good); } .roster-row .hist span.A { background: var(--critical); } .roster-row .hist span.L { background: var(--warning); } .roster-row .hist span.E { background: var(--series-1); }
.sticky-bar { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--border); background: color-mix(in oklab, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-radius: 0 0 var(--radius) var(--radius); }

/* ---------- Parent views ---------- */
.child-card { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.child-card .cc-head { display: flex; align-items: center; gap: 12px; }
.balance-card { padding: 20px; background: linear-gradient(135deg, var(--brand), color-mix(in oklab, var(--brand-2) 85%, var(--brand))); color: #fff; border: 0; position: relative; overflow: hidden; }
.balance-card::after { content: ""; position: absolute; right: -60px; top: -60px; width: 200px; height: 200px; border-radius: 50%; background: rgba(255, 255, 255, .09); }
.balance-card .muted, .balance-card .subtle { color: rgba(255, 255, 255, .78); }
.balance-card .btn { background: #fff; color: #111; border-color: transparent; }
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: 12px; padding: 22px; text-align: center; cursor: pointer; background: var(--surface-2); transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-softer); }
.dropzone i { font-size: 26px; color: var(--brand); }
.fee-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 13.5px; }
.fee-row.total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; font-weight: 700; }

/* ==========================================================================
   Login / auth
   ========================================================================== */
.auth { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); min-height: 100vh; background: var(--surface); }
.auth-hero {
  position: relative; overflow: hidden; color: #fff; padding: 40px 48px; display: flex; flex-direction: column;
  background:
    radial-gradient(900px 520px at 12% 8%, color-mix(in oklab, var(--brand) 70%, white 30%) 0%, transparent 60%),
    radial-gradient(700px 600px at 95% 100%, color-mix(in oklab, var(--brand-2) 80%, black 20%) 0%, transparent 62%),
    linear-gradient(150deg, color-mix(in oklab, var(--brand) 92%, black 8%), color-mix(in oklab, var(--brand-2) 90%, black 10%));
}
.auth-hero::before {
  content: ""; position: absolute; inset: 0; opacity: .14; pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, .5) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .5) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at 30% 40%, black 10%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at 30% 40%, black 10%, transparent 70%);
}
.auth-hero > * { position: relative; }
.hero-brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 16px; }
.hero-copy { margin-top: auto; max-width: 520px; }
.hero-copy .motto { font-size: 15px; opacity: .85; margin-bottom: 14px; letter-spacing: .01em; }
.hero-copy h1 { font-size: clamp(30px, 3.4vw, 44px); line-height: 1.08; letter-spacing: -.025em; font-weight: 750; }
.hero-copy p { margin-top: 14px; font-size: 16px; opacity: .85; max-width: 440px; }
.hero-stack { position: relative; height: 230px; margin: 34px 0 30px; max-width: 520px; }
.glass {
  position: absolute; background: rgba(255, 255, 255, .13); border: 1px solid rgba(255, 255, 255, .24);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-radius: 16px; padding: 14px 16px;
  box-shadow: 0 20px 40px -20px rgba(0, 0, 0, .45); color: #fff;
}
.glass .g-label { font-size: 12px; opacity: .8; }
.glass .g-value { font-size: 26px; font-weight: 750; letter-spacing: -.02em; }
.glass .g-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.glass .g-ic { width: 30px; height: 30px; border-radius: 9px; background: rgba(255, 255, 255, .2); display: grid; place-items: center; }
.glass .bars { display: flex; align-items: flex-end; gap: 5px; height: 46px; margin-top: 8px; }
.glass .bars span { width: 10px; border-radius: 3px 3px 0 0; background: rgba(255, 255, 255, .75); }
.float-a { animation: floaty 7s ease-in-out infinite; }
.float-b { animation: floaty 8s ease-in-out -2s infinite; }
.float-c { animation: floaty 9s ease-in-out -4s infinite; }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.hero-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12.5px; opacity: .8; }

.auth-panel { display: flex; flex-direction: column; padding: 28px 40px; min-width: 0; }
.auth-top { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.auth-top .mobile-brand { display: none; margin-right: auto; align-items: center; gap: 10px; font-weight: 700; }
.auth-card { width: 100%; max-width: 400px; margin: auto; padding: 24px 0; }
.auth-card h2 { font-size: 26px; font-weight: 750; letter-spacing: -.02em; }
.auth-card .lede { color: var(--text-2); margin-top: 6px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; margin-top: 26px; }
.auth-step { animation: step-in .28s cubic-bezier(.2, .8, .2, 1); }
@keyframes step-in { from { transform: translateX(14px); } to { transform: none; } }
.or { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.btn-google { background: var(--surface); }
.btn-google svg { width: 18px; height: 18px; }
.email-chip { display: inline-flex; align-items: center; gap: 8px; padding: 5px 6px 5px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); font-size: 13px; font-weight: 600; max-width: 100%; }
.email-chip button { border: 0; background: var(--surface); border-radius: 999px; padding: 2px 8px; font-size: 12px; font-weight: 600; color: var(--brand-text); cursor: pointer; border: 1px solid var(--border); }
.otp { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.otp input { height: 52px; text-align: center; font-size: 22px; font-weight: 700; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); font-variant-numeric: tabular-nums; }
.otp input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--ring); }
.strength { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.strength span { height: 4px; border-radius: 999px; background: var(--surface-3); }
.strength[data-score="1"] span:nth-child(-n+1) { background: var(--critical); }
.strength[data-score="2"] span:nth-child(-n+2) { background: var(--serious); }
.strength[data-score="3"] span:nth-child(-n+3) { background: var(--warning); }
.strength[data-score="4"] span:nth-child(-n+4) { background: var(--good); }
.auth-alt { text-align: center; font-size: 13.5px; color: var(--text-2); margin-top: 22px; }
.auth-legal { text-align: center; font-size: 12px; color: var(--text-3); }
.success-ic { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in oklab, var(--good) 14%, var(--surface)); color: var(--good); font-size: 26px; margin-bottom: 16px; }


/* ==========================================================================
   Components for Families / Staff / Classes / Settings / Registration
   ========================================================================== */
.avatar-stack { display: flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack .avatar + .avatar { margin-left: -8px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.tag.brand { background: var(--brand-soft); color: var(--brand-text); }

/* selectable chips (multi-select) */
.chip-check { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-2); user-select: none; }
.chip-check input { position: absolute; opacity: 0; pointer-events: none; }
.chip-check:hover { background: var(--surface-3); }
.chip-check:has(input:checked) { background: var(--brand-soft); border-color: color-mix(in oklab, var(--brand) 45%, var(--border)); color: var(--brand-text); }
.chip-check:has(input:checked)::before { content: "✓"; font-size: 12px; font-weight: 800; }
.chip-check:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.chip-check:has(input:disabled) { opacity: .5; cursor: not-allowed; }

/* switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; color: var(--text-2); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 36px; height: 20px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .15s; flex: 0 0 36px; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s; }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--brand); outline-offset: 2px; }

/* form grid */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.req { color: var(--critical); margin-left: 2px; }

/* settings layout */
.settings { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; }
.settings-nav { position: sticky; top: calc(var(--topbar-h) + 16px); display: flex; flex-direction: column; gap: 2px; }
.settings-nav button { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 12px; border-radius: 9px; border: 0; background: transparent; cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--text-2); text-align: left; }
.settings-nav button i { color: var(--text-3); width: 16px; }
.settings-nav button:hover { background: var(--surface-3); color: var(--text); }
.settings-nav button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.settings-nav button[aria-selected="true"] i { color: var(--brand); }
.settings-section + .settings-section { margin-top: 16px; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch-btn { width: 34px; height: 34px; border-radius: 10px; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; display: grid; place-items: center; color: #fff; }
.swatch-btn[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--text); }
.brand-preview { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: grid; grid-template-columns: 120px 1fr; min-height: 150px; background: var(--bg); }
.brand-preview .bp-side { background: var(--surface); border-right: 1px solid var(--border); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.brand-preview .bp-item { height: 10px; border-radius: 4px; background: var(--surface-3); }
.brand-preview .bp-item.on { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }
.brand-preview .bp-main { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.dns { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: grid; grid-template-columns: 70px 90px minmax(0, 1fr); gap: 4px 12px; overflow-x: auto; }
.dns .h { color: var(--text-3); font-family: var(--font-sans); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.table input.input { height: 34px; min-width: 90px; }
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.matrix .yes { color: var(--good); font-size: 16px; }
.matrix .no { color: var(--text-3); }
.matrix .scoped { font-size: 11.5px; font-weight: 600; color: var(--text-2); background: var(--surface-3); border-radius: 6px; padding: 2px 6px; white-space: nowrap; }

/* class cards */
.class-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 12px; }
.class-card { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; cursor: pointer; transition: border-color .15s, box-shadow .15s; text-align: left; font: inherit; color: inherit; }
.class-card:hover { border-color: color-mix(in oklab, var(--brand) 40%, var(--border)); box-shadow: var(--shadow); }
.class-card .cc-title { font-weight: 700; font-size: 15px; }
.class-card .cc-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); min-width: 0; }

/* icon tiles, FAQ, gradebook */
.ic-tile { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-text); font-size: 15px; }
.ic-tile.lg { width: 48px; height: 48px; flex-basis: 48px; border-radius: 12px; font-size: 21px; }
.faq details { border-bottom: 1px solid var(--border); }
.faq details:last-child { border-bottom: 0; }
.faq summary { cursor: pointer; list-style: none; padding: 14px 30px 14px 0; font-weight: 600; position: relative; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: 6px; top: 11px; font-size: 20px; line-height: 1; color: var(--text-3); }
.faq details[open] summary::after { content: "−"; }
.faq p { padding: 0 0 14px; color: var(--text-2); }
.gradebook th, .gradebook td { text-align: center; }
.gradebook th:first-child, .gradebook td:first-child { position: sticky; left: 0; z-index: 2; background: var(--surface); text-align: left; box-shadow: 1px 0 0 var(--border); }
.gradebook thead th:first-child { background: var(--surface-2); z-index: 3; }
.gb-cell { font-size: 13px; font-weight: 600; min-width: 64px; }
.gb-cell.good { background: color-mix(in oklab, var(--good) 11%, var(--surface)); }
.gb-cell.warning { background: color-mix(in oklab, var(--warning) 18%, var(--surface)); }
.gb-cell.critical { background: color-mix(in oklab, var(--critical) 10%, var(--surface)); color: color-mix(in oklab, var(--critical) 75%, var(--text)); font-size: 11.5px; }
.gb-cell.brand { color: var(--brand); }
.gb-cell.late { font-style: italic; }
.gb-key { width: 12px; height: 12px; border-radius: 3px; display: inline-block; border: 1px solid var(--border); }
.gb-key.good { background: color-mix(in oklab, var(--good) 22%, var(--surface)); }
.gb-key.warning { background: color-mix(in oklab, var(--warning) 32%, var(--surface)); }
.gb-key.critical { background: color-mix(in oklab, var(--critical) 20%, var(--surface)); }
button.chip-check { font: inherit; font-size: 13px; font-weight: 600; }

/* ==========================================================================
   Registration wizard (public page)
   ========================================================================== */
.reg-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 24px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 20; }
.reg-top .brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 16px; }
.reg-wrap { max-width: 880px; margin: 0 auto; padding: 28px 20px 80px; }
.stepper { display: flex; gap: 6px; margin: 18px 0 20px; counter-reset: step; }
.stepper li { list-style: none; flex: 1 1 0; min-width: 0; }
.stepper button { width: 100%; border: 0; background: none; padding: 0; text-align: left; cursor: pointer; color: var(--text-3); font-weight: 600; font-size: 12.5px; display: flex; flex-direction: column; gap: 8px; }
.stepper button:disabled { cursor: default; }
.stepper .bar { height: 4px; border-radius: 999px; background: var(--border); }
.stepper .lbl { display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stepper .num { width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; background: var(--surface-3); color: var(--text-2); flex: 0 0 20px; }
.stepper li.done .bar, .stepper li.current .bar { background: var(--brand); }
.stepper li.done .num { background: var(--brand); color: var(--brand-ink); }
.stepper li.current { color: var(--text); }
.stepper li.current button { color: var(--text); }
.stepper li.current .num { background: var(--brand-soft); color: var(--brand-text); box-shadow: 0 0 0 2px var(--brand); }
.wiz-card { padding: 24px; }
.wiz-card h2 { font-size: 20px; }
.wiz-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 24px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.child-block { border: 1px solid var(--border); border-radius: 12px; padding: 16px; background: var(--surface-2); }
.child-block + .child-block { margin-top: 12px; }
.sess-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 10px; }
.sess-opt { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface); cursor: pointer; text-align: left; font: inherit; color: inherit; }
.sess-opt:hover { border-color: color-mix(in oklab, var(--brand) 45%, var(--border)); }
.sess-opt[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-softer); box-shadow: 0 0 0 3px var(--ring); }
.sess-opt .rank-badge { position: absolute; top: 10px; right: 10px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; background: var(--brand); color: var(--brand-ink); }
.review-block { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.review-block + .review-block { margin-top: 12px; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.timeline li { display: flex; gap: 12px; }
.timeline .dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-text); flex: 0 0 28px; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-7, .span-5, .span-8, .span-4 { grid-column: span 12; }
  .topbar .search { width: 220px; }
  .topbar .search kbd { display: none; }
}
/* tablets & small laptops: compact list tables so they fit without sideways scrolling */
@media (min-width: 641px) and (max-width: 1280px) {
  :root { --sidebar-w: 248px; }
  .table.stack-sm th, .table.stack-sm td { padding-left: 10px; padding-right: 10px; }
  .table.stack-sm th:first-child, .table.stack-sm td:first-child { padding-left: 16px; }
  .table.stack-sm .cell-person { min-width: 150px; }
  .table.stack-sm td.nowrap, .table.stack-sm td .nowrap { white-space: normal; }
  table:has(#stBody) tr > :nth-child(5),
  table:has(#pyBody) tr > :nth-child(4),
  table:has(#asBody) tr > :nth-child(5),
  table:has(#sfBody) tr > :nth-child(6) { display: none; }
}
@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(300px, 86vw); transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .sb-backdrop { display: block; }
  .menu-toggle { display: grid; }
  .loc-pop { right: 12px; }
  .topbar { padding: 0 16px; }
  .topbar .search { display: none; }
  .content { padding: 16px; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-hero { display: none; }
  .auth-top .mobile-brand { display: flex; }
  .auth-panel { padding: 20px 16px; }
  .settings { grid-template-columns: minmax(0, 1fr); }
  .settings-nav { position: static; flex-direction: row; overflow-x: auto; scrollbar-width: none; }
  .settings-nav button { white-space: nowrap; flex: 0 0 auto; }
  .stepper .lbl span:last-child { display: none; }
  .reg-top { padding: 12px 16px; }
}
@media (max-width: 640px) {
  .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .topbar .crumbs .parent, .topbar .crumbs .sep { display: none; }
  .year-chip .label-long { display: none; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
  .page-head h1 { font-size: 21px; }
  .toolbar .select { flex: 1 1 140px; min-width: 0; }
  .toolbar .input-icon { max-width: none; }
  .roster-row { flex-wrap: wrap; }
  .roster-row .seg { width: 100%; justify-content: space-between; }
  .roster-row .seg button { flex: 1; }
  .roster-row .hist { display: none; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .brand-preview { grid-template-columns: 80px 1fr; }
  .wiz-card { padding: 18px; }
  .wiz-foot { padding: 14px 18px; }

  /* list tables become stacked cards */
  .table.stack-sm thead { display: none; }
  .table.stack-sm, .table.stack-sm tbody { display: block; width: 100%; }
  .table.stack-sm tr { display: block; padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .table.stack-sm tbody tr:last-child { border-bottom: 0; }
  .table.stack-sm td { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 4px 0; border: 0; text-align: right; min-height: 26px; }
  .table.stack-sm td::before { content: attr(data-label); flex: 0 0 auto; font-size: 12px; font-weight: 600; color: var(--text-3); text-align: left; padding-top: 3px; }
  .table.stack-sm td:empty, .table.stack-sm td[data-label=""]::before { display: none; }
  .table.stack-sm td:first-child { display: block; text-align: left; padding: 0 0 8px; }
  .table.stack-sm td:first-child::before, .table.stack-sm td[colspan]::before { display: none; }
  .table.stack-sm td[colspan] { display: block; }
  .table.stack-sm td.num { text-align: right; }
  .table.stack-sm .cv { min-width: 0; }
  .table.stack-sm .chip-row, .table.stack-sm .cv .hstack { justify-content: flex-end; }
  .table.stack-sm .cell-person { min-width: 0; }
  .table.stack-sm .nowrap { white-space: normal; }
  .table-wrap:has(> .stack-sm) { overflow: visible; }

  .list-item.wrap-sm { flex-wrap: wrap; }
  .list-item.wrap-sm .li-main { flex: 1 1 calc(100% - 60px); }
  .list-item.wrap-sm > .badge { margin-left: 56px; }
  .list-item.wrap-sm > .btn { margin-left: auto; }
  .doc { flex-wrap: wrap; }
  .doc > .grow { flex: 1 1 140px; }
  .drawer-foot { gap: 6px; }
  .drawer-foot .btn { flex: 1 1 auto; }
  .drawer-foot .grow { display: none; }
  .page-head > .hstack { width: 100%; }
  .pager { justify-content: center; }
  .stat .stat-value { font-size: 24px; }
  .class-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 400px) {
  .content { padding: 12px; }
  .topbar { padding: 0 10px; gap: 6px; }
  .year-chip { padding: 0 9px; }
  .year-chip .dot { display: none; }
  .drawer-head { padding: 16px; }
  .drawer-body { padding: 14px 16px 20px; }
  .drawer-foot { padding: 12px 16px; }
  .card-header { padding: 14px 14px 0; }
  .card-body { padding: 14px; }
  .toolbar { padding: 12px; }
  .seg button { padding: 0 8px; }
  .otp { gap: 6px; }
  .otp input { height: 46px; font-size: 19px; }
}
@media (min-width: 1680px) {
  .content { max-width: 1560px; }
  :root { --sidebar-w: 288px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
