/* ============================================================================
   dashboard-common.css — the ONE set of tokens and parts shared by every
   dashboard and report screen (2026-09-03 visual audit).

   Before this file each screen carried its own :root block (three copies of
   the indigo tokens), six KPI-tile designs, five card-header designs, seven
   timestamp formats and ~300 hex literals. Everything here is additive and
   namespaced `dq-` so it cannot collide with Bootstrap or the legacy shell.

   TOKENS. This block is the whole palette of the application — the shell
   skin (app-shell.css), every dashboard and every report resolve their
   colour here and nowhere else. It used to be two palettes: --dq-* for the
   dashboards and a second --eq-* set that only existed under `body.theme-v2`,
   a flag that was never on in production. They are merged. Where the two
   disagreed the accessible value won, which is why --eq-muted is #5b6b7d
   (5.4:1) and not #64748b (4.7:1), and why --dq-good keeps its dark #067647
   instead of the emerald: it is printed as TEXT on --dq-good-soft, where the
   emerald measures 2.2:1.

   A THEME IS THIS BLOCK AGAIN WITH DIFFERENT VALUES — see the body.theme-*
   blocks below. Nothing outside this file may declare a :root block, and no
   rule anywhere may hardcode a colour a theme would need to change.

   The --eq-accent-* group is additionally replaceable PER TENANT: when an
   account has a brand colour, lib/theme.py recomputes that whole group
   (including a contrast-safe foreground and a text-safe darkened variant)
   and layouts/base.html emits it as an inline style on <body>, which beats
   every selector here. See lib/theme.py for the colour maths.

   Charts read these tokens at runtime through dq-charts.js — never hardcode
   a chart colour in a template.
   ========================================================================== */

:root {
  /* -- ink ---------------------------------------------------------------- */
  --eq-ink:#0b1220;         /* headings, primary numerals */
  --eq-text:#334155;        /* body copy */
  --eq-muted:#5b6b7d;       /* secondary text — 5.4:1 on white; never lighter than this for words */
  --eq-faint:#94a3b8;       /* decorative ONLY: dots, dividers, chart gridlines.
                               2.6:1 on a white field, so never words — not even
                               placeholder words; those take --eq-muted. */

  /* -- surfaces ----------------------------------------------------------- */
  --eq-surface:#ffffff;     /* cards, panels, table bodies */
  --eq-surface-2:#f4f7fc;   /* table headers, secondary buttons, subtle fills */
  --eq-ground:#eef2f8;      /* page canvas, top */
  --eq-ground-2:#e6ebf4;    /* page canvas, bottom */
  --eq-aura:rgba(59,130,246,.10);  /* the faint wash behind the canvas */
  --eq-line:#e7ebf3;        /* hairline borders */
  --eq-field:#ffffff;       /* input background */
  --eq-field-line:#d5dbe6;  /* input border */
  --eq-navbar:rgba(255,255,255,.85);
  --eq-sidebar-1:#0a1428;   /* deep cobalt-navy sidebar gradient */
  --eq-sidebar-2:#0f2149;

  /* -- accent (replaceable per tenant; see lib/theme.py) ------------------- */
  --eq-accent:#1d4ed8;      /* the fill colour: buttons, badges, bars */
  --eq-accent-2:#3b82f6;    /* lighter accent for gradients / second series */
  --eq-accent-deep:#1a45c8; /* pressed / hover end of the gradient */
  --eq-accent-ink:#1d4ed8;  /* the accent as TEXT on --eq-surface: ≥4.5:1, always */
  --eq-on-accent:#ffffff;   /* text ON an accent fill: ≥4.5:1, always */
  --eq-accent-soft:#e8effc; /* pale tint for pill backgrounds */
  --eq-accent-wash:rgba(59,130,246,.055);  /* table row hover */
  --eq-accent-tint:rgba(59,130,246,.16);   /* focus ring, soft hover fill */
  --eq-accent-edge:rgba(59,130,246,.45);   /* soft border */
  --eq-accent-vivid:rgba(59,130,246,.85);  /* active nav pill, start */
  --eq-accent-strong:rgba(37,99,235,.65);  /* active nav pill, end */
  --eq-accent-shadow:rgba(37,99,235,.70);  /* the glow under a primary control */

  /* -- semantic ------------------------------------------------------------
     The paired *-soft value is the background these are printed on, so the
     foreground has to stay dark enough to read against it. --eq-emerald is
     the DECORATIVE green (button fills, icons) and is never used for words. */
  --eq-good:#067647;  --eq-good-soft:#e6f4ec;
  --eq-warn:#b54708;  --eq-warn-soft:#fef1e2;
  --eq-bad:#b42318;   --eq-bad-soft:#fdecea;
  /* The foreground for words ON a semantic FILL — the same pattern as
     --eq-on-accent and --eq-on-emerald, and needed for the same reason: the
     dark theme LIGHTENS all three semantic colours, so a literal `#fff`
     beside them stops being readable the moment a viewer picks dark.
     `.badge-warning` was measured at 1.85:1 on 34 screens, which is the
     single largest legibility failure the dark theme shipped with. Light
     and high contrast keep white (5.4:1 and 9.3:1 on the warn); dark takes
     the near-black ink (10.1:1). Literals, not var() aliases — see the note
     on --eq-on-emerald for why a theme cannot alias one of these. */
  --eq-on-good:#ffffff;
  --eq-on-warn:#ffffff;
  --eq-on-bad:#ffffff;
  /* Ink for text on a scrim WE draw (the photo-tile name strip), as
     opposed to a theme surface. Deliberately not theme-varying: the scrim
     is always dark, in every theme, because it sits over a photograph. */
  --eq-on-scrim:#ffffff;
  --eq-on-muted:#ffffff;
  --eq-emerald:#10b981; --eq-emerald-dp:#0e9f6e;
  /* The foreground for words ON an emerald fill — the same pattern as
     --eq-on-accent, and needed for the same reason. The emerald is a LIGHT
     green in light and dark and a DARK green in high contrast, so no single
     foreground serves all three: white on it measures 2.54:1 light and
     1.92:1 dark (both fail AA) but 9.0:1 in contrast. Declared as a literal
     and not as var(--eq-ink), because the ink inverts per theme and the
     emerald does not — in dark, --eq-ink is #e8edf5, which on #34d399 is
     1.9:1. Light and dark therefore both take the DARK ink: 7.4:1 and
     9.8:1. .btn-success and .badge-success are the two rules that use it. */
  --eq-on-emerald:#0b1220;

  /* ── TYPE ──────────────────────────────────────────────────────────────
     THE FONT IS A SYSTEM STACK, ON PURPOSE. A webfont is one more blocking
     request on the screen that takes 36,389 posts a month at a front desk,
     and `codedeploy.sh` ships every static directory except `images/`, so a
     self-hosted file would reach the servers but still cost that request.
     The stack names the faces the client machines ALREADY have and that are
     genuinely current: `Segoe UI Variable Text` is Windows 11's UI face,
     `-apple-system` is SF Pro on the iPads, and `Inter` is picked up free by
     anyone who has installed it. Nothing is downloaded.

     THE SCALE IS NOT A SINGLE RATIO, and pretending otherwise is how type
     scales get abandoned. Below 1rem one pixel is the difference between a
     legible table and a cramped one, so the steps are tight (12/13/14/15/16);
     above it they open out (18/22/28/36/48). Every step has a job named
     beside it; a size with no job does not belong in the scale.

     The two largest steps are `clamp()` rather than a media query. A 36px
     numeral on a 390px phone is wider than the tile holding it, and the
     breakpoint set is deliberately four values (tests/cssguard/
     test_breakpoints.py) — clamp needs none of them. */
  --eq-font:-apple-system,BlinkMacSystemFont,"Segoe UI Variable Text","Segoe UI",Inter,Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji";
  --eq-font-mono:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;

  --eq-text-caption:.75rem;      /* 12px  overline, table head, pill, badge */
  --eq-text-xs:.8125rem;         /* 13px  hint, error, footnote, meta line */
  --eq-text-sm:.875rem;          /* 14px  dense table cell, secondary text */
  --eq-text-base:.9375rem;       /* 15px  control text and form labels */
  --eq-text-body:1rem;           /* 16px  paragraph copy */
  --eq-text-lg:1.125rem;         /* 18px  card title, section heading */
  --eq-text-xl:1.375rem;         /* 22px  sub-head */
  --eq-text-2xl:1.75rem;         /* 28px  page title */
  --eq-text-3xl:clamp(1.75rem, 1.35rem + 1.8vw, 2.25rem);   /* 28→36 KPI numeral */
  --eq-text-display:clamp(2.25rem, 1.6rem + 2.8vw, 3rem);   /* 36→48 display */

  /* Four line heights, tied to size rather than to taste: big type needs
     less leading, paragraphs need more, and a table cell needs neither. */
  --eq-leading-tight:1.15;       /* display and numerals */
  --eq-leading-snug:1.3;         /* headings */
  --eq-leading-normal:1.45;      /* UI text, labels, cells */
  --eq-leading-relaxed:1.6;      /* paragraph copy */

  /* Four weights. 600 is the workhorse — it is the heaviest weight that
     stays a UI weight rather than a headline one, and both Segoe UI and SF
     have a real cut of it rather than a synthesised one. */
  --eq-weight-regular:400;
  --eq-weight-medium:500;
  --eq-weight-semibold:600;
  --eq-weight-bold:700;

  /* Large type is set too loose by default and small caps too tight. */
  --eq-tracking-tight:-.012em;   /* ≥22px */
  --eq-tracking-normal:0;
  --eq-tracking-wide:.06em;      /* the uppercase overline */
  --eq-measure:68ch;             /* the longest line a paragraph may run */

  /* ── SPACE ─────────────────────────────────────────────────────────────
     One 4px grid, named by multiples of it. Before this the kit measured
     padding in .6rem / .65rem / .72rem / .8rem / .9rem / 1.15rem / 1.25rem —
     seven values doing three jobs, which is the loudest "built over years"
     signal a screen gives off. The steps skip 7, 9 and 11 because a scale
     nobody has to choose within is a scale people use. */
  --eq-space-1:.25rem;           /* 4px   icon gap, hairline inset */
  --eq-space-2:.5rem;            /* 8px   inside a control */
  --eq-space-3:.75rem;           /* 12px  cell padding, card header */
  --eq-space-4:1rem;             /* 16px  grid gutter, control padding */
  --eq-space-5:1.25rem;          /* 20px  card body */
  --eq-space-6:1.5rem;           /* 24px  between cards */
  --eq-space-8:2rem;             /* 32px  page gutter, section break */
  --eq-space-10:2.5rem;          /* 40px  major section break */
  --eq-space-12:3rem;            /* 48px  page top/bottom */

  /* ── RADIUS ────────────────────────────────────────────────────────────
     Five steps, and the high-contrast theme flattens four of them. The
     funnel audit measured FIVE UNRELATED radii (4, 6, 8, 12, 50px) inside
     one four-click signup; these are the same count, in a progression, and
     every one of them is a token a theme can reach. --eq-radius-control
     keeps its name because components.css and two tests spell it. */
  --eq-radius-xs:6px;            /* chip, small button, skeleton */
  --eq-radius-control:10px;      /* button, input, select */
  --eq-radius-sm:12px;           /* alert, inner panel, summary strip */
  --eq-radius:16px;              /* card, tile, modal */
  --eq-radius-pill:999px;        /* a pill is a shape, not a soft edge */

  /* ── ELEVATION ─────────────────────────────────────────────────────────
     Four steps: hairline, resting, raised, overlay. A shadow is a LIGHT
     model, so it cannot survive a change of canvas unaltered — a soft dark
     shade on a near-black surface is simply invisible, which is why the dark
     theme below replaces the whole scale with a rim of light plus a deeper
     shade, and why the high-contrast theme replaces it with nothing at all
     and lets its 2px borders do the work. */
  --eq-shadow-xs:0 1px 2px rgba(15,23,42,.06);
  /* The moving highlight in a loading skeleton. It is a THIRD surface — one
     step brighter than --eq-surface-2 on a light canvas and one step dimmer
     than it on a dark one — so it cannot be expressed as either of the two
     surface tokens, and it was the last colour literal in this file's
     component half. */
  --eq-skeleton-hi:#f6f8fa;
  --eq-shadow:0 1px 2px rgba(15,23,42,.05), 0 12px 28px -16px rgba(15,23,42,.30);
  --eq-shadow-hover:0 2px 4px rgba(15,23,42,.06), 0 22px 44px -18px rgba(29,78,216,.32);
  --eq-shadow-lg:0 4px 8px -2px rgba(15,23,42,.08), 0 28px 56px -20px rgba(15,23,42,.38);

  /* ── MOTION ────────────────────────────────────────────────────────────
     Three durations and two curves. Nothing in the application may animate
     for longer than --eq-dur-3: at a front desk an animation is a delay, not
     a delight. The curves are decelerating — a control should arrive, not
     bounce. Every rule built on these is paired with a
     `prefers-reduced-motion: reduce` block, and the student scan screen
     reaches none of them: bulkmode carries no `dq-` class and no theme. */
  --eq-dur-1:120ms;              /* colour and opacity */
  --eq-dur-2:180ms;              /* transform with a shadow */
  --eq-dur-3:240ms;              /* a panel or an overlay */
  --eq-ease:cubic-bezier(.2,.6,.2,1);
  --eq-ease-out:cubic-bezier(.16,1,.3,1);

  /* ── CONTROL GEOMETRY ──────────────────────────────────────────────────
     Consumed by components.css. One height, one text size, and a touch pair
     for the width where iOS Safari zooms. The two font sizes repeat the
     values of --eq-text-base and --eq-text-body as LITERALS rather than
     aliasing them: a custom property holding var() is substituted where it
     is declared, so an alias in :root would freeze (see the dq-* note
     below), and tests/csslayers/test_cascade_order.py reads
     --eq-control-font-touch's literal to prove the iOS floor is 16px.
     --eq-control-font-touch must never drop below 16px: a smaller field
     taking focus zooms iOS Safari and it does not zoom back. */
  --eq-control-min:40px;
  --eq-control-min-touch:44px;
  --eq-control-font:.9375rem;        /* 15px — the same step as --eq-text-base */
  --eq-control-font-touch:1rem;      /* 16px — the iOS floor, not a taste */

  /* Categorical palette for nominal series (roles, towns, buildings). Ten
     hues that stay distinct for common colour-vision deficiencies; grey is
     reserved for "Other". Sequential/ordinal data (grades) uses --dq-seq-*.
     Chart hues are data, not brand: a theme may lighten them for a dark
     canvas but must keep them mutually distinguishable. */
  --dq-cat-1:#1d4ed8; --dq-cat-2:#0e9f6e; --dq-cat-3:#d97706; --dq-cat-4:#7c3aed;
  --dq-cat-5:#db2777; --dq-cat-6:#0891b2; --dq-cat-7:#65a30d; --dq-cat-8:#9f1239;
  --dq-cat-9:#4b5563; --dq-cat-10:#b45309;
  /* Readable text on each categorical fill, via lib.theme.on_color:
     whichever of white or near-black clears 4.5:1. The cat palette is
     for CHART fills, where nothing sits on top of it -- used behind
     white initials it measured 3.19-3.68:1 in light and 1.67-2.72:1
     in dark, i.e. invisible. */
  --dq-on-cat-1:#ffffff; --dq-on-cat-2:#0b1220; --dq-on-cat-3:#0b1220;
  --dq-on-cat-4:#ffffff; --dq-on-cat-5:#ffffff; --dq-on-cat-6:#0b1220;
  --dq-on-cat-7:#0b1220; --dq-on-cat-8:#ffffff; --dq-on-cat-9:#ffffff;
  --dq-seq-1:#dbeafe; --dq-seq-2:#93c5fd; --dq-seq-3:#3b82f6; --dq-seq-4:#1d4ed8; --dq-seq-5:#1e3a8a;
}

/* ---- dq-* aliases ----------------------------------------------------------
   413 references across the templates already spell these names. They are
   aliases, not a second palette: change a value in :root, not here.

   They are declared on BODY and not on :root, and that placement is the
   whole thing working or not. A custom property holding `var(--x)` is
   substituted on the element where it is DECLARED, and the result is what
   inherits. Declared on :root, `--dq-surface:var(--eq-surface)` would freeze
   the light value there and keep serving it to the whole document, so a
   theme could recolour the shell and every dashboard card would stay white —
   which is exactly what happened the first time. On body, --eq-surface
   resolves to whatever body carries: the theme class, or the tenant's accent
   from the inline style attribute, both of which land on body. */
body {
  --dq-ink:var(--eq-ink); --dq-text:var(--eq-text); --dq-muted:var(--eq-muted);
  --dq-faint:var(--eq-faint);
  --dq-surface:var(--eq-surface); --dq-ground:var(--eq-surface-2); --dq-line:var(--eq-line);
  --dq-accent:var(--eq-accent); --dq-accent-2:var(--eq-accent-2);
  --dq-accent-ink:var(--eq-accent-ink);
  --dq-accent-soft:var(--eq-accent-soft);
  --dq-good:var(--eq-good);  --dq-good-soft:var(--eq-good-soft);
  --dq-warn:var(--eq-warn);  --dq-warn-soft:var(--eq-warn-soft);
  --dq-bad:var(--eq-bad);    --dq-bad-soft:var(--eq-bad-soft);
  /* A card is a card: this aliased --eq-radius-sm (12px) while Bootstrap's
     .card took --eq-radius (16px), so a dashboard tile and the panel beside
     it turned their corners differently on the same screen. One value. */
  --dq-radius:var(--eq-radius);
  --dq-shadow:var(--eq-shadow); --dq-shadow-hover:var(--eq-shadow-hover);
  /* The focus halo, as one token. It holds a var(), so it has to be declared
     HERE and not in :root for exactly the reason the aliases above are —
     the accent is replaced per tenant on this same element.
     A LOOK, NOT AN INDICATOR: 1.18-1.49:1 against the surface it is drawn
     on, across the palettes, where a focus indicator needs 3:1. Never the
     only thing a focus state draws — pair it with the 2px --eq-accent-ink
     outline (components.css, "Focus"). */
  --eq-ring:0 0 0 3px var(--eq-accent-tint);
}

/* ============================================================================
   THEMES. Each one is the block above with different values, and nothing
   else: no second copy of a component, no second skin file. That is the
   whole point of having spent a commit merging the palettes.

   A theme class never reaches the student scan screen — lib/theme.py keeps
   the bulkmode blueprint neutral, because that screen takes 36,389 posts a
   month on real devices at a front desk and is not where a legibility
   surprise belongs.

   What a theme CANNOT reach: the 16,589 lines of per-page <style> that
   hardcode their own white panels and near-black text. Those render light
   under every theme. The two files that mattered most — index-page.css and
   chk_in.html, the busiest non-scan screens — were converted from an
   uncontrolled `prefers-color-scheme` block to these classes, so the dark
   theme covers them; the rest of the tail does not, and pretending otherwise
   in the picker copy would be dishonest.
   ========================================================================== */

/* ---- Dark ----------------------------------------------------------------
   Surfaces lift as they come forward (ground < surface < raised), which is
   how depth reads without shadows on a dark canvas. The semantic colours are
   lightened, not re-hued: a warning has to stay orange. */
body.theme-dark {
  color-scheme: dark;

  --eq-ink:#e8edf5;
  --eq-text:#c3ccda;
  --eq-muted:#9aa7b8;        /* 6.2:1 on --eq-surface */
  --eq-faint:#6b7889;

  --eq-surface:#161d2e;
  --eq-surface-2:#1e263a;
  --eq-ground:#0d1320;
  --eq-ground-2:#111829;
  --eq-aura:rgba(59,130,246,.10);
  --eq-line:#2a3348;
  --eq-field:#111829;
  --eq-field-line:#39445c;
  --eq-navbar:rgba(22,29,46,.88);
  --eq-sidebar-1:#0a1020;
  --eq-sidebar-2:#121a2e;

  --eq-accent:#60a5fa;
  --eq-accent-2:#93c5fd;
  --eq-accent-deep:#3b82f6;
  --eq-accent-ink:#8ec0fd;   /* 7.0:1 on --eq-surface */
  --eq-on-accent:#0b1220;    /* a light accent takes DARK text, not white */
  --eq-accent-soft:#1c2c48;
  --eq-accent-wash:rgba(96,165,250,.08);
  --eq-accent-tint:rgba(96,165,250,.22);
  --eq-accent-edge:rgba(96,165,250,.5);
  --eq-accent-vivid:rgba(96,165,250,.6);
  --eq-accent-strong:rgba(59,130,246,.45);
  --eq-accent-shadow:rgba(0,0,0,.6);

  --eq-good:#5fd0a0;  --eq-good-soft:#15362a;
  --eq-warn:#f0b36b;  --eq-warn-soft:#3a2a15;
  --eq-bad:#f08a80;   --eq-bad-soft:#3a1c19;
  /* All three semantic colours are LIGHTENED here, so all three fills take
     the dark ink: 9.8:1, 10.1:1 and 7.7:1. White measures 1.91, 1.85 and
     2.43 — which is what a badge, a danger button and a warning button
     looked like on every screen until this token existed. */
  --eq-on-good:#0b1220;
  --eq-on-warn:#0b1220;
  --eq-on-bad:#0b1220;
  --eq-on-muted:#1b1611;
  --eq-emerald:#34d399; --eq-emerald-dp:#10b981;
  /* Still the dark ink: the dark theme LIGHTENS the emerald (#34d399), so a
     fill of it needs darker text, not lighter. 9.8:1. */
  --eq-on-emerald:#0b1220;

  /* ELEVATION BY LUMINOSITY, NOT BY SHADE. A soft dark shadow on a near-black
     canvas is invisible — it was doing nothing here but costing a repaint.
     What reads as depth on a dark surface is a rim of light along the top
     edge of the raised thing, so every step gains a 1px white hairline and
     the shade underneath goes deeper to compensate. The step sizes are the
     same four as the light theme, so a component never has to know. */
  --eq-skeleton-hi:#28324a;
  --eq-shadow-xs:0 0 0 1px rgba(255,255,255,.04);
  --eq-shadow:0 0 0 1px rgba(255,255,255,.045), 0 1px 2px rgba(0,0,0,.5), 0 14px 32px -18px rgba(0,0,0,.85);
  --eq-shadow-hover:0 0 0 1px rgba(255,255,255,.09), 0 2px 4px rgba(0,0,0,.55), 0 24px 48px -20px rgba(0,0,0,.95);
  --eq-shadow-lg:0 0 0 1px rgba(255,255,255,.07), 0 4px 8px -2px rgba(0,0,0,.6), 0 30px 60px -24px rgba(0,0,0,.95);

  /* Chart hues have to clear a dark canvas, so the ramp lightens. They stay
     ten mutually distinguishable hues — the data has not changed. */
  --dq-cat-1:#60a5fa; --dq-cat-2:#34d399; --dq-cat-3:#fbbf24; --dq-cat-4:#a78bfa;
  --dq-cat-5:#f472b6; --dq-cat-6:#22d3ee; --dq-cat-7:#a3e635; --dq-cat-8:#fb7185;
  --dq-cat-9:#94a3b8; --dq-cat-10:#fdba74;
  /* Readable text on each categorical fill, via lib.theme.on_color:
     whichever of white or near-black clears 4.5:1. The cat palette is
     for CHART fills, where nothing sits on top of it -- used behind
     white initials it measured 3.19-3.68:1 in light and 1.67-2.72:1
     in dark, i.e. invisible. */
  --dq-on-cat-1:#0b1220; --dq-on-cat-2:#0b1220; --dq-on-cat-3:#0b1220;
  --dq-on-cat-4:#0b1220; --dq-on-cat-5:#0b1220; --dq-on-cat-6:#0b1220;
  --dq-on-cat-7:#0b1220; --dq-on-cat-8:#0b1220; --dq-on-cat-9:#0b1220;
  --dq-seq-1:#1e3a8a; --dq-seq-2:#1d4ed8; --dq-seq-3:#3b82f6; --dq-seq-4:#60a5fa; --dq-seq-5:#93c5fd;
}

/* Bootstrap paints these white from its own stylesheet, which no token can
   reach. They are the surfaces a dark canvas MUST invert or the page is half
   lit; everything else inherits. Modal geometry is untouched — only colour —
   because background-override.css owns the stacking and it must not change. */
body.theme-dark .modal-content, body.theme-midnight .modal-content,
body.theme-dark .modal .modal-content, body.theme-midnight .modal .modal-content,
body.theme-dark .dropdown-menu, body.theme-midnight .dropdown-menu,
body.theme-dark .list-group-item, body.theme-midnight .list-group-item,
body.theme-dark .popover, body.theme-midnight .popover,
body.theme-dark .page-link, body.theme-midnight .page-link {
  background-color: var(--eq-surface) !important;
  color: var(--eq-text);
  border-color: var(--eq-line);
}
body.theme-dark .modal-header, body.theme-midnight .modal-header,
body.theme-dark .modal-footer, body.theme-midnight .modal-footer { border-color: var(--eq-line); }
body.theme-dark .modal-footer,
body.theme-midnight .modal-footer { background-color: var(--eq-surface-2); }
body.theme-dark .dropdown-item, body.theme-midnight .dropdown-item { color: var(--eq-text); }
body.theme-dark .dropdown-item:hover, body.theme-midnight .dropdown-item:hover,
body.theme-dark .dropdown-item:focus,
body.theme-midnight .dropdown-item:focus { background-color: var(--eq-surface-2); color: var(--eq-ink); }
body.theme-dark .close,
body.theme-midnight .close { color: var(--eq-ink); text-shadow: none; opacity: .8; }
body.theme-dark .table, body.theme-midnight .table { color: var(--eq-text); }
/* Kept for what sits OUTSIDE .main-content under a dark palette (the navbar
   and anything appended to <body>). Inside it, every theme is covered by the
   "Bootstrap's text utilities" block further down — this pair used to be the
   only place .text-muted met a token, which left it at Bootstrap's grey in
   the four palettes that are not dark. */
body.theme-dark .text-muted,
body.theme-midnight .text-muted { color: var(--eq-muted) !important; }
body.theme-dark .bg-white, body.theme-midnight .bg-white,
body.theme-dark .bg-light,
body.theme-midnight .bg-light { background-color: var(--eq-surface) !important; }
body.theme-dark .input-group-text,
body.theme-midnight .input-group-text { background-color: var(--eq-surface-2);
  border-color: var(--eq-field-line); color: var(--eq-muted); }
/* Three per-theme copies stood here — the skeleton gradient, the muted pill
   and the table avatar — each re-stating in dark what the light rule said in
   literals. All three now resolve --eq-surface-2 and --eq-skeleton-hi, so
   the theme block carries the VALUES and the component carries the rule,
   which is the arrangement the rest of this file already keeps to. */
/* Bootstrap's outline buttons used to need a dark-theme override here,
   because its own grey is a 2.4:1 ghost on a dark panel — and one of those
   buttons is the "follow the organization's default" control on the picker
   itself. components.css now defines them from tokens for every theme, so
   the per-theme copy is gone: a component belongs in the component layer,
   and a theme is only ever a block of token values. */

/* ---- High contrast --------------------------------------------------------
   Not "light with bolder borders": the point is to remove every soft edge a
   glare-prone screen turns into mush. Flat white, near-black text, 2px lines,
   no shadow, no translucency, and an accent dark enough to be read as text
   anywhere it appears. */
body.theme-contrast {
  --eq-ink:#000000;
  --eq-text:#14181f;
  --eq-muted:#3d4753;        /* 9.3:1 on white */
  --eq-faint:#5a6472;

  --eq-surface:#ffffff;
  --eq-surface-2:#eef1f5;
  --eq-ground:#ffffff;
  --eq-ground-2:#ffffff;
  --eq-aura:transparent;
  --eq-line:#8b95a3;
  --eq-field:#ffffff;
  --eq-field-line:#59636f;
  --eq-navbar:#ffffff;
  /* Flat, not a gradient: a gradient to navy reads as the ordinary sidebar
     on exactly the screen this theme exists for. */
  --eq-sidebar-1:#000000;
  --eq-sidebar-2:#000000;

  --eq-accent:#143b9e;
  --eq-accent-2:#1d4ed8;
  --eq-accent-deep:#0d2a73;
  --eq-accent-ink:#143b9e;   /* 9.0:1 on white */
  --eq-on-accent:#ffffff;
  --eq-accent-soft:#dde6fb;
  --eq-accent-wash:rgba(20,59,158,.07);
  --eq-accent-tint:rgba(20,59,158,.18);
  --eq-accent-edge:rgba(20,59,158,.6);
  --eq-accent-vivid:rgba(29,78,216,.95);
  --eq-accent-strong:rgba(20,59,158,.9);
  --eq-accent-shadow:rgba(20,59,158,.45);

  --eq-good:#04543a;  --eq-good-soft:#dcf2e8;
  --eq-warn:#7a3000;  --eq-warn-soft:#fbe9d6;
  --eq-bad:#8a1109;   --eq-bad-soft:#fbdedb;
  /* This theme DARKENS all three, so all three fills take white: 9.0:1,
     9.3:1 and 9.7:1. */
  --eq-on-good:#ffffff;
  --eq-on-warn:#ffffff;
  --eq-on-bad:#ffffff;
  --eq-on-muted:#ffffff;
  --eq-emerald:#04543a; --eq-emerald-dp:#03402c;
  /* The one theme that DARKENS the emerald, so this is the one theme whose
     emerald fill takes white: 9.0:1, against 2.1:1 for the dark ink. */
  --eq-on-emerald:#ffffff;

  /* The radius scale collapses but does not vanish: a 2px border needs a
     corner to turn, and a 0px corner on a 2px line reads as a rendering
     fault. The PILL keeps its 999px — a pill is a shape that carries
     meaning (a status chip is not a button) and is not one of the soft
     edges this theme exists to remove. */
  --eq-skeleton-hi:#dfe4ec;
  --eq-radius-xs:4px;
  --eq-radius-control:6px;
  --eq-radius-sm:6px;
  --eq-radius:8px;
  --eq-radius-pill:999px;
  /* No shadow at any step. The borders above carry every edge, which is the
     whole proposition of this theme; a shadow on a glare-prone screen is the
     thing that turns an edge into mush. */
  --eq-shadow-xs:none;
  --eq-shadow:none;
  --eq-shadow-hover:none;
  --eq-shadow-lg:none;
}
/* Borders do the work shadows did, so they have to be visible. */
body.theme-contrast .card,
body.theme-contrast .content-section,
body.theme-contrast .dq-card,
body.theme-contrast .dq-tile,
body.theme-contrast .modal-content { border-width: 2px; }
body.theme-contrast .form-control,
body.theme-contrast .custom-select { border-width: 2px; }
/* A hover lift on a flat theme is a shimmer, not a cue. */
body.theme-contrast .card:hover { transform: none; }
body.theme-contrast .btn:hover,
body.theme-contrast .btn:focus { transform: none; }
body.theme-contrast .btn { border-width: 2px; }
body.theme-contrast .navbar { backdrop-filter: none; -webkit-backdrop-filter: none; }

/* ---- Midnight -------------------------------------------------------------
   WHO PICKS THIS. The after-hours shift, and anyone on an OLED panel — which
   is every laptop and most tablets a district buys now. Dark's canvas is a
   navy-tinted charcoal that looks right in a lit office; on an OLED in a dark
   room it is a grey rectangle glowing at you, and every one of those pixels
   is drawing power. Here the canvas is #000, where the pixel is genuinely
   off.

   That forces one real design change rather than a darker set of numbers.
   Dark separates its surfaces by LIGHTNESS — ground < surface < raised — and
   that ladder has nowhere to go once the bottom rung is black. So Midnight
   separates them by LINE: the surfaces sit within 8% of each other and every
   panel carries a visible hairline, which is also why its --eq-line is
   lighter relative to its surfaces than dark's is. The accent is a step
   brighter than dark's for the same reason the surfaces are closer: against
   true black, dark's #60a5fa reads as the only lit thing on the screen.
   ========================================================================== */
body.theme-midnight {
  color-scheme: dark;

  --eq-ink:#f2f3f6;
  --eq-text:#c6cad2;
  --eq-muted:#9aa0ac;        /* 7.5:1 on --eq-surface */
  --eq-faint:#6a707c;

  --eq-surface:#0a0a0c;
  --eq-surface-2:#15151a;
  --eq-ground:#000000;
  --eq-ground-2:#000000;
  --eq-aura:rgba(106,168,255,.07);
  --eq-line:#26262e;
  --eq-field:#000000;
  --eq-field-line:#3a3a46;
  --eq-navbar:rgba(10,10,12,.9);
  --eq-sidebar-1:#000000;
  --eq-sidebar-2:#08080a;

  --eq-accent:#6aa8ff;
  --eq-accent-2:#9cc4ff;
  --eq-accent-deep:#4b8ef0;
  --eq-accent-ink:#8cbcff;   /* 10.1:1 on --eq-surface */
  --eq-on-accent:#05070c;    /* a light accent takes DARK text */
  --eq-accent-soft:#121b2b;
  --eq-accent-wash:rgba(106,168,255,.07);
  --eq-accent-tint:rgba(106,168,255,.2);
  --eq-accent-edge:rgba(106,168,255,.5);
  --eq-accent-vivid:rgba(106,168,255,.55);
  --eq-accent-strong:rgba(75,142,240,.4);
  --eq-accent-shadow:rgba(0,0,0,.85);

  --eq-good:#56d39d;  --eq-good-soft:#07251a;
  --eq-warn:#f2b45f;  --eq-warn-soft:#271a07;
  --eq-bad:#f58a7e;   --eq-bad-soft:#2a100c;
  /* Lightened semantics take the near-black ink, same as dark: 10.8, 11.0
     and 8.5:1. White on them is 1.9-2.4 and is what a badge looks like when
     a theme forgets this token exists. */
  --eq-on-good:#05070c;
  --eq-on-warn:#05070c;
  --eq-on-bad:#05070c;
  --eq-on-muted:#1b1611;
  --eq-emerald:#34d399; --eq-emerald-dp:#10b981;
  --eq-on-emerald:#05070c;

  --eq-skeleton-hi:#1e1e26;

  /* The rim has to work harder here than in dark: there is no lighter ground
     behind the panel to read the shadow against, so the hairline IS the
     elevation and the shade only grounds it. */
  --eq-shadow-xs:0 0 0 1px rgba(255,255,255,.05);
  --eq-shadow:0 0 0 1px rgba(255,255,255,.06), 0 1px 2px rgba(0,0,0,.9), 0 16px 34px -20px rgba(0,0,0,1);
  --eq-shadow-hover:0 0 0 1px rgba(255,255,255,.12), 0 2px 4px rgba(0,0,0,.9), 0 26px 52px -22px rgba(0,0,0,1);
  --eq-shadow-lg:0 0 0 1px rgba(255,255,255,.09), 0 32px 64px -26px rgba(0,0,0,1);

  --dq-cat-1:#6aa8ff; --dq-cat-2:#34d399; --dq-cat-3:#fbbf24; --dq-cat-4:#a78bfa;
  --dq-cat-5:#f472b6; --dq-cat-6:#22d3ee; --dq-cat-7:#a3e635; --dq-cat-8:#fb7185;
  --dq-cat-9:#94a3b8; --dq-cat-10:#fdba74;
  /* Readable text on each categorical fill, via lib.theme.on_color:
     whichever of white or near-black clears 4.5:1. The cat palette is
     for CHART fills, where nothing sits on top of it -- used behind
     white initials it measured 3.19-3.68:1 in light and 1.67-2.72:1
     in dark, i.e. invisible. */
  --dq-on-cat-1:#0b1220; --dq-on-cat-2:#0b1220; --dq-on-cat-3:#0b1220;
  --dq-on-cat-4:#0b1220; --dq-on-cat-5:#0b1220; --dq-on-cat-6:#0b1220;
  --dq-on-cat-7:#0b1220; --dq-on-cat-8:#0b1220; --dq-on-cat-9:#0b1220;
  --dq-seq-1:#1e3a8a; --dq-seq-2:#1d4ed8; --dq-seq-3:#3b82f6; --dq-seq-4:#6aa8ff; --dq-seq-5:#9cc4ff;
}

/* ---- Warm light -----------------------------------------------------------
   WHO PICKS THIS. A front desk in a lobby with real daylight in it. The
   default canvas is a cool off-white (#eef2f8) with a blue aura, which is
   the right choice under fluorescent light and the wrong one next to a
   window: a cool screen in daylight reads as glare, and "it's harsh" is what
   people say about it. A paper tone scatters less and is what every reading
   surface that predates screens looks like.

   It is a canvas change, not a brand change. The accent stays cobalt — a
   tenant's brand colour arrives on <body> and must survive a viewer picking
   this — but the semantic colours are re-mixed warm, because the stock green
   and red are cool-biased and sit on a warm field here looking slightly
   wrong rather than slightly different. The sidebar goes espresso instead of
   navy for the same reason, and white on it is 14.9:1.
   ========================================================================== */
body.theme-warm {
  --eq-ink:#1b1611;
  --eq-text:#3c352b;
  --eq-muted:#6a6052;        /* 5.9:1 on --eq-surface */
  --eq-faint:#a89a86;

  --eq-surface:#fffcf7;
  --eq-surface-2:#f5eee2;
  --eq-ground:#f6f0e6;
  --eq-ground-2:#efe7d9;
  --eq-aura:rgba(29,78,216,.055);
  --eq-line:#e7ddcb;
  --eq-field:#fffcf7;
  --eq-field-line:#d9cdb8;
  --eq-navbar:rgba(255,252,247,.88);
  --eq-sidebar-1:#241c13;
  --eq-sidebar-2:#36291b;

  --eq-accent:#1d4ed8;
  --eq-accent-2:#3b82f6;
  --eq-accent-deep:#1a3f9e;
  --eq-accent-ink:#1b47c4;   /* 7.8:1 on the warm surface */
  --eq-on-accent:#ffffff;
  --eq-accent-soft:#e6ecfb;
  --eq-accent-wash:rgba(59,130,246,.05);
  --eq-accent-tint:rgba(59,130,246,.16);
  --eq-accent-edge:rgba(59,130,246,.45);
  --eq-accent-vivid:rgba(59,130,246,.85);
  --eq-accent-strong:rgba(37,99,235,.65);
  --eq-accent-shadow:rgba(37,99,235,.5);

  --eq-good:#0a6b43;  --eq-good-soft:#e3f1e6;
  --eq-warn:#9a4708;  --eq-warn-soft:#fbedd9;
  --eq-bad:#a82619;   --eq-bad-soft:#fbe6e0;
  /* Darkened semantics on a light field, so all three fills take white. */
  --eq-on-good:#ffffff;
  --eq-on-warn:#ffffff;
  --eq-on-bad:#ffffff;
  --eq-on-muted:#ffffff;
  --eq-emerald:#10b981; --eq-emerald-dp:#0e9f6e;
  --eq-on-emerald:#1b1611;

  --eq-skeleton-hi:#fbf6ee;

  /* Shade is warm here too. A neutral grey shadow on a cream panel reads as
     dirt, which is the one failure mode of a warm palette nobody expects. */
  --eq-shadow-xs:0 1px 2px rgba(60,45,25,.07);
  --eq-shadow:0 1px 2px rgba(60,45,25,.06), 0 12px 28px -16px rgba(60,45,25,.3);
  --eq-shadow-hover:0 2px 4px rgba(60,45,25,.08), 0 22px 44px -18px rgba(60,45,25,.34);
  --eq-shadow-lg:0 4px 8px -2px rgba(60,45,25,.1), 0 28px 56px -20px rgba(60,45,25,.4);
}

/* ---- Compact --------------------------------------------------------------
   WHO PICKS THIS. A clerk on the 1366x768 front-desk PC, who wants the rows
   that are currently below the fold.

   NOT A PALETTE. This block overrides the SPACING, TYPE and GEOMETRY scales
   and not one colour, which is why it has no contrast table of its own: it
   resolves the light values for every painted pair, identically. That it can
   exist at all in twenty lines is the argument for having tokenised the kit
   in the first place — before this commit "denser" would have meant editing
   roughly two hundred declarations across three files.

   WHAT IT DELIBERATELY DOES NOT SHRINK. --eq-space-1 and -2 (4px and 8px):
   below 8px nothing is spacing any more, it is a rendering accident. The
   three smallest type steps: a 12px caption is already the floor. And
   --eq-control-min-touch stays 44px, so the `(hover: none) and
   (pointer: coarse)` block in components.css still gives a tablet its full
   tap target — a density preference set on a desk PC must not follow the
   same account onto a touchscreen and make it unusable.

   THE LIMITATION, STATED. Density is expressed as a theme because the picker
   is one radio group, so you cannot have Compact AND Dark. Making it a second
   axis is a second cookie, a second body class and a second control on
   /settings/appearance/; the mechanics are in docs/design-system.md.
   ========================================================================== */
body.theme-compact {
  --eq-space-3:.625rem;      /* 12 -> 10 */
  --eq-space-4:.75rem;       /* 16 -> 12 */
  --eq-space-5:.875rem;      /* 20 -> 14 */
  --eq-space-6:1rem;         /* 24 -> 16 */
  --eq-space-8:1.25rem;      /* 32 -> 20 */
  --eq-space-10:1.5rem;      /* 40 -> 24 */
  --eq-space-12:2rem;        /* 48 -> 32 */

  --eq-text-body:.9375rem;   /* 16 -> 15 */
  --eq-text-lg:1.0625rem;    /* 18 -> 17 */
  --eq-text-xl:1.25rem;      /* 22 -> 20 */
  --eq-text-2xl:1.5rem;      /* 28 -> 24 */
  --eq-text-3xl:clamp(1.5rem, 1.25rem + 1.1vw, 1.75rem);
  --eq-leading-normal:1.35;
  --eq-leading-relaxed:1.5;

  --eq-control-min:34px;
  --eq-radius:12px;
  --eq-radius-sm:10px;
  --eq-radius-control:8px;
}
/* The one thing a token cannot reach: the card header's 60px floor, which
   eight pages were authored against and which would otherwise make every
   card header in this theme taller than its body padding. */
body.theme-compact .card-header { min-height: 48px; }

/* ---- Bootstrap's text utilities, on the palette, in EVERY theme -----------
   Bootstrap paints these from its own stylesheet in literals no token can
   reach, with !important, so each one is a colour that ignores the theme.
   Only .text-muted had been met, and only under dark and midnight. Measured
   in the browser across 26 screens before this block:

     .text-muted   #6c757d   3.92:1 on the light canvas, 3.82 warm, 4.14 on
                             a high-contrast panel (138 uses in 45 templates)
     .text-danger  #dc3545   3.71 dark, 4.37 midnight, 4.42 warm
     .text-info    #17a2b8   3.04 light, 2.98 warm
     .breadcrumb-item.active 3.58 dark, 4.22 midnight (Bootstrap's same grey)

   and by arithmetic for the two the crawl did not happen to render:
   .text-warning is #ffc107, 1.63:1 on white — the word "Pending" on a
   visitor's profile — and .text-dark is #343a40, 1.46:1 on the dark panel.

   Each maps to the token that already carries that MEANING, so a theme is
   still only a block of values. Each of the six tokens clears 4.5:1 on
   --eq-surface, --eq-surface-2 and both stops of the canvas in every
   palette; tests/cssguard/test_text_utilities.py measures each one.

   SCOPED TO .main-content, the same way and for the same reason as
   typography.css: that element exists only in layouts/eduqueue.html, so the
   marketing pages and the bulkmode scan screens are unreachable by
   construction. :where() weighs nothing, so each rule ties Bootstrap's own
   and wins on order alone.

   ONE HOVER FORM, for the one link that carries a utility: "Sign out" is
   `a.text-danger`, and Bootstrap darkens a link utility on hover with a
   selector one element heavier (`a.text-danger:hover`, #a71d2a — 2.28:1 on
   the dark panel). No other utility is on an anchor today; one that is put
   there needs the same pair, and tests/cssguard/test_text_utilities.py
   measures the hover state of every row it knows about. */
:where(.main-content) .text-muted,
:where(.main-content) .text-secondary { color: var(--eq-muted) !important; }
:where(.main-content) .text-success { color: var(--eq-good) !important; }
:where(.main-content) .text-warning { color: var(--eq-warn) !important; }
:where(.main-content) .text-danger,
:where(.main-content) a.text-danger:hover,
:where(.main-content) a.text-danger:focus { color: var(--eq-bad) !important; }
/* Info is the accent here, as .badge-info already is in components.css. */
:where(.main-content) .text-info { color: var(--eq-accent-ink) !important; }
:where(.main-content) .text-dark { color: var(--eq-ink) !important; }
/* Where you are, and the slash before it. No !important: Bootstrap's own
   rule has none, and a page that styles its own breadcrumb should still win. */
:where(.main-content) .breadcrumb-item.active,
:where(.main-content) .breadcrumb-item + .breadcrumb-item::before { color: var(--eq-muted); }

/* ---- Page frame ----------------------------------------------------------
   Every length below is a step of the 4px scale and every size a step of the
   type scale. The page title moves 24px -> 28px and picks up the negative
   tracking the scale specifies above 22px; everything else keeps the size it
   had and merely stops being a magic number. */
.dq-page { max-width:1440px; margin:0 auto; }
.dq-head { display:flex; align-items:flex-end; justify-content:space-between; flex-wrap:wrap;
  gap:var(--eq-space-3) var(--eq-space-4); margin:0 0 var(--eq-space-5); }
.dq-title { font-size:var(--eq-text-2xl); font-weight:var(--eq-weight-bold); color:var(--dq-ink);
  margin:0; line-height:var(--eq-leading-snug); letter-spacing:var(--eq-tracking-tight); }
.dq-sub { font-size:var(--eq-text-xs); line-height:var(--eq-leading-normal); color:var(--dq-muted);
  margin:var(--eq-space-1) 0 0; }
.dq-section { font-size:var(--eq-text-lg); font-weight:var(--eq-weight-semibold); color:var(--dq-ink);
  margin:var(--eq-space-8) 0 var(--eq-space-3); line-height:var(--eq-leading-snug); }
.dq-actions { display:flex; gap:var(--eq-space-2); flex-wrap:wrap; align-items:center; }

/* ---- KPI tile: label / value / note, one optional accent rule ------------- */
.dq-tiles { display:grid; grid-template-columns:repeat(auto-fit, minmax(200px, 1fr));
  gap:var(--eq-space-4); margin:0 0 var(--eq-space-5); }
.dq-tile { background:var(--dq-surface); border:1px solid var(--dq-line); border-radius:var(--dq-radius);
  padding:var(--eq-space-4) var(--eq-space-5); box-shadow:var(--dq-shadow); min-width:0;
  text-decoration:none; color:inherit; display:block;
  transition:box-shadow var(--eq-dur-2) var(--eq-ease), transform var(--eq-dur-2) var(--eq-ease),
             border-color var(--eq-dur-1) var(--eq-ease); }
/* A tile that is a LINK lifts; a tile that is only a number does not, because
   a hover state on something unclickable is a lie. This is the only new
   motion in the dashboard parts and no bulkmode screen carries a dq- class. */
a.dq-tile:hover, a.dq-tile:focus-visible { box-shadow:var(--dq-shadow-hover); border-color:var(--dq-accent);
  transform:translateY(-2px); color:inherit; text-decoration:none; }
.dq-tile .k { font-size:var(--eq-text-caption); font-weight:var(--eq-weight-semibold);
  letter-spacing:var(--eq-tracking-wide); text-transform:uppercase; color:var(--dq-muted);
  line-height:var(--eq-leading-normal); }
.dq-tile .v { font-size:var(--eq-text-3xl); font-weight:var(--eq-weight-bold); color:var(--dq-ink);
  line-height:var(--eq-leading-tight); letter-spacing:var(--eq-tracking-tight); margin-top:var(--eq-space-1);
  font-variant-numeric:tabular-nums lining-nums; }
.dq-tile .n { font-size:var(--eq-text-xs); color:var(--dq-muted); margin-top:var(--eq-space-1);
  line-height:var(--eq-leading-normal); }
/* A tile WITH a state icon. Grid, so the icon can span the label/value/note
   rows and sit centred beside them, and so a tile without one keeps exactly
   the markup and layout it had. The icon inherits the tile's tone colour --
   it is a state indicator, so it must not be the one thing on the tile that
   stays neutral when the tile goes bad. */
.dq-tile.has-ico { display:grid; grid-template-columns:auto 1fr;
  column-gap:var(--eq-space-4); align-items:center; }
.dq-tile.has-ico .ico { grid-row:1 / span 3; display:flex; align-items:center;
  justify-content:center; width:var(--eq-space-10); height:var(--eq-space-10);
  border-radius:var(--eq-radius-sm); background:var(--eq-surface-2);
  color:var(--dq-muted); font-size:var(--eq-text-lg); }
.dq-tile.has-ico.good .ico { color:var(--eq-good); }
.dq-tile.has-ico.warn .ico { color:var(--eq-warn); }
.dq-tile.has-ico.bad  .ico { color:var(--eq-bad); }
.dq-tile.has-ico .k, .dq-tile.has-ico .v, .dq-tile.has-ico .n { grid-column:2; }
.dq-tile.accent { border-left:4px solid var(--dq-accent); }
.dq-tile.good { border-left:4px solid var(--dq-good); }  .dq-tile.good .v { color:var(--dq-good); }
.dq-tile.warn { border-left:4px solid var(--dq-warn); }  .dq-tile.warn .v { color:var(--dq-warn); }
.dq-tile.bad  { border-left:4px solid var(--dq-bad); }   .dq-tile.bad .v  { color:var(--dq-bad); }
.dq-tile .delta { font-size:var(--eq-text-xs); font-weight:var(--eq-weight-semibold); }
.dq-tile .delta.up { color:var(--dq-good); } .dq-tile .delta.down { color:var(--dq-bad); }

/* ---- Card with a white header ------------------------------------------- */
.dq-card { background:var(--dq-surface); border:1px solid var(--dq-line); border-radius:var(--dq-radius);
  box-shadow:var(--dq-shadow); display:flex; flex-direction:column; min-width:0; }
.dq-card-head { display:flex; align-items:center; justify-content:space-between; gap:var(--eq-space-3);
  padding:var(--eq-space-3) var(--eq-space-5); border-bottom:1px solid var(--dq-line); }
.dq-card-head h3, .dq-card-title { font-size:var(--eq-text-base); font-weight:var(--eq-weight-semibold);
  color:var(--dq-ink); margin:0; line-height:var(--eq-leading-snug); }
.dq-card-hint { font-size:var(--eq-text-xs); color:var(--dq-muted); margin:var(--eq-space-1) 0 0; }
.dq-card-body { padding:var(--eq-space-4) var(--eq-space-5); flex:1; min-height:0; }
.dq-card-foot { display:flex; justify-content:space-between; gap:var(--eq-space-3);
  padding:var(--eq-space-2) var(--eq-space-5); border-top:1px solid var(--dq-line);
  font-size:var(--eq-text-caption); color:var(--dq-muted); }
.dq-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(min(420px, 100%), 1fr));
  gap:var(--eq-space-5); }
.dq-grid > .wide { grid-column:1 / -1; }
.dq-chart { position:relative; height:260px; }            /* the ONLY place a chart height is set */
.dq-chart.tall { height:340px; }
.dq-chart.short { height:180px; }
/* Was load-bearing: it was the only thing in the app undoing a global
   `canvas { display: none }` in main.css, which is now gone. Kept as plain
   layout — a canvas is a replaced inline element, and inline leaves a
   descender gap under it inside the chart box. */
.dq-chart canvas { display:block; }

/* Icon-only buttons in card headers: always visible, real focus ring. */
.dq-iconbtn { width:2rem; height:2rem; display:inline-flex; align-items:center; justify-content:center;
  border:1px solid var(--dq-line); border-radius:var(--eq-radius-xs); background:var(--dq-surface);
  color:var(--dq-muted); cursor:pointer;
  transition:color var(--eq-dur-1) var(--eq-ease), border-color var(--eq-dur-1) var(--eq-ease),
             box-shadow var(--eq-dur-1) var(--eq-ease); }
.dq-iconbtn:hover { color:var(--dq-accent-ink); border-color:var(--dq-accent); }
/* An outline, not only a colour change: this control is 32px square and its
   hover state and its focus state have to be told apart without a mouse. */
.dq-iconbtn:focus-visible { color:var(--dq-accent-ink); border-color:var(--dq-accent);
  outline:2px solid var(--dq-accent-ink); outline-offset:2px; box-shadow:var(--eq-ring); }

/* ---- Status pill: text + colour, never colour alone ----------------------- */
.dq-pill { display:inline-flex; align-items:center; gap:var(--eq-space-1);
  font-size:var(--eq-text-caption); font-weight:var(--eq-weight-semibold);
  padding:var(--eq-space-1) var(--eq-space-2); border-radius:var(--eq-radius-pill);
  white-space:nowrap; line-height:var(--eq-leading-normal);
  background:var(--dq-accent-soft); color:var(--dq-accent-ink); }
.dq-pill.good { background:var(--dq-good-soft); color:var(--dq-good); }
.dq-pill.warn { background:var(--dq-warn-soft); color:var(--dq-warn); }
.dq-pill.bad  { background:var(--dq-bad-soft);  color:var(--dq-bad); }
.dq-pill.muted { background:var(--eq-surface-2); color:var(--dq-muted); }
.dq-pill.live::before { content:""; width:.45rem; height:.45rem; border-radius:50%; background:currentColor; }

/* ---- Empty / loading states (use the empty_state macro) ------------------- */
.dq-empty { display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center;
  gap:var(--eq-space-1); padding:var(--eq-space-8) var(--eq-space-4); color:var(--dq-muted);
  min-height:160px; margin:auto; }
.dq-empty i { font-size:var(--eq-text-xl); color:var(--dq-faint); margin-bottom:var(--eq-space-1); }
.dq-empty .t { font-size:var(--eq-text-base); font-weight:var(--eq-weight-semibold); color:var(--dq-text); }
.dq-empty .d { font-size:var(--eq-text-xs); max-width:34ch; line-height:var(--eq-leading-normal); }
.dq-empty a.btn { margin-top:var(--eq-space-2); }
.dq-skeleton { display:block; height:1em; border-radius:var(--eq-radius-xs);
  background:linear-gradient(90deg, var(--eq-surface-2) 25%, var(--eq-skeleton-hi) 50%, var(--eq-surface-2) 75%);
  background-size:200% 100%; animation:dq-shimmer 1.4s linear infinite; }
@keyframes dq-shimmer { from { background-position:200% 0; } to { background-position:-200% 0; } }

/* ---- Tables -------------------------------------------------------------- */
.dq-table { width:100%; border-collapse:separate; border-spacing:0; font-size:var(--eq-text-sm); }
.dq-table th { position:sticky; top:0; z-index:1; background:var(--dq-surface);
  font-size:var(--eq-text-caption); letter-spacing:var(--eq-tracking-wide); text-transform:uppercase;
  color:var(--dq-muted); font-weight:var(--eq-weight-semibold);
  text-align:left; padding:var(--eq-space-2) var(--eq-space-3); border-bottom:1px solid var(--dq-line); }
.dq-table td { padding:var(--eq-space-3); border-bottom:1px solid var(--dq-line); vertical-align:middle;
  color:var(--dq-text); line-height:var(--eq-leading-normal); }
.dq-table tr:last-child td { border-bottom:0; }
/* A row that lights up under the pointer is how a person keeps their place
   across twelve columns. Colour only — a row must not move, or the cell
   being read slides out from under the eye. */
.dq-table tbody tr { transition:background-color var(--eq-dur-1) var(--eq-ease); }
.dq-table tbody tr:hover { background-color:var(--eq-accent-wash); }
.dq-table .num, .dq-table th.num { text-align:right; font-variant-numeric:tabular-nums lining-nums; }
.dq-table .strong { font-weight:var(--eq-weight-semibold); color:var(--dq-ink); }
.dq-table .muted { color:var(--dq-muted); font-size:var(--eq-text-xs); }
.dq-table .truncate { max-width:22ch; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.dq-table .avatar { width:36px; height:36px; border-radius:50%; object-fit:cover; background:var(--eq-surface-2); }
.dq-table .avatar.initial { display:inline-flex; align-items:center; justify-content:center;
  font-weight:var(--eq-weight-bold); color:var(--dq-muted); }
.dq-scroll { overflow-x:auto; -webkit-overflow-scrolling:touch; }
/* DataTables draws sort glyphs on every th, sortable or not. */
.dq-table th.sorting_disabled::before, .dq-table th.sorting_disabled::after { display:none; }
.dq-table th.sorting { cursor:pointer; }
/* DataTables toolbar without the negative-gutter .row hack */
.dq-dt-top { display:flex; flex-wrap:wrap; align-items:center; gap:var(--eq-space-2) var(--eq-space-3);
  margin-bottom:var(--eq-space-3); }
.dq-dt-top .dataTables_filter { margin-left:auto; }
.dq-dt-bottom { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between;
  gap:var(--eq-space-2); margin-top:var(--eq-space-3); }

/* ---- Report result summary strip ------------------------------------------ */
.dq-summary { display:flex; flex-wrap:wrap; align-items:center; gap:var(--eq-space-2) var(--eq-space-4);
  font-size:var(--eq-text-sm); color:var(--dq-text);
  padding:var(--eq-space-2) var(--eq-space-3); margin:0 0 var(--eq-space-3); background:var(--dq-ground);
  border:1px solid var(--dq-line); border-radius:var(--eq-radius-sm); }
.dq-summary b { color:var(--dq-ink); font-variant-numeric:tabular-nums lining-nums; }
.dq-summary .sep { color:var(--dq-faint); }

/* ---- Dual list boxes (bootstrap-duallistbox) -------------------------------
   The plugin builds its own markup: two bare <select multiple> with NO class
   (browser-default grey box, black 16px text), 11px "Showing all N" labels and
   move buttons glued to the top of the list. Beside the kit's inputs that read
   as broken CSS (the student-events filter, 2026-09-18). Dressed here once for
   every page that uses the widget; the report shells add nothing on top. */
.bootstrap-duallistbox-container .box1,
.bootstrap-duallistbox-container .box2 { display:flex; flex-direction:column; }
.bootstrap-duallistbox-container .info { display:block; margin:0 0 var(--eq-space-1);
  font-size:var(--eq-text-caption); font-weight:var(--eq-weight-semibold);
  letter-spacing:var(--eq-tracking-wide); text-transform:uppercase; color:var(--dq-muted); }
.bootstrap-duallistbox-container .form-control.filter { height:auto; margin:0 0 var(--eq-space-2);
  padding:var(--eq-space-2) var(--eq-space-3); font-size:var(--eq-text-sm);
  border-radius:var(--eq-radius-control); }
.bootstrap-duallistbox-container .btn-group.buttons { display:flex; gap:var(--eq-space-1); width:100%;
  margin:0 0 var(--eq-space-2); }
.bootstrap-duallistbox-container .btn-group .btn { flex:1 1 auto; height:auto;
  padding:var(--eq-space-1) var(--eq-space-2); font-size:var(--eq-text-xs);
  font-weight:var(--eq-weight-semibold); line-height:var(--eq-leading-snug);
  border-radius:var(--eq-radius-control); color:var(--dq-accent-ink); border-color:var(--dq-line);
  background:var(--dq-surface); box-shadow:none; }
.bootstrap-duallistbox-container .btn-group .btn:hover,
.bootstrap-duallistbox-container .btn-group .btn:focus { color:var(--eq-on-accent); background:var(--dq-accent); border-color:var(--dq-accent); }
.bootstrap-duallistbox-container .btn-group .btn:disabled { opacity:.45; }
.bootstrap-duallistbox-container select { width:100%; min-height:200px; padding:var(--eq-space-1) 0;
  font-size:var(--eq-text-sm); line-height:var(--eq-leading-normal);
  color:var(--dq-text); background:var(--dq-surface); border:1px solid var(--dq-line);
  border-radius:var(--eq-radius-control); outline:0; }
.bootstrap-duallistbox-container select:focus { border-color:var(--dq-accent); box-shadow:var(--eq-ring); }
/* The plugin's <select> carries no class, so it is not a .form-control and
   the `outline:0` above was never answered: the list a report is built from
   showed keyboard focus as the halo alone, 1.14:1 measured. */
.bootstrap-duallistbox-container select:focus-visible { outline:2px solid var(--dq-accent-ink); outline-offset:1px; }
.bootstrap-duallistbox-container select option { padding:var(--eq-space-1) var(--eq-space-3); }
.bootstrap-duallistbox-container select option:checked { background:var(--dq-accent-soft); color:var(--dq-ink); }
.bootstrap-duallistbox-container .box2 select:empty,
.bootstrap-duallistbox-container select:not(:has(option)) { background:var(--dq-ground); }
.bootstrap-duallistbox-container .clear1,
.bootstrap-duallistbox-container .clear2 { margin-top:var(--eq-space-1); font-size:var(--eq-text-caption);
  color:var(--dq-muted); padding:0; border:0; background:none; }

/* ---- Motion ----------------------------------------------------------------
   Everything that moves in this file, switched off in one place. A viewer who
   has asked for reduced motion gets the end state immediately, never a
   half-speed version of the same thing — and the loading skeleton keeps its
   fill so it still reads as "not here yet". */
@media (prefers-reduced-motion: reduce) {
  .dq-skeleton { animation:none; }
  .dq-pill.live::before { animation:none; }
  .dq-tile, .dq-iconbtn, .dq-table tbody tr { transition:none; }
  a.dq-tile:hover, a.dq-tile:focus-visible { transform:none; }
}
/* A finger cannot hover, so a lift on tap is a flicker after the fact. */
@media (hover: none) and (pointer: coarse) {
  a.dq-tile:hover { transform:none; box-shadow:var(--dq-shadow); }
}

/* ---- Print: every report page, once --------------------------------------
   Before this block Ctrl+P printed the 220px sidebar over page 1 of every
   report. Hide chrome and controls, keep table headers on every page, never
   split a row. Pages with their own @page rules (the WeasyPrint PDFs) don't
   go through this stylesheet. */
@media print {
  /* PAPER IS WHITE. A dark theme is a screen preference, and printing one
     would put near-white body text and a lightened chart ramp onto white
     paper — an empty-looking page, and a district deliverable. The palette
     reverts to the light values for print, for every theme, before any of
     the layout rules below run. The selector carries both the class and the
     element so it outranks `body.theme-dark`, which is what it has to undo. */
  body.theme-dark, body.theme-contrast, body.theme-midnight, body.theme-warm,
  body.theme-compact, :root {
    --eq-ink:#0b1220; --eq-text:#334155; --eq-muted:#45515f; --eq-faint:#6b7889;
    --eq-surface:#ffffff; --eq-surface-2:#f4f7fc; --eq-line:#c9d2e0;
    --eq-ground:#ffffff; --eq-ground-2:#ffffff; --eq-aura:transparent;
    --eq-accent:#1d4ed8; --eq-accent-2:#3b82f6; --eq-accent-ink:#1a3f9e;
    --eq-accent-soft:#e8effc; --eq-on-accent:#ffffff;
    --eq-good:#067647; --eq-warn:#b54708; --eq-bad:#b42318;
    --eq-good-soft:#e6f4ec; --eq-warn-soft:#fef1e2; --eq-bad-soft:#fdecea;
    /* Paper takes the light palette, so the semantic fills darken and their
       foreground has to go back to white WITH them — a dark theme's
       --eq-on-warn printed on the light warn is 3.45:1. A fill and its
       foreground are one decision, so the emerald is reset here too rather
       than left on whatever the screen theme chose: high contrast darkens
       it, and the dark ink on that is 2.08:1. */
    --eq-on-good:#ffffff; --eq-on-warn:#ffffff; --eq-on-bad:#ffffff;
  --eq-on-muted:#ffffff;
    --eq-emerald:#10b981; --eq-emerald-dp:#0e9f6e; --eq-on-emerald:#0b1220;
    --dq-cat-1:#1d4ed8; --dq-cat-2:#0e9f6e; --dq-cat-3:#d97706; --dq-cat-4:#1d4ed8;
    --dq-cat-5:#db2777; --dq-cat-6:#0891b2; --dq-cat-7:#65a30d; --dq-cat-8:#9f1239;
    --dq-cat-9:#4b5563; --dq-cat-10:#b45309;
    /* Readable text on each categorical fill, via lib.theme.on_color:
       whichever of white or near-black clears 4.5:1. The cat palette is
       for CHART fills, where nothing sits on top of it -- used behind
       white initials it measured 3.19-3.68:1 in light and 1.67-2.72:1
       in dark, i.e. invisible. */
    --dq-on-cat-1:#ffffff; --dq-on-cat-2:#0b1220; --dq-on-cat-3:#0b1220;
    --dq-on-cat-4:#ffffff; --dq-on-cat-5:#ffffff; --dq-on-cat-6:#0b1220;
    --dq-on-cat-7:#0b1220; --dq-on-cat-8:#ffffff; --dq-on-cat-9:#ffffff;
    --eq-shadow:none; --eq-shadow-hover:none;
  }
  body.theme-dark, body.theme-midnight { color:#334155; }
  /* Compact's spacing goes back to the light scale on paper as well: a
     district report printed at 10px gutters is not a saving, it is a reprint.
     The palette block above resets colour; these are the two scales it does
     not name. */
  body.theme-compact {
    --eq-space-3:.75rem; --eq-space-4:1rem; --eq-space-5:1.25rem;
    --eq-space-6:1.5rem; --eq-space-8:2rem; --eq-space-10:2.5rem;
    --eq-space-12:3rem;
    --eq-leading-normal:1.45; --eq-leading-relaxed:1.6;
  }
  .sidebar, .sidebar-nav, .scroll-to-top, .navbar, .breadcrumb, .dt-buttons, .dataTables_filter,
  .dataTables_length, .dataTables_paginate, .dataTables_info, .dq-actions, .dq-noprint, form.dq-filters,
  .building-selector-btn, #sidebarToggle,
  .modal-backdrop { display:none !important; }   /* a dialog open at Ctrl+P printed a sheet of grey */
  .main-content { margin-left:0 !important; }
  .main-content .container-fluid, .container-fluid { padding:0 !important; margin:0 !important; box-shadow:none !important;
    overflow:visible !important; }
  body, body.fixed-nav, body.sticky-footer { background:#fff !important; }
  /* --eq-line is reset to #c9d2e0 by the palette block above, which is the
     colour this rule used to spell out as #cbd5e1 — the last hex literal in
     this file outside the palette itself. */
  .dq-card, .dq-tile, .card { box-shadow:none !important; border-color:var(--eq-line) !important;
    break-inside:avoid; }
  /* A scroll box prints only the slice that happens to be visible, and
     .container-fluid is overflow-x:clip, which is definitionally
     non-scrollable -- so a report table wider than the screen lost its right
     half on paper with no warning. Both have to open up for print, and the
     table has to drop whatever min-width was forcing the scroll. */
  .dq-scroll { overflow:visible !important; }
  .dq-scroll table { min-width:0 !important; }   /* descendant, not child: DataTables inserts a wrapper div */
  /* position:static on th only missed every sticky FIRST COLUMN, which is a
     td -- the daily-report matrix pinned its name column straight through a
     print job. */
  .dq-table th, .dq-table td { position:static !important; }
  thead { display:table-header-group; }
  tr { break-inside:avoid; page-break-inside:avoid; }
  a[href]::after { content:"" !important; }
}

/* ---- The appearance picker's miniatures -----------------------------------
   /settings/appearance/ draws a small picture of each theme, and a picture of
   a theme is the one thing that CANNOT be var()-driven: the card for Midnight
   has to be black while the page around it is whatever the viewer is already
   using. So these are literals, and they are literals of the same values
   declared above — the swatch is data, not styling.

   The three original swatches still live in that template's own <style>; it
   renders after this file and wins for those, which is harmless because the
   values agree. New themes are defined here because the swatch belongs beside
   the theme, and because the template is one file five screens' worth of work
   was passing through. Moving the other three here is a one-paragraph job for
   whoever next opens that page. */
.ap-swatch.sw-midnight .bar { background:#000000; }
.ap-swatch.sw-midnight .pane { background:#000000; }
.ap-swatch.sw-midnight .tile { background:#0a0a0c; border:1px solid #26262e; }
.ap-swatch.sw-midnight .line { background:#3a3a46; }
.ap-swatch.sw-midnight .pill { background:#6aa8ff; }

.ap-swatch.sw-warm .bar { background:linear-gradient(185deg,#241c13,#36291b); }
.ap-swatch.sw-warm .pane { background:#f6f0e6; }
.ap-swatch.sw-warm .tile { background:#fffcf7; border:1px solid #e7ddcb; }
.ap-swatch.sw-warm .line { background:#d9cdb8; }
.ap-swatch.sw-warm .pill { background:#1d4ed8; }

/* Compact shares the light palette, so its miniature shares the colours and
   shows the difference that IS there: more rows in the same height. */
.ap-swatch.sw-compact .bar { background:linear-gradient(185deg,#0a1428,#0f2149); }
.ap-swatch.sw-compact .pane { background:#eef2f8; gap:var(--eq-space-1); padding:var(--eq-space-2); }
.ap-swatch.sw-compact .tile { background:#ffffff; border:1px solid #e7ebf3; height:12px; }
.ap-swatch.sw-compact .line { background:#c9d2e0; height:5px; }
.ap-swatch.sw-compact .pill { background:#1d4ed8; height:9px; }
