/*
 * EduERP design system (Phase 2)
 * One stylesheet for all three portals. Mobile-first. Tokens on :root.
 * --brand is replaced per institution (validated for contrast on the server).
 */

/* ---------- Typeface: Atkinson Hyperlegible (SIL Open Font License, see fonts/OFL.txt) ---------- */
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("fonts/atkinson-hyperlegible-400-v1.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("fonts/atkinson-hyperlegible-700-v1.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  /* Colour */
  --ink: #17283a;            /* register ink: main text */
  --ink-2: #46566a;          /* secondary text */
  --ink-3: #6b7888;          /* hints, placeholders (large/secondary use only) */
  --paper: #f3f5f2;          /* page background */
  --surface: #ffffff;        /* panels, tables, forms */
  --sunken: #eef1ec;         /* table headers, wells */
  --rule: #d8ddd5;           /* hairlines */
  --rule-strong: #b3bcb0;    /* input borders */

  --brand: #0b6e66;          /* institution colour (default: board green) */
  --brand-ink: #ffffff;      /* text on --brand */
  --brand-soft: #e2f0ed;     /* tinted backgrounds */
  --brand-strong: #07524c;   /* hover/pressed */

  --sidebar: #17283a;        /* Super Admin chrome */
  --sidebar-ink: #dbe3ea;
  --sidebar-muted: #93a3b4;
  --sidebar-active: #7fd1c6;

  --attention: #8a4f00;      --attention-bg: #fff3dc;  --attention-line: #f0c27a;
  --danger: #b42318;         --danger-bg: #fef1ef;     --danger-line: #f5b4ac;
  --success: #1c6b3a;        --success-bg: #eaf6ee;    --success-line: #a6d8b5;
  --info: #234f8a;           --info-bg: #edf3fb;       --info-line: #b6cbe8;
  --focus: #1a5fd0;

  /* Type: minor-third scale on a 16px base */
  --font: "Atkinson Hyperlegible", "Noto Sans Malayalam", "Noto Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --t-xs: 0.8125rem;   /* 13 */
  --t-sm: 0.875rem;    /* 14 */
  --t-md: 1rem;        /* 16 */
  --t-lg: 1.1875rem;   /* 19 */
  --t-xl: 1.4375rem;   /* 23 */
  --t-2xl: 1.75rem;    /* 28 */
  --t-3xl: 2.125rem;   /* 34 */

  /* Space: 4px grid */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

  /* Shape: radius follows hierarchy (small for controls, larger for containers) */
  --r-ctl: 6px;
  --r-panel: 10px;
  --r-plate: 4px;

  --shadow-pop: 0 12px 32px rgba(23, 40, 58, 0.18), 0 2px 6px rgba(23, 40, 58, 0.12);
  --tap: 44px;               /* minimum touch target */
  --content: 1180px;
  --measure: 68ch;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--t-md);
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, h4 { line-height: 1.25; margin: 0; font-weight: 700; color: var(--ink); }
h1 { font-size: var(--t-xl); }
h2 { font-size: var(--t-lg); }
h3 { font-size: var(--t-md); }
p { margin: 0 0 var(--s3); max-width: var(--measure); }
a { color: var(--brand); text-underline-offset: 2px; }
a:hover { color: var(--brand-strong); }
img, svg { display: block; max-width: 100%; }
small, .small { font-size: var(--t-sm); }
.muted { color: var(--ink-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
::selection { background: var(--brand-soft); }

.skip-link {
  position: absolute; left: var(--s3); top: -100px; z-index: 100;
  background: var(--surface); color: var(--ink); padding: var(--s2) var(--s4);
  border: 2px solid var(--focus); border-radius: var(--r-ctl); font-weight: 700;
}
.skip-link:focus { top: var(--s3); }

.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

@media (min-width: 900px) {
  h1 { font-size: var(--t-2xl); }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--tap); padding: 0 var(--s4);
  font: inherit; font-weight: 700; font-size: var(--t-md); line-height: 1;
  border-radius: var(--r-ctl); border: 1px solid transparent;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color .12s ease, border-color .12s ease;
}
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-strong); color: var(--brand-ink); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--rule-strong); }
.btn-secondary:hover { background: var(--sunken); color: var(--ink); }
.btn-quiet { background: transparent; color: var(--brand); padding: 0 var(--s2); }
.btn-quiet:hover { background: var(--brand-soft); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #8f1c13; color: #fff; }
.btn-small { min-height: 36px; padding: 0 var(--s3); font-size: var(--t-sm); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
/* Small screens: a touch target stays 44px even when it looks like a small button. */
@media (pointer: coarse) { .btn-small { min-height: var(--tap); } }

/* ---------- Forms ---------- */
.form { display: grid; gap: var(--s4); max-width: 560px; }
.form-wide { max-width: 860px; }
.form-grid { display: grid; gap: var(--s4); }
@media (min-width: 720px) { .form-grid.cols-2 { grid-template-columns: 1fr 1fr; } }
.field { display: grid; gap: var(--s1); }
.field > label, .field > .label { font-weight: 700; }
.field .hint { font-size: var(--t-sm); color: var(--ink-2); }
.field .error-text { font-size: var(--t-sm); color: var(--danger); font-weight: 700; }
.required-mark { color: var(--danger); margin-left: 2px; }
.input, .select, .textarea {
  width: 100%; min-height: var(--tap);
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule-strong); border-radius: var(--r-ctl);
  padding: var(--s2) var(--s3);
}
.textarea { min-height: 112px; resize: vertical; }
.select { appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2346566a' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus { outline: 3px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.input::placeholder { color: var(--ink-3); }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--danger); border-width: 2px; }
.input[readonly] { background: var(--sunken); }
.check { display: flex; gap: var(--s3); align-items: flex-start; min-height: var(--tap); padding-top: 10px; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--brand); flex: none; }
.input-with-action { display: flex; gap: var(--s2); }
.input-with-action .input { flex: 1; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 700; padding: 0; margin-bottom: var(--s2); }

/* ---------- Alerts and flash messages ---------- */
.alert {
  display: grid; grid-template-columns: auto 1fr; gap: var(--s3); align-items: start;
  padding: var(--s3) var(--s4); border-radius: var(--r-ctl);
  border: 1px solid; border-left-width: 4px; margin-bottom: var(--s4);
}
.alert .icon { margin-top: 2px; }
.alert-title { font-weight: 700; display: block; }
.alert p { margin: 0; }
.alert-info { background: var(--info-bg); border-color: var(--info-line); border-left-color: var(--info); color: var(--info); }
.alert-success { background: var(--success-bg); border-color: var(--success-line); border-left-color: var(--success); color: var(--success); }
.alert-attention { background: var(--attention-bg); border-color: var(--attention-line); border-left-color: var(--attention); color: var(--attention); }
.alert-danger { background: var(--danger-bg); border-color: var(--danger-line); border-left-color: var(--danger); color: var(--danger); }
.alert > div { color: var(--ink); }
.alert .alert-title { color: inherit; }

/* ---------- Status chips (application, payment, exam states) ---------- */
.status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--t-sm); font-weight: 700; line-height: 1;
  padding: 5px 10px 5px 8px; border-radius: 999px; border: 1px solid; white-space: nowrap;
}
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-neutral { color: var(--ink-2); background: var(--sunken); border-color: var(--rule); }
.status-pending { color: var(--attention); background: var(--attention-bg); border-color: var(--attention-line); }
.status-success { color: var(--success); background: var(--success-bg); border-color: var(--success-line); }
.status-danger { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-line); }
.status-info { color: var(--info); background: var(--info-bg); border-color: var(--info-line); }
/* "Correction required" and "Overdue" are outlined so they differ from plain pending even without colour. */
.status-outline { background: var(--surface); border-style: dashed; }

/* ---------- ID plate: how every Student ID, Registration No. and receipt number is shown ---------- */
.id-plate {
  display: inline-flex; align-items: stretch; min-width: 0;
  border: 1.5px solid var(--ink); border-radius: var(--r-plate);
  background: var(--surface); font-variant-numeric: tabular-nums; line-height: 1;
  max-width: 100%;
}
.id-plate .id-kind {
  display: flex; align-items: center; padding: 0 8px;
  background: var(--ink); color: #fff; font-size: var(--t-xs); font-weight: 700;
}
.id-plate .id-value { display: flex; align-items: center; padding: 7px 10px; letter-spacing: .03em; font-size: var(--t-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.id-plate .id-prefix { color: var(--ink-2); }
.id-plate .id-serial { font-weight: 700; color: var(--ink); }
.id-plate .id-copy {
  border: 0; border-left: 1px solid var(--rule); background: transparent; color: var(--ink-2);
  padding: 0 10px; cursor: pointer; min-width: 40px; display: flex; align-items: center; justify-content: center;
}
.id-plate .id-copy:hover { background: var(--sunken); color: var(--ink); }
.id-plate .id-copy .icon { width: 16px; height: 16px; }
.id-plate.is-compact .id-value { padding: 5px 8px; font-size: var(--t-sm); }
.id-plate.is-compact .id-copy { min-width: 32px; padding: 0 6px; }
.id-plate.is-large .id-value { font-size: var(--t-xl); padding: 10px 14px; }
.id-plate.is-copied .id-copy { color: var(--success); }

/* ---------- Panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-panel); }
.panel-body { padding: var(--s4); }
.panel-head {
  display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; justify-content: space-between;
  padding: var(--s3) var(--s4); border-bottom: 1px solid var(--rule);
}
.panel-head h2 { font-size: var(--t-md); }
.panel-foot { padding: var(--s3) var(--s4); border-top: 1px solid var(--rule); }
@media (min-width: 900px) { .panel-body { padding: var(--s5); } .panel-head { padding: var(--s3) var(--s5); } }
.stack { display: grid; gap: var(--s4); grid-template-columns: minmax(0, 1fr); }
.stack-lg { display: grid; gap: var(--s5); grid-template-columns: minmax(0, 1fr); }
/* Grid children may shrink below their content width, so wide tables scroll inside their panel instead of widening the page. */
.split > *, .form-grid > *, .facts > * { min-width: 0; }
main.content { min-width: 0; }
.split { display: grid; gap: var(--s5); }
@media (min-width: 1000px) { .split { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); align-items: start; } }

/* Definition list for record details (student profile, application) */
.facts { display: grid; gap: var(--s3) var(--s5); margin: 0; }
.facts div { display: grid; gap: 2px; }
.facts dt { font-size: var(--t-sm); color: var(--ink-2); }
.facts dd { margin: 0; font-weight: 700; }
@media (min-width: 720px) { .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- Summary strip: key figures in one row, separated by rules (not a wall of cards) ---------- */
.summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.summary a, .summary > div {
  display: grid; gap: 2px; padding: var(--s4); text-decoration: none; color: var(--ink);
  border-bottom: 1px solid var(--rule);
}
.summary > :nth-child(odd) { border-right: 1px solid var(--rule); }
/* Phone: an odd last figure takes the full row instead of leaving an empty cell beside it. */
.summary > :last-child:nth-child(odd) { grid-column: 1 / -1; border-right: 0; }
.summary a:hover { background: var(--sunken); }
.summary.cols-2 { --cols: 2; } .summary.cols-3 { --cols: 3; } .summary.cols-5 { --cols: 5; }
.summary .figure { font-size: var(--t-2xl); font-weight: 700; line-height: 1.1; }
.summary .label { font-size: var(--t-sm); color: var(--ink-2); }
.summary .figure.is-attention { color: var(--attention); }
@media (min-width: 900px) {
  .summary { grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); }
  .summary > :last-child:nth-child(odd) { grid-column: auto; }
  .summary a, .summary > div { border-bottom: 0; border-right: 1px solid var(--rule); padding: var(--s4) var(--s5); }
  .summary > :last-child { border-right: 0; }
}

/* ---------- Tables ---------- */
.table-tools { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--rule); }
.table-tools .search { flex: 1 1 220px; position: relative; }
.table-tools .search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.table-tools .search .input { padding-left: 40px; }
.table-tools .select { width: auto; min-width: 150px; }
.table-tools .count { margin-left: auto; font-size: var(--t-sm); color: var(--ink-2); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.table th {
  text-align: left; font-weight: 700; color: var(--ink-2); background: var(--sunken);
  padding: 10px var(--s4); border-bottom: 1px solid var(--rule); white-space: nowrap; position: sticky; top: 0;
}
.table td { padding: 12px var(--s4); border-bottom: 1px solid var(--rule); vertical-align: middle; }
.table td.primary-cell { min-width: 170px; }
.table td.nowrap, .table th.nowrap { white-space: nowrap; }
.table tbody tr:hover td { background: #f8faf7; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .row-title { font-weight: 700; color: var(--ink); text-decoration: none; }
.table .row-title:hover { text-decoration: underline; }
.table .sub { display: block; color: var(--ink-2); font-size: var(--t-xs); }
.table .actions { text-align: right; white-space: nowrap; }
/* Phone: each row becomes a compact record with labels (uses data-label on cells). */
@media (max-width: 719px) {
  .table.is-responsive thead { display: none; }
  .table.is-responsive tr { display: grid; gap: 6px; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--rule); }
  .table.is-responsive td { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); padding: 0; border: 0; min-width: 0; }
  .table.is-responsive td > * { min-width: 0; }
  .table.is-responsive td::before { flex: none; }
  .table.is-responsive td::before { content: attr(data-label); color: var(--ink-2); font-weight: 400; }
  .table.is-responsive td.primary-cell { display: block; }
  .table.is-responsive td.primary-cell::before { content: none; }
  .table.is-responsive td.actions { justify-content: flex-start; padding-top: var(--s1); }
  .table.is-responsive td.actions::before { content: none; }
  .table.is-responsive .num { text-align: right; }
}
.pager { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; justify-content: space-between; padding: var(--s3) var(--s4); border-top: 1px solid var(--rule); font-size: var(--t-sm); color: var(--ink-2); }

/* ---------- Empty states ---------- */
.empty { padding: var(--s6) var(--s4); text-align: left; max-width: 520px; }
.empty .icon { width: 32px; height: 32px; color: var(--ink-3); margin-bottom: var(--s3); }
.empty h3 { margin-bottom: var(--s2); }
.empty p { color: var(--ink-2); }

/* ---------- Page header ---------- */
.page-head { display: grid; gap: var(--s2); margin-bottom: var(--s5); }
.page-head .crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: var(--t-sm); color: var(--ink-2); list-style: none; padding: 0; margin: 0; }
.page-head .crumbs li + li::before { content: "/"; margin-right: 6px; color: var(--rule-strong); }
.page-head .crumbs a { color: var(--ink-2); }
.page-head .title-row { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; justify-content: space-between; }
.page-head .lede { color: var(--ink-2); margin: 0; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: var(--s1); border-bottom: 1px solid var(--rule); overflow-x: auto; margin-bottom: var(--s4); }
.tabs a { padding: var(--s3) var(--s3); color: var(--ink-2); text-decoration: none; font-weight: 700; border-bottom: 3px solid transparent; white-space: nowrap; min-height: var(--tap); display: flex; align-items: center; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--brand); }

/* ---------- Lists of tasks (center home) ---------- */
.tasklist { list-style: none; margin: 0; padding: 0; }
.tasklist li { border-bottom: 1px solid var(--rule); }
.tasklist li:last-child { border-bottom: 0; }
.tasklist a { display: grid; grid-template-columns: auto 1fr auto; gap: var(--s3); align-items: center; padding: var(--s3) var(--s4); color: var(--ink); text-decoration: none; min-height: 56px; }
.tasklist a:hover { background: var(--sunken); }
.tasklist .count-badge { min-width: 32px; padding: 4px 8px; border-radius: 999px; background: var(--ink); color: #fff; font-weight: 700; font-size: var(--t-sm); text-align: center; }
.tasklist .count-badge.is-zero { background: var(--sunken); color: var(--ink-2); }
.tasklist .task-text strong { display: block; }
.tasklist .task-text span { font-size: var(--t-sm); color: var(--ink-2); }

/* ---------- Dialog ---------- */
.dialog { border: 0; padding: 0; border-radius: var(--r-panel); box-shadow: var(--shadow-pop); width: min(480px, calc(100vw - 32px)); color: var(--ink); }
.dialog::backdrop { background: rgba(23, 40, 58, .45); }
.dialog-head { padding: var(--s4) var(--s5) 0; }
.dialog-body { padding: var(--s3) var(--s5); color: var(--ink-2); }
.dialog-foot { padding: var(--s4) var(--s5); display: flex; gap: var(--s2); justify-content: flex-end; flex-wrap: wrap; }

/* ---------- Toast (shown after an action) ---------- */
.toast {
  position: fixed; left: 50%; bottom: var(--s5); transform: translateX(-50%); z-index: 60;
  display: flex; gap: var(--s3); align-items: center;
  background: var(--ink); color: #fff; padding: var(--s3) var(--s4); border-radius: var(--r-ctl);
  box-shadow: var(--shadow-pop); max-width: calc(100vw - 32px);
}
.toast .icon { color: var(--sidebar-active); }

/* =====================================================================
   Portal chrome
   ===================================================================== */
.content { width: 100%; max-width: var(--content); margin: 0 auto; padding: var(--s5) var(--s4) var(--s7); }
@media (min-width: 900px) { .content { padding: var(--s6) var(--s6) var(--s8); } }

/* --- Super Admin: dark ink sidebar --- */
.shell-admin { min-height: 100vh; }
.sidebar {
  background: var(--sidebar); color: var(--sidebar-ink);
  position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 40;
  display: flex; flex-direction: column; transform: translateX(-100%); transition: transform .18s ease;
}
.sidebar.is-open { transform: none; }
.sidebar .sb-brand { display: flex; gap: var(--s3); align-items: center; padding: var(--s4) var(--s4) var(--s3); border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .sb-brand .logo { width: 36px; height: 36px; border-radius: 8px; background: var(--sidebar-active); color: var(--sidebar); display: grid; place-items: center; font-weight: 700; }
.sidebar .sb-brand strong { display: block; color: #fff; line-height: 1.2; }
.sidebar .sb-brand span { font-size: var(--t-xs); color: var(--sidebar-muted); }
.sidebar nav { flex: 1; overflow-y: auto; padding: var(--s3) var(--s2); }
.sidebar .nav-group { margin-bottom: var(--s4); }
.sidebar .nav-group-title { font-size: var(--t-xs); color: var(--sidebar-muted); padding: var(--s2) var(--s3) var(--s1); }
.sidebar a {
  display: flex; gap: var(--s3); align-items: center; min-height: 40px; padding: 0 var(--s3);
  color: var(--sidebar-ink); text-decoration: none; border-radius: var(--r-ctl); font-size: var(--t-sm);
}
.sidebar a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar a[aria-current="page"] { background: rgba(127,209,198,.14); color: #fff; box-shadow: inset 3px 0 0 var(--sidebar-active); }
.sidebar a .icon { width: 18px; height: 18px; color: var(--sidebar-muted); }
.sidebar a[aria-current="page"] .icon { color: var(--sidebar-active); }
.sidebar .sb-foot { padding: var(--s3) var(--s4); border-top: 1px solid rgba(255,255,255,.08); font-size: var(--t-xs); color: var(--sidebar-muted); }
.scrim { position: fixed; inset: 0; background: rgba(23,40,58,.45); z-index: 35; }
.scrim[hidden] { display: none; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; gap: var(--s3); align-items: center; min-height: 60px; padding: 0 var(--s4);
  background: var(--surface); border-bottom: 1px solid var(--rule);
}
.topbar .menu-btn { display: inline-flex; }
.topbar .top-search { flex: 1; max-width: 520px; position: relative; }
.topbar .top-search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.topbar .top-search .input { padding-left: 40px; background: var(--paper); }
.topbar .who { margin-left: auto; display: flex; gap: var(--s3); align-items: center; font-size: var(--t-sm); }
.topbar .who .name { display: none; }
@media (max-width: 599px) {
  .topbar .who .avatar, .topbar .who .btn span { display: none; }
  .appbar .avatar, .appbar .btn span { display: none; }
}
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-strong); display: grid; place-items: center; font-weight: 700; font-size: var(--t-sm); flex: none; }
@media (min-width: 1100px) {
  .sidebar { transform: none; }
  .scrim { display: none !important; }
  .shell-admin .main { margin-left: 264px; }
  .topbar .menu-btn { display: none; }
  .topbar .who .name { display: block; }
}

/* Main acting inside one center: a band that cannot be missed */
.acting-band {
  display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; justify-content: space-between;
  padding: var(--s2) var(--s4); background: var(--attention-bg); border-bottom: 2px solid var(--attention); color: var(--ink);
}
.acting-band strong { color: var(--attention); }

/* --- Center admin: top bar in the institution's own colour --- */
.appbar { background: var(--surface); border-bottom: 1px solid var(--rule); position: sticky; top: 0; z-index: 30; }
.appbar-row { display: flex; gap: var(--s3); align-items: center; min-height: 60px; padding: 0 var(--s4); max-width: var(--content); margin: 0 auto; }
.appbar .inst { display: flex; gap: var(--s3); align-items: center; text-decoration: none; color: inherit; min-width: 0; }
.appbar .inst .logo { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; flex: none; overflow: hidden; }
.appbar .inst strong { display: block; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar .inst span { font-size: var(--t-xs); }
.appbar .spacer { flex: 1; }
.appbar-brand { background: var(--brand); color: var(--brand-ink); border-bottom: 0; }
.appbar-brand .inst .logo { background: rgba(255,255,255,.95); color: var(--brand); }
.appbar-brand .inst span { color: rgba(255,255,255,.82); }
.appbar-brand .btn-quiet { color: var(--brand-ink); }
.appbar-brand .btn-quiet:hover { background: rgba(255,255,255,.14); }
.appbar-brand .avatar { background: rgba(255,255,255,.95); color: var(--brand-strong); }
.tasknav { background: var(--surface); border-bottom: 1px solid var(--rule); }
.tasknav-row { display: flex; gap: var(--s1); overflow-x: auto; max-width: var(--content); margin: 0 auto; padding: 0 var(--s3); scrollbar-width: none; }
.tasknav a { display: flex; gap: var(--s2); align-items: center; min-height: 48px; padding: 0 var(--s3); color: var(--ink-2); text-decoration: none; font-weight: 700; font-size: var(--t-sm); border-bottom: 3px solid transparent; white-space: nowrap; }
.tasknav a .icon { width: 18px; height: 18px; }
.tasknav a:hover { color: var(--ink); }
.tasknav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--brand); }

/* --- Student: light chrome, bottom tab bar on phones --- */
.shell-student .appbar .inst .logo { background: var(--brand); color: var(--brand-ink); }
.shell-student .appbar .inst span { color: var(--ink-2); }
.student-nav { display: none; gap: var(--s1); }
.student-nav a { padding: 0 var(--s3); min-height: 60px; display: flex; align-items: center; color: var(--ink-2); text-decoration: none; font-weight: 700; border-bottom: 3px solid transparent; }
.student-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--brand); }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--surface); border-top: 1px solid var(--rule);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a { display: grid; justify-items: center; gap: 2px; padding: 8px 2px 6px; min-height: 58px; color: var(--ink-2); text-decoration: none; font-size: 0.75rem; font-weight: 700; }
.tabbar a .icon { width: 22px; height: 22px; }
.tabbar a[aria-current="page"] { color: var(--brand); }
.tabbar a[aria-current="page"] .icon { stroke-width: 2.2; }
.shell-student .content { padding-bottom: 96px; }
@media (min-width: 900px) {
  .student-nav { display: flex; }
  .tabbar { display: none; }
  .shell-student .content { max-width: 980px; padding-bottom: var(--s8); }
}

/* Student home: the next thing to do comes first */
.next-up { border-left: 4px solid var(--brand); }
.next-up .when { font-size: var(--t-sm); color: var(--ink-2); }
.next-up h2 { font-size: var(--t-lg); margin: 2px 0 var(--s2); }
.meter { display: block; width: 100%; height: 12px; appearance: none; border: 1px solid var(--rule); border-radius: 999px; background: var(--sunken); overflow: hidden; }
.meter::-webkit-progress-bar { background: var(--sunken); border-radius: 999px; }
.meter::-webkit-progress-value { background: var(--brand); border-radius: 999px; }
.meter::-moz-progress-bar { background: var(--brand); border-radius: 999px; }
.list-links { list-style: none; margin: 0; padding: 0; }
.list-links > li > a { display: flex; gap: var(--s3); align-items: center; padding: var(--s3) var(--s4); min-height: 56px; border-bottom: 1px solid var(--rule); color: var(--ink); text-decoration: none; }
.list-links li:last-child > a { border-bottom: 0; }
.list-links > li > a:hover { background: var(--sunken); }
.list-row { display: flex; gap: var(--s3); align-items: center; padding: var(--s3) var(--s4); min-height: 56px; border-bottom: 1px solid var(--rule); }
.list-links li:last-child .list-row { border-bottom: 0; }
.list-row > span { display: grid; flex: 1; min-width: 0; }
.list-row > :last-child:not(span) { margin-left: auto; flex: none; }
.list-links .meta { margin-left: auto; font-size: var(--t-sm); color: var(--ink-2); white-space: nowrap; }

/* Advertisement slot (Module 15): only rendered when an ad exists, never on exam pages */
.ad-slot { display: grid; grid-template-columns: 96px 1fr; gap: var(--s3); align-items: center; padding: var(--s3); }
.ad-slot img, .ad-slot .ad-art { width: 96px; height: 72px; object-fit: cover; border-radius: var(--r-ctl); }
.ad-slot .ad-art { display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.ad-slot p { margin: 0; }
.ad-slot .ad-label { font-size: var(--t-xs); color: var(--ink-2); }

/* ---------- Sign-in pages ----------
   Institution panel shows only the institution's logo, name and published details
   (vision, mission, about, contact). Phone: logo + name, then the form, then the details.
   Computer: one coloured column on the left (identity + details), form on the right. */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-areas: "id" "form" "about"; }
.auth-id, .auth-about { background: var(--brand); color: var(--brand-ink); }
.auth-id { grid-area: id; display: flex; gap: var(--s4); align-items: center; padding: var(--s5) var(--s4); }
.auth-id .logo { width: 56px; height: 56px; border-radius: 12px; background: rgba(255,255,255,.95); color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: var(--t-lg); flex: none; }
.auth-id .inst-logo { width: 64px; height: 64px; object-fit: contain; background: #fff; border-radius: 12px; padding: 6px; flex: none; }
.auth-id .inst-name { margin: 0; font-size: var(--t-xl); font-weight: 700; line-height: 1.2; color: var(--brand-ink); text-wrap: balance; }
.auth-form { grid-area: form; padding: var(--s5) var(--s4) var(--s6); background: var(--surface); }
.auth-form > div { width: 100%; max-width: 400px; margin: 0 auto; }
.auth-form h1 { margin-bottom: var(--s2); }
.auth-form .form { margin-top: var(--s5); }
.auth-form .below { margin-top: var(--s5); font-size: var(--t-sm); }
.auth-about { grid-area: about; display: grid; gap: var(--s5); align-content: start; padding: var(--s5) var(--s4) var(--s6); }
.auth-about h2 { font-size: var(--t-sm); font-weight: 700; color: var(--brand-ink); opacity: .85; margin-bottom: var(--s1); }
.auth-about p { margin: 0; color: var(--brand-ink); max-width: 52ch; }
.auth-contact { display: grid; gap: 2px; font-size: var(--t-sm); padding-top: var(--s4); border-top: 1px solid rgba(255,255,255,.3); }
.shell-admin-auth .auth-id, .shell-admin-auth .auth-about { background: var(--sidebar); }
.shell-admin-auth .auth-id .logo { background: var(--sidebar-active); color: var(--sidebar); }
@media (min-width: 900px) {
  .auth { grid-template-columns: minmax(380px, 5fr) 7fr; grid-template-rows: auto 1fr; grid-template-areas: "id form" "about form"; }
  .auth-id { flex-direction: column; align-items: flex-start; padding: var(--s7) var(--s7) var(--s5); }
  .auth-id .logo { width: 72px; height: 72px; font-size: var(--t-xl); }
  .auth-id .inst-logo { width: 96px; height: 96px; }
  .auth-id .inst-name { font-size: var(--t-3xl); max-width: 16ch; }
  .auth-about { padding: var(--s3) var(--s7) var(--s7); }
  .auth-form { display: grid; align-content: center; padding: var(--s7); }
}
.locked { margin: 0; padding: var(--s2) var(--s3); background: var(--sunken); border-radius: var(--r-ctl); font-weight: 700; }
.logo-preview { width: 96px; height: 96px; object-fit: contain; border: 1px solid var(--rule); border-radius: var(--r-ctl); background: #fff; padding: 6px; }
.input-color { width: 96px; padding: 4px; }
.break { overflow-wrap: anywhere; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); margin: var(--s4) 0; }
.recovery-codes span { border: 1px dashed var(--rule-strong); border-radius: var(--r-plate); padding: var(--s2); text-align: center; font-weight: 700; letter-spacing: .04em; }
.setup-key { font-size: var(--t-xl); font-weight: 700; letter-spacing: .06em; word-break: break-all; padding: var(--s3); background: var(--sunken); border-radius: var(--r-ctl); }
.gateway-choices { display: grid; gap: var(--s3); margin-top: var(--s5); }
.gateway-choices a { display: grid; grid-template-columns: auto 1fr auto; gap: var(--s3); align-items: center; padding: var(--s4); border: 1px solid var(--rule-strong); border-radius: var(--r-panel); color: var(--ink); text-decoration: none; }
.gateway-choices a:hover { border-color: var(--brand); background: var(--brand-soft); }
.gateway-choices strong { display: block; }
.gateway-choices span { font-size: var(--t-sm); color: var(--ink-2); }

/* Spacing helper for a block after a form or panel */
.below { margin-top: var(--s5); }

/* ---------- Style guide only ---------- */
.sg-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s3); }
.sg-swatch { border: 1px solid var(--rule); border-radius: var(--r-ctl); overflow: hidden; font-size: var(--t-xs); background: var(--surface); }
.sg-swatch .chip { height: 56px; }
.sg-ink { background: var(--ink); } .sg-ink2 { background: var(--ink-2); } .sg-paper { background: var(--paper); border-bottom: 1px solid var(--rule); }
.sg-brand { background: var(--brand); } .sg-attention { background: var(--attention); } .sg-danger { background: var(--danger); }
.sg-success { background: var(--success); } .sg-info { background: var(--info); }
.sg-swatch div:last-child { padding: var(--s2); }
.sg-type > * { margin-bottom: var(--s3); }

/* ---------- Motion and print ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media print {
  .sidebar, .topbar, .appbar, .tasknav, .tabbar, .acting-band, .btn, .skip-link, .scrim { display: none !important; }
  .shell-admin .main { margin: 0 !important; }
  body { background: #fff; }
  .panel { border: 0; }
  .content { padding: 0; max-width: none; }
}

/* ---------- Phase 3: management screens ---------- */
.form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 720px) {
  .form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .form-grid.cols-4 { grid-template-columns: 1fr 2fr 1fr 1fr; }
}
.form-section { font-size: var(--t-md); margin: var(--s3) 0 0; padding-top: var(--s4); border-top: 1px solid var(--rule); }
.page-actions { margin-bottom: var(--s5); }
.page-actions form { display: contents; }
.panel + .panel, .split + .panel, .panel + .split { margin-top: var(--s5); }
.panel-head-actions { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s3); align-items: center; justify-content: space-between; }
.panel-foot { border-top: 1px solid var(--rule); }
.panel-draft { border-color: var(--attention-line); box-shadow: inset 4px 0 0 var(--attention); }
.subject-form h3, .form h3 { font-size: var(--t-md); margin: 0; }
.table tfoot td { font-weight: 700; border-top: 2px solid var(--rule-strong); }
.pre { white-space: pre-line; }
.measure { max-width: 65ch; }
.danger-text { color: var(--danger); }

/* Search and filter row: stacks on phones, one line on wider screens. */
.toolbar { display: grid; gap: var(--s3); align-items: end; margin-bottom: var(--s4); grid-template-columns: minmax(0, 1fr); }
.toolbar .field { margin: 0; }
@media (min-width: 720px) { .toolbar { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto; } }
.panel-foot .toolbar { margin: 0; }
@media (min-width: 720px) { .panel-foot .toolbar { grid-template-columns: minmax(0, 1fr) auto; } }

/* A button that opens a small form in place (Reject with reason, Withdraw, Ask for a course). */
.inline-action > summary, .menu-actions > summary { list-style: none; cursor: pointer; }
.inline-action > summary::-webkit-details-marker, .menu-actions > summary::-webkit-details-marker { display: none; }
.inline-action[open] { flex-basis: 100%; }
.inline-action[open] > summary { margin-bottom: var(--s3); }
.inline-action .form { padding: var(--s4); background: var(--sunken); border-radius: var(--r-ctl, 8px); }
.list-row:has(.inline-action[open]) { flex-wrap: wrap; }

/* "Manage" menu for an account row. */
.menu-actions { position: relative; display: inline-block; }
.menu-actions-list { display: grid; gap: 2px; margin-top: var(--s2); padding: var(--s2); background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--r-ctl, 8px); min-width: 220px; }
.menu-actions-list .btn { width: 100%; justify-content: flex-start; }
@media (min-width: 900px) {
  .menu-actions-list { position: absolute; right: 0; z-index: 20; box-shadow: var(--shadow-pop); }
}

/* Course requests */
.request-list { list-style: none; margin: 0; padding: 0; }
.request { display: grid; gap: var(--s3); padding: var(--s4); border-bottom: 1px solid var(--rule); }
.request:last-child { border-bottom: 0; }
.request p { margin: 0; }
.request-main { display: grid; gap: var(--s1); min-width: 0; }
.request-side { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.quote { color: var(--ink-2); border-left: 3px solid var(--rule-strong); padding-left: var(--s3); }
@media (min-width: 900px) {
  .request { grid-template-columns: minmax(0, 1fr) auto; align-items: start; }
  .request-side { justify-content: flex-end; max-width: 420px; }
}
.split > .panel { margin-top: 0; }
.list-row > .status { flex: none; display: inline-flex; margin-left: auto; }
.table th.num { text-align: right; }
.impact { margin: 0; padding-left: 1.2em; display: grid; gap: var(--s3); max-width: 75ch; }
.panel-closed { border-color: var(--rule-strong); box-shadow: inset 4px 0 0 var(--ink-3); margin-bottom: var(--s5); }
.frozen-banner { background: var(--sunken); border-bottom: 1px solid var(--rule-strong); }
.frozen-banner .alert { margin: 0; border-radius: 0; border-left: 0; border-right: 0; }
.panel-closed .facts + p { margin-top: var(--s4); }
/* Settings rows: name, type, switches; wraps on phones. */
.setting-row { display: grid; gap: var(--s3); grid-template-columns: minmax(0, 1fr); align-items: end; padding-bottom: var(--s3); border-bottom: 1px solid var(--rule); }
.setting-row:last-of-type { border-bottom: 0; }
@media (min-width: 720px) { .setting-row { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto auto; } .setting-row:not(:has(select)) { grid-template-columns: minmax(0, 3fr) auto auto; } }
.setting-row .check { min-height: 44px; }
.checks { border: 0; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.field-check { align-self: end; }
.stack > .panel + .panel, .stack-lg > .panel + .panel { margin-top: 0; }
form.stack-lg + .panel { margin-top: var(--s5); }
/* Admission application */
.doc-slot { display: grid; gap: var(--s2); padding: var(--s4) 0; border-bottom: 1px solid var(--rule); }
.doc-slot:last-child { border-bottom: 0; }
.doc-slot-head { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.doc-slot p { margin: 0; }
.upload-row { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.upload-row .input { flex: 1 1 220px; min-width: 0; }
.timeline { list-style: none; margin: 0; padding: var(--s4); display: grid; gap: var(--s3); }
.timeline li { border-left: 2px solid var(--rule-strong); padding-left: var(--s3); }
.timeline p { margin: 0; }
.changes { margin: var(--s2) 0 0; padding-left: 1.2em; }
.toolbar-narrow { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 720px) { .toolbar-narrow { grid-template-columns: minmax(0, 24rem) auto; } }
[data-aadhaar-confirm][hidden] { display: none; }
/* Student account (approval) and setup code slip */
.id-row { display: flex; flex-wrap: wrap; gap: var(--s3); }
.rule { border: 0; border-top: 1px solid var(--rule); margin: 0; width: 100%; }
.block { display: block; }
.slip h2 { margin: 0; }
.slip-inst { margin: 0 0 var(--s1); }
.slip-big { font-size: var(--t-lg, 1.25rem); font-weight: 700; letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.slip-code { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; }
.slip-steps { margin: 0; padding-left: 1.3em; display: grid; gap: var(--s1); }
@media print {
  .no-print, .alert { display: none !important; }
  .slip { border: 1.5px dashed #000 !important; }
}
.id-row .id-kind { white-space: nowrap; }
.slip + .btn-row { margin-top: var(--s4); }
.small-head { font-size: var(--t-md); margin: 0; }
.btn-row form { display: contents; }
.panel-body .form + p { margin: var(--s4) 0 0; }
/* Students */
.toolbar-students { display: flex; flex-wrap: wrap; }
.toolbar-students .field { flex: 1 1 11rem; min-width: 0; }
.toolbar-students .field-wide { flex: 2 1 16rem; }
.mono-id { font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.status-form { display: grid; gap: var(--s3); }
.panel-body .facts + p { margin: var(--s4) 0 0; }
/* Student requests */
.facts-tight { gap: var(--s2) var(--s5); }
@media (min-width: 720px) { .facts-tight { grid-template-columns: repeat(2, minmax(0, 1fr)); } .facts-tight .facts-wide { grid-column: 1 / -1; } }
.facts .changes { font-weight: 400; }
.request-item { display: grid; gap: var(--s2); padding: var(--s4); border-bottom: 1px solid var(--rule); }
.request-item:last-child { border-bottom: 0; }
.request-item-head { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; justify-content: space-between; }
.request-item h3 { font-size: var(--t-md); margin: 0; }
.ask { border-top: 1px solid var(--rule); }
.ask summary { cursor: pointer; padding: var(--s4); font-weight: 700; min-height: 44px; }
.ask[open] summary { padding-bottom: var(--s2); }
.ask .form { padding: 0 var(--s4) var(--s4); }
.correction-row { display: grid; gap: var(--s2); padding: var(--s3) 0; border-bottom: 1px solid var(--rule); }
@media (min-width: 720px) { .correction-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); align-items: start; } }
.correction-row .current dt { font-size: var(--t-sm); color: var(--ink-2); }
.correction-row .current dd { margin: 0; font-weight: 700; }
.ask-inline { border-top: 0; } .ask-inline summary { padding: var(--s2) 0; font-weight: 600; color: var(--brand); } .ask-inline .form { padding: 0 0 var(--s2); }
