/* ============================================================
   Kiraan Jadual Waktu — modern, calm, data-first.
   Palette follows the HUB ICT sage/charcoal design tokens.
   ============================================================ */

:root,
:root[data-theme='light'] {
  --bg: #c6cec5;
  --bg-2: #d6dfd3;
  --surface: #e7ece6;
  --surface-2: #dde5da;
  --surface-3: #a4b4a4;
  --ink: #0d2625;
  --ink-soft: #243e35;
  --muted: #30463d;
  --line: #83958b;
  --line-soft: #b4c1b4;
  --accent: #a96745;
  --accent-strong: #8c4f31;
  --accent-soft: rgba(169, 103, 69, 0.14);
  --ok: #2f6b4f;
  --ok-soft: rgba(47, 107, 79, 0.14);
  --over: #a8551c;
  --over-soft: rgba(168, 85, 28, 0.15);
  --under: #9b3a3a;
  --under-soft: rgba(155, 58, 58, 0.14);
  --focus: #0d2625;
  --header-bg: rgba(231, 236, 230, 0.72);
  --header-line: rgba(131, 149, 139, 0.36);
  --shadow-sm: 0 1px 2px rgba(13, 38, 37, 0.06), 0 2px 8px rgba(13, 38, 37, 0.05);
  --shadow-md: 0 10px 30px rgba(13, 38, 37, 0.1);
  --shadow-lg: 0 26px 70px rgba(13, 38, 37, 0.18);
  --grid-line: rgba(131, 149, 139, 0.22);
  --cell: #f2f5ef;
  --cell-hover: #e9efe5;
  --tick: #a96745;
  color-scheme: light;
}

:root[data-theme='dark'] {
  --bg: #191817;
  --bg-2: #211f1d;
  --surface: #22211f;
  --surface-2: #2b2926;
  --surface-3: #383530;
  --ink: #f2eee7;
  --ink-soft: #d2ccc2;
  --muted: #aaa297;
  --line: #454039;
  --line-soft: #34312d;
  --accent: #d4a387;
  --accent-strong: #e8c8b6;
  --accent-soft: rgba(212, 163, 135, 0.16);
  --ok: #6ee7b7;
  --ok-soft: rgba(16, 185, 129, 0.16);
  --over: #fcd34d;
  --over-soft: rgba(245, 158, 11, 0.16);
  --under: #fca5a5;
  --under-soft: rgba(239, 68, 68, 0.16);
  --focus: #d4a387;
  --header-bg: rgba(25, 24, 23, 0.72);
  --header-line: rgba(69, 64, 57, 0.6);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 14px 34px rgba(0, 0, 0, 0.42);
  --shadow-lg: 0 30px 80px rgba(0, 0, 0, 0.55);
  --grid-line: rgba(69, 64, 57, 0.55);
  --cell: #26241f;
  --cell-hover: #2f2c27;
  --tick: #d4a387;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(1100px 520px at 12% -8%, var(--bg-2) 0%, transparent 62%),
    radial-gradient(900px 480px at 100% 0%, var(--surface-2) 0%, transparent 58%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  opacity: 0.5;
  background-image: radial-gradient(var(--line-soft) 0.5px, transparent 0.5px);
  background-size: 22px 22px;
  mask-image: radial-gradient(1200px 700px at 50% 0%, black, transparent 78%);
}

h1, h2, h3 { margin: 0; line-height: 1.15; letter-spacing: -0.02em; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-strong); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--ink);
  color: var(--surface);
  border-radius: 10px;
  text-decoration: none;
  transition: top 160ms var(--ease);
}
.skip-link:focus { top: 12px; }

:root {
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 140ms;
  --dur: 240ms;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 22px;
}

/* ---------- App bar ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
  border-bottom: 1px solid var(--header-line);
}

.appbar-inner {
  max-width: 1360px;
  margin: 0 auto;
  padding: 12px clamp(14px, 3vw, 30px) 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  flex: none;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 1.02rem; font-weight: 800; letter-spacing: -0.01em; }
.brand-text span { font-size: 0.74rem; color: var(--muted); letter-spacing: 0.02em; }

.appbar-actions { display: flex; align-items: center; gap: 10px; }

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
}
.segmented button {
  border: 0;
  background: transparent;
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
}
.segmented button[aria-selected='true'] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.segmented button:active { transform: scale(0.97); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line-soft);
  background: var(--surface);
  color: var(--ink-soft);
  transition: background var(--dur) var(--ease), transform var(--dur-fast) var(--ease), border-color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--line); }
.icon-btn:active { transform: scale(0.95); }
.icon-moon { display: none; }
:root[data-theme='dark'] .icon-sun { display: none; }
:root[data-theme='dark'] .icon-moon { display: block; }

.tabs {
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 clamp(14px, 3vw, 30px);
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  border: 0;
  background: transparent;
  padding: 12px 14px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  transition: color var(--dur) var(--ease);
}
.tab:hover { color: var(--ink); }
.tab[aria-current='page'] { color: var(--ink); }
.tab[aria-current='page']::after {
  content: '';
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 6px;
  height: 3px;
  border-radius: 3px;
  background: var(--accent);
}

/* ---------- Layout ---------- */
.main {
  max-width: 1360px;
  margin: 0 auto;
  padding: clamp(18px, 3vw, 34px) clamp(14px, 3vw, 30px) 60px;
}
.footer {
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 clamp(14px, 3vw, 30px) 26px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--muted);
}
#dataNote { opacity: 0.85; }
.footer-right { display: inline-flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.link-btn {
  background: none;
  border: 0;
  padding: 2px 0;
  color: var(--accent-strong);
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-btn:hover { color: var(--ink); }

.loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 60px 0;
  color: var(--muted);
  justify-content: center;
}
.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--line-soft);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-strong);
}
.page-head h1 {
  font-size: clamp(1.7rem, 3.4vw, 2.5rem);
  font-weight: 800;
}
.lede { color: var(--muted); font-size: 0.95rem; max-width: 62ch; margin-top: 6px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--ink);
  color: var(--surface);
  font-size: 0.86rem;
  font-weight: 700;
  transition: transform var(--dur-fast) var(--ease), background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn:hover { box-shadow: var(--shadow-md); }
.btn:active { transform: scale(0.97); }
.btn.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn.ghost:hover { background: var(--surface-2); box-shadow: none; }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 0.78rem; border-radius: 9px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Cards / panels ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.kpi {
  position: relative;
  overflow: hidden;
  padding: 18px 18px 16px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow-sm);
}
.kpi::after {
  content: '';
  position: absolute;
  right: -20px;
  top: -24px;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--accent-soft);
  filter: blur(2px);
}
.kpi-label { font-size: 0.76rem; font-weight: 600; color: var(--muted); letter-spacing: 0.02em; }
.kpi-value { font-size: clamp(1.7rem, 3vw, 2.2rem); font-weight: 800; letter-spacing: -0.03em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi-unit { font-size: 0.9rem; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.kpi-foot { font-size: 0.74rem; color: var(--muted); margin-top: 2px; }

.grid-2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 16px; }
.grid-2.equal { grid-template-columns: 1fr 1fr; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 10px;
}
.panel-title { font-size: 1rem; font-weight: 800; letter-spacing: -0.01em; }
.panel-sub { font-size: 0.76rem; color: var(--muted); margin-top: 2px; }
.panel-body { padding: 6px 18px 18px; }
.panel-body.flush { padding: 0; }

/* ---------- Teacher load list (signature: period ticks) ---------- */
.loadlist { display: flex; flex-direction: column; gap: 2px; }
.loadrow {
  display: grid;
  grid-template-columns: minmax(120px, 1.1fr) minmax(90px, 2.3fr) auto;
  align-items: center;
  gap: 12px;
  padding: 9px 8px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  text-align: left;
  width: 100%;
  transition: background var(--dur) var(--ease);
}
.loadrow:hover { background: var(--surface-2); }
.loadrow-name { font-size: 0.83rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loadrow-track { position: relative; height: 22px; display: flex; align-items: center; }
.ticks { display: flex; gap: 2px; align-items: center; height: 22px; flex-wrap: nowrap; overflow: hidden; }
.tick {
  width: 4px;
  height: 14px;
  border-radius: 2px;
  background: var(--tick);
  opacity: 0.34;
  flex: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.tick.on { opacity: 0.9; }
.tick.over { background: var(--over); opacity: 1; }
.tick.under { background: var(--under); opacity: 0.8; }
.loadrow:hover .tick { transform: scaleY(1.12); }
.loadrow-value { font-size: 0.86rem; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 40px; text-align: right; }
.loadrow-value small { font-weight: 600; color: var(--muted); font-size: 0.68rem; }

/* ---------- Coverage ---------- */
.coverage-list { display: flex; flex-direction: column; gap: 10px; }
.coverage-row { display: grid; grid-template-columns: 92px 1fr auto; gap: 10px; align-items: center; }
.coverage-name { font-size: 0.8rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 999px; background: var(--accent); transition: width var(--dur) var(--ease); }
.meter-fill.full { background: var(--ok); }
.meter-fill.low { background: var(--under); }
.coverage-val { font-size: 0.76rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }

/* ---------- Alerts ---------- */
.alerts { display: flex; flex-direction: column; gap: 10px; }
.alert {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 0.82rem;
}
.alert .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; flex: none; background: var(--accent); }
.alert.over .dot { background: var(--over); }
.alert.under .dot { background: var(--under); }
.alert.ok .dot { background: var(--ok); }
.alert strong { font-weight: 800; }

/* ---------- Toolbar / fields ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 14px;
}
.session-info {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
  padding: 14px 18px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}
.session-title { margin-right: auto; min-width: 140px; }
.session-title strong { display: block; margin-top: 2px; font-size: 1.05rem; }
.session-info .field input { min-width: 150px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 0.74rem; font-weight: 700; color: var(--muted); letter-spacing: 0.02em; }
.field input, .field select {
  min-height: 42px;
  padding: 9px 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.field input:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field.search-field { flex: 1 1 220px; }
.muted { color: var(--muted); }
.hint { font-size: 0.78rem; color: var(--muted); }
.row { display: flex; align-items: center; }
.row.gap { gap: 10px; flex-wrap: wrap; }

/* ---------- Matrix / assignment grid ---------- */
.matrix-wrap {
  overflow: auto;
  border-radius: var(--r-md);
  border: 1px solid var(--line-soft);
  background: var(--surface);
  max-height: 70vh;
}
.matrix { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: 0.78rem; }
.matrix th, .matrix td { padding: 0; border-bottom: 1px solid var(--grid-line); border-right: 1px solid var(--grid-line); }
.matrix thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface-2);
  font-weight: 700;
  color: var(--ink-soft);
  padding: 9px 8px;
  white-space: nowrap;
  text-align: center;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}
.matrix thead th.corner { left: 0; z-index: 5; text-align: left; }
.matrix tbody th {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface-2);
  text-align: left;
  padding: 8px 12px;
  white-space: nowrap;
  font-weight: 700;
  min-width: 128px;
}
.matrix tbody th small { display: block; font-weight: 500; color: var(--muted); font-size: 0.68rem; }
.matrix tbody tr:hover th { background: var(--surface-3); }
.cell-btn {
  display: block;
  width: 100%;
  min-width: 78px;
  min-height: 40px;
  padding: 6px 8px;
  border: 0;
  background: var(--cell);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.cell-btn:hover { background: var(--cell-hover); }
.cell-btn.empty { color: var(--muted); font-weight: 500; opacity: 0.7; }
.cell-btn.empty::after { content: '—'; }
.cell-btn.filled { color: var(--ink); }
.cell-btn.cat-match { box-shadow: inset 0 0 0 2px var(--accent); }
.cell-btn.dim { opacity: 0.28; }
.cell-btn.dim:hover { opacity: 0.65; }
.matrix tbody td.zero { background: repeating-linear-gradient(135deg, transparent, transparent 6px, var(--grid-line) 6px, var(--grid-line) 7px); }
.class-total { padding: 8px 12px; font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.row-total { background: var(--surface-2); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 0.74rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- Teacher cards / table ---------- */
.teacher-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.teacher-card {
  text-align: left;
  padding: 15px 16px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.teacher-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--line); }
.teacher-card:active { transform: translateY(0) scale(0.99); }
.tc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.tc-name { font-size: 0.92rem; font-weight: 800; letter-spacing: -0.01em; }
.tc-type { font-size: 0.68rem; font-weight: 700; color: var(--accent-strong); text-transform: uppercase; letter-spacing: 0.08em; }
.tc-load { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.tc-load small { font-size: 0.68rem; font-weight: 600; color: var(--muted); }
.tc-bar { margin-top: 10px; }
.tc-subjects { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.chip b { font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- Tables ---------- */
.table-wrap { overflow: auto; border-radius: var(--r-md); border: 1px solid var(--line-soft); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--grid-line); }
.table th { position: sticky; top: 0; background: var(--surface-2); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); z-index: 1; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tbody tr:hover { background: var(--surface-2); }
.table tr:last-child td { border-bottom: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.over { background: var(--over-soft); color: var(--over); }
.badge.under { background: var(--under-soft); color: var(--under); }
.badge.neutral { background: var(--surface-2); color: var(--muted); }

.num-edit { width: 76px; min-height: 36px; padding: 6px 8px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); text-align: right; font-variant-numeric: tabular-nums; }
.text-edit {
  width: 100%;
  min-width: 140px;
  min-height: 38px;
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.84rem;
  font-weight: 600;
}
.text-edit.code { min-width: 86px; text-transform: uppercase; font-weight: 800; letter-spacing: 0.04em; }
.text-edit:focus, .num-edit:focus, .admin-add input:focus, .admin-add select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.admin-add {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  padding: 14px 18px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
}
.admin-add input, .admin-add select {
  min-height: 38px;
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.84rem;
}
.admin-add input[name='code'] { flex: 0 0 92px; text-transform: uppercase; }
.admin-add input[name='name'], .admin-add input[name='label'] { flex: 1 1 170px; }
.admin-add input[type='number'] { width: 96px; }
.admin-table td { vertical-align: middle; }
.admin-table .icon-btn { width: 34px; height: 34px; border-radius: 9px; }
.icon-btn.danger { color: var(--under); border-color: color-mix(in srgb, var(--under) 42%, transparent); }
.icon-btn.danger:hover { background: var(--under-soft); }
.btn.danger { background: var(--under); color: #fff; border-color: transparent; }
.btn.danger:hover { background: color-mix(in srgb, var(--under) 86%, #000); }
.confirm-sheet { width: min(420px, calc(100vw - 24px)); }

/* ---------- Dialog / sheet ---------- */
.sheet {
  width: min(560px, calc(100vw - 24px));
  max-height: min(82vh, 760px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.sheet[open] { animation: sheetIn var(--dur) var(--ease-out); }
@keyframes sheetIn { from { opacity: 0; transform: translateY(10px) scale(0.985); } to { opacity: 1; transform: none; } }
.sheet::backdrop { background: rgba(7, 12, 23, 0.46); backdrop-filter: blur(3px); }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 18px 8px; }
.sheet-head h2 { font-size: 1.15rem; font-weight: 800; }
.sheet-body { padding: 8px 18px 16px; overflow: auto; max-height: 60vh; }
.sheet-body.stack { display: flex; flex-direction: column; gap: 14px; }
.sheet-foot { display: flex; justify-content: space-between; gap: 10px; padding: 12px 18px 18px; border-top: 1px solid var(--line-soft); }

.picker-list { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; max-height: 46vh; overflow: auto; }
.picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 46px;
  padding: 9px 12px;
  border-radius: 11px;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  font-size: 0.86rem;
  font-weight: 600;
  transition: background var(--dur-fast) var(--ease);
}
.picker-item:hover { background: var(--surface-2); }
.picker-item[aria-selected='true'] { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 32%, transparent); }
.picker-item small { color: var(--muted); font-weight: 600; font-size: 0.72rem; }
.picker-empty { padding: 20px 8px; text-align: center; color: var(--muted); font-size: 0.84rem; }
.picker-group {
  padding: 12px 10px 4px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 20px);
  z-index: 80;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--surface);
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Detail drawer ---------- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(7, 12, 23, 0.42);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease);
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 61;
  width: min(440px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  transform: translateX(102%);
  transition: transform var(--dur) var(--ease-out);
  display: flex;
  flex-direction: column;
}
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 20px 10px; }
.drawer-body { padding: 6px 20px 24px; overflow: auto; }
.drawer h2 { font-size: 1.25rem; font-weight: 800; }
.breakdown { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.breakdown-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 9px 12px; border-radius: 10px; background: var(--surface-2); font-size: 0.82rem; }
.breakdown-row b { font-variant-numeric: tabular-nums; }

/* ---------- Utilities ---------- */
.stack-sm > * + * { margin-top: 10px; }
.stack > * + * { margin-top: 14px; }
.mt-16 { margin-top: 16px; }
.hidden { display: none !important; }
.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; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .brand-text span { display: none; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .kpi-grid { gap: 10px; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 1.55rem; }
  .loadrow { grid-template-columns: minmax(96px, 1fr) minmax(60px, 1.6fr) auto; gap: 8px; }
  .teacher-grid { grid-template-columns: 1fr; }
  .appbar-inner { padding-bottom: 8px; }
  .session-info { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  .session-title { grid-column: 1 / -1; margin-right: 0; }
  .session-info .field { min-width: 0; }
  .session-info .field input { width: 100%; min-width: 0; }
  .admin-segmented { display: flex; flex-wrap: wrap; width: 100%; border-radius: 14px; }
  .admin-segmented button { flex: 1 1 46%; border-radius: 10px; text-align: center; }
  .admin-table .text-edit { min-width: 105px; }
  .admin-table .text-edit.code { min-width: 68px; }
  .admin-table .num-edit { width: 64px; }
  .admin-table th, .admin-table td { padding: 8px 6px; }
}
@media (max-width: 520px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .brand-text { display: none; }
  .segmented button { padding: 7px 12px; }
  .tab { padding: 10px 8px 12px; font-size: 0.78rem; }
  .sheet { width: 100vw; max-height: 90vh; border-radius: 18px 18px 0 0; margin: auto auto 0; }
  .coverage-row { grid-template-columns: 76px 1fr auto; }
  .session-info { grid-template-columns: 1fr; }
  .admin-segmented button { flex: 1 1 46%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .drawer { transition: none; }
  .sheet[open] { animation: none; }
}

@media (prefers-contrast: more) {
  :root { --line: var(--ink); --line-soft: var(--ink); }
}

/* ---------- Print ---------- */
.print-report { display: none; }

@media print {
  body { background: #fff; color: #000; }
  body > *:not(#printReport) { display: none !important; }
  #printReport { display: block !important; }
  .appbar, .footer, .toast, .head-actions, .toolbar, .drawer, .drawer-backdrop, .sheet, .skip-link { display: none !important; }
  .main { max-width: none; padding: 0; }
  .panel, .table-wrap { box-shadow: none; border: 1px solid #999; break-inside: avoid; }
  .matrix-wrap { max-height: none; overflow: visible; }
  .tab[aria-current='page']::after { display: none; }
  .print-report { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 10.5pt; color: #111; }
  .print-header { border-bottom: 2px solid #111; padding-bottom: 6px; margin-bottom: 14px; }
  .print-header h1 { font-size: 16pt; margin: 0; }
  .print-header p { font-size: 9.5pt; margin: 2px 0 0; color: #444; }
  .pdf-teacher { break-inside: avoid; margin-bottom: 16px; }
  .pdf-teacher h2 { font-size: 12.5pt; margin: 0 0 2px; }
  .pdf-meta { font-size: 9pt; color: #555; margin: 0 0 6px; }
  .print-report table { width: 100%; border-collapse: collapse; font-size: 9.5pt; }
  .print-report th, .print-report td { border: 1px solid #999; padding: 4px 6px; text-align: left; vertical-align: top; }
  .print-report th { background: #eee; font-weight: 700; }
  .print-report .num { text-align: right; }
}
