/* ---------------------------------------------------------------------------
   Attendance Monitoring — interface

   Built for the two things staff actually use: a laptop and an iPad.
     • Laptop / iPad landscape  — sidebar down the left, full-width tables
     • iPad portrait            — bottom tab bar, but sized for fingers
     • Phone                    — same bottom bar, compact

   Touch rules of thumb applied throughout:
     - nothing tappable is smaller than 44px on a touch screen
     - every text box is 16px on touch, because anything smaller makes
       iOS Safari zoom the page in when you tap it
     - hover effects only exist on devices that actually have a pointer,
       otherwise a tapped button stays stuck looking "hovered"
   --------------------------------------------------------------------------- */

:root {
  --ink:      #0d1b2a;
  --ink-2:    #4a5a6a;
  --ink-3:    #8b98a5;
  --line:     #e3e8ee;
  --line-2:   #f1f4f7;
  --bg:       #f4f6f9;
  --card:     #ffffff;

  --navy:     #0e2a42;
  --navy-2:   #17405f;
  --navy-3:   #1e5680;
  --accent:   #0d7a6f;

  --present:    #067647;
  --present-bg: #e8f5ee;
  --late:       #a15c07;
  --late-bg:    #fdf3e3;
  --absent:     #b32318;
  --absent-bg:  #fdeceb;

  --high-bg:  #fef4f3;
  --med-bg:   #fffbf0;

  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;
  --sh:   0 1px 2px rgba(13, 27, 42, .05), 0 2px 8px rgba(13, 27, 42, .05);
  --sh-2: 0 8px 28px rgba(13, 27, 42, .12);
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --sidebar-w: 232px;
  --bar-h: 60px;          /* height of the bottom tab bar */
  --reg-w: 860px;         /* register column — keeps names and P/L/A close together */

  /* The browser's own easings are too weak to read as deliberate. These are
     the two that matter: things arriving, and things being pressed. */
  --ease-out: cubic-bezier(.23, 1, .32, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 640; letter-spacing: -.015em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
a { color: var(--navy-3); text-decoration: none; }
[hidden] { display: none !important; }
svg { flex: none; }

/* No 300ms tap delay, no grey flash, no double-tap zoom on iPad. */
button, a, select, input, textarea, label, .seg button, .segbar button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Visible keyboard focus for anyone driving this from a laptop keyboard. */
:focus-visible { outline: 2px solid var(--navy-3); outline-offset: 2px; border-radius: 4px; }
.sidebar :focus-visible, .mobilebar :focus-visible { outline-color: #fff; }

@media (hover: hover) {
  a:hover { text-decoration: underline; }
}

/* ================================ SHELL ================================== */
.shell { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
  width: var(--sidebar-w); flex: none;
  background: var(--navy); color: #fff;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; height: 100dvh;
}
.sidebar .brand { padding: 16px 16px 15px; border-bottom: 1px solid rgba(255,255,255,.09); }
.sidebar .brand .name { font-weight: 650; font-size: 15px; line-height: 1.3; }
.sidebar .brand .sub { font-size: 12px; color: rgba(255,255,255,.55); margin-top: 3px; }

/* The school's logo sets its last line in black, so it cannot sit on the navy.
   A white plaque gives it the light ground it was drawn for, and reads as a
   letterhead rather than a sticker. */
.plaque {
  display: block; background: #fff; border-radius: 10px;
  padding: 9px 11px; margin-bottom: 12px;
}
.plaque img { display: block; width: 100%; height: auto; }
.mobilehead .plaque {
  flex: none; width: 122px; padding: 5px 7px; margin: 0; border-radius: 7px;
}

.sidenav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidenav button {
  display: flex; align-items: center; gap: 11px;
  background: none; border: 0; color: rgba(255,255,255,.72);
  padding: 11px 12px; border-radius: var(--r-sm);
  font: inherit; font-size: 14px; font-weight: 520; text-align: left; cursor: pointer;
  width: 100%; min-height: 44px;
}
@media (hover: hover) {
  .sidenav button:hover { background: rgba(255,255,255,.07); color: #fff; }
}
.sidenav button.on { background: rgba(255,255,255,.13); color: #fff; font-weight: 600; }
.sidenav button .badge {
  margin-left: auto; background: var(--absent); color: #fff;
  font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px;
}

.sidefoot { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.09); font-size: 13px; }
.sidefoot .u { color: #fff; font-weight: 550; }
.sidefoot .r { color: rgba(255,255,255,.5); font-size: 12px; margin-bottom: 9px; }
.sidefoot button {
  background: rgba(255,255,255,.1); border: 0; color: #fff;
  padding: 9px 12px; border-radius: var(--r-sm); font: inherit; font-size: 13px;
  cursor: pointer; width: 100%; min-height: 40px;
}
@media (hover: hover) {
  .sidefoot button:hover { background: rgba(255,255,255,.2); }
}

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pagehead {
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 18px 26px; display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 20;
}
.pagehead .sub { color: var(--ink-2); font-size: 13.5px; margin-top: 2px; }
.pagehead .spacer { flex: 1; }
.pagehead .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ============================== DATE STRIP ===============================
   The whole school week on one row. Weekends and holidays are visibly not
   teaching days; today has a dot; the future is unreachable. Replaces a bare
   date input that took three taps on an iPad to reach yesterday. */
.datestrip { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.datestrip .days {
  display: flex; gap: 3px; flex: 1; min-width: 0;
  background: var(--line-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 3px; min-width: 296px;
}
.datestrip .d {
  flex: 1; min-width: 38px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1px;
  padding: 5px 2px; border: 0; border-radius: 7px; background: none;
  color: var(--ink-2); font: inherit; cursor: pointer; position: relative;
  transition: background .12s, color .12s, transform .14s var(--ease-out);
}
.datestrip .d .dw { font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; font-weight: 620; }
.datestrip .d .dn { font-size: 15px; font-weight: 640; color: var(--ink); font-variant-numeric: tabular-nums; }
@media (hover: hover) { .datestrip .d:not(:disabled):not(.on):hover { background: #fff; } }
.datestrip .d:not(:disabled):active { transform: scale(.94); }
.datestrip .d:focus-visible { outline: 2px solid var(--navy-3); outline-offset: 1px; }
/* A weekend or a holiday. Still clickable — a register can be recorded on one
   — but it should never look like a day anyone forgot to take. */
.datestrip .d.off { opacity: .45; }
.datestrip .d.off .dn { font-weight: 500; }
.datestrip .d:disabled { opacity: .25; cursor: not-allowed; }
.datestrip .d.now::after {
  content: ''; position: absolute; bottom: 2px; left: 50%; margin-left: -2px;
  width: 4px; height: 4px; border-radius: 50%; background: var(--accent);
}
.datestrip .d.on { background: var(--navy); box-shadow: var(--sh); opacity: 1; }
.datestrip .d.on .dw { color: rgba(255, 255, 255, .72); }
.datestrip .d.on .dn { color: #fff; font-weight: 660; }
.datestrip .d.on.now::after { background: #fff; }
.datestrip .nav {
  flex: none; width: 30px; height: 38px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--card); color: var(--ink-2);
  font-size: 19px; line-height: 1; cursor: pointer;
  transition: background .12s, transform .14s var(--ease-out);
}
@media (hover: hover) { .datestrip .nav:not(:disabled):hover { background: var(--line-2); } }
.datestrip .nav:not(:disabled):active { transform: scale(.94); }
.datestrip .nav:disabled { opacity: .3; cursor: not-allowed; }
.datestrip .nav:focus-visible { outline: 2px solid var(--navy-3); outline-offset: 1px; }
.datestrip .todaybtn { flex: none; }
.datestrip .jump { width: 148px; flex: none; font-size: 13px; min-height: 38px; padding: 6px 8px; }
/* On a phone the week takes its own line and the controls sit underneath, so
   the day cells never squeeze below a thumb's width. */
@media (max-width: 700px) {
  .datestrip { width: 100%; }
  .datestrip .days { order: 0; flex-basis: 100%; min-width: 0; }
  .datestrip .nav { order: 1; height: 44px; }
  .datestrip .todaybtn { order: 2; }
  .datestrip .jump { order: 3; flex: 1; width: auto; min-height: 44px; font-size: 16px; }
  .datestrip .d { padding: 8px 2px; }
}

main { padding: 22px 26px 40px; max-width: 1220px; width: 100%; margin-inline: auto; }
.stack { display: flex; flex-direction: column; gap: 18px; }

/* mobile / tablet bottom bar */
.mobilebar { display: none; }
.mobilehead { display: none; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .shell { flex-direction: column; }
  .mobilehead {
    display: flex; align-items: center; gap: 10px;
    background: var(--navy); color: #fff; padding: 11px 14px;
    position: sticky; top: 0; z-index: 30;
  }
  .mobilehead .name { font-weight: 650; font-size: 15px; flex: 1; }
  .mobilehead button {
    background: rgba(255,255,255,.12); border: 0; color: #fff;
    padding: 8px 14px; border-radius: var(--r-sm); font: inherit; font-size: 13px;
    min-height: 38px;
  }
  .pagehead { padding: 14px 16px; top: 47px; }
  main { padding: 16px 14px calc(var(--bar-h) + 34px); }
  .mobilebar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: rgba(255,255,255,.97); backdrop-filter: blur(10px);
    border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .mobilebar button {
    flex: 1; background: none; border: 0; color: var(--ink-3);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    font: inherit; font-size: 11px; font-weight: 550; padding: 5px 2px; cursor: pointer;
    position: relative; min-height: 48px;
  }
  .mobilebar button.on { color: var(--navy-3); }
  .mobilebar .badge {
    position: absolute; top: 1px; right: 50%; transform: translateX(16px);
    background: var(--absent); color: #fff; font-size: 10px; font-weight: 700;
    padding: 0 5px; border-radius: 999px; line-height: 15px;
  }
}

/* iPad in portrait lands here. It is not a phone — give the tab bar and the
   page proper room rather than shrinking everything down to handset size. */
@media (min-width: 600px) and (max-width: 900px) {
  :root { --bar-h: 68px; }
  .mobilehead { padding: 13px 20px; }
  .mobilehead .name { font-size: 16px; }
  .pagehead { padding: 16px 20px; top: 51px; }
  main { padding: 20px 20px calc(var(--bar-h) + 34px); }
  .mobilebar { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  .mobilebar button { font-size: 12.5px; gap: 5px; min-height: 54px; border-radius: var(--r-sm); }
  .mobilebar button.on { background: var(--line-2); }
}

/* ================================ CARDS ================================== */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--sh); padding: 18px;
}
.card > header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card > header .spacer { flex: 1; }
.card.flush { padding: 0; }
.card.flush > header { padding: 16px 18px 0; margin-bottom: 12px; }
.card.flush .tablewrap { padding-bottom: 4px; }

.muted { color: var(--ink-2); font-size: 13px; }
.tiny  { color: var(--ink-3); font-size: 12px; }
h3.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); font-weight: 650; }

/* ============================== CONTROLS ================================= */
button, input, select, textarea { font-family: inherit; font-size: 14px; }
.btn {
  background: var(--navy); color: #fff; border: 0; border-radius: var(--r-sm);
  padding: 10px 16px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .12s, transform .14s var(--ease-out); min-height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
}
@media (hover: hover) {
  .btn:hover { background: var(--navy-2); }
  .btn.ghost:hover { background: var(--line-2); }
}
/* Presses in fractionally. Nobody notices it; everybody notices its absence,
   as the half-second of doubt about whether the tap registered. */
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn.sm { padding: 7px 12px; font-size: 13px; min-height: 36px; }
.btn.wide { width: 100%; }
a.btn { text-decoration: none; }
a.btn:hover { text-decoration: none; }

input[type=text], input[type=tel], input[type=search], input[type=password], input[type=date], input[type=number], select, textarea {
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 11px;
  background: #fff; color: var(--ink); width: 100%; font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--navy-3); outline-offset: -1px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 150px; }
.row > .shrink { flex: 0 0 auto; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 13px; white-space: nowrap; }
.chk input { width: auto; }

/* segmented control (date shortcuts, filters) */
.segbar { display: inline-flex; background: var(--line-2); border-radius: var(--r-sm); padding: 3px; gap: 2px; flex-wrap: wrap; }
.segbar button {
  background: none; border: 0; padding: 8px 13px; border-radius: 6px;
  font: inherit; font-size: 13px; font-weight: 550; color: var(--ink-2); cursor: pointer;
  min-height: 36px;
}
.segbar button.on { background: #fff; color: var(--ink); box-shadow: var(--sh); }
/* A filter that carries a count. The number is the point of the filter — it is
   how reception knows there are four calls left to make without reading a list. */
.segbar .n {
  display: inline-block; margin-left: 5px; min-width: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--line); color: var(--ink-2);
  font-size: 11.5px; font-weight: 700; line-height: 18px; text-align: center;
}
.segbar button.on .n { background: var(--navy); color: #fff; }
.segbar.wide { display: flex; width: 100%; }
.segbar.wide button { flex: 1; }

/* ---- touch screens: nothing under 44px, no zoom-on-tap in text boxes ---- */
@media (pointer: coarse) {
  input[type=text], input[type=tel], input[type=search], input[type=password], input[type=date], input[type=number], select, textarea {
    font-size: 16px; padding: 11px 12px;
  }
  .btn { min-height: 44px; padding: 11px 18px; }
  .btn.sm { min-height: 40px; padding: 9px 14px; font-size: 14px; }
  .segbar button { min-height: 42px; padding: 9px 15px; font-size: 14px; }
  .chk { font-size: 14px; }
  .chk input { width: 20px; height: 20px; }
  th, td { padding: 13px 14px; }
  label.field > span { font-size: 13px; }
}

/* =============================== SIGN IN ================================= */
.login-wrap {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(160deg, #0e2a42 0%, #143a58 55%, #0d7a6f 190%);
}
.login { background: #fff; border-radius: var(--r-lg); padding: 30px 28px; width: 100%; max-width: 372px; box-shadow: var(--sh-2); }
.login .mark {
  width: 42px; height: 42px; border-radius: 11px; background: var(--navy);
  display: grid; place-items: center; color: #fff; margin-bottom: 14px;
}
/* The sign-in card is the one place the logo gets to be itself: white ground,
   full width, nothing else competing with it. */
.login .logo { display: block; width: 100%; max-width: 244px; height: auto; margin-bottom: 20px; }
.login h1 { font-size: 20px; }
.login .sub { color: var(--ink-2); font-size: 13.5px; margin: 4px 0 20px; }
.err { color: var(--absent); font-size: 13px; min-height: 18px; text-align: center; font-weight: 550; }

/* A password box with a reveal button tucked inside it. The button is a real
   button so it can be tabbed to, and it sits inside the field's own border so
   the field still reads as one control. */
.pw { position: relative; display: block; }
.pw input { padding-right: 62px; }
.pw .reveal {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; cursor: pointer; color: var(--ink-2);
  font-size: 12.5px; font-weight: 600; padding: 8px 9px; border-radius: 7px;
  min-height: 34px;
}
@media (hover: hover) { .pw .reveal:hover { background: var(--line-2); color: var(--ink); } }
.pw .reveal:focus-visible { outline: 2px solid var(--navy); outline-offset: 1px; }

.btn.block { width: 100%; justify-content: center; margin-top: 4px; }

/* The quiet line under the sign-in box: who to ask when you are locked out. */
.login .foot {
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line);
  color: var(--ink-2); font-size: 12.5px; line-height: 1.55; text-align: center;
}

/* A button that has to look like a link — "sign in as somebody else". */
.linkbtn {
  border: 0; background: none; padding: 2px 0; cursor: pointer;
  color: var(--navy); font-size: 13px; font-weight: 600; text-decoration: underline;
  text-underline-offset: 2px;
}
@media (hover: hover) { .linkbtn:hover { color: var(--accent); } }

/* A value the user may read and copy but not edit. Looks like a field, minus
   the affordances of one, so nobody wastes a moment trying to type in it. */
.readonly {
  border: 1px solid var(--line); background: var(--line-2); border-radius: var(--r-sm);
  padding: 10px 12px; color: var(--ink); user-select: all;
}
.readonly code { font: 600 14.5px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }

.note {
  background: #f0f6fb; border: 1px solid #d3e4f1; border-radius: var(--r-sm);
  padding: 11px 13px; color: var(--ink-2); font-size: 13px; line-height: 1.55;
  margin: 4px 0 12px;
}

/* Issued sign-in details. Deliberately oversized — this gets read off a screen
   and written onto paper, often by someone standing up. */
.creds { display: grid; gap: 10px; }
.creds > div {
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 11px 14px;
  background: var(--line-2);
}
.creds span { display: block; color: var(--ink-2); font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.creds code {
  font: 700 21px/1.25 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--ink); user-select: all; word-break: break-all;
}

/* ============================== REGISTER ================================= */
.progress { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; display: flex; }
.progress i { display: block; height: 100%; }
.progress i.p { background: var(--present); }
.progress i.l { background: var(--late); }
.progress i.a { background: var(--absent); }

/* Cap the register width. On a wide laptop the child's name and the P/L/A
   buttons would otherwise sit at opposite ends of a 1200px row, which is a
   long way for the eye and the hand to travel thirty times in a row. */
#regList, #regProgress, .sticky-save { max-width: var(--reg-w); }

.student {
  border: 1px solid var(--line); border-radius: var(--r); background: #fff;
  margin-bottom: 8px; overflow: hidden; transition: border-color .12s;
}
.student .main { display: flex; align-items: center; gap: 12px; padding: 11px 14px; }
.student .name { flex: 1; font-weight: 560; min-width: 0; }
.student .name small { display: block; font-weight: 400; color: var(--ink-3); font-size: 12px; margin-top: 1px; }
.seg { display: flex; gap: 6px; }
.seg button {
  border: 1.5px solid var(--line); background: #fff; color: var(--ink-3);
  min-width: 48px; height: 44px; border-radius: 9px; font-weight: 700; font-size: 13px;
  cursor: pointer; padding: 0 10px;
  transition: background .1s, border-color .1s, color .1s, transform .12s var(--ease-out);
}
.seg button:active:not(:disabled) { transform: scale(.96); }
@media (hover: hover) {
  .seg button:hover { border-color: var(--ink-3); color: var(--ink-2); }
}
.seg button[data-on="present"] { background: var(--present-bg); border-color: var(--present); color: var(--present); }
.seg button[data-on="late"]    { background: var(--late-bg);    border-color: var(--late);    color: var(--late); }
.seg button[data-on="absent"]  { background: var(--absent-bg);  border-color: var(--absent);  color: var(--absent); }
.student.is-present { border-left: 4px solid var(--present); }
.student.is-late    { border-left: 4px solid var(--late); }
.student.is-absent  { border-left: 4px solid var(--absent); }
.student.unmarked   { border-left: 4px solid var(--line); background: #fcfdfe; }
.student .extra { padding: 12px 14px; border-top: 1px dashed var(--line); background: #fcfdfe; }

/* A mark the office has already put right. The teacher can see exactly what it
   became and who decided it, and the buttons are out of action — because a
   re-submitted register must never quietly undo reception's work. */
.student.locked { background: #fbfcfd; }
.student.locked .seg button { opacity: .45; }
.student .amended { margin: 0; font-size: 13px; color: var(--ink-2); line-height: 1.55; }

/* Shows a teacher a lateness they cannot set themselves. Without it the child
   reads as unmarked on their screen, which is worse than useless. */
.chip.late {
  align-self: center; background: var(--late-bg); color: var(--late);
  border-radius: 999px; padding: 4px 11px; font-size: 12.5px; font-weight: 650; white-space: nowrap;
}

/* The buttons say "P / L / A" on a narrow phone and spell the word out
   wherever there is room — far harder to mis-tap under time pressure. */
.seg .wd { display: none; }
@media (min-width: 700px) {
  .seg .lt { display: none; }
  .seg .wd { display: inline; }
  .seg button { min-width: 88px; }
}

@media (pointer: coarse) {
  .student .main { padding: 13px 14px; gap: 14px; }
  .seg button { height: 48px; min-width: 54px; }
  .seg { gap: 8px; }
}
@media (pointer: coarse) and (min-width: 700px) {
  .seg button { min-width: 96px; }
}

.sticky-save {
  position: sticky; bottom: 0; background: rgba(244,246,249,.93);
  backdrop-filter: blur(8px); padding: 13px 0; margin-top: 10px;
  border-top: 1px solid var(--line); display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
}
@media (max-width: 900px) { .sticky-save { bottom: calc(var(--bar-h) + env(safe-area-inset-bottom)); } }

/* ================================ STATS ================================== */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 12px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 15px 16px; box-shadow: var(--sh);
}
.stat .n { font-size: 27px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; }
.stat .l { font-size: 12.5px; color: var(--ink-2); margin-top: 4px; }
.stat.good .n { color: var(--present); }
.stat.warn .n { color: var(--late); }
.stat.bad  .n { color: var(--absent); }

/* ================================ TABLE ================================== */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
th {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-2); font-weight: 650; background: var(--line-2);
  position: sticky; top: 0; z-index: 1;
}
tbody tr:last-child td { border-bottom: 0; }
@media (hover: hover) {
  tbody tr:hover { background: #fafbfc; }
  tr.pa:hover td { background: #fdeeed; }
}
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.pa td { background: var(--high-bg); }

/* ---- collapsible class groups (the student list on Setup) ---------------
   183 children is too many to scroll. They live inside their class, closed
   until asked for. Searching opens everything, so nobody is ever hidden. */
tr.grp > td { padding: 0; border-bottom: 1px solid var(--line); background: #f7f8fa; }
tr.grp + tr.grp > td { border-top: 0; }
tr.grp button {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 11px 13px; border: 0; background: none; cursor: pointer;
  font: inherit; color: var(--ink); text-align: left;
  transition: background .12s, transform .14s var(--ease-out);
}
tr.grp button:hover { background: #eef1f5; }
tr.grp button:active { transform: scale(.995); }
tr.grp button:focus-visible { outline: 2px solid var(--navy-3); outline-offset: -2px; }
tr.grp .caret {
  display: inline-block; width: 14px; flex: none; text-align: center;
  color: var(--ink-2); font-size: 11px;
}
tr.grp .spacer { flex: 1; }
tr.grp .pill, tr.grp .tiny { white-space: nowrap; }
tr.grp.open > td { background: #eef2f7; }
tr.kid td:first-child { padding-left: 34px; }
@media (hover: hover) { tbody tr.grp:hover { background: none; } }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 620; }
.pill.present, .pill.ok { background: var(--present-bg); color: var(--present); }
.pill.late         { background: var(--late-bg);    color: var(--late); }
.pill.absent, .pill.no { background: var(--absent-bg); color: var(--absent); }
.pill.grey         { background: var(--line-2);     color: var(--ink-2); }
/* The count of urgent concerns folded inside a closed group. It has to read as
   urgent while the group is still shut, or closing things hides the problem. */
.pill.red          { background: var(--absent-bg);  color: var(--absent); }
/* Wraps, unlike the other pills — this one carries a sentence, not a word. */
.pill.warn { background: var(--late-bg); color: var(--late); display: block;
  padding: 9px 12px; border-radius: var(--r-sm); font-size: 12.5px; line-height: 1.5; }

.bar { height: 7px; border-radius: 999px; background: var(--line); overflow: hidden; min-width: 64px; flex: 1; max-width: 110px; }
.bar > i { display: block; height: 100%; background: var(--present); }
.bar > i.warn { background: var(--late); }
.bar > i.bad  { background: var(--absent); }
.barcell { display: flex; align-items: center; gap: 9px; }

/* ============================== FOLLOW UP ================================ */
/* Reception's screen: one row per child who is not in class, and everything
   needed to deal with them without leaving the row — the mark, whether it is
   authorised, the guardian's number, whether anyone has rung yet, and the
   buttons that put it right. The row is a grid rather than a table because at
   a desk it is read top-to-bottom, and on an iPad it has to fold. */
.fu {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r);
  margin-bottom: 8px; box-shadow: var(--sh); overflow: hidden;
}
.fu.absent { border-left: 4px solid var(--absent); }
.fu.late   { border-left: 4px solid var(--late); }

.fu-main {
  display: grid; gap: 10px 16px; padding: 13px 15px; align-items: center;
  grid-template-columns: minmax(150px, 1.2fr) minmax(190px, 1.3fr) minmax(150px, 1fr) minmax(120px, .9fr) auto;
}
.fu-who .nm { display: block; font-weight: 600; color: var(--ink); font-size: 14.5px; }
.fu-who .tiny { display: block; margin-top: 1px; }
.fu-state { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.fu-contact a { font-weight: 550; }
.fu-done { min-width: 0; }
.fu-act { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.fu-note {
  padding: 9px 15px; border-top: 1px dashed var(--line); background: #fbfcfd;
  font-size: 13px; color: var(--ink-2);
}
/* Something a safeguarding lead needs to be drawn to, not something broken. */
.warn-txt { color: var(--late); font-weight: 600; }

/* Below a laptop the five columns stop being columns. Names and buttons stay
   full width; the middle detail pairs up. */
@media (max-width: 1100px) {
  .fu-main { grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr); }
  .fu-who, .fu-act { grid-column: 1 / -1; }
  .fu-act { justify-content: flex-start; }
}
@media (max-width: 560px) {
  .fu-main { grid-template-columns: 1fr; }
  .fu-act .btn { flex: 1; }
}

/* =============================== ALERTS ==================================
   Folded to year groups. A safeguarding lead asks "where is the problem this
   week" before she asks "which child", and a flat list of every concern in a
   183-child school answers the second question while burying the first. Each
   header carries its own count, so the shape of the week is readable with
   everything still closed. */
.tree .node { border: 1px solid var(--line); border-radius: var(--r); background: var(--card); margin-bottom: 8px; overflow: hidden; }
.tree .node.open { box-shadow: var(--sh); }
.tree .head {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 13px 15px; border: 0; background: #f7f8fa; cursor: pointer;
  font: inherit; color: var(--ink); text-align: left;
  transition: background .12s, transform .14s var(--ease-out);
}
.tree .head:hover { background: #eef1f5; }
.tree .head:active { transform: scale(.997); }
.tree .head:focus-visible { outline: 2px solid var(--navy-3); outline-offset: -2px; }
.tree .node.open > .head { background: #eef2f7; border-bottom: 1px solid var(--line); }
.tree .caret { display: inline-block; width: 14px; flex: none; text-align: center; color: var(--ink-2); font-size: 11px; }
.tree .spacer { flex: 1; }
.tree .head .pill, .tree .head .tiny { white-space: nowrap; }
.tree .node.grade > .head strong { font-size: 15.5px; }
.tree .kids { padding: 10px 12px; }
/* A class sits inside its grade, and a child inside its class. The indent is
   the only thing telling you which is which once several are open. */
.tree .node.cls { margin-bottom: 8px; background: #fff; }
.tree .node.cls:last-child { margin-bottom: 0; }
.tree .node.cls .kids { padding: 10px; background: #fbfcfd; }
.tree .node.cls .alert:last-child { margin-bottom: 0; }

@media (max-width: 560px) {
  .tree .head { padding: 12px 11px; gap: 7px; }
  .tree .kids { padding: 8px 7px; }
  /* The class name matters more than its branch on a narrow screen. */
  .tree .node.cls > .head .tiny.muted { display: none; }
}

.alertgroup { margin-bottom: 6px; }
.alert {
  display: flex; gap: 13px; padding: 13px 15px; border-radius: var(--r);
  border: 1px solid var(--line); background: #fff; margin-bottom: 8px; align-items: center;
}
.alert.high   { border-left: 4px solid var(--absent); background: var(--high-bg); }
.alert.medium { border-left: 4px solid var(--late);   background: var(--med-bg); }
.alert .body { flex: 1; min-width: 0; }
.alert .t { font-weight: 620; }
.alert .d { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.alert .tag { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; color: var(--ink-3); margin-bottom: 2px; }

@media (max-width: 620px) {
  .alert { flex-direction: column; align-items: stretch; gap: 10px; }
  .alert .btn { width: 100%; }
}

/* =============================== MISC ==================================== */
.empty { text-align: center; padding: 40px 16px; color: var(--ink-3); font-size: 14px; }
.spark { display: block; width: 100%; height: 150px; }

.modal-bg {
  position: fixed; inset: 0; background: rgba(13,27,42,.45); backdrop-filter: blur(2px);
  display: grid; place-items: center; padding: 16px; z-index: 60;
}
.modal {
  background: #fff; border-radius: var(--r-lg); padding: 22px; width: 100%; max-width: 560px;
  max-height: 88vh; max-height: 88dvh; overflow: auto; box-shadow: var(--sh-2);
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
/* Save and Cancel, held apart from the form and always in the same place, so
   nobody hunts for them at the bottom of a long amendment sheet. */
.modal-actions {
  display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap;
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line);
}
@media (max-width: 480px) { .modal-actions .btn { flex: 1; } }

/* ---- absence notes attached to a mark ---- */
.notes { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.notes h4 { margin: 0 0 9px; font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); }
.note-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: var(--r-sm); margin-bottom: 7px; background: var(--line-2);
}
.note-row a { flex: 1; min-width: 0; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linkbtn.danger { color: var(--absent); }
@media (hover: hover) { .linkbtn.danger:hover { color: #7a1710; } }

/* A whole-area drop target, because "choose file" buttons are small and this
   often gets used one-handed with a parent stood at the desk. */
.uploader {
  display: block; margin-top: 8px; padding: 16px 14px; text-align: center; cursor: pointer;
  border: 1.5px dashed var(--line); border-radius: var(--r-sm); background: #fcfdfe;
  color: var(--ink-2); font-size: 13px; transition: border-color .15s var(--ease-out), background .15s var(--ease-out);
}
@media (hover: hover) { .uploader:hover { border-color: var(--navy-3); background: #f5f9fc; } }
.uploader:active { border-color: var(--navy-3); }

/* The role key on Setup. Four roles will not fit on one line honestly, and a
   wrong guess here is somebody given the wrong access to children's records. */
.roles-key { display: grid; gap: 7px; }
.roles-key > div {
  background: var(--line-2); border-radius: var(--r-sm); padding: 9px 12px;
  font-size: 13px; color: var(--ink-2); line-height: 1.5;
}
.roles-key strong { color: var(--ink); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 26px;
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 10px;
  font-size: 14px; font-weight: 550; z-index: 70; box-shadow: var(--sh-2);
  max-width: calc(100vw - 32px); text-align: center;
}
.toast.bad { background: var(--absent); }
@media (max-width: 900px) { .toast { bottom: calc(var(--bar-h) + 24px); } }

.banner {
  display: flex; gap: 10px; align-items: center; padding: 11px 14px;
  border-radius: var(--r-sm); font-size: 13.5px; background: var(--line-2); color: var(--ink-2);
}
.banner.warn { background: var(--med-bg); color: var(--late); }
.banner.ok { background: var(--present-bg); color: var(--present); }
.banner code { background: rgba(0, 0, 0, .06); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
td code { background: var(--line-2); padding: 2px 6px; border-radius: 4px; font-size: 12px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* ================================ PRINT ================================== */
/* Reports get printed and put in front of governors and inspectors, so the
   printed page has to be readable rather than a screenshot of a web app. */
@page { margin: 14mm; }

@media print {
  .sidebar, .mobilebar, .mobilehead, .pagehead .actions,
  .sticky-save, .btn, .segbar, .chk, #repMore, .toast, .modal-bg { display: none !important; }

  body { background: #fff; font-size: 11pt; color: #000; }
  .shell { display: block; }
  main { padding: 0; max-width: none; }
  .stack { gap: 12px; }

  .pagehead { position: static; border-bottom: 1px solid #999; padding: 0 0 8px; margin-bottom: 12px; }
  .pagehead h1 { font-size: 16pt; }

  .card { box-shadow: none; break-inside: avoid; border: 1px solid #ccc; }
  .card.flush > header { padding: 10px 12px 0; }

  /* let long tables flow over pages instead of being clipped by the scroller */
  .tablewrap { overflow: visible !important; }
  table { font-size: 9pt; }
  th, td { white-space: normal; padding: 4px 6px; border-bottom: 1px solid #ddd; }
  th { background: #eee !important; position: static; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  thead { display: table-header-group; }   /* repeat headers on every page */
  tr { break-inside: avoid; }

  .stats { grid-template-columns: repeat(6, 1fr); gap: 6px; }
  .stat { padding: 8px; box-shadow: none; border: 1px solid #ccc; }
  .stat .n { font-size: 15pt; }
  .stat .l { font-size: 8pt; }

  .pill, tr.pa td, .bar > i {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  a { color: #000; text-decoration: none; }
  .spark { height: 110px; }
}

/* ========================= PRINTABLE REPORT SHEETS ========================= */
/* A record that goes into a safeguarding file, home in a bag, or across a desk
   at an inspection is not a screenshot of a web app. When a Print button is
   pressed the sheet is built into #printSheet, the body is given .printing, and
   for the duration of the print dialogue that sheet is the only thing on the
   page. Save as PDF in the dialogue produces the file — nothing to install,
   nothing sent anywhere, and no dependency added to the project. */
#printSheet { display: none; }

@media print {
  /* Everything the app draws is hidden — including the rules above this block,
     which are for printing the screen you are looking at. */
  body.printing > *:not(#printSheet) { display: none !important; }
  body.printing #printSheet { display: block; }
  body.printing { background: #fff; color: #000; font-size: 10.5pt; }

  /* A pack of reports splits cleanly, one child or one class per sheet. */
  .ph-page { break-after: page; }
  .ph-page:last-child { break-after: auto; }

  /* ------------------------------------------------------------ letterhead */
  .ph-head {
    display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px;
    border-bottom: 2px solid #111; padding-bottom: 10px; margin-bottom: 14px;
  }
  /* The logo is a wide wordmark, not a square badge — 2558x732. Sized by height
     with the width left alone, and given the whole first line to itself so it
     does not squeeze the title and the meta pairs beside it. */
  .ph-logo { flex-basis: 100%; height: 11mm; width: auto; object-fit: contain; object-position: left; }
  .ph-who { flex: 1; min-width: 70mm; }
  .ph-school { font-size: 9pt; letter-spacing: .08em; text-transform: uppercase; color: #444; }
  .ph-title { font-size: 18pt; font-weight: 700; line-height: 1.15; margin-top: 2px; }
  .ph-sub { font-size: 12pt; color: #333; margin-top: 1px; }
  .ph-meta { min-width: 46mm; font-size: 9pt; text-align: right; }
  .ph-meta div { display: flex; justify-content: space-between; gap: 10px; padding: 1px 0; }
  .ph-meta span { color: #666; }

  /* ------------------------------------------------- the band of headline numbers */
  .ph-stats {
    display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px;
    margin-bottom: 14px; break-inside: avoid;
  }
  .ph-stats > div {
    border: 1px solid #bbb; border-radius: 4px; padding: 7px 6px; text-align: center;
  }
  .ph-stats strong { display: block; font-size: 15pt; line-height: 1.1; }
  .ph-stats span { display: block; font-size: 7.5pt; color: #555; margin-top: 2px; }

  /* A child below the threshold is the reason the sheet was printed, so it is
     said in words rather than left to be worked out from a percentage. */
  .ph-flag {
    border: 1px solid #a33; background: #fdf0f0; color: #7a1d1d;
    padding: 8px 10px; border-radius: 4px; font-size: 10pt; margin: 0 0 14px;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .ph-line { font-size: 9.5pt; color: #333; margin: 0 0 10px; }
  .ph-line > span { color: #666; margin-right: 6px; }

  #printSheet h2 {
    font-size: 11pt; text-transform: uppercase; letter-spacing: .06em;
    border-bottom: 1px solid #999; padding-bottom: 4px; margin: 16px 0 8px;
    break-after: avoid;
  }
  #printSheet table { width: 100%; border-collapse: collapse; font-size: 9pt; }
  #printSheet th {
    text-align: left; background: #eee; border-bottom: 1px solid #999;
    padding: 4px 6px; font-size: 8.5pt; text-transform: uppercase; letter-spacing: .04em;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  #printSheet td { padding: 4px 6px; border-bottom: 1px solid #ddd; vertical-align: top; }
  #printSheet thead { display: table-header-group; }  /* headers repeat on every page */
  #printSheet tr { break-inside: avoid; }
  #printSheet .ph-pa td { background: #fbeaea; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #printSheet .num { text-align: right; }

  /* Somebody has to sign to say this was discussed with the family. */
  .ph-sign {
    display: grid; grid-template-columns: 2fr 2fr 1fr; gap: 18px;
    margin-top: 26px; break-inside: avoid;
  }
  .ph-sign > div { border-top: 1px solid #333; padding-top: 4px; min-height: 34px; }
  .ph-sign span { font-size: 8.5pt; color: #555; }

  .ph-foot {
    margin-top: 22px; padding-top: 8px; border-top: 1px solid #ccc;
    font-size: 8pt; color: #555; break-inside: avoid;
  }
  .ph-foot p { margin: 0 0 3px; }
}

/* Production-readiness controls follow the existing school interface. */
.environment-bar { position:sticky; top:0; z-index:1000; background:#9f1717; color:#fff; padding:12px 20px; text-align:center; font-weight:700; font-size:16px; }
.environment-bar[hidden] {display:none;}
.test-environment {--accent:#9f1717;}
.test-environment .sidebar {top:48px;height:calc(100dvh - 48px);}
.year-toolbar {display:flex;align-items:center;gap:12px;flex-wrap:wrap;padding:16px 28px 0;}
.year-toolbar select {width:auto;max-width:100%;}
.year-toolbar span {color:var(--ink-2);}
.calendar-range {display:grid;grid-template-columns:minmax(120px,2fr) minmax(130px,1fr) minmax(130px,1fr) auto;gap:12px;align-items:end;margin-block:12px;}
.calendar-range button {margin-bottom:16px;}
.calendar-range .field {min-width:0;}
#calendarEditor h3 {margin-top:28px;}
#saveCalendar {margin-top:16px;}
.paper-entry {padding:16px 0;display:flex;gap:20px;align-items:center;flex-wrap:wrap;}
.paper-entry[hidden] {display:none;}
.ph-test {font-weight:700;border:2px solid #000;padding:8px;}
@media(max-width:650px){.calendar-range{grid-template-columns:1fr 1fr;}.calendar-range .field:first-child{grid-column:1/-1;}.calendar-range button{grid-column:1/-1;}.year-toolbar{padding:12px 16px 0;}.environment-bar{padding:10px 12px;font-size:14px;}}
@media print { .environment-bar,.year-toolbar {display:none !important;} .test-environment:not(.printing)::before {content:'TEST SYSTEM — NOT A LIVE SCHOOL RECORD';display:block;font-weight:bold;} }
/* Keep the visible test warning clear of the existing sticky navigation. */
.test-environment {--environment-height:48px;}
.environment-bar {height:48px;box-sizing:border-box;display:flex;align-items:center;justify-content:center;}
.test-environment .sidebar {top:var(--environment-height);height:calc(100dvh - var(--environment-height));}
.test-environment .pagehead {top:var(--environment-height);}
#calendarEditor input[type="time"] {width:100%;min-height:44px;padding:9px 12px;font:inherit;background:#fff;border:1px solid var(--line);border-radius:var(--r-sm);}
@media(max-width:900px){
 .test-environment .mobilehead {top:var(--environment-height);}
 .test-environment .pagehead {top:calc(var(--environment-height) + 47px);}
}
@media(min-width:651px) and (max-width:900px){.test-environment .pagehead{top:calc(var(--environment-height) + 51px);}}
@media(max-width:650px){.test-environment{--environment-height:64px;}.environment-bar{height:64px;}}
/* Administration retains EtonHouse navy, generous white surfaces and clear type. */
h1 {font-size:28px;line-height:1.2;letter-spacing:-.025em;}
.card {box-shadow:none;border:1px solid var(--line);}
.card>header h2 {font-size:19px;}
.setup-intro {padding:0 0 8px;}
.setup-intro>p {margin:0 0 18px;color:var(--ink-2);font-size:16px;}
#setupNavigation {display:flex;gap:6px;flex-wrap:wrap;border-bottom:1px solid var(--line);padding-bottom:12px;}
#setupNavigation button {font:inherit;min-height:44px;padding:10px 16px;border:0;background:transparent;color:var(--ink-2);border-radius:8px;cursor:pointer;}
#setupNavigation button[aria-pressed="true"] {background:var(--navy);color:#fff;font-weight:650;}
#setupNavigation button:hover:not([aria-pressed="true"]) {background:#e7edf2;color:var(--navy);}
.section-help {font-size:14px;line-height:1.5;color:var(--ink-2);margin:5px 0 0;font-weight:400;max-width:65ch;}
#tab-setup .field {min-width:160px;}
#tab-setup .search-field {flex:2;}
#studentSearch {width:100%;padding:10px 12px;min-height:44px;border:1px solid var(--line);border-radius:8px;background:white;font:inherit;}
.student-results {margin:0;padding:0 18px 16px;color:var(--ink-2);font-size:14px;}
.class-group-actions {display:flex;align-items:center;gap:12px;}
#setupStudents .class-group-actions>button[data-grp] {flex:1;min-width:0;}
#setupStudents .class-group-actions>.class-add {width:auto;flex:none;font-size:13px;white-space:nowrap;min-height:44px;}
.student-actions {white-space:nowrap;}
.student-actions .btn {min-height:40px;margin:3px 3px 3px 0;}
.remove-action {color:var(--absent);}
.movement-student {display:flex;flex-direction:column;gap:4px;padding:20px 0;margin-bottom:8px;border-bottom:1px solid var(--line);}
.movement-student strong {font-size:20px;}.movement-student span {color:var(--ink-2);}
.dialog-actions {display:flex;gap:12px;justify-content:flex-end;margin-top:24px;}
.btn.danger {background:var(--absent);color:#fff;}
@media(max-width:650px){
 h1{font-size:24px;}#setupNavigation{display:grid;grid-template-columns:1fr 1fr;}#setupNavigation button{text-align:left;font-size:14px;}
 #tab-setup .row{flex-wrap:wrap;}#tab-setup .field{flex:1 1 100%;}#tab-setup .row .field{margin-bottom:4px;}
 .class-group-actions{align-items:flex-start;flex-direction:column;gap:0;}#setupStudents .class-group-actions>button[data-grp]{width:100%;}
 .student-actions{white-space:normal;min-width:155px;}.dialog-actions .btn{flex:1;}
}
@media(max-width:650px){
 #setupStudents,#setupStudents tbody{display:block;width:100%;min-width:0;}
 #setupStudents thead{display:none;}
 #setupStudents tr.grp,#setupStudents tr.grp>td{display:block;width:100%;}
 #setupStudents tr.kid{display:grid;grid-template-columns:1fr 1fr;padding:14px;border-bottom:1px solid var(--line);}
 #setupStudents tr.kid td{border:0;padding:5px 0;white-space:normal;overflow-wrap:anywhere;}
 #setupStudents tr.kid td:first-child,#setupStudents tr.kid td.student-actions{grid-column:1/-1;}
 #setupStudents td[data-label]::before{content:attr(data-label);display:block;color:var(--ink-2);font-size:12px;margin-bottom:2px;}
 #setupStudents .student-actions{padding-top:12px;display:flex;gap:6px;flex-wrap:wrap;}
}

/* Centre the working column and keep register controls aligned with its rows. */
#tab-register { width:100%; max-width:calc(var(--reg-w) + 40px); margin-inline:auto; }
@media(min-width:901px){.pagehead,.year-toolbar{padding-inline:max(26px, calc((100% - 1168px) / 2));}}
@media(max-width:650px){.modal input[type=text],.modal input[type=tel],.modal select{min-height:44px;font-size:16px;}}

/* School picker under the logo (admins who work in both schools) */
.school-switch{margin-top:10px;width:100%;padding:8px 10px;border-radius:8px;border:1px solid rgba(255,255,255,.25);background:rgba(255,255,255,.08);color:#fff;font:inherit;font-size:13px;cursor:pointer}
.school-switch option{color:#0e2a42;background:#fff}

/* ===================== Setup: clearer add / edit / remove ===================== */
.setup-stats {display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:12px;margin:0 0 18px;}
.stat-tile {font:inherit;text-align:left;display:flex;flex-direction:column;gap:2px;padding:16px 18px;background:var(--card);border:1px solid var(--line);border-radius:var(--r);cursor:pointer;transition:border-color .15s,box-shadow .15s,transform .15s;}
.stat-tile:hover:not(:disabled) {border-color:var(--navy-3);box-shadow:var(--sh);transform:translateY(-1px);}
.stat-tile:disabled {cursor:default;}
.stat-tile strong {font-size:28px;font-weight:680;letter-spacing:-.02em;color:var(--navy);line-height:1.1;}
.stat-tile span {font-size:14px;font-weight:600;color:var(--ink);}
.stat-tile small {font-size:12.5px;color:var(--ink-2);}
.card.flush > header .section-help, .card > header .section-help {margin:4px 0 0;color:var(--ink-2);font-size:14px;max-width:62ch;}
.toolbar {display:flex;gap:10px;flex-wrap:wrap;align-items:flex-end;padding:0 18px 12px;}
.toolbar > .field {flex:1 1 170px;margin:0;}
.toolbar > .search-field {flex:2 1 260px;}
.btn.with-icon span[aria-hidden] {font-weight:700;margin-right:2px;}
.card.flush table thead th {background:var(--line-2);font-size:12px;text-transform:uppercase;letter-spacing:.04em;color:var(--ink-2);font-weight:650;}
.card.flush table tbody tr:hover {background:#f8fafc;}
.card.flush table td, .card.flush table th {padding-left:18px;}
tr.is-muted td {color:var(--ink-3);}
tr.is-muted .avatar {background:var(--line-2);color:var(--ink-3);}
.actions-col {text-align:right;}
.row-actions {white-space:nowrap;text-align:right;}
.row-actions .btn, .student-actions .btn {margin:3px 0 3px 6px;}
.btn.ghost.remove-action {color:var(--absent);border-color:#f2c9c5;}
.btn.ghost.remove-action:hover {background:var(--absent-bg);}
.btn.ghost:hover {border-color:var(--navy-3);color:var(--navy);}
.person {display:flex;align-items:center;gap:10px;}
.avatar {flex:0 0 34px;width:34px;height:34px;border-radius:50%;display:grid;place-items:center;background:#e4ecf3;color:var(--navy);font-size:12.5px;font-weight:700;letter-spacing:.02em;}
.chip {display:inline-block;padding:2px 8px;margin:2px 2px 2px 0;border:1px solid var(--line);border-radius:6px;font-size:12.5px;background:var(--card);white-space:nowrap;}
.pill.role-teacher {background:#e8f0f8;color:var(--navy-3);}
.pill.role-office {background:#e6f4f2;color:var(--accent);}
.pill.role-slt {background:var(--line-2);color:var(--ink-2);}
.pill.role-admin {background:var(--navy);color:#fff;}
.roles-help {margin:0 18px 12px;border:1px solid var(--line);border-radius:var(--r-sm);padding:10px 14px;background:var(--line-2);}
.roles-help summary {cursor:pointer;font-weight:600;font-size:14px;color:var(--navy-3);}
.roles-help[open] summary {margin-bottom:10px;}
.import-card {border-style:dashed;}
#fGrantsWrap {border:1px solid var(--line);border-radius:var(--r-sm);padding:10px 14px 12px;}
#fGrantsWrap legend {font-weight:600;font-size:14px;padding:0 4px;}
@media (max-width: 720px) {
  .row-actions {white-space:normal;text-align:left;}
  .stat-tile strong {font-size:24px;}
}

/* ---------------------------- safeguarding form ---------------------------- */
.banner.danger { background: var(--absent-bg); color: var(--absent); display: block; line-height: 1.5; }
.banner.danger strong { margin-right: 4px; }
.sg-form { max-width: 760px; }
.sg-form .err { text-align: left; }
.sg-form em.req { color: var(--absent); font-style: normal; }
.sg-form em.opt { color: var(--ink-3); font-style: normal; font-weight: 450; }
.sg-form input[type=datetime-local] { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 11px; background: #fff; color: var(--ink); font-size: 14px; max-width: 280px; width: 100%; }
.sg-form textarea { resize: vertical; line-height: 1.5; font-family: inherit; }
.sg-form .invalid { outline: 2px solid var(--absent); outline-offset: -1px; }
fieldset.sg-types { border: 0; padding: 0; margin: 0 0 12px; }
fieldset.sg-types legend { font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; padding: 0; }
.sg-types .sg-opt { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); margin-bottom: 6px; cursor: pointer; font-size: 14px; background: #fff; }
.sg-types .sg-opt input { width: auto; margin: 0; }
.sg-types .sg-opt:has(input:checked) { border-color: var(--navy-3); background: #f0f6fb; }
.sg-types.invalid .sg-opt { border-color: var(--absent); }
.sg-done { max-width: 760px; }
.sg-done h2 { color: var(--present); margin-bottom: 8px; }
#sgTable tbody tr { cursor: pointer; }
.sg-detail dl { display: grid; grid-template-columns: 170px 1fr; gap: 8px 14px; margin: 0 0 14px; font-size: 14px; }
.sg-detail dt { font-weight: 600; color: var(--ink-2); }
.sg-detail dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
.sg-history { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; font-size: 13px; }
.sg-history li { margin-bottom: 8px; white-space: pre-wrap; }
@media (max-width: 600px) { .sg-detail dl { grid-template-columns: 1fr; } .sg-detail dt { margin-top: 6px; } }
.ph-sg dl { display: grid; grid-template-columns: 190px 1fr; gap: 6px 14px; font-size: 12pt; }
.ph-sg dt { font-weight: 700; }
.ph-sg dd { margin: 0; white-space: pre-wrap; }

/* =============================== KSA PORTAL ===============================
   The attendance app grew into the school's staff portal. These rules give it
   a front door (split sign-in), a home page of modules, grouped navigation
   and the IT Assets screens. Same navy, same white surfaces; a thin EtonHouse
   red is used sparingly as the accent. */
:root { --eh-red: #c8102e; --gold: #b8935a; }

/* ---- sign-in: brand panel + form ---- */
.login-wrap { display: grid; grid-template-columns: minmax(380px, 1.05fr) 1fr; padding: 0; place-items: stretch; background: var(--bg); }
.login-brand {
  position: relative; overflow: hidden; color: #fff; padding: 40px 48px;
  display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(30,86,128,.55) 0%, transparent 60%),
    radial-gradient(90% 70% at 0% 100%, rgba(13,122,111,.35) 0%, transparent 55%),
    linear-gradient(160deg, #0b2238 0%, #0e2a42 50%, #12344f 100%);
}
.login-brand::after {
  content: ''; position: absolute; inset: auto -120px -160px auto; width: 460px; height: 460px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.07); box-shadow: 0 0 0 60px rgba(255,255,255,.02), 0 0 0 130px rgba(255,255,255,.015);
}
.login-brand .plaque { width: 210px; margin: 0; padding: 12px 14px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.lb-kicker { text-transform: uppercase; letter-spacing: .14em; font-size: 11.5px; color: rgba(255,255,255,.6); margin: 0 0 10px; font-weight: 600; }
.lb-title { font-size: 40px; line-height: 1.08; font-weight: 700; letter-spacing: -.03em; margin: 0; }
.lb-title::after { content: ''; display: block; width: 54px; height: 3px; background: var(--eh-red); border-radius: 2px; margin-top: 16px; }
.lb-lede { color: rgba(255,255,255,.75); font-size: 16px; margin: 16px 0 28px; max-width: 34ch; }
.lb-modules { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; max-width: 420px; position: relative; z-index: 1; }
.lb-modules li { display: flex; gap: 14px; align-items: center; padding: 13px 15px; border-radius: 12px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08); backdrop-filter: blur(4px); }
.lb-modules strong { display: block; font-size: 14.5px; }
.lb-modules small { color: rgba(255,255,255,.62); font-size: 12.5px; }
.lb-ic { flex: none; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: rgba(255,255,255,.12); font-weight: 700; font-size: 15px; }
.lb-foot { font-size: 12px; color: rgba(255,255,255,.45); position: relative; z-index: 1; }
.login-side { display: grid; place-items: center; padding: 32px 20px; }
.login-side .login { box-shadow: none; border: 1px solid var(--line); max-width: 400px; padding: 34px 32px; }
.login-side .login .logo { display: none; }
.login h1 { font-size: 24px; }
.btn.ms { background: #fff; color: #1b1b1b; border: 1px solid #c9ced6; display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 600; min-height: 46px; text-decoration: none; }
@media (hover: hover) { .btn.ms:hover { background: #f5f7fa; } }
.alt-login { display: block; margin: 14px auto 4px; }
#ssoErr { text-align: left; background: var(--absent-bg); padding: 10px 12px; border-radius: var(--r-sm); margin-bottom: 14px; }
@media (max-width: 900px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-side { min-height: 100dvh; background: linear-gradient(160deg, #0e2a42 0%, #143a58 60%, #0d7a6f 200%); }
  .login-side .login .logo { display: block; }
}

/* ---- sidebar: portal identity and grouped navigation ---- */
.sidebar .brand .portal-name { font-size: 11px; text-transform: uppercase; letter-spacing: .14em; color: rgba(255,255,255,.55); font-weight: 650; margin-bottom: 3px; }
.sidebar .brand .name { font-size: 14px; }
.sidenav { overflow-y: auto; gap: 1px; }
.sidenav .group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .13em; color: rgba(255,255,255,.4); font-weight: 650; padding: 14px 12px 5px; }
.sidenav .group:first-child { padding-top: 2px; }
.sidenav button { min-height: 40px; padding: 9px 12px; }
.sidenav button.on { box-shadow: inset 3px 0 0 var(--eh-red); }
.pagehead .crumb { font-size: 11.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-3); font-weight: 650; margin-bottom: 2px; }
.pagehead .crumb:empty { display: none; }
body.no-year .year-toolbar { display: none; }
@media (max-width: 900px) {
  .mobilebar { overflow-x: auto; justify-content: flex-start; scrollbar-width: none; }
  .mobilebar::-webkit-scrollbar { display: none; }
  .mobilebar button { flex: 1 0 68px; }
}

/* ---- home ---- */
.hero {
  display: flex; gap: 20px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap;
  padding: 26px 28px; border-radius: var(--r-lg); color: #fff; position: relative; overflow: hidden;
  background: radial-gradient(90% 140% at 100% 0%, rgba(30,86,128,.9) 0%, transparent 60%), linear-gradient(135deg, #0b2238, #0e2a42 60%, #133a58);
  box-shadow: var(--sh-2);
}
.hero::after { content: ''; position: absolute; right: -80px; top: -80px; width: 260px; height: 260px; border-radius: 50%; border: 1px solid rgba(255,255,255,.08); box-shadow: 0 0 0 40px rgba(255,255,255,.025); }
.hero h2 { font-size: 28px; letter-spacing: -.025em; }
.hero-date { margin: 0 0 4px; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: rgba(255,255,255,.6); font-weight: 650; }
.hero-sub { margin: 4px 0 0; color: rgba(255,255,255,.72); }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; position: relative; z-index: 1; }
.hero-actions .btn { background: #fff; color: var(--navy); }
.hero-actions .btn.ghost { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.25); }
@media (hover: hover) { .hero-actions .btn:hover { background: #eef3f8; } .hero-actions .btn.ghost:hover { background: rgba(255,255,255,.18); } }
.modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.module {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh);
  padding: 20px; display: flex; flex-direction: column; gap: 14px; position: relative; overflow: hidden;
  transition: box-shadow .2s var(--ease-out), transform .2s var(--ease-out);
}
@media (hover: hover) { .module:hover { box-shadow: var(--sh-2); transform: translateY(-2px); } }
.module::before { content: ''; position: absolute; left: 0; top: 0; right: 0; height: 3px; background: var(--mod, var(--navy-3)); }
.module header { display: flex; align-items: center; gap: 12px; }
.module .mic { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; color: var(--mod, var(--navy-3)); background: color-mix(in srgb, var(--mod, var(--navy-3)) 11%, #fff); flex: none; }
.module h3 { font-size: 17px; }
.module .msub { font-size: 12.5px; color: var(--ink-3); }
.module .mstats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.module .mstat { background: var(--line-2); border-radius: var(--r-sm); padding: 10px 11px; }
.module .mstat b { display: block; font-size: 21px; letter-spacing: -.02em; line-height: 1.15; }
.module .mstat span { font-size: 11.5px; color: var(--ink-2); }
.module .mstat.bad b { color: var(--absent); } .module .mstat.good b { color: var(--present); } .module .mstat.warn b { color: var(--late); }
.module .mtext { font-size: 13.5px; color: var(--ink-2); margin: 0; }
.module .mfoot { margin-top: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.module .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.module.attendance { --mod: #1e5680; } .module.safeguarding { --mod: #c8102e; } .module.assets { --mod: #0d7a6f; }

/* ---- IT assets ---- */
.asset-toolbar { padding: 16px 18px 4px; display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.asset-toolbar .field { margin: 0; flex: 1 1 170px; }
.asset-toolbar .search-field { flex: 2 1 260px; }
.asset-buttons { display: flex; gap: 8px; flex-wrap: wrap; flex: 0 0 auto; }
#assetTable tbody tr { cursor: pointer; }
#assetTable td .sub { font-size: 12px; color: var(--ink-3); }
.pill.st-use { background: var(--present-bg); color: var(--present); }
.pill.st-stock { background: #e8f0f8; color: var(--navy-3); }
.pill.st-repair { background: var(--late-bg); color: var(--late); }
.pill.st-retired { background: var(--line-2); color: var(--ink-2); }
.pill.st-lost { background: var(--absent-bg); color: var(--absent); }
.asset-form .row > .field { margin-bottom: 10px; }
.asset-detail dl { display: grid; grid-template-columns: 150px 1fr; gap: 7px 14px; margin: 0 0 12px; font-size: 14px; }
.asset-detail dt { color: var(--ink-2); font-weight: 600; }
.asset-detail dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 12px 16px; font-size: 13px; }
.timeline li::before { content: ''; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid var(--navy-3); }
.timeline .when { color: var(--ink-3); font-size: 12px; }
.timeline .chg { color: var(--ink-2); }
.import-preview { font-size: 13px; }
.import-preview ul { margin: 6px 0; padding-left: 18px; }
@media (max-width: 600px) { .asset-detail dl { grid-template-columns: 1fr; } .asset-detail dt { margin-top: 4px; } }
.ph-assets table { width: 100%; border-collapse: collapse; font-size: 9pt; }
.ph-assets th, .ph-assets td { border-bottom: 1px solid #bbb; padding: 4px 5px; text-align: left; vertical-align: top; }
input[type=email] { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 11px; background: #fff; color: var(--ink); width: 100%; font-size: 14px; }
body.on-home .pagehead { display: none; }
input[type=datetime-local] { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 11px; background: #fff; color: var(--ink); font-size: 14px; width: 100%; font-family: inherit; }
