/* Attendance Desk — calm, dense data tool. Light + dark via tokens; mobile-first adjustments at the end. */
:root {
  --bg: #f5f5f1;
  --panel: #ffffff;
  --panel-2: #fafaf7;
  --hover: #f0efea;
  --line: #e6e4dd;
  --line-strong: #d2d0c6;
  --text: #1b1b18;
  --muted: #696860;
  --faint: #9b998f;
  --accent: #2f5bd3;
  --accent-ink: #ffffff;
  --accent-soft: #e9eefc;
  --ok: #1b7a45;
  --ok-bg: #e2f3e8;
  --mid: #9a6100;
  --mid-bg: #fcf0d6;
  --low: #b42318;
  --low-bg: #fde6e2;
  --pending: #7a3fc4;
  --pending-bg: #f1e8fd;
  --heat-0: #ecebe5;
  --heat-1: #d4ddfa;
  --heat-2: #9fb4f2;
  --heat-3: #5f83e6;
  --heat-4: #2f5bd3;
  --shadow: 0 1px 2px rgb(20 20 10 / 0.05), 0 1px 1px rgb(20 20 10 / 0.03);
  --shadow-lg: 0 12px 40px rgb(20 20 10 / 0.16);
  --radius: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --tabbar-h: 0px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121211; --panel: #1a1a18; --panel-2: #1f1f1c; --hover: #262622; --line: #2c2c28; --line-strong: #3d3d38;
    --text: #ecebe6; --muted: #a3a29a; --faint: #75746d;
    --accent: #7c9bff; --accent-ink: #0d1430; --accent-soft: #1f2741;
    --ok: #5cc98a; --ok-bg: #16301f; --mid: #e7b04b; --mid-bg: #33280f; --low: #f2786b; --low-bg: #3a1a16;
    --pending: #b994f5; --pending-bg: #2b2140;
    --heat-0: #24241f; --heat-1: #22305a; --heat-2: #33498a; --heat-3: #5671c8; --heat-4: #8aa5ff;
    --shadow: none; --shadow-lg: 0 12px 40px rgb(0 0 0 / 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121211; --panel: #1a1a18; --panel-2: #1f1f1c; --hover: #262622; --line: #2c2c28; --line-strong: #3d3d38;
  --text: #ecebe6; --muted: #a3a29a; --faint: #75746d;
  --accent: #7c9bff; --accent-ink: #0d1430; --accent-soft: #1f2741;
  --ok: #5cc98a; --ok-bg: #16301f; --mid: #e7b04b; --mid-bg: #33280f; --low: #f2786b; --low-bg: #3a1a16;
  --pending: #b994f5; --pending-bg: #2b2140;
  --heat-0: #24241f; --heat-1: #22305a; --heat-2: #33498a; --heat-3: #5671c8; --heat-4: #8aa5ff;
  --shadow: none; --shadow-lg: 0 12px 40px rgb(0 0 0 / 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--text); min-height: 100vh;
  font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 21px; line-height: 1.25; }
h2 { font-size: 15px; }
h3 { font-size: 12px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; }
h3.sub { margin: 14px 0 6px; }
p { margin: 0 0 8px; }
.num, td.num, .tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.thin { font-weight: 450; }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap, .wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.hidden { display: none !important; }
.txt-ok { color: var(--ok); } .txt-mid { color: var(--mid); } .txt-low { color: var(--low); } .txt-none { color: var(--faint); } .txt-pending { color: var(--pending); }
kbd { font: 11px var(--mono); padding: 1px 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; background: var(--panel-2); color: var(--muted); }

.ico { width: 18px; height: 18px; flex: none; }
.ico.inline { width: 14px; height: 14px; vertical-align: -2px; }
.ico.big { width: 40px; height: 40px; color: var(--faint); margin-bottom: 8px; }
.ico.faint { color: var(--faint); }

/* ── layout ─────────────────────────────────────────── */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; overscroll-behavior: contain;
  border-right: 1px solid var(--line); background: var(--panel-2); padding: 14px 10px 24px;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 9px; padding: 4px 8px 14px; font-weight: 700; color: var(--text); }
a.brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-size: 14px; font-weight: 750; }
.nav-group { margin-top: 16px; }
.nav-label { padding: 0 10px 4px; font-size: 11px; font-weight: 650; color: var(--faint); text-transform: uppercase; letter-spacing: 0.06em; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; color: var(--text); font-size: 13.5px; }
.nav a .ico { width: 17px; height: 17px; color: var(--muted); }
.nav a:hover { background: var(--hover); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a.active .ico { color: var(--accent); }
.nav .count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cls-dot { width: 8px; height: 8px; border-radius: 50%; margin: 0 4.5px; background: var(--faint); }
.cls-dot.ok { background: var(--ok); } .cls-dot.mid { background: var(--mid); } .cls-dot.low { background: var(--low); }
.badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--pending); color: #fff; font-size: 11px; font-weight: 700; }
.badge.low { background: var(--low); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 10px 24px; background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.content { padding: 20px 24px 64px; max-width: 1600px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head > div:first-child { min-width: 0; }
.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumbs a { color: var(--muted); }
.section-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.mobile-only { display: none !important; }
.scrim { display: none; }
.tabbar { display: none; }

/* ── top bar pieces ─────────────────────────────────── */
.search-trigger {
  display: flex; align-items: center; gap: 8px; flex: 0 1 420px; min-width: 0; height: 36px; padding: 0 8px 0 11px;
  border: 1px solid var(--line-strong); border-radius: 9px; background: var(--panel); color: var(--faint); cursor: pointer; font: inherit; text-align: left;
}
.search-trigger:hover { border-color: var(--faint); }
.search-trigger .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sync-chip {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 11px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--text); font: 600 12.5px var(--font); white-space: nowrap;
}
.sync-chip .ico { width: 15px; height: 15px; }
.sync-chip.ok { border-color: color-mix(in srgb, var(--ok) 45%, transparent); color: var(--ok); background: var(--ok-bg); }
.sync-chip.pending { border-color: color-mix(in srgb, var(--pending) 45%, transparent); color: var(--pending); background: var(--pending-bg); }
.sync-chip.low { border-color: var(--low); color: var(--low); background: var(--low-bg); }
.sync-chip.accent { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent;
  color: var(--muted); cursor: pointer; flex: none;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.icon-btn.danger:hover { color: var(--low); background: var(--low-bg); }
.pill-link { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--text); font-size: 12.5px; background: var(--panel); white-space: nowrap; }
.pill-link:hover { text-decoration: none; border-color: var(--faint); }

/* ── controls ───────────────────────────────────────── */
input, select, textarea, button { font: inherit; color: inherit; }
input[type="text"], input[type="search"], input[type="number"], input[type="date"], input[type="password"], select, textarea {
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 8px; padding: 6px 10px; min-height: 36px; outline: none; min-width: 0;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 60px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); font-weight: 550; min-width: 0; }
label.field > input, label.field > select, label.field > textarea { color: var(--text); font-weight: 400; font-size: 14px; width: 100%; }
label.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--accent); }
.field-label { font-size: 12.5px; color: var(--muted); font-weight: 550; margin-bottom: 4px; }
.input-ico { position: relative; display: flex; align-items: center; }
.input-ico .ico { position: absolute; left: 10px; width: 16px; height: 16px; color: var(--faint); pointer-events: none; }
.input-ico input { padding-left: 32px; width: 100%; }
.grow-sm { flex: 0 1 300px; min-width: 180px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
  min-height: 36px; padding: 0 14px; border-radius: 8px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line-strong); font-weight: 600; font-size: 13.5px; color: var(--text);
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
}
.btn .ico { width: 16px; height: 16px; }
.btn:hover { background: var(--panel-2); border-color: var(--faint); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--low); }
.btn.danger.solid { background: var(--low); border-color: var(--low); color: #fff; }
.btn.ok { color: var(--ok); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: 12.5px; }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 9px; padding: 2px; background: var(--panel); flex: none; }
.seg button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; padding: 5px 11px; border-radius: 7px; cursor: pointer; font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.seg button .ico { width: 15px; height: 15px; }
.seg button.on { background: var(--accent-soft); color: var(--accent); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips-scroll { display: flex; overflow-x: auto; scrollbar-width: none; min-width: 0; max-width: 100%; }
.chips-scroll::-webkit-scrollbar { display: none; }
.chips-scroll .chips { flex-wrap: nowrap; }
.fchip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--panel); color: var(--text); font-size: 13px; font-weight: 550; cursor: pointer; white-space: nowrap; }
.fchip .n { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 500; }
.fchip.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.fchip.on .n { color: inherit; opacity: 0.7; }
.check-chip input { width: 14px; height: 14px; }
.check-chip:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ── panels, KPIs, stats ────────────────────────────── */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.panel-body { padding: 14px; }
.panel.empty, .empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.panel.empty h2 { color: var(--text); margin-bottom: 6px; }
.empty-mini { display: flex; align-items: center; gap: 8px; padding: 18px 14px; color: var(--muted); font-size: 13.5px; }
.empty-mini .ico { color: var(--ok); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 22px; }
.kpi { padding: 14px 16px; }
.kpi .label { font-size: 12.5px; color: var(--muted); }
.kpi .value { display: flex; align-items: center; gap: 6px; font-size: 26px; font-weight: 680; font-variant-numeric: tabular-nums; margin: 2px 0 4px; letter-spacing: -0.02em; }
.kpi .value .ico { width: 22px; height: 22px; color: var(--ok); }
.kpi.pending { border-color: color-mix(in srgb, var(--pending) 40%, var(--line)); }
.meta { font-size: 12.5px; color: var(--muted); }
.stat-row { display: flex; gap: 10px; margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.stat-row::-webkit-scrollbar { display: none; }
.stat { flex: 1 0 auto; min-width: 110px; padding: 10px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.stat span { display: block; font-size: 12px; color: var(--muted); }
.stat b { font-size: 19px; font-weight: 680; font-variant-numeric: tabular-nums; }
.stat b small { font-size: 13px; color: var(--muted); font-weight: 500; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 16px; align-items: start; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; margin: 0; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.kv-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 0 4px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.legend { display: inline-flex; gap: 10px; font-size: 12px; color: var(--muted); align-items: center; flex-wrap: wrap; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; vertical-align: 0; }

/* ── generic list rows ─────────────────────────────── */
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); min-width: 0; color: var(--text); }
.list-row.top { align-items: flex-start; }
.list-row:last-child { border-bottom: 0; }
a.list-row:hover, .list-row a.plain:hover { text-decoration: none; }
a.list-row:hover { background: var(--panel-2); }
.lr-main { display: flex; flex-direction: column; min-width: 0; }
.lr-main > * { overflow: hidden; text-overflow: ellipsis; }
.lr-main b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row > a.grow { display: flex; align-items: center; gap: 12px; min-width: 0; }
a.plain { color: inherit; }
a.plain:hover { text-decoration: none; }
.avatar { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; flex: none; font-size: 12.5px; font-weight: 700; background: var(--hover); color: var(--muted); }
.avatar .ico { width: 17px; height: 17px; }
.avatar.ok { background: var(--ok-bg); color: var(--ok); } .avatar.mid { background: var(--mid-bg); color: var(--mid); } .avatar.low { background: var(--low-bg); color: var(--low); }
.date-badge { display: flex; flex-direction: column; align-items: center; width: 42px; flex: none; padding: 4px 0; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); line-height: 1.1; }
.date-badge b { font-size: 16px; } .date-badge small { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.mini-list { border: 1px solid var(--line); border-radius: 8px; }
.mini-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); color: var(--text); font-size: 13px; }
.mini-row:last-child { border-bottom: 0; }

/* ── overview ───────────────────────────────────────── */
.ov-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.class-card { display: flex; gap: 14px; align-items: center; padding: 14px; color: var(--text); transition: border-color 0.12s, transform 0.12s; }
.class-card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.bands { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--line); margin: 7px 0; }
.bands span { display: block; height: 100%; }
.bands .low { background: var(--low); } .bands .mid { background: var(--mid); } .bands .ok { background: var(--ok); }

/* ring gauge */
.ring { position: relative; display: inline-grid; place-items: center; flex: none; }
.ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; }
.ring .track { stroke: var(--line); }
.ring .val { stroke: var(--faint); stroke-linecap: round; transition: stroke-dasharray 0.4s; }
.ring.ok .val { stroke: var(--ok); } .ring.mid .val { stroke: var(--mid); } .ring.low .val { stroke: var(--low); }
.ring .tick { stroke: var(--text); stroke-width: 2.5; opacity: 0.45; transform-origin: 50% 50%; }
.ring svg .tick { transform: none; }
.ring-label { position: relative; display: flex; align-items: baseline; font-variant-numeric: tabular-nums; }
.ring-label b { font-weight: 700; letter-spacing: -0.03em; }
.ring-label small { font-size: 0.55em; color: var(--muted); margin-left: 1px; }

/* meter */
.meter { position: relative; display: block; height: 7px; border-radius: 4px; background: var(--line); overflow: visible; margin: 8px 0 6px; }
.meter .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--faint); }
.meter .extra { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(45deg, var(--accent), var(--accent) 3px, transparent 3px, transparent 5px); opacity: 0.8; }
.meter.ok .fill { background: var(--ok); } .meter.mid .fill { background: var(--mid); } .meter.low .fill { background: var(--low); }
.meter .mark { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--text); opacity: 0.5; border-radius: 1px; }

/* ── percentage tags, chips, toggles ────────────────── */
.pct { display: inline-block; min-width: 48px; padding: 2px 7px; border-radius: 6px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; position: relative; flex: none; }
.pct.ok { background: var(--ok-bg); color: var(--ok); }
.pct.mid { background: var(--mid-bg); color: var(--mid); }
.pct.low { background: var(--low-bg); color: var(--low); }
.pct.none { color: var(--faint); background: transparent; }
.pct.adj::after { content: "+"; position: absolute; top: -6px; right: -4px; font-size: 10px; font-weight: 800; color: var(--accent); }
.pct.pend { box-shadow: inset 0 0 0 1.5px var(--pending); }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--hover); color: var(--muted); flex: none; }
.chip .ico { width: 12px; height: 12px; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.low { background: var(--low-bg); color: var(--low); }
.chip.mid { background: var(--mid-bg); color: var(--mid); }
.chip.pending { background: var(--pending-bg); color: var(--pending); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
a.chip:hover { text-decoration: none; filter: brightness(0.97); }

.toggle {
  display: inline-flex; align-items: center; gap: 5px; min-width: 104px; height: 34px; justify-content: center;
  padding: 0 12px; border-radius: 999px; border: 1.5px solid transparent; cursor: pointer; font-size: 13px; font-weight: 650;
  transition: background 0.12s, transform 0.06s;
}
.toggle .ico { width: 15px; height: 15px; stroke-width: 2.4; }
.toggle:active { transform: scale(0.96); }
.toggle.p { background: var(--ok-bg); color: var(--ok); }
.toggle.a { background: var(--low-bg); color: var(--low); }
.toggle.staged { border-color: var(--pending); border-style: dashed; }
.toggle .was { font-weight: 500; opacity: 0.7; text-decoration: line-through; font-size: 11.5px; }
.toggle:disabled { cursor: not-allowed; opacity: 0.6; }

/* ── tables ─────────────────────────────────────────── */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); -webkit-overflow-scrolling: touch; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13.5px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--panel-2); position: sticky; top: 0; z-index: 2; white-space: nowrap; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th.sorted::after { content: " ↓"; } th.sorted.asc::after { content: " ↑"; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
.matrix { max-height: calc(100vh - 260px); }
.matrix th, .matrix td { padding: 6px 8px; }
.matrix .sticky-1 { position: sticky; left: 0; z-index: 1; background: var(--panel); min-width: 112px; }
.matrix .sticky-2 { position: sticky; left: 112px; z-index: 1; background: var(--panel); box-shadow: 1px 0 0 var(--line); }
.matrix th.sticky-1, .matrix th.sticky-2 { z-index: 3; background: var(--panel-2); }
.matrix td.name { max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.matrix th.subj { text-align: center; }
.matrix th.subj .subj-name { display: block; max-width: 96px; margin: 0 auto; overflow: hidden; text-overflow: ellipsis; }
.matrix th.subj small { display: block; font-weight: 500; color: var(--faint); font-size: 10.5px; }
.matrix th.sep, .matrix td.sep { border-left: 1px solid var(--line-strong); }
td.cell { text-align: center; cursor: pointer; }
td.cell:hover .pct { outline: 2px solid var(--accent); outline-offset: 1px; }
.batch-links { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; font-size: 13px; align-items: center; }

/* grid rows (student lectures, lecture roster): a table on desktop, cards on phones */
.rows { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; overflow: clip; }
.rows .rh, .rows .r { display: grid; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.rows .rh { background: var(--panel-2); font-size: 12px; font-weight: 600; color: var(--muted); position: sticky; top: 57px; z-index: 2; }
.rows .r:last-child { border-bottom: 0; }
.rows .r.selected { background: var(--accent-soft); }
.rows .r.changed { background: color-mix(in srgb, var(--pending-bg) 55%, transparent); }
.rows .r.not-counted > :not(.cb) { opacity: 0.55; }
.lec-rows .rh, .lec-rows .r { grid-template-columns: 28px 150px minmax(120px, 1fr) 150px minmax(0, 1.2fr); }
.roster-rows .r { grid-template-columns: 32px minmax(0, 1fr) minmax(0, 1fr) auto; }
.r-date, .r-subj, .r-who { display: flex; flex-direction: column; min-width: 0; }
.r-who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-toggle { display: flex; align-items: center; gap: 6px; }
.cb { display: grid; place-items: center; }

/* ── student page ───────────────────────────────────── */
.student-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; margin-top: 16px; }
.hero { display: flex; align-items: center; gap: 20px; padding: 18px; flex-wrap: wrap; }
.hero-main { min-width: 220px; }
.hero h1 { font-size: 21px; }
.breakdown { display: flex; gap: 10px 26px; margin-top: 10px; flex-wrap: wrap; }
.breakdown span { display: block; font-size: 12px; color: var(--muted); }
.breakdown b { font-size: 17px; font-variant-numeric: tabular-nums; }
.subj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.subj-card { display: block; text-align: left; padding: 12px 14px; cursor: pointer; font: inherit; color: var(--text); transition: border-color 0.12s; }
.subj-card:hover { border-color: var(--faint); }
.subj-card.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.bulkbar { display: none; align-items: center; gap: 8px; padding: 8px 10px 8px 14px; margin-bottom: 10px; border-radius: 10px; background: var(--text); color: var(--bg); position: sticky; top: 64px; z-index: 5; }
.bulkbar.show { display: flex; }
.bulkbar .btn { background: var(--panel); }
.bulkbar .icon-btn { color: var(--bg); }
.adj-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.adj-item:last-child { border-bottom: 0; }
.adj-item .pts, .pts-badge { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; min-width: 54px; }
.preview { padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); font-size: 13px; min-height: 40px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid .full { grid-column: 1 / -1; }
details.fold > summary { list-style: none; cursor: pointer; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold .fold-ico { transition: transform 0.15s; color: var(--muted); }
details.fold[open] .fold-ico { transform: rotate(90deg); }
details.fold:not([open]) > summary.panel-head { border-bottom: 0; }

/* ── banners ────────────────────────────────────────── */
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--radius); margin-bottom: 14px; font-size: 13.5px; flex-wrap: wrap; }
.banner > .ico { margin-top: 1px; }
.banner > div { flex: 1; min-width: 200px; }
.banner.warn { background: var(--mid-bg); color: var(--mid); }
.banner.info { background: var(--accent-soft); color: var(--accent); }
.banner.err { background: var(--low-bg); color: var(--low); }
.banner.pending { background: var(--pending-bg); color: var(--pending); }
.banner a { color: inherit; text-decoration: underline; }
.group { margin-bottom: 14px; }
.panel.group.has-failed { border-color: color-mix(in srgb, var(--low) 50%, var(--line)); }
.arrow { color: var(--faint); margin: 0 3px; }
.mode-panel { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 14px; }
.mode-panel.flat { padding: 0; margin: 0; }
.mode-ico { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--pending-bg); color: var(--pending); flex: none; }
.mode-ico.live { background: var(--ok-bg); color: var(--ok); }

/* ── status dot ─────────────────────────────────────── */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.dot.warn { background: var(--mid); }
.dot.err { background: var(--low); }

/* ── accounts ───────────────────────────────────────── */
.acc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: 12px; align-items: start; }
.account { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.account.off { opacity: 0.6; }
.account.add { border-style: dashed; }
.acc-top { display: flex; align-items: center; gap: 12px; }
.acc-top .state { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.acc-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.acc-actions { border-top: 1px solid var(--line); padding-top: 10px; }

/* ── calendar ───────────────────────────────────────── */
.cal-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, 1fr); gap: 16px; align-items: start; margin-top: 14px; }
.cal-nav { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.cal-title { font-weight: 700; font-size: 16px; margin: -36px 0 12px 44px; pointer-events: none; height: 24px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.cal-wd { font-size: 11.5px; color: var(--faint); text-align: center; font-weight: 600; padding-bottom: 2px; }
.cal-cell {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; aspect-ratio: 1 / 0.92;
  padding: 6px 7px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; font: inherit; color: var(--text); min-width: 0; text-align: left;
}
.cal-cell.pad { border: 0; background: transparent; cursor: default; }
.cal-cell:disabled { cursor: default; background: transparent; border-style: dashed; opacity: 0.55; }
.cal-cell .d { font-size: 12px; font-weight: 600; color: var(--muted); }
.cal-cell .v { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.cal-cell .s { display: flex; gap: 4px; align-items: center; font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; max-width: 100%; }
.cal-cell .s i, .dotl { display: inline-block; width: 6px; height: 6px; border-radius: 50%; }
.st { background: var(--pending); } .pu { background: var(--ok); }
.cal-cell.zero { background: var(--panel); }
.cal-cell.u1 { background: var(--heat-1); border-color: transparent; }
.cal-cell.u2 { background: var(--heat-2); border-color: transparent; }
.cal-cell.u3 { background: var(--heat-3); border-color: transparent; color: #fff; }
.cal-cell.u4 { background: var(--heat-4); border-color: transparent; color: #fff; }
.cal-cell.u3 .d, .cal-cell.u4 .d, .cal-cell.u3 .s, .cal-cell.u4 .s { color: rgb(255 255 255 / 0.85); }
.cal-cell.failed { box-shadow: inset 0 0 0 2px var(--low); }
.cal-cell.att-ok { background: var(--ok-bg); } .cal-cell.att-mid { background: var(--mid-bg); } .cal-cell.att-low { background: var(--low-bg); }
.cal-cell.att-ok .v { color: var(--ok); } .cal-cell.att-mid .v { color: var(--mid); } .cal-cell.att-low .v { color: var(--low); }
.cal-cell.today .d { color: var(--accent); text-decoration: underline; }
.cal-cell.sel { outline: 2.5px solid var(--text); outline-offset: 1px; }
.cal-cell:not(:disabled):not(.pad):hover { filter: brightness(0.96); }
.strip-panel { margin-bottom: 0; }
.strip-wrap { overflow-x: auto; scrollbar-width: thin; padding-bottom: 2px; }
.strip { display: flex; gap: 3px; width: max-content; }
.strip-col { display: flex; flex-direction: column; gap: 3px; }
.strip-m { height: 14px; font-size: 10.5px; color: var(--faint); white-space: nowrap; width: 13px; overflow: visible; }
.strip-cell { width: 13px; height: 13px; border-radius: 3px; border: 0; padding: 0; background: var(--heat-0); cursor: pointer; }
.strip-cell:disabled { background: transparent; box-shadow: inset 0 0 0 1px var(--line); cursor: default; }
.strip-cell.zero { background: var(--heat-0); }
.strip-cell.u1, .lg.u1, .cw-cell.u1 { background: var(--heat-1); }
.strip-cell.u2, .lg.u2, .cw-cell.u2 { background: var(--heat-2); }
.strip-cell.u3, .lg.u3, .cw-cell.u3 { background: var(--heat-3); color: #fff; }
.strip-cell.u4, .lg.u4, .cw-cell.u4 { background: var(--heat-4); color: #fff; }
.strip-cell.att-ok, .lg.att-ok, .cw-cell.att-ok { background: var(--ok); opacity: 0.75; }
.strip-cell.att-mid, .lg.att-mid, .cw-cell.att-mid { background: var(--mid); opacity: 0.75; }
.strip-cell.att-low, .lg.att-low, .cw-cell.att-low { background: var(--low); opacity: 0.75; }
.strip-cell.failed { box-shadow: inset 0 0 0 2px var(--low); }
.strip-cell.sel { outline: 2px solid var(--text); outline-offset: 1px; }
.legend .lg { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin: 0; }
.legend .dotl { margin-right: 4px; }
.day-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.day-tags { margin-bottom: 10px; }
.by-class { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; margin-bottom: 12px; }
.bc { display: flex; flex-wrap: wrap; gap: 2px 6px; align-items: baseline; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); font-size: 13px; }
.bc:hover { border-color: var(--accent); text-decoration: none; }
.day-list { display: flex; flex-direction: column; gap: 6px; }
.day-lec { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; }
.day-lec:hover { border-color: var(--faint); }
.day-lec .grow { display: flex; flex-direction: column; min-width: 0; }
.day-lec.not-counted { opacity: 0.55; }
.day-n { display: flex; gap: 4px; align-items: center; font-variant-numeric: tabular-nums; }
.cw-wrap { overflow-x: auto; }
table.cw { width: auto; border-spacing: 3px; border-collapse: separate; }
table.cw th, table.cw td { padding: 0; border: 0; background: transparent; position: static; font-size: 11px; }
table.cw th { color: var(--faint); font-weight: 500; text-align: left; height: 18px; }
.cw-name { padding-right: 10px !important; white-space: nowrap; font-size: 13px !important; }
.cw-cell { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 5px; background: var(--heat-0); color: var(--text); font-size: 10.5px; font-weight: 700; }
.cw-cell:hover { outline: 2px solid var(--text); text-decoration: none; }
.cw-cell.none { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }

/* student calendar */
.scal { padding: 12px; }
.scal-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 2px 2px 10px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.scal-head .grow { min-width: 200px; }
.scal-head .meter { margin: 6px 0 0; }
.scal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.scal-cell { min-height: 92px; border: 1px solid var(--line); border-radius: 8px; padding: 4px; background: var(--panel-2); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.scal-cell.pad { border: 0; background: transparent; }
.scal-cell.empty { background: transparent; border-style: dashed; opacity: 0.55; }
.scal-cell.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.scal-d { display: flex; justify-content: space-between; align-items: baseline; gap: 4px; border: 0; background: transparent; padding: 1px 3px; border-radius: 5px; cursor: pointer; font: 600 12px var(--font); color: var(--muted); width: 100%; }
.scal-d:disabled { cursor: default; }
.scal-d:not(:disabled):hover { background: var(--hover); color: var(--text); }
.scal-d small { font-size: 10.5px; font-weight: 700; }
.scal-chips { display: flex; flex-wrap: wrap; gap: 3px; }
.lchip { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 26px; padding: 0 5px; border-radius: 6px; border: 1.5px solid transparent; font: 700 11px var(--font); cursor: pointer; letter-spacing: 0.02em; }
.lchip sub { font-size: 8.5px; margin-left: 1px; }
.lchip.p { background: var(--ok-bg); color: var(--ok); }
.lchip.a { background: var(--low-bg); color: var(--low); }
.lchip.staged { border-color: var(--pending); border-style: dashed; }
.lchip.picked { outline: 2px solid var(--accent); outline-offset: 1px; }
.lchip.nc { opacity: 0.5; }
.lchip:active { transform: scale(0.94); }
.lchip:disabled { opacity: 0.5; cursor: not-allowed; }
.scal-legend { margin-top: 10px; }
.legend i.dash { background: transparent; border: 1.5px dashed var(--pending); width: 10px; height: 10px; }
.scal-key { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; }

/* ── auto-fill dialog ───────────────────────────────── */
.af-opts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 12px 0; }
.af-adv { margin-bottom: 12px; border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; }
.af-adv > summary { cursor: pointer; font-size: 13px; color: var(--muted); font-weight: 600; }
.af-adv-body { display: flex; flex-direction: column; gap: 12px; padding-top: 12px; }
.af-adv-body .chips { margin-bottom: 6px; }
.af-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.af-summary > div { padding: 10px 12px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line); }
.af-summary b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.af-summary span { font-size: 12px; color: var(--muted); }
.af-summary .warn { background: var(--mid-bg); border-color: transparent; } .af-summary .warn b { color: var(--mid); }
.af-student { border: 1px solid var(--line); border-radius: 9px; margin-bottom: 8px; }
.af-student > summary { display: flex; align-items: center; gap: 8px; padding: 9px 12px; cursor: pointer; flex-wrap: wrap; }
.af-student[open] > summary { border-bottom: 1px solid var(--line); }
.af-student > :not(summary) { margin: 8px 12px; }
.af-delta { display: inline-flex; align-items: center; }
.af-goals { display: flex; flex-wrap: wrap; gap: 6px; }
.picks { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px; max-height: 320px; overflow: auto; }
.pick { display: grid; grid-template-columns: 22px 120px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 7px 10px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13px; }
.pick:last-child { border-bottom: 0; }
.pick.small { background: color-mix(in srgb, var(--mid-bg) 60%, transparent); }
.pick:has(input:not(:checked)) { opacity: 0.5; }
.pick-subj { display: flex; flex-direction: column; min-width: 0; }
.pick-subj small { color: var(--muted); }
.pick-n { display: inline-flex; gap: 4px; align-items: center; font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pick-n.warn { color: var(--mid); font-weight: 600; }
.pick-n .ico { width: 14px; height: 14px; }

/* ── progress / toast / dialog / palette ────────────── */
.progress { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); transition: width 0.3s; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; align-items: flex-end; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 12px; background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; font-size: 13.5px; max-width: 440px; box-shadow: var(--shadow-lg); animation: toast-in 0.18s ease-out; pointer-events: auto; }
.toast button { border: 0; background: transparent; color: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; padding: 0; white-space: nowrap; }
.toast.err { background: var(--low); color: #fff; }
.toast.warn { background: var(--mid); color: #fff; }
.toast.ok { border-left: 4px solid var(--ok); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }
dialog { border: 1px solid var(--line-strong); border-radius: 14px; padding: 0; background: var(--panel); color: var(--text); width: min(560px, 94vw); max-height: 88vh; box-shadow: var(--shadow-lg); }
dialog.wide { width: min(980px, 96vw); }
dialog::backdrop { background: rgb(10 10 8 / 0.42); }
dialog > form { display: flex; flex-direction: column; max-height: 88vh; }
.dialog-head { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 12px 12px 12px 18px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.dialog-body { padding: 16px 18px; overflow: auto; flex: 1; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.choices { display: grid; gap: 10px; margin-bottom: 12px; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1.5px solid var(--line-strong); border-radius: 11px; cursor: pointer; }
.choice input { margin-top: 3px; }
.choice > span:last-child { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.choice b { font-size: 14px; }
.choice-ico { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--hover); flex: none; color: var(--muted); }
.choice.on { border-color: var(--accent); background: var(--accent-soft); }
.choice.on .choice-ico { background: var(--accent); color: var(--accent-ink); }
.choice.disabled { opacity: 0.5; cursor: not-allowed; }
.palette { width: min(640px, 94vw); max-height: 76vh; margin-top: 9vh; padding: 0; overflow: hidden; }
.palette-box { display: flex; flex-direction: column; max-height: 76vh; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line); }
.palette-input .ico { color: var(--faint); }
.palette-input input { flex: 1; border: 0 !important; box-shadow: none !important; font-size: 16px; padding: 6px 0; background: transparent; }
.palette-results { overflow-y: auto; padding: 6px; flex: 1; overscroll-behavior: contain; }
.pal-group { padding: 8px 10px 4px; font-size: 11px; font-weight: 650; color: var(--faint); text-transform: uppercase; letter-spacing: 0.06em; }
.pal-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.pal-item:hover { background: var(--hover); text-decoration: none; }
.pal-item.sel { background: var(--accent-soft); }
.pal-ico { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--hover); color: var(--muted); flex: none; }
.pal-item.sel .pal-ico { background: var(--accent); color: var(--accent-ink); }
.pal-item .grow { display: flex; flex-direction: column; min-width: 0; }
.pal-label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-empty { padding: 26px 16px; color: var(--muted); text-align: center; font-size: 13.5px; }
.palette-foot { display: flex; gap: 16px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
pre.code { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow: auto; font: 12px/1.5 var(--mono); }
details > summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.loading { padding: 40px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.kbd-row { display: flex; align-items: center; gap: 6px; padding: 4px 0; }
.kbd-row span { color: var(--muted); margin-left: 6px; }

/* ── login ──────────────────────────────────────────── */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(380px, 100%); padding: 28px; text-align: center; }
.pin-boxes { display: flex; gap: 8px; justify-content: center; margin: 22px 0 14px; }
.pin-boxes input { width: 46px; height: 56px; text-align: center; font-size: 24px; font-weight: 650; padding: 0; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--panel-2); font-variant-numeric: tabular-nums; min-width: 0; }
.pin-boxes input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.login-error { min-height: 20px; color: var(--low); font-size: 13.5px; }
.shake { animation: shake 0.35s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* ── responsive ─────────────────────────────────────── */
@media (max-width: 1180px) {
  .ov-grid, .student-grid { grid-template-columns: 1fr; }
  .cal-layout { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  :root { --tabbar-h: calc(60px + env(safe-area-inset-bottom)); }
  .desktop-only { display: none !important; }
  .mobile-only { display: revert !important; }
  .brand.mobile-only, .icon-btn.mobile-only { display: inline-grid !important; }
  .app { grid-template-columns: 1fr; }
  /* Sidebar becomes a slide-in drawer opened from the "More" tab. */
  .sidebar {
    position: fixed; z-index: 60; top: 0; left: 0; bottom: 0; width: min(310px, 86vw); height: auto;
    transform: translateX(-102%); transition: transform 0.22s ease; box-shadow: var(--shadow-lg);
    padding-top: calc(14px + env(safe-area-inset-top)); padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }
  .drawer-open .sidebar { transform: none; }
  .scrim { position: fixed; inset: 0; z-index: 55; background: rgb(10 10 8 / 0.4); opacity: 0; pointer-events: none; transition: opacity 0.2s; display: block; }
  .drawer-open .scrim { opacity: 1; pointer-events: auto; }
  .drawer-open { overflow: hidden; }
  .nav a { padding: 10px 10px; font-size: 15px; }

  .topbar { padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top)); gap: 8px; }
  .topbar .brand { padding: 0; }
  .topbar-title { font-weight: 650; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
  .topbar .grow { display: none; }
  .search-trigger { display: none; }
  .sync-chip { height: 32px; padding: 0 10px; }

  .tabbar {
    display: flex; position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; height: var(--tabbar-h);
    padding-bottom: env(safe-area-inset-bottom); background: color-mix(in srgb, var(--panel) 92%, transparent);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  }
  .tab { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: transparent; color: var(--muted); font: 600 11px var(--font); cursor: pointer; }
  .tab .ico { width: 22px; height: 22px; }
  .tab.active { color: var(--accent); }
  .tab:hover { text-decoration: none; }
  .tab .badge { position: absolute; top: 6px; left: calc(50% + 6px); }
  .tab-search .ico { width: 24px; height: 24px; }
  .tab:focus:not(:focus-visible) { outline: none; }

  .content { padding: 14px 12px calc(var(--tabbar-h) + 28px); }
  .toasts { left: 12px; right: 12px; bottom: calc(var(--tabbar-h) + 10px); align-items: stretch; }
  .toast { max-width: none; }
  h1 { font-size: 19px; }
  .page-head { margin-bottom: 12px; align-items: flex-start; }
  .page-head .row .btn { flex: 1 1 auto; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
  .kpi { padding: 12px; }
  .kpi .value { font-size: 22px; }
  .cards { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .grow-sm { flex: 1 1 100%; }
  .toolbar > input.grow { flex: 1 1 100%; }
  .rows .rh { display: none; }
  .lec-rows .r { grid-template-columns: 26px minmax(0, 1fr) auto; grid-template-areas: "cb date toggle" "cb subj toggle"; row-gap: 2px; padding: 10px 12px; }
  .lec-rows .r > .cb { grid-area: cb; }
  .lec-rows .r > .r-date { grid-area: date; flex-direction: row; gap: 8px; align-items: baseline; }
  .lec-rows .r > .r-subj { grid-area: subj; flex-direction: row; gap: 6px; align-items: baseline; }
  .lec-rows .r > .r-toggle { grid-area: toggle; }
  .roster-rows .r { grid-template-columns: 24px minmax(0, 1fr) auto; padding: 10px 12px; }
  .roster-rows .r-note { grid-column: 2 / 3; grid-row: 2; }
  .roster-rows .r-note:empty { display: none; }
  .roster-rows .r-toggle { grid-column: 3; grid-row: 1 / span 2; }
  .toggle { min-width: 100px; height: 38px; }
  .bulkbar { position: fixed; left: 12px; right: 12px; top: auto; bottom: calc(var(--tabbar-h) + 10px); z-index: 45; box-shadow: var(--shadow-lg); margin: 0; }
  .hero { padding: 14px; gap: 14px; }
  .hero h1 { font-size: 18px; }
  .breakdown { gap: 8px 18px; }
  .breakdown b { font-size: 15px; }
  .subj-grid { grid-template-columns: 1fr; }
  .matrix { max-height: 70vh; }
  .matrix .sticky-1 { min-width: 0; position: static; }
  .matrix .sticky-2 { left: 0; }
  .matrix th.sticky-1, .matrix td.sticky-1 { display: none; }
  .list-row { padding: 11px 12px; gap: 10px; }
  .stat { min-width: 96px; padding: 9px 12px; }
  .stat b { font-size: 17px; }
  .cal-cell { aspect-ratio: 1 / 1.05; padding: 4px; border-radius: 7px; }
  .cal-cell .v { font-size: 12.5px; }
  .cal-cell .s { display: none; }
  .cal-grid { gap: 3px; }
  .cal-title { margin-left: 44px; }
  .af-opts { grid-template-columns: 1fr 1fr; }
  .scal { padding: 8px; }
  .scal-grid { gap: 3px; }
  .scal-cell { min-height: 74px; padding: 2px; border-radius: 6px; }
  .scal-d small { display: none; }
  .scal-chips { gap: 2px; }
  .lchip { min-width: 0; width: 100%; height: 24px; padding: 0 2px; font-size: 9.5px; border-radius: 5px; }
  .scal-legend span.muted { flex-basis: 100%; }
  .af-summary { grid-template-columns: 1fr 1fr; }
  .pick { grid-template-columns: 22px minmax(0, 1fr) auto; }
  .pick-date { grid-column: 2; }
  .pick-subj { grid-column: 2; grid-row: 2; }
  .pick-n { grid-column: 3; grid-row: 1 / span 2; }
  /* Dialogs become bottom sheets. */
  dialog, dialog.wide, .palette { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 16px 16px 0 0; border-bottom: 0; }
  dialog > form, .palette-box { max-height: 92vh; }
  .dialog-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .dialog-foot .btn { flex: 1; }
  .palette { height: 92vh; }
  .palette-box { height: 100%; }
  .kv { grid-template-columns: 1fr; gap: 0 0; }
  .kv dt { margin-top: 6px; font-size: 12px; }
}
@media (max-width: 380px) {
  .sync-chip span:not(.spinner) { display: none; }
  .kpis { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* before → after % on the Unsynced changes page */
.delta { display: inline-flex; align-items: baseline; gap: 4px; white-space: nowrap; font-variant-numeric: tabular-nums; font-size: 13px; }
.delta .arrow { color: var(--muted); }
.delta.lg { font-size: 16px; }
.impact { display: inline-flex; align-items: baseline; gap: 6px; }
.impact-subjects { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; }
.impact-chip { display: inline-flex; align-items: baseline; gap: 6px; padding: 3px 8px; border-radius: 999px; background: var(--hover); font-size: 12px; }
.impact-chip .delta { font-size: 12px; }
@media (max-width: 900px) {
  .list-row .impact { flex-basis: 100%; order: 5; padding-left: 2px; }
}
@media (max-width: 900px) { .list-row:has(.impact) { flex-wrap: wrap; } }
.sub-check { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-weight: 600; color: var(--text); }
.sub-check input { margin: 0; }

/* Students page */
.stu-meter { display: flex; flex-direction: column; gap: 4px; width: 200px; flex: none; }
.stu-meter .meter { width: 100%; }
@media (max-width: 760px) {
  .stu-meter { width: 92px; }
  .stu-meter .muted { display: none; }
}

/* Campaigns */
.title-input { display: block; width: 100%; max-width: 560px; margin-top: 4px; font: inherit; font-size: 22px; font-weight: 700; color: var(--text); background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 2px 6px; margin-left: -7px; }
.title-input:hover { border-color: var(--line); }
.title-input:focus { border-color: var(--accent); outline: none; background: var(--panel); }
.cp-rule .field { max-width: 150px; }
.cp-rule { align-items: flex-end; }
.cp-class select { min-width: 0; flex: 1 1 140px; }
.sugg { max-height: 320px; overflow: auto; margin: 0; }
.sugg .list-row { width: 100%; text-align: left; background: none; border-left: 0; border-right: 0; border-top: 0; cursor: pointer; font: inherit; }
.sugg .list-row:disabled { opacity: .55; cursor: default; }
.fold-plain summary { cursor: pointer; color: var(--muted); font-weight: 600; }

/* class rank badge (#1 = highest attendance) */
.rank { display: inline-block; min-width: 34px; flex: none; text-align: center; padding: 2px 6px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--hover); font-variant-numeric: tabular-nums; }
.rank.top1, .rank.top2, .rank.top3 { color: var(--accent); background: var(--accent-soft); }
.rank.none { background: transparent; color: var(--faint); }
