/* UG-EDIS production portal. Colours from sch.html brand scale.
   Self-contained — no CDN — so a school with a flaky uplink still
   gets a usable layout.
   Shell polish mirrors Rent Manager structure (display/body fonts,
   soft gradient canvas, quieter panels, 12px nav chips) while
   keeping UG-EDIS green tokens and left-rail layout. */

@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal; font-weight: 600; font-display: optional;
  src: url("fonts/PlusJakartaSans-600.woff2") format("woff2");
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal; font-weight: 700; font-display: optional;
  src: url("fonts/PlusJakartaSans-700.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/Inter-400.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal; font-weight: 500; font-display: optional;
  src: url("fonts/Inter-500.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal; font-weight: 600; font-display: swap;
  src: url("fonts/Inter-600.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal; font-weight: 700; font-display: optional;
  src: url("fonts/Inter-700.woff2") format("woff2");
}

:root {
  /* Shared tokens (colours, fonts, radius, shadows) live in tokens.css,
     loaded first. Only portal-specific extras stay here. */
  --brand-soft: rgba(4, 120, 87, 0.1);
  --brand-glow: rgba(4, 120, 87, 0.28);
  --border-soft: rgba(17, 22, 20, 0.08);
  --warn: var(--warning);
  --warn-bg: #fffbeb;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--canvas);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
body.portal-body {
  display: block;
}

h1, h2, h3, .shell-head h1, .shell-head h2 {
  font-family: var(--font-display);
}

a { color: var(--brand-700); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Login ---------- */
.login-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px;
  width: 100%;
  max-width: 420px;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--brand-700);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 17px;
}
.login-brand h1 { margin: 0; font-size: 17px; }
.login-brand p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 4px; }
input[type="text"], input[type="password"], input[type="date"],
input[type="time"], input[type="number"], input[type="email"],
input[type="datetime-local"], input[type="month"], input[type="tel"], input[type="url"], input[type="search"],
input:not([type]), textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
}
input:focus, textarea:focus { outline: 2px solid var(--brand-100); border-color: var(--brand-600); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  min-height: 40px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); border-radius: var(--r-md);
  box-shadow: 0 1px 2px rgba(4, 120, 87, .3), inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); text-decoration: none; }
.login-card .btn-primary { width: 100%; margin-top: 16px; }
.btn-ghost {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--border-strong);
  font-weight: 500;
}
.btn-ghost:hover { background: var(--bg); text-decoration: none; }
.btn.inline { width: auto; margin-top: 0; }

.err {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  margin: 12px 0 0;
}
.hint { font-size: 12px; color: var(--muted); margin-top: 16px; line-height: 1.45; }

/* ---------- App shell: 264px side panel + slim top bar ---------- */
.portal-layout {
  min-height: 100dvh;
  display: grid;
}
@media (min-width: 1100px) {
  .portal-layout { grid-template-columns: 264px 1fr; }
}
.portal-sidebar {
  display: none;
  flex-direction: column;
  width: 264px;
  max-height: 100dvh;
  position: sticky;
  top: 0;
  background: var(--card);
  border-right: 1px solid var(--border-soft);
  box-shadow: 2px 0 12px -8px rgba(30, 41, 59, 0.15);
  overflow: hidden;
  z-index: 40;
}
@media (min-width: 1100px) {
  .portal-sidebar { display: flex; }
}
.portal-sidebar.is-open {
  display: flex;
  position: fixed;
  inset: 0 auto 0 0;
  box-shadow: 4px 0 24px rgba(17, 22, 20, 0.15);
}
.drawer-back {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(17, 22, 20, 0.4);
}
.portal-side-scroll {
  flex: 1;
  overflow: auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.portal-school-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 16px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border-soft);
}
.portal-school-chip .logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--brand-50);
  border: 1px solid var(--brand-100);
  display: grid;
  place-items: center;
  color: var(--brand-700);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}
.portal-school-chip .meta {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--ink);
  font-family: var(--font-display);
}
.portal-school-chip .meta span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-body);
  margin-top: 2px;
}
.portal-find {
  margin: 10px 6px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(241, 245, 249, 0.85);
}
.portal-find:focus-within {
  border-color: var(--brand-700);
  box-shadow: 0 0 0 3px var(--brand-soft);
  background: #fff;
}
.portal-find input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  padding: 0;
  margin: 0;
}
.portal-find svg { flex-shrink: 0; color: var(--muted); }
.side-nav { display: flex; flex-direction: column; gap: 6px; padding: 4px 2px 8px; }
.portal-side-group {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.85;
  padding: 14px 14px 4px;
}
.portal-side-link {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--n-700);
  text-decoration: none;
  border-left: 0;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.portal-side-link:hover {
  background: rgba(17, 22, 20, 0.04);
  color: var(--ink);
  text-decoration: none;
}
.portal-side-link[aria-current="page"] {
  background: var(--green-50);
  color: var(--green-800);
  font-weight: 600;
}
.portal-side-link[aria-current="page"]:hover {
  background: var(--green-100);
  color: var(--green-800);
}
.portal-side-link[hidden],
.portal-side-group[hidden] { display: none !important; }
.portal-side-foot {
  padding: 14px;
  border-top: 1px solid var(--border-soft);
  background: var(--card);
}
.portal-logout-form { margin: 0; }
.portal-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}
.portal-logout:hover { background: rgba(241, 245, 249, 0.9); }
.portal-powered {
  display: block;
  margin-top: 8px;
  padding: 0 4px;
  font-size: 12px;
  color: var(--muted);
}
.portal-main {
  min-width: 0;
  min-height: 100dvh;
  background: transparent;
}
.slim-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 10px 32px;
  /* Solid first so the bar stays opaque if backdrop-filter is unsupported. */
  background: #ffffff;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--border-soft);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .slim-topbar { background: #ffffff; }
}
.slim-school {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  flex: 1;
  min-width: 0;
}
.slim-school b { font-size: 13px; font-weight: 500; color: var(--muted); }
.slim-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}
.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
}
.sync-pill i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--n-400);
}
.sync-pill.has-pending {
  color: var(--warn);
  border-color: rgba(146, 64, 14, 0.18);
  background: var(--warn-bg);
}
.sync-pill.has-pending i {
  background: #b45309;
}
.menu-btn {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}
@media (min-width: 1100px) {
  .menu-btn { display: none; }
}

/* Legacy top-nav kept for any leftover markup / tests that inspect links */
.top-nav { display: none; }
.top-nav-link { display: none; }
.brand-lockup { display: flex; align-items: center; gap: 10px; }
.student-picker { display: grid; gap: 6px; }
.student-picker-filter {
  width: 100%;
  box-sizing: border-box;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  font: inherit;
  background: #fff;
}
.student-picker-filter:focus {
  outline: 2px solid var(--brand-soft);
  border-color: var(--brand-600);
}
.who { text-align: right; font-size: 12px; }
.who .name { font-weight: 700; }
.who .meta { color: var(--muted); font-size: 12px; }
.who-row { display: flex; align-items: center; gap: 10px; }
.rolebar { display: none; }
.role-pill {
  display: inline-block;
  background: var(--brand-700);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 10px;
}

main.shell {
  max-width: none;
  margin: 0;
  padding: 28px 32px 48px;
  width: 100%;
}
.shell-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.shell-head h1,
.shell-head h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.shell-head p { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.shell-head .head-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.counter {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  padding: 0;
}
@media (max-width: 1280px) {
  .slim-topbar,
  main.shell { padding-left: 24px; padding-right: 24px; }
}

/* ---------- Module grid (sch.html card shape) ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.module-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  color: inherit;
  text-decoration: none;
}
.module-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.05); }
.module-card.is-disabled { opacity: 0.85; cursor: default; }
.module-card.is-disabled:hover { transform: none; box-shadow: none; }
.module-icon {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--brand-50);
  color: var(--brand-700);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
}
.module-card h3 { margin: 0; font-size: 13px; }
.module-card p { margin: 4px 0 0; font-size: 12px; color: var(--muted); }

/* ---------- Home school counts ---------- */
.dash-panel { padding-bottom: 14px; }
.dash-head { margin-bottom: 12px; }
.dash-head h3 { margin: 0; font-size: 15px; }
.dash-head .muted { margin: 4px 0 0; }
.dash-scroll {
  max-height: min(220px, 32vh);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 2px;
  margin: 0 -2px;
  border-radius: 12px;
  -webkit-overflow-scrolling: touch;
}
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.dash-stat {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  min-width: 0;
}
.dash-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.dash-stat strong {
  display: block;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

/* ---------- Home roster (learners) ---------- */
.roster-panel { padding-bottom: 14px; }
.roster-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}
.roster-head h3 { margin: 0; font-size: 15px; }
.roster-head .muted { margin: 4px 0 0; }
.roster-scroll {
  max-height: min(420px, 55vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 2px 8px;
  margin: 0 -2px;
  border-radius: 12px;
  -webkit-overflow-scrolling: touch;
}
.roster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.learner-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  min-height: 88px;
  transition: box-shadow 0.15s ease, transform 0.15s ease, background 0.15s ease;
}
.learner-card:hover {
  background: var(--card);
  box-shadow: 0 8px 16px -8px rgb(0 0 0 / 0.12);
  transform: translateY(-1px);
}
.learner-card-body { min-width: 0; flex: 1; }
.learner-card h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  overflow-wrap: anywhere;
}
.learner-card p {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--muted);
}
.learner-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
}
.roster-foot { margin: 12px 0 0; font-size: 13px; }
.lab-scroll {
  max-height: min(480px, 60vh);
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.lab-enter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 0;
}
.lab-enter-form select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 8px;
}
.lab-module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  padding: 2px;
}
.lab-module {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}
.lab-module.is-ready { border-color: #a7f3d0; }
.lab-module.is-blocked { border-color: #fde68a; }
.lab-module.is-missing { opacity: 0.85; }
.lab-module-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 6px;
}
.lab-module p { margin: 0; font-size: 12px; color: var(--muted); }
.rolebar-inner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.role-lab-link {
  font-size: 13px;
  font-weight: 700;
  color: var(--brand-700);
}
.report-peer-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 14px;
  padding: 10px 12px;
  background: var(--brand-50);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.report-peer-nav .btn { margin: 0; }
.tag {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  background: var(--brand-50);
  color: var(--brand-800);
  border: 1px solid var(--brand-100);
  padding: 2px 7px;
  border-radius: 999px;
}
.tag.warn { background: var(--warn-bg); color: var(--warn); border-color: #fde68a; }

.banner {
  background: var(--warn-bg);
  border: 1px solid #fde68a;
  color: var(--warn);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 18px;
}

.not-found { text-align: center; padding: 64px 16px; }

.flash {
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}
.flash.ok { background: var(--brand-50); color: var(--brand-800); border: 1px solid var(--brand-100); }
.flash.err { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }

.table-wrap { overflow-x: auto; max-width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th {
  font-size: 12px;
  text-transform: none;
  color: var(--muted);
  letter-spacing: 0;
  background: var(--head);
  font-weight: 600;
}
table.data tr:last-child td { border-bottom: none; }
table.data td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data .name-cell b { display: block; font-size: 15px; font-weight: 700; }
table.data .name-cell a { color: inherit; }
table.data .name-cell a:hover { color: var(--brand-700); }
table.data .name-cell span { display: block; font-size: 13px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.status-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
}
.status-tag.active { background: var(--brand-50); color: var(--brand-800); }
.status-tag.suspended { background: var(--warn-bg); color: var(--warn); }
.status-tag.other { background: var(--n-100); color: var(--muted); }
.ugx.due { color: var(--danger); font-weight: 700; }
.ugx.ok { color: var(--brand-700); font-weight: 700; }
.finder-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.finder-card .searchrow {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.finder-card .searchrow label {
  flex: 1;
  min-width: 200px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 0 14px;
  min-height: 48px;
  background: #fff;
  font-weight: 400;
}
.finder-card .searchrow input:not(.student-picker-filter) {
  border: 0;
  outline: 0;
  padding: 0;
  margin: 0;
  min-height: 0;
  font-size: 15px;
}
.finder-card .filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}
.finder-card .filters label { margin: 0; font-size: 13px; color: var(--muted); font-weight: 500; }
.finder-card .finder-go { min-height: 48px; padding: 0 20px; }
.finder-field { display: flex; flex-direction: column; gap: 6px; min-width: 200px; }
.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;
}
.panel.sheet { padding: 0; overflow: hidden; }
.panel-form { padding: 16px; border-top: 1px solid var(--line); }
.panel .hint { margin: 12px 0 0; }
.empty-note { padding: 28px 16px; text-align: center; }
table.data.lean tbody tr {
  content-visibility: auto;
  contain-intrinsic-size: auto 56px;
}
table.data.hover-rows tbody tr { transition: background 0.16s ease; }
table.data.hover-rows tbody tr:hover { background: #f4fbf8; }
.class-card h3 { margin: 0; }
.class-card .panel-head p { margin: 4px 0 0; }
.listhead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin: 8px 2px 12px;
}
.listhead h2 { margin: 0; font-size: 17px; font-weight: 700; }
.listhead span { font-size: 14px; color: var(--muted); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--e-1);
}
.panel h3 { margin: 0 0 12px; font-size: 17px; font-weight: 700; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: -16px -16px 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.panel-head h3 { margin: 0; font-size: 15px; }
.panel-body { margin: 0; }
.panel .table-wrap { border: 0; border-radius: 0; background: transparent; }
.panel-head + .table-wrap { margin: -14px -16px -16px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px 14px;
  align-items: end;
}
.form-grid label { margin-top: 0; }
.form-grid .span-2 { grid-column: span 2; }
select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  background: #fff;
}
.btn-primary.inline { width: auto; margin-top: 0; }
.muted { color: var(--muted); font-size: 12px; }
.ugx { font-variant-numeric: tabular-nums; }
.ugx.due { color: var(--danger); font-weight: 700; }
.ugx.ok { color: var(--brand-800); font-weight: 700; }
.status-present { color: var(--brand-800); font-weight: 600; }
.status-absent { color: var(--danger); font-weight: 600; }
.status-late, .status-half_day { color: var(--warn); font-weight: 600; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; padding-bottom: 8px; }
.check input { width: auto; }
.sub { margin: 16px 0 8px; font-size: 13px; font-weight: 700; }
.stream-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 12px; }
.chip {
  display: inline-flex; align-items: center; min-height: 32px;
  background: #fff; border: 1px solid var(--border-strong); border-radius: 999px;
  padding: 0 12px; font-size: 13px; font-weight: 500; color: var(--ink);
}
.role-filters {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin: 0 0 16px; font-size: 14px;
}
.role-filters a {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--border-strong); background: #fff;
  color: var(--ink); font-weight: 500; text-decoration: none;
}
.role-filters a:hover { background: var(--bg); text-decoration: none; }
.role-filters a.is-on {
  background: var(--brand-800); border-color: var(--brand-800); color: #fff;
}
.metric-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px; margin: 0 0 20px;
}
.metric-row .c {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 4px;
}
.metric-row .k { font-size: 13px; color: var(--muted); }
.metric-row .v { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.metric-row .s { font-size: 13px; color: var(--muted); }
.ugx { font-variant-numeric: tabular-nums; font-weight: 600; }
table.data td.num .ugx { font-weight: 700; }

@media (max-width: 600px) {
  .topbar-inner { height: auto; min-height: 64px; padding: 10px 12px; flex-wrap: wrap; }
  .who-row { align-items: flex-end; gap: 6px; }
  .who .name { max-width: 120px; overflow-wrap: anywhere; }
  .shell { padding-left: 12px; padding-right: 12px; }
  .shell-head { align-items: flex-start; }
  .panel { padding: 14px; }
  .panel-head { margin: -14px -14px 12px; padding: 12px 14px; }
  .panel-head + .table-wrap { margin: -12px -14px -14px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: auto; }
  .shell-head { flex-wrap: wrap; align-items: flex-start; }
  .shell-head > * { min-width: 0; max-width: 100%; }
  .shell-head h2, .shell-head h3, .shell-head p { overflow-wrap: anywhere; }
  .btn, input[type="text"], input[type="password"], input[type="date"],
  input[type="time"], input[type="number"], input[type="email"],
  input[type="datetime-local"], input[type="month"], input[type="tel"], input:not([type]), select, textarea {
    min-height: 44px;
  }
  .btn-primary.inline { width: 100%; }
  .btn-ghost { padding: 8px 10px; min-height: 44px; }
  .mode-toggle { display: flex; width: 100%; }
  .mode-toggle a { flex: 1; min-height: 44px; display: flex; align-items: center; justify-content: center; text-align: center; }
}

/* ---------- Marks entry (grade pill, cutoff legend, mode toggle) ---------- */
.grade-pill { display: inline-flex; min-width: 22px; justify-content: center; padding: 2px 7px;
  border-radius: 8px; font-weight: 800; font-size: 12px; background: var(--brand-50); color: var(--brand-800); }
.legend { font-size: 12px; color: var(--muted); margin-top: 10px; line-height: 1.6; }
.mode-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 12px; }
.mode-toggle a { padding: 6px 14px; font-size: 12px; font-weight: 700; color: var(--muted); }
.mode-toggle a.active { background: var(--brand-700); color: #fff; }

/* ---------- Home — benchmark metric cards + module groups ---------- */
.home-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.home-summary > div {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.home-summary-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}
.home-summary-val {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.home-summary-val--warn { color: var(--danger); }
.home-summary-note { font-size: 13px; color: var(--muted); }
.home-summary-note a { font-weight: 600; }
.dash-stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}
.dash-label { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.dash-stat strong {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.home-mod-lede { margin: 0 0 12px; font-size: 14px; }
.home-mod-grids {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.home-mod-card { margin-bottom: 0; box-shadow: none; }
.home-mod-card .panel-head h3 { font-size: 17px; font-weight: 700; }
.home-mod-table td:first-child a { font-weight: 600; color: var(--ink); }
.home-mod-table td:first-child a:hover { color: var(--brand-700); }
.home-mod-row.is-disabled td { opacity: 0.85; }
.module-card { box-shadow: none; }
@media (max-width: 900px) {
  .home-summary { grid-template-columns: 1fr 1fr; }
  .home-mod-grids { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .home-summary { grid-template-columns: 1fr; }
}

/* Shown after a click or form post, once the next page is taking
   long enough to notice. The shell stays. The new document replaces this. */
.page-pending[hidden] { display: none !important; }
.page-pending { display: flex; flex-direction: column; gap: 16px; }
body.is-page-pending main.shell > :not(#page-pending) { display: none; }
.skel {
  display: block;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--border) 0%, var(--surface-2) 45%, var(--border) 100%);
  background-size: 200% 100%;
  animation: skel-shimmer 1.2s ease-in-out infinite;
}
.skel-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.skel-stats .skel { height: 84px; }
.skel-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.skel-line { height: 14px; width: 42%; }
.skel-line--short { width: 26%; }
.skel-row { height: 44px; width: 100%; }
.page-pending-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
@media (max-width: 700px) {
  .skel-stats { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .skel { animation: none; background: var(--border); }
}
@keyframes skel-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* ---- School theme styles (schools.theme_style) ------------------------
   classic: default light shell. vivid: brand-coloured side menu.
   elegant: warm cream canvas with serif headings. Colours come from the
   school's own --brand-* tokens injected in base.html. */
body.theme-vivid .portal-sidebar,
body.theme-vivid .portal-side-foot { background: var(--brand-800); border-color: transparent; }
body.theme-vivid .portal-school-chip { border-color: rgba(255,255,255,.14); }
body.theme-vivid .portal-school-chip .meta { color: #fff; }
body.theme-vivid .portal-school-chip .meta span,
body.theme-vivid .portal-side-group { color: rgba(255,255,255,.7); }
body.theme-vivid .portal-school-chip .logo { background: var(--brand-accent, #fff); border-color: transparent; color: #111827; }
body.theme-vivid .portal-side-link { color: rgba(255,255,255,.86); }
body.theme-vivid .portal-side-link:hover { background: rgba(255,255,255,.1); color: #fff; }
body.theme-vivid .portal-side-link[aria-current="page"] { background: #fff; color: var(--brand-800); border-left-color: var(--brand-accent, #fff); box-shadow: none; }
body.theme-vivid .portal-find { background: rgba(255,255,255,.12); border-color: transparent; }
body.theme-vivid .portal-find input, body.theme-vivid .portal-find svg { color: #fff; }
body.theme-vivid .portal-find input::placeholder { color: rgba(255,255,255,.7); }
body.theme-vivid .portal-logout { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.2); }
body.theme-vivid .portal-powered { color: rgba(255,255,255,.6); }
body.theme-vivid .slim-topbar { border-bottom: 3px solid var(--brand-accent, var(--brand-700)); }
body.theme-elegant { --font-display: Georgia, "Times New Roman", serif; --canvas: #fbf8f2; --bg: var(--canvas); --bg-mid: #f6f1e7; }
body.theme-elegant .portal-sidebar, body.theme-elegant .portal-side-foot { background: #fffdf8; }
body.theme-elegant h1, body.theme-elegant h2, body.theme-elegant h3 { font-family: var(--font-display); }
body.theme-elegant .slim-topbar { border-bottom: 2px solid var(--brand-accent, var(--line)); }

/* =====================================================================
   2026-10 polish: dashboard KPIs, charts, data tables, forms, empty
   states, print. Same tokens as ug-edis-web-preview.html.
   ===================================================================== */
.portal-sidebar { height: 100dvh; }

/* KPI cards */
.kpi-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 0 0 18px; }
.kpi { display: flex; flex-direction: column; gap: 6px; padding: 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--e-1); color: var(--text); text-decoration: none; position: relative; overflow: hidden;
  transition: border-color .15s ease, box-shadow .15s ease; }
a.kpi:hover { border-color: var(--border-strong); box-shadow: var(--e-2); text-decoration: none; }
.kpi-label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.kpi-value { font-family: var(--font-display); font-size: var(--fs-stat); font-weight: 700; line-height: 32px; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 13px; color: var(--text-3); font-weight: 600; }
.kpi-note { font-size: 12px; color: var(--text-3); }
.kpi-warn { background: linear-gradient(#FFFCF5, var(--surface)); border-color: #F7D9A8; }
.kpi-warn .kpi-label { color: var(--warning); }
.delta { font-weight: 700; }
.delta.up { color: #047857; } .delta.down { color: var(--danger); }
.progress { height: 6px; border-radius: 99px; background: var(--brand-50); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand-600); border-radius: inherit; }

/* Charts */
.chart-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.chart-grid .panel { margin: 0; }
.chart-wide { grid-column: span 2; }
.chart-panel .panel-head h3 { font-size: 15px; margin: 0; }
.chart { margin: 0; }
.chart-line svg { width: 100%; height: 190px; display: block; }
.chart-grid line.chart-grid, .chart .chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis { font-size: 12px; fill: var(--muted); font-family: var(--font-body); }
.chart-stroke { fill: none; stroke: var(--brand-600); stroke-width: 2.5; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.chart-area { stroke: none; }
.chart-tip rect { fill: #111614; }
.chart-tip text { fill: #fff; font-size: 12px; font-weight: 600; }
.chart-dot { fill: var(--card); stroke: var(--brand-700); stroke-width: 2; }
.bar-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.bar-list li { display: grid; grid-template-columns: 64px 1fr 34px; align-items: center; gap: 10px; font-size: 13px; }
.bar-label { color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 10px; background: var(--brand-50); border-radius: 99px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-600), var(--brand-700)); border-radius: inherit; }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.col-chart { display: flex; align-items: flex-end; gap: 8px; height: 170px; padding-top: 6px; }
.col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; min-width: 0; }
.col-bar { width: 100%; max-width: 36px; min-height: 2px; background: var(--brand-600); border-radius: 6px 6px 2px 2px; }
.col:nth-child(even) .col-bar { background: var(--brand-700); }
.col-val { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.col-label { font-size: 12px; font-weight: 700; }
.glance { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0; }
.glance div { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.glance dt { font-size: 12px; color: var(--muted); }
.glance dd { margin: 2px 0 0; font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.notice-list { list-style: none; margin: 0 0 10px; padding: 0; }
.notice-list li { display: grid; grid-template-columns: 92px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.notice-list li:last-child { border-bottom: 0; }
.notice-list time { font-size: 12px; color: var(--brand-700); font-weight: 700; background: var(--brand-50); border-radius: 8px; padding: 4px 8px; height: fit-content; text-align: center; }
.notice-list p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

/* Empty states */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center;
  padding: 28px 16px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); background: var(--bg); }
.empty-state::before { content: ""; width: 38px; height: 38px; border-radius: 12px; background: var(--brand-50);
  box-shadow: inset 0 0 0 2px var(--brand-100); margin-bottom: 6px; }
.empty-state strong { color: var(--ink); font-size: 15px; }
.empty-state.small { padding: 22px 12px; }
td.empty-cell { padding: 0 !important; background: var(--card) !important; }
td.empty-cell .empty-state { border: 0; border-radius: 0; }

/* Data-table tools (added by portal.js to every table with 8+ rows) */
.table-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 0; }
.table-tools input[type=search] { min-width: 220px; flex: 1; max-width: 360px; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 10px; font: inherit; font-size: 14px; background: var(--card); }
.table-tools .tt-count { font-size: 13px; color: var(--muted); }
.table-pager { display: flex; align-items: center; justify-content: flex-end; gap: 6px; padding: 10px 0 2px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.table-pager button { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 6px 11px; font: inherit; cursor: pointer; color: var(--ink); }
.table-pager button[aria-current="page"] { background: var(--brand-700); border-color: var(--brand-700); color: #fff; }
.table-pager button:disabled { opacity: .45; cursor: default; }
table.data th[data-sort] { cursor: pointer; user-select: none; white-space: nowrap; }
table.data th[data-sort]::after { content: " ↕"; color: var(--border-strong); font-size: 12px; }
table.data th[aria-sort="ascending"]::after { content: " ▲"; color: var(--brand-700); }
table.data th[aria-sort="descending"]::after { content: " ▼"; color: var(--brand-700); }
.table-wrap { overflow-x: auto; }
table.data thead th { position: sticky; top: 0; z-index: 1; }
table.data tbody tr:hover { background: var(--brand-50); }

/* Forms: inline validation */
.field-error { display: block; color: var(--danger); font-size: 13px; font-weight: 600; margin-top: 4px; }
input.is-invalid, select.is-invalid, textarea.is-invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 3px rgba(185,28,28,.12) !important; }
label:has(> [required]) > :first-child, label.req { }
.req-mark { color: var(--danger); margin-left: 2px; }

@media (max-width: 1100px) { .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1280px) { .chart-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 760px) {
  .kpi-row, .chart-grid { grid-template-columns: 1fr; }
  .chart-wide { grid-column: auto; }
  .table-tools input[type=search] { min-width: 0; max-width: none; width: 100%; }
  .notice-list li { grid-template-columns: 1fr; gap: 4px; }
  .notice-list time { width: fit-content; }
}

/* Print: report cards and any page print cleanly on A4 */
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff !important; }
  .portal-sidebar, .slim-topbar, .drawer-back, .head-actions, .table-tools, .table-pager, .no-print, .flash,
  .page-pending, form.finder-card, .report-peer-nav, #open-side-menu, nav { display: none !important; }
  .portal-layout { display: block !important; }
  .shell { padding: 0 !important; max-width: none !important; }
  .panel { box-shadow: none !important; border: 1px solid var(--border-strong) !important; break-inside: avoid; }
  table.data thead th { position: static; }
  table.data tbody tr[hidden] { display: table-row !important; }
  a { color: inherit !important; text-decoration: none !important; }
  .print-only { display: block !important; }
}
.print-only { display: none; }
@media (max-width: 760px) {
  .kpi-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px 12px 12px 16px; }
  .kpi-value { font-size: 24px; }
  .kpi-label { font-size: 12px; }
}
tr.row-detail td { padding-top: 0; background: transparent; }
details.row-edit > summary { cursor: pointer; color: var(--brand-700); font-size: 13px; font-weight: 600; padding: 4px 0 10px; list-style: none; }
details.row-edit > summary::before { content: "✎ "; }
details.row-edit[open] { background: var(--bg); border-radius: 10px; padding: 10px 12px 12px; margin-bottom: 8px; }
details.row-edit form + form { margin-top: 10px; }
.change-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 6px; max-width: 560px; }
.change-list li { font-size: 12px; background: var(--bg); border-radius: 6px; padding: 2px 8px; overflow-wrap: anywhere; }
.cl-field { color: var(--muted); font-weight: 600; margin-right: 4px; text-transform: capitalize; }
.change-list del { color: var(--danger); } .change-list ins { text-decoration: none; color: #047857; font-weight: 600; }
/* Report card sheet (screen + A4 print) */
.report-sheet { max-width: 900px; margin: 0 auto; }
.rs-head { display: flex; align-items: center; gap: 16px; padding-bottom: 14px; border-bottom: 3px solid var(--brand-700); }
.rs-logo { width: 64px; height: 64px; border-radius: 14px; background: var(--brand-700); color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 24px; overflow: hidden; flex: none; }
.rs-logo img { width: 100%; height: 100%; object-fit: cover; }
.rs-school h2 { margin: 0; font-size: 24px; color: var(--brand-800); font-family: var(--font-display); }
.rs-school p { margin: 4px 0 0; color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 12px; letter-spacing: .06em; }
.rs-learner { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 16px 0; }
.rs-learner div { background: var(--brand-50); border-radius: 10px; padding: 8px 12px; }
.rs-learner dt { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.rs-learner dd { margin: 2px 0 0; font-weight: 700; }
.rs-section { font-size: 14px; text-transform: uppercase; letter-spacing: .05em; color: var(--brand-700); margin: 18px 0 8px; }
.rs-section small { text-transform: none; letter-spacing: 0; color: var(--muted); font-weight: 500; margin-left: 6px; }
.rs-table th, .rs-table td { padding: 8px 12px; }
.rs-conduct { margin: 0; }
.rs-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 22px; }
.rs-sign div { display: flex; flex-direction: column; gap: 14px; font-size: 13px; }
.rs-sign span { font-weight: 700; }
.rs-sign i { display: block; border-bottom: 1px solid var(--n-400); height: 14px; }
.rs-sign em { color: var(--muted); font-size: 12px; font-style: normal; }
.rs-foot { margin: 18px 0 0; font-size: 12px; color: var(--muted); text-align: center; }
.rs-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
@media (max-width: 700px) { .rs-learner { grid-template-columns: 1fr 1fr; } .rs-sign { grid-template-columns: 1fr; } }
@media print {
  .report-sheet { max-width: none; }
  .rs-learner div { background: var(--n-100) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .rs-head, .rs-logo { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .shell-head { display: none !important; }
  .panel:has(.report-sheet) { border: 0 !important; padding: 0 !important; }
}
/* Phone: long tables become stacked cards (labels come from the header) */
@media (max-width: 600px) {
  table.data.has-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.data.has-cards, table.data.has-cards tbody, table.data.has-cards tr, table.data.has-cards td { display: block; width: 100%; box-sizing: border-box; }
  table.data.has-cards tr { border: 1px solid var(--line); border-radius: 12px; margin: 0 0 10px; padding: 6px 4px; background: var(--card) !important; }
  table.data.has-cards tr[hidden] { display: none; }
  table.data.has-cards td { border: 0 !important; padding: 6px 10px !important; text-align: left !important; white-space: normal !important; }
  table.data.has-cards td[data-label] { display: grid; grid-template-columns: minmax(90px, 38%) 1fr; gap: 10px; align-items: start; }
  table.data.has-cards td[data-label]::before { content: attr(data-label); font-size: 12px; font-weight: 700; color: var(--muted);
    text-transform: uppercase; letter-spacing: .04em; padding-top: 2px; }
  table.data.has-cards td[data-label=""]::before { content: none; }
  table.data.has-cards td:empty { display: none; }
  table.data.has-cards tr.row-detail { margin-top: -10px; border-top: 0; border-radius: 0 0 12px 12px; }
  .table-wrap { overflow: visible; }
}
.chart-wide .glance { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 760px) { .chart-wide .glance { grid-template-columns: 1fr 1fr; } }

/* DS-W6: branded error pages (404 / 500) */
body.error-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--canvas); }
.error-card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl);
  box-shadow: var(--e-2); padding: 32px 28px; text-align: center; }
.error-mark { width: 44px; height: 44px; margin: 0 auto 16px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--green-800), var(--green-950)); color: #fff; font-family: var(--font-display);
  font-weight: 700; font-size: 14px; }
.error-code { margin: 0 0 4px; font-size: 12px; font-weight: 600; color: var(--text-3); }
.error-card h1 { margin: 0 0 8px; font-family: var(--font-display); font-size: 24px; color: var(--text); }
.error-text { margin: 0 auto 20px; max-width: 320px; font-size: 14px; line-height: 21px; color: var(--text-2); }
.error-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.error-actions .btn { min-height: 44px; }

/* V2-W1: fee receipt v2 (DESIGN_SYSTEM §13 "Success and receipt") */
.receipt { max-width: 520px; padding: 22px 22px 18px; }
.receipt-head { display: flex; align-items: center; gap: 12px; }
.receipt-crest { width: 44px; height: 44px; flex: none; border-radius: var(--r-md); display: grid; place-items: center;
  background: var(--brand-primary, var(--green-800)); color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 17px; }
.receipt-school { margin: 0; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.receipt-title { margin: 2px 0 0; font-family: var(--font-display); font-size: 24px; line-height: 30px; color: var(--text); }
.receipt-meta { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 14px; font-size: 13px; color: var(--text-2); }
.receipt-number { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.receipt-perf { position: relative; height: 0; margin: 16px -22px; border-top: 2px dashed var(--border-strong); }
.receipt-perf::before, .receipt-perf::after { content: ""; position: absolute; top: -10px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--canvas); }
.receipt-perf::before { left: -9px; } .receipt-perf::after { right: -9px; }
.receipt-kv { margin: 0; display: grid; gap: 0; }
.receipt-kv div { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.receipt-kv dt { color: var(--text-3); font-size: 13px; }
.receipt-kv dd { margin: 0; font-weight: 600; text-align: right; font-size: 14px; }
.receipt-mode { text-transform: capitalize; }
.receipt-total { border-bottom: 0 !important; }
.receipt-total dd { font-family: var(--font-display); font-size: 24px; font-weight: 700; color: var(--green-800); font-variant-numeric: tabular-nums; }
.receipt-words { margin: 8px 0 0; padding: 10px 12px; border-radius: var(--r-sm); background: var(--green-25); color: var(--text);
  font-size: 14px; font-weight: 600; }
.receipt-words span { display: block; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 2px; }
.receipt-sign { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: end; margin-top: 22px; font-size: 13px; }
.receipt-sign span { font-weight: 600; }
.receipt-sign i { display: block; border-bottom: 1px solid var(--n-400); height: 18px; }
.receipt-sign em { grid-column: 2; color: var(--text-3); font-size: 12px; font-style: normal; }
.receipt-foot { margin: 16px 0 0; color: var(--text-3); font-size: 12px; text-align: center; }
.receipt-actions { margin-top: 14px; display: flex; justify-content: flex-end; }
.receipt-balance { margin-top: 6px; }
.receipt-first { margin-top: 12px; border-top: 1px solid var(--border); }
.receipt-balance div { border-bottom: 0; }
.receipt-verify { display: flex; align-items: center; gap: 14px; margin-top: 14px; padding: 12px; border-radius: var(--r-md); background: var(--n-25, #f8faf9); border: 1px solid var(--border); }
.receipt-qr { flex: none; display: block; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); line-height: 0; }
.receipt-verify b { display: block; font-size: 14px; color: var(--text); }
.receipt-verify span { display: block; font-size: 13px; line-height: 17px; color: var(--text-2); margin-top: 2px; }
@media print {
  .receipt { max-width: 140mm; margin: 0 auto; border: 1px solid var(--border-strong) !important; }
  .receipt-perf::before, .receipt-perf::after { background: #fff; }
  .receipt-crest, .receipt-words { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .shell-head { display: none !important; }
}

/* ADM-W1: platform context in the top bar (superadmin only) */
.crest { width: 34px; height: 34px; flex: none; border-radius: 10px; display: grid; place-items: center; color: #fff;
  font-family: var(--font-display); font-weight: 700; font-size: 12px; letter-spacing: .02em;
  background: linear-gradient(145deg, var(--green-800), var(--green-950)); box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.crest.platform { background: linear-gradient(145deg, var(--n-700), var(--n-900)); }
.envpill { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: var(--r-pill);
  background: var(--n-900); color: #fff; font-size: 12px; font-weight: 600; white-space: nowrap; }
.envpill i { width: 6px; height: 6px; border-radius: 50%; background: var(--green-300); }
@media (max-width: 600px) { .envpill { display: none; } }

/* ADM-W2: dense data table and filter bar (DESIGN_SYSTEM §17) */
.panel-gap { margin-top: 16px; }
.inline-form { display: inline; }
.code { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: 6px; background: var(--n-100);
  color: var(--n-700); font-size: 12px; font-weight: 600; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.fbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; margin: 0 0 12px; }
.views { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--n-100); }
.views a { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 8px;
  color: var(--text-2); font-size: 13px; font-weight: 600; text-decoration: none; }
.views a b { font-weight: 600; color: var(--text-3); font-variant-numeric: tabular-nums; }
.views a.on { background: var(--surface); color: var(--text); box-shadow: var(--e-1); }
.fsearch input { height: 36px; min-width: 220px; border-radius: 10px; border: 1px solid var(--border-strong); padding: 0 12px; }
.fclear { color: var(--green-800); font-size: 13px; font-weight: 600; }
.fcount { margin-left: auto; color: var(--text-3); font-size: 13px; }
.dt-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--e-1); overflow: hidden; }
table.dt { width: 100%; border-collapse: collapse; font-size: 13px; line-height: 18px; }
table.dt thead th { height: 36px; padding: 0 14px; text-align: left; background: var(--surface-2); color: var(--text-2);
  font-size: 12px; font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.dt tbody td { height: 48px; padding: 6px 14px; border-bottom: 1px solid var(--n-100); vertical-align: middle; }
table.dt tbody tr:hover td { background: var(--n-25); }
table.dt tbody tr.dim td { color: var(--text-3); }
table.dt .num { text-align: right; font-variant-numeric: tabular-nums; }
table.dt .dt-actions { white-space: nowrap; text-align: right; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who .crest { width: 30px; height: 30px; font-size: 12px; border-radius: 8px; }
.who b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 12px; margin-top: 2px; }
tr.dim .who .crest { background: var(--n-300); }
.pkg { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 260px; }
.dotst { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; }
.dotst i { width: 8px; height: 8px; border-radius: 50%; background: var(--n-400); }
.dotst.ok i { background: var(--green-600); } .dotst.danger { color: var(--danger); } .dotst.danger i { background: var(--danger); }
.dotst.warn i { background: var(--warning-icon); }
.dt-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px;
  background: var(--surface-2); color: var(--text-3); font-size: 12px; }
@media (max-width: 760px) {
  .dt-wrap { overflow-x: auto; }
  .fsearch input { min-width: 0; width: 100%; }
  .fcount { margin-left: 0; }
}

/* ADM-W3: danger confirm dialog (DESIGN_SYSTEM §17 "Danger actions") */
.btn.danger-outline { color: var(--danger); border-color: #FECACA; }
.btn.danger-outline:hover { background: var(--danger-bg); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:disabled { opacity: .45; cursor: not-allowed; }
dialog.dlg { width: min(540px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: var(--r-xl); box-shadow: var(--e-3);
  background: var(--surface); color: var(--text); }
dialog.dlg::backdrop { background: rgba(17, 22, 20, .48); }
.dlg-body { padding: 22px 24px 8px; display: grid; gap: 12px; }
.dlg-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--danger-bg);
  color: var(--danger); font-family: var(--font-display); font-weight: 700; font-size: 24px; }
.dlg-body h2 { margin: 0; font-family: var(--font-display); font-size: 17px; line-height: 24px; }
.dlg-what { margin: 0; padding-left: 18px; color: var(--text-2); font-size: 13px; display: grid; gap: 4px; }
.dlg-body label { display: block; font-size: 13px; font-weight: 600; }
.dlg-body label .muted { font-weight: 500; }
.dlg-body textarea, .dlg-body input { display: block; width: 100%; box-sizing: border-box; margin-top: 6px; font-size: 16px; min-height: 44px; border-radius: var(--r-md); border: 1px solid var(--border-strong); padding: 8px 12px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 24px; margin-top: 12px; background: var(--surface-2);
  border-top: 1px solid var(--border); }

/* ADM-W4: inline code check and per-field server errors */
.code-status { display: block; min-height: 18px; font-size: 13px; font-weight: 600; }
.code-status.ok { color: var(--success); } .code-status.bad { color: var(--danger); }
input[aria-invalid="true"] { border-color: #B91C1C; box-shadow: 0 0 0 3px rgba(185, 28, 28, .1); }

/* ADM-W5: audit viewer (DESIGN_SYSTEM §17 "Audit row") */
.aud-tz { margin: 4px 0 12px; font-size: 13px; }
.aud { display: grid; gap: 16px; }
.aud-group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--e-1); overflow: hidden; }
.aud-day { display: flex; justify-content: space-between; align-items: center; margin: 0; padding: 10px 16px; background: var(--surface-2);
  border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--text-2); font-family: var(--font-body); }
.aud-day small { color: var(--text-3); font-weight: 600; font-size: 12px; }
.aud-row { border-bottom: 1px solid var(--n-100); }
.aud-row:last-child { border-bottom: 0; }
.aud-row > summary { display: grid; grid-template-columns: 76px 220px 200px 1fr; gap: 12px; align-items: center; min-height: 52px;
  padding: 6px 16px; cursor: pointer; list-style: none; font-size: 13px; }
.aud-row > summary::-webkit-details-marker { display: none; }
.aud-row > summary:hover { background: var(--n-25); }
.aud-time time { font-weight: 600; font-variant-numeric: tabular-nums; }
.aud-time small { color: var(--text-3); font-size: 12px; }
.aud-who { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aud-what { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aud-what b { color: var(--text); font-weight: 600; }
.code.act-danger { background: var(--danger-bg); color: var(--danger); }
.code.act-warn { background: var(--warning-bg); color: var(--warning); }
.code.act-info { background: var(--info-bg); color: var(--info); }
.code.act-ok { background: var(--success-bg); color: var(--success); }
table.diff { width: calc(100% - 32px); margin: 0 16px 8px; border-collapse: collapse; font-size: 13px; }
table.diff th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); padding: 6px 8px; border-bottom: 1px solid var(--border); }
table.diff td { padding: 6px 8px; border-bottom: 1px solid var(--n-100); overflow-wrap: anywhere; }
table.diff td.diff-field { color: var(--text-2); font-weight: 600; text-transform: capitalize; width: 30%; }
table.diff del { color: var(--danger); } table.diff ins { color: var(--success); text-decoration: none; font-weight: 600; }
.aud-meta { margin: 0; padding: 0 16px 12px; color: var(--text-3); font-size: 12px; }
@media (max-width: 760px) {
  .aud-row > summary { grid-template-columns: 64px 1fr; }
  .aud-who, .aud-what { grid-column: 2; }
  .aud-act { grid-column: 2; }
}

/* ADM-W8: Staff and logins (Director setup screen) */
.avatar { width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--n-150);
  color: var(--n-700); font-size: 12px; font-weight: 600; }
.badge-2fa { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: var(--r-pill); font-size: 12px;
  font-weight: 600; background: var(--warning-bg); color: var(--warning); white-space: nowrap; }
.badge-2fa.on { background: var(--success-bg); color: var(--success); }
.invited { display: block; font-size: 12px; margin-top: 2px; }
.row-lock { display: inline-grid; place-items: center; width: 32px; height: 32px; color: var(--n-300); }
.row-edit-link { font-weight: 600; color: var(--green-800); }
.empty-cell { padding: 24px !important; text-align: center; }
table.dt tr.row-detail td { height: auto; padding: 0 14px; border-bottom: 1px solid var(--n-100); }
table.dt tr.row-detail:not(:target):not(.open) { display: none; }
.who > div { min-width: 0; text-align: left; }
@media (max-width: 600px) {
  table.dt.staff thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.dt.staff, table.dt.staff tbody, table.dt.staff tr, table.dt.staff td { display: block; width: 100%; box-sizing: border-box; }
  table.dt.staff tr.staff-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; padding: 10px 12px; border-top: 1px solid var(--n-100); }
  table.dt.staff tr.staff-row td { height: auto; padding: 0; border: 0; }
  table.dt.staff tr.staff-row td:first-child { grid-column: 1; }
  table.dt.staff tr.staff-row td.dt-actions { grid-column: 2; grid-row: 1; }
  table.dt.staff tr.staff-row td:not(:first-child):not(.dt-actions) { grid-column: 1 / -1; padding-left: 40px; font-size: 13px; }
}

/* ADM-W9: a disabled Save looks disabled */
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; box-shadow: none; }

/* ADM-W10: import preview */
.imp-counts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 8px 0 14px; }
.imp-count { border-radius: var(--r-md); padding: 10px 14px; border: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--text-2); }
.imp-count b { display: block; font-family: var(--font-display); font-size: 24px; line-height: 30px; color: var(--text); font-variant-numeric: tabular-nums; }
.imp-count.ready { background: var(--success-bg); } .imp-count.warn { background: var(--warning-bg); } .imp-count.skip { background: var(--danger-bg); }
.imp-commit { margin-top: 14px; }

/* ADM-W11: fee structure card on school settings (no amounts) */
.fee-card { margin-top: 12px; padding: 16px; }
.fee-card h2 { margin: 0 0 6px; font-size: 15px; }
.fee-card-count { margin: 0; font-weight: 600; }
.fee-card .muted { margin: 4px 0 10px; font-size: 13px; }

/* Form drafts (portal.js part 3): note above a form whose typing was kept. */
.draft-note { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 14px; padding: 10px 12px;
  border-radius: 10px; background: var(--info-bg, #eff6ff); color: var(--text); font-size: 13px; line-height: 18px; }
.draft-note span { flex: 1 1 220px; min-width: 0; }
