/* School management presentation layer. Existing markup and workflows stay intact. */
@font-face {
  font-family: "Kanit";
  src: url("assets/fonts/Kanit-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Kanit";
  src: url("assets/fonts/Kanit-Medium.ttf") format("truetype");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Kanit";
  src: url("assets/fonts/Kanit-SemiBold.ttf") format("truetype");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Kanit";
  src: url("assets/fonts/Kanit-Bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

:root {
  --ui-font: "Kanit", "Leelawadee UI", Tahoma, sans-serif;
  --ui-space-1: 4px;
  --ui-space-2: 8px;
  --ui-space-3: 12px;
  --ui-space-4: 16px;
  --ui-space-6: 24px;
  --ui-space-8: 32px;
  --ui-control: 44px;
  --ui-header: 88px;
  --ui-sidebar: 280px;
  --ui-compact-sidebar: 84px;
  --ui-radius: 12px;
  --ui-panel-radius: 18px;
  --ui-focus: #2448ba;
  --ui-field-border: #72809a;
  --ui-row-hover: #eef3ff;
  --ui-success-soft: #edf7f1;
  --ui-warning-soft: #fff5e6;
  --ui-danger-soft: #fff0f3;
  --ui-info-soft: #edf2ff;
  --ui-teal-soft: #e9f7f8;
  --ui-purple-soft: #f2efff;
  --ui-hero-start: #f1f5ff;
  --ui-hero-end: #eefaf8;
  --ui-nav-active: #3155ad;
  --ui-login-start: #233d80;
  --ui-login-end: #176d80;
  --font-primary: var(--ui-font);
  --bg: #f3f6fc;
  --surface: #ffffff;
  --surface-soft: #edf2fb;
  --surface-glass: var(--surface);
  --text: #24324a;
  --muted: #526078;
  --line: #dce4f2;
  --line-strong: #a9b8cf;
  --primary: #315de6;
  --primary-dark: #2448ba;
  --primary-soft: #edf2ff;
  --teal: #08747f;
  --green: #18794e;
  --amber: #a65f08;
  --red: #bd3455;
  --purple: #6c4fbd;
  --info: #096f9e;
  --success: var(--green);
  --warning: var(--amber);
  --danger: var(--red);
  --on-primary: #ffffff;
  --on-success: #ffffff;
  --on-danger: #ffffff;
  --on-sidebar: #ffffff;
  --sidebar: #172843;
  --sidebar-soft: #203858;
  --sidebar-line: #354c6d;
  --radius-sm: 8px;
  --radius-md: var(--ui-radius);
  --radius-lg: var(--ui-panel-radius);
  --radius-xl: 22px;
  --shadow-xs: 0 1px 2px rgb(15 23 42 / 4%);
  --shadow-sm: 0 3px 12px rgb(35 61 128 / 6%);
  --shadow: 0 10px 30px rgb(35 61 128 / 9%);
  --shadow-lg: 0 16px 48px rgb(15 23 42 / 12%);
  --motion-fast: 140ms;
  --motion-med: 220ms;
  --ui-page-motion: 220ms;
  --ui-ease: cubic-bezier(.22, 1, .36, 1);
}

:root[data-theme="dark"] {
  --ui-focus: #9bb6f5;
  --ui-field-border: #7f94ae;
  --ui-row-hover: #263650;
  --ui-success-soft: #20382f;
  --ui-warning-soft: #3b3226;
  --ui-danger-soft: #3c2935;
  --ui-info-soft: #253552;
  --ui-teal-soft: #203b40;
  --ui-purple-soft: #332f49;
  --ui-hero-start: #22324f;
  --ui-hero-end: #213b42;
  --ui-nav-active: #2d4b89;
  --ui-login-start: #1c305e;
  --ui-login-end: #214551;
  --bg: #111a2a;
  --surface: #1a263b;
  --surface-soft: #24334b;
  --surface-glass: var(--surface);
  --text: #e1e8f3;
  --muted: #a9b8ce;
  --line: #3b4d68;
  --line-strong: #5c7090;
  --primary: #8aa6e2;
  --primary-dark: #adc1ee;
  --primary-soft: #253552;
  --teal: #81c9c2;
  --green: #a1cdb7;
  --amber: #dbb477;
  --red: #e3a0b0;
  --purple: #b4a5df;
  --info: #97bbdb;
  --on-primary: #111b2e;
  --on-success: #142c23;
  --on-danger: #34202c;
  --sidebar: #152238;
  --sidebar-soft: #223752;
  --shadow-xs: 0 1px 2px rgb(0 0 0 / 12%);
  --shadow-sm: 0 2px 6px rgb(0 0 0 / 12%);
  --shadow: 0 8px 24px rgb(0 0 0 / 18%);
}

/* Type and surfaces are shared across staff and student pages. */
html { scroll-padding-top: calc(var(--ui-header) + 16px); }
body { background: var(--bg); font-family: var(--ui-font); font-size: 16px; font-weight: 400; line-height: 1.65; }
button, input, select, textarea { font-family: var(--ui-font); }
:root :is(.main, .content, .content > *, .grid > *, .form-field) { min-width: 0; }
:root :is(.content, .dashboard-content) { padding: var(--ui-space-6); background: var(--bg); }
:root .content { animation: none; }
:root .dashboard-prototype { width: 100%; max-width: 1440px; gap: var(--ui-space-4); }
:root :is(.panel, .card, .dashboard-panel, .master-panel, .modal, .modern-login-container) {
  background: var(--surface);
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
  backdrop-filter: none;
}
:root :is(.panel-header, .dashboard-panel-header, .master-panel .panel-header) {
  padding: var(--ui-space-4) var(--ui-space-6);
  background: var(--surface);
  border-color: var(--line);
}
:root :is(.panel-body, .dashboard-panel-body, .master-panel .panel-body) { padding: var(--ui-space-6); }
:root :is(.panel-header h3, .master-title h3, .dashboard-panel-header h3) {
  color: var(--text);
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.5;
}
:root :is(.panel-header p, .master-title p, .dashboard-panel-header p, .section-heading p) {
  color: var(--muted);
  font-size: .875rem;
  line-height: 1.65;
}
:root :is(.content > .card > .section-heading, .content > .panel > .panel-header, .report-grid > .panel > .panel-header) {
  background: var(--surface);
  border-color: var(--line);
}

/* Navigation keeps its current sections, permission checks and drawer controls. */
:root .sidebar { background: linear-gradient(165deg, var(--sidebar), var(--sidebar-soft)); box-shadow: none; }
:root .brand { padding: 24px 16px; min-height: 104px; }
:root .brand-mark { box-shadow: none; border-radius: 12px; }
:root .brand h1 { font-weight: 600; line-height: 1.65; color: #f8fafc; }
:root :is(.brand p, .sidebar-title, .nav-label small) { color: #cbd5e1; }
:root .sidebar-title { font-size: .75rem; font-weight: 600; }
:root .sidebar-section { padding: 16px 12px 4px; }
:root .nav-list { gap: 4px; }
:root .nav-button {
  min-height: 52px;
  border-radius: var(--ui-radius);
  color: #e2e8f0;
  box-shadow: none;
  transform: none;
}
:root .nav-label strong { font-size: .875rem; font-weight: 600; line-height: 1.6; }
:root .nav-label small { font-size: .75rem; line-height: 1.5; }
:root .nav-button:hover { background: #2a4265; border-color: transparent; transform: none; }
:root[data-theme] .nav-button.active { background: linear-gradient(115deg, var(--ui-nav-active), #28678b); color: #ffffff; border-color: transparent; box-shadow: 0 4px 12px rgb(8 21 47 / 16%); }
:root .nav-button.active .nav-label small { color: #e2edff; }
:root .nav-icon { border: 0; background: #24364f; color: #e2e8f0; box-shadow: none; }
:root .nav-button.active .nav-icon { background: #e9f0ff; color: #2448ba; }
:root .nav-count { background: #314764; color: #ffffff; border-radius: 6px; font-weight: 600; }
:root .nav-button.active .nav-count { background: #ffffff; color: #1d4ed8; }
:root :is(.topbar, .app-shell.is-dashboard-view .topbar) {
  min-height: var(--ui-header);
  padding: 16px 24px;
  background: var(--surface) !important;
  border-bottom: 1px solid var(--line);
  box-shadow: none;
  backdrop-filter: none;
}
:root .page-title h2 { font-size: 1.125rem; font-weight: 700; line-height: 1.6; }
:root .page-title p { color: var(--muted); font-size: .8125rem; }
:root :is(.theme-switch, .user-pill, .avatar) { box-shadow: none; }
:root .theme-switch { border-radius: var(--ui-radius); background: var(--surface-soft); border-color: var(--line); }
:root .theme-switch::before { border-radius: 8px; background: var(--primary-soft); box-shadow: none; }
:root .theme-switch button { min-height: 40px; border-radius: 8px; font-weight: 600; }
:root[data-theme] .theme-switch button[data-theme-choice][aria-pressed="true"] { background: var(--primary-soft); color: var(--primary-dark); box-shadow: none; }
:root .user-pill { border-radius: var(--ui-radius); background: var(--surface); border-color: var(--line-strong); }

/* Colored accents distinguish sections while preserving the data hierarchy. */
:root .dashboard-hero {
  padding: var(--ui-space-6);
  gap: var(--ui-space-4);
  background: linear-gradient(120deg, var(--ui-hero-start), var(--surface) 60%, var(--ui-hero-end));
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  box-shadow: var(--shadow-sm);
}
:root .dashboard-hero h2 { margin-top: 8px; font-size: clamp(1.35rem, 2vw, 1.75rem); line-height: 1.55; font-weight: 700; }
:root .dashboard-hero p { color: var(--muted); font-size: .9375rem; line-height: 1.7; }
:root .dashboard-kicker { background: var(--primary-soft); color: var(--primary-dark); border: 0; font-weight: 600; }
:root .dashboard-meta span { background: var(--surface-soft); color: var(--muted); border: 1px solid var(--line); font-weight: 500; }
:root .dashboard-hero-actions { gap: 8px; }
:root .dashboard-action { padding: 12px 16px; min-height: 64px; box-shadow: none; }
:root :is(.dashboard-metric, .master-summary-card, .metric-card) {
  padding: 20px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--tone, var(--summary-tone, var(--primary)));
  background: linear-gradient(145deg, color-mix(in srgb, var(--tone, var(--summary-tone, var(--primary))) 7%, var(--surface)), var(--surface) 75%);
  color: var(--text);
  box-shadow: var(--shadow-xs);
  transform: none;
}
:root :is(.dashboard-metric-text span, .dashboard-metric-text small, .dashboard-metric-en, .master-summary-card span, .master-summary-card small) {
  color: var(--muted); opacity: 1;
}
:root :is(.dashboard-metric-text strong, .master-summary-card strong, .metric-value) {
  color: var(--text); font-size: 2rem; font-weight: 700; line-height: 1.5; font-variant-numeric: tabular-nums;
}
:root :is(.dashboard-metric-text span, .master-summary-card span) { font-size: .875rem; font-weight: 600; line-height: 1.6; }
:root :is(.dashboard-metric-icon, .master-summary-icon) {
  background: color-mix(in srgb, var(--tone, var(--summary-tone, var(--primary))) 12%, var(--surface));
  color: var(--tone, var(--summary-tone, var(--primary)));
  box-shadow: none;
  border-radius: var(--ui-radius);
}
:root .dashboard-quick-export { border-color: var(--line); }
:root :is(.dashboard-quick-form, .attendance-control-card, .grade-filter-shell, .home-visit-control-card) {
  background: var(--surface-soft); border-color: var(--line); border-radius: var(--ui-radius); box-shadow: none;
}
:root .btn.success.dashboard-export-action:not(:disabled) {
  background: linear-gradient(135deg, var(--ui-teal-soft), var(--surface));
  color: var(--teal);
  border: 1px solid var(--line-strong);
  min-height: 80px;
  box-shadow: none;
}
:root .btn.success.dashboard-export-action:not(:disabled):hover { background: var(--ui-teal-soft); border-color: var(--teal); }
:root .dashboard-export-action:not(:disabled) small { color: var(--muted); opacity: 1; }
:root .dashboard-export-action:not(:disabled) .dashboard-export-badge { background: var(--ui-teal-soft); color: var(--teal); }
:root .dashboard-list-item { box-shadow: none; }
:root .dashboard-donut { background: var(--dashboard-donut-bg, conic-gradient(var(--tone) calc(var(--donut, 0) * 1%), var(--surface-soft) 0)); }
:root .dashboard-donut-center { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
:root .dashboard-donut-center strong { color: var(--text); }
:root .dashboard-donut-center span { color: var(--muted); }
:root .dashboard-legend-row span:not(.dashboard-dot) { color: var(--text); }
:root[data-theme] .topbar .btn.icon-only { background: var(--surface); color: var(--text); border-color: var(--line-strong); }

/* Shared forms and actions retain existing field names, validation and handlers. */
:root :is(.form-grid, .form-grid.three) { gap: 20px 24px; }
:root .form-field { gap: 8px; }
:root .form-field label { font-size: .875rem; font-weight: 500; line-height: 1.65; color: var(--text); }
:root :is(.form-field label small, .form-field small, .form-hint, .modern-input-group label small) {
  color: var(--muted); font-size: .8125rem; line-height: 1.65;
}
:root :is(.input, .select, .textarea, .modern-input) {
  min-height: var(--ui-control);
  border: 1px solid var(--ui-field-border);
  border-radius: var(--ui-radius);
  background: var(--surface);
  color: var(--text);
  font-size: .9375rem;
  line-height: 1.6;
  box-shadow: none;
}
:root :is(.input, .select, .textarea) { padding: 10px 12px; }
:root .search-field .input { padding-left: 42px; }
:root :is(.input, .textarea, .modern-input)::placeholder { color: var(--muted); opacity: 1; }
:root :is(.input, .select, .textarea, .modern-input):hover { border-color: var(--primary); }
:root :is(.input, .select, .textarea, .modern-input):focus {
  border-color: var(--ui-focus); outline: 2px solid var(--ui-focus); outline-offset: 2px; box-shadow: none;
}
:root :is(.input, .select, .textarea):disabled { background: var(--surface-soft); color: var(--muted); border-color: var(--line-strong); opacity: 1; }
:root :is(.input, .textarea):read-only { background: var(--surface-soft); }

/* Score entry uses the keyboard and table paste; keep native numeric validation. */
:root input[type="number"][data-score-paste-cell] {
  -moz-appearance: textfield;
  appearance: textfield;
}
:root input[type="number"][data-score-paste-cell]::-webkit-inner-spin-button,
:root input[type="number"][data-score-paste-cell]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
:root .textarea { min-height: 112px; }
:root .readonly-field { border-color: var(--line-strong); background: var(--surface-soft); color: var(--muted); }
:root :is(.field-validation, .form-error) { color: var(--red); line-height: 1.7; font-size: .875rem; }
:root :is(.btn, .modern-btn, .table-action-button) {
  min-height: var(--ui-control);
  border-radius: var(--ui-radius);
  font-size: .875rem;
  font-weight: 600;
  line-height: 1.6;
  box-shadow: none;
  text-shadow: none;
  transform: none;
  transition: background-color var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast), box-shadow var(--motion-fast), transform var(--motion-fast);
}
:root .btn { padding: 10px 16px; }
:root .btn:hover { transform: none; box-shadow: none; }
:root .btn:active { transform: none; }
:root .btn:not(:disabled):active { transform: translateY(1px); }
:root .btn.primary:not(:disabled):hover { background: var(--primary-dark); border-color: var(--primary-dark); }
:root .btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
:root .btn.success { background: var(--success); border-color: var(--success); color: var(--on-success); }
:root .btn.danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
:root .btn.ghost.danger { background: transparent; color: var(--danger); border-color: var(--line-strong); }
:root .btn.small { min-height: 40px; padding: 8px 12px; font-size: .8125rem; }
:root .btn.icon-only { width: var(--ui-control); min-width: var(--ui-control); padding: 0; }
:root .check-option { min-height: 44px; background: var(--surface); border-color: var(--ui-field-border); box-shadow: none; font-weight: 500; }
:root .check-option input { width: 18px; height: 18px; flex-shrink: 0; }
:root .tabs { gap: 8px; padding: 4px; }
:root .tab { min-height: 44px; border-radius: 8px; font-weight: 600; }
:root .tab.active { background: var(--primary); color: var(--on-primary); box-shadow: none; }

/* Semantic colors work independently in both themes. Status wording is unchanged. */
:root .status { min-height: 28px; border-radius: 6px; font-size: .75rem; font-weight: 600; padding: 3px 9px; }
:root .status.green { background: var(--ui-success-soft); color: var(--green); border-color: var(--green); }
:root .status.amber { background: var(--ui-warning-soft); color: var(--amber); border-color: var(--amber); }
:root .status.red { background: var(--ui-danger-soft); color: var(--red); border-color: var(--red); }
:root .status.blue { background: var(--ui-info-soft); color: var(--primary-dark); border-color: var(--primary); }
:root .status.teal { background: var(--ui-teal-soft); color: var(--teal); border-color: var(--teal); }
:root .status.purple { background: var(--ui-purple-soft); color: var(--purple); border-color: var(--purple); }

/* Tables retain their specialized identity columns and mobile card layouts. */
:root :is(.table-wrap, .table-wrapper, .dashboard-table-scroll, .dashboard-grade-table-wrap) {
  max-width: 100%; border-color: var(--line); border-radius: var(--ui-radius); box-shadow: none;
  scrollbar-width: thin; scrollbar-color: var(--ui-field-border) var(--surface-soft);
}
:root :is(.table-wrap, .dashboard-table-scroll, .dashboard-grade-table-wrap) { overflow-x: auto; }
:root :is(th, td) { font-size: .875rem; line-height: 1.7; border-color: var(--line); }
:root th { background: var(--surface-soft); color: var(--muted); font-weight: 600; }
:root td { color: var(--text); }
:root :is(.master-table, .attendance-daily-table, .score-matrix, .pp5-table) :is(th, td) { padding: 12px; }
:root tbody tr:hover { background: var(--ui-row-hover); }
:root tbody tr:focus-within { box-shadow: inset 3px 0 var(--primary); }
:root .table-actions { gap: 8px; }
:root .table-actions .btn { min-height: 40px; padding: 8px 12px; font-size: .8125rem; }
:root .pp5-section { background: var(--surface); border-color: var(--line); border-radius: var(--ui-panel-radius); }
:root .pp5-section:focus-within { border-color: color-mix(in srgb, var(--primary) 55%, var(--line)); }
:root .pp5-export-band { background: var(--surface-soft); border-color: var(--line); box-shadow: none; }
:root .modal { border-radius: var(--ui-panel-radius); box-shadow: var(--shadow-lg); }
:root :is(.modal-header, .modal-footer) { background: var(--surface); border-color: var(--line); padding: 16px 24px; }
:root .modal-body { padding: 24px; }

/* Global keyboard focus and restrained motion. */
.ui-page-emoji { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; margin-right: 8px; border-radius: 10px; background: var(--primary-soft); font-size: 18px; vertical-align: middle; }
:root :is(button, a, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--ui-focus); outline-offset: 3px; box-shadow: none;
}
:root .sidebar :is(button, summary):focus-visible { outline-color: #bfdbfe; outline-offset: -3px; }
:root :is(button, a, input, select, textarea, summary) { scroll-margin-block: calc(var(--ui-header) + 16px) 24px; }
:root .att-status-input:focus-visible + .att-status-btn { outline: 2px solid var(--ui-focus); outline-offset: 2px; }
:root :is(.content > *, .panel, .card, .metric-card, .dashboard-metric) { animation: none; }
:root :is(.metric-card, .list-item, .quick-login):hover { transform: none; }

/* Sign-in screens share the same tokens; authentication code stays untouched. */
:root .modern-login-page { background: var(--bg); }
:root .modern-login-container { border-color: var(--line); border-radius: 18px; box-shadow: var(--shadow); }
:root .modern-login-left { background: linear-gradient(145deg, var(--ui-login-start), var(--ui-login-end)); padding: 48px; }
:root .modern-login-left::before { background: none; }
:root .modern-title { color: #ffffff; font-weight: 700; line-height: 1.55; font-size: clamp(1.5rem, 3vw, 2.25rem); }
:root .modern-subtitle { color: #e2e8f0; line-height: 1.75; }
:root .modern-login-right { padding: 40px; }
:root .login-form-head h2 { font-weight: 700; font-size: 1.5rem; line-height: 1.55; }
:root .modern-input { min-height: 48px; font-size: 1rem; }
:root .modern-btn { background: var(--login-accent); color: var(--on-primary); min-height: 48px; }
:root .modern-btn.green { color: var(--on-success); }
:root :is(.modern-btn, .switch-portal a):hover { transform: none; box-shadow: none; }
:root .switch-portal a { border-color: var(--line-strong); font-weight: 600; box-shadow: none; }

/* Replace light-only inline score backgrounds without changing cell contents. */
:root[data-theme="dark"] .score-matrix :is(.score-total-col, .score-total-cell) { background: var(--surface-soft) !important; color: var(--text); }
:root[data-theme="dark"] .score-matrix :is(th:last-child, td:last-child) { background: var(--ui-info-soft) !important; color: var(--primary-dark) !important; }
:root[data-theme="dark"] :is(.input, .textarea):read-only { background: var(--surface-soft) !important; color: var(--muted); }

@media (min-width: 1025px) {
  :root .app-shell { grid-template-columns: var(--ui-sidebar) minmax(0, 1fr); }
  :root .sidebar { width: var(--ui-sidebar); }
  :root .app-shell.is-sidebar-collapsed { grid-template-columns: var(--ui-compact-sidebar) minmax(0, 1fr); }
  :root .app-shell.is-sidebar-collapsed .sidebar { width: var(--ui-compact-sidebar); }
  :root .dashboard-hero { grid-template-columns: minmax(0, 1fr) 340px; align-items: center; }
  :root .dashboard-hero-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  :root .master-table .table-actions { flex-wrap: nowrap; }
}

@media (max-width: 1024px) {
  :root { --ui-header: 136px; }
  :root :is(.topbar, .app-shell.is-dashboard-view .topbar) { padding: 12px 16px; gap: 8px; min-height: auto; }
  :root :is(.content, .dashboard-content) { padding: 20px; }
  :root .dashboard-hero { padding: 20px; }
  :root .dashboard-hero-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  :root .modern-login-left { padding: 32px; }
  :root .modern-login-right { padding: 32px; }
}

@media (max-width: 640px) {
  :root { --ui-header: 132px; }
  :root :is(.content, .dashboard-content) { padding: 16px 12px 24px; }
  :root :is(.panel-header, .dashboard-panel-header, .master-panel .panel-header) { padding: 16px; }
  :root :is(.panel-body, .dashboard-panel-body, .master-panel .panel-body) { padding: 16px; }
  :root .page-title h2 { font-size: 1rem; }
  :root .page-title p { font-size: .75rem; }
  :root .dashboard-hero { padding: 16px; }
  :root .dashboard-hero h2 { font-size: 1.25rem; }
  :root :is(.dashboard-metric-grid, .master-summary-grid, .grade-summary-grid) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  :root :is(.dashboard-metric, .master-summary-card) { padding: 14px; min-height: 148px; }
  :root .dashboard-metric { grid-template-columns: minmax(0, 1fr); gap: 8px; align-content: start; }
  :root .dashboard-metric-icon { width: 36px; height: 36px; grid-row: 1; }
  :root :is(.dashboard-metric-text strong, .master-summary-card strong) { font-size: 1.75rem; }
  :root :is(.dashboard-metric-text span, .master-summary-card span) { font-size: .8125rem; }
  :root :is(.dashboard-metric-text small, .master-summary-card small) { font-size: .75rem; }
  :root .dashboard-action { padding: 10px 12px; font-size: .8125rem; }
  :root .dashboard-action small { font-size: .75rem; }
  :root :is(.btn.small, .table-actions .btn, .theme-switch button) { min-height: 44px; }
  :root :is(.input, .select, .textarea) { font-size: 1rem; }
  :root :is(.form-grid, .form-grid.three) { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  :root .toolbar-group { min-width: 0; }
  :root .modern-login-page { padding: 76px 12px 24px; }
  :root .modern-login-left { padding: 24px; }
  :root .modern-login-right { padding: 24px; }
  :root .modern-title { font-size: 1.5rem; }
  :root .login-theme-control { top: 12px; right: 12px; }
  :root .modal-body { padding: 16px; }
  :root :is(.modal-header, .modal-footer) { padding: 16px; }
}

@media (max-width: 359px) {
  :root :is(.dashboard-metric-grid, .master-summary-grid, .grade-summary-grid, .dashboard-hero-actions) { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  :root { --ui-page-motion: 0ms; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  :root .btn:not(:disabled):active { transform: none; }
}

/* A fixed table layout ignores the minimum widths of later score columns.
   Let every PP5 column keep its intrinsic size inside its own scroll region. */
:root .pp5-student-table {
  table-layout: auto;
  width: max-content !important;
  min-width: 100% !important;
}
:root .pp5-student-table th:not(.pp5-col-no):not(.pp5-col-name) {
  min-width: 112px !important;
  white-space: normal;
  overflow-wrap: break-word;
}
:root .pp5-student-table td .input {
  min-height: 44px;
  width: 88px !important;
  min-width: 88px !important;
  max-width: 88px;
}
:root .pp5-student-table td .select {
  width: 112px;
  min-width: 112px;
}
:root .pp5-section,
:root .pp5-section .section-heading > div,
:root .pp5-section .table-wrap { min-width: 0; }
:root .pp5-section .table-wrap {
  overflow: auto;
  overscroll-behavior-x: contain;
  scroll-padding-inline: 12px;
}
:root .pp5-batch-count { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; color: var(--text); font-size: .875rem; }
:root .pp5-batch-count .select { width: 96px; min-width: 96px; min-height: 44px; }
:root .pp5-batch-note { margin: 0 0 8px; line-height: 1.8; }
:root .pp5-batch-status { margin: 0 0 12px; line-height: 1.8; overflow-wrap: anywhere; }
:root .pp5-batch-status[role="alert"] { color: var(--red); }
@media (max-width: 1024px) {
  :root form[data-pp5-batch-form] .section-heading { flex-wrap: wrap; }
  :root form[data-pp5-batch-form] .toolbar-group { width: 100%; flex-wrap: wrap; }
  :root .pp5-batch-count { flex: 1 1 100%; justify-content: space-between; }
  :root .pp5-batch-count .select { font-size: 1rem; }
}
:root .ui-table-scroll-hint {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: .8125rem;
  line-height: 1.7;
}
:root .ui-table-scroll-hint[hidden] { display: none; }
:root .table-wrap:focus-visible {
  outline: 3px solid var(--ui-focus);
  outline-offset: 2px;
}
:root .modal-header .btn.icon-only {
  background: var(--surface-soft);
  color: var(--text);
  border-color: var(--line-strong);
}

@media (max-width: 1024px) {
  :root .pp5-student-table { --pp5-no-col: 80px; --pp5-name-col: 200px; }
  :root :is(.btn.small, .theme-switch button, .table-actions .btn) { min-height: 44px; }
  :root .modal-backdrop { padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  :root .modal {
    max-width: 100%;
    max-height: calc(100dvh - max(12px, env(safe-area-inset-top)) - max(12px, env(safe-area-inset-bottom)));
  }
  :root .modal-header,
  :root .modal-footer { flex-shrink: 0; }
  :root .modal-header h3 { min-width: 0; overflow-wrap: anywhere; }
  :root .modal-header .btn { flex-shrink: 0; }
  :root .modal-body { min-width: 0; overflow: auto; }
}
@media (max-width: 640px) {
  :root .pp5-student-table { --pp5-no-col: 72px; --pp5-name-col: 160px; }
  :root .pp5-student-table td .input { font-size: 1rem; }
  :root .pp5-section .toolbar-group { width: 100%; flex-wrap: wrap; }
  :root .pp5-section .toolbar-group > .btn { flex: 1 1 140px; white-space: normal; }
  /* Freezing all three identity columns would cover every attendance date. */
  :root .attendance-overview-table :is(.student-code-col, .student-name-col) { position: static; }
  :root .attendance-overview-table .student-index-col { left: 0; }
  :root .modal-footer { flex-wrap: wrap; gap: 8px; }
  :root .modal-footer .btn { flex: 1 1 120px; white-space: normal; }
  :root .toast { max-width: calc(100vw - 24px); right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); overflow-wrap: anywhere; }
}

/* Screen-only enhancements are loaded with media=screen; existing print/export styles remain authoritative. */

/* Role dashboards share the existing Kanit tokens and scoped data components. */
:root .dashboard-data-note {
  display: flex;
  justify-content: space-between;
  gap: 8px 20px;
  flex-wrap: wrap;
  margin: 0;
  color: var(--muted);
  font-size: .8125rem;
  line-height: 1.7;
}
:root .dashboard-inline-summary {
  margin: 12px 0;
  padding: 12px 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--ui-radius);
  color: var(--text);
  line-height: 1.8;
  overflow-wrap: anywhere;
}
:root .dashboard-work-action { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
:root .dashboard-class-progress { grid-column: 2 / -1; color: var(--muted); line-height: 1.6; }
:root .dashboard-work-table { width: 100%; min-width: 720px; border-collapse: collapse; table-layout: auto; }
:root .dashboard-work-table :is(th, td) { padding: 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); white-space: normal; }
:root .dashboard-work-table th { background: var(--surface-soft); color: var(--text); font-weight: 500; }
:root .dashboard-work-table small { display: block; margin-top: 4px; color: var(--muted); }
:root .dashboard-work-table :is(.btn, .status) { white-space: normal; }
:root .dashboard-score-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
:root .dashboard-score-filter label { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
:root .dashboard-score-filter .select { width: auto; max-width: 100%; min-height: 44px; }
:root :is(.dashboard-score-teacher, .dashboard-score-criteria) { margin: 12px 0; border: 1px solid var(--line); border-radius: var(--ui-radius); min-width: 0; overflow: hidden; }
:root :is(.dashboard-score-teacher, .dashboard-score-criteria) > summary { padding: 14px 16px; cursor: pointer; min-height: 44px; background: var(--surface-soft); color: var(--text); overflow-wrap: anywhere; }
:root .dashboard-score-teacher > summary span { display: block; margin-top: 6px; font-size: .875rem; line-height: 1.8; color: var(--muted); }
:root .dashboard-score-criteria p { margin: 12px 16px; font-size: .875rem; line-height: 1.9; color: var(--muted); }
:root [data-dashboard-score-report] [hidden] { display: none !important; }
:root .dashboard-score-work-table { min-width: 880px; }
:root .dashboard-quick-form { grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); }
:root .dashboard-risk-panel { min-width: 0; overflow: hidden; }
:root .dashboard-risk-panel > .panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 20px 24px;
  margin: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
:root .dashboard-risk-panel > .panel-header > div { min-width: 0; flex: 1 1 280px; }
:root .dashboard-risk-panel :is(h3, p) { overflow-wrap: anywhere; }
:root .dashboard-risk-panel .panel-header h3 { margin: 0 0 6px; }
:root .dashboard-risk-panel .panel-header p { margin: 0; color: var(--muted); line-height: 1.7; }
:root .dashboard-risk-panel > .panel-body { padding: 20px 24px; min-width: 0; }
:root .dashboard-risk-explanation { margin: 0 0 16px; line-height: 1.8; }
:root .dashboard-risk-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
:root .dashboard-risk-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 0 1 auto;
  min-width: 0;
  min-height: var(--ui-control);
  padding: 10px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--ui-radius);
  background: var(--surface);
  color: var(--text);
  font: 500 .9375rem/1.6 var(--ui-font);
  cursor: pointer;
  overflow-wrap: anywhere;
}
:root .dashboard-risk-tab[aria-selected="true"] { color: var(--primary-dark); background: var(--primary-soft); border-color: var(--primary); box-shadow: inset 0 -3px 0 var(--primary); }
:root .dashboard-risk-tab-count { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; min-height: 26px; padding-inline: 6px; border-radius: 8px; background: var(--surface-soft); color: var(--text); flex-shrink: 0; }
:root .dashboard-risk-tab:focus-visible,
:root .dashboard-risk-tab-panel:focus-visible,
:root .dashboard-risk-list:focus-visible,
:root .dashboard-weekly-disclosure > summary:focus-visible { outline: 3px solid var(--ui-focus); outline-offset: 3px; }
:root .dashboard-risk-tab-panel[hidden] { display: none !important; }
:root .dashboard-risk-summary { display: flex; flex-wrap: wrap; gap: 8px 20px; padding: 12px 14px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: var(--ui-radius); background: var(--surface-soft); line-height: 1.8; }
:root .dashboard-risk-summary > .small { flex-basis: 100%; }
:root .dashboard-risk-list { display: grid; gap: 10px; padding: 0; margin: 0; list-style: none; }
:root .dashboard-risk-panel .dashboard-risk-list { max-height: 520px; max-height: min(62dvh, 520px); overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; align-content: start; padding: 3px; }
:root .dashboard-risk-scroll-hint { margin: 0 0 8px; }
:root .dashboard-risk-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, auto); gap: 16px; padding: 16px; border: 1px solid var(--line); border-left: 4px solid var(--amber); border-radius: var(--ui-radius); background: var(--ui-warning-soft); }
:root .dashboard-risk-row[data-risk-level="critical"] { border-left-color: var(--red); background: var(--ui-danger-soft); }
:root .dashboard-risk-person,
:root .dashboard-risk-measure { display: flex; flex-direction: column; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
:root .dashboard-risk-person > strong { font-weight: 500; }
:root .dashboard-risk-measure { align-items: flex-end; text-align: right; }
:root .dashboard-risk-measure > strong { font-size: 1.25rem; color: var(--text); }
:root .dashboard-risk-measure .status { white-space: normal; }
:root .dashboard-risk-footnote { margin: 16px 0 0; line-height: 1.8; }
:root .dashboard-risk-modal { width: min(900px, 100%); }
:root .dashboard-risk-modal .modal-body { background: var(--surface); color: var(--text); overflow-y: auto; }
:root .dashboard-weekly-disclosure { border: 1px solid var(--line); border-radius: var(--ui-radius); padding: 12px; }
:root .dashboard-weekly-disclosure > summary { min-height: 44px; padding: 10px 8px; cursor: pointer; font-weight: 500; color: var(--primary-dark); }

@media (max-width: 1024px) {
  :root .dashboard-risk-panel > :is(.panel-header, .panel-body) { padding: 18px; }
  :root .dashboard-risk-tab { flex-grow: 1; }
  :root .dashboard-quick-form :is(input, select) { min-height: 44px; font-size: 1rem; }
}
@media (max-width: 640px) {
  :root .dashboard-data-note { flex-direction: column; }
  :root .dashboard-risk-panel > :is(.panel-header, .panel-body) { padding: 16px; }
  :root .dashboard-risk-panel > .panel-header > .btn { width: 100%; }
  :root .dashboard-risk-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  :root .dashboard-risk-tab { padding: 10px 8px; font-size: .875rem; }
  :root .dashboard-risk-row { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  :root .dashboard-risk-measure { align-items: flex-start; text-align: left; }
  :root .dashboard-work-action { width: 100%; justify-content: space-between; }
  :root .dashboard-weekly-disclosure { padding: 8px; }
}

/* Task groups and in-page navigation are shared by every role dashboard. */
:root .dashboard-prototype .dashboard-section-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--ui-panel-radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
:root .dashboard-prototype .dashboard-section-nav-label {
  flex: 0 0 auto;
  margin-inline-end: 4px;
  color: var(--muted);
  font-size: .8125rem;
  font-weight: 600;
}
:root .dashboard-prototype .dashboard-section-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--ui-control);
  max-width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--ui-radius);
  background: var(--surface-soft);
  color: var(--primary-dark);
  font-size: .875rem;
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
  white-space: normal;
  transition: background-color var(--motion-fast) ease, border-color var(--motion-fast) ease;
}
:root .dashboard-prototype .dashboard-section-nav a:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}
:root .dashboard-prototype .dashboard-section-nav a:focus-visible {
  outline: 3px solid var(--ui-focus);
  outline-offset: 2px;
}
:root .dashboard-prototype .dashboard-group {
  display: grid;
  align-content: start;
  gap: var(--ui-space-4);
  min-width: 0;
  scroll-margin-top: calc(var(--ui-header) + var(--ui-space-4));
}
:root .dashboard-prototype .dashboard-group-content {
  display: grid;
  align-content: start;
  gap: var(--ui-space-4);
  min-width: 0;
}
:root .dashboard-prototype .dashboard-group > *,
:root .dashboard-prototype .dashboard-group-content > *,
:root .dashboard-prototype .dashboard-group .dashboard-main-grid,
:root .dashboard-prototype .dashboard-group .dashboard-table-scroll,
:root .dashboard-prototype .dashboard-group .dashboard-grade-table-wrap {
  min-width: 0;
  max-width: 100%;
}
:root .dashboard-prototype .dashboard-group :is(.dashboard-table-scroll, .dashboard-grade-table-wrap) {
  overflow-x: auto;
  overscroll-behavior-x: contain;
}
:root .dashboard-prototype .dashboard-group-header,
:root .dashboard-prototype .dashboard-section-heading {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 12px 16px;
  border-inline-start: 4px solid var(--primary);
  border-radius: 0 var(--ui-radius) var(--ui-radius) 0;
  background: var(--surface-soft);
}
:root .dashboard-prototype .dashboard-group-header h2,
:root .dashboard-prototype .dashboard-section-heading h2 {
  margin: 0;
  color: var(--text);
  font-size: clamp(1.0625rem, 1.5vw, 1.25rem);
  font-weight: 700;
  line-height: 1.5;
}
:root .dashboard-prototype .dashboard-group-header p,
:root .dashboard-prototype .dashboard-section-heading p {
  margin: 0;
  color: var(--muted);
  font-size: .875rem;
  line-height: 1.7;
}
:root .dashboard-prototype .dashboard-group:target > :is(.dashboard-group-header, .dashboard-section-heading) {
  border-inline-start-color: var(--teal);
  background: var(--ui-teal-soft);
}

@media (max-width: 1024px) {
  :root .dashboard-prototype .dashboard-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  :root .dashboard-prototype .dashboard-section-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-padding-inline: 12px;
    scrollbar-width: thin;
  }
  :root .dashboard-prototype .dashboard-section-nav a {
    flex: 0 0 auto;
    min-width: 124px;
    max-width: 72vw;
  }
  :root .dashboard-prototype .dashboard-group-header,
  :root .dashboard-prototype .dashboard-section-heading { padding: 10px 12px; }
  :root .dashboard-prototype .dashboard-risk-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-padding-inline: 4px;
    scrollbar-width: thin;
    padding-bottom: 4px;
  }
  :root .dashboard-prototype .dashboard-risk-tab {
    flex: 0 0 clamp(148px, 44vw, 230px);
    justify-content: space-between;
    text-align: left;
    padding: 10px 12px;
  }
  :root .dashboard-prototype .dashboard-risk-tab > span:first-child {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  :root .dashboard-prototype .dashboard-risk-panel .dashboard-risk-list {
    max-height: none;
    overflow-y: visible;
    scrollbar-gutter: auto;
  }
  :root .dashboard-prototype .dashboard-risk-scroll-hint { display: none; }
}
@media (max-width: 430px) {
  :root .dashboard-prototype .dashboard-metric-grid { grid-template-columns: minmax(0, 1fr); }
  :root .dashboard-prototype .dashboard-metric {
    min-height: 104px;
    grid-template-columns: minmax(0, 1fr) 40px;
    align-items: center;
  }
  :root .dashboard-prototype .dashboard-metric-icon {
    width: 40px;
    height: 40px;
    grid-row: auto;
  }
}
@media (prefers-reduced-motion: reduce) {
  :root .dashboard-prototype .dashboard-section-nav a { transition: none; }
}

/* Publication is a separate, deliberate step after staff finish entering grades. */
:root .grade-release-panel { display: grid; gap: var(--ui-space-4); min-width: 0; }
:root .grade-release-filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--ui-space-3); }
:root .grade-release-filters label { display: grid; gap: var(--ui-space-1); min-width: 0; color: var(--text); font-size: .875rem; font-weight: 600; }
:root .grade-release-filters select { width: 100%; min-width: 0; min-height: var(--ui-control); color: var(--text); background: var(--surface); }
:root .grade-release-hint { margin: 0; line-height: 1.7; }
:root .grade-release-summary { margin: 0; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--ui-radius); background: var(--ui-teal-soft); color: var(--text); }
:root .grade-release-summary strong { color: var(--teal); font-size: 1.0625rem; }
:root .grade-release-roster-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--ui-space-3); }
:root .grade-release-roster-head label { display: inline-flex; align-items: center; gap: 10px; min-height: var(--ui-control); font-weight: 600; cursor: pointer; }
:root .grade-release-roster-head span { color: var(--muted); font-size: .875rem; }
:root .grade-release-panel input[type="checkbox"] { width: 20px; height: 20px; flex: 0 0 20px; accent-color: var(--primary-dark); cursor: pointer; }
:root .grade-release-roster { display: grid; gap: 0; max-height: 420px; margin: 0; padding: 0; overflow-y: auto; list-style: none; border: 1px solid var(--line); border-radius: var(--ui-radius); background: var(--surface); }
:root .grade-release-student { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--ui-space-3); min-width: 0; padding: 10px 14px; border-bottom: 1px solid var(--line); }
:root .grade-release-student:last-child { border-bottom: 0; }
:root .grade-release-student:nth-child(even) { background: var(--surface-soft); }
:root .grade-release-student:hover { background: var(--ui-row-hover); }
:root .grade-release-student label { display: flex; align-items: center; gap: 12px; min-width: 0; min-height: var(--ui-control); cursor: pointer; }
:root .grade-release-student-name { display: grid; gap: 1px; min-width: 0; overflow-wrap: anywhere; }
:root .grade-release-student-name strong { color: var(--text); font-size: .9375rem; font-weight: 600; }
:root .grade-release-student-name small { color: var(--muted); font-size: .8125rem; }
:root .grade-release-student .status { white-space: nowrap; }
:root .grade-release-actions { display: flex; flex-wrap: wrap; gap: var(--ui-space-2); }
:root .grade-release-actions .btn { min-height: var(--ui-control); }
:root .grade-release-feedback { margin: 0; padding: 10px 14px; border-radius: var(--ui-radius); background: var(--ui-success-soft); color: var(--green); font-weight: 500; }
:root .grade-release-feedback.is-saving { background: var(--ui-info-soft); color: var(--text); }
:root .grade-release-feedback.is-error, :root .grade-release-feedback[role="alert"] { background: var(--ui-danger-soft); color: var(--red); }
:root .grade-release-panel :is(input, select, button, .grade-release-roster):focus-visible { outline: 3px solid var(--ui-focus); outline-offset: 2px; }
:root .grade-result-pending { display: flex; align-items: flex-start; gap: 16px; padding: 18px; border: 1px solid var(--line); border-radius: var(--ui-radius); background: var(--ui-info-soft); color: var(--text); }
:root .grade-result-pending > span { display: grid; place-items: center; width: 48px; height: 48px; flex: 0 0 48px; border-radius: var(--ui-radius); background: var(--surface); font-size: 1.5rem; }
:root .grade-result-pending strong { display: block; font-size: 1.0625rem; }
:root .grade-result-pending p { margin: 4px 0 0; color: var(--muted); }

@media (max-width: 900px) {
  :root .grade-release-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  :root .grade-release-filters label:last-child { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  :root .grade-release-filters { grid-template-columns: minmax(0, 1fr); }
  :root .grade-release-filters label:last-child { grid-column: auto; }
  :root .grade-release-roster { max-height: min(52vh, 420px); }
  :root .grade-release-student { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  :root .grade-release-student .status { justify-self: start; margin-inline-start: 32px; }
  :root .grade-release-actions { display: grid; grid-template-columns: minmax(0, 1fr); }
  :root .grade-release-actions .btn { width: 100%; white-space: normal; }
  :root .grade-result-pending { padding: 14px; gap: 12px; }
  :root .grade-result-pending > span { width: 40px; height: 40px; flex-basis: 40px; }
}

/* Role dashboards: readable hierarchy and persistent, accessible navigation. */
:root:has(.is-dashboard-view), :root body:has(.is-dashboard-view) { overflow-x: clip; }
:root .dashboard-prototype { gap: 24px; --dashboard-accent: var(--primary); }
:root .dashboard-prototype-student { --dashboard-accent: var(--teal); }
:root .dashboard-prototype-teacher { --dashboard-accent: var(--green); }
:root .dashboard-prototype-principal { --dashboard-accent: var(--purple); }
:root .dashboard-prototype-academic { --dashboard-accent: var(--teal); }
:root .dashboard-prototype-officer { --dashboard-accent: var(--amber); }
:root .dashboard-prototype .dashboard-hero {
  border: 1px solid var(--line); border-top: 4px solid var(--dashboard-accent);
  background: linear-gradient(115deg, color-mix(in srgb, var(--dashboard-accent) 8%, var(--surface)), var(--surface) 65%);
  padding: 28px; box-shadow: var(--shadow-xs);
}
:root .dashboard-prototype .dashboard-kicker { color: var(--dashboard-accent); background: var(--surface); }
:root .dashboard-prototype .dashboard-hero h2 { font-size: clamp(1.4rem, 2.3vw, 2rem); letter-spacing: -.02em; }
:root .dashboard-prototype .dashboard-hero-actions { align-self: stretch; align-content: center; }
:root .dashboard-prototype .dashboard-action { min-height: 96px; border-radius: 14px; text-align: start; }
:root .dashboard-prototype .dashboard-action small { line-height: 1.6; }
:root .dashboard-prototype .dashboard-data-note { margin: -12px 0 -8px; font-size: .8125rem; }
:root .dashboard-prototype .dashboard-section-nav {
  position: sticky; top: var(--dashboard-header-height, 88px); z-index: 3;
  display: flex; flex-wrap: nowrap; overflow: visible; gap: 12px;
  padding: 8px; border-radius: 14px; box-shadow: var(--shadow-sm);
}
:root .dashboard-section-links { display: flex; flex: 1; min-width: 0; gap: 4px; overflow-x: auto; scrollbar-width: thin; padding: 3px; }
:root .dashboard-prototype .dashboard-section-nav a { flex: 0 0 auto; min-width: auto; border-color: transparent; background: transparent; color: var(--muted); white-space: nowrap; }
:root .dashboard-prototype .dashboard-section-nav a[aria-current="location"] { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-dark); }
:root .dashboard-prototype .dashboard-section-picker { display: none; }
:root .dashboard-prototype .dashboard-back-top { flex-shrink: 0; min-height: 44px; padding: 8px 12px; }
:root .dashboard-prototype .dashboard-group { scroll-margin-top: var(--dashboard-anchor-offset, 170px); gap: 16px; }
:root .dashboard-prototype .dashboard-group-header { border: 0; border-radius: 0; padding: 4px 0; background: transparent; }
:root .dashboard-prototype .dashboard-group-header h2 { display: flex; align-items: center; gap: 10px; }
:root .dashboard-prototype .dashboard-group-header h2::before { content: ''; flex: 0 0 4px; height: 22px; border-radius: 4px; background: var(--dashboard-accent); }
:root .dashboard-prototype .dashboard-group-header p { padding-inline-start: 14px; }
:root .dashboard-prototype .dashboard-group:target > .dashboard-group-header { background: transparent; }
:root .dashboard-prototype .dashboard-metric { background: var(--surface); border-top-width: 1px; padding: 22px; position: relative; }
:root .dashboard-prototype .dashboard-metric-text strong { font-size: clamp(1.8rem, 2.5vw, 2.4rem); line-height: 1.4; }
:root .dashboard-prototype .dashboard-metric-en { display: none; }
:root .dashboard-prototype .dashboard-panel { box-shadow: var(--shadow-xs); overflow: hidden; }
:root .dashboard-prototype .dashboard-panel-header { padding: 18px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
:root .dashboard-prototype .dashboard-panel-header h3 { font-size: 1rem; }
:root .dashboard-prototype .dashboard-panel-body { padding: 20px; }
:root .dashboard-prototype .dashboard-score-filter { padding: 16px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 12px; align-items: end; }
:root .dashboard-prototype .dashboard-score-filter label { display: grid; gap: 6px; font-size: .875rem; }
:root .dashboard-prototype .dashboard-score-search { flex: 1 1 240px; }
:root .dashboard-prototype .dashboard-score-filter input { width: 100%; min-height: 44px; }
:root .dashboard-prototype [data-dashboard-score-filter-status] { flex-basis: 100%; }
:root .dashboard-prototype [hidden] { display: none !important; }
:root .dashboard-prototype :is(button, a, select, input, summary):focus-visible { outline: 3px solid var(--ui-focus); outline-offset: 3px; }
:root .dashboard-prototype .dashboard-group-header h2:focus { outline: 2px solid var(--ui-focus); outline-offset: 4px; border-radius: 4px; }
@media (max-width: 900px) {
  :root .dashboard-prototype .dashboard-section-links { display: none; }
  :root .dashboard-prototype .dashboard-section-picker { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; margin: 0; font-size: .8125rem; white-space: nowrap; }
  :root .dashboard-section-picker select { width: 100%; min-width: 0; flex: 1; min-height: 44px; }
  :root .dashboard-prototype .dashboard-section-nav { gap: 8px; }
  :root .dashboard-prototype .dashboard-back-top span { display: none; }
}
@media (max-width: 640px) {
  :root .dashboard-prototype { gap: 20px; }
  :root .dashboard-prototype .dashboard-hero { padding: 18px; }
  :root .dashboard-prototype .dashboard-action { min-height: 76px; padding: 12px; }
  :root .dashboard-prototype .dashboard-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  :root .dashboard-prototype .dashboard-metric { padding: 14px; min-height: 150px; gap: 8px; }
  :root .dashboard-prototype .dashboard-metric-text span { font-size: .8125rem; }
  :root .dashboard-prototype .dashboard-panel-header { padding: 14px; }
  :root .dashboard-prototype .dashboard-panel-body { padding: 14px; }
  :root .dashboard-prototype .dashboard-score-filter { padding: 12px; }
  :root .dashboard-prototype .dashboard-score-filter label { width: 100%; }
  :root .dashboard-prototype .dashboard-score-filter .select { width: 100%; }
}
@media (max-height: 500px) {
  :root .dashboard-prototype .dashboard-section-nav { position: static; }
}

/* Student schedule and grade cards use dark surfaces instead of legacy light fills. */
:root[data-theme="dark"] .dashboard-prototype-student .dashboard-day-card {
  border-color: var(--line);
  background: var(--surface);
}
:root[data-theme="dark"] .dashboard-prototype-student .dashboard-day-header {
  border-bottom: 1px solid var(--line);
  background: var(--ui-teal-soft);
  color: var(--text);
}
:root[data-theme="dark"] .dashboard-prototype-student .dashboard-day-header span {
  color: var(--muted);
}
:root[data-theme="dark"] .dashboard-prototype-student .dashboard-day-slots {
  background: var(--surface);
}
:root[data-theme="dark"] .dashboard-prototype-student .dashboard-lesson {
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--text);
}
:root[data-theme="dark"] .dashboard-prototype-student .dashboard-lesson-time {
  color: var(--teal);
}
:root[data-theme="dark"] .dashboard-prototype-student .dashboard-lesson strong {
  color: var(--text);
}
:root[data-theme="dark"] .dashboard-prototype-student .dashboard-lesson :is(span, small) {
  color: var(--muted);
}
:root[data-theme="dark"] .dashboard-prototype-student .dashboard-lesson-home {
  border-color: color-mix(in srgb, var(--amber) 45%, var(--line));
  background: var(--ui-warning-soft);
}
:root[data-theme="dark"] .dashboard-prototype-student .dashboard-lesson-home .dashboard-lesson-time {
  color: var(--amber);
}
:root[data-theme="dark"] .dashboard-prototype-student .dashboard-lesson-lunch {
  border-color: color-mix(in srgb, var(--red) 45%, var(--line));
  background: var(--ui-danger-soft);
}
:root[data-theme="dark"] .dashboard-prototype-student .dashboard-lesson-lunch .dashboard-lesson-time {
  color: var(--red);
}
:root[data-theme="dark"] .dashboard-prototype-student .dashboard-lesson.is-empty {
  border-color: var(--line);
  background: color-mix(in srgb, var(--surface-soft) 58%, var(--surface));
  color: var(--muted);
}
:root[data-theme="dark"] .dashboard-prototype-student .dashboard-gpa {
  border-color: var(--line-strong);
  background: var(--ui-teal-soft);
}
:root[data-theme="dark"] .dashboard-prototype-student .dashboard-gpa span {
  color: var(--muted);
}
:root[data-theme="dark"] .dashboard-prototype-student .dashboard-gpa strong {
  color: var(--text);
}
:root[data-theme="dark"] .dashboard-prototype-student .dashboard-grade-card dl > div {
  border: 1px solid var(--line);
  background: var(--surface-soft);
}
:root[data-theme="dark"] .dashboard-prototype-student .dashboard-grade-card dt {
  color: var(--muted);
}
:root[data-theme="dark"] .dashboard-prototype-student .dashboard-grade-card dd {
  color: var(--text);
}
:root[data-theme="dark"] .dashboard-prototype-student .dashboard-weekly-disclosure > summary {
  border-color: var(--line-strong);
  background: var(--surface-soft);
  color: var(--text);
  box-shadow: none;
}
:root[data-theme="dark"] .dashboard-prototype-student .dashboard-weekly-disclosure > summary:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}
