/* =====================================================================
   WHERE IS HAITHAM NOW?  --  main.css
   The reset and the shared component set, built on css/tokens.css.

   Mobile first: everything here targets a phone held in one hand.
   responsive.css only widens it.

   House rules for this file:
     - no hex codes, no px borders, no shadow values. Spend tokens.
     - no RTL overrides for shadows or presses. --sh-dir already did it.
     - every interactive thing gets a border, a hard shadow, and a press.
   ===================================================================== */

/* ---------- Reset ---------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--t-body);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

h1, h2, h3, h4 {
  margin: 0;
  line-height: 1.12;
  font-weight: 700;
  letter-spacing: var(--track-tight);
}
h1 { font-size: var(--t-h1); }
h2 { font-size: var(--t-h2); }
p  { margin: 0; }
img, svg { max-width: 100%; }

a { color: var(--text); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { background: var(--accent); color: var(--accent-contrast); }

/* Keyboard focus has to beat a 3px ink border, so it is a thick offset
   ring in the action colour with an ink outline behind it. */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 6px var(--ink);
  border-radius: 0;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .btn:active, .filter-pill:active, .req-card:active { transform: none !important; }
}

/* ---------- Icons -----------------------------------------------------
   Drawn in js/icons.js, 24x24, outlined in currentColor and filled from
   tokens. Sized in `em` so an icon always matches the type beside it,
   and nudged down a fraction so its optical centre lands on the baseline
   of the text rather than above it.
   -------------------------------------------------------------------- */
.icon {
  width: 1em;
  height: 1em;
  flex: none;
  vertical-align: -0.14em;
  overflow: visible;
}

/* Directional drawings - an arrow, a walking figure - have to face the
   way the language reads. */
:root[dir='rtl'] .icon-flip { transform: scaleX(-1); }

/* A `data-icon` span is only a holder; the drawing inside carries the
   size, so the span must not add a line box of its own. */
[data-icon] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* An icon's own colour can vanish on a filled control - a yellow wrench
   on a yellow nav tab. On anything already wearing the action colour the
   body becomes paper and the cut-outs become the ground, which keeps
   both halves of every two-tone drawing readable. */
.btn-primary .icon,
.bottomnav [aria-current='page'] .icon,
.desktop-nav [aria-current='page'] .icon,
.admin-side a[aria-current='page'] .icon,
.section-head .icon,
.day-head .icon,
.time-preview .icon,
.badge-accent .icon,
.queue-rank .icon,
.brand-mark .icon,
.table th .icon {
  --ic: var(--surface);
  --ic2: var(--accent);
}

/* Where the ground is already dark, the fill goes the other way. */
.badge-critical .icon,
.counter[data-tone='critical'] .icon,
.segmented label.is-critical .icon {
  --ic: var(--critical);
  --ic2: var(--critical-soft);
}

/* The green "I'm available now" button and the red refuse button are
   filled too, just not in the action colour. */
.btn-ok:hover .icon,
.btn-secondary .icon { --ic: var(--surface); --ic2: var(--secondary); }
.btn-danger:hover .icon { --ic: var(--surface); --ic2: var(--danger); }

/* A tone dot sets --ic inline, and an inline style already beats every
   rule above, so the signal colour survives any ground without help. */

/* Icons that stand alone rather than beside words - the app bar, the
   nav, an empty state - want to be bigger than the type around them. */
.brand-mark .icon { font-size: 17px; }
.bottomnav .ico .icon { font-size: 21px; }
.admin-side .ico .icon { font-size: 15px; }
.fact .ico .icon { font-size: 17px; }
.empty-icon .icon { font-size: 34px; }
.sheet-close .icon { font-size: 15px; }
.btn-icon .icon { font-size: 18px; }
.hero-status .icon,
.now-status .icon { font-size: .8em; }

/* The old emoji holders set a font-size for a character; with a drawing
   inside they only need to stop adding their own leading. */
.empty-icon { line-height: 1; }

/* ---------- Layout --------------------------------------------------- */
.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding: var(--s-5) var(--s-4) var(--s-4);
}

.page { padding-bottom: calc(var(--nav-h) + var(--s-7)); }

/* A <section> dropped straight into the page (history days, generated
   report blocks) still needs separating from its neighbour. */
main > section + section,
[id$='-host'] > section + section { margin-block-start: var(--gap-group); }

.stack       { display: flex; flex-direction: column; gap: var(--gap); }
.stack-loose { display: flex; flex-direction: column; gap: var(--gap-group); }
.stack-sm    { display: flex; flex-direction: column; gap: var(--gap-tight); }
.section-gap { margin-top: var(--gap-group); }
.row         { display: flex; align-items: center; gap: var(--s-2); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.row-wrap    { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.grow        { flex: 1 1 auto; min-width: 0; }

/* ---------- App bar ---------------------------------------------------
   A flat white band under a solid ink rule. No blur, no translucency:
   the edge between the chrome and the page is a drawn line, not a haze.
   -------------------------------------------------------------------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg-elevated);
  border-bottom: var(--bd) solid var(--border);
}
.appbar-inner {
  max-width: var(--maxw);
  margin-inline: auto;
  min-height: var(--header-h);
  padding: var(--s-2) var(--s-3);
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.brand {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: var(--track-tight);
  color: var(--text);
  text-decoration: none;
  min-width: 0;
}
.brand:hover { background: none; color: var(--text); }
.brand > .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-mark {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: var(--accent);
  color: var(--accent-contrast);
  border: var(--bd-thin) solid var(--ink);
  box-shadow: var(--shadow-sm);
  font-size: 15px;
  flex: none;
}
.appbar-clock {
  /* Doubles as the hidden way into the admin console, so rapid tapping
     must not start selecting the text. */
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: default;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  padding: 3px var(--s-2);
  border: var(--bd-thin) solid var(--ink);
  background: var(--surface-2);
}

/* ---------- Buttons ---------------------------------------------------
   Substantial, bordered, shadowed and tactile: pressing one moves it onto
   its own shadow, which is the single most recognisable gesture in this
   design language. Importance is carried by size and fill, never by
   hiding a secondary action behind a bare icon.
   -------------------------------------------------------------------- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: var(--tap);
  padding: var(--s-3) var(--s-4);
  border: var(--bd) solid var(--ink);
  border-radius: 0;
  background: var(--btn-bg);
  color: var(--btn-fg);
  box-shadow: var(--shadow-sm);
  font: inherit;
  font-weight: 700;
  letter-spacing: .01em;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: transform .05s ease, box-shadow .05s ease, background .12s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--accent-soft); text-decoration: none; }
.btn:active {
  transform: var(--press);
  box-shadow: var(--shadow-flat);
}
.btn[disabled], .btn[aria-disabled='true'] {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  background: var(--muted-soft);
}

.btn-primary   { --btn-bg: var(--accent);        --btn-fg: var(--accent-contrast); }
.btn-primary:hover { --btn-bg: var(--accent-hover); }
.btn-secondary { --btn-bg: var(--secondary);     --btn-fg: var(--text-invert); }
.btn-secondary:hover { --btn-bg: var(--secondary-hover); }
.btn-ok        { --btn-bg: var(--secondary-soft); --btn-fg: var(--secondary-text); }
.btn-ok:hover  { --btn-bg: var(--secondary); --btn-fg: var(--text-invert); }
.btn-danger    { --btn-bg: var(--danger-soft);   --btn-fg: var(--danger); }
.btn-danger:hover { --btn-bg: var(--danger); --btn-fg: var(--text-invert); }
.btn-soft      { --btn-bg: var(--surface-2); }

/* The one exception to the border-and-shadow rule: chrome affordances
   (language, theme, close) that must not compete with real actions. */
.btn-ghost {
  --btn-bg: transparent;
  border-color: transparent;
  box-shadow: none;
  font-weight: 600;
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--accent); color: var(--accent-contrast); }
.btn-ghost:active { transform: none; box-shadow: none; }

/* The primary action is meant to be impossible to miss. */
.btn-lg {
  min-height: 60px;
  padding-inline: var(--s-5);
  font-size: 17px;
  text-transform: uppercase;
  letter-spacing: .04em;
  box-shadow: var(--shadow-md);
}
.btn-lg:active { transform: var(--press-deep); box-shadow: var(--shadow-flat); }

.btn-sm {
  min-height: 38px;
  padding: var(--s-1) var(--s-3);
  font-size: var(--t-small);
  border-width: var(--bd-thin);
}
.btn-block { width: 100%; }
.btn-icon  { min-width: var(--tap); padding-inline: var(--s-3); }

.btn-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3);
}

/* Busy state: the label is swapped for a spinner + text by ui.js */
.spinner {
  width: 15px; height: 15px;
  border: var(--bd-thin) solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Cards -----------------------------------------------------
   Physical blocks, not floating panels: a drawn edge and a hard shadow,
   so a card looks like a thing resting on the page.
   -------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: var(--bd) solid var(--border);
  box-shadow: var(--shadow-md);
  padding: var(--s-5) var(--s-4);
}
.card-tight { padding: var(--s-4); }

/* Flex `gap` owns the spacing wherever a parent is a .stack. Everywhere
   else - a plain <div> that innerHTML fills with cards - nothing would
   separate them at all, so adjacent blocks get their own margin and the
   flex containers switch it back off. */
.card + .card,
.queue-card + .queue-card,
.cfg-row + .cfg-row,
.now-card + .card,
.card + .queue-card,
.queue-card + .card { margin-block-start: var(--gap); }

:is(.stack, .stack-sm, .stack-loose) >
  :is(.card, .queue-card, .cfg-row, .now-card) +
  :is(.card, .queue-card, .cfg-row) { margin-block-start: 0; }

/* ---------- Deliberate separation between groups ---------------------
   These sit on top of the stack gap, because they divide the screen into
   parts that mean different things: the status, the numbers, the filters.
   -------------------------------------------------------------------- */
section.admin-section { margin-block: 1rem; }
.admin-section .counters { margin-block: 1rem; }
#now-host { margin-block: 1rem; }
.filters { margin-block: 1rem; }

/* A card's own heading: a mono rule across the top of its contents. The
   type is small on purpose - the card's border is doing the shouting. */
.card-title {
  font-family: var(--mono);
  font-size: var(--t-meta);
  font-weight: 600;
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: var(--s-4);
  padding-bottom: var(--s-2);
  border-bottom: var(--bd-hair) solid var(--border);
}

/* ---------- Status badges ---------------------------------------------
   Rectangular, bordered, always carrying their own text. Colour is a
   second signal here, never the only one - which is what keeps the
   statuses readable for a colour-blind reader and in a photocopy.
   -------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: 3px var(--s-2);
  border: var(--bd-thin) solid var(--ink);
  background: var(--muted-soft);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-ok     { background: var(--ok-soft);     color: var(--ok); }
.badge-warn   { background: var(--warn-soft);   color: var(--warn); }
.badge-info   { background: var(--info-soft);   color: var(--info); }
.badge-urgent { background: var(--urgent-soft); color: var(--urgent); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-accent { background: var(--accent);      color: var(--accent-contrast); }
.badge-critical { background: var(--critical-soft); color: var(--critical); }
.badge-muted  { background: var(--muted-soft);  color: var(--text-muted); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: 6px var(--s-3);
  background: var(--surface-2);
  border: var(--bd-thin) solid var(--ink);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.mono   { font-family: var(--mono); font-size: .93em; }
.tabnum { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted  { color: var(--text-muted); }
.faint  { color: var(--text-faint); }
.small  { font-size: 13px; }

/* ---------- Forms -----------------------------------------------------
   Thick edges, flat fills, generous targets. The label is mono and
   uppercase so a field announces itself before it is read.
   -------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--s-2); }

.label {
  font-family: var(--mono);
  font-size: var(--t-meta);
  font-weight: 600;
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--text);
}

.input, .select, .textarea {
  width: 100%;
  min-height: var(--tap);
  padding: var(--s-3) var(--s-3);
  font: inherit;
  font-size: 16px;                    /* 16px stops iOS zooming on focus */
  font-weight: 500;
  color: var(--text);
  /* background-color, never the `background` shorthand: the shorthand
     resets background-repeat and background-position too, which is how
     the select arrow ended up tiled across a focused field. */
  background-color: var(--surface);
  border: var(--bd) solid var(--ink);
  border-radius: 0;
  transition: box-shadow .08s ease, background-color .12s ease;
}
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }

/* Focus fills the field with the action colour's shadow rather than a
   glow, so it matches the way buttons behave. */
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  background-color: var(--surface);
  box-shadow: var(--shadow-sm);
}
.textarea { min-height: 104px; resize: vertical; line-height: 1.5; }

/* Exactly one arrow: the native one is removed by appearance:none (with
   the two vendor spellings older Android Chrome and Firefox still need),
   and ours is drawn once from --select-arrow, which the theme swaps. */
.select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right var(--s-3) center;
  background-size: 18px;
  padding-inline-end: var(--s-6);
  cursor: pointer;
}
/* Firefox keeps a focus ring on the text of a select; it has its own. */
.select:-moz-focusring { color: transparent; text-shadow: 0 0 0 var(--text); }
:root[dir='rtl'] .select { background-position: left var(--s-3) center; }

/* Checkboxes get the same ink treatment as everything else. */
input[type='checkbox'] {
  appearance: none;
  width: 24px; height: 24px;
  flex: none;
  border: var(--bd) solid var(--ink);
  background: var(--surface);
  cursor: pointer;
  display: grid;
  place-items: center;
}
input[type='checkbox']:checked { background: var(--accent); }
input[type='checkbox']:checked::after {
  content: '';
  width: 10px; height: 6px;
  border: 3px solid var(--ink);
  border-top: 0;
  border-right: 0;
  transform: rotate(-45deg) translate(1px, -2px);
}

.help  { font-size: 13px; color: var(--text-muted); }
.error {
  font-size: var(--t-small);
  font-weight: 700;
  color: var(--danger);
  background: var(--danger-soft);
  border: var(--bd-thin) solid var(--danger);
  padding: var(--s-2) var(--s-3);
}

/* Segmented radio group: tappable blocks, the chosen one filled. */
.segmented { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  flex: 1 1 auto;
  min-width: 96px;
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: var(--s-2) var(--s-3);
  border: var(--bd) solid var(--ink);
  background: var(--surface);
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: transform .05s ease, box-shadow .05s ease;
}
.segmented label:hover { background: var(--accent-soft); }
.segmented input:checked + label {
  background: var(--accent);
  color: var(--accent-contrast);
  box-shadow: var(--shadow-sm);
}
/* The top of the urgency scale is the one option drawn inverted. Same
   border, same shadow, same press - only the fill changes, so it reads
   as louder rather than as a different kind of control. */
.segmented label.is-critical {
  background: var(--critical-soft);
  color: var(--critical);
  border-color: var(--ink);
}
.segmented label.is-critical:hover { background: var(--danger-fill); }
.segmented input:checked + label.is-critical {
  background: var(--critical-soft);
  color: var(--critical);
  box-shadow: var(--shadow-md);
}

/* A short playful line. Deliberately plain so it reads as an aside, not
   as another status the eye has to decode. */
.quip {
  font-weight: 700;
  font-size: var(--t-small);
  padding: var(--s-2) var(--s-3);
  border: var(--bd-thin) solid var(--ink);
  background: var(--accent);
  color: var(--accent-contrast);
}
.quip:empty { display: none; }
.quip[data-priority='life_death'] {
  background: var(--critical-soft);
  color: var(--critical);
}
/* On the board it is commentary on a fact already stated above it, so it
   loses the plate and keeps only the weight. */
.quip-quiet {
  border: 0;
  padding: 0;
  margin-top: var(--s-2);
  background: none;
  color: var(--text-muted);
  font-weight: 600;
}

.segmented input:focus-visible + label {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 6px var(--ink);
}

/* ---------- Request type tabs -----------------------------------------
   Two kinds of request, chosen before anything is filled in. Drawn as
   plates that press, like every other control here; the chosen one is
   filled and sits on its shadow so there is no ambiguity about which
   form is on screen.
   -------------------------------------------------------------------- */
.reqtabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-2);
  margin-bottom: var(--s-4);
}
.reqtab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: var(--tap);
  padding: var(--s-2) var(--s-3);
  border: var(--bd) solid var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font: inherit;
  font-weight: 700;
  font-size: var(--t-small);
  text-transform: uppercase;
  letter-spacing: .02em;
  color: var(--text);
  cursor: pointer;
  transition: transform .05s ease, box-shadow .05s ease, background .12s ease;
}
.reqtab:hover { background: var(--accent-soft); }
.reqtab[aria-selected='true'] {
  background: var(--accent);
  color: var(--accent-contrast);
  transform: var(--press);
  box-shadow: var(--shadow-flat);
}
.reqtab[aria-selected='true'] .icon { --ic: var(--surface); --ic2: var(--accent); }

/* A heading inside a long form, to break it into parts that can be
   skimmed. Quieter than a card title because it divides, not contains. */
.form-heading {
  font-family: var(--mono);
  font-size: var(--t-meta);
  font-weight: 600;
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--text);
  padding-top: var(--s-3);
  border-top: var(--bd-hair) solid var(--border);
}

/* ---------- The chosen file ------------------------------------------- */
.filechip {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  background: var(--surface-2);
  border: var(--bd-thin) solid var(--ink);
  font-size: 13px;
  font-weight: 600;
}
.filechip .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filechip .mono { flex: none; font-size: 11.5px; color: var(--text-muted); }

/* Upload progress. Stepped rather than smooth, to match the bar charts. */
.upload-bar {
  height: 12px;
  border: var(--bd-thin) solid var(--ink);
  background: var(--surface);
  margin-top: var(--s-2);
}
.upload-bar > span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .2s steps(10, end);
}

/* ---------- A print job, on a card ------------------------------------
   Only ever rendered for the administrator or for the person who sent it.
   The filename inside is the reason this block exists, and the reason it
   is never built from a public snapshot.
   -------------------------------------------------------------------- */
.printbox {
  margin-top: var(--s-3);
  padding: var(--s-3);
  background: var(--surface-2);
  border: var(--bd-thin) solid var(--border);
  border-inline-start: 8px solid var(--info-fill);
}
.printbox-file {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-weight: 700;
  font-size: var(--t-small);
  overflow-wrap: anywhere;
}
.printbox-line {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}
.printbox-note { font-family: var(--font); font-style: italic; }
.printbox .btn { margin-top: var(--s-3); }

/* A print request is marked on the public board too, but with a type, not
   a filename: the stripe says "this one is a document", nothing more. */
.queue-item[data-type='print'] { border-inline-end: 5px solid var(--info-fill); }

/* A required field says so once, with one mark, rather than repeating the
   word "required" down the page. <abbr> carries the explanation for a
   screen reader; the asterisk carries it for everyone else. */
.req {
  color: var(--danger);
  font-weight: 700;
  margin-inline-start: 3px;
  text-decoration: none;
  cursor: help;
}
.req-key {
  font-family: var(--mono);
  font-size: 11.5px;
  margin-top: calc(var(--s-2) * -1);
}
.req-key::first-letter { color: var(--danger); font-weight: 700; }

/* Haitham disagreeing with how urgent somebody thinks their problem is.
   It sits beside their own badge, never instead of it. */
.flagline {
  font-weight: 600;
  color: var(--info);
}
.flagnotice { border-inline-start: 8px solid var(--info-fill); }

/* ---------- One card per document --------------------------------------
   Each attached file is its own block with its own copies, paper, sides
   and class, because twenty of one thing for Grade 8 and five of another
   for Grade 10 is one errand, not two requests.
   -------------------------------------------------------------------- */
.filecard {
  border: var(--bd-thin) solid var(--border);
  border-inline-start: 8px solid var(--info-fill);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: var(--s-3);
}
/* Attached, but over the limit the chosen urgency allows. Kept on screen
   and marked rather than silently dropped: which file to lose is the
   colleague's decision, not the form's. */
.filecard.is-over {
  border-inline-start-color: var(--danger-fill);
  background: var(--danger-soft);
}
.filecard-head {
  display: flex;
  align-items: flex-start;
  gap: var(--s-2);
}
.filecard-name {
  display: block;
  font-weight: 700;
  font-size: var(--t-small);
  overflow-wrap: anywhere;
}
.filecard-meta {
  display: block;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-muted);
}
.filecard-num {
  flex: none;
  width: 22px; height: 22px;
  display: inline-grid; place-items: center;
  background: var(--accent);
  color: var(--accent-contrast);
  border: var(--bd-thin) solid var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
}
.filecard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-2);
  margin-top: var(--s-3);
  padding-top: var(--s-3);
  border-top: var(--bd-hair) solid var(--border);
}
.filecard-grid .label { font-size: 10.5px; }
.filecard-grid .input,
.filecard-grid .select { min-height: 42px; border-width: var(--bd-thin); }

/* The urgency block leads the form, so it reads as the first decision
   rather than the last. */
.urgency-first { padding-bottom: var(--s-3); border-bottom: var(--bd-hair) solid var(--border); }
.limit-broken { color: var(--danger); font-weight: 700; }

/* The colour permission question, asked on the document it applies to
   rather than once for the whole request: a colour poster and two
   black-and-white worksheets are one errand. */
.filecard-ask {
  margin-top: var(--s-3);
  padding: var(--s-3);
  background: var(--accent-soft);
  border: var(--bd-thin) solid var(--ink);
}
/* "How did it arrive?" and "What is it?" get a line each. The first is a
   long question and the second wants room to type into - side by side on
   a phone they are two cramped half-widths. */
.filecard-grid.is-stacked { grid-template-columns: minmax(0, 1fr); }

.filecard-note { margin-top: var(--s-3); }
.filecard-note .help { font-family: var(--mono); font-size: 11px; }

/* ---------- Toasts --------------------------------------------------- */
.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--s-4));
  transform: translateX(-50%);
  z-index: 90;
  width: min(94vw, 460px);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-3);
  background: var(--bg-elevated);
  border: var(--bd) solid var(--ink);
  box-shadow: var(--shadow-md);
  font-size: var(--t-small);
  font-weight: 700;
  animation: toast-in .15s ease;
}
.toast-ok    { border-inline-start: 10px solid var(--ok-fill); }
.toast-error { border-inline-start: 10px solid var(--danger-fill); }
.toast-info  { border-inline-start: 10px solid var(--accent); }
.toast button {
  margin-inline-start: auto;
  background: none; border: 0; cursor: pointer;
  color: var(--text); font-size: 17px; line-height: 1; padding: 0 2px;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Modal / sheet -------------------------------------------- */
.sheet {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: 100vw;
  max-height: 100dvh;
  margin: 0;
  position: fixed;
  inset: 0;
  /* The UA stylesheet sets dialog { width/height: fit-content }, which
     over-constrains inset:0 and collapses the box to zero height. Both
     must be stated explicitly or the panel lands off-screen. */
  width: 100%;
  height: 100%;
}
.sheet::backdrop { background: rgba(13, 13, 13, .72); }
.sheet-panel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: 92dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg-elevated);
  border-top: var(--bd) solid var(--ink);
  padding: var(--s-2) var(--s-4) calc(var(--s-5) + env(safe-area-inset-bottom));
  animation: sheet-up .18s cubic-bezier(.2, .8, .3, 1);
}
@keyframes sheet-up { from { transform: translateY(14px); } }
.sheet-grip {
  width: 56px; height: 5px;
  background: var(--ink);
  margin: var(--s-2) auto var(--s-3);
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  margin-bottom: var(--s-4);
  padding-bottom: var(--s-3);
  border-bottom: var(--bd) solid var(--border);
}
.sheet-head h2 { font-size: 20px; text-transform: uppercase; }
.sheet-close {
  background: var(--surface);
  border: var(--bd-thin) solid var(--ink);
  width: 38px; height: 38px;
  font-size: 16px; line-height: 1;
  font-weight: 700;
  cursor: pointer;
  color: var(--text);
  flex: none;
}
.sheet-close:hover { background: var(--danger); color: var(--text-invert); }

/* ---------- Bottom navigation ---------------------------------------- */
.bottomnav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 45;
  display: flex;
  background: var(--bg-elevated);
  border-top: var(--bd) solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a, .bottomnav button {
  flex: 1;
  min-height: var(--nav-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: 0;
  border-inline-end: var(--bd-hair) solid var(--border);
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
  position: relative;
}
.bottomnav > :last-child { border-inline-end: 0; }
.bottomnav .ico { font-size: 19px; line-height: 1; }
.bottomnav [aria-current='page'] {
  background: var(--accent);
  color: var(--accent-contrast);
}
.nav-dot {
  position: absolute;
  top: 9px;
  inset-inline-start: calc(50% + 9px);
  min-width: 19px; height: 19px;
  padding: 0 3px;
  border: var(--bd-thin) solid var(--ink);
  background: var(--danger);
  color: var(--text-invert);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

/* ---------- States --------------------------------------------------- */
.skeleton {
  background: repeating-linear-gradient(
    45deg,
    var(--surface-2) 0 10px,
    var(--muted-soft) 10px 20px
  );
  border: var(--bd-thin) solid var(--border);
  height: 18px;
  animation: hatch 1.1s linear infinite;
}
@keyframes hatch { to { background-position: 28px 0; } }

.empty {
  text-align: center;
  padding: var(--s-6) var(--s-4);
  color: var(--text-muted);
  border: var(--bd-thin) dashed var(--border);
}
.empty-icon { font-size: 32px; margin-bottom: var(--s-2); }

.offline-bar {
  background: var(--warn);
  color: var(--text-invert);
  font-family: var(--mono);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: .06em;
  text-transform: uppercase;
  text-align: center;
  padding: var(--s-2) var(--s-3);
  border-bottom: var(--bd) solid var(--ink);
}

.notice {
  padding: var(--s-4);
  border: var(--bd) solid var(--ink);
  background: var(--surface-2);
  box-shadow: var(--shadow-sm);
  font-size: var(--t-small);
  font-weight: 500;
}
.notice-ok     { background: var(--secondary-soft); color: var(--secondary-text); }
.notice-warn   { background: var(--warn-soft);      color: var(--warn); }
.notice-danger { background: var(--danger-soft);    color: var(--danger); }
.notice-info   { background: var(--accent-soft);    color: var(--accent-text); }
/* Asked for explicitly. margin-block is the logical form, so it is top
   and bottom in both reading directions and nothing has to flip. */
.notice-spaced { margin-block: 25px; }

/* ---------- Tables (admin) ------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: var(--bd) solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-small);
}
.table th, .table td {
  text-align: start;
  padding: var(--s-3) var(--s-3);
  border-bottom: var(--bd-hair) solid var(--border);
  vertical-align: middle;
}
.table th {
  font-family: var(--mono);
  font-size: var(--t-meta);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--text);
  background: var(--accent);
  font-weight: 600;
  white-space: nowrap;
  border-bottom-width: var(--bd);
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--accent-soft); }
.table td.actions { white-space: nowrap; text-align: end; }

/* ---------- Print -----------------------------------------------------
   The ink-and-paper system photocopies well, which matters for a printed
   weekly report. Shadows go, borders stay.
   -------------------------------------------------------------------- */
@media print {
  .appbar, .bottomnav, .toasts, .no-print, .btn { display: none !important; }
  body { background: #fff; color: #000; }
  .card, .table-wrap, .notice { box-shadow: none !important; border: 2px solid #000; break-inside: avoid; }
  .page { padding-bottom: 0; }
}
