/*
 * ============================================================
 * ADVISOR PORTAL — Global Design System (Taibah University)
 * ============================================================
 * Inter + DM Serif Display + JetBrains Mono + Noto Kufi Arabic
 * Teal (#0A8E6E) brand with glassmorphism design language
 * ============================================================
 */

/* ── FONTS — Taibah University brand ─────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=DM+Serif+Display:ital@0;1&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* Arabic (loads only when page lang=ar) */
@import url('https://fonts.googleapis.com/css2?family=Noto+Kufi+Arabic:wght@400;600;700&display=swap');

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  /* ── backgrounds — a warm paper ground ──────────────────────
     These were a cool blue-grey (#eef1f7 / #f3f6fa). That ground only works
     while every panel is a white card floating on it: the card supplies the
     reading surface and the grey is just the gap between cards. Once the cards
     retire and the page itself becomes the sheet (see "Sheet sections"), the
     ground IS the reading surface, so it has to be paper rather than gap.

     Warm, and lighter than the grey it replaces, so this RAISES contrast rather
     than spending it: measured against every ink token the worst case goes from
     4.80:1 (--sev-warning on the old --bg) to 4.93:1 here. --surface lands at
     4.72 and --surface-2 at 4.56, the latter matching the 4.57 the old
     --surface-2 measured, so no token that passed before fails now.

     --card stays white: a genuinely raised surface (a modal, a popover, a drag
     ghost) still needs to read as lifted off the sheet. */
  --bg:             #f6f4ee;
  --card:           #ffffff;
  --surface:        #f2efe7;

  /* ink — WCAG AA compliant text hierarchy */
  --ink:            #111144;
  --ink-2:          #1e1e4a;
  --t0:             #111144;
  --t1:             #1e1e4a;
  --t2:             #3e3e62;
  --t3:             #5c5c7a;
  /* --t4 was #7a7a92: 4.18:1 on --card and 3.69:1 on --bg, below the 4.5:1 its
     uses (labels, captions, inactive tabs) need. #66667f clears every surface it
     sits on: 5.57 card, 4.92 bg, 5.14 surface, 4.69 surface-2. */
  --t4:             #66667f;
  --t5:             #a8a8be;
  --muted:          #5c5c7a;
  --muted-light:    #66667f;

  /* borders — warmed to match the paper ground above; same strength as before
     (--line measures 1.29:1 on the sheet, exactly what #dde3ed measured on a
     white card), so nothing that was readable has become fainter. */
  --line:           #ded8ca;
  --line-strong:    #c4bca7;
  --line-h:         rgba(17,17,68,0.10);
  --line-a:         rgba(17,17,68,0.15);

  /* ── rules — structure, where a card used to do the structuring ──────
     A separate pair from --line on purpose. --line is an EDGE: it draws round
     the thing it belongs to (a table cell, an input, a chip) and is allowed to
     be faint because the thing it edges is visible anyway. A RULE is the only
     thing dividing two regions of one sheet, so it has to survive a theme where
     --line does not: dark mode's --line is rgba(255,255,255,0.06), which is
     invisible as a divider on a near-black page. Dark overrides these to 0.12
     and 0.24; light keeps them identical to --line / --line-strong.

     Like --line, a rule is a separator rather than a control boundary, so WCAG
     1.4.11's 3:1 is not its bar (--control-edge carries that, unchanged). */
  --rule:           #ded8ca;
  --rule-strong:    #c4bca7;

  /* Taibah University brand — primary teal */
  --brand:          #0A8E6E;
  --brand-dark:     #05664b; /* = --text-brand: a text colour only */
  --brand-soft:     rgba(10,142,110,0.06);
  --brand-glow:     rgba(10, 142, 110, 0.18);

  /* Extended Taibah palette */
  --teal:           #0A8E6E;
  --teal-bright:    #0CA87E;
  --teal-pale:      #2EC9A0;
  --teal-deep:      #067858;
  --teal-dim:       rgba(10,142,110,0.06);
  --teal-border:    rgba(10,142,110,0.16);

  --royal:          #4056E3;
  --royal-bright:   #5068F0;
  --royal-dim:      rgba(64,86,227,0.06);
  --royal-border:   rgba(64,86,227,0.16);

  --sky:            #00AEDA;
  --sky-bright:     #10C0EC;
  --sky-dim:        rgba(0,174,218,0.06);

  --rose:           #e8849e;
  --rose-dim:       rgba(232,132,158,0.08);

  --amber:          #d97706;
  --amber-dim:      rgba(245,158,11,0.08);

  --navy:           #111144;

  /* sidebar accent */
  --sidebar-bar:    #0CA87E;
  --sidebar-glow:   rgba(10, 142, 110, 0.28);

  /* semantic */
  --success:        #0A8E6E;
  --danger:         #C03030;
  --warning:        #9A6A08;

  /* ── text and fills that must PASS, not just look right ─────
     --teal (#0A8E6E) is a brand colour, not a text colour: as text on white it is
     4.11:1 and as a fill under white text the same 4.11:1, both under the 4.5:1
     that 12–14px text needs. These tokens are the passing pair for each job.
     --text-brand: teal TEXT (links, active labels, codes) — 6.98:1 on --card,
     and ≥ 4.9:1 on a teal wash of up to 16% over every surface (chips, active
     rows: #067858 was 4.31:1 on --teal-dim over --surface-2).
     --btn-primary-*: the one filled primary — white on #067858 is 5.48:1, and the
     hover and pressed states go DARKER (6.98:1) instead of brighter, so they
     never fail mid-hover. */
  --text-brand:       #05664b;
  --btn-primary-bg:   #067858;
  --btn-primary-ink:  #ffffff;
  --btn-primary-hover:#05664b;

  /* ── severity — one vocabulary for every status the product shows ──────
     critical blocks something (publish, a seat); warning lowers quality but does
     not block; info is context; ok meets its target and is NEVER used for a
     neutral count. Each passes 4.5:1 as text on --card and --bg (critical 6.57 /
     5.81, warning 5.43 / 4.80, info 6.41 / 5.67, ok 5.48 / 4.84). The -bg tints
     are for row/chip backgrounds under --t1 text. */
  --sev-critical:     #b42318;
  --sev-critical-bg:  rgba(180,35,24,0.08);
  --sev-warning:      #b54708;
  --sev-warning-bg:   rgba(181,71,8,0.09);
  --sev-info:         #3b4fd6;
  --sev-info-bg:      rgba(59,79,214,0.08);
  --sev-ok:           #067858;
  --sev-ok-bg:        rgba(6,120,88,0.08);
  /* Warning TEXT on a tinted chip or a neutral control fill: --sev-warning is
     4.28:1 there (it is measured for the card and the page). #9a3c06 is 5.8:1 on
     the neutral fill and 6.3:1 on the page. */
  --sev-warning-ink:  #9a3c06;
  /* Sky as TEXT: --sky (#00AEDA) is a fill colour, 2.45:1 as pill text. */
  --text-sky:         #00698f;

  /* ── prerequisite / plan-map graph (static/js/prereq-graph.js draws the SVG) ──
     The node fills and inks were hard-coded light-theme constants, so in dark mode
     the course codes measured about 1.6:1 (passed, in progress) and 1.2:1 (open).
     Each state is now a fill / edge / ink / legend-dot set; the light values are the
     old constants unchanged (5.6:1 and better), the dark set is below. */
  --pg-node-fill:     rgba(255,255,255,0.65);
  --pg-node-edge:     rgba(17,17,68,0.08);
  --pg-passed-fill:   rgba(10,142,110,0.24);
  --pg-passed-edge:   rgba(10,142,110,0.72);
  --pg-passed-ink:    #075f49;
  --pg-passed-dot:    rgba(10,142,110,0.55);
  --pg-studying-fill: rgba(64,86,227,0.20);
  --pg-studying-edge: rgba(64,86,227,0.68);
  --pg-studying-ink:  #3043bd;
  --pg-studying-dot:  rgba(64,86,227,0.50);
  --pg-open-fill:     rgba(255,255,255,0.92);
  --pg-open-edge:     #0a8e6e;
  --pg-locked-fill:   rgba(120,124,150,0.09);
  --pg-locked-edge:   rgba(120,124,150,0.42);
  --pg-locked-ink:    #596173;
  --pg-locked-dot:    rgba(120,124,150,0.45);
  --pg-found-fill:    rgba(10,142,110,0.08);
  --pg-found-edge:    rgba(10,142,110,0.22);
  --pg-found-ink:     #087a5e;
  --pg-term-fill:     rgba(64,86,227,0.08);
  --pg-term-edge:     rgba(64,86,227,0.22);
  --pg-term-ink:      #3548c9;
  --pg-gate-fill:     rgba(180,83,9,0.07);
  --pg-gate-edge:     rgba(180,83,9,0.30);
  --pg-warn:          #b45309;

  /* ── the neutral button ─────────────────────────────────────
     Its own tokens, because it is the one control that has to look right on FOUR
     different backdrops — a card, a `.va-bubble`, a modal footer and a glass
     toolbar — and no opaque palette colour can do that. `.va-bubble` is
     `var(--surface)`, so a neutral button painted `var(--surface)` is 1.00:1
     against the very screen it was added for.

     TRANSLUCENT solves it: a tint composites over whatever is behind it, so the
     contrast is a property of the tint rather than of the backdrop. Measured
     across all four light surfaces the fill lands at 1.15:1 every time and its
     text at 7.8–8.8:1.

     The border alpha is COMPUTED, not chosen, and deliberately NOT the minimum
     that passes. 0.47 is the smallest alpha clearing 3:1 on the hardest of the
     four backdrops; sitting on the threshold is fragile against alpha rounding,
     device-pixel anti-aliasing and any future token change. 0.52 measures 3.42 to
     3.53 across the four, so a 3.25 assertion has real headroom.

     Either way the boundary meets WCAG 1.4.11 for non-text UI without `--line`
     moving, which would have taken every card, table and input edge in the app
     with it. That trade was only forced by the rejected base-rule design. */
  --btn-neutral-bg:     rgba(17,17,68,0.07);
  --btn-neutral-border: rgba(17,17,68,0.52);
  --btn-neutral-text:   var(--t2);

  /* A genuinely SECOND surface. Aliasing it to `--surface` collapsed it onto the
     first, which is how `.sa-escalate.is-prominent` — the panel whose whole job is
     to stand out when the adviser abstains — ended up 1.00:1 inside a bubble that
     is already `--surface`. */
  --surface-2:      #efebe3;

  /* The edge of a form field, an outline button and the sidebar controls. The old
     edge was rgba(17,17,68,.08-.10) and the field was drawn by an inset shadow
     alone: 1.2:1 against the 3:1 a control boundary needs (WCAG 1.4.11). This
     value measures 3.4-3.9:1 on the card, the page and a glass card; it is the
     same strength as the workspace toolbar ring (--btn-neutral-border). */
  --control-edge:   rgba(17,17,68,0.52);

  /* shape */
  --radius:         10px;
  --radius-sm:      7px;
  --radius-lg:      14px;

  /* typography — Taibah brand fonts */
  --font-body:      'Inter', 'Noto Kufi Arabic', system-ui, sans-serif;
  /* Neither JetBrains Mono nor DM Serif Display has Arabic glyphs; naming Noto
     Kufi Arabic next means Arabic text set in these two faces is drawn in the
     page's own Arabic face rather than a system monospace/serif fallback. */
  --font-mono:      'JetBrains Mono', 'Noto Kufi Arabic', 'Cascadia Code', ui-monospace, monospace;
  --font-serif:     'DM Serif Display', 'Noto Kufi Arabic', serif;

  /* shadows */
  --shadow-card:    0 1px 3px rgba(13,21,38,.06), 0 8px 24px rgba(13,21,38,.07);
  --shadow-lift:    0 4px 12px rgba(13,21,38,.10), 0 16px 40px rgba(13,21,38,.09);
  --shadow-input:   0 1px 2px rgba(13,21,38,.04);
  --shadow-sm:      0 1px 3px rgba(13,21,38,.08);
  /* ── the neumorphic shadows, retired ──────────────────────────────
     These drew the soft raised/dished look on every button, input, capsule and
     pager — 73 rules take one of the three. Two problems on the sheet: the dark
     half of each pair is rgba(163,177,198,…), a COOL blue-grey, which on a warm
     ground reads as grime rather than shadow; and a blurred 16px halo beside a
     crisp 1px rule is two design languages touching. A control is an outlined
     rectangle now, and its edge is --control-edge (3.4-3.9:1, so it clears the
     3:1 WCAG 1.4.11 needs for a control boundary) rather than a shadow.

     They are kept as TOKENS, set to a transparent layer, instead of being
     deleted. `none` is not a shadow layer: a rule like
         box-shadow: inset 0 0 0 1px var(--teal), var(--shadow-neu-inset),
                     0 0 0 2px var(--teal);
     is invalid the moment one layer is `none`, and the browser drops the WHOLE
     declaration — which in that example is the focus ring on a dialog input.
     A zero-size transparent layer composes correctly and paints nothing. */
  --shadow-neu:     0 0 0 0 rgba(0,0,0,0);
  --shadow-neu-sm:  0 0 0 0 rgba(0,0,0,0);
  --shadow-neu-inset: inset 0 0 0 0 rgba(0,0,0,0);

  /* borders — reusable subtle border */
  --border-subtle:  1px solid rgba(17,17,68,0.05);
  --border-mid:     1px solid rgba(17,17,68,0.08);

  /* glassmorphism */
  --glass-bg:       rgba(255,255,255,0.55);
  --glass-bg-data:  rgba(255,255,255,0.72);   /* tables, data cards — stronger for readability */
  --glass-bg-header:rgba(255,255,255,0.82);   /* table headers — strongest */
  --glass-blur:     blur(20px);

  /* focus (teal ring for accessibility) */
  --focus-ring:     0 0 0 2px #fff, 0 0 0 4px var(--teal);

  /* transitions */
  --ease:           cubic-bezier(0.16,1,0.3,1);
  --spring:         cubic-bezier(0.34,1.56,0.64,1);

  /* motion durations — standardise the 0.12 / 0.2 / 0.3s cluster */
  --dur-fast:       0.12s;
  --dur:            0.2s;
  --dur-slow:       0.3s;

  /* radius — fills gaps; --radius-md was referenced (L6113/6180) but undefined */
  --radius-xs:      4px;
  --radius-md:      12px;
  --radius-pill:    999px;
  --radius-full:    50%;

  /* glass blur tiers — companions to --glass-blur (blur(20px)) */
  --glass-blur-sm:  blur(12px);
  --glass-blur-lg:  blur(24px);

  /* spacing scale — derived from real px usage (≈8px base) */
  --space-0:        0;
  --space-1:        2px;
  --space-2:        4px;
  --space-3:        6px;
  --space-4:        8px;
  --space-5:        10px;
  --space-6:        12px;
  --space-7:        14px;
  --space-8:        16px;
  --space-10:       20px;
  --space-12:       24px;
  --space-16:       32px;

  /* type scale — THE canonical sizes. One scale: `.fs-*` utilities and the legacy
     `--fs-sm` are aliases of it, not a second system.
     The root size is fluid (html: 14px at 375px wide → 16px at ≥1440px), so a
     floor written in rem alone renders under itself on smaller screens: the two
     smallest steps carry a px floor. 11px is the least any text may be (micro
     labels: chips, kickers, counts); 12px is the least DATA may be. */
  --fs-sm:          var(--text-micro);   /* legacy alias: .pill */
  /* The floor for the micro-labels that used to sit at 8-10.9px (badges, kickers,
     counts, matrix cells). 11px in Latin; 12px in Arabic, set below under
     html[dir="rtl"], because Arabic at 11px is not legible. */
  --text-micro:     max(11px, 0.6875rem);
  /* The name the TYPOGRAPHY SCALE block below documents. It was a second copy
     of the literal, so the Arabic floor -- which only ever redefined
     --text-micro -- missed all 18 rules that used this name, and they stayed
     at 11px in Arabic. An alias cannot drift out of step again. */
  --text-2xs:       var(--text-micro);
  --text-xs:        max(12px, 0.75rem);
  /* Every step carries a px floor, not only the two smallest. The root is 14px
     on a phone, so a bare rem step rendered UNDER its own design size there:
     .875rem body copy was 12.25px, and the raw .72-.78rem literals this scale
     replaced measured 9.8-10.9px on a 390px screen (premium review, 2026-11).
     A floor keeps the desktop size (the rem term wins at >=1440px) and stops
     the phone from shrinking type below it. One scale, nine steps:
       micro 11 · xs 12 · sm 13 · base 14 · md 16 · lg 18 · xl 22 · display 28 · numeral 36
     (desktop px; Arabic micro is 12, see html[dir="rtl"] below). */
  --text-sm:        max(13px, 0.8125rem);
  --text-base:      max(14px, 0.875rem);
  --text-md:        max(16px, 1rem);
  --text-lg:        max(18px, 1.125rem);
  --text-xl:        max(20px, 1.375rem);
  /* the serif masthead / hero headline, and the serif display numeral */
  --text-display:   max(24px, 1.75rem);
  --text-numeral:   max(28px, 2.25rem);
  /* running text: the body copy every page inherits (15px desktop, 14px phone) */
  --text-body:      max(14px, 0.9375rem);
  /* THE ROOT, not a step: html's own size, which every rem on the page is a
     multiple of. Fluid, 14px at 375px wide to 16px at 1440px and up. It is a
     token so that no sweep can fold it into the scale again: the premium
     review's codemod (#250) rewrote this clamp as var(--text-md), which fixed
     the root at 16px at every width and moved the MRI page, the classic MRI
     tab and split view (owner: unchanged) at every width under 1440px. */
  --text-root:      clamp(0.875rem, 0.831rem + 0.19vw, 1rem);

  /* ── control sizes — ONE height ladder for buttons, fields, selects and
     segmented controls, so a toolbar row lines up. Height is a MINIMUM: a
     wrapped label and the WCAG 1.4.12 text-spacing overrides still grow the
     control. The line-height is explicit because the Arabic face's `normal`
     line box is about twice the font size, which made every padded control
     ~10px taller in Arabic than in English. Phones and coarse pointers get the
     touch sizes by redefining these tokens once (see the 768px block), not by
     per-component media rules. */
  --control-h-xs:   24px;
  --control-h-sm:   32px;
  --control-h:      38px;
  --control-h-lg:   44px;
  --control-px-sm:  12px;
  --control-px:     16px;
  --control-fs-sm:  var(--text-sm);
  --control-fs:     var(--text-base);
  --field-fs:       var(--text-base);
  --field-fs-sm:    var(--text-sm);
  --control-lh:     1.3;
  --control-radius: var(--radius-sm);

  /* z-index layering scale — single source of stacking truth */
  --z-base:         0;
  --z-raised:       10;
  --z-sticky:       100;
  --z-sidebar:      200;
  --z-fixed-bar:    900;
  --z-drawer:       1500;
  --z-modal:        2000;
  --z-toast:        3000;
  --z-loading-bar:  9000;
  --z-skip-link:    9500;
  --z-fullscreen:   9800;

  /* glow ring — geometry for the recurring "0 0 Npx var(--brand-glow)" pattern */
  --shadow-glow:    0 0 6px var(--brand-glow);

  /* the sidebar's width at this viewport (it steps down with the media queries
     below), so a bar fixed to the page can sit in the content column */
  --sb-w:           252px;

  /* the sidebar's own two surfaces: its nav scrollbar, and the tooltip the
     icon rail shows for each item's name.
     The thumb is a control, not decoration, so it clears the 3:1 of WCAG
     1.4.11 against the glass behind it: 3.42:1 here, 3.57:1 in dark. */
  /* Quiet at rest, full strength under the pointer. The resting value is a
     soft wash of the brand teal: it measures 1.7:1 light and 2.0:1 dark, under
     the 3:1 of WCAG 1.4.11, which it can be because it is not what tells you
     the list runs on — `.nav-sec` fades at whichever edge has more ("G16"),
     and that is the affordance. Reach for the bar and it goes to the full
     teal, 3.9:1 and 5.9:1, so the control itself is never faint. */
  --sb-thumb:        color-mix(in srgb, var(--teal) 42%, transparent);
  --sb-thumb-strong: var(--teal);
  --sb-tip-bg:       #1e1e4a;
  --sb-tip-ink:      #ffffff;
  --sb-tip-edge:     transparent;

  /* the smallest any running text may be: 11px in Latin, 12px in Arabic (below).
     It was 0px in Latin, which made every max(var(--fs-floor), …) a no-op on a
     phone's 14px root. */
  --fs-floor:       11px;
}
html[dir="rtl"] {
  --fs-floor: 12px;
  /* Noto Kufi Arabic needs room above and below for its marks (tashkeel): at
     1.3 they touch the control's edge. 1.5 x 14px still fits the 32px tier. */
  --control-lh: 1.5;
}
/* Touch sizes: a phone, or any device whose primary pointer is a finger, gets
   44px controls (40px for the compact tier) and 16px field text, which also
   stops iOS zooming into a focused field. One redefinition instead of the old
   per-component 768px and 480px rules, which disagreed (44px vs 34px). */
@media (max-width: 768px), (pointer: coarse) {
  :root {
    --control-h-sm: 40px;
    --control-h:    44px;
    --field-fs:     var(--text-md);
    --field-fs-sm:  var(--text-md);
  }
}

/* ── The Arabic type scale ────────────────────────────────────────────────────
   Noto Kufi Arabic draws its letters smaller than Inter at the same size. In
   Chrome at 100px, Inter's x-height is 55px and the Kufi letter body 48-50px,
   so 12px Arabic reads like 10.4px Latin; 72% of the Arabic text measured 12px
   on desktop and 78% on phones (Arabic review, 2026-11). Each step is about 15%
   larger in Arabic, so a page reads at the same size in both languages.
   Not every step: --text-display is the serif masthead, and DM Serif Display's
   x-height (48px at 100px) already equals the Kufi letter body, so 28px Arabic
   matches it; --text-xl and --text-numeral are KPI numerals in Latin digits.
   The controls stop one step short of the text: 15/14px keeps every filter bar
   on its line, and the 16px touch field text (no iOS zoom) is restated below,
   because the :root touch block above is less specific than this one.
   On <html>, the element :root names, so the aliases computed there (--text-2xs,
   --fs-sm) follow the new steps. Not on the MRI page or split view (owner:
   unchanged): their body class keeps the whole block off their <html>, and they
   keep the 12px Arabic micro step below. */
html[dir="rtl"]:not(:has(> body.twm-root, > body.tws-root)) {
  --fs-floor:       13px;
  --text-micro:     max(13px, 0.8125rem);
  --text-xs:        max(14px, 0.875rem);
  --text-sm:        max(15px, 0.9375rem);
  --text-base:      max(16px, 1rem);
  --text-md:        max(18px, 1.125rem);
  --text-lg:        max(20px, 1.25rem);
  --text-body:      max(16px, 1.0625rem);
  --control-fs-sm:  max(14px, 0.875rem);
  --control-fs:     max(15px, 0.9375rem);
  --field-fs-sm:    max(14px, 0.875rem);
  --field-fs:       max(15px, 0.9375rem);
}
@media (max-width: 768px), (pointer: coarse) {
  html[dir="rtl"]:not(:has(> body.twm-root, > body.tws-root)) {
    --field-fs:     max(16px, 1rem);
    --field-fs-sm:  max(16px, 1rem);
  }
}
/* What keeps the Arabic sizes it has today:
   - the owner's sidebar, its command palette, its phone toggle and the icon
     rail's tooltip (which is appended to <body>): its labels are fitted to the
     252/210/195px rail, and tests pin the Arabic section headings at 14px and
     the search row's label uncut at every step;
   - the dense tool surfaces whose geometry is measured: the Timetable
     Workspace's chrome above its panes (at most 170px, and already 170px in
     Arabic at 1536px), its inspector's four tabs (a 296-320px pane) and its
     board grid (a 96px slot, a 56px day column), and the exam builder's
     schedule grid, its edit toolbar and its fixed-height scope chips. Their
     side panels and panel bodies, which scroll, take the scale;
   - Latin data: the audit log's table (roles, actions, endpoints, hashes; its
     Arabic headers and dates take the scale again below), and the Timetable
     Graph page, which has no Arabic text at all.
   A token computed on <html> arrives here as a finished value, so every alias
   is restated too; tests/test_design_type_scale.py checks that these are the
   first :root block's values (12px micro aside). :where() keeps the list at
   zero specificity, so a component can still adjust a step inside it. */
html[dir="rtl"] :where(.sidebar, .sbp, .sidebar-toggle, .sb-tip,
    .tw-header, .tw-cmd-bar, .tw-stats, .tw-panel-tabs, .tw-grid-table, main:has(#twWorkspace) .page-header,
    main.exam-builder-page :is(#schedGrid, .et-edit-controls, #progList, #secList),
    .audit-table, .tg-shell) {
  --fs-floor:       12px;
  --text-micro:     max(12px, 0.75rem);
  --text-2xs:       var(--text-micro);
  --fs-sm:          var(--text-micro);
  --text-xs:        max(12px, 0.75rem);
  --text-sm:        max(13px, 0.8125rem);
  --text-base:      max(14px, 0.875rem);
  --text-md:        max(16px, 1rem);
  --text-lg:        max(18px, 1.125rem);
  --text-body:      max(14px, 0.9375rem);
  --control-fs-sm:  var(--text-sm);
  --control-fs:     var(--text-base);
  --field-fs-sm:    var(--text-sm);
  --field-fs:       var(--text-base);
}
@media (max-width: 768px), (pointer: coarse) {
  html[dir="rtl"] :where(.sidebar, .sbp, .sidebar-toggle, .sb-tip,
      .tw-header, .tw-cmd-bar, .tw-stats, .tw-panel-tabs, .tw-grid-table, main:has(#twWorkspace) .page-header,
      main.exam-builder-page :is(#schedGrid, .et-edit-controls, #progList, #secList),
      .audit-table, .tg-shell) {
    --field-fs:     var(--text-md);
    --field-fs-sm:  var(--text-md);
  }
}
/* ...and a held zone's own unsized text keeps the size it inherited: the tokens
   are restated inside, but a size inherited from outside the zone arrives
   finished (the graph's node labels grew from 15 to 17px with the body). Zero
   specificity, so any size a component gives the zone itself still wins. */
:where(html[dir="rtl"]) :where(.tw-header, .tw-cmd-bar, .tw-stats, .tw-panel-tabs, .tw-grid-table,
    main:has(#twWorkspace) .page-header, .tg-shell) {
  font-size: var(--text-body);
}
:where(html[dir="rtl"]) :where(main.exam-builder-page :is(#schedGrid, .et-edit-controls, #progList, #secList)) {
  font-size: var(--text-base);
}

/* ── MRI stays exactly as it was (owner, 2026-10-23) ─────────────────────────
   The MRI page itself needs nothing here: `page-timetable-mri.js` puts
   `.twm-root` on <body>, and `timetable-mri-full.css` then hides .color-mesh,
   .sidebar and the page chrome outright, paints its own opaque background with
   !important, and draws every colour from hard-coded --twm-* values of its own.
   None of the ground changes above reach it.

   The CLASSIC INSPECTOR'S MRI TAB does read the globals: `timetable-mri.css`
   takes var(--line) seven times and var(--bg) three, so warming those would
   have moved its panel edges and fills. Scoping the previous values onto
   `.tw-mri` holds the whole tab where it was — every .tw-mri-* element is built
   inside that one wrapper (page-timetable-workspace.js), so they all inherit
   it, while --brand, --radius and the rest still come from :root.

   It lives in the global sheet precisely so that neither MRI file is touched,
   and it sits AFTER :root rather than inside it: tests/test_design_system_tokens.py
   reads the FIRST `:root {` block up to its first `\n}`, so splitting :root in
   two hides every token below the split from the contrast tests.
   Dark needs no entry — none of the dark values changed. */
.tw-mri {
  --bg:             #eef1f7;
  --line:           #dde3ed;
  --line-strong:    #c8d0df;
}
/* The shared page chrome those two pages still show keeps its old sizes there
   when the type scale moves (premium review, 2026-11; owner: MRI unchanged, split
   view out of scope): the keyboard skip link, and the footer under the MRI
   canvas. A computed-style snapshot of both pages is diffed to prove it. */
body.twm-root .skip-link,
body.tws-root .skip-link { font-size: clamp(0.75rem, 0.715rem + 0.09vw, 0.8125rem); }
body.twm-root .system-footer { font-size: 0.74rem; }
body.twm-root .system-footer strong { font-weight: 800; }

/* ============================================================
   DARK MODE — Deep Navy
   ============================================================ */
html[data-theme="dark"] {
  /* backgrounds */
  --bg:             #0d0f1a;
  --card:           #151826;
  --surface:        #1b1f30;

  /* ink — inverted text hierarchy */
  --ink:            #e2e4ec;
  --ink-2:          #d0d2dc;
  --t0:             #e2e4ec;
  --t1:             #d0d2dc;
  --t2:             #c0c4d4;
  --t3:             #a0a4b8;
  /* was #7a7e92: 4.39:1 on --card, 3.65:1 on --surface-2. #8c92aa: 5.72 card,
     6.19 bg, 5.30 surface, 4.75 surface-2 — and still a step below --t3. */
  --t4:             #8c92aa;
  --t5:             #505468;
  --muted:          #a0a4b8;
  --muted-light:    #8c92aa;

  /* the neutral button — same reasoning, dark values, same refusal to sit on the
     threshold. 0.38 measures 4.03 to 4.5 across card, surface, bubble and page.
     Neumorphic light-shadows do not exist against a near-black card, so dark uses
     the translucent white this theme already gives its inputs, chips and bubbles. */
  --btn-neutral-bg:     rgba(255,255,255,0.07);
  --btn-neutral-border: rgba(255,255,255,0.38);
  --btn-neutral-text:   var(--t1);

  /* dark control edge: 3.7-4.2:1 on the card, the surface and the page */
  --control-edge:       rgba(255,255,255,0.40);

  --surface-2:      #232838;

  /* borders */
  --line:           rgba(255,255,255,0.06);
  --line-strong:    rgba(255,255,255,0.10);
  --line-h:         rgba(255,255,255,0.06);
  --line-a:         rgba(255,255,255,0.10);

  /* A rule divides two regions of the sheet with nothing else to help it, so it
     cannot inherit --line's 0.06 here: on #0d0f1a that is a 1.04:1 difference,
     which is to say no line at all. These are the dividers the light theme gets
     for free from a warm hairline on paper. */
  --rule:           rgba(255,255,255,0.12);
  --rule-strong:    rgba(255,255,255,0.24);

  /* brand — slightly brighter teal for dark bg */
  --brand:          #0CA87E;
  --brand-dark:     #2EC9A0;
  --brand-soft:     rgba(10,142,110,0.12);
  --brand-glow:     rgba(10,142,110,0.25);

  /* Extended teal */
  --teal:           #0CA87E;
  --teal-bright:    #2EC9A0;
  --teal-pale:      #4DD9B4;
  --teal-deep:      #0CA87E;
  --teal-dim:       rgba(10,142,110,0.12);
  --teal-border:    rgba(10,142,110,0.24);

  /* Extended palette */
  --royal:          #5068F0;
  --royal-bright:   #6B80FF;
  --royal-dim:      rgba(64,86,227,0.12);
  --royal-border:   rgba(64,86,227,0.24);
  --sky:            #10C0EC;
  --sky-bright:     #40D0F8;
  --sky-dim:        rgba(0,174,218,0.12);

  --rose:           #f0a0b4;
  --rose-dim:       rgba(240,160,180,0.12);

  --amber:          #f59e0b;
  --amber-dim:      rgba(245,158,11,0.14);

  --navy:           #e2e4ec; /* inverted for readability */

  /* sidebar accent */
  --sidebar-bar:    #2EC9A0;
  --sidebar-glow:   rgba(10,142,110,0.35);

  /* semantic */
  --success:        #2EC9A0;
  --danger:         #F06060;
  --warning:        #F5B731;

  /* passing pairs, dark: white on --teal (#0CA87E) is 3.04:1. The dark primary is
     the bright mint with near-black ink (8.13:1), so on Deep Navy the one primary
     is the brightest teal on the screen rather than the dullest. */
  --text-brand:       #2ec9a0;
  --btn-primary-bg:   #2ec9a0;
  --btn-primary-ink:  #04201a;
  --btn-primary-hover:#4dd9b4;

  /* severity, dark: each ≥ 5.2:1 on every dark surface */
  --sev-critical:     #f97066;
  --sev-critical-bg:  rgba(249,112,102,0.12);
  --sev-warning:      #f5b731;
  --sev-warning-bg:   rgba(245,183,49,0.11);
  --sev-info:         #8093ff;
  --sev-info-bg:      rgba(128,147,255,0.12);
  --sev-ok:           #2ec9a0;
  --sev-ok-bg:        rgba(46,201,160,0.10);
  --sev-warning-ink:  var(--sev-warning);
  --text-sky:         var(--sky);

  /* plan-map graph, dark: tinted fills with light inks of the same hue */
  --pg-node-fill:     rgba(255,255,255,0.07);
  --pg-node-edge:     rgba(255,255,255,0.24);
  --pg-passed-fill:   rgba(46,201,160,0.16);
  --pg-passed-edge:   rgba(46,201,160,0.75);
  --pg-passed-ink:    #7ee8c8;
  --pg-passed-dot:    rgba(46,201,160,0.85);
  --pg-studying-fill: rgba(128,147,255,0.18);
  --pg-studying-edge: rgba(128,147,255,0.78);
  --pg-studying-ink:  #b7c2ff;
  --pg-studying-dot:  rgba(128,147,255,0.9);
  --pg-open-fill:     rgba(255,255,255,0.10);
  --pg-open-edge:     #2ec9a0;
  --pg-locked-fill:   rgba(160,164,184,0.08);
  --pg-locked-edge:   rgba(160,164,184,0.50);
  --pg-locked-ink:    #a9aec3;
  --pg-locked-dot:    rgba(160,164,184,0.75);
  --pg-found-fill:    rgba(46,201,160,0.10);
  --pg-found-edge:    rgba(46,201,160,0.40);
  --pg-found-ink:     #6fe0bd;
  --pg-term-fill:     rgba(128,147,255,0.10);
  --pg-term-edge:     rgba(128,147,255,0.40);
  --pg-term-ink:      #aab6ff;
  --pg-gate-fill:     rgba(245,183,49,0.10);
  --pg-gate-edge:     rgba(245,183,49,0.45);
  --pg-warn:          #f5b731;

  /* shadows — darker */
  --shadow-card:    0 1px 3px rgba(0,0,0,.20), 0 8px 24px rgba(0,0,0,.30);
  --shadow-lift:    0 4px 12px rgba(0,0,0,.25), 0 16px 40px rgba(0,0,0,.35);
  --shadow-input:   0 1px 2px rgba(0,0,0,.15);
  --shadow-sm:      0 1px 3px rgba(0,0,0,.28);
  /* Flat here too, and for the same reason — see the light block. */
  --shadow-neu:     0 0 0 0 rgba(0,0,0,0);
  --shadow-neu-sm:  0 0 0 0 rgba(0,0,0,0);
  --shadow-neu-inset: inset 0 0 0 0 rgba(0,0,0,0);

  /* borders */
  --border-subtle:  1px solid rgba(255,255,255,0.05);
  --border-mid:     1px solid rgba(255,255,255,0.08);

  /* glassmorphism — dark glass */
  --glass-bg:       rgba(255,255,255,0.04);
  --glass-bg-data:  rgba(255,255,255,0.06);
  --glass-bg-header:rgba(255,255,255,0.08);

  /* focus ring */
  --focus-ring:     0 0 0 2px #0d0f1a, 0 0 0 4px var(--teal);

  color-scheme: dark;
}

/* The light theme says so too. base.html's <meta name="color-scheme" content="light
   dark"> lets the OS choose otherwise, so a dark OS painted dark scrollbars,
   pickers and native controls on a light page (every student page is light). */
html[data-theme="light"] { color-scheme: light; }

/* Arabic is read at a larger size than Latin to be as legible: the micro-label
   floor is 12px, not 11px, wherever --text-micro is used. This is what the MRI
   page and split view keep; every other page takes the Arabic type scale near
   the top of this sheet, whose selector outranks this one. */
html[dir="rtl"] { --text-micro: max(12px, 0.75rem); }

/* ── Dark body background ──
   The body ink is --t0. It said --t2, but an unscoped `html[data-theme="dark"]
   body` rule in the LOGIN block (same specificity, later) painted every dark
   page #e2e4ec — which is --t0 — so --t0 is what dark pages have always shown.
   That login rule is now scoped to the login page; this states the real value. */
html[data-theme="dark"] body {
  background: var(--bg) !important;
  color: var(--t0) !important;
}

/* ── Dark sidebar ── */
html[data-theme="dark"] .sidebar {
  background: rgba(255,255,255,0.03);
  border-inline-end-color: rgba(255,255,255,0.05);
}
/* A dark scrim is invisible on a near-black sidebar, and a near-black tooltip
   needs an edge to separate it from the page behind it. */
html[data-theme="dark"] {
  /* Both tokens follow the theme on their own; dark needs no values of its
     own for the thumb. */
  --sb-tip-bg:       #272a3d;
  --sb-tip-ink:      var(--t0);
  --sb-tip-edge:     rgba(255,255,255,0.12);
}
html[data-theme="dark"] .sidebar .form-select {
  background-color: rgba(255,255,255,0.06) !important;
  color: var(--t2) !important;
  border-color: var(--control-edge) !important;
}
html[data-theme="dark"] .sidebar .form-select:focus {
  background-color: rgba(255,255,255,0.1) !important;
}
html[data-theme="dark"] .logo-area {
  border-block-end-color: rgba(255,255,255,0.06);
}

/* ── Dark page header ── */
html[data-theme="dark"] .page-header {
  background: rgba(13,15,26,0.6);
}

/* ── Dark color mesh ── */
html[data-theme="dark"] .color-mesh {
  background:
    radial-gradient(ellipse 80% 60% at 0% 0%, rgba(10,142,110,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 55% at 45% 0%, rgba(0,174,218,0.04) 0%, transparent 55%),
    radial-gradient(ellipse 55% 50% at 100% 5%, rgba(64,86,227,0.05) 0%, transparent 55%),
    radial-gradient(ellipse 70% 50% at 15% 45%, rgba(64,224,208,0.04) 0%, transparent 50%),
    radial-gradient(ellipse 50% 40% at 55% 40%, rgba(229,198,3,0.03) 0%, transparent 45%),
    radial-gradient(ellipse 55% 50% at 95% 45%, rgba(255,209,220,0.04) 0%, transparent 50%),
    radial-gradient(ellipse 60% 45% at 40% 90%, rgba(10,142,110,0.03) 0%, transparent 50%),
    radial-gradient(ellipse 50% 45% at 85% 85%, rgba(0,174,218,0.03) 0%, transparent 50%),
    radial-gradient(ellipse 45% 40% at 10% 90%, rgba(64,86,227,0.02) 0%, transparent 45%),
    linear-gradient(160deg, #0a0c14 0%, #0c0f1c 25%, #0d0f1a 50%, #0b0e18 75%, #0d101c 100%);
}


/* ── Dark selection ── */
html[data-theme="dark"] ::selection { background: var(--btn-primary-bg); color: var(--btn-primary-ink); }

/* ── Dark form inputs ── */
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select {
  background-color: rgba(255,255,255,0.05) !important;
  color: var(--t1) !important;
  border-color: var(--control-edge) !important;
}
html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .form-select:focus {
  background-color: rgba(255,255,255,0.08) !important;
  border-color: var(--teal) !important;
  box-shadow: 0 0 0 3px rgba(10,142,110,0.2) !important;
}
html[data-theme="dark"] .form-control::placeholder {
  color: var(--t4) !important;
}

/* ── Dark buttons ── */
html[data-theme="dark"] .btn-outline-secondary {
  color: var(--t3) !important;
  border-color: var(--control-edge) !important;
}
html[data-theme="dark"] .btn-outline-secondary:hover {
  background: rgba(255,255,255,0.06) !important;
  color: var(--t1) !important;
}
html[data-theme="dark"] .btn-outline-dark {
  color: var(--t2) !important;
  border-color: var(--control-edge) !important;
}
html[data-theme="dark"] .btn-outline-dark:hover {
  background: rgba(255,255,255,0.08) !important;
  color: #fff !important;
}

/* ── Dark table ── */
html[data-theme="dark"] table th {
  color: var(--t3);
}
html[data-theme="dark"] table td {
  border-color: rgba(255,255,255,0.04);
}html[data-theme="dark"] table thead th,
html[data-theme="dark"] .cmd-search-row,
html[data-theme="dark"] .dba-panel-header,
html[data-theme="dark"] .audit-table th,
html[data-theme="dark"] .audit-table td,
html[data-theme="dark"] .ap-drawer-section .table-wrap td {
  border-bottom-color: rgba(255,255,255,0.06);
}

/* ── Dark scrollbar ── */
html[data-theme="dark"] ::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.02);
}
html[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.08);
}
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.14);
}

/* ── Dark pills ── */
html[data-theme="dark"] .pill-teal {
  background: rgba(10,142,110,0.15);
}
html[data-theme="dark"] .pill-royal {
  background: rgba(64,86,227,0.15);
}html[data-theme="dark"] .pill-muted,
html[data-theme="dark"] .sp-fill-wrap,
html[data-theme="dark"] .sp-progress,
html[data-theme="dark"] .pf-pw-bar-track {
  background: rgba(255,255,255,0.06);
}

/* ── Dark back-to-top ── */
html[data-theme="dark"] .btt {
  background: rgba(255,255,255,0.06) !important;
  border-color: rgba(255,255,255,0.1) !important;
  color: var(--t3) !important;
}

/* ── Dark mode: background + shadow overrides ─────────────
   Kill hardcoded rgba(255,255,255,0.40) backgrounds AND
   neumorphic shadows (rgba(163,177,198,...) + rgba(255,255,255,0.7+))
   ─────────────────────────────────────────────────────────── */

/* Cards & panels — dark surface (bg + border + shadow) for the classes
   that share the teal-card treatment. .advisor-block, .cpanel, .zone-card,
   .drawer moved to V2 UNIFIED dark rule. */
html[data-theme="dark"] .soft-card,
html[data-theme="dark"] .term-card,
html[data-theme="dark"] .term-details,
html[data-theme="dark"] .glass-card,
html[data-theme="dark"] .task-card {
  background: rgba(255,255,255,0.04) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25) !important;
  border:     1px solid rgba(10,142,110,0.2) !important;
}

/* .metric and .mc left the rule above: they are sheet tiles in both themes
   now, and that rule's `!important` would otherwise outrank the light
   conversion and hand dark its cards straight back. */
html[data-theme="dark"] .metric,
html[data-theme="dark"] .mc {
  background: none !important;
  box-shadow: none !important;
  border:     0 !important;
  border-top: 1px solid var(--rule) !important;
}

/* Cards & panels — bg + shadow only (no teal border) */
html[data-theme="dark"] .actions-row,
html[data-theme="dark"] .page-nav,
html[data-theme="dark"] .skel-card,
html[data-theme="dark"] .glass-filter-row,
html[data-theme="dark"] .audit-table-wrap,
html[data-theme="dark"] .mobile-cards tbody tr {
  background: rgba(255,255,255,0.04) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25) !important;
}
/* The filter bar left the rule above for the same reason as .metric and .mc.
   It still needs an OPAQUE fill, because it is sticky on several screens and
   would otherwise let the rows it is pinned over show through — in dark that
   is --bg, the sheet it sits on, exactly as in light. */
html[data-theme="dark"] .filter-bar {
  background: var(--bg) !important;
  box-shadow: none !important;
}

/* Kill backdrop-filter in dark mode — flat look matching advisor-block */
html[data-theme="dark"] .mc,
html[data-theme="dark"] .cpanel,
html[data-theme="dark"] .soft-card,
html[data-theme="dark"] .zone-card,
html[data-theme="dark"] .metric,
html[data-theme="dark"] .glass-card {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
html[data-theme="dark"] .advisor-block h3,
html[data-theme="dark"] .zone-title,
html[data-theme="dark"] .um-panel-title,
html[data-theme="dark"] .cp-t,
html[data-theme="dark"] .dba-section-title,
html[data-theme="dark"] .pf-card-title,
html[data-theme="dark"] .pane-title,
html[data-theme="dark"] .ap-drawer-section-title,
html[data-theme="dark"] .et-panel > h6,
html[data-theme="dark"] .si-panel > h6,
html[data-theme="dark"] .cpanel > h6 {
  color: #2ec9a0;
}
html[data-theme="dark"] .drawer h3 {
  color: #e2e4ec;
}

/* Panels with stronger glass for data readability. .table-wrap left this rule:
   it is a sheet section in both themes now, and the `!important` here would
   have given dark back the card light just took off it. Its sticky header
   keeps its own opaque fill, which is what actually protects the rows. */
html[data-theme="dark"] .soft-card {
  background: rgba(255,255,255,0.06) !important;
}

/* Pagination bar */
html[data-theme="dark"] .pg-bar {
  background: rgba(255,255,255,0.04) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25) !important;
}

/* Recommendation items */
html[data-theme="dark"] .rec {
  background: rgba(255,255,255,0.04) !important;
  box-shadow: none !important;
}
html[data-theme="dark"] .rec:hover {
  background: rgba(10,142,110,0.08) !important;
  box-shadow: none !important;
}

/* Table header hover */
html[data-theme="dark"] .table-wrap thead th:hover {
  background: rgba(255,255,255,0.08) !important;
}

/* Table header row */
html[data-theme="dark"] .table-wrap thead {
  background: rgba(255,255,255,0.06) !important;
}

/* Batch metrics. The id raises this to (1,1,1), above every rule the sheet
   conversion wrote, so these tiles were the one place in dark still painted as
   boxes. Flat, like every other .metric. */
html[data-theme="dark"] #batchMetrics .metric {
  background: none !important;
  border-color: var(--rule) !important;
}

/* Card/panel hover — slightly deeper.
   .metric, .mc and .cpanel left this rule: they are flat sheet tiles now, and
   `!important` here made hovering one in dark paint a shadowed card back on.
   Worse, the `border-top: … !important` they carry blocks the light theme's
   hover (a border-colour change), so dark's ONLY hover cue was the card this
   rule drew. Their dark hover is restated just below. */
html[data-theme="dark"] .soft-card:hover {
  background: rgba(255,255,255,0.06) !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35) !important;
}
html[data-theme="dark"] .metric:hover,
html[data-theme="dark"] .mc:hover,
html[data-theme="dark"] .cpanel:hover {
  border-top-color: var(--rule-strong) !important;
  background: rgba(255,255,255,0.04) !important;
  box-shadow: none !important;
}

/* Buttons — flat with subtle shadow.
   The CONTROLS in this list are split out below: a drop shadow on a near-black
   page is not a boundary (it measures about 1.03:1 against --bg), so in dark
   these had no visible edge at all, as they did before this change. They take
   the same --btn-neutral-border ring the light theme gives them, which is the
   alpha the token's own comment computed to clear 3:1 in dark.
   .tbl-cnt and .pill-status stay as they are — they are counts and status
   chips, not controls — and a DISABLED control is exempt from 1.4.11 and must
   not be given an edge that makes it read as live. */
html[data-theme="dark"] .tbl-cnt,
html[data-theme="dark"] .pill-status,
html[data-theme="dark"] body .btn:disabled,
html[data-theme="dark"] body .btn.disabled {
  box-shadow: 0 1px 4px rgba(0,0,0,0.2) !important;
}
html[data-theme="dark"] .btn-circle,
html[data-theme="dark"] .pg-btn,
html[data-theme="dark"] .fb-dd,
html[data-theme="dark"] .empty-state-action {
  box-shadow: inset 0 0 0 1px var(--btn-neutral-border), 0 1px 4px rgba(0,0,0,0.2) !important;
}

/* Button hover — slight lift */
/* The outline variants carry a real 1px border, so they keep their edge through
   this layer; the three that are ringed by box-shadow need it restating. */
html[data-theme="dark"] body .btn-outline-secondary:hover,
html[data-theme="dark"] body .btn-outline-success:hover,
html[data-theme="dark"] body .btn-outline-warning:hover,
html[data-theme="dark"] body .btn-outline-info:hover,
html[data-theme="dark"] body .btn-outline-dark:hover,
html[data-theme="dark"] body .btn-export:hover {
  box-shadow: inset 0 0 0 1px var(--teal) !important;
}
html[data-theme="dark"] .btn-circle:hover,
html[data-theme="dark"] .pg-btn:hover,
html[data-theme="dark"] .fb-dd:hover {
  box-shadow: inset 0 0 0 1px var(--control-edge), 0 2px 8px rgba(0,0,0,0.3) !important;
}
/* Dark hovers by getting LIGHTER. The light theme's navy hover tint is darker
   than the resting white-7% fill here, so without this the control's fill
   disappears at the moment you point at it. .fb-dd already has its own. */
html[data-theme="dark"] .btn-circle:hover,
html[data-theme="dark"] .pg-btn:hover { background: rgba(255,255,255,0.12) !important; }

/* Button active / pressed — inset dark */
html[data-theme="dark"] body .btn-outline-secondary:active {
  box-shadow: inset 1px 1px 3px rgba(0,0,0,0.3) !important;
  /* Without this the dark :hover background (same !important, higher
     specificity than the light :active rule) wins through the press. */
  background: rgba(255,255,255,0.16) !important;
}
/* Selected/pressed: the teal ring says which one, and survives the layer. */
html[data-theme="dark"] .btn-circle:active,
html[data-theme="dark"] .pg-btn.active,
html[data-theme="dark"] .fb-dd.active {
  box-shadow: inset 0 0 0 1px var(--teal), inset 1px 1px 3px rgba(0,0,0,0.3) !important;
}
/* The outline buttons keep their ring through the dark hover and press layers. */
html[data-theme="dark"] body .btn-outline-danger:hover {
  box-shadow: inset 0 0 0 1px var(--sev-critical), 0 2px 8px rgba(0,0,0,0.3) !important;
}
html[data-theme="dark"] body .btn-outline-primary:hover {
  box-shadow: inset 0 0 0 1px var(--text-brand), 0 2px 8px rgba(0,0,0,0.3) !important;
}
html[data-theme="dark"] body .btn-outline-primary:active {
  box-shadow: inset 0 0 0 1px var(--text-brand), inset 1px 1px 3px rgba(0,0,0,0.3) !important;
}

/* Input focus ring — keep teal ring, kill neumorphic.
   The two `.btn` selectors that used to be here are gone, and this is the only
   rule in this repair where anything was REMOVED rather than corrected. It is
   redundant after correction, and provably so: its stated intent is "keep the
   teal ring", which the focus contract now delivers in a solid, measured form,
   while this declaration is 20%-alpha teal — the 1.9:1 indicator that contract
   exists to replace. Corrected but left in place, it would have won at (0,3,3)
   with `!important` and silently reinstated the defect in dark mode. */
html[data-theme="dark"] .form-control:focus-visible,
html[data-theme="dark"] .form-select:focus-visible {
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.15) !important;
}

/* Inputs — subtle inset */
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select {
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.15) !important;
}
/* Inset-shadow field/icon surfaces — shared dark value */
html[data-theme="dark"] .dlg-icon,
html[data-theme="dark"] .mc-icon {
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.2) !important;
}
/* The search and dialog fields keep their edge (--control-edge) in dark too. */
html[data-theme="dark"] .fb-search,
html[data-theme="dark"] .dlg-input-row input {
  box-shadow: inset 0 0 0 1px var(--control-edge), inset 0 1px 3px rgba(0,0,0,0.2) !important;
}
/* Inset + the shared solid focus ring */
html[data-theme="dark"] .fb-search:focus-within,
html[data-theme="dark"] .dlg-input-row input:focus {
  box-shadow: inset 0 0 0 1px var(--teal), inset 0 1px 3px rgba(0,0,0,0.2), 0 0 0 2px var(--teal) !important;
}

/* Dialogs — clean dark shadow */
html[data-theme="dark"] .dlg-box {
  box-shadow: 0 8px 32px rgba(0,0,0,0.5) !important;
}
html[data-theme="dark"] .dlg-footer .btn-cancel:hover {
  box-shadow: inset 0 0 0 1px var(--control-edge) !important;
  background: rgba(255,255,255,0.12) !important;
}
html[data-theme="dark"] .dlg-footer .btn-confirm:disabled {
  box-shadow: 0 1px 3px rgba(0,0,0,0.15) !important;
}

/* Toast — dark shadow */
html[data-theme="dark"] .ux-toast {
  box-shadow: 0 4px 16px rgba(0,0,0,0.4) !important;
}
html[data-theme="dark"] .ux-toast-icon {
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.2) !important;
}

/* ── Dark: cpanel header ───
   (No fill: the panel header is a ruled line on the sheet in both themes. Dark
   used to paint a 6% grey band that light had already removed.) */
/* ── Dark: conflict matrix ─── */
html[data-theme="dark"] .cm-table th,html[data-theme="dark"] .cm-table td{border-color:rgba(255,255,255,0.06)}
html[data-theme="dark"] .cm-corner{background:linear-gradient(135deg,rgba(10,142,110,0.12),rgba(64,86,227,0.12))}
html[data-theme="dark"] .cm-col-hdr,html[data-theme="dark"] .cm-row-hdr{background:rgba(255,255,255,0.06)}
html[data-theme="dark"] .cm-diag{background:rgba(10,142,110,0.1);border-color:rgba(10,142,110,0.2) !important}
html[data-theme="dark"] .cm-cell:hover{box-shadow:0 0 10px rgba(10,142,110,0.3)}
html[data-theme="dark"] .cm-table tr:hover .cm-row-hdr{background:rgba(10,142,110,0.15)}

/* ── Dark: dialog box ─── */
html[data-theme="dark"] .dlg-box {
  background: #151826 !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5) !important;
}
html[data-theme="dark"] .dlg-overlay {
  background: rgba(0,0,0,0.6) !important;
}
/* Both dialog systems (dlg.confirm's .dlg-backdrop and the native .ux-dialog)
   dim the page more in dark: a navy veil over a near-black page barely
   separated the dialog from it. */
html[data-theme="dark"] .dlg-backdrop { background: rgba(2,4,10,0.72); }
html[data-theme="dark"] .ux-dialog::backdrop { background: rgba(2,4,10,0.72); }

/* ── Dark: .fb-dd & other button-like elements bg ─── */
html[data-theme="dark"] .fb-dd {
  background: rgba(255,255,255,0.03) !important;
}
/* The light hover tints with navy, which in dark is almost the page colour —
   the resting fill would VANISH on hover and only the ring would remain. Dark
   hovers by getting lighter, the same direction light gets darker. */
html[data-theme="dark"] .fb-dd:hover {
  background: rgba(255,255,255,0.12) !important;
}
html[data-theme="dark"] .fb-dd.active {
  background: rgba(10,142,110,0.08) !important;
}

/* ── Dark: btn-outline-dark hover (was hardcoded navy bg) ─── */
html[data-theme="dark"] body .btn-outline-dark:hover {
  background: rgba(255,255,255,0.08) !important;
}

/* ── Dark: .page-header bg ─── */
html[data-theme="dark"] .page-header {
  background: rgba(13,15,26,0.6) !important;
}

/* ── Dark: table-wrap thead sticky bg ─── */
/* Composited over --card for the same reason as the light rule: these are
   sticky headers now, and a 6%-alpha background lets the rows scroll through
   them. This block outranks the base rule (id-ish specificity + !important),
   so leaving it translucent would silently undo the fix in dark mode only. */
html[data-theme="dark"] .table-wrap thead th {
  background: linear-gradient(rgba(255,255,255,0.06), rgba(255,255,255,0.06)),
              var(--bg) !important;
}
html[data-theme="dark"] .table-wrap thead th:hover {
  background: linear-gradient(rgba(255,255,255,0.10), rgba(255,255,255,0.10)),
              var(--bg) !important;
}

/* ── Dark: mc spark bars ─── */
html[data-theme="dark"] .mc .spark .b,
html[data-theme="dark"] .ps-item .spark .b {
  background: rgba(255,255,255,0.08);
}

/* ── Dark: panel-specific hardcoded backgrounds ─── */
html[data-theme="dark"] #batchMetrics .metric {
  background: none !important;
  border-color: var(--rule) !important;
}
html[data-theme="dark"] #advisorportfolio #advTable thead th {
  background: rgba(10,142,110,0.08) !important;
  color: var(--text-brand) !important;
}
html[data-theme="dark"] #advisorportfolio .metric {
  border-color: rgba(255,255,255,0.06) !important;
}

/* The flattened row's dark hover. The light wash is navy-tinted teal, which is
   DARKER than the dark surface, so it would read as a hole here. */
html[data-theme="dark"] .tbl-card tbody tr.cr-row:hover,
html[data-theme="dark"] .tbl-card tbody tr.cr-row:focus-within {
  background: rgba(255,255,255,0.06) !important;
}

/* ── Dark: .tbl-card backgrounds ─── */
html[data-theme="dark"] .tbl-card {
  background: transparent !important;
}
/* The header cell is painted OPAQUE (a 6% white wash over --card), like every other
   dark table header. It was a bare translucent 6% on top of `.table-wrap thead`'s
   own 6% and the glass behind it: three layers stacked into the flat grey bar
   (about rgb(75,80,89)) whose labels measured 3.3:1. */
html[data-theme="dark"] .tbl-card thead th {
  background: linear-gradient(rgba(255,255,255,0.06), rgba(255,255,255,0.06)),
              var(--card) !important;
  border-bottom-color: rgba(255,255,255,0.06) !important;
}
html[data-theme="dark"] .tbl-card thead { background: transparent !important; }
html[data-theme="dark"] .tbl-card tbody tr {
  border-bottom-color: rgba(255,255,255,0.04) !important;
}

/* ── Dark: skel-block (skeleton loading) ─── */
html[data-theme="dark"] .skel-block {
  background: rgba(255,255,255,0.06) !important;
}

/* ── Dark: .rec inset shadow (sticky-cta gradient) ─── */
html[data-theme="dark"] .sticky-cta::before {
  opacity: 0.4;
}

/* ── Theme toggle button ── */
.theme-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--control-edge);
  background: transparent; cursor: pointer;
  color: var(--t4); font-size: 16px;
  transition: all 0.2s var(--ease);
}
.theme-toggle:hover { background: var(--brand-soft); color: var(--t2); }
html[data-theme="dark"] .theme-toggle {
  color: var(--t4);
}
/* Which icon shows is decided here, by the theme. The dark icon used to carry
   Bootstrap's `d-none` (display:none !important), which the inline style that
   sidebar.html sets could never beat, so in dark mode both icons were hidden and
   the toggle was an empty box. The inline style still says the same thing. */
.theme-toggle .theme-icon-dark { display: none; }
html[data-theme="dark"] .theme-toggle .theme-icon-dark { display: inline; }
html[data-theme="dark"] .theme-toggle .theme-icon-light { display: none; }
html[data-theme="dark"] .theme-toggle:hover {
  background: rgba(255,255,255,0.06);
  color: #F5B731;
}

/* ============================================================
   REUSABLE UTILITY CLASSES
   ============================================================ */
/* Glass card — the most repeated pattern across all templates */
.glass-card {
  background:             linear-gradient(160deg, var(--teal-dim) 0%, var(--card) 100%);
  border:                 1px solid var(--teal-border);
  border-radius:          var(--radius);
  box-shadow:             var(--shadow-card);
}

/* Neumorphic surface */
.neu { box-shadow: var(--shadow-neu); }
.neu-sm { box-shadow: var(--shadow-neu-sm); }
.neu-inset { box-shadow: var(--shadow-neu-inset); }

/* Common icon sizing — used 20+ times inline */
.i-xxs { width: 12px; height: 12px; }
.i-13  { width: 13px; height: 13px; }
.i-xs  { width: 14px; height: 14px; }
.i-sm  { width: 16px; height: 16px; }
.i-md  { width: 20px; height: 20px; }
.i-lg  { width: 24px; height: 24px; }
.i-xl  { width: 32px; height: 32px; }

/* ── Utility classes ─ colour ──────────────────────────── */
.text-teal     { color: var(--text-brand)    !important; }
.text-warning  { color: var(--sev-warning-ink) !important; }
.text-t3       { color: var(--t3)      !important; }
.text-t4       { color: var(--t4)      !important; }
.text-royal    { color: var(--royal)   !important; }

/* ── Utility classes ─ layout ──────────────────────────── */
.text-end      { text-align: end       !important; }
.u-border      { border: 1px solid var(--line); }

/* ── Utility classes ─ typography ──────────────────────── */
.text-caps     { text-transform: uppercase; letter-spacing: 0.04em; }
.font-mono     { font-family: var(--font-mono); }
.fs-10         { font-size: var(--text-micro); }
.fs-11         { font-size: var(--text-micro); }
.fs-12         { font-size: var(--text-xs); }
/* .fs-xs/-sm/-md keep their order but no longer go under the 12px data floor
   (they were 11.2 / 11.5 / 12.5px). They are aliases of the --text-* scale. */
.fs-xs         { font-size: var(--text-xs); }
.fs-sm         { font-size: var(--text-sm); }
.fs-md         { font-size: var(--text-sm); }
.tnum          { font-variant-numeric: tabular-nums; }

/* ── Utility classes ─ misc ────────────────────────────── */
.u-cursor-pointer { cursor: pointer; }

/* Pill / chip — used in planner, dashboard, portfolio */
.pill {
  display: inline-flex; align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-pill);
  font-size: var(--fs-sm, 0.72rem);
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.5;
}
.pill-teal { background: var(--teal-dim);  color: var(--text-brand);  border: 1px solid var(--teal-border); }
.pill-royal { background: var(--royal-dim); color: var(--royal); border: 1px solid var(--royal-border); }
.pill-sky { background: var(--sky-dim);   color: var(--text-sky); }
.pill-muted { background: var(--brand-soft); color: var(--t3); border: var(--border-mid); }
.pill-danger { background: var(--pl-danger-bg); color: var(--danger); border: 1px solid rgba(192,48,48,0.14); }

/* ============================================================
   TYPOGRAPHY SCALE
   ============================================================
   The scale is the --text-* tokens in :root, nothing else:
     --text-2xs  ≥11px  micro labels only — chips, counts, kickers
     --text-xs   ≥12px  the least DATA may be — meta lines, table cells, captions
     --text-sm   ≥12.5px dense UI — toolbars, inputs, list rows, issue titles (13px at 16px)
     --text-base  14px  body copy, panel text, dialogs
     --text-md    16px  page and panel titles
     --text-lg    18px  section titles
     --text-xl    22px  metric values
   (sizes at the 16px root; the root is fluid, 14px → 16px between 375 and
   1440px wide, which is why the two smallest steps carry a px floor).
   Older components still size headings with their own clamp() values; new
   components use the tokens. An earlier comment here documented --fs-xs …
   --fs-3xl tokens that were never defined; they do not exist.
   ============================================================ */

/* ============================================================
   BASE
   ============================================================ */
html {
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Fluid root: 14px @ 375  →  16px @ 1440 (see --text-root) */
  font-size: var(--text-root);
  /* DM Serif Display is loaded at its one real weight (400). Without this, a
     heading or stat numeral asked for 700 is thickened by the browser, which
     blurs the serif's hairlines. Inter, JetBrains Mono and Noto Kufi Arabic are
     loaded with a real bold, so nothing else is affected. */
  font-synthesis-weight: none;
}

body {
  /* Was a hard-coded #f0f2f0, which quietly outranked --bg: the page ground was
     NOT the token every component was matched against, so changing --bg moved
     the components and left the paper underneath them unchanged. The token is
     the ground now, which is also what makes the dark override below a
     restatement of dark's own --bg rather than a second source of truth. */
  background:          var(--bg) !important;
  background-attachment: fixed;
  color:               var(--t2) !important;
  font-family:         var(--font-body) !important;
  /* MRI and split view inherit this (owner: unchanged) — leave it as is; every
     other page takes the override just below. */
  font-size:           clamp(0.8125rem, 0.742rem + 0.19vw, 0.9375rem);
  line-height:         1.5;
  margin:              0;
}
/* Body copy: 15px on a desktop and never under 14px. The clamp above is
   relative to a root that is itself 14px on a phone, so running text was
   11.4px at 390px wide. MRI and split view keep the clamp (owner: out of
   scope); their body classes are set before anything paints. */
body:not(.twm-root):not(.tws-root) { font-size: var(--text-body); }
/* The sidebar and its command palette keep the size they were designed and
   measured at (their labels are fitted to the rail's 210/195px steps). */
.sidebar, .sbp { font-size: clamp(0.8125rem, 0.742rem + 0.19vw, 0.9375rem); }

/* Box model: a padded or bordered box is the size it says. Nothing reset
   box-sizing, so an <a class="btn"> (content-box) grew by its padding — 52-56px
   beside a 38px <button> — and a `width:100%` box with padding ran off a phone
   (the Arabic login scrolled sideways by 15px). Zero specificity, so any
   component that wants content-box still says so. Not on the MRI page or the
   classic inspector's MRI tab (owner: unchanged), nor split view, which has
   its own reset (body.tws-root *), nor the classic Timetable Workspace, whose
   board geometry (slot, cell and card heights) was measured in content-box and
   is pinned by its frame tests; nor the sidebar, its command palette and its
   phone menu button (the owner's design, sized against measured label fits). */
:where(body:not(.twm-root):not(.tws-root):not(:has(#twWorkspace))) :where(*:not(.tw-mri, .tw-mri *, .sidebar, .sidebar *, .sbp, .sbp *, .sidebar-toggle, .sidebar-toggle *)),
:where(body:not(.twm-root):not(.tws-root):not(:has(#twWorkspace))) :where(*:not(.tw-mri, .tw-mri *, .sidebar, .sidebar *, .sbp, .sbp *, .sidebar-toggle, .sidebar-toggle *))::before,
:where(body:not(.twm-root):not(.tws-root):not(:has(#twWorkspace))) :where(*:not(.tw-mri, .tw-mri *, .sidebar, .sidebar *, .sbp, .sbp *, .sidebar-toggle, .sidebar-toggle *))::after {
  box-sizing: border-box;
}

/* Form controls do not inherit the page font: the browser draws a button, an
   input, a select and a textarea in the system face (Arial) unless told
   otherwise, so every bespoke button was Arial, in Arabic too. Only the family
   is inherited; each component keeps its own size, weight and spacing. */
button,
input,
select,
textarea {
  font-family: inherit;
}
/* …and they do not inherit its SIZE either: a control no component sizes falls
   back to the browser's 13.33px (the Virtual Advisor fields and example
   buttons). Zero specificity: every component's own size still wins. Not on
   the MRI page, split view or inside the classic inspector's MRI tab. */
:where(body:not(.twm-root):not(.tws-root)) :where(input, select, textarea):where(:not(.tw-mri *, .sidebar *, .sbp *)) { font-size: var(--field-fs); }
:where(body:not(.twm-root):not(.tws-root)) :where(button):where(:not(.tw-mri *, .sidebar *, .sbp *)) { font-size: var(--control-fs); }

/* A plain link in running text is the brand's link, not the browser's blue and
   visited violet (the student course page showed both). Zero specificity, and
   only links without a class: every component's own link style still wins. */
/* Bold is one weight: `strong` and `b` default to "bolder", which inside a 700
   parent asked for 900 (audit explorer). Zero specificity. */
:where(body:not(.twm-root):not(.tws-root)) :where(b, strong):where(:not(.tw-mri *)) { font-weight: 700; }
/* The prerequisite graph's node labels are drawn by script with weight 750
   (rendered as 800); the type scale's bold is 700. */
.prereq-svg text[font-weight="750"] { font-weight: 700; }

:where(body:not(.twm-root):not(.tws-root)) :where(a:not([class])):where(:not(.tw-mri *)) {
  color: var(--text-brand);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: color-mix(in srgb, currentColor 45%, transparent);
}
:where(body:not(.twm-root):not(.tws-root)) :where(a:not([class])):where(:not(.tw-mri *)):hover {
  text-decoration-color: currentColor;
}

/* Native checkboxes and radios: one size and the brand fill (they were 13-18px in
   the browser's blue/grey). Zero specificity, so the custom switches and the
   .form-check-input box keep their own drawing. */
:where(body:not(.twm-root):not(.tws-root)) :where(input[type="checkbox"], input[type="radio"]):where(:not(.tw-mri *)) {
  accent-color: var(--btn-primary-bg);
  width: 16px;
  height: 16px;
}
/* The file picker's button is a neutral small button, not the browser's. */
:where(body:not(.twm-root):not(.tws-root)) :where(input[type="file"])::file-selector-button {
  margin-inline-end: var(--space-4);
  min-height: var(--control-h-sm);
  padding: 0 var(--control-px-sm);
  border: 0;
  border-radius: var(--control-radius);
  background: var(--btn-neutral-bg);
  box-shadow: inset 0 0 0 1px var(--btn-neutral-border);
  color: var(--btn-neutral-text);
  font: inherit;
  font-size: var(--control-fs-sm);
  font-weight: 600;
  cursor: pointer;
}

/* ── Placeholder text ────────────────────────────────────────
   A placeholder is text, so it clears 4.5:1 like any other: --t4 does on every
   surface in both themes. The browser's own grey measured 3.4-4.4:1 and --t5
   (the old .fb-search and dark-input placeholder) 1.95-2.35:1. */
::placeholder { color: var(--t4); opacity: 1; }

/* ── Selection highlight ─────────────────────────────────── */
::selection { background: var(--btn-primary-bg); color: var(--btn-primary-ink); }

/* ── Skip-to-content link (accessibility) ───────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  inset-inline-start: 0;
  z-index: 10000;
  padding: 8px 16px;
  /* The one filled primary pair: white on --teal was 4.11:1 (light) and 3.04:1
     (dark); --btn-primary-* is 5.48:1 and 8.13:1. */
  background: var(--btn-primary-bg);
  color: var(--btn-primary-ink);
  font-weight: 600;
  font-size: var(--text-sm);
  text-decoration: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}
.skip-link:focus { top: 0; }

/* ── Thin custom scrollbars ──────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: var(--line-a) transparent; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-a); border-radius: 3px; }

/* ── Noise texture overlay for depth ─────────────────────── */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9990;
  pointer-events: none;
  opacity: 0.02;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ============================================================
   BACKGROUND EFFECTS — gradient mesh + ambient blobs
   ============================================================ */
/* The light mesh was nine radial washes in five hues — teal, sky, royal,
   turquoise, yellow, pink — over an opaque #f2f5f2 base. The base is the part
   that mattered: being opaque and fixed over the whole viewport, IT was the
   page ground, and --bg underneath it was never visible on any screen. So the
   ground could not be changed without this rule, and the washes tinted every
   surface sitting on it a slightly different colour depending on where it
   happened to fall down the page.

   Light drops the paint and keeps the element: body's --bg shows through, with
   the 2% fractal-noise grain body::after already draws, which is what gives the
   paper its tooth. Dark keeps its mesh (see the dark block above) — over a
   near-black ground those washes read as depth rather than as a tint, and
   reworking Deep Navy is not this change. */
.color-mesh {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: none;
}

/* [hidden] always hides. The UA rule is a weak `display:none`, so any component
   that sets `display` (`html body .btn{display:inline-flex}`, Bootstrap's
   `.d-flex{display:flex!important}`, which loads after this file) silently
   un-hid elements a script had hidden — the planner card's Cancel among them.
   `html [hidden]` (0,1,1) outranks those utilities even though they load later. */
html [hidden] { display: none !important; }

/* ============================================================
   LAYOUT
   ============================================================ */
.shell {
  height: 100vh;
  display: flex;
  position: relative;
  z-index: 1;
  overflow: hidden;
}

/* ── Content wrap — constrains page content to a working width ──
   1440px: the 1120px column it replaced used a third of a wide screen and left
   the page floating in empty background. Prose stays readable on its own
   (.panel-sub and the intros stop at 80ch); cards and tables use the room. */
.content-wrap {
  max-width: 1440px;
  margin: 0 auto;
}

/* ── Content width tiers ──────────────────────────────────────
   base.html renders `<main data-width="{% block content_width %}">`. A page
   keeps the 1440px column above. A builder page may take `wide`; a tool
   page — a board, a canvas, a grid that is the whole job — takes `full` and
   uses the window. Opt-in per page, so no page widens by accident and
   `.content-wrap` itself (which the mobile menu's inert logic targets) is
   unchanged. Below 1025px every tier is already 100% (the 1024px block). */
main[data-width="wide"] > .content-wrap { max-width: 1760px; }
main[data-width="full"] > .content-wrap { max-width: none; }
/* The entry animation's end state (`transform: translateY(0)` held by
   `animation-fill-mode: both`) makes .content-wrap the containing block of every
   `position: fixed` element inside it. A tool page anchors floating panels to the
   window, so it does not animate in. */
main[data-width="full"] > .content-wrap { animation: none; }

/* ── Viewport-filling tool pages: main[data-fill="viewport"] ───
   The page itself does not scroll; its panes do. .content-wrap becomes a column
   exactly as tall as the window, the region marked `.app-fill` takes what the
   header and bars leave, and the footer shrinks to one line (it stays: it is the
   product's attribution). A window shorter than 640px, or 1024px wide and below,
   gets ordinary page scrolling instead, and the page's panes keep a usable
   minimum height there (the page's own CSS sets it). */
@media (min-width: 1025px) and (min-height: 640px) {
  main[data-fill="viewport"] > .content-wrap {
    display: flex; flex-direction: column;
    height: 100%; min-height: 0;
  }
  main[data-fill="viewport"] > .content-wrap > .app-fill { flex: 1 1 auto; min-height: 0; }
  main[data-fill="viewport"] > .content-wrap > :not(.app-fill) { flex: none; }
}
main[data-fill="viewport"] .system-footer {
  margin: 0; padding: 3px 12px;
  font-size: var(--text-2xs); line-height: 1.4;
  border-top: 1px solid var(--line);
}

main.flex-grow-1 {
  flex: 1;
  padding: 1.5rem;
  min-width: 0;       /* prevent flex overflow */
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
}

.system-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 2rem auto 0;
  padding: 1rem 0 0.25rem;
  color: var(--t4);
  font-size: var(--text-xs);
  letter-spacing: 0.01em;
  text-align: center;
  border-top: 1px solid rgba(148,163,184,0.16);
}
/* A short page keeps its footer at the foot of the window, not under the last
   card. The page column is at least as tall as <main>; the footer is sticky with
   `top: 100%`, so it is pushed toward the window's bottom edge and stopped by the
   column's own bottom: exactly the foot of the window on a short page, and its
   ordinary place on a long one. The column stays in block flow, so no margin
   anywhere on the page changes (a flex column stops margins collapsing and moved
   content on 46 screens). Viewport-filling tool pages lay themselves out (above);
   the MRI page is left alone. */
/* flow-root: a full-width page's header bleeds into <main>'s padding with a
   negative top margin; collapsing through the column, it started the column 24px
   high and the footer stopped 24px short. Its own formatting context keeps the
   margin inside, where the header still bleeds exactly as before. */
main:not([data-fill="viewport"]) > .content-wrap:where(:not(:has(#twmPage))) { min-height: 100%; display: flow-root; }
main:not([data-fill="viewport"]) > .content-wrap:where(:not(:has(#twmPage))) > .system-footer {
  position: sticky;
  top: 100%;
}
@media print {
  main:not([data-fill="viewport"]) > .content-wrap:where(:not(:has(#twmPage))) { min-height: 0; display: block; }
  main:not([data-fill="viewport"]) > .content-wrap:where(:not(:has(#twmPage))) > .system-footer { position: static; }
}

.system-footer strong {
  color: var(--t2);
  font-weight: 700;
}

.system-footer-sep {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.45;
}

html[data-theme="dark"] .system-footer {
  border-top-color: rgba(255,255,255,0.09);
}

/* ============================================================
   SIDEBAR
   ============================================================ */
/* ── Icon system ──────────────────────────────────────────── */
.i { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; flex-shrink: 0; }
.i svg { width: 100%; height: 100%; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.i-sm { width: 14px; height: 14px; }
.i-sm svg { stroke-width: 2; }
.i-lg { width: 20px; height: 20px; }

.sidebar {
  width:           252px;
  height:          100vh;
  background:      var(--glass-bg);
  backdrop-filter:  blur(50px) saturate(160%);
  -webkit-backdrop-filter: blur(50px) saturate(160%);
  border-inline-end: var(--border-subtle);
  display:         flex;
  flex-direction:  column;
  flex-shrink:     0;
  position:        relative;
}

/* Decorative gradient line on the sidebar edge */
.sidebar::after {
  content: '';
  position: absolute;
  top: 0;
  inset-inline-end: -1px;
  width: 1.5px;
  height: 40%;
  background: linear-gradient(180deg, var(--teal), var(--sky), var(--royal), transparent);
  opacity: 0.25;
}

/* ── Logo area ────────────────────────────────────────────── */
.logo-area {
  padding:          20px 18px 22px;
  display:          flex;
  align-items:      center;
  gap:              12px;
  border-block-end: var(--border-subtle);
}

.logo-mark {
  width:           40px;
  height:          40px;
  flex-shrink:     0;
  border-radius:   11px;
  position:        relative;
  background:      linear-gradient(135deg, var(--teal), var(--sky), var(--royal));
  display:         flex;
  align-items:     center;
  justify-content: center;
  box-shadow:      0 4px 16px color-mix(in srgb, var(--teal) 20%, transparent),
                   0 2px 6px rgba(64,86,227,0.12),
                   0 1px 0 rgba(255,255,255,0.25) inset;
}
.logo-mark::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 11px;
  background: linear-gradient(180deg, rgba(255,255,255,0.3), transparent 50%);
}
.logo-mark .i {
  width: 22px; height: 22px;
  color: #fff;
  position: relative; z-index: 1;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.15));
}

.logo-title {
  font-family:     var(--font-serif);
  font-size:       clamp(1.0625rem, 0.992rem + 0.19vw, 1.25rem); /* 17px → 20px */
  color:           var(--navy);
  line-height:     1.1;
  letter-spacing:  -0.01em;
}
/* The sidebar's text keeps the type floor (--text-2xs is 11px, the least any
   text may be) at every width: it measured 8.9px at 1440, 7.4px at 1100 and
   6.5px in the phone drawer, because each rem step shrank with the fluid root
   and two breakpoints shrank it again. No breakpoint below sets a size. */
.logo-sub {
  font-size:       var(--text-2xs);
  color:           var(--t4);
  font-weight:     600;
  letter-spacing:  0.08em;
  text-transform:  uppercase;
  margin-top:      3px;
  font-family:     var(--font-mono);
}

/* ── Navigation sections ──────────────────────────────────── */
.nav-sec {
  padding:    14px 10px;
  flex:       1;
  overflow-y: auto;
  /* The gutter is kept whether or not the list scrolls: collapsing a group can
     make it fit, and without this every label would jump sideways by the width
     of the scrollbar the moment it did. No effect where the browser draws an
     overlay scrollbar, which reserves nothing. */
  scrollbar-gutter: stable;
}

/* Each group's header is a <button>, because the group collapses. A bare
   <button> has no surface of its own and falls through to the user agent's
   ButtonFace grey (the defect tests/test_design_system_buttons.py pins for
   `.btn`), so the box is reset here explicitly. */
.nav-lbl {
  padding:        14px 10px 5px;
  font-size:      var(--text-2xs);
  font-weight:    700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color:          var(--t3);
  font-family:    var(--font-mono);
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  gap:             8px;
  width:           100%;
  background:      transparent;
  border:          0;
  border-radius:   var(--radius-sm);
  text-align:      start;
  line-height:     1.3;
  cursor:          pointer;
  transition:      color 0.15s var(--ease);
}
.nav-lbl:hover { color: var(--t2); }

.nav-lbl-chev {
  width:      13px;
  height:     13px;
  opacity:    0.8;
  transition: transform 0.18s var(--ease);
}
/* Collapsed: the chevron turns from "down" to the reading direction's forward
   edge — right in English, left in Arabic. */
.nav-lbl[aria-expanded="false"] .nav-lbl-chev { transform: rotate(-90deg); }
html[dir="rtl"] .nav-lbl[aria-expanded="false"] .nav-lbl-chev { transform: rotate(90deg); }

/* Staff navigation uses inline section headers on desktop. The drawer and
   the optional icon rail keep their own layout. */
.nav-section-icon { display: none; }
@media (min-width: 769px) {
  html:not([data-sidebar-rail]) [data-inline-sections] .nav-lbl {
    justify-content: start;
    min-height: 40px;
    margin-block: 0 2px;
    padding: 1px 10px;
    gap: 10px;
    color: var(--t1);
    font-family: var(--font-body);
    font-weight: 600;
    text-transform: none;
    letter-spacing: normal;
  }
  html:not([data-sidebar-rail]) [data-inline-sections] .nav-lbl-t {
    font-size: max(14px, var(--text-base));
  }
  html:not([data-sidebar-rail]) [data-inline-sections] .nav-lbl-chev {
    margin-inline-start: auto;
  }
  html:not([data-sidebar-rail]) [data-inline-sections] .nav-section-icon {
    display: inline-flex;
    box-sizing: border-box;
    width: 24px;
    height: 24px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--t2);
  }
  .nav-section-icon svg { width: 16px; height: 16px; }
  html:not([data-sidebar-rail]) [data-inline-sections] .nav-lbl:hover {
    background: var(--surface);
  }
  html:not([data-sidebar-rail]) [data-inline-sections] .is-current-section > .nav-lbl {
    color: var(--text-brand);
    background: color-mix(in srgb, var(--teal) 12%, transparent);
  }
  html:not([data-sidebar-rail]) [data-inline-sections] .is-current-section .nav-section-icon {
    background: var(--text-brand);
    border-color: var(--text-brand);
    color: var(--card);
  }
  html:not([data-sidebar-rail]) [data-inline-sections] .nav-grp-items {
    margin-block: 2px 8px;
    margin-inline: 24px 4px;
    border-inline-start: 1px solid var(--line);
    padding-inline-start: 6px;
  }
  html:not([data-sidebar-rail]) [data-inline-sections] .nav-a {
    padding: 6px 8px;
    gap: 7px;
    min-height: 32px;
  }
}
/* A wide tablet or touchscreen laptop still needs the roomier headings. */
@media (min-width: 769px) and (any-pointer: coarse) {
  html:not([data-sidebar-rail]) [data-inline-sections] .nav-lbl {
    min-height: 46px;
    margin-block: 3px;
    padding-block: 6px;
  }
  html:not([data-sidebar-rail]) [data-inline-sections] .nav-section-icon {
    width: 28px;
    height: 28px;
  }
}
@media (min-width: 769px) and (max-width: 992px) {
  html:not([data-sidebar-rail]) [data-inline-sections] .nav-lbl {
    padding-inline: 6px;
    gap: 6px;
  }
}
@media (min-width: 769px) and (forced-colors: active) {
  [data-inline-sections] .is-current-section > .nav-lbl {
    outline: 1px solid Highlight;
    outline-offset: -1px;
  }
}

/* ── Nav links ────────────────────────────────────────────── */
.nav-a {
  display:         flex;
  align-items:     center;
  gap:             10px;
  padding:         9px 12px;
  margin:          1.5px 0;
  border-radius:   var(--radius-sm);
  color:           var(--t3);
  font-size:       var(--text-sm);
  font-weight:     400;
  text-decoration: none;
  cursor:          pointer;
  /* Named, not `all`: hover and the active state move colour, the gradient
     wash and the inset ring, and nothing else. `all` also animated width,
     padding and transform, which the icon rail changes in one step. */
  transition:      color 0.15s var(--ease),
                   background 0.15s var(--ease),
                   box-shadow 0.15s var(--ease);
  position:        relative;
}
.nav-a:hover {
  color:      var(--t1);
  background: color-mix(in srgb, var(--teal) 5%, transparent);
}

/* Active state */
.nav-a.active,
.nav-a.on {
  color:       var(--text-brand);
  font-weight: 600;
  background:  linear-gradient(135deg, color-mix(in srgb, var(--teal) 14%, transparent), rgba(0,174,218,0.05));
  box-shadow:  0 0 0 1px var(--teal-border) inset;
}

.nav-a.active::before,
.nav-a.on::before {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: 7px;
  bottom: 7px;
  width: 3px;
  /* rounded on its inner side, which is the left one in Arabic */
  border-radius: 0;
  border-start-end-radius: 3px;
  border-end-end-radius: 3px;
  background: linear-gradient(180deg, var(--teal), var(--sky));
  box-shadow: 0 0 8px color-mix(in srgb, var(--teal) 30%, transparent), 0 0 4px rgba(0,174,218,0.2);
}

/* 0.4 put --t3 at 1.84:1 on the sidebar's glass in light and 2.21:1 in dark —
   below the 3:1 WCAG 1.4.11 asks of a non-text graphic, and far too faint to
   scan a 33-item list by. 0.75 measures 3.52:1 light and 4.64:1 dark, and the
   active icon (0.9, and --text-brand rather than --t3) still reads apart. */
.nav-a .i        { opacity: 0.75; color: var(--t3); }
.nav-a.active .i,
.nav-a.on .i     { opacity: 0.9; color: var(--text-brand); }

/* Nav badge */
.nav-badge {
  margin-inline-start: auto;
  font-family:         var(--font-mono);
  font-size:           var(--text-2xs);
  font-weight:         700;
  min-width:           18px;
  height:              18px;
  border-radius:       var(--radius-pill);
  display:             flex;
  align-items:         center;
  justify-content:     center;
  background:          rgba(192,48,48,0.08);
  color:               var(--danger);
  border:              1px solid rgba(192,48,48,0.16);
}

/* ── Sidebar footer ──────────────────────────────────────── */
.s-foot {
  margin-top:      auto;
  padding:         14px;
  border-block-start: var(--border-subtle);
}

.s-usr {
  display:      flex;
  align-items:  center;
  gap:          10px;
  padding:      8px 10px;
  border-radius: var(--radius-sm);
  cursor:       pointer;
  transition:   all 0.15s var(--ease);
  text-decoration: none;
  color:        inherit;
}
.s-usr:hover {
  background: color-mix(in srgb, var(--teal) 5%, transparent);
  box-shadow: 0 0 0 1px var(--line) inset;
}

.avatar {
  width:           32px;
  height:          32px;
  border-radius:   9px;
  /* Initials on the primary pair: white on the old teal-to-royal gradient was
     4.11:1 at its teal end (3.04:1 dark), and 10px was under the 11px floor. */
  background:      linear-gradient(135deg, var(--btn-primary-bg), var(--btn-primary-hover));
  display:         flex;
  align-items:     center;
  justify-content: center;
  color:           var(--btn-primary-ink);
  font-size:       var(--text-2xs);
  font-weight:     700;
  font-family:     var(--font-mono);
  box-shadow:      0 2px 8px color-mix(in srgb, var(--teal) 20%, transparent),
                   0 1px 0 rgba(255,255,255,0.15) inset;
  position:        relative;
}
.avatar::after {
  content: '';
  position: absolute;
  bottom: -1px;
  inset-inline-end: -1px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
  border: 2px solid #fff;
  box-shadow: 0 0 4px color-mix(in srgb, var(--teal) 40%, transparent);
}

.u-nm { font-size: var(--text-xs); font-weight: 600; color: var(--t1); }
.u-rl { font-size: var(--text-2xs); color: var(--t4); font-family: var(--font-mono); }

.s-usr-row { display: flex; align-items: center; gap: 4px; }
.s-usr-row .s-usr { flex: 1; min-width: 0; }
.s-usr-logout {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  /* A <button>: without a background and border it was the browser's grey
     button (light: ButtonFace with a 2px black border; dark: grey with a 2px
     white one). The same recipe as the theme toggle beside it. */
  padding: 0; background: transparent; cursor: pointer;
  border: 1px solid var(--control-edge);
  color: var(--t4); transition: all 0.15s var(--ease);
  flex-shrink: 0;
}
.s-usr-logout .i { width: 16px; height: 16px; }
.s-usr-logout:hover { background: rgba(192,48,48,0.08); color: var(--danger); }

.s-lang { margin-top: 10px; }

/* Language switcher inside glassmorphism sidebar */
.sidebar .form-select {
  background-color: var(--glass-bg) !important;
  border-color:     var(--control-edge) !important;
  color:            var(--t2) !important;
  font-size:        var(--text-xs);
  font-family:      var(--font-body);
  border-radius:    var(--radius-sm);
}
.sidebar .form-select:focus {
  background-color: var(--glass-bg-data) !important;
  border-color:     var(--teal) !important;
  box-shadow:       0 0 0 3px color-mix(in srgb, var(--teal) 15%, transparent) !important;
  color:            var(--t0) !important;
}

/* ── Collapse-to-rail toggle (in the search row) ──────────── */
.sb-rail-toggle {
  display:         flex;
  align-items:     center;
  justify-content: center;
  width:           28px;   /* ≥24px: WCAG 2.2 SC 2.5.8 */
  height:          28px;
  flex-shrink:     0;
  padding:         0;
  border-radius:   var(--radius-sm);
  /* A <button> with no surface of its own renders as the user agent's grey
     ButtonFace, as `.s-usr-logout` below records. */
  background:      transparent;
  border:          1px solid var(--control-edge);
  color:           var(--t3);
  cursor:          pointer;
  transition:      color 0.15s var(--ease), background-color 0.15s var(--ease);
}
.sb-rail-toggle .i     { width: 14px; height: 14px; }
.sb-rail-toggle:hover  { color: var(--t1); background: color-mix(in srgb, var(--teal) 8%, transparent); }
/* The chevron points the way a press moves the sidebar's edge: inline-start
   while the sidebar is wide, inline-end once it is a rail. That is an XOR of
   the rail and the reading direction, so it takes three rules. */
.sb-rail-toggle .i            { transform: scaleX(1); }
html[dir="rtl"] .sb-rail-toggle .i { transform: scaleX(-1); }

/* ── Nav search row — the command palette's way in ────────── */
.nav-find { padding: 10px 10px 0; display: flex; align-items: center; gap: 8px; }
.nav-find-btn {
  display:       flex;
  align-items:   center;
  gap:           9px;
  flex:          1;
  min-width:     0;
  padding:       8px 10px;
  border-radius: var(--radius-sm);
  background:    var(--glass-bg-data);
  border:        1px solid var(--control-edge);
  color:         var(--t3);
  font-family:   var(--font-body);
  font-size:     var(--text-xs);
  text-align:    start;
  cursor:        pointer;
  position:      relative;
  transition:    color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.nav-find-btn:hover { color: var(--t1); border-color: var(--teal); }
.nav-find-i  { opacity: 0.8; }
.nav-find-t  { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The global `kbd` rule is 0.72rem, which renders at 10.1px on the fluid root
   of a narrow window — under the 11px type floor. */
.nav-find-kbd {
  flex-shrink:   0;
  font-family:   var(--font-mono);
  font-size:     var(--text-2xs);
  font-weight:   600;
  color:         var(--t3);
  background:    color-mix(in srgb, var(--t3) 9%, transparent);
  border:        1px solid var(--control-edge);
  border-bottom: 1px solid var(--control-edge);
  border-radius: 5px;
  padding:       1px 5px;
  line-height:   1.4;
}

/* The list already says when it has more to scroll: `.nav-sec` carries a
   scroll-driven mask that fades whichever edge still has list beyond it (the
   "G16" block near the end of this file). Nothing here duplicates it. */

/* ── Collapsed section groups ─────────────────────────────── */
/* Before the sidebar module loads, leave the current screen's group visible. */
html[data-sidebar-fold-on-load] .nav-grp:not(:has(.nav-a.active)) > .nav-grp-items {
  display: none;
}

/* Which groups are collapsed is applied as an attribute on <html> by the
   anti-flash script in base.html, so a collapsed group is never painted open
   first. One selector per group: CSS cannot compare the attribute's value
   against the group's own name, and a loose match would collapse the wrong
   group. */
html[data-sidebar-collapsed~="exams"]       .nav-grp[data-group="exams"]       > .nav-grp-items,
html[data-sidebar-collapsed~="advising"]    .nav-grp[data-group="advising"]    > .nav-grp-items,
html[data-sidebar-collapsed~="curriculum"]  .nav-grp[data-group="curriculum"]  > .nav-grp-items,
html[data-sidebar-collapsed~="timetabling"] .nav-grp[data-group="timetabling"] > .nav-grp-items,
html[data-sidebar-collapsed~="insights"]    .nav-grp[data-group="insights"]    > .nav-grp-items,
html[data-sidebar-collapsed~="admin"]       .nav-grp[data-group="admin"]       > .nav-grp-items,
html[data-sidebar-collapsed~="student"]     .nav-grp[data-group="student"]     > .nav-grp-items {
  display: none;
}

/* ── Icon rail — the sidebar at 64px ──────────────────────── */
/* Only above the phone breakpoint: at ≤768px the sidebar is already a drawer
   the hamburger opens, and those rules set its width themselves. */
@media (min-width: 769px) {
  /* `:root` so this outranks the `:root { --sb-w }` steps in the ≤1200px and
     ≤992px blocks, which sit later in the file. */
  html[data-sidebar-rail]:root   { --sb-w: 64px; }
  html[data-sidebar-rail] .sidebar { width: 64px; }

  /* The words go; the mark, the icons and the avatar stay. */
  html[data-sidebar-rail] .logo-words,
  html[data-sidebar-rail] .nav-lbl,
  html[data-sidebar-rail] .nav-find-kbd,
  html[data-sidebar-rail] .s-usr-words,
  html[data-sidebar-rail] .s-lang { display: none; }

  html[data-sidebar-rail] .logo-area {
    flex-direction: column;
    gap:            10px;
    padding:        14px 0 12px;
  }
  html[data-sidebar-rail] .nav-find { padding: 10px 8px 0; flex-direction: column; gap: 8px; }
  /* Both edges: a gutter on one side alone pushes every icon half its width
     off the centre of a 64px rail, which is plain to see. */
  html[data-sidebar-rail] .nav-sec  { padding-inline: 4px; scrollbar-gutter: stable both-edges; }
  html[data-sidebar-rail] .nav-find-btn,
  html[data-sidebar-rail] .nav-a {
    justify-content: center;
    gap:             0;
    padding-inline:  0;
  }
  /* The search row is a column here, so the button's `flex: 1` buys it height,
     not width, and `align-items: center` sizes it to its contents: without
     this it shrinks to its 18px icon, under the 24px minimum the toggle's own
     rule cites. The toggle keeps its 28px and stays centred. */
  html[data-sidebar-rail] .nav-find-btn { align-self: stretch; }

  /* Every group's items show in the rail: with the headers gone there would be
     nothing left to re-open a collapsed one with. Same specificity as the
     collapse rule above and later in the file, so this wins. */
  html[data-sidebar-rail] .nav-grp[data-group] > .nav-grp-items { display: block; }
  html[data-sidebar-rail] .nav-grp + .nav-grp {
    margin-block-start:  8px;
    padding-block-start: 8px;
    border-block-start:  var(--border-subtle);
  }

  /* The label stays in the DOM, clipped: it is the link's accessible name, and
     the sidebar script draws it as a tooltip on hover and on focus. A
     `display: none` here would leave 33 unnamed links. */
  html[data-sidebar-rail] .nav-t,
  html[data-sidebar-rail] .nav-find-t {
    position:    absolute;
    width:       1px;
    height:      1px;
    padding:     0;
    margin:      -1px;
    overflow:    hidden;
    clip:        rect(0,0,0,0);
    white-space: nowrap;
    border:      0;
  }

  /* The count becomes a dot on the icon — 64px has no room for a number beside
     one. The spoken count in the `.visually-hidden` span beside it is
     untouched, so a screen reader still hears how many. `.sidebar-badge` is
     left out: it is display:none until the dashboard fills it. */
  html[data-sidebar-rail] .nav-badge:not(.sidebar-badge) {
    display:          block;
    position:         absolute;
    top:              5px;
    inset-inline-end: 9px;
    min-width:        0;
    width:            9px;
    height:           9px;
    padding:          0;
    border-radius:    50%;
    background:       var(--danger);
    border-color:     var(--danger);
    /* The digits are pushed out of the 9px box and clipped. */
    color:            transparent;
    overflow:         hidden;
    text-indent:      100%;
    white-space:      nowrap;
  }

  html[data-sidebar-rail] .s-foot     { padding: 10px 8px; }
  html[data-sidebar-rail] .s-usr-row  { flex-direction: column; gap: 8px; }
  html[data-sidebar-rail] .s-usr      { justify-content: center; padding-inline: 0; gap: 0; }
  html[data-sidebar-rail] .s-foot-row { justify-content: center; }

  html[data-sidebar-rail] .sb-rail-toggle .i          { transform: scaleX(-1); }
  html[dir="rtl"][data-sidebar-rail] .sb-rail-toggle .i { transform: scaleX(1); }
}

@media (max-width: 768px) {
  /* The drawer has the hamburger; there is no rail to collapse to, and a
     keyboard shortcut means nothing on a phone. */
  .sb-rail-toggle,
  .nav-find-kbd { display: none; }
}

/* ── The icon rail's tooltip ──────────────────────────────── */
/* Drawn at the body, not inside the link: `.nav-sec` scrolls, and a scroller
   clips both axes, so a tooltip positioned inside it is cut off at the rail's
   edge. */
.sb-tip {
  position:      fixed;
  z-index:       var(--z-drawer);
  max-width:     260px;
  padding:       6px 10px;
  border-radius: var(--radius-sm);
  background:    var(--sb-tip-bg);
  color:         var(--sb-tip-ink);
  border:        1px solid var(--sb-tip-edge);
  font-family:   var(--font-body);
  font-size:     var(--text-xs);
  line-height:   1.35;
  box-shadow:    0 10px 28px rgba(17,17,68,0.22);
}
.sb-tip[hidden] { display: none; }

/* ============================================================
   SIDEBAR COMMAND PALETTE  (Ctrl/Cmd+K — every nav destination)
   ============================================================ */
.sbp {
  position:        fixed;
  inset:           0;
  z-index:         var(--z-modal);
  display:         flex;
  align-items:     flex-start;
  justify-content: center;
  padding:         clamp(48px, 12vh, 140px) 16px 16px;
}
.sbp[hidden] { display: none; }

.sbp-backdrop {
  position:                absolute;
  inset:                   0;
  background:              rgba(17,17,68,0.38);
  backdrop-filter:         blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.sbp-panel {
  position:       relative;
  width:          100%;
  max-width:      560px;
  max-height:     min(70vh, 560px);
  display:        flex;
  flex-direction: column;
  overflow:       hidden;
  background:     rgba(255,255,255,0.94);
  backdrop-filter:         blur(30px) saturate(150%);
  -webkit-backdrop-filter: blur(30px) saturate(150%);
  border:         1px solid var(--line);
  border-radius:  var(--radius-lg);
  box-shadow:     0 28px 70px rgba(17,17,68,0.26);
}
html[data-theme="dark"] .sbp-panel {
  background:   #161a2b;
  border-color: rgba(255,255,255,0.10);
}

.sbp-field {
  display:          flex;
  align-items:      center;
  gap:              10px;
  padding:          14px 16px;
  flex-shrink:      0;
  border-block-end: 1px solid var(--line);
}
.sbp-field .i { color: var(--t3); opacity: 0.85; flex-shrink: 0; }
.sbp-input {
  flex:        1;
  min-width:   0;
  background:  transparent;
  border:      0;
  color:       var(--t0);
  font-family: var(--font-body);
  font-size:   var(--text-md);
}
/* As `.nav-find-kbd`: the global `kbd` size renders under the 11px floor. */
.sbp-esc {
  flex-shrink:   0;
  font-family:   var(--font-mono);
  font-size:     var(--text-2xs);
  font-weight:   600;
  color:         var(--t3);
  background:    color-mix(in srgb, var(--t3) 9%, transparent);
  border:        1px solid var(--control-edge);
  border-bottom: 1px solid var(--control-edge);
  border-radius: 5px;
  padding:       1px 5px;
  line-height:   1.4;
}

.sbp-list {
  list-style:       none;
  margin:           0;
  padding:          6px;
  overflow-y:       auto;
  flex:             1;
  min-height:       0;
}
.sbp-opt {
  display:       flex;
  align-items:   center;
  gap:           10px;
  padding:       9px 10px;
  border-radius: var(--radius-sm);
  color:         var(--t2);
  font-size:     var(--text-sm);
  cursor:        pointer;
  scroll-margin: 6px;
}
/* The same three signals as the sidebar's own active link — a wash, an inset
   ring and the brand ink — never colour alone. */
.sbp-opt[aria-selected="true"] {
  color:      var(--text-brand);
  background: linear-gradient(135deg, color-mix(in srgb, var(--teal) 14%, transparent), rgba(0,174,218,0.05));
  box-shadow: 0 0 0 1px var(--teal-border) inset;
}
.sbp-opt .i                       { opacity: 0.8; color: var(--t3); flex-shrink: 0; }
.sbp-opt[aria-selected="true"] .i { opacity: 0.95; color: var(--text-brand); }
.sbp-opt-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sbp-opt-sec {
  flex-shrink:    0;
  font-family:    var(--font-mono);
  font-size:      var(--text-2xs);
  color:          var(--t4);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
/* Latin utility typography must not leak into Arabic labels (as `.nav-lbl`). */
html[dir="rtl"] .sbp-opt-sec,
html[dir="rtl"] .sbp-foot {
  font-family:    var(--font-body);
  letter-spacing: 0;
  text-transform: none;
}
/* The highlight is a background and nothing else. A weight or a padding on it
   splits the label into runs with different font properties, and a browser
   shapes those separately — which breaks the cursive joins of an Arabic word
   at every edge of a match. */
.sbp-opt mark {
  background:    color-mix(in srgb, var(--teal) 24%, transparent);
  color:         inherit;
  font-weight:   inherit;
  border-radius: 3px;
}

.sbp-empty {
  margin:     0;
  padding:    22px 16px;
  text-align: center;
  color:      var(--t3);
  font-size:  var(--text-sm);
}
.sbp-foot {
  flex-shrink:        0;
  padding:            9px 14px;
  border-block-start: 1px solid var(--line);
  color:              var(--t4);
  font-size:          var(--text-2xs);
  font-family:        var(--font-mono);
}

@media (forced-colors: active) {
  /* The wash and the inset ring are dropped here; a border keeps the chosen
     row and the panel visible boxes. The row's marker is an outline, not a
     border: a border is laid out, so it grew the row 2px and shunted every
     row below it on each arrow key. */
  .sbp-opt[aria-selected="true"] { outline: 1px solid currentColor; outline-offset: -1px; }
  .sb-tip { border: 1px solid currentColor; }
}

@media (max-width: 768px) {
  .sbp { padding-top: 24px; }
  .sbp-panel { max-height: 78vh; }
}

/* ============================================================
   PAGE HEADER  (sticky context bar on every page)
   ============================================================ */
.page-header {
  position:         relative;
  z-index:          50;
  display:          flex;
  align-items:      center;
  justify-content:  space-between;
  gap:              1rem;
  padding:          0.65rem 1.5rem;
  margin:           -1.5rem -1.5rem 1.25rem -1.5rem;
  background:       var(--glass-bg);
  backdrop-filter:  blur(24px) saturate(130%);
  -webkit-backdrop-filter: blur(24px) saturate(130%);
  border-bottom:    none;
}
.page-header::after {
  content:    '';
  position:   absolute;
  bottom:     -1px;
  inset-inline-start: 0;
  inset-inline-end:   0;
  height:     2px;
  background: linear-gradient(90deg, var(--teal), var(--sky) 35%, var(--royal) 65%, transparent);
  opacity:    0.15;
}
/* p-3 main (planner, user-mgmt, portfolio) adjusts bleed */
main.p-3 .page-header {
  padding: 0.5rem 1rem;
  margin:  -1rem -1rem 1.25rem -1rem;
}
/* p-0 main has no padding to bleed into: the −1.5rem margin above pushed the
   header 24px ABOVE the scroll container's top, where it can never be scrolled
   into view (the title was clipped). It sits in flow and pads itself instead.
   (At ≤992px main gets 1rem padding !important and the bleed rule there wins.) */
main.p-0 .page-header {
  margin:  0;
  padding: 0.5rem 1rem;
}
.page-header-left { display: flex; flex-direction: column; gap: 0.2rem; }
.page-header-module { font-weight: 700; font-size: var(--text-md); color: var(--navy); letter-spacing: -0.01em; }
.page-header-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; }
/* A page without chips (or with only a hidden one a script fills later) must not
   keep their row's gap under its title. */
.page-header-chips:not(:has(> :not(.d-none, [hidden]))) { display: none; }
.page-header-right { flex-shrink: 0; display: flex; align-items: center; gap: 0.5rem; }
.page-header-right:empty { display: none; }

/* ── Page masthead ─────────────────────────────────────────────
   A page says its title once, as its headline. The header used to be a glass
   strip holding a 16px module label, with a second, serif copy of the same
   title under it in .page-intro. On a page that is read rather than operated
   the header is now the masthead: the h1 is the headline, its chips beside it,
   the page's actions on the right, and no strip. Unchanged:
   - tool pages (data-width="full", data-fill="viewport", the edge-to-edge
     p-0 boards): their bar is measured chrome
     (tests/test_ux_layout_primitives_browser.py);
   - phones (768px and below), where the bar carries the menu button. */
@media (min-width: 769px) {
  main:not(.p-0):not([data-width="full"]):not([data-fill="viewport"]) > .content-wrap > .page-header {
    margin: 0 0 0.4rem !important;     /* the 992px block's bleed is !important */
    padding: 0.25rem 0 0 !important;
    background: none !important;       /* so is the dark theme's strip */
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    align-items: flex-start;
  }
  main:not(.p-0):not([data-width="full"]):not([data-fill="viewport"]) > .content-wrap > .page-header::after {
    content: none;
  }
  main:not(.p-0):not([data-width="full"]):not([data-fill="viewport"]) > .content-wrap > .page-header:has(+ .page-intro:empty) {
    margin-bottom: 1.25rem !important;
  }
  /* ...and the same when the intro holds only a blank subtitle box. */
  main:not(.p-0):not([data-width="full"]):not([data-fill="viewport"]) > .content-wrap > .page-header:has(+ .page-intro > .panel-sub:empty:only-child) {
    margin-bottom: 1.25rem !important;
  }
  main:not(.p-0):not([data-width="full"]):not([data-fill="viewport"]) .page-header-left {
    flex-direction: row; flex-wrap: wrap; align-items: center;
    gap: 0.4rem 0.75rem; min-width: 0;
  }
  main:not(.p-0):not([data-width="full"]):not([data-fill="viewport"]) .page-header-module {
    margin: 0;
    font-family: var(--font-serif);
    font-weight: 400;                  /* G11: DM Serif Display has one weight */
    font-size: var(--text-display);
    line-height: 1.2;
  }
  /* Arabic: DM Serif Display has no Arabic, so the title fell back to Noto Kufi
     at the serif's one weight (400) and its tight 1.2 leading — thin, with the
     marks of a second line touching the first. Its size already matches the
     English (the serif's x-height equals the Kufi letter body), so it keeps
     28px and takes the body face at 600 with room for the marks. */
  html[dir="rtl"] main:not(.p-0):not([data-width="full"]):not([data-fill="viewport"]) .page-header-module {
    letter-spacing: 0;
    font-family: var(--font-body);
    font-weight: 600;
    line-height: 1.4;
  }
  main:not(.p-0):not([data-width="full"]):not([data-fill="viewport"]) .page-header-right {
    padding-top: 0.2rem;
  }
  main:not(.p-0):not([data-width="full"]):not([data-fill="viewport"]) > .content-wrap > .page-intro {
    margin-top: 0;
  }
}

/* ── Page-header chips ── */
.ph-chip {
  display: inline-block;
  font-size: var(--text-micro); font-weight: 600;
  padding: 0.15rem 0.5rem; border-radius: var(--radius-pill);
  letter-spacing: 0.01em; white-space: nowrap;
}
.ph-chip-role,
.ph-chip-page { background: var(--teal-dim); color: var(--text-brand); border: 1px solid var(--teal-border); }
.ph-chip-scope,
.ph-chip-gray { background: var(--brand-soft); color: var(--t3); border: var(--border-mid); }
.ph-chip-scope { max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.ph-chip-dept,
.ph-chip-status { background: var(--teal-dim); color: var(--text-brand); border: 1px solid var(--teal-border); }
.ph-chip-context { background: var(--teal-dim); color: var(--text-brand); border: 1px solid var(--teal-border); font-family: var(--font-mono); }
.ph-chip-danger { background: var(--pl-danger-bg); color: var(--danger); border: 1px solid rgba(192,48,48,0.14); }
.ph-chip-warn { background: rgba(154,106,8,0.06); color: var(--sev-warning); border: 1px solid rgba(154,106,8,0.14); }

/* ── Top loading bar ── */
#ux-loading-bar {
  position: fixed; top: 0; inset-inline-start: 0; inset-inline-end: 0; height: 3px; z-index: 9999;
  background: linear-gradient(90deg, transparent 0%, var(--teal) 30%, var(--teal-bright) 70%, transparent 100%);
  background-size: 200% 100%;
  animation: ux-loading-sweep 1.2s linear infinite;
  opacity: 0; transition: opacity 0.2s var(--ease); pointer-events: none;
}
#ux-loading-bar.active { opacity: 1; }
@keyframes ux-loading-sweep {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Button loading spinner ── */
.ux-loading {
  position: relative !important;
  padding-inline-start: 2rem !important;
}
.ux-loading::before {
  content: '';
  position: absolute;
  inset-inline-start: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  width: 12px; height: 12px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: ux-spin 0.7s linear infinite;
}
.ux-loading.btn-outline-secondary::before,
.ux-loading.btn-outline-dark::before,
.ux-loading.btn-outline-primary::before {
  border-color: rgba(0,0,0,0.18);
  border-top-color: currentColor;
}
@keyframes ux-spin { to { transform: translateY(-50%) rotate(360deg); } }

/* ── Empty states ── */
.empty-state {
  text-align: center; padding: 2.5rem 1.5rem;
  color: var(--t4); display: flex; flex-direction: column; align-items: center;
}
@media (max-width: 768px) {
  /* In a table wider than the phone the empty state was centred on the
     table, off screen; it stays in the visible part of its scroller. */
  td > .empty-state { position: sticky; inset-inline-start: 0; max-width: calc(100vw - 2.5rem); }
}
.empty-state .i { display: inline-flex; align-items: center; justify-content: center; opacity: 0.45; }
.empty-icon { display: block; font-size: 2rem; margin-bottom: 0.5rem; opacity: 0.6; }
/* An empty state is an invitation, not a disabled panel: at 11-12px weight-300
   text and a 30-45% icon it read as broken. The icon sits on a soft brand tile,
   the title is a heading, the hint is body text. */
.empty-state > .empty-icon,
.empty-state > .i:first-child,
.ap-empty-icon {
  display: inline-flex; align-items: center; justify-content: center;
  box-sizing: border-box; width: 52px; height: 52px; padding: 13px;
  margin: 0 0 12px; border-radius: var(--radius-lg);
  background: var(--teal-dim); color: var(--text-brand); opacity: 1;
}
.empty-state > .empty-icon > .i,
.ap-empty-icon > .i { width: 100%; height: 100%; opacity: 1; }
/* Serif is for the page title and display numerals; a heading inside the page is
   set in the body face (premium review: three section-title styles side by side). */
.empty-title, .ap-empty-title { font-family: var(--font-body); font-weight: 600; font-size: var(--text-md); color: var(--navy); margin-bottom: 4px; }
.empty-hint, .ap-empty-hint { font-size: var(--text-sm); color: var(--t3); line-height: 1.55; font-weight: 400; max-width: 52ch; }
.empty-hint strong, .ap-empty-hint strong { color: var(--text-brand); }

/* Remove table-striped odd-row override */
.table-striped > tbody > tr:nth-of-type(odd) > * { --bs-table-accent-bg: transparent; }

/* ============================================================
   PANELS  (keep !important — panels share .card with Bootstrap)
   ============================================================ */
.panel {
  display:   none !important;
  opacity:   0;
  transform: translateY(6px);
  transition: opacity .20s var(--ease), transform .20s var(--ease);
  padding:   0;
}

.panel.active {
  display:   block !important;
  opacity:   1;
  transform: translateY(0);
}

.panel h2 {
  margin-bottom:   0.2rem;
  font-family:     var(--font-body);
  font-weight:     700;
  font-size:       var(--text-md);
  color:           var(--navy);
  letter-spacing: -0.01em;
}

/* ── Page intro (h2 heading + subtitle below page-header) ── */
.page-intro { margin: 0.75rem 0 1.25rem; }
/* An empty intro still carried its 2rem of margin into the page. */
.page-intro:empty { display: none; }
/* The dashboard's Overview panel shows no subtitle, so #pageIntroSub renders
   empty -- the box stays in the DOM because activatePanel fills it when another
   panel opens. An intro holding nothing but that blank box is blank too. */
.page-intro:has(> .panel-sub:empty:only-child) { display: none; }
/* The page's title is the header's h1. An intro heading, where a page has one,
   names the view inside the page (Exam Timetable: "Student lists"; a student's
   name on their graduation plan), so it reads as a subtitle, not a second title. */
.page-intro h2 { font-family: var(--font-body); font-weight: 600; font-size: var(--text-lg); color: var(--t1); margin: 0 0 4px; }

.panel-sub {
  color:         var(--t3);
  font-size:     var(--text-base);
  margin-bottom: 1.25rem;
  max-width:     80ch;
  line-height:   1.5;
}

/* ============================================================
   CARDS
   ============================================================ */
.soft-card {
  border:           1px solid var(--teal-border) !important;
  border-radius:    var(--radius) !important;
  background:       linear-gradient(160deg, var(--teal-dim) 0%, var(--card) 100%) !important;
  box-shadow:       var(--shadow-card) !important;
  padding:          1.25rem;
  margin-bottom:    1rem;
  transition:       all 0.25s var(--ease);
  position:         relative;
  overflow:         hidden;
}

.soft-card:hover {
  box-shadow:       var(--shadow-lift) !important;
  background:       var(--glass-bg) !important;
  transform:        translateY(-1px);
}

/* ============================================================
   FORMS
   ============================================================ */
.form-label {
  font-family:     var(--font-body) !important;
  font-size:       var(--text-xs) !important;
  font-weight:     700 !important;
  color:           var(--ink-2) !important;
  letter-spacing:  0.04em;
  text-transform:  uppercase;
  margin-bottom:   0.3rem;
  display:         block;
}
/* A field's help line sits under its label, not above it: it had no rule and
   took the 15px body text (17px in Arabic) in full ink, over a 12px label. */
.form-text { font-size: var(--text-xs); line-height: 1.5; color: var(--t3); }

.form-control,
.form-select {
  font-family:      var(--font-body) !important;
  /* The control ladder (see :root): the same height as a .btn beside it, and a
     line-height of its own so an Arabic field is not 10px taller than English. */
  font-size:        var(--field-fs) !important;
  line-height:      var(--control-lh);
  min-height:       var(--control-h);
  color:            var(--ink) !important;
  border:           1px solid var(--control-edge) !important;
  /* 14px was the soft-era radius and never matched the system's own --radius
     (10px) or --radius-sm (7px); beside a 1px rule it reads as a different
     design language. Controls take --radius-sm. */
  border-radius:    var(--control-radius) !important;
  background-color: transparent !important;
  padding:          0 var(--control-px-sm) !important;
  box-sizing:       border-box !important;
  max-width:        100% !important;
  box-shadow:       var(--shadow-neu-inset) !important;
  transition:       box-shadow .25s var(--ease), border-color .25s var(--ease);
}

.form-control:hover,
.form-select:hover { border-color: var(--control-edge) !important; }

.form-control:focus,
.form-select:focus {
  background-color: transparent !important;
  box-shadow:       var(--shadow-neu-inset),
                    0 0 0 2px color-mix(in srgb, var(--teal) 50%, transparent) !important;
  outline:          none !important;
  border-color:     var(--teal) !important;
}

/* ── Compact inputs for small numeric values ───────────── */
.form-control-compact {
  max-width: 80px !important;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

/* Chrome autofill override — delay bg-color change forever */
.form-control:-webkit-autofill,
.form-control:-webkit-autofill:hover,
.form-control:-webkit-autofill:focus,
.form-control:-webkit-autofill:active,
.form-select:-webkit-autofill,
.form-select:-webkit-autofill:hover,
.form-select:-webkit-autofill:focus,
.form-select:-webkit-autofill:active {
  -webkit-text-fill-color: var(--ink, #0d1526) !important;
  caret-color: var(--ink, #0d1526);
  transition: background-color 9999s ease-in-out 0s,
              color 9999s ease-in-out 0s !important;
}

/* Hide browser credential buttons */
.form-control::-ms-reveal,
.form-control::-ms-clear,
.form-control::-webkit-credentials-auto-fill-button { display: none !important; }

/* A select keeps room for its chevron on the side the chevron is drawn (the
   shorthand above, !important, had taken bootstrap-compat's 2.25rem reserve
   away, so a long option ran under the arrow — in both directions). */
.form-select { padding-inline-end: 2.25rem !important; }
/* The small field is the compact tier, the height of a .btn-sm beside it (the
   -sm classes changed nothing: the rule above outranked their padding). */
.form-control.form-control-sm,
.form-select.form-select-sm {
  min-height: var(--control-h-sm);
  font-size:  var(--field-fs-sm) !important;
}
/* The sidebar's language select keeps exactly the size it renders at on master
   (the sidebar is the owner's design; the field ladder above does not reach it).
   Its own wrapper selector, so the sidebar rule above keeps its declared token. */
.s-lang .form-select {
  font-size:   clamp(0.8rem, 0.78rem + 0.09vw, 0.875rem) !important;
  line-height: 1.5;
  min-height:  0;
  padding:     0.45rem 1rem !important;
}

/* Textareas keep rounded-rectangle */
textarea.form-control {
  border-radius: var(--control-radius) !important;
  padding:       var(--space-4) var(--control-px-sm) !important;
  line-height:   1.5;
}

/* ============================================================
   BUTTONS  (html body prefix for specificity over Bootstrap)
   Neumorphic raised style — lifted surface with soft shadows
   ============================================================ */
html body .btn {
  font-family:     var(--font-body) !important;
  font-weight:     600 !important;
  /* the default tier of the control ladder (see :root) */
  font-size:       var(--control-fs) !important;
  line-height:     var(--control-lh);
  border-radius:   var(--control-radius) !important;
  border:          none !important;
  min-height:      var(--control-h);
  padding:         var(--space-2) var(--control-px) !important;
  display:         inline-flex;
  align-items:     center;
  justify-content: center;
  gap:             0.4rem;
  transition:      all .20s var(--ease) !important;
}

/* A link drawn as a button is not underlined: "Search another student" and
   "Back to portfolio" read as text links in the page header. */
html body a.btn:not(.btn-link),
html body a.btn:not(.btn-link):hover,
html body a.btn:not(.btn-link):focus { text-decoration: none; }

/* ── Filled buttons — raised neumorphic with colour fill ── */
/* The fill and ink are the passing pair from :root (--btn-primary-*): white on the
   old --teal fill was 4.11:1 in light and 3.04:1 in dark, and the hover went
   BRIGHTER (--teal-bright), which made it worse exactly while pointed at. */
html body .btn-primary {
  background:   var(--btn-primary-bg) !important;
  color:        var(--btn-primary-ink) !important;
  /* The filled button's own neumorphic pair: an offset coloured drop plus a
     white counter-light. On the sheet the FILL is the definition — a solid
     #067858 at 5.48:1 against its own text needs no halo to be found. */
  box-shadow:   none !important;
}
html body .btn-primary:hover,
html body .btn-primary:focus {
  background:   var(--btn-primary-hover) !important;
  box-shadow:   none !important;
}
html body .btn-primary:active {
  background:   var(--btn-primary-bg) !important;
  box-shadow:   inset 0 0 0 999px rgba(0,0,0,0.12) !important;
}

html body .btn-success {
  background:   var(--btn-primary-bg) !important;
  color:        var(--btn-primary-ink) !important;
  /* The filled button's own neumorphic pair: an offset coloured drop plus a
     white counter-light. On the sheet the FILL is the definition — a solid
     #067858 at 5.48:1 against its own text needs no halo to be found. */
  box-shadow:   none !important;
}
html body .btn-success:hover {
  background:   var(--btn-primary-hover) !important;
  box-shadow:   none !important;
}
html body .btn-success:active {
  box-shadow:   inset 0 0 0 999px rgba(0,0,0,0.12) !important;
}

html body .btn-danger {
  background:   var(--danger) !important;
  color:        #fff !important;
  box-shadow:   none !important;
}
html body .btn-danger:hover {
  box-shadow:   none !important;
}
html body .btn-danger:active {
  box-shadow:   inset 0 0 0 999px rgba(0,0,0,0.12) !important;
}

/* Warning (amber). Dark ink, as dark mode already had: white on the amber fill
   measured 3.19:1, under the 4.5:1 its 14px label needs; --ink on it is 5.3:1.
   The hover goes LIGHTER so the ink only gains contrast while pointed at (the
   old darker hover would have dropped dark ink to 3.1:1). */
html body .btn-warning {
  background:   var(--amber) !important;
  color:        var(--ink) !important;
  box-shadow:   none !important;
}
html body .btn-warning:hover {
  background:   color-mix(in srgb, var(--amber) 82%, #fff) !important;
  box-shadow:   none !important;
}
html body .btn-warning:active {
  box-shadow:   inset 0 0 0 999px rgba(0,0,0,0.12) !important;
}

/* In dark the danger and warning fills are the LIGHT tints (#F06060, #f59e0b),
   and white on them is 3.21:1 and 2.1:1. Dark ink, as on the primary fill. */
html[data-theme="dark"] body .btn-danger,
html[data-theme="dark"] body .btn-warning,
html[data-theme="dark"] .plan-black,
html[data-theme="dark"] .plan-red { color: var(--btn-primary-ink) !important; }
/* (the dialog's own buttons set no !important, so the read-only dialog's neutral
   button, which is more specific, still wins over this) */
html[data-theme="dark"] .dlg-footer .btn-confirm.danger,
html[data-theme="dark"] .dlg-footer .btn-confirm.warning { color: var(--btn-primary-ink); }

/* ── Outline variants — soft raised surface ────────────── */
/* An outline button needs an OUTLINE: its edge was only a neumorphic shadow, which
   in dark mode is rgba(255,255,255,.02) and invisible, and its --teal text was
   4.11:1. The ring is an inset shadow (no layout cost; `border:none !important`
   on the base) in the passing --text-brand, restated in every state because
   box-shadow is replaced, not added. */
html body .btn-outline-primary {
  color:        var(--text-brand) !important;
  background:   transparent !important;
  box-shadow:   inset 0 0 0 1px var(--text-brand), var(--shadow-neu-sm) !important;
}
html body .btn-outline-primary:hover {
  background:   color-mix(in srgb, var(--teal) 6%, transparent) !important;
  color:        var(--text-brand) !important;
  box-shadow:   inset 0 0 0 1px var(--text-brand), var(--shadow-neu) !important;
}
/* Pressed. The dished inset WAS the whole press cue; flat, it left :active
   looking identical to :hover. A deeper wash of the same colour reads as
   pressed without moving the control. */
html body .btn-outline-primary:active {
  box-shadow:   inset 0 0 0 1px var(--text-brand), var(--shadow-neu-inset) !important;
  background:   color-mix(in srgb, var(--teal) 14%, transparent) !important;
}

/* The outline variants that had no ring at all (secondary, dark, info, warning)
   draw one: a real 1px border in --control-edge, 3:1 or better in both themes.
   A border, not another inset shadow, because every hover/press/dark rule below
   replaces box-shadow wholesale and the ring would need restating in each. */
html body .btn-outline-secondary {
  color:        var(--t2) !important;
  background:   transparent !important;
  border:       1px solid var(--control-edge) !important;
  box-shadow:   var(--shadow-neu-sm) !important;
}
html body .btn-outline-secondary:hover {
  background:   var(--brand-soft) !important;
  color:        var(--t1) !important;
  box-shadow:   var(--shadow-neu) !important;
}
html body .btn-outline-secondary:active {
  box-shadow:   var(--shadow-neu-inset) !important;
  background:   rgba(17,17,68,0.10) !important;
}

html body .btn-outline-success {
  color:        var(--text-brand) !important;
  background:   transparent !important;
  border:       1px solid var(--text-brand) !important;
  box-shadow:   var(--shadow-neu-sm) !important;
}
html body .btn-outline-success:hover {
  background:   color-mix(in srgb, var(--teal) 5%, transparent) !important;
  color:        var(--text-brand) !important;
  box-shadow:   var(--shadow-neu) !important;
}

/* A destructive outline button: the same real ring as .btn-outline-primary, in
   the critical colour. Its hover text was a fixed #a02020, which in dark mode
   is dark red on Deep Navy; --sev-critical passes in both themes. */
html body .btn-outline-danger {
  color:        var(--sev-critical) !important;
  background:   transparent !important;
  box-shadow:   inset 0 0 0 1px var(--sev-critical), var(--shadow-neu-sm) !important;
}
html body .btn-outline-danger:hover {
  background:   var(--sev-critical-bg) !important;
  color:        var(--sev-critical) !important;
  box-shadow:   inset 0 0 0 1px var(--sev-critical), var(--shadow-neu) !important;
}

html body .btn-outline-warning {
  color:        #92400e !important;
  background:   transparent !important;
  border:       1px solid var(--control-edge) !important;
  box-shadow:   var(--shadow-neu-sm) !important;
}
html body .btn-outline-warning:hover {
  background:   rgba(217,119,6,0.05) !important;
  color:        #78350f !important;
  box-shadow:   var(--shadow-neu) !important;
}

html body .btn-outline-info {
  color:        var(--sky) !important;
  background:   transparent !important;
  border:       1px solid var(--control-edge) !important;
  box-shadow:   var(--shadow-neu-sm) !important;
}
html body .btn-outline-info:hover {
  background:   rgba(0,174,218,0.05) !important;
  color:        #0284a0 !important;
  box-shadow:   var(--shadow-neu) !important;
}

html body .btn-outline-dark {
  color:        var(--t1) !important;
  background:   transparent !important;
  border:       1px solid var(--control-edge) !important;
  box-shadow:   var(--shadow-neu-sm) !important;
}
html body .btn-outline-dark:hover {
  background:   var(--brand-soft) !important;
  color:        var(--navy) !important;
  box-shadow:   var(--shadow-neu) !important;
}

/* ── Small button size ────────────────────────────────────── */
/* An explicit line-height: `normal` takes the font's own line box, and the
   Arabic face's (Noto Kufi Arabic) is about twice the font size, so every
   32px button grew to 33.6px in Arabic and pushed its toolbar row down
   (stage 3, L30). The height stays a minimum, never fixed: wrapped words
   and the WCAG 1.4.12 text-spacing overrides still grow the button. */
html body .btn-sm,
html body .btn.btn-sm {
  /* the compact tier of the control ladder (see :root): 32px, 40px on touch */
  font-size:    var(--control-fs-sm) !important;
  line-height:  var(--control-lh);
  min-height:   var(--control-h-sm);
  padding:      var(--space-1) var(--control-px-sm) !important;
  /* 10px made a small button rounder than the 7px button and field beside it */
  border-radius: var(--control-radius) !important;
}

/* ── the neutral button ──────────────────────────────────────
   An EXPLICIT class, not a fallthrough on the base rule.

   `html body .btn` shapes every button in the app and sets no background, so a
   `.btn` with no variant falls through to `ButtonFace`, a user-agent system
   colour — measured `rgb(240,240,240)` in a light UA and `rgb(107,107,107)` in a
   dark one, ignoring the theme entirely. That is the "dark grey, looks disabled"
   the screen review reported.

   The first attempt put the surface on the BASE rule. It reached 19 controls and
   also everything else: `html body .btn` (0,1,2) outranks `.btn-link` (0,1,0), so
   link-buttons lost their colour in dark mode, and three buttons carrying inline
   backgrounds gained a grey hairline inside their fill. An explicit class cannot
   interact with Bootstrap variants, link and close controls, or the
   screen-specific button systems, and the scope that justified the global
   approach was wrong anyway — 19 controls in 8 files, not the 130 across 30 I
   first counted with a `\bbtn\b` pattern that matches inside `btn-circle`. */
html body .btn-neutral {
  background:   var(--btn-neutral-bg);
  color:        var(--btn-neutral-text);
  /* An inset ring, not a border: `border: none !important` above would have to be
     fought, and a real border would add 2px to this control's geometry alone. */
  box-shadow:   inset 0 0 0 1px var(--btn-neutral-border);
}
/* THE BOUNDARY SURVIVES EVERY STATE. It is an inset box-shadow, and box-shadow is
   not additive — any later rule that sets it REPLACES the ring rather than adding
   to it. The base focus rules below carry `!important`, so without the
   `.btn-neutral` overrides here the control loses its only visible boundary at
   precisely the moment attention is on it. Every state therefore restates the
   inset ring first and appends its own layer. */
html body .btn-neutral:hover {
  background:   color-mix(in srgb, var(--teal) 10%, var(--btn-neutral-bg));
  color:        var(--text-brand);
  /* The hover ring is teal AND still a boundary: 60% teal over the fill clears
     the same threshold the resting ring does. */
  box-shadow:   inset 0 0 0 1px var(--btn-neutral-border),
                inset 0 0 0 1px color-mix(in srgb, var(--teal) 60%, transparent);
}

html body .btn-neutral:active {
  background:   var(--btn-neutral-bg);
  box-shadow:   inset 0 0 0 1px var(--btn-neutral-border),
                inset 2px 2px 4px rgba(0,0,0,0.10);
}

/* ── focus, in two levels ─────────────────────────────────────
   The old rule was `var(--teal)` at 50% alpha, which composites against whatever
   is behind it and measured 1.9–2.1:1 — below the 3:1 an indicator has to reach
   to be one.

   Dropping `:focus` entirely was the first attempt and it was wrong in the other
   direction: `page-student-planner.js:308` moves focus to the rebuild-confirm
   button precisely so the reveal is not silent, and `:316` announces «اضغط
   «اعرض الجداول الممكنة»» and focuses that button. After a mouse interaction
   neither matches `:focus-visible`, so both landed with NO indicator at all.

   So both levels exist and differ: a programmatic or mouse focus is visible, a
   keyboard focus is stronger. The 2px gap is `--surface` rather than `--card`
   because the ring must survive on a saturated `.btn-primary`, whose own fill
   would otherwise swallow an inner ring drawn in the card colour. */
html body .btn:focus {
  outline: 2px solid transparent;   /* visible to Windows High Contrast */
  box-shadow: 0 0 0 2px var(--surface),
              0 0 0 4px color-mix(in srgb, var(--teal) 65%, transparent) !important;
}
html body .btn:focus-visible {
  outline: 2px solid transparent;
  box-shadow: 0 0 0 2px var(--surface),
              0 0 0 4px var(--teal) !important;
}
/* A disabled control must not look active. `pointer-events: none` stops the mouse
   but says nothing about a programmatic `.focus()`. */
html body .btn:disabled:focus,
html body .btn.disabled:focus {
  outline: none !important;
  box-shadow: var(--shadow-neu-sm) !important;
}

/*
 * MUST REMAIN AFTER THE SHARED .btn FOCUS RULES.
 * Both declarations are !important and have EQUAL specificity (0,2,2), so source
 * order alone decides. This rule preserves the neutral inset boundary while
 * focused; moved above, the boundary silently disappears.
 *
 * Not hypothetical: `html body .btn-neutral:focus` was first written believing it
 * outranked the shared rule at (0,3,2). `.btn-neutral` plus `:focus` is two
 * class-level selectors, exactly like `.btn:focus`. A browser probe caught it —
 * the focused control rendered two shadow layers instead of three, having dropped
 * the only boundary it has, precisely when attention is on it. box-shadow is not
 * additive; a later declaration replaces the whole list.
 * `tests/test_design_system_buttons.py` asserts the inset ring survives both
 * focus levels, so a formatter that reorders this file fails there.
 */
html body .btn-neutral:focus {
  box-shadow:   inset 0 0 0 1px var(--btn-neutral-border),
                0 0 0 2px var(--surface),
                0 0 0 4px color-mix(in srgb, var(--teal) 65%, transparent) !important;
}
html body .btn-neutral:focus-visible {
  box-shadow:   inset 0 0 0 1px var(--btn-neutral-border),
                0 0 0 2px var(--surface),
                0 0 0 4px var(--teal) !important;
}


/* ============================================================
   TOOL-PAGE COMPONENTS  (ux-*)
   ------------------------------------------------------------
   Shared building blocks for dense tool pages (boards, grids, inspectors),
   first used by the Timetable Workspace. Same `ux-` prefix as `.ux-toast`.
   Density rule: these surfaces are FLAT. Neumorphic depth reads as a
   control only when it stands alone; packed into a toolbar it is noise, and in
   dark mode its light edge (rgba(255,255,255,.02)) is invisible, so every
   control here draws a token ring that clears 3:1 instead (WCAG 1.4.11).
   Glass belongs to the one chrome band of a page, never to panes or cells.
   ============================================================ */

/* ── Toolbar ───────────────────────────────────────────────
   A row is as tall as its tallest control: the controls carry an explicit
   line-height (.btn-sm, .fb-search.fb-sm fields), so the row does not change
   with the font's metrics (Arabic was 172px of chrome, stage 3 L30). Never
   give a toolbar a fixed block size or clip it: it wraps, and with the WCAG
   1.4.12 text-spacing overrides its rows must be free to grow. */
.ux-toolbar {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: var(--space-3) var(--space-4);
  min-width: 0;
}
.ux-toolbar-group {
  display: inline-flex; align-items: center; gap: var(--space-2);
  min-width: 0;
}
.ux-sep {
  flex: none; align-self: center;
  width: 1px; height: 20px;
  background: var(--line-strong);
}
.ux-spacer { flex: 1 1 0; min-width: 0; }
/* A label inside a toolbar: what the next controls are about. */
.ux-toolbar-label {
  flex: none;
  color: var(--t3); font-size: var(--text-xs); font-weight: 600;
  white-space: nowrap;
}

/* ── Compact controls ────────────────────────────────────────
   .btn-sm is the toolbar size (--control-h-sm, set with the button rules). */
/* A square icon button. A size modifier only: it carries no surface, so it is
   always paired with a surface variant (btn-neutral, btn-primary …). */
html body .btn.btn-icon {
  width: var(--control-h-sm); min-width: var(--control-h-sm);
  height: var(--control-h-sm); min-height: var(--control-h-sm);
  padding: 0 !important;
  border-radius: var(--control-radius) !important;
}
html body .btn.btn-icon svg,
html body .btn.btn-icon .i { width: 16px; height: 16px; flex: none; }
/* A directional icon (undo, redo, an arrow) mirrors in a right-to-left page. */
html[dir="rtl"] .i-flip-rtl { transform: scaleX(-1); }

/* ── Split button: an action and its options as one control ─
   Markup: `.btn-split` > main `.btn` + `.btn.btn-split-caret` (+ its `.ux-menu`).
   Logical radii, so the joined edges are right in Arabic too. Two neutral halves
   each draw an inset ring; overlapping them by 1px leaves ONE 1px seam, not two.
   The half with focus rises above its sibling so its ring is not painted under. */
.btn-split { position: relative; display: inline-flex; align-items: stretch; flex: none; }
html body .btn-split > .btn:not(.btn-split-caret) {
  border-start-end-radius: 0 !important;
  border-end-end-radius:   0 !important;
}
html body .btn-split > .btn.btn-split-caret {
  position: relative;
  margin-inline-start: -1px;
  min-width: 30px;
  padding-inline: 7px !important;
  border-start-start-radius: 0 !important;
  border-end-start-radius:   0 !important;
}
/* Filled halves have no ring to share: draw the seam in the ink colour. */
.btn-split > .btn-primary.btn-split-caret::before {
  content: ''; position: absolute; inset-block: 7px; inset-inline-start: 0;
  width: 1px; background: currentColor; opacity: 0.4;
}
html body .btn-split > .btn:hover,
html body .btn-split > .btn:focus,
html body .btn-split > .btn:focus-visible { position: relative; z-index: 1; }
.btn-split-caret svg { width: 14px; height: 14px; }

/* ── Menu ───────────────────────────────────────────────────
   A menu is `[role=menu].ux-menu` holding `[role=menuitem]` buttons or links.
   Its open state is its inline `display` (`style="display:none"` closed), owned
   by static/js/ux-menu.js — so this rule never sets `display`. The script places
   it at its preferred edge of the control that opened it; on a phone it becomes a
   sheet across its toolbar. */
.ux-menu {
  box-sizing: border-box;
  position: absolute; top: 100%; inset-inline-start: 0;
  z-index: calc(var(--z-sticky) + 20);
  min-width: 240px; max-width: calc(100vw - 32px);
  max-height: min(440px, 70vh); overflow-y: auto;
  margin-top: 4px; padding: 4px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lift);
  text-align: start;
}
.ux-menu[data-align="end"] { inset-inline-start: auto; inset-inline-end: 0; }
.ux-menu-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  box-sizing: border-box; width: 100%; padding: 8px 10px;
  border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--t1);
  font: inherit; font-size: var(--text-sm); line-height: 1.4;
  text-align: start; text-decoration: none; white-space: normal;
  cursor: pointer;
}
.ux-menu-item:hover,
.ux-menu-item:focus-visible { background: color-mix(in srgb, var(--teal) 9%, transparent); color: var(--t0); }
.ux-menu-item:disabled,
.ux-menu-item[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; background: transparent; }
.ux-menu-title { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: inherit; }
.ux-menu-title svg { width: 14px; height: 14px; flex: none; opacity: 0.75; }
.ux-menu-desc { display: block; color: var(--t3); font-size: var(--text-xs); font-weight: 400; }
.ux-menu-item[data-tone="warning"] .ux-menu-title { color: var(--sev-warning); }
.ux-menu-sep { height: 1px; margin: 4px 6px; background: var(--line); }
.ux-menu-anchor { position: relative; display: inline-flex; flex: none; }
/* Phones: a menu is a sheet across its toolbar, 12px in from each side. The
   anchor stops being the containing block so the sheet can span the toolbar;
   ux-controls.js lifts it to sit just under the buttons that opened it. */
@media (max-width: 640px) {
  .ux-toolbar { position: relative; }
  .ux-toolbar .btn-split,
  .ux-toolbar .ux-menu-anchor { position: static; }
  .ux-toolbar .ux-menu {
    top: 100%; inset-inline: 12px !important;
    min-width: 0 !important; max-width: none;
  }
}

/* ── Segmented buttons (choose one of a few views) ───────────
   Buttons with `aria-current`, NOT a tablist: a tablist promises arrow-key tabs
   and owned panels. The track scrolls sideways when the items overflow. */
/* An empty segmented control means nothing (no scenario open, boards still
   loading): it takes no room. */
.ux-seg:empty { display: none; }
.ux-seg {
  display: flex; align-items: stretch; gap: 2px;
  min-width: 0; max-width: 100%;
  padding: 3px;
  border-radius: var(--radius-md);
  background: var(--btn-neutral-bg);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  overflow-x: auto; scrollbar-width: thin;
}
.ux-seg-item {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  min-height: 28px; padding: 3px 10px;
  border: 0; border-radius: var(--radius);
  background: transparent; color: var(--t2);
  font: inherit; font-size: var(--text-sm); font-weight: 500; line-height: 1.2;
  white-space: nowrap; cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.ux-seg-item:hover { background: color-mix(in srgb, var(--teal) 8%, transparent); color: var(--t0); }
.ux-seg-item[aria-current="true"],
.ux-seg-item[aria-current="page"],
.ux-seg-item[aria-checked="true"] {
  background: var(--card); color: var(--t0); font-weight: 600;
  box-shadow: 0 1px 2px rgba(17,17,68,0.10), inset 0 0 0 1px var(--btn-neutral-border);
}
html[data-theme="dark"] .ux-seg-item[aria-current="true"],
html[data-theme="dark"] .ux-seg-item[aria-current="page"],
html[data-theme="dark"] .ux-seg-item[aria-checked="true"] { background: var(--surface-2); }
.ux-seg-item:disabled { opacity: 0.5; cursor: not-allowed; }
/* The same control as a radio group: `<label class="ux-seg-item"><input type=radio>`. */
.ux-seg-item input {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
label.ux-seg-item { position: relative; }
.ux-seg-item:has(input:checked) {
  background: var(--card); color: var(--t0); font-weight: 600;
  box-shadow: 0 1px 2px rgba(17,17,68,0.10), inset 0 0 0 1px var(--btn-neutral-border);
}
html[data-theme="dark"] .ux-seg-item:has(input:checked) { background: var(--surface-2); }
.ux-seg-item:has(input:disabled) { opacity: 0.5; cursor: not-allowed; }
.ux-seg-item:focus-within { outline: 2px solid var(--teal); outline-offset: 1px; }
.ux-seg-meta { color: var(--t3); font-size: var(--text-2xs); font-weight: 600; font-variant-numeric: tabular-nums; }
.ux-seg-flag {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: var(--text-2xs); font-weight: 700; font-variant-numeric: tabular-nums;
}
.ux-seg-flag[data-tone="critical"] { color: var(--sev-critical); }
.ux-seg-flag[data-tone="warning"]  { color: var(--sev-warning); }

/* ── Overflow: a strip whose items may not fit (UXControls overflow) ──
   Markup: `.ux-overflow` wrapping ONE scroller, a `.ux-seg` or a `.ux-tabs`.
   ux-controls.js adds a scroll button at each inline end and keeps on the
   wrapper `data-overflow-start` / `data-overflow-end` while there is more to
   see that way; it keeps the item that has focus, else the active item
   (aria-current, aria-selected, aria-checked, .active, a checked radio), in
   view, clear of the cue, by scrolling the strip only; an item the keyboard
   focuses is revealed at once (the browser's own focus scroll leaves it
   under the cue). The cue is the button over the cut edge plus a fade of the items into it. The
   wrapper takes the scroller's place in the layout: size it, not the
   scroller. The buttons are for a pointer (the keyboard reaches every
   item), so they take no Tab stop and no focus; their 1px edge is a real
   border, so it shows in forced colours too (stage 3, L07, L16). The
   scroller's scroll-padding makes a script's scrollIntoView stop clear of
   the cue too (measured: 52px from the end edge with it, 0 without). */
.ux-overflow {
  --ux-overflow-cue: 52px;          /* the button (24px) and the fade beyond it */
  --ux-overflow-inset-block: 3px;
  --ux-overflow-inset-inline: 3px;
  position: relative;
  display: flex; align-items: stretch;
  min-width: 0; max-width: 100%;
}
.ux-overflow > :not(.ux-overflow-btn) {
  --ux-cue-start: 0px; --ux-cue-end: 0px;
  flex: 1 1 auto; min-width: 0; max-width: none;
  overflow-x: auto; scrollbar-width: none;
  scroll-padding-inline: var(--ux-overflow-cue);
  -webkit-mask-image: linear-gradient(to right,
    transparent calc(var(--ux-cue-start) / 2), #000 var(--ux-cue-start),
    #000 calc(100% - var(--ux-cue-end)), transparent calc(100% - var(--ux-cue-end) / 2));
  mask-image: linear-gradient(to right,
    transparent calc(var(--ux-cue-start) / 2), #000 var(--ux-cue-start),
    #000 calc(100% - var(--ux-cue-end)), transparent calc(100% - var(--ux-cue-end) / 2));
}
html[dir="rtl"] .ux-overflow > :not(.ux-overflow-btn) {
  -webkit-mask-image: linear-gradient(to left,
    transparent calc(var(--ux-cue-start) / 2), #000 var(--ux-cue-start),
    #000 calc(100% - var(--ux-cue-end)), transparent calc(100% - var(--ux-cue-end) / 2));
  mask-image: linear-gradient(to left,
    transparent calc(var(--ux-cue-start) / 2), #000 var(--ux-cue-start),
    #000 calc(100% - var(--ux-cue-end)), transparent calc(100% - var(--ux-cue-end) / 2));
}
.ux-overflow > :not(.ux-overflow-btn)::-webkit-scrollbar { display: none; }
.ux-overflow[data-overflow-start] > :not(.ux-overflow-btn) { --ux-cue-start: var(--ux-overflow-cue); }
.ux-overflow[data-overflow-end] > :not(.ux-overflow-btn) { --ux-cue-end: var(--ux-overflow-cue); }
/* A segmented track is drawn by the wrapper, so the fade takes the items and
   never the track; an empty one takes no room, as an empty .ux-seg. */
.ux-overflow:has(> .ux-seg) {
  border-radius: var(--radius-md);
  background: var(--btn-neutral-bg);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.ux-overflow > .ux-seg { border-radius: var(--radius-md); background: none; box-shadow: none; }
.ux-overflow:has(> .ux-seg:empty) { display: none; }
.ux-overflow:has(> .ux-tabs) { --ux-overflow-inset-block: 5px; --ux-overflow-inset-inline: 0px; }
.ux-overflow-btn {
  position: absolute; z-index: 1;
  inset-block: var(--ux-overflow-inset-block);
  display: none; align-items: center; justify-content: center;
  box-sizing: border-box; inline-size: 24px; min-block-size: 24px;
  margin: 0; padding: 0;
  /* --t4, not the neutral ring: the button sits on a segmented track as well
     as on a card, and its edge clears 3:1 against both, in both themes (the
     neutral ring is 2.95:1 on the dark track). */
  border: 1px solid var(--t4); border-radius: var(--radius-sm);
  background: var(--card); color: var(--t1);
  font: inherit; line-height: 1;
  cursor: pointer;
}
.ux-overflow-btn[data-ux-overflow-dir="start"] { inset-inline-start: var(--ux-overflow-inset-inline); }
.ux-overflow-btn[data-ux-overflow-dir="end"]   { inset-inline-end: var(--ux-overflow-inset-inline); }
.ux-overflow[data-overflow-start] > .ux-overflow-btn[data-ux-overflow-dir="start"],
.ux-overflow[data-overflow-end] > .ux-overflow-btn[data-ux-overflow-dir="end"] { display: inline-flex; }
.ux-overflow-btn:hover { background: color-mix(in srgb, var(--teal) 10%, var(--card)); color: var(--t0); }
.ux-overflow-btn svg { width: 14px; height: 14px; flex: none; }

/* ── Roving grids (UXControls.roving) ─────────────────────────
   A row of an ARIA grid drawn on a CSS grid groups its cells for assistive
   technology and leaves their placement to the table. A roving grid cell
   takes an inset ring, so tiled cells and a clipped table never hide it.
   `.ux-keys`: the keys of a keyboard region, shown while the keyboard is in
   it (the controller's `hint`) — placed after the region's scroller, never
   inside it, so it neither covers a stop nor scrolls away sideways. */
.ux-grid-row { display: contents; }
html body [role="gridcell"][tabindex]:focus-visible { outline-offset: -2px !important; box-shadow: none !important; }
.ux-keys {
  flex: none; margin: 0; padding: 6px 10px;
  background: var(--surface); border-top: 1px solid var(--line-strong);
  color: var(--t2); font-size: var(--text-xs);
}

/* ── Courses that left students without a section (TimetableHotspots) ──
   An optimise result's ranked list: the code isolated (an LTR code in an RTL
   line), the course name, and how many students it left out, pushed to the
   line's end. A critical start bar marks the list, with its count in words. */
.ux-hotspots { margin: 0 0 10px; }
.ux-hotspots-title { margin: 0; font-size: var(--text-sm); font-weight: 700; color: var(--sev-critical); }
.ux-hotspots-help { margin: 2px 0 6px; color: var(--t2); font-size: var(--text-xs); }
.ux-hotspots-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.ux-hotspots-row {
  display: flex; align-items: baseline; gap: 8px; min-width: 0;
  padding: 4px 8px; border-radius: var(--radius-sm);
  border-inline-start: 3px solid var(--sev-critical); background: var(--surface);
  font-size: var(--text-sm); color: var(--ink);
}
.ux-hotspots-code { font-weight: 700; flex: none; }
.ux-hotspots-name { min-width: 0; color: var(--t2); overflow-wrap: anywhere; }
.ux-hotspots-count { margin-inline-start: auto; flex: none; font-weight: 600; color: var(--sev-critical); white-space: nowrap; }
@media (forced-colors: active) { .ux-hotspots-row { border-inline-start-color: CanvasText; } }

/* ── Tabs (a real tablist: arrow keys, owned panels) ─────── */
.ux-tabs {
  display: flex; align-items: stretch; gap: 2px;
  border-bottom: 1px solid var(--line-strong);
  overflow-x: auto; scrollbar-width: none;
}
.ux-tab {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  flex: 1 0 auto; min-height: 38px; padding: 8px 10px 6px;
  border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  background: transparent; color: var(--t3);
  font: inherit; font-size: var(--text-sm); font-weight: 600;
  white-space: nowrap; cursor: pointer;
}
.ux-tab:hover { color: var(--t1); }
.ux-tab.active,
.ux-tab[aria-selected="true"] { color: var(--text-brand); border-bottom-color: var(--text-brand); }
.ux-tab-count {
  min-width: 18px; padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--surface-2); color: var(--t2);
  font-size: var(--text-2xs); font-weight: 700; line-height: 1.5;
  font-variant-numeric: tabular-nums; text-align: center;
}
.ux-tab-count:empty { display: none; }
/* 8% wash: the 12% --sev-critical-bg put the dark count at 4.4:1 */
.ux-tab-count[data-tone="critical"] { background: color-mix(in srgb, var(--sev-critical) 8%, transparent); color: var(--sev-critical); }
.ux-tab-count[data-tone="warning"]  { background: var(--sev-warning-bg);  color: var(--sev-warning); }

/* ── Stat strip: numbers that say scope, meaning and direction ─
   One `.ux-stat-group` per scope, each a heading plus a `<dl
   aria-labelledby>` of `.ux-stat` (`<div><dt>label</dt><dd>value</dd></div>`).
   Values stay neutral; a `data-tone` adds a start-edge bar and an icon, so the
   tone never rests on colour alone. "—" is unknown, never a coloured 0. */
.ux-stat-strip {
  display: flex; flex-wrap: wrap; align-items: stretch;
  gap: 6px 0; min-width: 0;
}
.ux-stat-group {
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0; padding-inline: 14px;
  border-inline-start: 1px solid var(--line-strong);
}
.ux-stat-group:first-child { padding-inline-start: 0; border-inline-start: 0; }
.ux-stat-scope {
  margin: 0;
  color: var(--t3); font-size: var(--text-2xs); font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase; white-space: nowrap;
}
/* Arabic letters join: spacing them apart breaks the word. */
html[dir="rtl"] .ux-stat-scope { letter-spacing: 0; text-transform: none; }
.ux-stat-group > dl { display: flex; flex-wrap: wrap; gap: 2px 4px; margin: 0; }
.ux-stat {
  position: relative;
  display: flex; flex-direction: column-reverse; justify-content: flex-end;
  min-width: 76px; max-width: 176px;
  padding: 2px 10px 2px 9px;
  border-inline-start: 2px solid transparent;
}
/* A label too long for its stat wraps rather than lose its end, and nothing
   cuts it: with the WCAG 1.4.12 text spacing "Meetings without a room" lost
   its last word to an ellipsis, and the box that cut it also cut 2px of the
   Arabic face's letters (stage 3, C2). At the default spacing every label
   fits on one line. */
.ux-stat > dt {
  color: var(--t3); font-size: var(--text-xs); font-weight: 500; line-height: 1.3;
}
.ux-stat > dd {
  display: flex; align-items: center; gap: 5px;
  margin: 0;
  color: var(--t0); font-size: var(--text-lg); font-weight: 700; line-height: 1.3;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.ux-stat-unit { color: var(--t3); font-size: var(--text-xs); font-weight: 600; }
.ux-stat[data-tone="critical"] { border-inline-start-color: var(--sev-critical); }
.ux-stat[data-tone="warning"]  { border-inline-start-color: var(--sev-warning); }
.ux-stat[data-tone="ok"]       { border-inline-start-color: color-mix(in srgb, var(--sev-ok) 55%, transparent); }
.ux-stat[data-tone="critical"] > dd::before,
.ux-stat[data-tone="warning"]  > dd::before,
.ux-stat[data-tone="ok"]       > dd::before {
  content: ''; flex: none; width: 14px; height: 14px;
  background: currentColor;
  -webkit-mask: var(--ux-tone-icon) center / contain no-repeat;
          mask: var(--ux-tone-icon) center / contain no-repeat;
}
.ux-stat[data-tone="critical"] > dd::before { color: var(--sev-critical); --ux-tone-icon: var(--ux-icon-critical); }
.ux-stat[data-tone="warning"]  > dd::before { color: var(--sev-warning);  --ux-tone-icon: var(--ux-icon-warning); }
.ux-stat[data-tone="ok"]       > dd::before { color: var(--sev-ok);       --ux-tone-icon: var(--ux-icon-ok); }
.ux-stat[data-tone="unknown"]  > dd { color: var(--t3); }
.ux-stat-note { color: var(--t3); font-size: var(--text-2xs); font-weight: 500; white-space: nowrap; }

/* Status icons as masks (data URIs; nothing for the static manifest to rewrite).
   Octagon = blocks something; triangle = lowers quality; check = meets its
   target; circle-i = context. The shape carries the meaning without colour.
   Padlock = its time is locked; link = another scenario also places it. */
:root {
  --ux-icon-lock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='11' width='16' height='10' rx='2'/%3E%3Cpath d='M8 11V7a4 4 0 0 1 8 0v4'/%3E%3C/svg%3E");
  --ux-icon-shared: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 13a5 5 0 0 0 7.07 0l3-3a5 5 0 0 0-7.07-7.07l-1.5 1.5'/%3E%3Cpath d='M14 11a5 5 0 0 0-7.07 0l-3 3a5 5 0 0 0 7.07 7.07l1.5-1.5'/%3E%3C/svg%3E");
  --ux-icon-critical: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='7.86 2 16.14 2 22 7.86 22 16.14 16.14 22 7.86 22 2 16.14 2 7.86'/%3E%3Cline x1='12' y1='8' x2='12' y2='12'/%3E%3Cline x1='12' y1='16' x2='12.01' y2='16'/%3E%3C/svg%3E");
  --ux-icon-warning: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z'/%3E%3Cline x1='12' y1='9' x2='12' y2='13'/%3E%3Cline x1='12' y1='17' x2='12.01' y2='17'/%3E%3C/svg%3E");
  --ux-icon-ok: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  --ux-icon-info: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='16' x2='12' y2='12'/%3E%3Cline x1='12' y1='8' x2='12.01' y2='8'/%3E%3C/svg%3E");
}
/* An inline status icon: `<span class="ux-tone-icon" data-tone="critical">`. */
.ux-tone-icon {
  display: inline-block; flex: none; width: 14px; height: 14px; vertical-align: -2px;
  background: currentColor;
  -webkit-mask: var(--ux-tone-icon, var(--ux-icon-info)) center / contain no-repeat;
          mask: var(--ux-tone-icon, var(--ux-icon-info)) center / contain no-repeat;
}
.ux-tone-icon[data-tone="critical"] { color: var(--sev-critical); --ux-tone-icon: var(--ux-icon-critical); }
.ux-tone-icon[data-tone="warning"]  { color: var(--sev-warning);  --ux-tone-icon: var(--ux-icon-warning); }
.ux-tone-icon[data-tone="ok"]       { color: var(--sev-ok);       --ux-tone-icon: var(--ux-icon-ok); }
.ux-tone-icon[data-tone="info"]     { color: var(--sev-info);     --ux-tone-icon: var(--ux-icon-info); }

/* A state icon in the text colour: `<span class="ux-icon" data-icon="lock"
   role="img" aria-label="…">`. Sized to its text by default. */
.ux-icon {
  display: inline-block; flex: none; width: 1em; height: 1em; vertical-align: -0.125em;
  background: currentColor;
  -webkit-mask: var(--ux-icon, var(--ux-icon-info)) center / contain no-repeat;
          mask: var(--ux-icon, var(--ux-icon-info)) center / contain no-repeat;
}
.ux-icon[data-icon="lock"]   { --ux-icon: var(--ux-icon-lock); }
.ux-icon[data-icon="shared"] { --ux-icon: var(--ux-icon-shared); }

/* ── Disclosure: a group whose header opens and closes it ─────
   `<button class="ux-disclosure-toggle" aria-expanded aria-controls>` holding
   its `.ux-disclosure-label` (which takes the free width), then anything that
   stays visible when closed (a count), then `.ux-disclosure-chevron`; the
   region it controls follows the button. ux-controls.js does the opening. */
.ux-disclosure-toggle {
  display: flex; align-items: center; gap: 6px;
  width: 100%; margin: 0; padding: 6px 4px;
  border: 0; border-radius: var(--radius-sm);
  background: transparent; color: inherit;
  font: inherit; font-weight: 700; text-align: start;
  cursor: pointer;
}
.ux-disclosure-toggle:hover { background: color-mix(in srgb, var(--t0) 5%, transparent); }
.ux-disclosure-label { flex: 1 1 auto; min-width: 0; }
/* The chevron is an L drawn with PHYSICAL borders (its corner bottom-right)
   and turned: 45deg points it down (open, either direction); closed, it points
   along the reading direction — right in LTR (-45deg), left in RTL (135deg).
   Logical borders would move the corner in RTL and every angle with it. */
.ux-disclosure-chevron {
  flex: none; margin-inline-start: auto;
  width: 8px; height: 8px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg); opacity: 0.7;
  transition: transform var(--dur-fast, 0.15s) var(--ease, ease);
}
.ux-disclosure-toggle[aria-expanded="false"] .ux-disclosure-chevron { transform: rotate(-45deg); }
[dir="rtl"] .ux-disclosure-toggle[aria-expanded="false"] .ux-disclosure-chevron { transform: rotate(135deg); }
@media (prefers-reduced-motion: reduce) { .ux-disclosure-chevron { transition: none; } }

/* ── Legend: what a page's marks mean ───────────────────────
   `<div class="ux-legend" role="note">` holding `.ux-legend-item`s, each a
   swatch (or icon) and its words. One quiet line that wraps; it is read once
   and then out of the way, so it sits after the content it explains. */
.ux-legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px;
  margin: 0; padding: 8px 2px;
  color: var(--t2); font-size: var(--text-xs); line-height: 1.4;
}
.ux-legend-title { color: var(--t2); font-weight: 700; }
.ux-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.ux-legend-swatch {
  flex: none; width: 16px; height: 12px; border-radius: 3px;
  background: var(--surface-2); border: 1px solid var(--btn-neutral-border, var(--line));
}

/* ── Pane: a titled region that scrolls on its own ──────────── */
.ux-pane {
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
  background: var(--card);
}
.ux-pane-head {
  display: flex; align-items: center; gap: var(--space-3);
  min-height: 40px; padding: 4px 6px 4px 12px;
  border-bottom: 1px solid var(--line);
}
.ux-pane-title {
  flex: 1 1 auto; min-width: 0; margin: 0;
  color: var(--t1); font-size: var(--text-sm); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ux-pane-body {
  flex: 1 1 auto; min-height: 0;
  overflow: auto; overscroll-behavior: contain;
}
/* Everything else in a pane keeps its height: a tab strip that scrolls sideways
   has a min-height of 0, and would otherwise be shrunk away by the body. */
.ux-pane > :not(.ux-pane-body) { flex: none; }

/* ── Meta line: "AIR2 · cap 40 · Dr Ahmad". The separator is CSS, so a part
   that is not rendered (or is [hidden]) leaves no stray dot behind. It ends
   the part before it, never starts the next: a part is one flex item, so
   when the line wraps the dot stays at the end of the line it closes and the
   next line starts with words (it used to start "· 2 meetings a week",
   stage 3 L29). ── */
.ux-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.35em; min-width: 0; }
.ux-meta > :not([hidden]):has(~ :not([hidden]))::after { content: '·'; margin-inline-start: 0.35em; color: var(--t4); }
/* A part written the other way from its line (a left-to-right time or code in
   an Arabic line, `<bdi dir="ltr">`) has its own ends swapped: its dot goes at
   its own start, which is the line's end side. */
.ux-meta:dir(rtl) > :dir(ltr):not([hidden]):has(~ :not([hidden]))::after,
.ux-meta:dir(ltr) > :dir(rtl):not([hidden]):has(~ :not([hidden]))::after { content: none; }
.ux-meta:dir(rtl) > :dir(ltr):not([hidden]):has(~ :not([hidden]))::before,
.ux-meta:dir(ltr) > :dir(rtl):not([hidden]):has(~ :not([hidden]))::before { content: '·'; margin-inline-end: 0.35em; color: var(--t4); }

/* ── Dialog: a native <dialog> form surface ────────────────── */
.ux-dialog {
  width: min(600px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  padding: 0; overflow: auto;
  border: 1px solid var(--line-strong); border-radius: var(--radius-lg);
  background: var(--card); color: var(--t1);
  box-shadow: var(--shadow-lift);
}
.ux-dialog::backdrop { background: rgba(12,20,35,0.5); }
/* The head's first child (the title, or the block holding the title and its
   sub-line) takes the row, so the close button after it sits at the end edge
   in either language. The flex item is that child, not the title inside it:
   the close button used to float right after the sub-line, 236px from the
   edge of the slot dialog (stage 3, L14). It may also be narrower than its
   longest word, which then breaks: a scenario name or label with no space in
   it wraps beside the close button instead of pushing it out of the dialog
   or running under it. */
.ux-dialog-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 6px; }
.ux-dialog-head > :first-child { flex: 1 1 auto; min-width: 0; overflow-wrap: break-word; }
.ux-dialog-title { margin: 0; color: var(--t0); font-size: var(--text-md); font-weight: 700; }
.ux-dialog-sub { margin: 4px 0 0; color: var(--t3); font-size: var(--text-xs); font-weight: 500; }
.ux-dialog-body { display: grid; gap: 16px; padding: 10px 20px 18px; }
/* A body that takes focus (a scrolling list, `tabindex="-1"`) draws its ring
   inside itself: outside, the dialog's edges cut it and the status line above
   the body covered it (L33). */
html body .ux-dialog-body:focus-visible { outline-offset: -2px !important; box-shadow: none !important; }
.ux-dialog-foot {
  display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
}
.ux-field { display: grid; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.ux-field-label { padding: 0; color: var(--t2); font-size: var(--text-xs); font-weight: 600; }
.ux-field-hint { margin: 0; color: var(--t3); font-size: var(--text-xs); }
.ux-field-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
/* A dialog that edits rows needs more room than one that chooses. */
.ux-dialog-wide { width: min(800px, calc(100vw - 32px)); }
/* A field's error, under it, named by the field's aria-describedby. */
.ux-field-error { margin: 2px 0 0; color: var(--sev-critical); font-size: var(--text-xs); font-weight: 600; }
/* A field the server refused: a critical edge, inside as well as out, so
   it reads at 3:1 beside the 1px edges of the fields around it. */
.ux-dialog [aria-invalid="true"] { border-color: var(--sev-critical); box-shadow: inset 0 0 0 1px var(--sev-critical); }

/* ── Rows: a list edited as rows (design record §7.2 item 6, 6f) ──
   `.ux-rows` is a table with one row per item: a row header (its number),
   text fields, then the row's own buttons (`.ux-rows-actions`, icon buttons
   named by the row). `.ux-rows-time` is a 24-hour time typed as text, left to
   right in either language, wide enough for "08:00" in a wide font;
   `.ux-rows-length` a computed value beside it, `.ux-rows-flags` the row's
   pills. `.ux-rows-grow` (the label's cell) takes the width the cells around
   it leave, each of those at least a fixed width, so two tables of one
   dialog line up. A row's error is a `.ux-field-error` in a full-width row
   under it. Below 560px each row is a
   two-line card: the number and the label, then the rest; the header row is
   hidden from sight only (each field keeps its name). */
.ux-rows { width: 100%; border-collapse: collapse; }
.ux-rows th { padding: 4px 6px; color: var(--t2); font-size: var(--text-xs); font-weight: 600; text-align: start; border-bottom: 1px solid var(--line-strong); }
.ux-rows td { padding: 4px 6px; vertical-align: middle; border-bottom: 1px solid var(--line); }
.ux-rows tbody th { min-width: 1.75rem; border-bottom-color: var(--line); font-variant-numeric: tabular-nums; }
.ux-rows tr:has(+ tr[data-error-for]:not([hidden])) > * { border-bottom: 0; }
.ux-rows :where(input) {
  box-sizing: border-box; inline-size: 100%; min-inline-size: 6rem; min-height: 32px;
  padding: 4px 8px; margin: 0;
  border: 1px solid var(--btn-neutral-border); border-radius: var(--radius-sm);
  background: var(--card); color: var(--t1);
  font: inherit; font-size: var(--text-sm);
}
.ux-rows-time { inline-size: 76px; min-inline-size: 76px; direction: ltr; text-align: center; font-variant-numeric: tabular-nums; }
.ux-rows-length { min-width: 4.5rem; color: var(--t2); font-size: var(--text-xs); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ux-rows-flags { min-width: 6.5rem; }
.ux-rows-grow { width: 100%; }
.ux-rows-actions { min-width: 6.5rem; white-space: nowrap; text-align: end; }
.ux-rows-actions .btn + .btn { margin-inline-start: 4px; }
.ux-rows-actions .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
@media (max-width: 560px) {
  .ux-rows thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .ux-rows tbody tr:not([hidden]) { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; padding: 6px 0; border-bottom: 1px solid var(--line); }
  .ux-rows tbody tr[data-error-for] { padding-top: 0; }
  .ux-rows tbody tr > * { width: auto; min-width: 0; padding: 0; border: 0; }
  .ux-rows tbody tr > td:nth-child(2) { flex: 1 1 calc(100% - 3rem); }
  .ux-rows tbody tr > td.ux-rows-actions { margin-inline-start: auto; }
  .ux-rows tbody tr > td[colspan] { flex: 1 1 100%; }
}
.ux-choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; }
.ux-choice {
  position: relative;
  display: grid; gap: 2px; padding: 10px 12px;
  border-radius: var(--radius); background: var(--btn-neutral-bg);
  box-shadow: inset 0 0 0 1px var(--btn-neutral-border);
  cursor: pointer;
}
.ux-choice input {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
.ux-choice-title { color: var(--t0); font-size: var(--text-sm); font-weight: 600; }
.ux-choice-desc { color: var(--t3); font-size: var(--text-xs); line-height: 1.45; }
.ux-choice:has(input:checked) {
  background: color-mix(in srgb, var(--teal) 9%, var(--card));
  box-shadow: inset 0 0 0 2px var(--text-brand);
}
.ux-choice:has(input:disabled) { opacity: 0.5; cursor: not-allowed; }
.ux-choice:focus-within { outline: 2px solid var(--teal); outline-offset: 2px; }

/* ── Choosing dialogs (UXControls.dialog) ────────────────────
   `.ux-dialog-scroll`: a long list scrolls inside the body while the head
   (the title) and the foot (the commit button) stay in view.
   `.ux-choice-list`: rows of `.ux-choice`, one native radio each; the page
   sets `aria-busy` on the list alone while it reads, so the status lines
   outside it are still announced. A `data-tone` row has a start-edge bar,
   with its verdict in words beside it, so the tone never rests on colour
   alone. `.ux-choice-static` is a row that cannot be chosen, its reason
   written in it (there are no disabled radios). */
.ux-dialog-scroll[open] { display: flex; flex-direction: column; overflow: hidden; }
.ux-dialog-scroll > form { display: flex; flex-direction: column; min-height: 0; }
.ux-dialog-scroll .ux-dialog-head,
.ux-dialog-scroll .ux-dialog-foot { flex: none; }
.ux-dialog-scroll .ux-dialog-body { min-height: 0; overflow: auto; overscroll-behavior: contain; }
/* A fieldset can be the list: no frame, and it may shrink in a narrow dialog. */
.ux-choice-list { display: grid; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; list-style: none; }
.ux-choice-list[aria-busy="true"] { opacity: .6; }
.ux-choice[data-tone] { border-inline-start: 3px solid transparent; }
.ux-choice[data-tone="critical"] { border-inline-start-color: var(--sev-critical); }
.ux-choice[data-tone="warning"]  { border-inline-start-color: var(--sev-warning); }
.ux-choice[data-tone="info"]     { border-inline-start-color: var(--sev-info); }
.ux-choice[data-tone="ok"]       { border-inline-start-color: color-mix(in srgb, var(--sev-ok) 55%, transparent); }
.ux-choice-static { cursor: default; }
.ux-choice-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ux-choice-status { margin: 0; color: var(--t3); font-size: var(--text-xs); }
/* A paragraph: no margins of its own, and it pushes the buttons to the end. */
.ux-dialog-foot-note { margin: 0; margin-inline-end: auto; color: var(--t2); font-size: var(--text-xs); }
/* Forced colours drop the row's shadow frame and its tint, and the radio is a
   clipped pixel. The row draws a real border; the chosen row a thick
   Highlight one, its padding trading for the width so nothing moves; the row
   with the keyboard an outline outside it. The two marks never share a
   property, so a chosen row that has the keyboard shows both. */
@media (forced-colors: active) {
  .ux-choice { border: 1px solid CanvasText; padding: 9px 11px; }
  .ux-choice[data-tone] { border-inline-start-color: CanvasText; }
  .ux-choice:has(input:checked) { border: 3px solid Highlight; padding: 7px 9px; }
  .ux-choice[data-tone]:has(input:checked) { padding-inline-start: 11px; }
  .ux-choice:focus-within { outline: 2px solid CanvasText; outline-offset: 2px; }
}

/* ── Job card: a long-running job, floating at the window's end edge ─
   Fixed, so nothing in the page moves when it appears (a banner would push the
   board down mid-drag). Holds the job's status, its fields and its Cancel. */
.ux-job {
  position: fixed; inset-block-end: 16px; inset-inline-end: 16px;
  z-index: var(--z-fixed-bar);
  width: min(380px, calc(100vw - 32px));
  padding: 12px 14px;
  background: var(--card); color: var(--t1);
  border: 1px solid var(--line-strong); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lift);
  font-size: var(--text-sm);
}
.ux-job-head { display: flex; align-items: center; gap: 8px; }
.ux-job-title { flex: 1 1 auto; min-width: 0; font-weight: 700; color: var(--t0); }
.ux-job-fields {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 12px;
  margin: 10px 0 0; font-size: var(--text-xs);
}
.ux-job-fields dt { color: var(--t3); font-weight: 500; }
.ux-job-fields dd { margin: 0; color: var(--t1); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.ux-job-message { margin: 8px 0 0; color: var(--t2); font-size: var(--text-xs); }
.ux-job-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* ── Status pill, neutral tone (idle, cancelled, unknown) ─────── */
.pill-n { background: var(--surface-2); color: var(--t2); }


/* ============================================================
   ACTIONS ROW
   ============================================================ */
.actions-row {
  display:         flex;
  gap:             0.5rem;
  row-gap:         0.5rem;
  flex-wrap:       wrap;
  align-items:     center;
  padding:         0.5rem;
  border:          none;
  border-radius:   var(--radius-lg);
  background:      var(--glass-bg);
  backdrop-filter: blur(12px);
  margin-bottom:   1rem;
  box-shadow:      var(--shadow-neu);
}

.actions-row .btn,
.actions-row .form-select,
.actions-row .form-control { min-height: 36px; }

@media (max-width: 1280px) and (min-width: 1024px) {
  .actions-row { gap: 0.35rem; }
  .actions-row .btn { font-size: var(--text-sm) !important; padding: 0.35rem 0.9rem !important; }
}

/* ── ≤1200px — Compact sidebar for mid-size screens ──────── */
@media (max-width: 1200px) {
  :root { --sb-w: 210px; }
  .sidebar { width: 210px; }

  .logo-area {
    padding: 14px 14px 16px;
    gap: 10px;
  }
  .logo-mark { width: 34px; height: 34px; border-radius: 9px; }
  .logo-mark .i { width: 18px; height: 18px; }
  .logo-title { font-size: 0.95rem; }
  .logo-sub  { margin-top: 2px; }

  .nav-lbl { padding: 10px 10px 3px; }
  .nav-a   { padding: 7px 10px; gap: 8px; margin: 1px 0; }
  .nav-a .i { width: 15px; height: 15px; }

  .s-foot { padding: 10px 12px; }
  .s-usr  { gap: 8px; }
  .avatar { width: 30px; height: 30px; }
  .s-usr-logout { width: 28px; height: 28px; }
  .s-usr-logout .i { width: 14px; height: 14px; }
  .s-lang select { padding: 3px 6px; }
}

#student .actions-row, #batch .actions-row, #plan .actions-row,
#prereq .actions-row, #eligibility .actions-row, #advisoradmin .actions-row,
#advisorportfolio .actions-row, #usermgmt .actions-row, #dbadmin .actions-row,
#exports .actions-row, #highpriority .actions-row { padding: 0.5rem; }

/* ============================================================
   TABLE WRAP
   ============================================================ */
.table-wrap {
  /* Viewport-relative, not a flat 420px. A fixed box meant a 13-row report got
     its own scrollbar INSIDE the page scrollbar on every screen, while a 27"
     monitor showed the same ten rows as a laptop. clamp() lets a short table
     render whole — no nested scrolling at all — and a long one use the height
     the screen actually has. */
  max-height:    clamp(340px, 70vh, 900px);
  overflow:      auto;
  /* The table sat in a translucent, blurred, neumorphic box. With the panels
     around it on the sheet, that box was the last card on the page — ten
     screens of data reading as an object instead of as the page's own content.
     The rule under the last row is the only edge it needs; its sticky header
     keeps its own fill (below), so rows cannot scroll up through it. */
  border:        none;
  border-block-end: 1px solid var(--rule);
  border-radius: 0;
  background:    none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow:    none;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.table-wrap tbody tr { transition: background .10s var(--ease); }

.table-wrap tbody tr:hover td { background: color-mix(in srgb, var(--teal) 7%, transparent); }

.table-wrap thead th {
  /* Sticky, so the column names survive scrolling. Ten rows in, "CS112(2.92)"
     under an unlabelled column is just a number.
     The fill must stay OPAQUE or the rows travel visibly underneath it — that
     is why the glass tint was composited over a solid colour rather than used
     alone. It composites over --bg now instead of --card: with the wrapper's
     own card gone, a white band was the only white left on the sheet. */
  position:      sticky;
  top:           0;
  z-index:       2;
  background:    linear-gradient(var(--glass-bg-header), var(--glass-bg-header)),
                 var(--bg) !important;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-bottom: 1px solid var(--rule-strong);
  cursor:        pointer;
  font-family:   var(--font-mono);
  font-weight:   700;
  font-size:     var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color:         var(--t3);
  padding:       0.55rem 0.75rem;
  text-align:    start;
  white-space:   nowrap;
  user-select:   none;
}

.table-wrap thead th:hover {
  background: linear-gradient(var(--glass-bg-data), var(--glass-bg-data)),
              var(--card) !important;
  color: var(--t3);
}

/* Sorted-column visual indicator */
.table-wrap thead th.sorted { color: var(--text-brand); }
.table-wrap thead th.sorted::after { content: ' \25B2'; font-size: var(--text-micro); opacity: 0.7; }
.table-wrap thead th.sorted.desc::after { content: ' \25BC'; }

.table-wrap tbody td {
  font-family:  var(--font-body);
  font-size:    var(--text-sm);
  vertical-align: middle;
  padding:      0.5rem 0.75rem;
  border-top:   1px solid var(--line);
  color:        var(--ink);
}

.table-wrap tbody tr:first-child td { border-top: none; }

.table-compact th,
.table-compact td { padding: 0.22rem 0.4rem !important; font-size: var(--text-sm); }

/* ============================================================
   CARD-ROW TABLE — Glassmorphic table rows (Taibah mockup)
   ============================================================ */
/* ── Table section wrapper ── */
.tbl-section { margin-bottom:24px; }
.tbl-header {
  display:flex; align-items:center; justify-content:space-between;
  margin-bottom:14px; padding:0 4px;
}
.tbl-title {
  font-family:var(--font-body); font-weight:700; font-size:var(--text-md); color:var(--navy);
  display:flex; align-items:center; gap:10px; line-height:1.1;
}
.tbl-cnt {
  font-family:var(--font-mono); font-size:var(--text-micro); font-weight:700;
  padding:3px 9px; border-radius:var(--radius-pill);
  background:var(--brand-soft); color:var(--text-brand); border:none;
  box-shadow:var(--shadow-neu-sm);
}
.tbl-actions { display:flex; gap:6px; }

.tbl-card { width:100%; border-collapse:collapse; }
.tbl-card thead th {
  font-size:var(--text-sm); font-weight:700; text-transform:uppercase;
  letter-spacing:0.08em; color:var(--t3); padding:0 14px 4px;
  font-family:var(--font-mono); cursor:pointer;
  user-select:none; transition:color .12s var(--ease); border:none;
  white-space:nowrap;
}
/* Arabic letters join and have no capitals: spacing them apart breaks the
   word, and the mono face has no Arabic glyphs (the fallback reads tiny). */
html[dir="rtl"] .tbl-card thead th { letter-spacing: 0; text-transform: none; font-family: inherit; }
/* `:not(.sp-plan-table)` is load-bearing: Section Planning's headers set their
   own padding and vertical alignment so the 11-column table still fits the
   pane in Arabic. */
.tbl-card:not(.sp-plan-table) thead th {
  border-bottom:1px solid var(--rule); padding-bottom:8px;
}

/* A sticky header needs a box that SCROLLS. With no scrolling ancestor the
   header sticks to the viewport instead and floats over the page, so this is
   opt-in per container rather than global: `.cp-scroll` marks the panel bodies
   that carry their own max-height and overflow. The fill must stay OPAQUE or
   rows travel visibly underneath it, and it composites over --bg so no white
   band appears on the sheet. */
/* Both selectors, because `.tbl-card thead th[data-sort]` below sets
   `position:relative` for the arrow and ties with the bare selector on
   specificity -- and it comes later, so it would win. The [data-sort] form here
   outranks it, and sticky anchors the arrow just as well as relative. */
.cp-scroll .tbl-card thead th,
.cp-scroll .tbl-card thead th[data-sort] {
  position:sticky; top:0; z-index:2;
  background: linear-gradient(var(--glass-bg-header), var(--glass-bg-header)),
              var(--bg);
}
.tbl-card thead th:hover { color:var(--t3); }
.tbl-card thead th[data-dir] { color:var(--text-brand); }

/* Sort affordance, driven by the attributes wireSortableTable actually sets.
   `.sorted` was never set by anything, and the two hand-written arrows in the
   markup never moved off "up". Opacity is the measured 0.75 from the rule this
   replaces -- the --t3 glyph is 3.4:1 (light) to 4.1:1 (dark) there, where the
   0.28 resting arrow this mirrors measured about 1.5:1. */
.tbl-card thead th[data-sort] { padding-inline-end:1.5rem; position:relative; }
.tbl-card thead th[data-sort]::after {
  content:'↕'; position:absolute; inset-inline-end:0.4rem; top:calc(50% - 2px);
  transform:translateY(-50%); opacity:0.75; font-size:0.7rem; transition:opacity .12s;
}
.tbl-card thead th[data-sort]:hover::after { opacity:1; }
.tbl-card thead th[data-sort][data-dir="asc"]::after  { content:'↑'; opacity:1; color:var(--text-brand); }
.tbl-card thead th[data-sort][data-dir="desc"]::after { content:'↓'; opacity:1; color:var(--text-brand); }

/* ── Card rows — glassmorphic table rows ── */
.tbl-card tbody tr.cr-row {
  background:none;
  backdrop-filter:none;
  -webkit-backdrop-filter:none;
  box-shadow:none;
  transition:background .10s var(--ease);
  cursor:pointer; position:relative;
}
.tbl-card tbody tr.cr-row td {
  padding:14px 14px; border:none;
  border-top:var(--border-subtle);
  border-bottom:var(--border-subtle);
  vertical-align:middle; font-size:var(--text-sm);
}
.tbl-card tbody tr.cr-row td:first-child {
  border-inline-start:3px solid transparent;
  transition:border-color .2s var(--ease);
}
.tbl-card tbody tr.cr-row:hover {
  background:color-mix(in srgb, var(--teal) 7%, transparent);
}
.tbl-card tbody tr.cr-row:hover td:first-child {
  border-inline-start-color:var(--teal);
}
[dir="rtl"] .tbl-card tbody tr.cr-row:hover td:first-child {
  border-inline-start-color:var(--teal);
}
.tbl-card tbody tr.cr-row.selected {
  background:color-mix(in srgb, var(--teal) 4%, transparent);
}
/* Without this the selected rule, which comes later and ties on specificity,
   would answer a hover over a selected row with a FAINTER wash than the row
   already had. */
.tbl-card tbody tr.cr-row.selected:hover {
  background:color-mix(in srgb, var(--teal) 10%, transparent);
}
.tbl-card tbody tr.cr-row.selected td:first-child {
  border-inline-start-color:var(--teal);
}
[dir="rtl"] .tbl-card tbody tr.cr-row.selected td:first-child {
  border-inline-start-color:var(--teal);
}



/* Cell typography */
.cr-id {
  font-family:var(--font-mono); font-size:var(--text-xs);
  font-weight:700; color:var(--text-brand);
  transition:text-shadow .2s var(--ease);
}
.tbl-card tbody tr.cr-row:hover .cr-id {
  text-shadow:0 0 8px color-mix(in srgb, var(--teal) 20%, transparent);
}
.cr-nm { color:var(--navy); font-weight:600; font-size:var(--text-sm); }
.cr-sub { font-size:var(--text-micro); color:var(--t4); margin-top:1px; font-weight:400; }
.cr-prog { font-size:var(--text-sm); color:var(--t2); font-weight:400; }
.cr-gpa {
  font-family:var(--font-mono); font-weight:700; font-size:var(--text-sm);
}
.cr-gpa-hi { color:var(--text-brand); }
.cr-gpa-md { color:var(--t1); }
.cr-gpa-lo { color:var(--danger); }

/* Progress bar */
.cr-bar { display:flex; align-items:center; gap:8px; }
.cr-track {
  width:56px; height:6px; border-radius:3px;
  background:var(--brand-soft); overflow:hidden;
  box-shadow:0 1px 2px rgba(0,0,0,0.03) inset;
}
.cr-fill { height:100%; border-radius:3px; }
.cr-fill-hi { background:linear-gradient(90deg, var(--teal), var(--sky)); }
.cr-fill-md { background:linear-gradient(90deg, var(--sky), var(--royal)); }
.cr-fill-lo { background:linear-gradient(90deg, var(--danger), var(--warning)); }
.cr-txt {
  font-family:var(--font-mono); font-size:var(--text-micro); color:var(--t4);
}

/* Row actions */
.cr-actions { display:flex; align-items:center; gap:5px; justify-content:flex-end; }
.btn-circle {
  width:32px; height:32px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  /* Dark got a ring in the split below; light had nothing left once the
     shadow flattened, leaving a bare glyph with no control boundary. */
  background:var(--btn-neutral-bg); border:none;
  color:var(--t3); cursor:pointer; transition:all .18s var(--ease);
  box-shadow:inset 0 0 0 1px var(--btn-neutral-border);
}
.btn-circle:hover {
  color:var(--text-brand);
  background:rgba(17,17,68,0.11);
  box-shadow:inset 0 0 0 1px var(--control-edge);
}
/* Same as the outline buttons: the press cue was the dished inset alone. */
.btn-circle:active {
  box-shadow:var(--shadow-neu-inset);
  background:color-mix(in srgb, var(--teal) 16%, transparent);
}
.btn-circle.ac {
  background:linear-gradient(135deg, var(--btn-primary-bg), var(--btn-primary-hover));
  color:var(--btn-primary-ink);
  box-shadow:none;
}
.btn-circle .i { width:14px; height:14px; }

/* Pagination — Taibah mockup */
.pg-bar {
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 22px; margin-top:4px;
  background:var(--glass-bg);
  backdrop-filter:blur(16px); -webkit-backdrop-filter:blur(16px);
  border:none; border-radius:var(--radius-sm);
  box-shadow:var(--shadow-neu-sm);
}
.pg-info { font-size:var(--text-xs); color:var(--t3); font-weight:500; }
.pg-info strong { color:var(--t1); font-weight:700; }
.pg-nav { display:flex; align-items:center; gap:4px; }
.pg-btn {
  width:32px; height:32px; border-radius:var(--radius-sm);
  display:flex; align-items:center; justify-content:center;
  background:var(--btn-neutral-bg); border:none;
  color:var(--t3); font-size:var(--text-xs); font-weight:600; cursor:pointer;
  transition:all .15s var(--ease); font-family:var(--font-mono);
  box-shadow:inset 0 0 0 1px var(--btn-neutral-border);
}
.pg-btn:hover { color:var(--t1); background:rgba(17,17,68,0.11); box-shadow:inset 0 0 0 1px var(--control-edge); }
/* The selected page kept its own dished pair, hard-coded rather than tokenised,
   so it survived the retirement. Its fill is what says "selected". */
.pg-btn.active { background:var(--btn-primary-bg); color:var(--btn-primary-ink); box-shadow:none; }
.pg-btn:disabled { opacity:0.5; pointer-events:none; }

/* ── Prereq Dependency Graph ── */
.prereq-svg { display:block;width:100%;height:auto;margin:0 auto }
.pg-edge { fill:none;stroke:var(--teal);stroke-width:2;stroke-opacity:0.4;transition:all .35s var(--ease) }
.pg-node { cursor:pointer }.pg-node rect{transition:all .35s var(--ease)}.pg-node text{transition:fill .35s var(--ease);pointer-events:none}
.pg-node:hover rect{stroke-width:2;filter:drop-shadow(0 2px 8px color-mix(in srgb, var(--teal) 25%, transparent))}
.pg-node:focus{outline:none}
.pg-node:focus-visible rect{stroke:var(--teal)!important;stroke-width:3;filter:drop-shadow(0 2px 8px color-mix(in srgb, var(--teal) 28%, transparent))}
.pg-node.hl rect{stroke:var(--teal)!important;stroke-width:2.2}
.pg-node.hl text{fill:var(--text-brand)!important}
.pg-edge.hl{stroke:var(--teal);stroke-width:3;stroke-opacity:0.9}
.pg-node.dm{opacity:0.16;transition:opacity .25s}.pg-edge.dm{opacity:0.06;transition:opacity .25s}
.pg-legend{display:flex;align-items:center;flex-wrap:wrap;gap:10px 18px;padding:14px 16px 2px;font-size:var(--text-xs);line-height:1.45;font-weight:600;color:var(--t2);font-family:var(--font-mono);letter-spacing:0.01em}
.pg-legend-dot{display:inline-block;width:10px;height:10px;border-radius:50%;margin-inline-end:6px;vertical-align:middle;box-shadow:0 0 5px currentColor}
.pg-legend-dash{display:inline-block;width:12px;height:0;border-block-start:1.5px dashed var(--t3);margin-inline-end:5px;vertical-align:middle}

/* term bands — the graph's vertical axis is the declared programme term */
.pg-band{fill:transparent}
.pg-band-alt{fill:color-mix(in srgb, var(--navy) 4.5%, transparent)}
.pg-band-rule{stroke:color-mix(in srgb, var(--navy) 12%, transparent);stroke-width:1}
.pg-gutter-rule{stroke:color-mix(in srgb, var(--navy) 15%, transparent);stroke-width:1.2}
.pg-band-lbl{font-family:var(--font-mono);font-size:var(--text-xs);font-weight:700;fill:var(--t2);letter-spacing:0.02em}
.pg-band-lbl-empty{opacity:0.45}
.pg-band-note{font-family:var(--font-mono);font-size:var(--text-xs);font-weight:600;fill:var(--t3);opacity:0.65;letter-spacing:0.01em}
.pg-node-gate rect{stroke-dasharray:4 3}
.pg-node-inferred rect{stroke-dasharray:5 3}
.pg-edge-warn{stroke:var(--pg-warn);stroke-opacity:0.55;stroke-dasharray:5 4}
.pg-edge-warn.hl{stroke:var(--pg-warn);stroke-opacity:0.95}
.pg-warn{
  display:flex;flex-wrap:wrap;align-items:baseline;gap:8px;margin:10px 16px 0;padding:8px 12px;
  border-radius:var(--radius);background:rgba(180,83,9,0.07);border:1px solid rgba(180,83,9,0.22);
  font-size:var(--text-xs);font-weight:600;color:var(--pg-warn);line-height:1.5;
}
.pg-warn-detail{font-family:var(--font-mono);font-weight:500;opacity:0.8}

/* layout toggle */
.pg-modes{display:flex;gap:2px;margin-inline-start:auto;padding:2px;border-radius:var(--radius-pill);background:color-mix(in srgb, var(--navy) 5%, transparent)}
.pg-mode{
  white-space:nowrap;
  min-height:32px;border:0;cursor:pointer;padding:6px 13px;border-radius:var(--radius-pill);background:transparent;
  font-family:var(--font-mono);font-size:var(--text-xs);font-weight:700;letter-spacing:0.01em;color:var(--t3);
  transition:all .25s var(--ease);
}
.pg-mode:hover{color:var(--t1)}
.pg-mode.is-on{background:var(--teal-dim);color:var(--text-brand);box-shadow:0 1px 3px rgba(17,17,68,0.08)}
.pg-mode:focus-visible{outline:2px solid var(--teal);outline-offset:1px}

/* ── Conflict Matrix ── */
.cm-table { border-collapse:separate;border-spacing:0;font-family:var(--font-mono);font-size:var(--text-xs);width:auto }
.cm-table th,.cm-table td{border:1px solid var(--line);border-right-color:var(--line-strong);border-bottom-color:var(--line-strong);padding:0;text-align:center;min-width:44px;height:34px}
.cm-corner { background:linear-gradient(135deg,var(--teal-dim),var(--royal-dim));position:sticky;inset-inline-start:0;top:0;z-index:3;border:none }
.cm-col-hdr{background:var(--glass-bg-header);position:sticky;top:0;z-index:2;padding:6px 2px;font-weight:700;font-size:var(--text-micro);color:var(--t2);letter-spacing:0.01em}
.cm-col-hdr span{writing-mode:vertical-lr;transform:rotate(180deg);white-space:nowrap}
/* Logical sides (stage 3, SW-27): in Arabic the row headers stick to the right, where the rows start. */
.cm-row-hdr{background:var(--glass-bg-header);position:sticky;inset-inline-start:0;z-index:1;font-weight:700;padding:4px 10px;text-align:start;white-space:nowrap;font-size:var(--text-xs);color:var(--t1);letter-spacing:0.02em}
.cm-cell { font-weight:600;font-size:var(--text-xs);transition:transform .1s var(--ease),box-shadow .1s var(--ease) }
.cm-cell:hover { transform:scale(1.15);box-shadow:0 0 8px rgba(0,0,0,0.15);z-index:4;position:relative;border-radius:3px }
.cm-diag{background:var(--glass-bg-data);color:var(--text-brand);font-weight:700;font-size:var(--text-micro);border:1px solid var(--teal-border) !important}
.cm-zero { color:var(--t4);font-weight:400;font-size:var(--text-micro) }
.cm-table tr:hover .cm-row-hdr{background:var(--brand-soft);color:var(--text-brand)}
.cm-table tr:hover td:not(.cm-diag){opacity:0.92}

/* ============================================================
   METRICS
   ============================================================ */
.metric {
  border:        0;
  border-top:    1px solid var(--rule);
  border-radius: 0;
  padding:       0.75rem 0;
  background:    none;
  height:        100%;
  box-shadow:    none;
  transition:    border-color .25s var(--ease);
  position:      relative;
  overflow:      visible;
}

/* The inset accent bar needed the card's rounded top to sit in; the tile's own
   opening rule now carries it. */
.metric::before { content: none; }

.metric:hover {
  transform:    none;
  box-shadow:   none;
  background:   none;
  border-color: var(--rule-strong);
}

.metric .k {
  font-family:    var(--font-mono);
  color:          var(--t4);
  font-size:      var(--text-micro);
  font-weight:    700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom:  0.35rem;
}

.metric .v {
  font-family:    var(--font-serif) !important;
  font-weight:    400;
  font-size:      clamp(1.25rem, 1.118rem + 0.56vw, 1.6rem); /* 20px → 25.6px */
  color:          var(--text-brand);
  letter-spacing: -0.02em;
  line-height:    1.1;
}

/* ============================================================
   MC — Enhanced Metric Cards (Taibah design)
   ============================================================ */
.mc {
  background:      none;
  border:          0;
  border-top:      1px solid var(--rule);
  border-radius:   0;
  padding:         16px 0;
  position:        relative;
  overflow:        visible;
  box-shadow:      none;
  transition:      border-color .25s var(--ease);
}
/* The glowing accent bar floated inside the card's rounded top, so with the
   card gone it had nothing to sit in. The tile's own opening rule carries the
   same signal, and takes --mc-c when the tile is colour-coded. */
.mc::before {
  content:''; position:absolute; top:-1px; inset-inline-start:0; inset-inline-end:0; height:1px;
  background: var(--mc-c, transparent); opacity:0.55; transition:opacity .25s var(--ease);
}
.mc:hover::before { opacity:0.9; }
/* A blurred teal orb bled out of the card's top corner. It was only ever
   visible because `overflow:hidden` clipped it into a corner wash, and on an
   unclipped sheet it would spill across its neighbours. */
.mc::after { content: none; }
/* Nothing is floating, so there is nothing to lift. Several .mc tiles are
   links, so the cue is a wash as well as the rule, not the rule alone. */
.mc:hover {
  transform: none;
  box-shadow: none;
  border-top-color: var(--rule-strong);
  background: color-mix(in srgb, var(--teal) 5%, transparent);
}

.mc-head { display:flex; align-items:center; gap:10px; margin-bottom:12px; }
.mc-icon {
  width:38px; height:38px; border-radius:var(--radius);
  display:flex; align-items:center; justify-content:center;
  border:none;
}
.mc-icon .i { width:18px; height:18px; }
.mc-lbl {
  font-size:var(--text-micro); font-weight:700; text-transform:uppercase;
  letter-spacing:0.07em; color:var(--t4);
}
.mc-val {
  font-family:var(--font-serif); letter-spacing:-0.02em; line-height:1;
  font-size:clamp(1.25rem, 0.955rem + 1.25vw, 1.75rem); /* 20px → 28px */
}
.mc-hero .mc-val { font-size:clamp(1.625rem, 1.273rem + 1.5vw, 2.25rem); /* 26px → 36px */ }
.mc-delta {
  font-size:var(--text-micro); margin-top:8px; font-weight:600;
  font-family:var(--font-mono); display:flex; align-items:center; gap:4px;
  color:var(--t4);
}
.mc-delta .up   { color:var(--text-brand); }
.mc-delta .dn   { color:var(--danger); }
.mc-delta .flat { color:var(--t3); }

/* Sparkline */
.spark { display:flex; align-items:flex-end; gap:2.5px; height:28px; margin-top:12px; }
.spark .b {
  flex:1; min-width:4px; border-radius:2px 2px 0 0;
  background:var(--mc-c, var(--teal)); opacity:0.1; transition:opacity .15s;
}
.spark .b:nth-last-child(1) { opacity:0.35; }
.spark .b:nth-last-child(2) { opacity:0.22; }
.spark .b:nth-last-child(3) { opacity:0.16; }
.spark .b:hover { opacity:0.45; }

/* MC color variants */
.mc-teal { --mc-c:var(--teal); }
.mc-teal .mc-icon  { background:color-mix(in srgb, var(--teal) 8%, transparent); color:var(--text-brand); }
.mc-teal .mc-val   { color:var(--t0); }

.mc-royal { --mc-c:var(--royal); }
.mc-royal .mc-icon { background:rgba(64,86,227,0.08); color:var(--royal); }
.mc-royal .mc-val  { color:var(--t0); }

.mc-err { --mc-c:var(--danger); }
.mc-err .mc-icon   { background:rgba(192,48,48,0.08); color:var(--danger); }
.mc-err .mc-val    { color:var(--danger); }

.mc-sky { --mc-c:var(--sky); }
.mc-sky .mc-icon   { background:rgba(0,174,218,0.08); color:var(--sky); }
.mc-sky .mc-val    { color:var(--t0); }

.mc-warn { --mc-c:var(--warning); }
.mc-warn .mc-icon  { background:rgba(154,106,8,0.08); color:var(--sev-warning); }
.mc-warn .mc-val   { color:var(--sev-warning); }

/* ── Page summary line ──────────────────────────────────────────────
   What the .mc tile rows became. A row of them cost 111px of a 950px viewport
   -- a third of the chrome above the fold -- while largely restating the
   filter the user had just typed: "PROGRAM / COE" sat two rows under the box
   they typed COE into. The same figures read fine on one ~41px line, so the
   graph and the table a screen exists for start above the fold.
   The containers keep their ids and their d-none, and the values keep theirs,
   so the JS that fills all six is untouched.
   ──────────────────────────────────────────────────────────────────── */
.page-summary {
  display:     flex;
  flex-wrap:   wrap;
  align-items: baseline;
  row-gap:     6px;
  padding:     10px 0;
  border-top:  1px solid var(--rule);
}
.ps-item { display:inline-flex; align-items:baseline; gap:7px; }
/* The separator belongs to the item that FOLLOWS it, so a line that wraps
   never opens with a stray dot. */
.ps-item:not(:first-child)::before {
  content:'·'; color:var(--t4); opacity:0.55; margin:0 14px;
}
.ps-lbl {
  font-size:var(--text-micro); font-weight:700; text-transform:uppercase;
  letter-spacing:0.07em; color:var(--t4); white-space:nowrap;
}
/* Arabic letters join and have no capitals: spacing them apart breaks the word. */
html[dir="rtl"] .ps-lbl { letter-spacing:0; text-transform:none; }
.ps-val {
  font-family:var(--font-serif); font-size:var(--text-lg); line-height:1.25;
  letter-spacing:-0.01em; color:var(--t0); white-space:nowrap;
}
/* Severity keeps its colour, because here the colour is the message. The
   decorative tones deliberately do not: the tile row's three differently
   coloured peer figures are what the summary line set out to fix. */
.ps-item.mc-err  .ps-val { color:var(--sev-critical); }
.ps-item.mc-warn .ps-val { color:var(--sev-warning); }

/* The student panel's sparklines ride along -- they are data, not a restated
   filter -- at line height rather than the 28px tile height. */
.ps-item .spark { height:14px; margin:0; align-self:center; }

/* ============================================================
   REC — Recommendation Item Cards
   ============================================================ */
.rec {
  display:flex; align-items:center; justify-content:space-between;
  padding:11px 14px; border:var(--border-subtle);
  border-radius:var(--radius-sm); margin-bottom:7px; cursor:pointer;
  transition:all .15s var(--ease); position:relative; overflow:hidden;
  background:var(--glass-bg);
  box-shadow:0 1px 0 var(--glass-bg-header) inset;
}
.rec:last-child { margin-bottom:0; }
.rec:hover {
  border-color:var(--teal-border); background:color-mix(in srgb, var(--teal) 4%, transparent);
  transform:translateX(4px);
  box-shadow:0 1px 0 rgba(255,255,255,0.3) inset, -3px 0 0 var(--teal);
}
[dir="rtl"] .rec:hover {
  transform:translateX(-4px);
  box-shadow:0 1px 0 rgba(255,255,255,0.3) inset, 3px 0 0 var(--teal);
}
.rec-code {
  font-family:var(--font-mono); font-size:var(--text-xs); font-weight:700; color:var(--text-brand);
}
.rec-name { font-size:var(--text-sm); color:var(--navy); font-weight:600; margin-top:2px; }
.rec-pre  { font-size:var(--text-micro); color:var(--t3); margin-top:2px; font-family:var(--font-mono); }

/* ============================================================
   PILL — Status Pills with Dot Indicators
   ============================================================ */
.pill-status {
  display:inline-flex; align-items:center; gap:5px;
  padding:3px 10px; border-radius:var(--radius-pill);
  font-size:var(--text-2xs); /* ≥11px: the old clamp reached 10px */ font-weight:600; border:none;
  position:relative;
  box-shadow:var(--shadow-neu-sm);
}
.pill-status::before {
  content:''; position:absolute; top:0; inset-inline-start:0; inset-inline-end:0; height:50%;
  background:linear-gradient(180deg, rgba(255,255,255,0.3), transparent);
  border-radius:var(--radius-pill) var(--radius-pill) 0 0; pointer-events:none;
}
.pill-dot {
  width:5px; height:5px; border-radius:50%;
  background:currentColor; box-shadow:0 0 4px currentColor;
}
/* Status pills speak the severity vocabulary: each ink clears 4.5:1 on its own
   7% tint of --card in both themes (tests/test_design_system_tokens.py).
   The old inks were --warning on a 6% tint (the workspace's "Draft", 4.17:1)
   and --teal (3.81:1 on its tint). */
.pill-g { --pill-ink:var(--sev-ok); }
.pill-r { --pill-ink:var(--sev-critical); }
.pill-a { --pill-ink:var(--sev-warning); }
.pill-b { --pill-ink:var(--sev-info); }
/* An opaque tint of the card, so the pair is a property of the tokens and not
   of whatever glass the pill sits on (a 9% wash over the page measured 4.46:1). */
.pill-g, .pill-r, .pill-a, .pill-b {
  background:color-mix(in srgb, var(--pill-ink) 7%, var(--card));
  color:var(--pill-ink);
}
/* Inside a toolbar a pill is flat, like every other toolbar surface (the
   TOOL-PAGE COMPONENTS density rule): no neumorphic depth, no gloss. */
.ux-toolbar .pill-status,
html[data-theme="dark"] .ux-toolbar .pill-status { box-shadow:none !important; }
.ux-toolbar .pill-status::before { content:none; }
.pill-muted { background:var(--surface-2); color:var(--t3); }

/* ============================================================
   FILTER BAR — Glassmorphic toolbar
   ============================================================ */
/* A translucent card with a neumorphic shadow, wrapped around controls that
   are themselves outlined pills — a box inside a box, on thirteen screens. It
   is a ruled band now: the controls keep their own edges and the rule says
   where the bar ends.

   The background is opaque --bg rather than `none` ON PURPOSE. This bar is
   sticky on several screens (.sticky-cta raises it to z-index 6), and a sticky
   bar with a transparent background lets the rows it is pinned over show
   through it. --bg is the sheet it sits on, so it still reads as flush. */
.filter-bar {
  display:flex; align-items:center; gap:10px; margin-bottom:18px;
  padding:12px 0;
  background:var(--bg);
  backdrop-filter:none;
  -webkit-backdrop-filter:none;
  border:none;
  border-block-end:1px solid var(--rule);
  border-radius:0;
  box-shadow:none;
  flex-wrap:wrap;
}
/* The three places that are still a card on purpose: a bar inside one must
   match ITS surface, or --bg paints a cream strip across a white drawer. */
.drawer .filter-bar,
.dlg-box .filter-bar,
.matrix-fullscreen .filter-bar { background: var(--card); }
/* A field capsule (icon + input/select) is a default-tier control: the height
   comes from the ladder, not from the input's padding and line box (it was 37px
   beside a 38px button, 46px in Arabic and 31px on a phone). */
.fb-search {
  display:flex; align-items:center; gap:8px; flex:1; max-width:320px;
  min-height:var(--control-h);
  padding:0 var(--control-px-sm); border-radius:var(--control-radius);
  background:transparent; border:none;
  box-shadow:inset 0 0 0 1px var(--control-edge), var(--shadow-neu-inset);
  transition:box-shadow .25s var(--ease);
  overflow:hidden;
}
.fb-search:focus-within {
  background:transparent;
  box-shadow:inset 0 0 0 1px var(--teal), var(--shadow-neu-inset),
             0 0 0 2px var(--teal);
}
.fb-search .i { color:var(--t4); }
.fb-search input {
  flex:1; background:transparent; border:none; outline:none;
  box-shadow:none; color:var(--t1); font-size:var(--field-fs); font-family:inherit;
  line-height:var(--control-lh);
  padding:0;
  /* the whole capsule height is the field's hit area */
  align-self:stretch;
}
.fb-search input:focus,
.fb-search input:focus-visible {
  outline:    none !important;
  box-shadow: none !important;
  background: transparent !important;
}
.fb-search input:-webkit-autofill,
.fb-search input:-webkit-autofill:hover,
.fb-search input:-webkit-autofill:focus,
.fb-search input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--t1) !important;
  caret-color: var(--t1);
  transition: background-color 9999s ease-in-out 0s,
              color 9999s ease-in-out 0s !important;
}
.fb-search input::placeholder { color:var(--t4); }
/* a long placeholder ends in an ellipsis instead of being cut mid-word */
.fb-search input { text-overflow: ellipsis; }
/* Datalist inputs: position the native dropdown arrow cleanly */
.fb-search input[list] { padding-inline-end: 0.25rem; }
.fb-search input[list]::-webkit-calendar-picker-indicator {
  color: var(--t4); cursor: pointer; margin-inline-start: 4px; flex-shrink: 0;
}
.fb-search select {
  flex:1; min-width:0; width:100%;
  background:transparent; border:none; outline:none;
  box-shadow:none; color:var(--t1); font-size:var(--field-fs); font-family:inherit;
  line-height:var(--control-lh);
  padding:0; cursor:pointer; align-self:stretch;
  -webkit-appearance:none; -moz-appearance:none; appearance:none;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239aa5b4'/%3E%3C/svg%3E");
  background-repeat:no-repeat;
  background-position:right 0.4rem center;
  padding-inline-end:1.5rem;
  text-overflow:ellipsis;
}
.fb-search select:focus,
.fb-search select:focus-visible {
  outline:    none !important;
  box-shadow: none !important;
  background-color: transparent !important;
}
.fb-spacer { flex:1; }
/* This was `background: transparent; border: none` with the neumorphic shadow
   as its ONLY boundary, so flattening that shadow left it at 1.00:1 against the
   sheet — a button with no edge at all, which is a WCAG 1.4.11 failure, not a
   style choice. It takes the neutral-control pair the design system already
   measured for this exact job (the tokens' own comment: the fill lands at
   1.15:1 on four different backdrops and the border alpha was COMPUTED to
   clear 3:1 on the hardest of them, with headroom).

   The ring is an inset shadow rather than a border so the control's box does
   not grow by 2px and re-wrap every bar it sits in. */
.fb-dd {
  display:flex; align-items:center; gap:6px;
  /* a default-tier control, the height of the capsules and buttons beside it */
  min-height:var(--control-h); line-height:var(--control-lh);
  padding:0 var(--control-px-sm); border-radius:var(--control-radius);
  background:var(--btn-neutral-bg); border:none;
  font-size:var(--control-fs-sm); font-weight:600; color:var(--t2);
  cursor:pointer; transition:all .18s var(--ease);
  box-shadow:inset 0 0 0 1px var(--btn-neutral-border);
  backdrop-filter:none;
}
.fb-dd:hover { box-shadow:inset 0 0 0 1px var(--control-edge); background:rgba(17,17,68,0.11); color:var(--t1); }
/* Selected. The old cue was raised-versus-dished; flat, the only difference
   left was hue, which is not a cue for everyone. Weight carries it too. */
.fb-dd.active { background:var(--brand-soft); color:var(--text-brand); font-weight:700; box-shadow:inset 0 0 0 1px var(--teal); }
.fb-dd .i { opacity:0.4; }
.fb-dd-count {
  display:inline-flex; align-items:center; justify-content:center;
  min-width:20px; height:18px; padding:0 5px;
  border-radius:var(--radius); font-family:var(--font-mono); font-size:var(--text-micro); font-weight:700;
  background:color-mix(in srgb, var(--teal) 10%, transparent); color:var(--text-brand); margin-inline-start:4px;
}
.fb-dd.active .fb-dd-count { background:color-mix(in srgb, var(--teal) 20%, transparent); }

/* ── Filter bar that fits its fields (opt-in: .fb-fit) ─────────────────
   Put .fb-fit on a .filter-bar, or on any row of .fb-search capsules, and
   each capsule is as wide as what it shows instead of squeezed or capped:
   every pre-filled value and placeholder shows whole, at every width, in
   English and Arabic, in any font. Section Planning set the pattern
   (.sp-page .sp-fb-*). A bar without .fb-fit is unchanged.
   - An <input> is 12ch unless it carries a width below. Widths are in ch
     of the field's own font, so a wider font widens the field with it.
   - A <select> is as wide as its longest option.
   - .fb-grow on a capsule: it takes the bar's spare room (a search box).
   - .fb-actions: the bar's buttons (or its counts) as one unit at its
     end; they wrap together, never one left alone on a line.
   - .fb-tail: the bar's last field and its .fb-actions, when that holds a
     single button: they wrap as one unit (Section Planning's Section and
     its actions), so the button never sits alone on a line. The field
     stays right after its siblings; the button keeps the bar's end. */
.fb-fit .fb-search { flex: 0 0 auto; min-width: 0; max-width: 100%; }
.fb-fit .fb-search > .i { flex: none; }
.fb-fit .fb-lbl { flex: none; white-space: nowrap; }
.fb-fit .fb-search > input { flex: 0 1 auto; min-width: 0; width: 12ch; font-variant-numeric: tabular-nums; }
.fb-fit .fb-search > select { flex: 0 1 auto; min-width: 0; width: auto; }
/* A digit or a letter (1, M). `ch` is the width of "0" in the first font of
   the stack, and Arabic's face draws it narrow: 3ch was 22px there (L31), so
   the field keeps a 28px floor in any font. */
.fb-fit .fb-search > .fb-w-3ch { width: 3ch; min-width: 28px; }
.fb-fit .fb-search > .fb-w-6ch { width: 6ch; }     /* a year, a limit, "Sem" */
.fb-fit .fb-search > .fb-w-9ch { width: 9ch; }     /* "Semester", "Section", "Program" */
.fb-fit .fb-search > .fb-w-12ch { width: 12ch; }   /* a student ID, "Join yrs" in Arabic */
.fb-fit .fb-search > .fb-w-16ch { width: 16ch; }   /* "Program (optional)", a few codes */
.fb-fit .fb-search > .fb-w-20ch { width: 20ch; }   /* a search placeholder */
.fb-fit .fb-search > .fb-w-34ch { width: 34ch; }   /* a file path */
.fb-fit .fb-search.fb-grow { flex: 1 1 auto; max-width: 26rem; }
.fb-fit .fb-grow > input,
.fb-fit .fb-search-full > input { flex: 1 1 auto; }
.fb-fit .fb-actions { display: flex; align-items: center; gap: 10px; flex: none; margin-inline-start: auto; }
/* Grows into the line's spare room, so its button's auto margin reaches the
   bar's end. It wraps inside only when it alone is wider than the bar. */
.fb-fit .fb-tail { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; flex: 1 1 auto; min-width: 0; }
/* On a phone the tail's button takes the rest of its line, with the bar's
   phone gap: beside its field it widens into the room left, and where the
   field fills a line (a long select) it spans the bar, an action row rather
   than a small button left alone. */
@media (max-width: 480px) {
  .fb-fit .fb-tail { gap: 6px; }
  /* Every fit bar's action group, tail or not: once a phone's 16px field text
     widens the capsules, a button that wraps spans its line (an action row)
     instead of sitting alone at one end of it. */
  .fb-fit .fb-actions { flex: 1 0 auto; }
  .fb-fit .fb-actions > .btn { flex: 1 1 auto; }
}
/* .sticky-cta's accent line is a 0-wide flex item in a bar: it never draws,
   but it took a gap and started the bar's first line 10px in from the rest. */
.fb-fit.sticky-cta::before { display: none; }
/* The capsule is the field: a keyboard user sees a full-strength ring,
   in dark mode too (the shared dark glow is a 20% ring set !important). */
.fb-fit .fb-search:focus-within { box-shadow: var(--shadow-neu-inset), 0 0 0 2px var(--teal); }
html[data-theme="dark"] .fb-fit .fb-search:focus-within { box-shadow: inset 0 1px 3px rgba(0,0,0,0.2), 0 0 0 2px var(--teal) !important; }
/* A select's arrow sits at its inline end, where its padding is: the left in Arabic. */
html[dir="rtl"] .fb-fit .fb-search select { background-position: left 0.4rem center; }

/* ── Compact capsule: .fb-search.fb-sm ─────────────────────
   The 32px field for a dense toolbar, the same height as .btn-sm beside it. Flat,
   with the neutral button's measured ≥3:1 ring as its edge (density rule, see
   TOOL-PAGE COMPONENTS); the label is the small secondary text. The .fb-fit focus
   ring above still applies. */
.fb-search.fb-sm {
  min-height: var(--control-h-sm); padding: 0 0.6rem; gap: 6px;
  border-radius: var(--control-radius);
  background: var(--btn-neutral-bg);
  box-shadow: inset 0 0 0 1px var(--btn-neutral-border);
}
html[data-theme="dark"] .fb-search.fb-sm { box-shadow: inset 0 0 0 1px var(--btn-neutral-border) !important; }
/* An explicit line-height, as .btn-sm's: with `normal` the Arabic face's line
   box made the field, and its toolbar row, 34.6px instead of 32px (L30). */
.fb-search.fb-sm input,
.fb-search.fb-sm select { padding: 0; font-size: var(--field-fs-sm); line-height: var(--control-lh); }
/* ONE height tier per bar. A filter bar of default capsules lines its buttons
   and dropdown chips up at the default height (a dashboard bar measured
   37/36/38/32px side by side); a bar that carries compact capsules, or says it
   is compact, takes the compact tier for all of them. */
.filter-bar:not(.filter-bar-sm):not(:has(.fb-sm)) :is(.btn:not(.btn-icon), .fb-dd) { min-height: var(--control-h); }
:is(.filter-bar-sm, .filter-bar:has(.fb-sm)) :is(.btn:not(.btn-icon), .fb-dd, .fb-search) { min-height: var(--control-h-sm); }
.fb-search.fb-sm select { padding-inline-end: 1.3rem; background-position: right 0.15rem center; }
html[dir="rtl"] .fb-search.fb-sm select { background-position: left 0.15rem center; }
/* A field's name stays visible next to its value: a capsule that opens holding
   "1448" or "80" said nothing once the placeholder had gone. */
.fb-lbl { flex: none; white-space: nowrap; color: var(--t3); font-size: var(--text-xs); font-weight: 600; }
.fb-search.fb-sm > svg { width: 14px; height: 14px; flex: none; color: var(--t3); }
.fb-fit .fb-search.fb-sm:focus-within { box-shadow: inset 0 0 0 1px var(--btn-neutral-border), 0 0 0 2px var(--teal); }
html[data-theme="dark"] .fb-fit .fb-search.fb-sm:focus-within { box-shadow: inset 0 0 0 1px var(--btn-neutral-border), 0 0 0 2px var(--teal) !important; }

/* ============================================================
   CPANEL — Bottom Panel Cards (Recommendations, Activity)
   ============================================================ */
.cpanel {  overflow:visible;
  transition:border-color .25s var(--ease);
}
.cpanel:hover { box-shadow:none; border-color:var(--rule-strong); }
/* The same teal-sky-royal wash the page mesh and the dashboard hero carried.
   The panel's opening rule is the divider now, so this is a second line drawn
   under the first. */
.cpanel::before { content: none; }
/* The panel's header kept a translucent-white band, which on the sheet showed
   as a pale stripe across an otherwise flat section. The panel's own opening
   rule already separates it; this just needs its own baseline. */
.cp-h {
  padding:14px 0; border-block-end:1px solid var(--rule);
  display:flex; align-items:center; gap:9px; background:none;
}
/* a panel header that holds the graph's layout switch lets it take its own
   line on a phone ("By / term" broke inside the pill) */
.cp-h:has(.pg-modes) { flex-wrap:wrap; row-gap:8px; }
.cp-t { font-size:var(--text-base); font-weight:700; color:var(--t1); }
.cp-live {
  font-family:var(--font-mono); font-size:var(--text-micro); font-weight:700;
  padding:2px 8px; border-radius:var(--radius-pill);
  background:var(--teal-dim); color:var(--text-brand); border:1px solid var(--teal-border);
  /* (no perpetual pulse: a badge that never stops moving pulls the eye from the
     data it labels) */
}
.cp-b { padding:16px 20px; }

/* ============================================================
   STICKY-CTA — Gradient accent line
   ============================================================ */
/* Same rainbow strip as .cpanel carried, above a bar that now rules itself. */
.sticky-cta::before { content: none; }

/* ============================================================
   STATUS INDICATORS
   ============================================================ */
.status-dot {
  display:        inline-block;
  width:          0.55rem;
  height:         0.55rem;
  border-radius:  50%;
  margin-inline-end: 0.4rem;
  vertical-align: middle;
}

/* Scoped to the dot. Unscoped, these painted ANY element carrying the same state
   class — the planner job card's `.pr8-status-pill.status-running` became a
   pulsing mint block with light text on it. Every dot pairs `status-dot` with them
   (dashboard scrape indicator), so scoping changes no dot. */
.status-dot.status-running {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(18,162,89,.20);
  animation:  pulse-green 2s infinite;
}

.status-dot.status-stopped { background: var(--muted); }
.status-dot.status-failed { background: var(--danger); }

@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 0 3px rgba(18,162,89,.20); }
  50%       { box-shadow: 0 0 0 6px rgba(18,162,89,.04); }
}

.status-passed td           { background: color-mix(in srgb, var(--teal) 4%, transparent) !important; }
.status-studying td         { background: rgba(64,86,227,0.04) !important; }
.status-can-register td     { background: rgba(0,174,218,0.04) !important; }

/* ============================================================
   PILLS & CHIPS
   ============================================================ */
.pill {
  display:       inline-block;
  background:    var(--royal-dim);
  color:         var(--royal);
  border:        1px solid var(--royal-border);
  border-radius: var(--radius-pill);
  padding:       0.2rem 0.6rem;
  margin:        0.15rem;
  font-family:   var(--font-mono);
  font-size:     var(--text-xs);
  font-weight:   600;
  letter-spacing: 0.01em;
}

.top-chip {
  display: inline-block; background: var(--teal-dim); color: var(--text-brand);
  border: 1px solid var(--teal-border); border-radius: var(--radius-pill);
  padding: 0.22rem 0.6rem; margin: 0.18rem; font-size: var(--text-sm); font-weight: 600;
}

.hint-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--brand-soft); color: var(--text-brand);
  border: 1px solid var(--teal-border); border-radius: var(--radius-pill);
  padding: 5px 14px; margin: 3px; font-size: var(--text-xs); font-weight: 600;
  font-family: var(--font-mono); cursor: pointer;
  transition: all .2s var(--ease);
}
.hint-chip:hover { background: color-mix(in srgb, var(--teal) 12%, transparent); transform: translateY(-1px); box-shadow: 0 2px 6px color-mix(in srgb, var(--teal) 15%, transparent); }

.risk-pill {
  display: inline-block; border-radius: var(--radius-pill);
  padding: 0.18rem 0.55rem; font-size: var(--text-micro); font-weight: 700;
}

.risk-high { background: #fff0f0; color: #991b1b; border: 1px solid var(--pl-conflict-cell); }
.risk-mid { background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; }
.risk-low { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }

/* ============================================================
   ALERT CHIPS
   ============================================================ */
.alert-chip {
  display: inline-flex; align-items: center; gap: 6px; border-radius: var(--radius-sm);
  padding: 8px 14px; margin: 3px; font-size: var(--text-xs); font-weight: 600;
  backdrop-filter: blur(12px); transition: all .2s var(--ease);
}
.alert-chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 5px currentColor; flex-shrink: 0; }
.alert-chip.warn   { background: rgba(154,106,8,0.06); color: var(--sev-warning); border: 1px solid rgba(154,106,8,0.16); }
.alert-chip.danger { background: var(--pl-danger-bg); color: var(--danger); border: 1px solid rgba(192,48,48,0.16); }

/* ============================================================
   MISC UTILITIES
   ============================================================ */
.importance-high  { color: var(--text-brand); font-weight: 700; font-family: var(--font-mono); font-size: var(--text-xs); }
.importance-mid   { color: var(--sky); font-weight: 600; font-family: var(--font-mono); font-size: var(--text-xs); }
.importance-low   { color: var(--t3); font-family: var(--font-mono); font-size: var(--text-xs); }
.missing-prereq { color: var(--danger); font-weight: 600; font-size: var(--text-micro); }
.empty-note       { color: var(--muted-light); font-style: normal; font-size: var(--text-base); }
.row-highlight { background: #fffbeb !important; }
tr.attention-row td { background: #fff7ed !important; }

/* A banner is a sentence: the body face at the small-print step, with figures that
   line up. Mono is for codes, ids and kickers (premium review: status prose in mono). */
.meta-banner {
  border-radius: var(--radius-sm); padding:10px 14px; font-size:var(--text-sm);
  font-family: var(--font-body); font-variant-numeric: tabular-nums; backdrop-filter: blur(10px);
}
.meta-info {
  background: color-mix(in srgb, var(--teal) 4%, transparent); border: 1px solid var(--teal-border);
  color: var(--t2);
}
.meta-warn {
  background: rgba(154,106,8,0.05); border: 1px solid rgba(154,106,8,0.15);
  color: var(--sev-warning);
}
.meta-danger {
  background: rgba(192,48,48,0.05); border: 1px solid rgba(192,48,48,0.15);
  color: var(--danger);
}

.danger-zone { border: 1px solid var(--pl-conflict-cell); background: #fff5f5; border-radius: var(--radius); padding: 0.75rem; }
.danger-zone-strong { border: 2px dashed #f87171; background: #fff1f2; border-radius: var(--radius); padding: 0.875rem; }

/* ============================================================
   ZONE CARDS
   ============================================================ */
.zone-card { padding: 1rem; margin-top: 0.75rem; }

/* `.zone-card .zone-title` used to re-style the heading here as uppercase grey
   with a 3px teal pipe. It out-specified (0,2,0) the app-wide card-title rule
   that retired that look (plain `.zone-title`, 0,1,0), so the one panel wrapped
   in `.zone-card` was the last screen still rendering the old chrome. The
   override is gone: `.zone-title` inside a zone card now gets the same teal
   sentence-case heading as every other card title in the app. */

/* ============================================================
   TABLE GROUP ROW
   A full-width subhead inside a table body — "TERM 1 · 16 CREDITS" —
   so long tables carry their own structure instead of repeating the
   grouping value in every row.
   ============================================================ */
.table > tbody > tr.table-group-row > th {
  background:     var(--card);
  color:          var(--text-brand);
  font-family:    var(--font-body);
  font-size:      var(--text-micro);
  font-weight:    700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align:     start;
  padding:        var(--space-5) var(--space-8);
  border-bottom:  1px solid var(--line);
}
/* Arabic letters join: spacing them apart breaks the word, and there is no
   upper case to go to (the same guard `.ux-stat-scope` carries). */
html[dir="rtl"] .table > tbody > tr.table-group-row > th {
  letter-spacing: 0;
  text-transform: none;
}

/* A course's prerequisites, read down a column: codes in the mono face so they
   line up, and "none" kept quiet so the eye catches the courses that DO gate. */
.course-prereqs {
  font-family: var(--font-mono);
  font-size:  0.92em;   /* relative to the row: table data, not a caption */
  color:      var(--t2);
}
.course-prereqs.is-none {
  font-family: var(--font-body);
  font-size:  1em;
  color:      var(--t4);
  font-style: italic;
}
/* Arabic has no italic: slanting it is a distortion, not an emphasis. */
html[dir="rtl"] .course-prereqs.is-none { font-style: normal; }

/* ============================================================
   TERM CARDS
   ============================================================ */
.term-card {
  border: none; border-radius: var(--radius-lg);
  background: var(--glass-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  padding: 0.875rem; margin-bottom: 0.75rem;
  box-shadow: var(--shadow-neu);
}

.term-card h4 { margin-bottom: 0.4rem; font-weight: 600; }

.term-header-sticky { display: flex; align-items: center; gap: 10px; flex: 1; }
.term-header-sticky h4 { font-family: var(--font-body); font-weight: 700; font-size: var(--text-md); color: var(--navy); margin: 0; }

.term-summary { list-style: none; cursor: pointer; padding: 12px 16px; display: flex; align-items: center; gap: 8px; transition: background .15s var(--ease); }
.term-summary::-webkit-details-marker { display: none; }
.term-summary::before { content: ''; width: 0; height: 0; border-inline-start: 5px solid var(--teal); border-block-start: 4px solid transparent; border-block-end: 4px solid transparent; transition: transform .2s var(--ease); opacity: 0.5; flex-shrink: 0; }
.term-details[open] > .term-summary::before { transform: rotate(90deg); }
.term-summary:hover { background: color-mix(in srgb, var(--teal) 3%, transparent); }

.term-details {
  background: var(--glass-bg); backdrop-filter: var(--glass-blur);
  border: none; border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: var(--shadow-neu); margin-bottom: 10px;
}
.term-details::before { content: ''; display: block; height: 2px; background: linear-gradient(90deg, transparent 5%, var(--teal) 25%, var(--sky) 50%, var(--royal) 75%, transparent 95%); opacity: 0.12; }

/* ============================================================
   PLAN ITEM
   ============================================================ */
.plan-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border: var(--border-subtle);
  border-radius: var(--radius-sm); cursor: default;
  background: var(--glass-bg); margin-bottom: 6px;
  border-inline-start: 3px solid var(--teal);
  transition: all .2s var(--ease);
}
.plan-item:hover { background: color-mix(in srgb, var(--teal) 4%, transparent); transform: translateX(3px); box-shadow: 0 2px 6px color-mix(in srgb, var(--teal) 10%, transparent); }
.plan-item .title { font-family: var(--font-mono); font-weight: 700; color: var(--text-brand); font-size: var(--text-sm); }
.plan-item .sub   { font-size: var(--text-micro); color: var(--t3); font-family: var(--font-mono); }

/* ============================================================
   COURSE ROW / DRAWER / ADVISOR BLOCK
   ============================================================ */
.course-row { cursor: pointer; transition: all .15s var(--ease); }
.course-row:hover { transform: translateY(-1px); }
.course-row.active { outline: 2px solid var(--teal); outline-offset: -1px; background: var(--brand-soft) !important; }
.plan-course-link { cursor: pointer; }

.drawer { padding: 0.875rem; }
.drawer h3 { margin-bottom: 0.4rem; font-weight: 700; color: var(--brand-dark); }
.drawer .kv { font-size: var(--text-base); color: var(--ink-2); margin-bottom: 0.28rem; }

.advisor-block { padding: 1rem; margin-top: 0.875rem; }
/* Canonical card-heading style — teal, bold, 14px.
   Applied to advisor-block h3 (the original source) plus the
   other card-title patterns across the app (zone-title,
   um-panel-title, .et-panel/.si-panel/.cpanel direct h6). */
.advisor-block h3,
.zone-title,
.um-panel-title,
.cp-t,
.dba-section-title,
.pf-card-title,
.pane-title,
.ap-drawer-section-title,
.et-panel > h6,
.si-panel > h6,
.cpanel > h6 {
  margin:          0 0 0.55rem;
  font-family:     var(--font-body);
  font-size:       var(--text-base);
  font-weight:     700;
  color:           var(--text-brand);
  letter-spacing:  0;
  text-transform:  none;
  display:         flex;
  align-items:     center;
  gap:             0.45rem;
}

/* Hide the old teal-pipe prefix now that the heading text itself is teal. */
.zone-title::before,
.um-panel-title::before,
.dba-section-title::before,
.ap-drawer-section-title::before {
  display: none;
}
/* Keep the colored prefix for state variants (edit / danger zone). */
.um-panel-title.edit::before,
.um-panel-title.danger::before,
.danger-panel .dba-section-title::before {
  display: inline-block;
}

/* ============================================================
   MISC COMPONENTS
   ============================================================ */
.field-error {
  color: var(--danger); font-size: var(--text-xs); margin-top: 0.2rem;
  display: none; font-weight: 500;
}
.input-invalid {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(224,52,52,.12) !important;
}

.task-card {
  border: var(--border-subtle); border-radius: var(--radius);
  background: var(--glass-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  padding: 0.8rem 1rem; margin-bottom: 0.5rem;
  transition: box-shadow .15s, transform .15s;
}
.task-card:hover { box-shadow: var(--shadow-card); transform: translateY(-1px); }
.task-card .k {
  font-family: var(--font-body); font-size: var(--text-micro); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2);
}

.sticky-cta { z-index: 6; }

.mini-bar-wrap {
  background: var(--line); border-radius: var(--radius-pill);
  height: 5px; min-width: 100px; display: inline-block; vertical-align: middle;
}
.mini-bar {
  background: linear-gradient(90deg, var(--success) 0%, #22c55e 100%);
  height: 5px; border-radius: var(--radius-pill);
}

.log-box {
  background: #08101e; color: #b8d4f8; border-radius: var(--radius);
  padding: 1rem; overflow-x: auto;
  font-family: var(--font-mono); font-size: var(--text-sm); line-height: 1.6;
  border: 1px solid rgba(255,255,255,.06);
}

/* ============================================================
   STUDENT PLAN ACTIONS
   ============================================================ */
#studentPlanActions {
  overflow-x: auto; flex-wrap: nowrap; padding-bottom: 0.2rem;
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
  display: flex; gap: 0.45rem; align-items: center; margin-bottom: 1rem;
}

#studentPlanActions .btn,
#studentPlanActions .form-select { flex: 0 0 auto; }
#studentPlanActions details { display: inline-block; }
#studentPlanActions details summary { list-style: none; }
#studentPlanActions details summary::-webkit-details-marker { display: none; }

/* ============================================================
   MODULE-SPECIFIC
   ============================================================ */
#student form .btn-primary       { font-weight: 700; }
#loadStudentPlan                 { border-color: var(--brand); color: var(--text-brand); }
#student .secondary-inline-actions .btn { min-height: 34px; }

#batch .batch-filters .btn-success { font-weight: 700; }
/* The id makes this (1,1,0), so it outranked the sheet conversion on .metric
   and left the batch tiles tinted teal in LIGHT mode — the dark counterparts of
   this rule were found in review, this one sits 3,000 lines away from them. */
#batchMetrics .metric              { border-color: var(--rule); background: none; }
#batch .batch-export-row           { margin-top: 0.75rem; }
#batch .batch-export-row .btn      { min-height: 36px; }

#advisorportfolio .metric          { border-color: var(--line-strong); }
#advisorportfolio #advTable        { font-size: var(--text-sm); }
#advisorportfolio #advTable th,
#advisorportfolio #advTable td     { padding: 0.35rem 0.5rem; white-space: nowrap; }
#advisorportfolio #advTable td:nth-child(2),
#advisorportfolio #advTable td:nth-child(11) {
  max-width: 220px; overflow: hidden; text-overflow: ellipsis;
}
#advisorportfolio #advTable thead th { background: var(--teal-dim); color: var(--text-brand); }

#advisoradmin .btn-primary,
#advisorportfolio .btn-primary     { font-weight: 600; }
#advisoradmin .panel-sub,
#advisorportfolio .panel-sub       { font-size: var(--text-base); }
#advisoradmin .actions-row .btn,
#advisorportfolio .actions-row .btn { border-radius: var(--radius-sm); }
/* #advisoradmin .advisor-block border-color now handled by TEAL CARD SURFACE + V2 dark rule */

#usermgmt .actions-row .btn        { flex: 1 1 180px; }
#umMeta.meta-banner                { font-size: var(--text-base); }

/* ============================================================
   RTL SUPPORT
   ============================================================ */
html[dir="rtl"] body {
  font-family: 'Noto Kufi Arabic', 'Inter', system-ui, sans-serif !important;
  letter-spacing: 0;
}

/* ── RTL: push sidebar to the RIGHT side ──────────────────────
   Three independent mechanisms so at least one always wins:
   1. row-reverse on the flex container (.shell)
   2. order:2 on the sidebar itself — works even if row-reverse fails
   3. The sidebar still renders correctly because it is a flex child
   ─────────────────────────────────────────────────────────── */
html[dir="rtl"] .shell {
  flex-direction: row-reverse !important;
}

html[dir="rtl"] .sidebar {
  order:      2 !important;
  text-align: end;
}

html[dir="rtl"] main.flex-grow-1 {
  order: 1 !important;
}

html[dir="rtl"] .panel .form-label     { letter-spacing: 0; }
html[dir="rtl"] .table-wrap thead th   { text-transform: none; letter-spacing: 0; }
html[dir="rtl"] .actions-row           { justify-content: flex-start; }
html[dir="rtl"] .zone-card .zone-title { letter-spacing: 0; }

/* Latin utility typography must not leak into Arabic interface labels. It
   produces visibly spaced-out Arabic and weakens the information hierarchy. */
html[dir="rtl"] .logo-sub,
html[dir="rtl"] .nav-lbl,
html[dir="rtl"] .kpi .k,
html[dir="rtl"] .ph-chip-context,
html[dir="rtl"] .student-next-step-label,
html[dir="rtl"] .sp-kpi-card span,
/* Section Planning (its page wrapper .sp-page; the save review dialog sits
   outside it, under its own class): headers, KPI labels, rule labels,
   programme counts and a phone card's labels. */
html[dir="rtl"] .sp-page .tbl-card thead th,
html[dir="rtl"] .sp-page .sp-mc .k,
html[dir="rtl"] .sp-page .sp-caps-lbl,
html[dir="rtl"] .sp-page .sp-adv-table th,
html[dir="rtl"] .sp-page .sp-prog-count,
html[dir="rtl"] .sp-page .mobile-cards tbody td::before,
html[dir="rtl"] .sp-limit-review th {
  font-family: var(--font-body);
  letter-spacing: 0;
  text-transform: none;
}
html[dir="rtl"] .sp-page .text-caps::placeholder { letter-spacing: 0; }

html[dir="rtl"] .page-intro,
html[dir="rtl"] .page-intro p { line-height: 1.75; }

/* ── Pre / code blocks: prevent horizontal overflow ──────── */
pre, .pre-output {
  white-space:    pre-wrap;
  word-break:     break-all;
  overflow-x:     auto;
  -webkit-overflow-scrolling: touch;
}

/* ============================================================
   RESPONSIVE — PROFESSIONAL MOBILE SYSTEM
   ============================================================ */

/* ── Hamburger button (hidden on desktop) ──────────────────── */
.sidebar-toggle {
  display:        none;          /* shown in mobile breakpoint */
  align-items:    center;
  justify-content: center;
  min-width:      44px;          /* a11y: WCAG 2.5.8 minimum touch target */
  min-height:     44px;          /* a11y: WCAG 2.5.8 minimum touch target */
  width:          44px;
  height:         44px;
  border-radius:  8px;
  border:         none;
  background:     var(--btn-primary-bg);
  color:          var(--btn-primary-ink);
  cursor:         pointer;
  flex-shrink:    0;
  margin-inline-end: 0.35rem;   /* gap between hamburger and module title */
  box-shadow:     0 1px 4px color-mix(in srgb, var(--teal) 25%, transparent);
  transition:     background 0.15s var(--ease), transform 0.1s var(--ease);
  position:       relative;
  z-index:        5;
}

.sidebar-toggle:hover { background: var(--btn-primary-hover); }
.sidebar-toggle:active { transform: scale(0.93); }

.sidebar-toggle-icon {
  display:        flex;
  flex-direction: column;
  gap:            4px;
  width:          15px;
}

.sidebar-toggle-icon span {
  display:        block;
  height:         2px;
  border-radius:  2px;
  background:     var(--btn-primary-ink);
  transition:     transform 0.2s var(--ease), opacity 0.2s var(--ease), width 0.2s var(--ease);
}

/* × animation when open */
.sidebar-open .sidebar-toggle-icon span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.sidebar-open .sidebar-toggle-icon span:nth-child(2) { opacity: 0; width: 0; }
.sidebar-open .sidebar-toggle-icon span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ── Sidebar backdrop overlay ───────────────────────────────── */
.sidebar-backdrop {
  display:    none;
  position:   fixed;
  inset:      0;
  background: rgba(0, 0, 0, 0.55);
  z-index:    199;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation:  sb-fade-in 0.2s var(--ease);
}

@keyframes sb-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ── 1024px — Tablet: stack sidebar, reduce card padding ──────── */
@media (max-width: 1024px) {

  /* Dashboard metric cards: 2-column grid */
  .row.g-2 > [class*="col-md-3"],
  .row.g-2 > [class*="col-md-4"] {
    flex: 0 0 50%;
    max-width: 50%;
  }

  /* MC metric cards: reduce padding on tablet */
  .mc {
    padding: 14px;
  }
  /* mc-val and mc-hero font-sizes now handled by clamp() in base rules */

  /* KPI cards (exam timetable): 2-column grid */
  .kpi {
    padding: 0.5rem;
  }

  /* ET panel: tighter padding */
  .et-panel {
    padding: 12px 14px;
  }

  /* ET grid: reduce cell padding for tablet */
  .et-grid th, .et-grid td {
    padding: 5px 4px;
    font-size: var(--text-xs);
  }

  /* ET conflict matrix: smaller cells on tablet */
  .et-matrix td {
    width: 22px;
    height: 22px;
    min-width: 22px;
    font-size: var(--text-micro);
  }

  /* Tbl-card rows: reduce padding */
  .tbl-card tbody tr.cr-row td {
    padding: 10px 10px;
  }

  /* Content wrap: allow full width */
  .content-wrap {
    max-width: 100%;
  }
}

/* ── 992px — Narrow desktop / large tablet ──────────────────── */
@media (max-width: 992px) {
  :root { --sb-w: 195px; }
  .sidebar { width: 195px; }

  .logo-area { padding: 12px 12px 14px; gap: 8px; }
  .logo-mark { width: 30px; height: 30px; border-radius: 8px; }
  .logo-mark .i { width: 16px; height: 16px; }
  .logo-title { font-size: 0.88rem; }

  .nav-lbl { padding: 8px 10px 2px; }
  .nav-a   { padding: 6px 10px; gap: 7px; }
  .nav-a .i { width: 14px; height: 14px; }

  .s-foot { padding: 8px 10px; }
  .avatar { width: 28px; height: 28px; }

  main.flex-grow-1 { padding: 1rem !important; }

  /* page-header: adjust bleed for 1rem main padding */
  .page-header {
    margin: -1rem -1rem 1.25rem -1rem !important;
    padding-inline: 1rem;
  }

  .actions-row .btn,
  .actions-row .form-select,
  .actions-row .form-control    { flex: 1 1 200px; }

  #usermgmt .actions-row .btn   { flex: 1 1 160px; }
}

/* ── 768px — Tablet / large phone (sidebar becomes overlay) ── */
@media (max-width: 768px) {
  :root { --sb-w: 0px; }

  /* Show hamburger */
  .sidebar-toggle { display: flex; }

  /* Sidebar: fixed overlay, slides in from the inline-start edge */
  .sidebar {
    position:   fixed;
    top:        0;
    bottom:     0;
    inset-inline-start: 0;
    z-index:    10;
    width:      0;
    padding:    0;
    overflow:   hidden;
    visibility: hidden;
    pointer-events: none;
    border-inline-end: 0;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(50px) saturate(160%);
    -webkit-backdrop-filter: blur(50px) saturate(160%);
    transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0s 0.28s,
                z-index 0s 0.28s;
    box-shadow: none;
  }
  .sidebar::after { display: none; }
  .sidebar.sidebar-open {
    z-index:    200;
    visibility: visible;
    pointer-events: auto;
    transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0s,
                z-index 0s;
  }

  /* 320px, and never closer than 56px to the far edge, so the backdrop beside
     it stays a target a thumb can close it with (Material's modal drawer). At
     272px, 16px labels such as "Recommendation Debug" and the longer Arabic ones
     wrapped onto a second line, and so did the Arabic product name. */
  .sidebar.sidebar-open {
    width:      min(320px, calc(100vw - 56px));
    padding:    0;
    overflow-y: auto;
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.15);
  }

  /* Show backdrop when sidebar open */
  .sidebar.sidebar-open ~ * .sidebar-backdrop,
  .sidebar-backdrop.active { display: block; }

  /* Toast: full-width top bar on mobile */
  #toast-container {
    inset-inline-start: 0.5rem;
    inset-inline-end: 0.5rem;
  }
  .ux-toast { max-width: 100%; min-width: 0; }

  /* page-header: bleeds to edges */
  .page-header {
    margin:        0 -1rem 1.25rem -1rem !important;  /* bleeds out of main's 1rem padding */
    padding:       0.4rem 0.65rem !important;
    border-radius: 0;
    border-bottom: 1px solid var(--line, var(--line));
    background:    rgba(255,255,255,0.4);
    backdrop-filter: blur(24px) saturate(130%);
    -webkit-backdrop-filter: blur(24px) saturate(130%);
    z-index:       100;                              /* above panel content when scrolling */
    gap:           0.4rem !important;
    flex-wrap:     nowrap !important;
    align-items:   center !important;
  }

  /* Compact hamburger for mobile — keep 44px touch target (a11y: WCAG 2.5.8) */
  .sidebar-toggle {
    min-width:  44px;
    min-height: 44px;
    width:  44px;
    height: 44px;
    border-radius: 7px;
    margin-inline-end: 0.2rem;
    box-shadow: 0 1px 3px color-mix(in srgb, var(--teal) 20%, transparent);
  }
  .sidebar-toggle-icon { width: 13px; gap: 3.5px; }
  .sidebar-toggle-icon span { height: 1.5px; }
  .sidebar-open .sidebar-toggle-icon span:nth-child(1) { transform: translateY(5px) rotate(45deg); }
  .sidebar-open .sidebar-toggle-icon span:nth-child(3) { transform: translateY(-5px) rotate(-45deg); }

  /* page-header-left: allow shrink and truncation */
  .page-header-left {
    min-width: 0;
    flex: 1 1 0%;
    overflow: hidden;
  }
  .page-header-module {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* the title is the largest line of the phone's bar (it was 12.4px, under the
       14.7px subtitle below it) */
    font-size: var(--text-lg);
  }
  /* the Arabic title's weight on a phone is the desktop masthead's (600) */
  html[dir="rtl"] main:not(.p-0):not([data-width="full"]):not([data-fill="viewport"]) .page-header-module {
    font-weight: 600;
  }
  .page-intro h2 { font-size: var(--text-md); }
  /* Chips wrap to a second line rather than being cut mid-word ("Student: ..."
     and "1448/1" were clipped at the screen edge). */
  .page-header-chips {
    overflow: visible;
    flex-wrap: wrap;
  }
  /* A page's own actions take a row under the title: the menu button, a title
     and two text buttons ("Export this scenario", "Search another student") do
     not fit in 390px, and the title was squeezed out and a button cut off. */
  .page-header:has(> .page-header-right:not(:empty)) { flex-wrap: wrap !important; }
  .page-header-right:not(:empty) { flex: 1 1 100%; flex-wrap: wrap; justify-content: flex-end; }

  /* main padding: keep gutter, page-header bleeds out via negative margin */
  main.flex-grow-1 {
    padding: 1rem !important;
  }

  /* Touch targets (44px buttons and fields, 16px field text against iOS zoom)
     come from the control tokens, redefined once for touch near :root. */

  /* Metric cards: 2-column grid on tablet */
  .row.g-2 > [class*="col-md-3"] {
    flex: 0 0 50%;
    max-width: 50%;
  }

  /* Table wraps: no artificial max-height on mobile, enable horizontal scroll */
  .table-wrap { max-height: none !important; overflow-x: auto !important; -webkit-overflow-scrolling: touch; }

  /* Actions row: wrap earlier */
  .actions-row {
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .actions-row .btn,
  .actions-row .form-select,
  .actions-row .form-control { flex: 1 1 160px; }

  /* Form rows: stack more aggressively */
  .sticky-cta { position: static !important; }

  /* Planner: hide step navigation description text */
  .step-pill { font-size: var(--text-micro); padding: 0.25rem 0.45rem; }

  /* Zone cards: tighter on mobile */
  .zone-card { padding: 0.75rem; }

  /* Advisor block: tighter */
  .advisor-block { padding: 0.75rem; }

  /* Dashboard: full-width cards */
  .row.g-2 > [class*="col-md-3"],
  .row.g-2 > [class*="col-md-4"] {
    flex: 0 0 50%;
    max-width: 50%;
  }

  /* MC cards: compact on mobile */
  .mc { padding: 12px; }
  /* mc-val and mc-hero font-sizes now handled by clamp() in base rules */

  /* ET panel: full-width, tighter */
  .et-panel { padding: 10px 12px; }

  /* ET form inputs: stack vertically */
  .et-panel .row > [class*="col-md-"] {
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* ET grid: enable horizontal scroll, reduce cell sizes */
  .et-grid { font-size: var(--text-xs); }
  .et-grid th { padding: 4px 3px; font-size: var(--text-xs); } /* a11y: min 12px for headers */
  .et-grid td { padding: 4px 3px; font-size: var(--text-micro); }
  .et-grid td { min-width: 60px; }

  /* ET matrix: horizontal scroll container */
  .et-matrix { font-size: var(--text-micro); }
  .et-matrix td { width: 20px; height: 20px; min-width: 20px; font-size: var(--text-micro); }
  .et-matrix thead th > span { font-size: var(--text-xs); } /* a11y: min 12px for headers */

  /* Hide non-essential table columns on mobile */
  .tbl-card thead th:nth-child(n+5),
  .tbl-card tbody td:nth-child(n+5) {
    display: none;
  }

  /* Ensure tbl-card rows fit mobile */
  .tbl-card tbody tr.cr-row td { padding: 8px 8px; }
  /* cr-id, cr-nm, cr-row td font-sizes now handled by clamp() in base rules */
}

/* ── 480px — Small phone ────────────────────────────────────── */
@media (max-width: 480px) {

  /* page-header: even tighter on small phone */
  .page-header {
    padding: 0.35rem 0.5rem !important;
    gap: 0.35rem !important;
  }
  .sidebar-toggle {
    min-width:  44px;           /* a11y: WCAG 2.5.8 minimum touch target */
    min-height: 44px;           /* a11y: WCAG 2.5.8 minimum touch target */
    width:  44px;
    height: 44px;
    border-radius: 6px;
    margin-inline-end: 0.15rem;
    box-shadow: 0 1px 3px color-mix(in srgb, var(--teal) 20%, transparent);
  }
  .sidebar-toggle-icon { width: 11px; gap: 2.5px; }
  .sidebar-toggle-icon span { height: 1.5px; }
  .sidebar-open .sidebar-toggle-icon span:nth-child(1) { transform: translateY(4px) rotate(45deg); }
  .sidebar-open .sidebar-toggle-icon span:nth-child(3) { transform: translateY(-4px) rotate(-45deg); }

  /* page-header chips: hide verbose ones, keep essential */
  .ph-chip-scope  { display: none; }
  .ph-chip-dept   { display: none; }
  .ph-chip-role   { font-size: var(--text-micro); padding: 0.1rem 0.35rem; }

  /* Form inputs: always full width */
  .row > [class*="col-md-"],
  .row > [class*="col-lg-"] {
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* Buttons full width in action rows */
  .actions-row .btn,
  .actions-row .form-select,
  .actions-row .form-control { flex: 1 1 100%; width: 100%; }

  /* Metric cards: still 2-col on small phone (avoid 1-col waste) */
  .row.g-2 > [class*="col-md-3"] {
    flex: 0 0 50%;
    max-width: 50%;
  }

  /* metric .v and .k font-sizes now handled by clamp() in base rules */

  /* Panel padding: removed card wrapper, no extra padding needed */

  /* Dashboard batch export row: stack */
  .batch-export-row .btn { width: 100%; }

  /* Adm wizard: stack vertically */
  .adm-wizard-bar { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .adm-step-line  { width: 2px; height: 20px; margin-block: 0; margin-inline: 0; margin-inline-start: 15px; }

  /* Student plan actions: wrap */
  #studentPlanActions { flex-wrap: wrap; overflow-x: visible; }

  /* Table-wrap: full viewport height scrollable */
  .table-wrap { max-height: 60vh !important; overflow-y: auto; }

  /* High-priority filter: grid stacks */
  .hp-advanced .row > * { flex: 0 0 100%; max-width: 100%; }

  /* ── Mobile density: tighter padding for admin screens ── */
  .soft-card { padding: 0.75rem; margin-bottom: 0.5rem; }
  /* flush with the title and the rule above it, as the desktop bar is (it kept
     the card-era 12px inset, so a phone's fields started 12px in) */
  .filter-bar { padding: 8px 0; gap: 6px; margin-bottom: 12px; }
  /* Buttons and fields keep the touch tier here too: this block used to shrink
     them to 34px with 10.9px labels, undoing the 44px rule above it. */
  html body .btn { padding-inline: var(--control-px-sm) !important; }
  .form-label { margin-bottom: 0.15rem; }
  .page-intro h2 { margin-bottom: 2px; }
  .panel-sub, .page-intro .panel-sub { margin-bottom: 0.5rem; }

  /* ── Mobile Cards — table-to-card transform ──────────────── */
  .mobile-cards thead { display: none; }
  .mobile-cards tbody { display: flex; flex-direction: column; gap: 0.75rem; }
  .mobile-cards tbody tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius, 12px);
    background: var(--glass-bg-data);
    backdrop-filter: blur(16px) saturate(120%);
    -webkit-backdrop-filter: blur(16px) saturate(120%);
    box-shadow: var(--shadow-neu-sm);
  }
  .mobile-cards tbody tr td {
    display: flex;
    flex-direction: column;
    padding: 0.2rem 0;
    border: none;
    font-size: var(--text-sm);
  }
  .mobile-cards tbody tr td::before {
    content: attr(data-label);
    font-family: var(--font-mono, monospace);
    font-size: var(--text-micro);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--t3, #6b7280);
    margin-bottom: 0.15rem;
  }
  .mobile-cards tbody tr td.mc-primary {
    grid-column: 1 / -1;
    font-weight: 700;
    font-size: var(--text-base);
    color: var(--navy, #111144);
  }
  .mobile-cards tbody tr td.mc-actions {
    grid-column: 1 / -1;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-top: 0.35rem;
    border-top: var(--border-subtle);
    margin-top: 0.25rem;
  }
  .mobile-cards tbody tr td.mc-hide { display: none; }
}

/* ── RTL mobile: sidebar slides from the RIGHT ─────────────── */
@media (max-width: 768px) {
  html[dir="rtl"] .sidebar {
    inset-inline-start: 0;
    inset-inline-end:   auto;
    box-shadow: none;
  }

  html[dir="rtl"] .sidebar.sidebar-open {
    box-shadow: -4px 0 32px rgba(0, 0, 0, 0.15);
  }
}

/* ── The phone drawer: a touch surface ─────────────────────────
   On a phone the sidebar is a drawer, and it kept the compaction the ≤1200px
   and ≤992px blocks above make for the 210px and 195px rails: 31.5px rows,
   24px group headings in 11px capitals (smaller than the items under them), a
   30px mark beside a 12.35px product name, 28-32px buttons and an 11.3px
   language select, which iOS zooms into when it takes focus. 34 of its 35
   controls were under the 44px the touch ladder gives every other control on
   a phone. Here the drawer starts from the full rail's look and takes the
   touch ladder: 44px rows (--control-h), the touch tier's 16px text, and group
   headings in the body face at 600, as large as their items.
   Not on the MRI page (owner: unchanged), which hides the sidebar: the
   zero-specificity :where() keeps every computed style there as it was. Split
   view draws no sidebar at all.
   The sidebar is outside the global box-sizing reset, so each touch row is a
   border box here: its 44px is the target, not the text inside its padding. */
@media (max-width: 768px) {
  /* The visible height, not 100vh: a phone's 100vh is the height with its
     browser toolbar hidden, so with the toolbar showing the footer's controls
     sat partly under it. A browser without dvh keeps the 100vh above. */
  :where(body:not(.twm-root)) .sidebar { height: 100dvh; }

  :where(body:not(.twm-root)) .sidebar :is(.nav-find-btn, .nav-lbl, .nav-a, .s-usr, .s-usr-logout, .theme-toggle) {
    box-sizing: border-box;
  }

  :where(body:not(.twm-root)) .sidebar .logo-area    { padding: 16px 18px; gap: 12px; }
  :where(body:not(.twm-root)) .sidebar .logo-mark    { width: 40px; height: 40px; border-radius: 11px; }
  :where(body:not(.twm-root)) .sidebar .logo-mark .i { width: 22px; height: 22px; }
  /* the phone's page title is this size too (.page-header-module) */
  :where(body:not(.twm-root)) .sidebar .logo-title   { font-size: var(--text-lg); }

  :where(body:not(.twm-root)) .sidebar .nav-find { padding: 12px 12px 4px; }
  :where(body:not(.twm-root)) .sidebar .nav-find-btn {
    min-height:     var(--control-h);
    padding-block:  0;
    padding-inline: 12px;
    gap:            10px;
    font-size:      var(--field-fs);
  }
  :where(body:not(.twm-root)) .sidebar .nav-find-i { width: 20px; height: 20px; }

  :where(body:not(.twm-root)) .sidebar .nav-sec { padding: 8px 12px 16px; }
  :where(body:not(.twm-root)) .sidebar .nav-lbl {
    min-height:         var(--control-h);
    margin-block-start: 10px;
    padding:            0 12px;
    font-family:        var(--font-body);
    font-weight:        600;
    letter-spacing:     normal;
    text-transform:     none;
    color:              var(--t1);
  }
  :where(body:not(.twm-root)) .sidebar .nav-grp:first-child > .nav-lbl { margin-block-start: 0; }
  :where(body:not(.twm-root)) .sidebar .nav-lbl-t    { font-size: var(--text-md); }
  :where(body:not(.twm-root)) .sidebar .nav-lbl-chev { width: 18px; height: 18px; }
  :where(body:not(.twm-root)) .sidebar .nav-a {
    min-height: var(--control-h);
    padding:    8px 12px;
    gap:        12px;
    margin:     2px 0;
    font-size:  var(--text-md);
  }
  :where(body:not(.twm-root)) .sidebar .nav-a .i { width: 20px; height: 20px; }

  :where(body:not(.twm-root)) .sidebar .s-foot { padding: 12px 14px 14px; }
  :where(body:not(.twm-root)) .sidebar .s-usr  { min-height: var(--control-h); gap: 12px; }
  :where(body:not(.twm-root)) .sidebar .avatar { width: 36px; height: 36px; border-radius: 10px; }
  :where(body:not(.twm-root)) .sidebar .u-nm   { font-size: var(--text-base); }
  /* Arabic: the full rail's one step up (12 to 13px), as at 1201px and above */
  html[dir="rtl"] :where(body:not(.twm-root)) .sidebar .u-rl,
  html[dir="rtl"] :where(body:not(.twm-root)) .sidebar .logo-sub { font-size: var(--text-sm); }
  :where(body:not(.twm-root)) .sidebar .s-usr-logout,
  :where(body:not(.twm-root)) .sidebar .theme-toggle { width: var(--control-h); height: var(--control-h); }
  :where(body:not(.twm-root)) .sidebar .s-usr-logout .i { width: 18px; height: 18px; }
  /* a field: the touch tier's 16px text, so focusing it does not zoom the page */
  :where(body:not(.twm-root)) .sidebar .s-lang .form-select {
    min-height:    var(--control-h);
    padding-block: 0 !important;
    font-size:     var(--field-fs) !important;
  }
}
/* A short screen, such as a phone on its side: between the fixed header,
   search row and footer, 375px left the list two rows. There the whole drawer
   scrolls as one, as a modal drawer does (it opens at its top: the script that
   centres the current page scrolls the list alone). */
@media (max-width: 768px) and (max-height: 540px) {
  :where(body:not(.twm-root)) .sidebar .nav-sec { flex: none; overflow: visible; }
}
/* A mouse on a narrow window: a group heading answers the pointer the way the
   desktop's headings do. Not on touch, where a hover state outlives the tap. */
@media (max-width: 768px) and (hover: hover) {
  :where(body:not(.twm-root)) .sidebar .nav-lbl:hover { background: var(--surface); }
}

/* ============================================================
   MODAL DIALOG SYSTEM  (replaces window.confirm / prompt)
   ============================================================ */
.dlg-backdrop {
  position:   fixed;
  inset:      0;
  z-index:    2000;
  background: rgba(10, 18, 40, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display:    flex;
  align-items: center;
  justify-content: center;
  padding:    1rem;
  animation: dlg-fade-in 0.18s var(--ease);
}

@keyframes dlg-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.dlg-box {
  background:    var(--bg);
  border-radius: var(--radius-lg);
  border:        1px solid var(--line-strong);
  box-shadow:    var(--shadow-lift);
  width:         100%;
  max-width:     440px;
  overflow:      hidden;
  /* Cap to the viewport and lay out as a column so a tall body scrolls
     internally while the header and footer (action buttons) stay pinned and
     on-screen. Without this, content taller than the screen pushed the footer
     buttons out of view. */
  display:        flex;
  flex-direction: column;
  max-height:     calc(100vh - 2rem);
  animation:     dlg-slide-up 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes dlg-slide-up {
  from { transform: translateY(20px) scale(0.97); opacity: 0; }
  to   { transform: translateY(0) scale(1);       opacity: 1; }
}

.dlg-header {
  padding:       1.25rem 1.5rem 0;
  display:       flex;
  align-items:   flex-start;
  gap:           0.875rem;
  flex-shrink:   0;
}

.dlg-close {
  margin-inline-start: auto;
  background:    none;
  border:        none;
  font-size:     var(--text-xl);
  line-height:   1;
  color:         var(--ink-light, #6b7280);
  cursor:        pointer;
  padding:       0 0.25rem;
  opacity:       0.6;
  transition:    opacity 0.15s;
}
.dlg-close:hover { opacity: 1; }

.dlg-icon {
  flex-shrink: 0;
  width:       40px;
  height:      40px;
  border-radius: var(--radius-md);
  display:     flex;
  align-items: center;
  justify-content: center;
  box-shadow:  var(--shadow-neu-inset);
}
.dlg-icon .i { width: 20px; height: 20px; }

.dlg-icon-danger { background: rgba(220,38,38,0.06); color: #dc2626; }
.dlg-icon-warning { background: rgba(217,119,6,0.06); color: var(--sev-warning); }
.dlg-icon-info { background: var(--brand-soft); color: var(--text-brand); }
.dlg-icon-success { background: rgba(22,163,74,0.06); color: #16a34a; }

.dlg-title {
  font-weight:    700;
  font-size:      var(--text-md);
  color:          var(--ink);
  margin-bottom:  0.3rem;
  letter-spacing: -0.01em;
}

.dlg-body {
  padding-block:        0.35rem 1rem;
  padding-inline-start: calc(1.5rem + 40px + 0.875rem);
  padding-inline-end:   1.5rem;
  font-size:      var(--text-base);
  color:          var(--ink-2);
  line-height:    1.55;
  /* The scroll region: takes the slack and scrolls when content is tall, so the
     pinned footer buttons remain on-screen. */
  flex:           1 1 auto;
  min-height:     0;
  overflow-y:     auto;
}

.dlg-body p { margin-bottom: 0.5rem; }
.dlg-body p:last-child { margin-bottom: 0; }

.dlg-body strong { color: var(--ink); }

.dlg-body code {
  font-family:   var(--font-mono);
  font-size:     var(--text-sm);
  background:    var(--brand-soft);
  padding:       0.15rem 0.4rem;
  border-radius: var(--radius-xs);
  color:         var(--ink);
}

.dlg-input-row {
  padding-block:        0 1rem;
  padding-inline-start: calc(1.5rem + 40px + 0.875rem);
  padding-inline-end:   1.5rem;
  flex-shrink:          0;
}

.dlg-input-row label {
  display:       block;
  font-size:     var(--text-micro);
  font-weight:   700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color:         var(--ink-2);
  margin-bottom: 0.35rem;
}

.dlg-input-row input {
  box-sizing:    border-box;
  width:         100%;
  padding:       0.5rem 0.75rem;
  border:        none;
  border-radius: var(--radius-sm);
  font-family:   var(--font-mono);
  font-size:     var(--text-base);
  font-weight:   600;
  color:         var(--ink);
  background:    transparent;
  box-shadow:    inset 0 0 0 1px var(--control-edge), var(--shadow-neu-inset);
  transition:    box-shadow 0.2s var(--ease);
  outline:       none;
}

.dlg-input-row input:focus {
  box-shadow:   inset 0 0 0 1px var(--teal), var(--shadow-neu-inset),
                0 0 0 2px var(--teal);
}

.dlg-input-row input.dlg-input-danger:focus {
  border-color: var(--danger);
  box-shadow:   0 0 0 3px rgba(220,38,38,.15);
}

.dlg-input-hint {
  font-size:   var(--text-xs);
  color:       var(--muted);
  margin-top:  0.3rem;
}

.dlg-footer {
  padding:       0.875rem 1.5rem 1.25rem;
  display:       flex;
  justify-content: flex-end;
  gap:           0.5rem;
  border-top:    none;
  background:    transparent;
  /* Pinned below the scrollable body so the action buttons are always visible. */
  flex-shrink:   0;
}

.dlg-footer .btn-cancel {
  background:    transparent;
  border:        none;
  color:         var(--t2);
  font-family:   var(--font-body);
  font-weight:   600;
  font-size:     var(--text-base);
  padding:       0.5rem 1.25rem;
  border-radius: var(--radius-sm);
  cursor:        pointer;
  transition:    all 0.18s;
  /* `background: transparent; border: none` with the neumorphic shadow as its
     ONLY edge, so flattening that shadow left the Cancel button of every
     confirm dialog as bare text at 1.00:1. Same fix, same measured tokens, as
     .fb-dd. */
  background:    var(--btn-neutral-bg);
  box-shadow:    inset 0 0 0 1px var(--btn-neutral-border);
}

.dlg-footer .btn-cancel:hover {
  color:        var(--ink);
  background:   rgba(17,17,68,0.11);
  box-shadow:   inset 0 0 0 1px var(--control-edge);
}

.dlg-footer .btn-confirm {
  font-family:   var(--font-body);
  font-weight:   700;
  font-size:     var(--text-base);
  padding:       0.5rem 1.5rem;
  /* 7px, to match .btn-cancel beside it in the same footer. */
  border-radius: var(--radius-sm);
  border:        none;
  cursor:        pointer;
  transition:    all 0.18s;
  min-width:     90px;
}

.dlg-footer .btn-confirm.danger {
  background: var(--danger);
  color:      #fff;
  box-shadow: none;
}

.dlg-footer .btn-confirm.danger:hover {
  background: #d43a3a;
  box-shadow: none;
}

.dlg-footer .btn-confirm.primary {
  background: var(--btn-primary-bg);
  color:      var(--btn-primary-ink);
  box-shadow: none;
}

.dlg-footer .btn-confirm.primary:hover {
  background: var(--btn-primary-hover);
  box-shadow: none;
}

.dlg-footer .btn-confirm.warning {
  background: var(--amber);
  color:      #fff;
  box-shadow: none;
}

/* A dialog that only INFORMS (the publish-blockers list: one OK button, nothing is
   confirmed) is not a destructive confirmation, so it closes on the neutral
   button rather than a red one. Its caller passes kind 'danger' for the icon. */
.dlg-box:has(.tw-readiness-lead) .dlg-footer .btn-confirm.danger {
  background: var(--btn-neutral-bg);
  color:      var(--btn-neutral-text);
  box-shadow: inset 0 0 0 1px var(--btn-neutral-border);
}
.dlg-box:has(.tw-readiness-lead) .dlg-footer .btn-confirm.danger:hover {
  background: color-mix(in srgb, var(--teal) 10%, var(--btn-neutral-bg));
  color:      var(--text-brand);
  box-shadow: inset 0 0 0 1px var(--btn-neutral-border);
}

.dlg-footer .btn-confirm:disabled {
  opacity:   0.45;
  cursor:    not-allowed;
  box-shadow: var(--shadow-neu-sm);
}

/* ============================================================
   TOAST NOTIFICATION  (custom bottom-right)
   ============================================================ */
#toast-container {
  position:    fixed;
  top:         1rem;
  inset-inline-end: 1.5rem;
  z-index:     3000;
  display:     flex;
  flex-direction: column;
  gap:         0.5rem;
  pointer-events: none;
}

.ux-toast {
  display:       flex;
  align-items:   flex-start;
  gap:           0.75rem;
  padding:       0.875rem 1rem;
  background:    var(--bg);
  border-radius: var(--radius-lg);
  border:        none;
  box-shadow:    var(--shadow-lift);
  min-width:     260px;
  max-width:     340px;
  pointer-events: all;
  position:      relative;
  overflow:      hidden;
  animation:     toast-in 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  border-inline-start: 3px solid transparent;
}

.ux-toast.removing {
  animation: toast-out 0.22s var(--ease) forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-12px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toast-out {
  to   { opacity: 0; transform: translateX(20px); max-height: 0; padding: 0; margin: 0; border: none; }
}

.ux-toast.success { border-inline-start-color: var(--success); }
.ux-toast.error   { border-inline-start-color: var(--danger);  }
.ux-toast.info    { border-inline-start-color: var(--brand);   }
.ux-toast.warning { border-inline-start-color: var(--warning); }

.ux-toast-icon {
  flex-shrink: 0;
  width:       28px;
  height:      28px;
  border-radius: var(--radius-sm);
  display:     flex;
  align-items: center;
  justify-content: center;
  font-size:   var(--text-base);
  box-shadow:  var(--shadow-neu-inset);
}

.ux-toast.success .ux-toast-icon { background: var(--teal-dim); color: var(--sev-ok); }
.ux-toast.error   .ux-toast-icon { background: var(--pl-danger-bg); color: var(--danger);  }
.ux-toast.info    .ux-toast-icon { background: var(--teal-dim); color: var(--text-brand);   }
.ux-toast.warning .ux-toast-icon { background: rgba(154,106,8,0.06); color: var(--sev-warning); }

.ux-toast-body { flex: 1; min-width: 0; }

.ux-toast-title {
  font-weight:    700;
  font-size:      var(--text-base);
  color:          var(--ink);
  line-height:    1.3;
}

.ux-toast-sub {
  font-size:   var(--text-xs);
  color:       var(--muted);
  margin-top:  0.1rem;
  white-space: nowrap;
  overflow:    hidden;
  text-overflow: ellipsis;
}

.ux-toast-close {
  flex-shrink: 0;
  /* a real target (it was 22px) */
  width:       var(--control-h-sm);
  height:      var(--control-h-sm);
  border:      none;
  background:  none;
  color:       var(--muted);
  cursor:      pointer;
  border-radius: var(--radius-xs);
  display:     flex;
  align-items: center;
  justify-content: center;
  font-size:   var(--text-xs);
  padding:     0;
  transition:  background 0.1s;
}
.ux-toast-close:hover { background: var(--brand-soft); color: var(--ink); }

/* Drain bar */
.ux-toast-progress {
  position:  absolute;
  bottom:    0; inset-inline-start: 0;
  height:    2px;
  border-radius: 0 0 0 2px;
  animation: toast-drain linear forwards;
  transform-origin: left;
}
[dir="rtl"] .ux-toast-progress {
  transform-origin: right;
}

.ux-toast.success .ux-toast-progress { background: var(--success); }
.ux-toast.error   .ux-toast-progress { background: var(--danger);  }
.ux-toast.info    .ux-toast-progress { background: var(--brand);   }
.ux-toast.warning .ux-toast-progress { background: var(--warning); }

@keyframes toast-drain {
  from { width: 100%; }
  to   { width: 0%; }
}

/* The toast is a card (UI review 3): it had the page's own colour and no edge,
   so in dark mode only its 3px status bar told it from the page. A one-line
   toast centres its title against the icon and the close button; one with a
   second line keeps them at the top. Not the MRI page or split view (owner). */
:where(body:not(.twm-root):not(.tws-root)) .ux-toast {
  background: var(--card);
  border: 1px solid var(--rule);
  border-inline-start-width: 3px;
  align-items: center;
}
:where(body:not(.twm-root):not(.tws-root)) .ux-toast:has(.ux-toast-sub) { align-items: flex-start; }
@media (max-width: 768px) {
  /* A phone's toasts span the page between its gutters. The older phone block
     above comes before the base rules, which outrank it, so the stack sat 43px
     from one edge and 8px from the other. */
  :where(body:not(.twm-root):not(.tws-root)) #toast-container { inset-inline: 1rem; }
  :where(body:not(.twm-root):not(.tws-root)) #toast-container .ux-toast { min-width: 0; max-width: none; }
}

/* ============================================================
   SORT ARROWS
   ============================================================ */
.table-wrap thead th[data-sort] {
  padding-inline-end: 1.5rem; /* room for arrow */
  /* No `position` here: it would override the sticky set on `.table-wrap thead
     th` above, which is both earlier and less specific. Sticky already anchors
     the ::after arrow. */
}

.table-wrap thead th[data-sort]::after {
  content:   '↕';
  position:  absolute;
  inset-inline-end: 0.4rem;
  top:       50%;
  transform: translateY(-50%);
  /* 0.28 put this glyph at roughly 1.5:1 -- the project's own .sort-arrow rule
     had already measured that and settled on 0.75, where --t3 reads 3.4:1
     (light) to 4.1:1 (dark). Both tables now use that value. */
  opacity:   0.75;
  font-size: 0.7rem;
  transition: opacity 0.1s;
}

.table-wrap thead th[data-sort]:hover::after { opacity: 1; }

.table-wrap thead th[data-sort][data-dir="asc"]::after  { content: '↑'; opacity: 0.85; }
.table-wrap thead th[data-sort][data-dir="desc"]::after { content: '↓'; opacity: 0.85; }

/* Active sort col gets subtle highlight */
.table-wrap thead th[data-sort][data-dir] {
  color: var(--brand-dark) !important;
  background: var(--teal-dim) !important;
}

/* ============================================================
   SKELETON LOADING ROWS
   ============================================================ */
.skel-row td {
  padding: 0.5rem 0.75rem !important;
  border-top: 1px solid var(--line) !important;
}

.skel-cell {
  height:        14px;
  border-radius: var(--radius-sm);
  background:    linear-gradient(90deg, var(--line) 25%, var(--card) 50%, var(--line) 75%);
  background-size: 200% 100%;
  animation:     skel-shimmer 1.4s var(--ease) infinite;
}

@keyframes skel-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* (Sidebar user card styles are now defined in the SIDEBAR section above as .s-foot, .s-usr, .avatar, .u-nm, .u-rl) */

/* ============================================================
   KEYBOARD SHORTCUT HELP OVERLAY
   ============================================================ */
.kbd-help-backdrop {
  position:    fixed;
  inset:       0;
  z-index:     2500;
  background:  rgba(10,18,40,.6);
  backdrop-filter: blur(6px);
  display:     flex;
  align-items: center;
  justify-content: center;
  animation:   dlg-fade-in 0.15s var(--ease);
}

.kbd-help-box {
  background:    var(--card);
  border-radius: var(--radius-lg);
  box-shadow:    0 24px 64px rgba(10,18,40,.22);
  width:         100%;
  max-width:     480px;
  padding:       1.5rem;
  animation:     dlg-slide-up 0.2s var(--ease);
}

.kbd-help-box h3 {
  font-size:      var(--text-md);
  font-weight:    700;
  margin-bottom:  1rem;
  color:          var(--ink);
  display:        flex;
  align-items:    center;
  gap:            0.5rem;
}

.kbd-row {
  display:        flex;
  align-items:    center;
  justify-content: space-between;
  padding:        0.45rem 0;
  border-bottom:  1px solid var(--line);
  font-size:      var(--text-base);
}

.kbd-row:last-child { border-bottom: none; }

.kbd-desc { color: var(--ink-2); }

.kbd-key {
  display:        inline-flex;
  align-items:    center;
  gap:            0.2rem;
}

kbd {
  display:        inline-block;
  padding:        0.15rem 0.45rem;
  font-family:    var(--font-mono);
  font-size:      var(--text-micro);
  font-weight:    600;
  color:          var(--ink);
  background:     var(--brand-soft);
  border:         var(--border-mid);
  border-bottom:  2px solid var(--line-strong);
  border-radius:  var(--radius-xs);
  line-height:    1.4;
}

/* ============================================================
   FOCUS RINGS  (keyboard nav only — no ring on mouse click)
   ============================================================ */
/* Remove outline on mouse users */
*:focus:not(:focus-visible) { outline: none; box-shadow: none; }

/* Restore crisp ring for keyboard users */
*:focus-visible {
  outline:        2px solid var(--teal) !important;
  outline-offset: 2px !important;
  box-shadow:     0 0 0 4px var(--brand-glow) !important;
}
/* A soft corner for a focused thing that has none of its own (a link, a row).
   Zero specificity: it used to be (0,1,0), which beat every component declared
   earlier in this sheet, so a round toggle or a pill chip turned into a 7px
   rounded square the moment it took keyboard focus. */
:where(*:focus-visible) { border-radius: var(--radius-sm); }
/* The MRI page and the classic MRI tab keep the old behaviour exactly (owner). */
:where(body.twm-root, .tw-mri) *:focus-visible { border-radius: var(--radius-sm); }

/* Fields and selects take the SAME ring as every other control (2px solid teal,
   2px offset), not a 25%-alpha glow of about 1.9:1 that a select hardly showed.
   The border stays (it used to be removed, which also lost the field's edge and
   moved it by 2px); it turns teal. */
.form-control:focus-visible,
.form-select:focus-visible {
  outline:        2px solid var(--teal) !important;
  outline-offset: 2px !important;
  border-color:   var(--teal) !important;
  box-shadow:     var(--shadow-neu-inset) !important;
}

/* Sidebar links keyboard nav */
.sidebar .nav-a:focus-visible {
  outline:        2px solid var(--teal) !important;
  outline-offset: -2px !important;
  box-shadow:     none !important;
}

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
  /* Hide chrome */
  .sidebar,
  .sidebar-backdrop,
  .sidebar-toggle,
  .page-header,
  .actions-row,
  #ux-loading-bar,
  #toast-container,
  .dlg-backdrop,
  .btn-outline-secondary,
  .cmd-backdrop,
  .kbd-help-backdrop,
  .color-mesh { display: none !important; }

  /* Reset backgrounds */
  body {
    background: #fff !important;
    background-image: none !important;
    color: #000 !important;
    font-size: 11pt;
  }
  body::after { display: none !important; }

  main.flex-grow-1 {
    padding: 0 !important;
    width:   100% !important;
  }

  /* Glassmorphic panels: flatten on print */
  .mc, .cpanel, .zone-card, .term-details, .filter-bar {
    border:     1px solid #ccc !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: #fff !important;
    break-inside: avoid;
  }

  /* Tables: full width, visible borders */
  .table-wrap {
    max-height:  none !important;
    overflow:    visible !important;
    border:      1px solid #ccc;
    box-shadow:  none !important;
    break-inside: avoid;
  }

  .table-wrap thead th {
    background: #f0f0f0 !important;
    color: #000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Metric cards */
  .metric {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    break-inside: avoid;
  }

  /* Links: show URL in print */
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.75em;
    color: #666;
  }

  /* Hide less important link annotations */
  .nav-link[href^="#"]::after { content: none; }
  .nav-a[href^="#"]::after    { content: none; }
  .btn[href]::after           { content: none; }
}

/* ============================================================
   ADVISOR PORTFOLIO — DUAL-ACTION STUDENT ID CELL
   ============================================================ */
.adv-id-cell { white-space: nowrap; }

/* ============================================================
   REDUCED MOTION — Accessibility: disable animations for users
   who prefer reduced motion (vestibular disorders, etc.)
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   UI/UX POLISH — Global Improvements
   ============================================================ */

/* ── Visually-hidden helper (screen-reader only) ───────────── */
.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;
}

/* ── Enhanced empty state with recovery action ─────────────── */
.empty-state-action {
  display: inline-flex; align-items: center; gap: 0.4rem;
  margin-top: 0.75rem; padding: 0.4rem 1rem;
  border-radius: var(--radius); border: none;
  font-size: var(--text-sm); font-weight: 600;
  color: var(--text-brand); background: var(--brand-soft);
  cursor: pointer; transition: all 0.18s var(--ease);
  text-decoration: none;
  box-shadow: inset 0 0 0 1px var(--control-edge);
}
.empty-state-action:hover {
  background: color-mix(in srgb, var(--teal) 12%, transparent);
  /* --shadow-neu-sm is transparent now, so this said "no ring on hover": the
     button lost its edge exactly when pointed at. */
  box-shadow: inset 0 0 0 1px var(--teal);
  color: var(--text-brand);
}
.empty-state-action .i { width: 14px; height: 14px; }

/* ── Error state card ──────────────────────────────────────── */
.error-state {
  text-align: center; padding: 2rem 1.5rem;
  border: 1px solid rgba(192,48,48,0.12);
  border-radius: var(--radius);
  background: rgba(255,245,245,0.5);
  backdrop-filter: blur(12px);
}
.error-state .error-icon {
  display: flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; border-radius: var(--radius-md);
  margin: 0 auto 0.75rem;
  background: var(--pl-danger-bg); color: var(--danger);
  box-shadow: var(--shadow-neu-inset);
}
.error-state .error-icon .i { width: 24px; height: 24px; }
.error-state .error-title {
  font-weight: 700; font-size: var(--text-md); color: var(--danger);
  margin-bottom: 0.3rem;
}
.error-state .error-detail {
  font-size: var(--text-sm); color: var(--t3); line-height: 1.5;
  max-width: 40ch; margin: 0 auto;
}

/* ── Skeleton loading card ─────────────────────────────────── */
.skel-card {
  border-radius: var(--radius);
  padding: 1.25rem;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-neu-sm);
}
.skel-block {
  height: 14px; border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--line) 25%, var(--card) 50%, var(--line) 75%);
  background-size: 200% 100%;
  animation: skel-shimmer 1.4s var(--ease) infinite;
  margin-bottom: 0.5rem;
}
.skel-block:last-child { margin-bottom: 0; }
.skel-block-lg { height: 28px; }
.skel-block-sm { height: 10px; }
.skel-block-w50 { width: 50%; }
.skel-block-w75 { width: 75%; }
.skel-block-w30 { width: 30%; }

/* ── Button disabled state polish ──────────────────────────── */
html body .btn:disabled,
html body .btn.disabled {
  /* .5 left the label of an outline or neutral button at 2.5:1 (light) against
     its card: hard to tell from the card at all. .62 keeps it clearly disabled
     and puts the label at 3.3:1 or better (light) and 4.6:1 (dark). */
  opacity: 0.62;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: var(--shadow-neu-sm) !important;
}

/*
 * MUST REMAIN AFTER THE SHARED .btn DISABLED RULE ABOVE.
 * The extra `.btn` matches the dark-theme disabled rule's specificity (0,3,2),
 * and the later source order preserves the neutral inset boundary in both themes.
 * Without it, the shared dark shadow replaces the boundary while disabled.
 *
 * The same trap as the focus rules, found the same way — by a browser probe, not
 * by reading the file. A disabled control still has to be recognisable AS a
 * control, so it keeps its boundary while losing its interactivity: opacity says
 * disabled, the ring says button, and no outer focus ring appears even when
 * something calls .focus() on it.
 */
html body .btn.btn-neutral:disabled,
html body .btn.btn-neutral.disabled,
html body .btn.btn-neutral:disabled:focus,
html body .btn.btn-neutral.disabled:focus {
  background:   var(--btn-neutral-bg);
  color:        var(--btn-neutral-text);
  box-shadow:   inset 0 0 0 1px var(--btn-neutral-border) !important;
}
/* The outline variants draw their edge as an inset ring, and the disabled rule
   above replaces every shadow: a disabled "Insert sections" was borderless red
   text beside a solid button. They keep the ring; opacity says disabled. */
html body .btn.btn-outline-primary:disabled,
html body .btn.btn-outline-primary.disabled,
html body .btn.btn-outline-primary:disabled:focus,
html body .btn.btn-outline-primary.disabled:focus {
  box-shadow:   inset 0 0 0 1px var(--text-brand) !important;
}
html body .btn.btn-outline-danger:disabled,
html body .btn.btn-outline-danger.disabled,
html body .btn.btn-outline-danger:disabled:focus,
html body .btn.btn-outline-danger.disabled:focus {
  box-shadow:   inset 0 0 0 1px var(--sev-critical) !important;
}

/* ── Export button style (was undefined in audit_explorer) ──── */
/* `html body .btn` forces `border: none !important`, so a real border cannot
   reach this button: the shadow was its only edge in light, and dark never had
   one (its 1px border loses to that same !important). An inset ring wins. */
html body .btn-export {
  color: var(--text-brand) !important;
  background: color-mix(in srgb, var(--teal) 6%, transparent) !important;
  font-weight: 600 !important;
  /* --teal-border is rgba(10,142,110,0.16): about 1.2:1, a tint rather than an
     edge. A control boundary needs the real one. */
  box-shadow: inset 0 0 0 1px var(--control-edge) !important;
  /* Its box and line box come from the global reset and the .btn ladder now:
     an <a> and a <button> export control are the same height (they were 52px
     and 40px before the reset). */
}
/* On a phone the label carries the meaning and the icon is the first thing to
   give up its room. The portfolio's actions (CSV, Copy IDs, Copy Risk IDs) are
   one group that may not wrap apart; in Arabic they need 390px of a 338px bar
   with their icons and fit without them. */
@media (max-width: 480px) {
  html body .filter-bar .btn-export > .i { display: none; }
}
html body .btn-export:hover {
  background: color-mix(in srgb, var(--teal) 12%, transparent) !important;
  color: var(--text-brand) !important;
  box-shadow: inset 0 0 0 1px var(--teal) !important;
}

/* ── Neumorphic audit table (replaces plain .audit-table) ──── */
/* The audit table's own wrapper, the twin of .table-wrap. Its sticky header
   keeps an opaque fill of its own (below), so the wrapper needs no card. */
.audit-table-wrap {
  background: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: none;
  border-block-end: 1px solid var(--rule);
  border-radius: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: none;
}

/* ── Glassmorphic filter row ───────────────────────────────── */
/* The last translucent, blurred, neumorphic bar in the app — the same shape
   .filter-bar had, on the audit screen. A ruled band, and opaque, because it
   can sit above a scrolling table. */
.glass-filter-row {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
  align-items: center; margin-bottom: 1rem;
  padding: 0.75rem 0;
  background: var(--bg);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: none; border-block-end: 1px solid var(--rule); border-radius: 0;
  box-shadow: none;
}

/* ── Table row status highlights — accessible colors ───────── */
.audit-table tbody tr:hover td {
  background: color-mix(in srgb, var(--teal) 3%, transparent) !important;
}
.audit-table tbody tr td.status-success { color: var(--pl-ok-text); font-weight: 700; }
.audit-table tbody tr td.status-error   { color: var(--pl-danger-text); font-weight: 700; }
.audit-table tbody tr td.status-deny    { color: var(--pl-warn-text); font-weight: 700; }
.audit-table tbody tr td.status-critical { color: #991b1b; font-weight: 700; background: rgba(255,240,240,0.5); }

/* ── Consistent card heading pattern ───────────────────────── */
.card-heading {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: var(--text-micro); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); margin-bottom: 0.75rem;
}
.card-heading::before {
  content: ""; display: inline-block;
  width: 3px; height: 0.8rem; border-radius: 2px;
  background: var(--brand); opacity: 0.6;
}
.card-heading .i { width: 16px; height: 16px; opacity: 0.5; }

/* ── Smooth page transitions ───────────────────────────────── */
.content-wrap { animation: page-enter 0.3s var(--ease) both; }
@keyframes page-enter {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Interactive table row — highlight on focus for a11y ───── */
.tbl-card tbody tr.cr-row:focus-within {
  outline: 2px solid var(--teal);
  outline-offset: -2px;
  box-shadow: var(--shadow-neu);
}

.table-wrap tbody tr:focus-within td {
  background: color-mix(in srgb, var(--teal) 4%, transparent);
}

/* ── Mobile filter bar stacking ────────────────────────────── */
@media (max-width: 768px) {
  .glass-filter-row {
    flex-direction: column;
    align-items: stretch;
  }
  .glass-filter-row .form-control,
  .glass-filter-row .form-select {
    max-width: 100% !important;
    width: 100%;
  }
  .glass-filter-row .btn {
    width: 100%;
  }

  /* Profile grid: full-width on mobile */
  .pf-grid { grid-template-columns: 1fr !important; }
  .pf-info-card { flex-direction: column; text-align: center; }

  /* Audit table: reduce font, enable scroll */
  .audit-table th { padding: 5px; white-space: nowrap; font-size: var(--text-xs); } /* a11y: min 12px for headers */
  .audit-table td { padding: 5px; white-space: nowrap; }
}

/* ── High contrast mode support ────────────────────────────── */
@media (forced-colors: active) {
  .pill-status, .ph-chip, .pill, .nav-badge {
    border: 1px solid currentColor;
  }
  /* Its fill becomes Canvas here: a border keeps it a visible box. */
  .skip-link { border: 2px solid currentColor; }
  .sidebar { border-inline-end: 1px solid currentColor; }
  .btn { border: 1px solid currentColor; }
  /* Mask icons are painted by their background, which forced colours would
     otherwise drop: draw them in the text colour. */
  .ux-tone-icon, .ux-icon { forced-color-adjust: none; background: CanvasText; }
}

/* ============================================================
   BACK-TO-TOP BUTTON
   ============================================================ */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  inset-inline-end: 2rem;
  z-index: 900;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--glass-bg-header);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  /* Pre-existing, not caused by the control conversion: a near-white glass disc
     on a light ground measured about 1.1:1 against the page, with only a 6%
     drop shadow to find it by — under the 3:1 WCAG 1.4.11 asks of a control's
     boundary. It is a control, and this pass is about control boundaries, so
     it takes the same --control-edge ring as the rest. */
  box-shadow: var(--shadow-card), inset 0 0 0 1px var(--control-edge);
  color: var(--text-brand);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 0.3s var(--ease), visibility 0.3s var(--ease), transform 0.3s var(--ease),
              background 0.2s ease, box-shadow 0.2s ease;
  pointer-events: none;
}
.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}
.back-to-top:hover {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-ink);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--teal) 25%, transparent);
}
.back-to-top:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
}
.back-to-top svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ============================================================
   PRINT STYLESHEET — clean output for reports
   ============================================================ */
@media print {
  /* Hide non-essential UI */
  .sidebar,
  .sidebar-toggle,
  .sidebar-backdrop,
  .color-mesh,
  .back-to-top,
  .skip-link,
  .page-header-right,
  #ux-loading-bar,
  #toast-container,
  .cmd-backdrop,
  .sbp,
  .sb-tip,
  .nav-badge,
  body::after {
    display: none !important;
  }

  /* Reset backgrounds */
  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 11pt !important;
    line-height: 1.4 !important;
  }

  /* Full width content */
  .shell {
    display: block !important;
  }
  main.flex-grow-1 {
    margin: 0 !important;
    padding: 0.5cm !important;
    max-width: 100% !important;
  }

  /* Glass cards → plain bordered boxes */
  .glass, .glass-panel,
  [class*="glass"] {
    background: #fff !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;
    border: 1px solid #ddd !important;
  }

  /* Tables: full borders */
  table { border-collapse: collapse; width: 100%; }
  th, td {
    border: 1px solid #ccc !important;
    padding: 4px 8px !important;
    background: #fff !important;
    color: #000 !important;
  }
  th { background: #f5f5f5 !important; font-weight: 700; }

  /* Page breaks */
  h1, h2, h3 { page-break-after: avoid; }
  tr { page-break-inside: avoid; }

  /* Links show URL */
  a[href]:not([href^="#"]):not([href^="javascript"])::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }

  /* Page header: simpler */
  .page-header {
    border-bottom: 2px solid var(--teal);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
  }
}

/* ============================================================
   SMOOTH CONTENT TRANSITIONS
   ============================================================ */
.content-wrap { animation: contentFadeIn 0.35s var(--ease) both; }
/* The fade-in must not HOLD its end state: a held `transform: translateY(0)` made
   .content-wrap the containing block of every `position: fixed` element inside
   it, so a drawer, a modal, a popover or a full-screen panel opened in the page
   stopped where the page's content stopped (the portfolio drawer, the dashboard's
   dialogs and Ctrl+K palette, the instructor picker, the expanded graduation map,
   the exam matrix's full screen). The end state equals the default, so nothing
   moves. What the transform also did is kept on purpose: `position: relative`
   keeps the column the anchor of absolutely positioned children, `isolation`
   keeps its stacking context (nothing inside paints over the sidebar). Only
   `fixed` changes: it now means the window. Scoped to exactly the columns that
   held the transform: a full-width tool page, the bulk-bar page and a
   reduced-motion reader never animate, so they keep their column unpositioned.
   The MRI page keeps its own. */
@media (prefers-reduced-motion: no-preference) {
  main:not([data-width="full"]) > .content-wrap:where(:not(:has(#twmPage, #bulkBar))) {
    animation-fill-mode: backwards; position: relative; isolation: isolate;
  }
}
@keyframes contentFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Panel/section show transition for SPA-style hash panels */
.panel[style*="display: block"],
.panel.active {
  animation: panelSlideIn 0.3s var(--ease) both;
}
@keyframes panelSlideIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   FOCUS IMPROVEMENTS — better visible focus for all interactives
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 0;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 12%, transparent);
}

/* ============================================================
   SKELETON LOADING STATES (#17)
   ============================================================ */
.skeleton { position: relative; overflow: hidden; background: var(--line); border-radius: var(--radius-sm); color: transparent !important; }
.skeleton * { visibility: hidden; }
.skeleton::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
  animation: skeleton-shimmer 1.5s infinite;
}
@keyframes skeleton-shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

/* Skeleton variants */
.skeleton-text { height: 1em; width: 60%; display: inline-block; }
.skeleton-text-sm { height: 0.75em; width: 40%; display: inline-block; }
.skeleton-circle { width: 40px; height: 40px; border-radius: 50%; }
.skeleton-card { height: 80px; border-radius: var(--radius, 18px); }
.skeleton-stat { height: 52px; width: 120px; border-radius: var(--radius-md); display: inline-block; }

/* ============================================================
   SHARED EMPTY STATE COMPONENT (#23)
   ============================================================ */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 3rem 1.5rem; text-align: center; }
.empty-state-icon { width: 56px; height: 56px; margin-bottom: 1rem; opacity: 0.35; color: var(--t4, #6c6c8a); }
.empty-state-title { font-size: var(--text-md); font-weight: 600; color: var(--t2, #2d2d5e); margin-bottom: 0.35rem; }
.empty-state-desc { font-size: var(--text-base); color: var(--t4, #6c6c8a); max-width: 320px; line-height: 1.5; }
.empty-state-cta { margin-top: 1rem; }

/* ============================================================
   REDUCED MOTION — respect user preferences
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .back-to-top { transition: none !important; }
  .content-wrap { animation: none !important; }
}

/* ============================================================
   TEAL CARD SURFACE — canonical visual used by many components
   ------------------------------------------------------------
   One source of truth for the gradient-teal + border + shadow
   pattern. Individual components layer their own padding / margin
   / transitions on top of this surface.
   ============================================================ */
/* These were a teal-tinted gradient inside a teal border with a drop shadow —
   a card, and a coloured one. Two costs: the page became a field of identical
   tinted boxes with no hierarchy between them, and the brand colour was spent
   on the furniture, so a teal that MEANT something (a link, an active state, a
   passing figure) had to shout over a page already teal all over.

   They are sections of the sheet now, opened by a rule. Padding, margin and
   transitions stay with each component; only the surface is retired. */
.page-panel, .et-panel, .sp-panel, .si-panel,
.advisor-block, .cpanel, .zone-card,
.ov-kpi, .ov-action, .ov-activity, .student-ctx-card,
.sp-mc, .kpi {
  background:    none;
  border:        0;
  border-top:    1px solid var(--rule);
  border-radius: 0;
  box-shadow:    none;
}

/* .drawer is the exception, and it was in the list above. It floats OVER the
   page rather than sitting in it, which is the one job a shadow exists to do:
   without an edge and a lift there is nothing to say where the page stops and
   the drawer starts. Modals (.dlg-box) and toasts (.ux-toast) keep theirs for
   the same reason, in their own rules. */
.drawer {
  background:    var(--card);
  border:        1px solid var(--line);
  border-radius: var(--radius);
  box-shadow:    var(--shadow-lift);
}

/* ============================================================
   V2 UNIFIED COMPONENTS
   ------------------------------------------------------------
   Canonical classes used across multiple feature templates.
   Before promoting a class here, the rule is: it must be used
   on ≥2 pages OR represent a standard page primitive (card,
   KPI tile, toggle chip). Page-specific styling stays in the
   feature partial / template.
   ============================================================ */

/* Page panel — gradient-teal card surface with standard padding.
   Canonical name is .page-panel. Legacy aliases listed so existing
   templates don't have to rename classes in this unification pass. */
.page-panel,
.et-panel,
.sp-panel,
.si-panel {
  padding:       16px 20px;
  margin-bottom: 12px;
  }
.page-panel--tight { padding: 12px 14px; }
.page-panel--flush { margin-bottom: 0; }

/* KPI tile — single metric.
   Canonical definition consolidating prior copies in
   exam_timetable.html, sections_import.html, dashboard partial. */
/* `.kpi` is styled TWICE: once in the V2 unified surface rule above and again
   here, and this one is later, so it wins. Converting only the group rule left
   every KPI tile in the app still painted as a card — the one place where the
   sheet visibly did not land. Both now say the same thing. */
.kpi {
  border:        0;
  border-top:    1px solid var(--rule);
  border-radius: 0;
  padding:       0.6rem 0;
  background:    none;
  box-shadow:    none;
}
.kpi .k {
  font-family:    var(--font-mono);
  font-size:      var(--text-micro);
  font-weight:    700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color:          var(--t3);
}
.kpi .v {
  font-family: var(--font-serif);
  font-size:   var(--text-xl);
  font-weight: 700;
  color:       var(--text-brand);
  line-height: 1.15;
}
.kpi .v.warn { color: var(--danger); }

/* Clickable drill-down KPI variant. */
.kpi-click {
  cursor:     pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
/* The ring hugged the card's rounded box; on a flat tile with no side padding
   it drew a cramped rectangle around the text. A wash reads on the sheet, and
   unlike `border-color` it is not blocked by the dark `border: 0 !important`
   these tiles carry — in dark these drill-downs had no hover or selected state
   at all. Restated at (0,2,0)/(0,3,0) so dark's (0,2,1) .kpi rule cannot win. */
.kpi-click:hover,
html[data-theme="dark"] .kpi-click:hover {
  border-top-color: var(--teal);
  background: color-mix(in srgb, var(--teal) 8%, transparent);
  box-shadow: none;
}
.kpi-click .v {
  text-decoration:        underline;
  text-decoration-style:  dotted;
  text-underline-offset:  3px;
}
/* The selected drill-down. Same reasoning as the hover above, and a touch
   stronger so "which one am I filtered to" is readable at a glance. */
.kpi-click.active,
html[data-theme="dark"] .kpi-click.active {
  border-top-color: var(--teal);
  background: color-mix(in srgb, var(--teal) 14%, transparent);
  box-shadow: none;
}

/* Toggle chip — radio/checkbox rendered as a pill. Canonical name is
   .chip-toggle; .et-chip kept as alias so templates don't have to
   rename yet. */
.chip-toggle,
.et-chip {
  display:       inline-flex;
  align-items:   center;
  gap:           4px;
  padding:       2px 10px;
  border:        1.5px solid var(--t4);
  border-radius: var(--radius-lg);
  background:    transparent;
  color:         var(--t2);
  font-size:     var(--text-sm);
  font-weight:   600;
  cursor:        pointer;
  user-select:   none;
  transition:    background-color 0.15s, border-color 0.15s, color 0.15s;
}
.chip-toggle:hover,
.et-chip:hover { border-color: var(--teal); }

.chip-toggle.is-active,
.chip-toggle.active,
.et-chip.is-active,
.et-chip.active,
.chip-toggle:has(input:checked),
.et-chip:has(input:checked) {
  background:   var(--btn-primary-bg);
  border-color: var(--btn-primary-bg);
  color:        var(--btn-primary-ink);
}
/* The input is visually hidden, not `display:none`: a display-none checkbox
   cannot take focus, so a chip group could not be used from the keyboard. */
.chip-toggle,
.et-chip { position: relative; }
.chip-toggle input,
.et-chip input {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
.chip-toggle:focus-within { outline: 2px solid var(--teal); outline-offset: 2px; }

/* Exam filters remain native, keyboard-operable checkboxes. */
#examSettingsControls .et-chip { position: relative; }
#examSettingsControls .et-chip input {
  display: block;
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
#examSettingsControls .et-chip:focus-within,
#etResults .kpi-click:focus-visible,
#historyList .et-run-info:focus-visible,
#historyList .et-del-btn:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.et-course-option { border-radius: var(--radius-sm); padding: 5px 10px; }
.et-course-name {
  display: block;
  max-width: 240px;
  white-space: normal;
  overflow-wrap: anywhere;
  font-size: var(--text-xs);
  font-weight: 400;
  line-height: 1.35;
}
.et-course-plans { display: block; font-size: var(--text-micro); opacity: 0.8; }

/* Amber modifier dot (e.g. online/remote indicator). */
.chip-toggle__dot,
.et-online-dot {
  color:               #f59e0b;
  font-size:           0.6em;
  line-height:         1;
  vertical-align:      middle;
  margin-inline-start: 2px;
}
.chip-toggle.is-active .chip-toggle__dot,
.chip-toggle.active    .chip-toggle__dot,
.et-chip.is-active     .et-online-dot,
.et-chip.active        .et-online-dot { color: #fef3c7; }

/* Dark-mode adjustments. */
/* These are sheet sections in both themes now (see the V2 unified surface rule),
   so dark no longer re-paints them as cards — it would have put the card back
   on exactly the screens light just took it off. Only .drawer, which floats,
   keeps a surface here. */
html[data-theme="dark"] .page-panel,
html[data-theme="dark"] .et-panel,
html[data-theme="dark"] .sp-panel,
html[data-theme="dark"] .si-panel,
html[data-theme="dark"] .kpi,
html[data-theme="dark"] .sp-mc,
html[data-theme="dark"] .ov-kpi,
html[data-theme="dark"] .ov-action,
html[data-theme="dark"] .ov-activity,
html[data-theme="dark"] .student-ctx-card,
html[data-theme="dark"] .advisor-block,
html[data-theme="dark"] .cpanel,
html[data-theme="dark"] .zone-card {
  background:   none;
  border-color: var(--rule);
  box-shadow:   none;
}
html[data-theme="dark"] .drawer {
  background:   var(--card);
  border-color: var(--line-strong);
  box-shadow:   0 8px 28px rgba(0,0,0,0.45);
}
html[data-theme="dark"] .chip-toggle,
html[data-theme="dark"] .et-chip { color: var(--t1); }
html[data-theme="dark"] .chip-toggle.is-active,
html[data-theme="dark"] .chip-toggle.active,
html[data-theme="dark"] .et-chip.is-active,
html[data-theme="dark"] .et-chip.active,
html[data-theme="dark"] .chip-toggle:has(input:checked),
html[data-theme="dark"] .et-chip:has(input:checked) { color: var(--btn-primary-ink); }  /* on the mint fill: white was 2.10:1 */

/* Mobile tightening. */
@media (max-width: 768px) {
  .page-panel,
  .et-panel,
  .sp-panel   { padding: 12px 14px; }
  .kpi        { padding: 0.4rem; }
  .kpi .v     { font-size: var(--text-lg); }
  .chip-toggle,
  .et-chip    { font-size: var(--text-micro); padding: 1px 7px; }
}

/* ============================================================
   EXAM TIMETABLE — feature-specific styles
   ------------------------------------------------------------
   Moved out of core/templates/core/exam_timetable.html so all
   project styles live in global.css. Class names kept as-is
   where unique to this page; unified where shared.
   ============================================================ */

.et-period-start,
.et-period-end {
  direction:            ltr;
  text-align:           center;
  width:                80px;
  max-width:            80px;
  font-variant-numeric: tabular-nums;
  font-family:          var(--font-mono, monospace);
}

#etPeriodsRepeater .is-invalid {
  background-image: none;
  padding-inline: 8px;
}

/* Drill-down container (kpi click targets) */
#kpiDrill       { border-top: 2px solid var(--teal); padding-top: 10px; }
#kpiDrill table th {
  font-size:      var(--text-micro);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color:          var(--t3);
  white-space:    nowrap;
}
#kpiDrill table td { vertical-align: middle; }
.drill-course-chip {
  display:       inline-block;
  padding:       1px 7px;
  border-radius: var(--radius-xs);
  font-size:     var(--text-xs);
  font-weight:   600;
  margin:        1px 2px;
}

/* Run history list (sidebar) */
.et-history-item {
  display:          flex;
  align-items:      center;
  justify-content:  space-between;
  gap:              8px;
  padding:          6px 10px;
  border-radius:    var(--radius-sm);
  cursor:           pointer;
  transition:       background 0.15s;
}
.et-history-item:hover { background: var(--teal-dim); }
.et-history-item.active       { background: var(--brand-soft); font-weight: 600; }
.et-history-item .et-run-info { flex: 1; min-width: 0; }
#historyList button.et-run-info {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: start;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.et-del-btn {
  flex-shrink:   0;
  padding:       4px 6px;
  border:        none;
  border-radius: var(--radius-xs);
  background:    none;
  color:         var(--t3);
  font-size:     var(--text-base);
  cursor:        pointer;
  opacity:       0;
  transition:    opacity 0.15s, color 0.15s, background 0.15s;
}
.et-history-item:hover .et-del-btn { opacity: 1; }
#historyList .et-history-item:focus-within .et-del-btn { opacity: 1; }
.et-del-btn:hover {
  color:      var(--danger);
  background: rgba(192,48,48,0.08);
}

/* Department hierarchy (course selection panel) */
.et-dept-group { margin-bottom: 4px; }
.et-dept-header {
  display:       flex;
  align-items:   center;
  gap:           6px;
  padding:       3px 4px;
  border-radius: var(--radius-xs);
  font-size:     var(--text-xs);
  cursor:        pointer;
  transition:    background 0.15s;
}
.et-dept-header:hover { background: var(--teal-dim); }
.et-dept-header .dept-name         { font-weight: 700; color: var(--t2); font-size: var(--text-sm); }
.et-dept-header .dept-count        { color: var(--t3); font-weight: 400; }
.et-dept-header .dept-toggle {
  margin-inline-start: auto;
  font-size:           var(--text-micro);
  color:               var(--text-brand);
  text-decoration:     none;
}
.et-dept-chips {
  padding-block:          2px 4px;
  padding-inline-start:   12px;
  padding-inline-end:     0;
  border-inline-start:    2px solid var(--teal-border);
  margin-inline-start:    6px;
}
.et-level-row {
  display:       flex;
  flex-wrap:     wrap;
  align-items:   center;
  gap:           3px;
  margin-bottom: 2px;
}
.et-level-badge {
  flex-shrink:   0;
  min-width:     20px;
  padding:       1px 5px;
  border-radius: 3px;
  background:    var(--brand-soft);
  color:         var(--t3);
  font-size:     var(--text-micro);
  font-weight:   700;
  text-align:    center;
  white-space:   nowrap;
}

/* Exam schedule grid */
.et-grid { width: 100%; border-collapse: collapse; }
.et-grid th, .et-grid td {
  padding:        7px 6px;
  border:         var(--border-mid);
  text-align:     center;
  vertical-align: middle;
}
.et-grid thead th {
  background:     var(--teal-dim);
  color:          var(--t3);
  font-size:      var(--text-xs);
  font-weight:    700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space:    nowrap;
}
.et-grid tbody th {
  background:  var(--teal-dim);
  color:       var(--t2);
  font-size:   var(--text-sm);
  font-weight: 700;
  min-width:   70px;
  white-space: nowrap;
}
.et-grid td              { min-width: 90px; font-size: var(--text-sm); font-weight: 600; }
.et-grid .et-empty       { color: var(--t4); font-size: var(--text-xs); font-weight: 400; }
.et-grid .et-course {
  display:        inline-block;
  vertical-align: top;
  margin:         2px 1px;
  padding:        3px 8px;
  border-radius:  var(--radius-sm);
  font-size:      var(--text-sm);
  font-weight:    600;
}
.et-grid .et-overflow-row th,
.et-grid .et-overflow-row td { background: var(--pl-danger-bg); }
.et-grid .et-highlight       { outline: 2.5px solid var(--teal); outline-offset: -2px; }
.et-grid .et-dim             { opacity: 0.25; }

/* Drag-and-drop pin */
.et-fixed-exams { border: 1px solid var(--line-h); border-radius: var(--radius-sm); padding: 12px; }
.et-builder-busy { opacity: 0.65; }
.et-fixed-exams .form-label { font-size: var(--text-xs); }
.et-pin-fields { display: grid; grid-template-columns: minmax(0, 2.6fr) minmax(100px, 1fr) minmax(150px, 1.2fr) minmax(110px, 0.8fr); gap: 10px; align-items: end; }
.et-pin-fields > div { min-width: 0; }
.et-pin-fields .form-select { width: 100%; min-width: 0; }
.et-pin-fields .btn { white-space: normal; }
@media (max-width: 1100px) {
  .et-pin-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .et-pin-course-field { grid-column: 1 / -1; }
}
@media (max-width: 575px) {
  .et-pin-fields { grid-template-columns: minmax(0, 1fr); }
}
.et-fixed-exams .table { font-size: var(--text-sm); }
.et-fixed-exams .et-pin-invalid { background: var(--pl-danger-bg); }
.et-fixed-exams .et-pin-actions { display: flex; gap: 6px; justify-content: flex-end; }
.et-fixed-exams .et-pin-problem { display: block; color: var(--danger); font-size: var(--text-xs); }
.et-course[draggable="true"]         { cursor: grab; }
.et-course[draggable="true"]:active  { cursor: grabbing; }
.et-course.et-pinned {
  outline:        2px dashed var(--warning);
  outline-offset: -1px;
}
.et-grid td.et-drag-over {
  background:     var(--brand-soft) !important;
  outline:        2px dashed var(--teal);
  outline-offset: -2px;
}
.et-pin-bar {
  display:       flex;
  align-items:   center;
  gap:           8px;
  margin-top:    6px;
  font-size:     var(--text-xs);
  color:         var(--t3);
}
.et-pin-bar a {
  color:           var(--danger);
  font-size:       var(--text-xs);
  text-decoration: none;
}

/* Conflict matrix (heatmap) */
.et-matrix { border-collapse: collapse; font-size: var(--text-micro); }
.et-matrix th, .et-matrix td {
  border:         1px solid var(--line-h);
  padding:        0;
  text-align:     center;
  vertical-align: middle;
}
.et-matrix td {
  width:       32px;
  height:      32px;
  min-width:   32px;
  font-size:   var(--text-micro);
  font-weight: 600;
  cursor:      default;
}
.et-matrix thead th {
  height:         80px;
  padding:        4px 0;
  vertical-align: bottom;
  white-space:    nowrap;
  cursor:         pointer;
}
.et-matrix thead th > span {
  display:          inline-block;
  width:            1.6em;
  transform:        rotate(-55deg);
  transform-origin: left bottom;
  color:            var(--t2);
  font-size:        var(--text-micro);
  font-weight:      700;
}
[dir="rtl"] .et-matrix thead th > span {
  transform:        rotate(55deg);
  transform-origin: right bottom;
}
.et-matrix tbody th {
  padding:       0 5px;
  background:    var(--teal-dim);
  color:         var(--t2);
  font-size:     var(--text-micro);
  font-weight:   700;
  text-align:    end;
  white-space:   nowrap;
  cursor:        pointer;
}
.et-matrix td:not(.cm-0):not(.cm-diag) { cursor: pointer; }
.et-matrix .cm-0    { background: transparent;        color: transparent; }
.et-matrix .cm-1    { background: hsl(45 90% 88%);    color: var(--sev-warning); }
.et-matrix .cm-2    { background: hsl(33 90% 78%);    color: #7a4400; }
.et-matrix .cm-3    { background: hsl(15 85% 68%);    color: #fff; }
.et-matrix .cm-4    { background: hsl(0 80% 55%);     color: #fff; }
.et-matrix .cm-diag { background: var(--t5);          color: transparent; }
.et-matrix tbody tr:hover > td,
.et-matrix tbody tr:hover > th,
.et-matrix .cm-col-hl               { box-shadow: inset 0 0 0 50px var(--brand-soft); }
.et-matrix tbody tr:hover > .cm-col-hl { box-shadow: inset 0 0 0 50px var(--brand-glow); }

.et-legend {
  display:     flex;
  flex-wrap:   wrap;
  align-items: center;
  gap:         12px;
  margin-top:  8px;
  color:       var(--t3);
  font-size:   var(--text-micro);
}
.et-legend-box {
  display:        inline-block;
  width:          18px;
  height:         18px;
  border:         var(--border-mid);
  border-radius:  3px;
  vertical-align: middle;
}

/* Matrix zoom toolbar */
.et-matrix-toolbar {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  padding:         0.5rem 0.75rem;
  margin-bottom:   0.5rem;
}
.et-matrix-title {
  font-family:    var(--font-mono);
  font-size:      var(--text-xs);
  font-weight:    700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color:          var(--t3);
}
.et-zoom-controls { display: flex; align-items: center; gap: 0.35rem; }
.et-zoom-btn {
  display:         flex;
  align-items:     center;
  justify-content: center;
  width:           28px;
  height:          28px;
  border:          none;
  border-radius:   var(--radius-sm);
  background:      var(--glass-bg);
  color:           var(--t3);
  font-size:       var(--text-base);
  font-weight:     700;
  cursor:          pointer;
  box-shadow:      var(--shadow-neu-sm);
  transition:      all 0.15s;
}
.et-zoom-btn:hover { color: var(--text-brand); }
.et-zoom-btn:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.et-zoom-level {
  min-width:   40px;
  color:       var(--t3);
  font-family: var(--font-mono);
  font-size:   var(--text-xs);
  font-weight: 600;
  text-align:  center;
}
.et-matrix-viewport {
  overflow:                    auto;
  max-height:                  400px;
  border-radius:               var(--radius);
  -webkit-overflow-scrolling:  touch;
}
.et-matrix-scaler { transition: transform 0.2s var(--ease); }
.et-matrix-empty { display: none; }
.et-matrix-empty.visible { display: block; }

/* Utility tags used inside the grid */
.et-period-sep { font-size: var(--text-xs); color: var(--t3); }
.et-period-remove-btn { padding: 2px 6px; font-size: var(--text-xs); line-height: 1; }
.et-add-period-btn { font-size: var(--text-xs); }
.et-drill-table { font-size: var(--text-sm); }
.et-credit-tag { opacity: 0.6; font-weight: 400; }
.et-room-tag {
  display:       block;
  max-width:     180px;
  margin-top:    2px;
  font-family:   var(--font-mono);
  font-size:     var(--text-micro);
  font-weight:   500;
  opacity:       0.75;
  white-space:   nowrap;
  overflow:      hidden;
  text-overflow: ellipsis;
}
.et-qa-title { color: var(--danger); }
.et-overflow-label { color: var(--danger); }
.et-pagination-ellipsis { padding: 0 0.2rem; color: var(--t3); }

/* Fullscreen matrix */
.page-panel.matrix-fullscreen,
.et-panel.matrix-fullscreen {
  position:        fixed;
  inset:           0;
  z-index:         10001;
  display:         flex;
  flex-direction:  column;
  margin:          0;
  padding:         12px 18px;
  background:      var(--card);
  border-radius:   0;
  overflow:        hidden;
}
/* `.page-panel.matrix-fullscreen` is (0,2,0) and the dark panel rule above is
   (0,2,1), so the dark rule wins on this element too — and it now says
   `background: none`. Unqualified, a fullscreen matrix in dark mode would be
   completely see-through, with the sidebar and the page behind it showing
   through an overlay that covers the viewport. (It was already half
   see-through at rgba(255,255,255,0.04); the sheet conversion made it total.)
   This restates the opaque fill at (0,3,0) so it wins back. */
html[data-theme="dark"] .page-panel.matrix-fullscreen,
html[data-theme="dark"] .et-panel.matrix-fullscreen {
  background:   var(--card);
  border:       0;
  box-shadow:   none;
}
.page-panel.matrix-fullscreen .et-matrix-viewport,
.et-panel.matrix-fullscreen   .et-matrix-viewport {
  max-height: none;
  flex:       1 1 auto;
}

/* Dark-mode overrides — exam timetable */
html[data-theme="dark"] .et-matrix th,
html[data-theme="dark"] .et-matrix td                { border-color: var(--line); }
html[data-theme="dark"] .et-zoom-btn                 { box-shadow: var(--shadow-neu-sm); }
html[data-theme="dark"] .et-zoom-btn:hover           { box-shadow: var(--shadow-neu); }
html[data-theme="dark"] .et-matrix .cm-diag          { background: var(--glass-bg-header); }
html[data-theme="dark"] .et-matrix .cm-1             { background: hsl(45 60% 22%); color: hsl(45 90% 72%); }
html[data-theme="dark"] .et-matrix .cm-2             { background: hsl(33 60% 22%); color: hsl(33 80% 72%); }
html[data-theme="dark"] .et-matrix .cm-3             { background: hsl(15 55% 28%); color: #fff; }
html[data-theme="dark"] .et-matrix .cm-4             { background: hsl(0 60% 32%); color: #fff; }
html[data-theme="dark"] .et-grid .et-overflow-row th,
html[data-theme="dark"] .et-grid .et-overflow-row td { background: rgba(240,96,96,0.08); }
html[data-theme="dark"] .et-del-btn:hover            { color: var(--danger); background: rgba(240,96,96,0.10); }
html[data-theme="dark"] .drill-course-chip          { color: var(--t0); }
html[data-theme="dark"] .drill-course-chip small    { color: var(--t3); }
html[data-theme="dark"] #scheduleGrid td            { color: var(--t0); }
html[data-theme="dark"] #scheduleGrid th            { color: var(--t3); }

/* Responsive tightening — exam timetable */
@media (max-width: 1024px) {
  .et-grid td         { min-width: 70px; }
  .et-matrix td       { width: 28px; height: 28px; min-width: 28px; }
  .et-dept-chips      { padding-inline-start: 8px; }
}
@media (max-width: 768px) {
  .et-grid            { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .et-grid td         { min-width: 60px; font-size: var(--text-xs); }
  .et-grid th         { font-size: var(--text-micro); }
  .et-matrix          { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .et-matrix td       { width: 26px; height: 26px; min-width: 26px; font-size: var(--text-micro); }
  .et-matrix thead th { height: 60px; }
  .et-matrix thead th > span { font-size: var(--text-micro); }
  .et-dept-chips      { padding-inline-start: 6px; margin-inline-start: 4px; }
  .et-legend          { gap: 6px; font-size: var(--text-micro); }
  .et-panel .row > [class*="col-md-"],
  .page-panel .row > [class*="col-md-"] {
    flex:      0 0 100%;
    max-width: 100%;
  }
}

/* Dark borders for the DB-admin sections and Section Planning's advanced panel.
   (They used to ride in the Timetable Workspace's dark block; that page's rules
   now live in timetable-workspace.css, loaded only by the page.) */
html[data-theme="dark"] .dba-section,
html[data-theme="dark"] .dba-nav-item,
html[data-theme="dark"] .sp-adv-wrap {
  border-color: rgba(255,255,255,0.06);
}


/* ============================================================
   PLANNER — shared palette and week-grid base
   ------------------------------------------------------------
   The old planner page was retired on 2026-11-25; its rules went with it
   (the board's are below, prefix plb-). What stays is shared: the --pl-*
   palette and the WeekGrid base rules student-timetable.js draws with.
   Introduces --pl-overlay-* / --pl-danger-* / --pl-warn-* /
   --pl-ok-* / --pl-conflict-cell CSS custom properties for
   this feature's overlay palette. Dark variants at the bottom.
   ============================================================ */

:root {
  --pl-overlay-1:     rgba(17,17,68,0.03);
  --pl-overlay-2:     rgba(17,17,68,0.04);
  --pl-overlay-3:     rgba(17,17,68,0.05);
  --pl-overlay-4:     rgba(17,17,68,0.06);
  --pl-overlay-5:     rgba(17,17,68,0.08);
  --pl-overlay-6:     rgba(17,17,68,0.025);
  --pl-danger-bg:     rgba(192,48,48,0.06);
  --pl-danger-text:   #b91c1c;
  --pl-danger-btn:    rgba(220,38,38,0.08);
  --pl-danger-btn-h:  rgba(220,38,38,0.14);
  --pl-danger-border: rgba(220,38,38,0.1);
  --pl-warn-text:     #b45309;
  --pl-warn-border:   rgba(245,158,11,0.15);
  --pl-ok-text:       #047857;
  --pl-conflict-cell: #fecaca;
}

/* ------------------------------------------------------------
   Shared WeekGrid — "blocks" mode (split-screen look)
   Themed CSS-grid emitted by WeekGrid.renderWeekGrid({mode:'blocks'}).
   Pastel cell background + accent left-border arrive inline from
   colorForCourse()/colorForCourseBorder() (already theme-aware), so
   this owns only layout, grid lines, headers, and status markers —
   light + dark both work via design tokens.
   ------------------------------------------------------------ */
.wg-blocks {
  display:          grid;
  grid-template-columns: 50px repeat(var(--wg-days, 5), minmax(0, 1fr));
  grid-auto-rows:   21px;
  gap:              1px;
  background:       var(--line);
  border:           1px solid var(--line);
  border-radius:    var(--radius);
  overflow:         hidden;
}
.wg-blocks .wg-h {
  display:          flex;
  align-items:      center;
  justify-content:  center;
  background:       var(--card);
  font-size:        var(--text-micro);
  font-weight:      700;
  color:            var(--t3);
  text-transform:   uppercase;
  letter-spacing:   0.03em;
  position:         sticky;
  top:              0;
  z-index:          3;
}
.wg-blocks .wg-cor { color: var(--t4); }
.wg-blocks .wg-t {
  display:          flex;
  align-items:      center;
  justify-content:  center;
  background:       var(--card);
  font-family:      var(--font-mono, monospace);
  font-size:        var(--text-micro);
  color:            var(--t4);
}
.wg-blocks .wg-cell {
  background:       var(--pl-overlay-1);
  min-width:        0;
  overflow:         hidden;
}
.wg-blocks .wg-filled {
  position:             relative;
  display:              flex;
  flex-direction:       column;
  justify-content:      center;
  gap:                  1px;
  padding:              2px 5px;
  overflow:             hidden;
  border-inline-start:  3px solid var(--teal);
  border-radius:        3px;
  z-index:              1;
}
.wg-blocks .wg-filled .wg-cid {
  font-family:      var(--font-mono, monospace);
  font-weight:      700;
  font-size:        var(--text-xs);
  line-height:      1.1;
  color:            var(--ink);
  white-space:      nowrap;
  overflow:         hidden;
  text-overflow:    ellipsis;
}
.wg-blocks .wg-filled .wg-meta {
  font-size:        var(--text-micro);
  line-height:      1.15;
  color:            var(--t3);   /* --t4 was 4.2:1 on the block's tint */
  white-space:      nowrap;
  overflow:         hidden;
  text-overflow:    ellipsis;
}
/* In dark the block tints are deep course hues: --t3 was 3.6:1 on them, --t1 is
   5.8:1 on the darkest. */
html[data-theme="dark"] .wg-blocks .wg-filled .wg-meta { color: var(--t1); }

.plan-black { background: var(--ink);    color: #fff; }
.plan-red { background: var(--danger); color: #fff; }
.plan-green { background: var(--btn-primary-bg); color: var(--btn-primary-ink); }
.plan-prereq { background: var(--royal);  color: #fff; }

/* Details chevron */
details[open] > summary .i                  { transform: rotate(90deg); }
details > summary::-webkit-details-marker   { display: none; }

/* RTL polish */
[dir="rtl"] .form-check                     { padding-right: 1.5em; padding-left: 0; }
[dir="rtl"] .form-check .form-check-input   { float: right; margin-right: -1.5em; margin-left: 0.5em; }
[dir="rtl"] .ms-auto                        { margin-left: 0 !important; margin-right: auto !important; }

/* Dark-mode overrides — planner */
html[data-theme="dark"] {
  --pl-overlay-1:     rgba(255,255,255,0.03);
  --pl-overlay-2:     rgba(255,255,255,0.04);
  --pl-overlay-3:     rgba(255,255,255,0.06);
  --pl-overlay-4:     rgba(255,255,255,0.06);
  --pl-overlay-5:     rgba(255,255,255,0.08);
  --pl-overlay-6:     rgba(255,255,255,0.025);
  --pl-danger-bg:     rgba(240,96,96,0.08);
  --pl-danger-text:   #f97066;   /* was #f06060: 4.1:1 on its own 10% wash, 5.0:1 here */
  --pl-danger-btn:    rgba(240,96,96,0.10);
  --pl-danger-btn-h:  rgba(240,96,96,0.18);
  --pl-danger-border: rgba(240,96,96,0.15);
  --pl-warn-text:     #f59e0b;
  --pl-warn-border:   rgba(245,158,11,0.20);
  --pl-ok-text:       #2ec9a0;
  --pl-conflict-cell: hsl(0 40% 22%);
}

/* ============================================================
   PLANNER BOARD (prefix plb-) — the new staff planner screen
   ------------------------------------------------------------
   core/templates/core/planner_board.html + static/js/page-planner-board.js,
   (the only planner page since 2026-11-25). Everything here starts with
   `.plb`; layout properties are logical (inline/block), so right-to-left mirrors
   by itself. The page's own width decides the layout (container query on
   `.plb`), not the window's, because the sidebar takes a share of the window.
   ============================================================ */
.plb {
  container: plb / inline-size;
  --plb-gap: 28px;
  --plb-row: 8px;
  --plb-reg: hsl(232 70% 93%);
  --plb-reg-edge: hsl(232 50% 62%);
  --plb-new: hsl(162 60% 90%);
  --plb-new-edge: hsl(162 60% 32%);
  /* One colour per course, ten of them (S6): an edge/swatch colour and the tint a week block
     sits on. Chosen in OKLCH, 36 degrees apart with the lightness alternating round the wheel,
     and numbered so that consecutive numbers (first-free assignment) are 108 degrees apart.
     Least pairwise OKLab distance: edges 0.139, tints 0.061 (light); 0.124 and 0.062 (dark).
     --ink and --t2 on every tint are at least 6.8:1 (light) and 6.1:1 (dark). */
  --plb-c1: #c95f47;
  --plb-c1-t: #feded6;
  --plb-c2: #26731f;
  --plb-c2-t: #bee1ba;
  --plb-c3: #3587d3;
  --plb-c3-t: #d4e9ff;
  --plb-c4: #9b3660;
  --plb-c4-t: #fbc5d6;
  --plb-c5: #8e8700;
  --plb-c5-t: #ebeab8;
  --plb-c6: #016c7e;
  --plb-c6-t: #a4e2f0;
  --plb-c7: #a964b4;
  --plb-c7-t: #fad9ff;
  --plb-c8: #865400;
  --plb-c8-t: #f2cfa8;
  --plb-c9: #029983;
  --plb-c9-t: #b8f5e6;
  --plb-c10: #5c50ab;
  --plb-c10-t: #d2d1fe;
  display: flex; flex-direction: column; gap: 8px;
  font-size: var(--text-sm); line-height: 18px; color: var(--t2);
  font-variant-numeric: tabular-nums;
}
html[data-theme="dark"] .plb {
  --plb-reg: hsl(232 45% 22%);
  --plb-reg-edge: hsl(232 55% 66%);
  --plb-new: hsl(162 45% 18%);
  --plb-new-edge: hsl(162 60% 52%);
  --plb-c1: #feb19f;
  --plb-c1-t: #592e24;
  --plb-c2: #74b46d;
  --plb-c2-t: #1a3717;
  --plb-c3: #9cccff;
  --plb-c3-t: #1f3e5c;
  --plb-c4: #dd80a1;
  --plb-c4-t: #48202f;
  --plb-c5: #d1cc6b;
  --plb-c5-t: #403e0f;
  --plb-c6: #1eb4cf;
  --plb-c6-t: #01363f;
  --plb-c7: #ecadf6;
  --plb-c7-t: #4c3050;
  --plb-c8: #d19345;
  --plb-c8-t: #432801;
  --plb-c9: #60e1c7;
  --plb-c9-t: #01473c;
  --plb-c10: #9b96e9;
  --plb-c10-t: #2d294e;
}
.plb-status { margin: 0; min-height: 18px; font-size: var(--text-xs); color: var(--t3); }
.plb-status[data-kind="error"] { color: var(--sev-critical); font-weight: 600; }
.plb-status[data-kind="warn"] { color: var(--sev-warning-ink); font-weight: 600; }
.plb-h2 { margin: 0; font-size: var(--text-md); font-weight: 700; line-height: 22px; color: var(--text-brand); }
.plb-mic {
  font-family: var(--font-mono); font-size: var(--text-micro); line-height: 14px;
  text-transform: uppercase; color: var(--t3);
}
.plb-empty { margin: 0; font-size: var(--text-xs); line-height: 18px; color: var(--t3); }
.plb-empty strong { color: var(--t2); }
.plb-note { margin: 6px 0 0; font-size: var(--text-xs); line-height: 16px; color: var(--sev-warning-ink); }
.plb-cd { font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 700; line-height: 16px; color: var(--ink); white-space: nowrap; }

/* masthead: the title row of the page header carries the fields that load a student */
.plb-ctx {
  font-family: var(--font-mono); font-size: var(--text-micro); font-weight: 600; line-height: 16px;
  border-radius: var(--radius-pill);
  background: var(--brand-soft); color: var(--text-brand);
}
.plb-load { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; }
.plb-cap {
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--control-h-sm);
  padding: 0 10px; border-radius: var(--radius-sm); box-shadow: inset 0 0 0 1px var(--control-edge);
  color: var(--t3); cursor: text;
}
.plb-cap > span { font-size: var(--text-xs); font-weight: 600; color: var(--t3); white-space: nowrap; }
.plb-cap input, .plb-cap select {
  border: 0; outline: 0; box-shadow: none; background: transparent; margin: 0; padding: 0;
  min-width: 0; font: inherit; font-size: var(--text-base); color: var(--ink);
}
.plb-cap input:focus, .plb-cap select:focus { box-shadow: none; outline: 0; }
.plb-cap:focus-within { box-shadow: inset 0 0 0 2px var(--text-brand); }
.plb-w-id { width: 10ch; }
.plb-w-year { width: 5ch; }
.plb-termwrap { position: relative; }
.plb-termbtn { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.plb-termpop {
  position: absolute; inset-inline-end: 0; top: 100%; z-index: 6; margin-top: 4px; padding: 8px;
  display: flex; flex-wrap: wrap; gap: 6px; background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow-lift), 0 0 0 1px var(--rule);
}
.plb-termpop[hidden] { display: none; }
.plb-lk {
  display: inline-flex; align-items: center; gap: 4px; min-height: var(--control-h-sm); padding: 0;
  border: 0; background: none; cursor: pointer;
  font-size: var(--text-xs); font-weight: 600; line-height: 16px; color: var(--text-brand); white-space: nowrap;
}
.plb-lk:disabled { color: var(--t3); cursor: default; }

/* The page is one flat sheet: the student band, a closed disclosure, three zones, an apply bar.
   Under the options zone the projection and the guidance sit side by side. */
.plb-band {
  display: grid; column-gap: var(--plb-gap); row-gap: 12px;
}
.plb-band { grid-template-columns: minmax(0, 1fr); }
.plb-grad, .plb-guide, .plb-week { min-width: 0; }
.plb-grad { display: flex; flex-direction: column; gap: 4px; }
/* The old heading row holds only the visually hidden title and the "why" button: with the
   button hidden it must take no height (the header above already says it all). */
.plb-grad > .plb-gh:has(#plbGradWhyBtn[hidden]) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.plb-guide { position: relative; }
.plb-guide[hidden] { display: none; }

/* zones: a serif heading with its number, one rule under the row, no cards */
.plb-zone { display: flex; flex-direction: column; gap: 12px; margin-block-start: 16px; min-width: 0; }
.plb-zh { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding-block-end: 8px; border-bottom: 1px solid var(--rule-strong); }
.plb-zh h2 {
  margin: 0 auto 0 0; display: flex; align-items: baseline; gap: 10px;
  font-family: var(--font-serif); font-size: var(--text-lg); font-weight: 400; line-height: 1.15; color: var(--ink);
}
.plb-zn { font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 600; line-height: 16px; color: var(--text-brand); }
.plb-zh .plb-changed { margin: 0; }
.plb-zh-act { min-height: var(--control-h); }

/* the student band: four facts in one row */
.plb-sband { padding-block: 10px 6px; border-top: 1px solid var(--rule-strong); }
.plb-sgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 28px; }
.plb-sgrid > .plb-empty { grid-column: 1 / -1; }
.plb-sf { display: flex; flex-direction: column; min-width: 0; }
.plb-big {
  font-family: var(--font-serif); font-weight: 400; line-height: 1.1; color: var(--ink);
  overflow-wrap: anywhere;
}
.plb-big-u { font-family: var(--font-body); font-size: var(--text-sm); color: var(--t3); }
.plb-smeta { color: var(--t3); overflow-wrap: anywhere; }
.plb-bar { overflow: hidden; }
.plb-bar > i { display: block; block-size: 100%; background: var(--text-brand); }

/* the current timetable: a closed disclosure under the band */
.plb-curtt { border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.plb-curtt[hidden] { display: none; }
.plb-curtt > summary {
  display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none;
  font-size: var(--text-sm); color: var(--t2);
}
.plb-curtt > summary::-webkit-details-marker { display: none; }
.plb-curtt > summary:focus-visible { outline: 2px solid var(--text-brand); outline-offset: 2px; }
.plb-curtt-ch { flex: none; color: var(--t3); transition: transform .15s; }
.plb-curtt[open] .plb-curtt-ch { transform: rotate(90deg); }
html[dir="rtl"] .plb-curtt-ch { transform: scaleX(-1); }
html[dir="rtl"] .plb-curtt[open] .plb-curtt-ch { transform: scaleX(-1) rotate(90deg); }
.plb-curtt-t { flex: none; font-weight: 700; color: var(--ink); }
.plb-curtt-d { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--t3); }
.plb-curtt-s { flex: none; margin-inline-start: auto; font-size: var(--text-xs); }
.plb-curtt-hide, .plb-curtt[open] .plb-curtt-show { display: none; }
.plb-curtt[open] .plb-curtt-hide { display: inline; }
.plb-curtt-body { padding-block: 6px 12px; }

/* rules: one wrapping row of labelled controls; the rules an adviser changes most come first */
.plb-rules { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px 28px; }
.plb-rl { margin: 0; font-size: var(--text-xs); line-height: 16px; color: var(--t2); }
.plb-rc-row { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.plb-rc-row--checks { gap: 0; align-self: flex-end; }
.plb-seg { display: inline-flex; border-radius: var(--radius-sm); box-shadow: inset 0 0 0 1px var(--control-edge); }
.plb-seg-o {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--control-h); padding-inline: 12px; cursor: pointer;
  font-size: var(--text-xs); font-weight: 600; line-height: 16px; color: var(--t2);
}
.plb-seg-o:first-child { border-start-start-radius: var(--radius-sm); border-end-start-radius: var(--radius-sm); }
.plb-seg-o:last-child { border-start-end-radius: var(--radius-sm); border-end-end-radius: var(--radius-sm); }
.plb-seg-o input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.plb-seg-o:has(input:checked) { background: var(--brand-soft); color: var(--text-brand); box-shadow: inset 0 0 0 1px var(--text-brand); }
.plb-seg-o:has(input:focus-visible) { outline: 2px solid var(--text-brand); outline-offset: 2px; }
.plb-rc-in {
  width: 7ch; min-height: var(--control-h); padding: 0 8px; margin: 0; border: 0; border-radius: var(--radius-sm);
  box-shadow: inset 0 0 0 1px var(--control-edge); background: transparent;
  font: inherit; font-size: var(--text-sm); color: var(--ink); text-align: end;
}
.plb-rc-in:focus { outline: 0; box-shadow: inset 0 0 0 2px var(--text-brand); }
.plb-rc-in[aria-invalid="true"] { box-shadow: inset 0 0 0 2px var(--sev-critical); }
.plb-check--off { color: var(--t3); cursor: default; }
.plb-check--off input { cursor: default; }
.plb-usual { margin: 0; font-weight: 600; line-height: 16px; }
.plb-usual[hidden] { display: none; }
.plb-changed { margin: 2px 0 0; font-size: var(--text-xs); font-weight: 700; line-height: 16px; color: var(--sev-warning-ink); }
.plb-changed[hidden] { display: none; }
.plb-confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding-block: 8px; border-top: 1px solid var(--rule); }
.plb-confirm[hidden] { display: none; }
.plb-confirm-t { flex: 1 1 280px; margin: 0; font-size: var(--text-sm); line-height: 18px; color: var(--sev-warning-ink); font-weight: 600; }
/* While the registered courses are rows of the plan (Ignore): what that means and the way back.
   Its words are a live region that stays in the page; empty (Keep), the bar takes no room. */
.plb-convbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; }
.plb-convbar[data-on="true"] {
  margin-block: 8px 4px; padding: 6px 12px; border-radius: var(--radius-sm);
  background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--teal-border);
}
.plb-convbar-t { margin: 0; font-size: var(--text-sm); font-weight: 600; line-height: 20px; color: var(--text-brand); }
.plb-convbar > .plb-convbar-ask { flex: 1 1 100%; padding-block: 6px 2px; border-top-color: var(--teal-border); }

/* option strip: only the registered week until a build exists */
.plb-opts { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.plb-tabs { display: flex; flex-wrap: wrap; align-items: stretch; }
/* The tab list holds tabs only; "More options" is a disclosure beside it. Tabs stretch to one
   height so their names share a line and their underlines sit on the strip's rule. */
.plb-tablist { flex: 1 1 0; min-width: 0; display: flex; flex-wrap: wrap; align-items: stretch; }
.plb-tab {
  flex: 1 1 150px; max-width: 236px; min-width: 0; display: flex; flex-direction: column; margin-block-end: -1px;
  border: 0; border-bottom: 2px solid transparent; background: none;
  text-align: start; cursor: pointer; color: inherit;
}
.plb-tab[aria-selected="true"] { border-bottom-color: var(--text-brand); }
.plb-tab-n { display: flex; flex-wrap: wrap; align-items: center; gap: 0 6px; font-size: var(--text-base); font-weight: 600; line-height: 20px; color: var(--ink); overflow-wrap: anywhere; }
.plb-tab[aria-selected="true"] .plb-tab-n { color: var(--text-brand); font-weight: 700; }
.plb-tab-lock { display: inline-flex; color: var(--t4); }
.plb-tab-lock[hidden] { display: none; }
.plb-tab-cr { font-size: var(--text-xs); font-weight: 500; line-height: 16px; color: var(--t3); }
.plb-tab-aka { font-weight: 500; color: var(--t3); }   /* the options this tab also stands for */
.plb-tab-x { font-size: var(--text-xs); line-height: 16px; color: var(--t3); }
.plb-tab-x:empty { display: none; }
.plb-tab-warn { font-weight: 700; color: var(--sev-warning-ink); }
.plb-tab:focus-visible, .plb-more-btn:focus-visible, .plb-more-item:focus-visible { outline: 2px solid var(--text-brand); outline-offset: 2px; }
.plb-more { position: relative; flex: 0 0 auto; align-self: center; }
.plb-more-btn {
  display: inline-flex; align-items: center; min-height: var(--control-h-sm); padding: 0 10px; border: 0; border-radius: var(--radius-sm);
  background: none; box-shadow: inset 0 0 0 1px var(--control-edge); cursor: pointer;
  font-size: var(--text-xs); font-weight: 600; line-height: 16px; color: var(--text-brand); white-space: nowrap;
}
.plb-more-list {
  position: absolute; inset-inline-end: 0; top: 100%; z-index: 5; margin-top: 4px; padding: 4px;
  display: flex; flex-direction: column; gap: 2px; min-width: 220px; max-width: min(360px, 90vw);
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-lift), 0 0 0 1px var(--rule);
}
.plb-more-list[hidden] { display: none; }
.plb-more-item {
  display: block; min-height: var(--control-h-sm); padding: 6px 8px; border: 0; border-radius: var(--radius-sm); background: none;
  text-align: start; cursor: pointer; font-size: var(--text-sm); line-height: 18px; color: var(--ink);
}
.plb-more-item:hover { background: var(--brand-soft); color: var(--text-brand); }

/* build, review and apply */
.plb-buildrow { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding-top: 4px; }
.plb-buildnotes { flex: 1 1 260px; min-width: 0; display: flex; }
.plb-buildrow .btn, .plb-applybar .btn { min-height: var(--control-h); }
.plb-applybar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  margin-block-start: 20px; background: var(--card);
}
.plb-applynotes { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.plb-acts-note { margin: 0; font-size: var(--text-xs); line-height: 16px; color: var(--t3); overflow-wrap: anywhere; }
.plb-acts-note:empty, .plb-acts-note[hidden] { display: none; }
.plb-acts-note[data-kind="error"] { color: var(--sev-critical); font-weight: 600; }
.plb-acts-note[data-kind="warn"], .plb-acts-why { color: var(--sev-warning-ink); font-weight: 600; }
.plb-acts-note[data-kind="ok"] { color: var(--t2); font-weight: 600; }
.plb-buildnote { min-width: 0; padding-block: 4px; font-size: var(--text-sm); line-height: 18px; color: var(--t2); }
.plb-buildnote[hidden] { display: none; }
.plb-buildnote-lead { margin: 0; font-weight: 700; color: var(--sev-warning-ink); }
.plb-buildnote-list { margin: 2px 0 0; padding-inline-start: 18px; }
.plb-apply-list { margin: 4px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; }
.plb-apply-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; padding-block: 6px; border-top: 1px solid var(--line); font-size: var(--text-sm); line-height: 18px; color: var(--ink); }
.plb-apply-row:first-child { border-top: 0; }
.plb-apply-when { font-size: var(--text-xs); color: var(--t3); }
.plb-apply-p { margin: 8px 0 0; font-size: var(--text-sm); line-height: 18px; color: var(--t2); }

/* panes */
.plb-ph { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; min-height: var(--control-h-sm); margin-bottom: 6px; }
.plb-phn { font-size: var(--text-xs); line-height: 16px; color: var(--t3); white-space: nowrap; }
.plb-phn[data-over="true"] { color: var(--sev-warning-ink); font-weight: 600; }
/* zone 02: the course picker. Available | transfer column | Your plan. Flat: 1px rules, no cards. */
.plb-srcrow { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 16px; }
.plb-srcf { display: flex; flex-direction: column; gap: 4px; flex: 0 1 320px; min-width: 0; }
.plb-select {
  width: 100%; min-height: var(--control-h); padding: 0 10px; border: 0; border-radius: var(--radius-sm);
  background: transparent; box-shadow: inset 0 0 0 1px var(--control-edge);
  font: inherit; font-size: var(--text-base); color: var(--ink);
}
.plb-select:focus-visible { outline: 2px solid var(--text-brand); outline-offset: 1px; }
.plb-find { min-height: var(--control-h); }
.plb-find input { flex: 1 1 auto; width: 100%; font-size: var(--text-base); }
.plb-pick { display: grid; grid-template-columns: minmax(0, 1fr) 64px minmax(0, 1fr); align-items: start; }
.plb-pane { position: relative; min-width: 0; border-top: 1px solid var(--rule-strong); }
.plb-pane .plb-ph { margin-bottom: 0; }
.plb-h3 { flex: 1 1 auto; margin: 0; font-size: var(--text-sm); font-weight: 700; line-height: 20px; color: var(--ink); }
.plb-pload { font-size: var(--text-sm); line-height: 20px; color: var(--t3); white-space: nowrap; }
.plb-pload b { font-size: var(--text-md); font-weight: 700; color: var(--ink); }
.plb-pload[data-over="true"], .plb-pload[data-over="true"] b { color: var(--sev-warning-ink); }
.plb-meter { display: flex; block-size: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.plb-meter[hidden] { display: none; }
.plb-meter > i { display: block; block-size: 100%; }
.plb-meter-p { background: var(--text-brand); }
.plb-meter-r { background: var(--rule-strong); }
.plb-meter[data-over="true"] .plb-meter-p { background: var(--sev-warning-ink); }
.plb-mline { margin: 4px 0 6px; font-size: var(--text-xs); line-height: 16px; color: var(--t3); }
.plb-mline[data-over="true"] { color: var(--sev-warning-ink); font-weight: 600; }
.plb-plist { display: flex; flex-direction: column; min-width: 0; }
.plb-pad { padding-block: 10px; }

/* an available course: chevron | tick | code | name | meta, its sections folded under it */
.plb-arow { border-top: 1px solid var(--line); }
.plb-ar-main {
  display: grid; grid-template-columns: 36px 20px max-content minmax(0, 1fr) auto; align-items: center;
  column-gap: 8px; padding-inline-end: 8px;
}
.plb-ar-main--off { grid-template-columns: max-content minmax(0, 1fr) auto; padding-inline-start: 12px; color: var(--t3); }
.plb-chev {
  display: inline-flex; align-items: center; justify-content: center; inline-size: 36px; block-size: 36px; padding: 0;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--t3); cursor: pointer;
}
.plb-chev svg { transform: rotate(-90deg); }
html[dir="rtl"] .plb-chev svg { transform: rotate(90deg); }
.plb-chev[aria-expanded="true"] svg, html[dir="rtl"] .plb-chev[aria-expanded="true"] svg { transform: none; }
.plb-chev:hover { color: var(--text-brand); }
.plb-chev:focus-visible, .plb-secbtn:focus-visible, .plb-req:focus-visible, .plb-xb:focus-visible, .plb-fold:focus-visible,
.plb-tick:focus-visible, .plb-ib:focus-visible { outline: 2px solid var(--text-brand); outline-offset: 2px; }
.plb-code { white-space: nowrap; font-family: var(--font-mono); color: var(--ink); }
.plb-nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; color: var(--ink); }
.plb-nm--wrap { display: block; white-space: normal; overflow-wrap: anywhere; }
.plb-ar-main--off .plb-nm { color: var(--t3); }
.plb-meta { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 2px 4px; font-size: var(--text-xs); line-height: 16px; color: var(--t3); }
.plb-fxl { padding-block: 0 6px; padding-inline: 64px 8px; }
.plb-secs { padding-block-end: 8px; padding-inline-start: 44px; }
.plb-secs[hidden], .plb-blocked[hidden] { display: none; }
.plb-sec { display: grid; grid-template-columns: 20px 44px minmax(0, 1fr) auto; align-items: center; column-gap: 8px; padding-block: 3px; padding-inline-end: 8px; border-top: 1px solid var(--line); font-size: var(--text-xs); line-height: 16px; color: var(--t2); }
.plb-sec--h { border-top: 0; }
.plb-sec[data-off="true"] { color: var(--t3); }
label.plb-sec:not([data-off="true"]) { cursor: pointer; }
.plb-sec-n { font-family: var(--font-mono); font-weight: 700; color: var(--ink); }
.plb-sec-seats { text-align: end; white-space: nowrap; }
.plb-only-row { padding-top: 6px; }
.plb-only svg { flex: none; margin-inline-start: 4px; }
.plb-foldrow { border-top: 1px solid var(--line); }
.plb-fold {
  display: flex; align-items: center; gap: 8px; inline-size: 100%; min-height: 44px; padding: 0 8px 0 0; border: 0; background: none;
  text-align: start; font: inherit; font-size: var(--text-xs); font-weight: 600; color: var(--t2); cursor: pointer;
}
.plb-fold svg { flex: none; transform: rotate(-90deg); }
html[dir="rtl"] .plb-fold svg { transform: rotate(90deg); }
.plb-fold[aria-expanded="true"] svg, html[dir="rtl"] .plb-fold[aria-expanded="true"] svg { transform: none; }
.plb-blocked .plb-arow { border-top: 1px solid var(--line); }

/* the transfer column */
.plb-xfer { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; align-self: center; padding-inline: 4px; }
.plb-xgap { display: block; block-size: 16px; }
.plb-xb {
  display: inline-flex; align-items: center; justify-content: center; inline-size: 44px; block-size: 44px; padding: 0;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-brand);
  box-shadow: inset 0 0 0 1px var(--control-edge); cursor: pointer;
}
.plb-xb:hover:not(:disabled) { background: var(--brand-soft); }
.plb-xb:disabled { color: var(--t4); box-shadow: inset 0 0 0 1px var(--rule); cursor: default; opacity: .6; }
/* "Towards the plan" is drawn pointing right; the plan is on the left in right-to-left, so it flips there. */
.plb-xb[data-side="plan-to-list"] .plb-dir { transform: scaleX(-1); }
html[dir="rtl"] .plb-dir { transform: scaleX(-1); }
html[dir="rtl"] .plb-xb[data-side="plan-to-list"] .plb-dir { transform: none; }

/* your plan */
.plb-prow {
  display: grid; grid-template-columns: 20px max-content minmax(0, 1fr) auto auto 44px; align-items: center; column-gap: 8px;
  padding-block: 4px; border-top: 1px solid var(--line);
}
.plb-prow[data-open="true"] { background: var(--brand-soft); }
/* A registered course as a row (S7): its quiet tag, and for one held as load only (no usable
   section) a note where the section control would be; its remove button keeps the last column. */
.plb-flag.plb-reg-tag { background: var(--line); color: var(--t2); }
/* A tag under a name never reaches past the name's cell: a narrow pane ends it in an ellipsis. */
.plb-sl > .plb-flag { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plb-load-note { font-size: var(--text-xs); line-height: 16px; color: var(--t3); }
.plb-prow--load > .plb-ib { grid-column: 6; }
.plb-pmain { display: flex; flex-direction: column; min-width: 0; }
.plb-cr { font-size: var(--text-xs); line-height: 16px; color: var(--t3); white-space: nowrap; }
.plb-secbtn {
  display: inline-flex; align-items: center; gap: 4px; min-height: var(--control-h-sm); padding: 0 8px; border: 0; border-radius: var(--radius-sm);
  background: transparent; box-shadow: inset 0 0 0 1px var(--control-edge); cursor: pointer; white-space: nowrap;
  max-width: 220px; min-width: 0; font: inherit; font-size: var(--text-xs); font-weight: 600; color: var(--t2);
}
.plb-secbtn-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plb-secbtn[data-limited="true"] { background: var(--brand-soft); color: var(--text-brand); box-shadow: inset 0 0 0 1px var(--teal-border); }
.plb-secbtn[aria-expanded="true"] svg { transform: rotate(180deg); }
.plb-req {
  display: inline-flex; align-items: center; justify-content: center; min-width: var(--control-h-sm);
  border: 0; background: transparent; cursor: pointer;
  font: inherit; font-size: var(--text-xs); color: var(--t3);
}
.plb-req:hover { color: var(--text-brand); }
.plb-hint {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 8px 0 0; padding: 12px;
  border: 1px dashed var(--rule-strong); border-radius: var(--radius-sm); font-size: var(--text-xs); line-height: 16px; color: var(--t3);
}
.plb-hint svg { flex: none; }
.plb-pop {
  position: absolute; z-index: 6; display: flex; flex-direction: column; gap: 8px; padding: 12px; max-height: 440px; overflow: auto;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-lift), 0 0 0 1px var(--rule);
}
.plb-pop[hidden] { display: none; }
.plb-pane--plan .plb-ph .plb-lk { white-space: nowrap; }
.plb-sc { display: block; font-size: var(--text-xs); line-height: 16px; color: var(--t3); }
.plb-sc--blocked { padding-inline-end: 0; }
.plb-sc--miss { white-space: normal; color: var(--sev-warning-ink); font-weight: 600; }
.plb-ib {
  display: inline-flex; align-items: center; justify-content: center; width: var(--control-h-sm); height: var(--control-h-sm);
  padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--t3); cursor: pointer;
}
.plb-ib:hover { color: var(--text-brand); }
.plb-tick { width: 16px; height: 16px; margin: 0; accent-color: var(--text-brand); cursor: pointer; }
.plb-chip {
  display: inline-flex; align-items: center; padding: 1px 8px; border-radius: var(--radius-sm);
  font-size: var(--text-micro); font-weight: 700; line-height: 16px; background: var(--sev-critical-bg); color: var(--sev-critical);
}

/* week */
.plb-lg { display: inline-flex; align-items: center; gap: 12px; margin-inline-start: auto; font-size: var(--text-xs); line-height: 16px; color: var(--t3); white-space: nowrap; }
.plb-lg-i { display: inline-flex; align-items: center; gap: 5px; }
.plb-k { flex: none; width: 11px; height: 16px; border-radius: 2px; background: var(--plb-reg); border-inline-start: 3px solid var(--plb-reg-edge); }
.plb-k--new { background: var(--plb-new); border-inline-start-color: var(--plb-new-edge); }
.plb-wkwrap { overflow-x: auto; }
.plb-wk {
  display: grid; min-width: 440px;
  grid-template-columns: 50px repeat(var(--plb-days, 5), minmax(0, 1fr));
  grid-template-rows: 22px repeat(var(--plb-rows, 28), var(--plb-row)) auto;
}
.plb-dh { align-self: center; padding-inline-start: 8px; font-size: var(--text-micro); font-weight: 700; line-height: 14px; letter-spacing: .04em; text-transform: uppercase; color: var(--t3); }
.plb-dh:lang(ar) { letter-spacing: 0; }
.plb-tm { grid-column: 1; margin-top: -7px; padding-inline-end: 8px; text-align: end; font-family: var(--font-mono); font-size: var(--text-micro); line-height: 14px; color: var(--t4); }
.plb-hl { grid-column: 2 / -1; height: 1px; align-self: start; background: var(--rule); }
.plb-vl { grid-row: 1 / -1; width: 1px; justify-self: start; background: var(--rule); }
.plb-b {
  margin: 1px; padding-block: 2px; padding-inline: 5px 4px; border-radius: 3px; overflow: hidden;
  display: flex; flex-wrap: wrap; align-content: flex-start; column-gap: 6px; min-width: 0;
  border-inline-start: 3px solid var(--plb-reg-edge); background: var(--plb-reg);
}
.plb-b[data-kind="new"] { border-inline-start-color: var(--plb-new-edge); background: var(--plb-new); }
.plb-b[data-clash="true"] { outline: 2px solid var(--sev-critical); outline-offset: -2px; }
/* An option's class at the section the student holds (an edited plan): a bar along its foot. */
.plb-b[data-own="true"], .plb-k--own { box-shadow: inset 0 -3px 0 var(--t3); }
/* A block's lines are whole lines: the code, the section and the time never break inside, and
   what a column is too narrow for ends in an ellipsis instead of half a line. */
.plb-bt { flex: 1 0 100%; min-width: 0; font-size: var(--text-micro); line-height: 14px; color: var(--t2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* A time reads left to right in both languages, so the ellipsis it may end in takes the end of the
   range, never the start hour (in a right-to-left box it would cut "11:" off the front). */
.plb-bt { direction: ltr; }
html[dir="rtl"] .plb-bt { text-align: right; }
.plb-b .plb-cd { min-width: 0; max-width: 100%; overflow: hidden; }
.plb-bs { margin-inline-start: auto; max-width: 100%; overflow: hidden; font-family: var(--font-mono); font-size: var(--text-micro); font-weight: 700; line-height: 14px; color: var(--t2); white-space: nowrap; }
/* A code and a section label read left to right in both languages (each is a <bdi dir="ltr">), so
   the ellipsis either may end in is the label's own and takes its end: on the code's or the
   section's box, in a right-to-left block, it took the START ("…E124" for COE124, "…1" for §M1).
   Each box is a row of its parts and only the label is cut; the lock and the word "alt" keep the
   box's start edge, and the word (a phone does not show it at all) gives way before the label. */
.plb-b .plb-cd, .plb-gb .plb-cd, .plb-bs { display: flex; align-items: baseline; }
.plb-b .plb-cd > bdi, .plb-gb .plb-cd > bdi, .plb-bs > bdi { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.plb-bs > .plb-alt-w { flex: 0 1000000 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: pre; }
/* How many lines a block holds is decided by the script from the block's own geometry (its rows
   x --plb-row against these line heights): "two" = code and section, then the time; "one" = a
   block too short for two lines, code · time · §section. Whatever a column is too narrow for
   gives way in this order: the section, then the time; the code last. One line is a flex row, and
   the order is its shrink weights: each is a million times the next, so a part takes no share of
   the shortfall (not even the sub-pixel that would end it in an ellipsis) until the one before it
   is gone. */
.plb-b[data-fit="two"], .plb-gb[data-fit="two"] {
  display: grid; grid-template-columns: minmax(0, max-content) minmax(0, 1fr); grid-template-areas: "cd bs" "bt bt";
  align-content: start; column-gap: 6px;
}
.plb-b[data-fit="two"] > .plb-cd, .plb-gb[data-fit="two"] > .plb-cd { grid-area: cd; }
.plb-b[data-fit="two"] > .plb-bs, .plb-gb[data-fit="two"] > .plb-bs { grid-area: bs; justify-self: end; }
.plb-b[data-fit="two"] > .plb-bt, .plb-gb[data-fit="two"] > .plb-bt { grid-area: bt; }
.plb-b[data-fit="one"], .plb-gb[data-fit="one"] { flex-wrap: nowrap; align-items: baseline; column-gap: 5px; }
.plb-b[data-fit="one"] > .plb-cd, .plb-gb[data-fit="one"] > .plb-cd { order: 0; flex: 0 1 auto; }
.plb-b[data-fit="one"] > .plb-bt, .plb-gb[data-fit="one"] > .plb-bt { order: 1; flex: 0 1000000 auto; }
.plb-b[data-fit="one"] > .plb-bs, .plb-gb[data-fit="one"] > .plb-bs { order: 2; flex: 0 1000000000000 auto; min-width: 0; }
/* An alternative: a section the adviser allowed, drawn dashed under the open course. Not a control. */
.plb-gb {
  margin: 1px; padding-block: 2px; padding-inline: 5px 4px; border-radius: 3px; overflow: hidden; pointer-events: none;
  display: flex; flex-wrap: wrap; align-content: flex-start; column-gap: 6px; min-width: 0;
  background: transparent; border: 1px dashed var(--t4); border-inline-start: 3px dashed var(--t4);
}
.plb-gb .plb-cd { min-width: 0; max-width: 100%; overflow: hidden; color: var(--t3); }
.plb-gb .plb-bs, .plb-gb .plb-bt { color: var(--t3); }
.plb-k--alt { background: transparent; border: 1px dashed var(--t4); border-inline-start: 3px dashed var(--t4); }
.plb-or { color: var(--t3); font-weight: 400; }
/* The lock is a part of the code's row (above): its foot on the code's baseline, then 1px lower,
   where it sat as an inline icon. */
.plb-b .plb-cd > svg { flex: none; position: relative; top: 1px; margin-inline-end: 3px; opacity: .75; }
/* On a phone a week column is too narrow for the word "alt": the dashed edge and the legend say it. */
@media (max-width: 768px) { .plb-gb .plb-alt-w { display: none; } }
.plb-free {
  display: flex; justify-content: center; padding-top: 94px; margin-inline-start: 1px;
  background: color-mix(in srgb, var(--ink) 3%, transparent); font-size: var(--text-xs); font-weight: 600; color: var(--t3);
}
.plb-df { display: flex; flex-direction: column; padding: 5px 8px 0; font-size: var(--text-xs); line-height: 16px; color: var(--t3); }
.plb-df b { font-weight: 600; color: var(--ink); }

/* edit rules */
.plb-check { display: flex; align-items: center; gap: 8px; min-height: var(--control-h-sm); font-size: var(--text-sm); font-weight: 600; color: var(--t1); cursor: pointer; }
.plb-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--text-brand); }
.plb-err { margin: 0; font-size: var(--text-xs); font-weight: 600; color: var(--sev-critical); }
.plb-err[hidden] { display: none; }

/* the course detail panel, seat warnings, the out-of-date build, "Why these options" */
.plb-dt-close:focus-visible, .plb-why-btn:focus-visible, .plb-dt-title:focus-visible {
  outline: 2px solid var(--text-brand); outline-offset: 2px;
}
.plb-few { font-weight: 700; color: var(--sev-warning-ink); }
.plb-nb { white-space: nowrap; }
.plb-dt-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.plb-dt-title { flex: 1 1 auto; min-width: 0; margin: 0; font-size: var(--text-md); font-weight: 700; line-height: 22px; color: var(--text-brand); overflow-wrap: anywhere; }
.plb-dt-cr { font-size: var(--text-xs); font-weight: 500; color: var(--t3); white-space: nowrap; }
.plb-dt-close {
  flex: none; min-height: var(--control-h-sm); padding: 0 10px; border: 0; border-radius: var(--radius-sm); background: none;
  box-shadow: inset 0 0 0 1px var(--control-edge); cursor: pointer;
  font-size: var(--text-xs); font-weight: 600; line-height: 16px; color: var(--text-brand);
}
.plb-dt-group { display: flex; flex-direction: column; gap: 0; min-width: 0; margin: 0; padding: 0; border: 0; }
.plb-dt-group legend { padding: 0; margin-bottom: 2px; }
.plb-dt-sec { display: flex; align-items: flex-start; gap: 8px; min-height: var(--control-h-sm); padding-block: 6px; border-top: 1px solid var(--line); cursor: pointer; }
.plb-dt-sec[data-unusable="true"] { color: var(--t3); }
div.plb-dt-sec { cursor: default; }
.plb-dt-radio { flex: none; width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--text-brand); cursor: pointer; }
.plb-dt-radio:disabled { cursor: not-allowed; }
.plb-dt-sec-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.plb-dt-sec-main { font-size: var(--text-sm); font-weight: 600; line-height: 18px; color: var(--ink); overflow-wrap: anywhere; }
.plb-dt-sec[data-unusable="true"] .plb-dt-sec-main { color: var(--t3); }
.plb-dt-sec-seats { font-size: var(--text-xs); line-height: 16px; color: var(--t3); }
.plb-dt-flags { display: flex; flex-wrap: wrap; gap: 4px; }
.plb-flag { padding: 0 6px; border-radius: var(--radius-sm); font-size: var(--text-micro); font-weight: 700; line-height: 16px; background: var(--brand-soft); color: var(--text-brand); }
.plb-flag--warn { background: var(--sev-warning-bg); color: var(--sev-warning-ink); }
.plb-flag--bad { background: var(--sev-critical-bg); color: var(--sev-critical); }
/* "GS311 (registered) likely counts for it": a muted hint on an elective row, never a warning */
.plb-flag--filled { background: var(--surface); color: var(--t2); }
.plb-meta .plb-flag--filled { font-weight: 500; }
.plb-dt-why { font-size: var(--text-xs); font-weight: 600; line-height: 16px; color: var(--sev-warning-ink); }
.plb-dt-hint { margin: 0 0 4px; font-size: var(--text-xs); line-height: 16px; color: var(--t3); }
.plb-tabs[data-stale] { border-bottom-style: dashed; }
/* Out-of-date options stay readable: the names lose their emphasis and the selected one its solid
   underline. Fading the whole tab dropped its small grey facts well below readable contrast. */
.plb-tabs[data-stale] .plb-tab[data-opt] .plb-tab-n { color: var(--t2); font-weight: 600; }
.plb-tabs[data-stale] .plb-tab[data-opt][aria-selected="true"] { border-bottom-color: var(--t3); border-bottom-style: dashed; }
.plb-tab-diff { color: var(--t2); }
.plb-tab-chg { color: var(--t2); }
.plb-why-btn { align-self: flex-start; }
.plb-why { display: flex; flex-direction: column; gap: 4px; padding-block: 4px; font-size: var(--text-xs); line-height: 16px; color: var(--t2); overflow-wrap: anywhere; }
.plb-why[hidden], .plb-why-btn[hidden] { display: none; }
.plb-why-list { margin: 0; padding-inline-start: 16px; display: flex; flex-direction: column; gap: 2px; }
.plb-why-h { margin: 4px 0 0; font-weight: 700; color: var(--sev-warning-ink); }
.plb-why-n { color: var(--t3); }
.plb-why-p { margin: 0; }

/* the guidance column, option names, and the planned blocks of the week that open the detail.
   Everything wraps: nothing here is sized to a text width. */
.plb-tab-nm { min-width: 0; }
.plb-tab-x--sg { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 8px; }
.plb-sg, .plb-sg-in { font-size: var(--text-micro); font-weight: 700; color: var(--text-brand); }
.plb-sg-in { margin-inline-start: 2px; }
.plb-fx { display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: 12px; row-gap: 6px; align-items: start; margin: 0; }
.plb-fr { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; align-items: start; }
.plb-fr > dt { padding-top: 3px; }
.plb-fr > dd { margin: 0; min-width: 0; }
.plb-fr--watch { margin-inline: -8px; padding: 5px 8px 6px; border-radius: var(--radius-sm); background: var(--sev-warning-bg); }
.plb-fr--watch > dt { color: var(--sev-warning-ink); }
.plb-gv { display: flex; flex-direction: column; min-width: 0; }
.plb-gt { font-size: var(--text-base); font-weight: 700; line-height: 20px; color: var(--ink); overflow-wrap: anywhere; }
.plb-gv-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 10px; min-width: 0; }
/* The Suggested row: the reason, then the view link on a line of its own. */
.plb-gv-row--own > .plb-gx { flex-basis: 100%; }
.plb-gx { flex: 1 1 12ch; min-width: 0; font-size: var(--text-xs); line-height: 16px; color: var(--t2); overflow-wrap: anywhere; }
.plb-wb { display: flex; align-items: flex-start; gap: 6px; font-size: var(--text-sm); font-weight: 700; line-height: 18px; color: var(--sev-warning-ink); overflow-wrap: anywhere; }
.plb-wb svg { flex: none; margin-top: 2px; }
.plb-okl { display: flex; align-items: flex-start; gap: 6px; min-height: 20px; font-size: var(--text-xs); line-height: 16px; color: var(--t2); overflow-wrap: anywhere; }
.plb-okl svg { flex: none; margin-top: 1px; color: var(--sev-ok); }
.plb-okl[data-kind="warn"] { font-weight: 600; color: var(--sev-warning-ink); }
.plb-okl[data-kind="warn"] svg { color: var(--sev-warning-ink); }
.plb-view { margin-block: -6px; }
html[dir="rtl"] .plb-view svg { transform: scaleX(-1); }
.plb-view:focus-visible { outline: 2px solid var(--text-brand); outline-offset: 2px; }
/* An out-of-date build keeps its guidance, marked as the tabs are: a dashed rule, quieter names. */
.plb-guide[data-stale]::before { width: 0; background: none; border-inline-start: 1px dashed var(--rule-strong); }
.plb-guide[data-stale] .plb-gt { color: var(--t2); font-weight: 600; }
/* What one course does to graduation: on the section line of its row, wrapping under it when short of room. */
.plb-sl { display: flex; flex-wrap: wrap; align-items: center; column-gap: 10px; min-width: 0; }
.plb-fxt { min-width: 0; font-size: var(--text-xs); line-height: 16px; color: var(--t3); overflow-wrap: anywhere; }
.plb-fxt--strong { font-weight: 700; color: var(--ink); }
.plb-fxt--brand { font-weight: 600; color: var(--text-brand); }
.plb-fxt[data-stale] { border-block-end: 1px dashed var(--rule-strong); }
.plb-dep { display: block; }
.plb-dep bdi { font-weight: 700; color: var(--ink); }
.plb-dt-fx { margin: 2px 0 0; }
/* A planned block is a real control; a registered one stays a picture. */
button.plb-b {
  width: auto; height: auto; align-self: stretch; justify-self: stretch;
  border-block: 0; border-inline-end: 0; font: inherit; text-align: start; color: inherit; cursor: pointer;
}
button.plb-b:hover { filter: brightness(.97); }
button.plb-b:focus-visible { outline: 2px solid var(--text-brand); outline-offset: 1px; z-index: 1; }
.plb-b[data-open="true"] { box-shadow: inset 0 0 0 2px var(--text-brand); }

/* projected graduation: the runway. One DOM, two layouts. The stacked layout is the default (a
   wrapping flex row per line: label and landing, then the ticks under them, one axis for both
   lines); the row layout (one grid, a subgrid per line) applies once the band itself is wide enough
   for its number of columns (container `plbgrad`, thresholds below), unless the script finds that
   its texts have no room there and marks the runway `data-fit="stacked"`. Text widths depend on
   the language and on the fonts that loaded, so fitRunway() in page-planner-board.js measures
   them: the layout, the unit on the first tick, how many term labels, the size of the result. */
.plb-grad { container: plbgrad / inline-size; }
.plb-gh { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 10px; min-height: 24px; }
.plb-gh .plb-lk { margin-block: -4px; }
.plb-grad [hidden] { display: none; }
.plb-grad .plb-lk:focus-visible, .plb-grad:focus-visible, .plb-grad .plb-empty:focus-visible { outline: 2px solid var(--text-brand); outline-offset: 2px; }
.plb-rwwrap { min-width: 0; }
.plb-rwwrap:empty { display: none; }
.plb-rw { --plb-cols: 1; display: flex; flex-direction: column; gap: 10px; margin-top: 2px; min-width: 0; }
.plb-rwl { position: relative; display: flex; flex-wrap: wrap; align-items: flex-end; min-width: 0; }
.plb-rwl .plb-rl { order: 0; display: flex; align-items: flex-end; gap: 8px; margin: 0; padding-inline-end: 14px; font-size: inherit; line-height: inherit; color: inherit; }
.plb-num { min-width: 21px; font-size: var(--text-numeral); font-weight: 600; line-height: 38px; color: var(--ink); }
.plb-st { display: flex; flex-direction: column; padding-bottom: 3px; }
.plb-st b { font-size: var(--text-base); font-weight: 600; line-height: 18px; color: var(--t2); }
.plb-rwl--reg .plb-num { font-size: var(--text-display); line-height: 32px; color: var(--t3); }
.plb-rwl--reg .plb-st b { color: var(--t3); }
/* Stacked, a tick is one Nth of the row less a hair: N shares rounded by a browser to its own
   unit may add up to more than the row, and the last tick would wrap. */
.plb-tk {
  position: relative; box-sizing: border-box; order: 3; flex: 0 0 calc(100% / var(--plb-cols) - 0.01px); min-width: 0; height: 46px;
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 6px; white-space: nowrap;
  font-size: var(--text-sm); font-weight: 600; line-height: 18px; color: var(--ink); border-bottom: 3px solid var(--brand);
}
.plb-tk::before { content: ""; position: absolute; inset-inline-start: 0; bottom: 0; width: 1px; height: 8px; background: var(--rule-strong); }
.plb-tk--end::after {
  content: ""; position: absolute; inset-inline-end: -1px; bottom: -6px; width: 9px; height: 9px;
  border-radius: var(--radius-pill); background: var(--brand); box-shadow: 0 0 0 2px var(--bg);
}
.plb-u { margin-inline-start: 3px; font-size: var(--text-micro); font-weight: 500; color: var(--t3); }
.plb-tk--wait { color: var(--t3); border-bottom-style: dashed; }
.plb-rwl--reg .plb-tk { height: 34px; font-weight: 500; color: var(--t3); border-bottom: 2px solid var(--t4); }
.plb-rwl--reg .plb-tk--wait { border-bottom-style: dashed; }
.plb-rwl--reg .plb-tk--end::after { bottom: -5px; width: 8px; height: 8px; background: var(--bg); box-shadow: inset 0 0 0 2px var(--t4), 0 0 0 2px var(--bg); }
.plb-grad[data-stale] .plb-rwl--opt .plb-tk { border-bottom-style: dashed; }
.plb-land { order: 1; margin-inline-start: auto; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: flex-end; gap: 0 8px; padding-bottom: 3px; text-align: end; }
.plb-land b { font-size: var(--text-sm); font-weight: 600; line-height: 18px; color: var(--ink); }
.plb-rwl--reg .plb-land b { font-weight: 500; color: var(--t2); }
.plb-brk { order: 2; display: block; flex: 0 0 100%; height: 0; }
.plb-rwn { order: 1; flex: 1 1 12ch; min-width: 0; margin: 0; padding-bottom: 3px; font-size: var(--text-sm); line-height: 18px; color: var(--t2); }
.plb-axn { order: 4; flex: 0 0 100%; padding-top: 2px; }
.plb-ax {
  order: 3; flex: 0 0 calc(100% / var(--plb-cols) - 0.01px); min-width: 0; padding-top: 6px; text-align: center; white-space: nowrap;
  font-family: var(--font-mono); font-size: var(--text-micro); font-weight: 500; line-height: 16px; color: var(--t3);
}
.plb-ax--now { font-weight: 700; color: var(--ink); }
.plb-asm { margin: 4px 0 0; font-size: var(--text-xs); line-height: 16px; color: var(--t3); }
.plb-asm--warn { font-weight: 600; color: var(--sev-warning-ink); }
.plb-gwhy { display: flex; flex-direction: column; gap: 2px; margin: 4px 0 0; padding-inline-start: 16px; font-size: var(--text-xs); line-height: 16px; color: var(--t2); overflow-wrap: anywhere; }
.plb-tab-terms { font-weight: 700; color: var(--t2); }
/* The first tick loses its unit when its line has no room for it (fitRunway() decides): the
   caption under the axis ("Credits per term") says it. */
.plb-rw[data-unit="off"] .plb-u { display: none; }
/* The band keeps the height of its two lines from the moment a forecast is asked for, so the tabs
   under it do not jump when the forecast lands or when a tab with a single line is chosen: 176px
   is the runway beside the guidance column with its assumptions on two lines. (On a phone the page
   is scrolled past the band by then, and the browser holds the tabs in place.) */
.plb-grad[data-state="loading"], .plb-grad[data-state="ready"] { min-height: 176px; }
@container plbgrad (min-width: 440px) {
  .plb-rw[data-span="s"]:not([data-fit="stacked"]) { display: grid; grid-template-columns: max-content repeat(var(--plb-cols), minmax(0, 1fr)) fit-content(16rem); align-items: end; gap: 2px 0; }
  .plb-rw[data-span="s"]:not([data-fit="stacked"]) .plb-rwl { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; align-items: end; }
  .plb-rw[data-span="s"]:not([data-fit="stacked"]) .plb-rwl > :not(.sr-only) { grid-row: 1; order: 0; }
  .plb-rw[data-span="s"]:not([data-fit="stacked"]) .plb-rwl .plb-rl, .plb-rw[data-span="s"]:not([data-fit="stacked"]) .plb-axn { grid-column: 1; }
  .plb-rw[data-span="s"]:not([data-fit="stacked"]) .plb-brk { display: none; }
  .plb-rw[data-span="s"]:not([data-fit="stacked"]) .plb-axn { display: block; padding-top: 7px; padding-inline-end: 14px; }
  .plb-rw[data-span="s"]:not([data-fit="stacked"]) .plb-rwn { grid-column: 2 / -1; }
  .plb-rw[data-span="s"]:not([data-fit="stacked"]) .plb-land { grid-column: var(--plb-from) / -1; flex-direction: column; flex-wrap: nowrap; align-items: flex-start; justify-content: flex-start; gap: 0; margin: 0; padding: 0 0 5px; padding-inline-start: 16px; text-align: start; }
  .plb-rw[data-span="s"]:not([data-fit="stacked"]) .plb-rwl--reg .plb-land { min-width: 112px; padding-bottom: 2px; }
}
@container plbgrad (min-width: 580px) {
  .plb-rw[data-span="m"]:not([data-fit="stacked"]) { display: grid; grid-template-columns: max-content repeat(var(--plb-cols), minmax(0, 1fr)) fit-content(16rem); align-items: end; gap: 2px 0; }
  .plb-rw[data-span="m"]:not([data-fit="stacked"]) .plb-rwl { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; align-items: end; }
  .plb-rw[data-span="m"]:not([data-fit="stacked"]) .plb-rwl > :not(.sr-only) { grid-row: 1; order: 0; }
  .plb-rw[data-span="m"]:not([data-fit="stacked"]) .plb-rwl .plb-rl, .plb-rw[data-span="m"]:not([data-fit="stacked"]) .plb-axn { grid-column: 1; }
  .plb-rw[data-span="m"]:not([data-fit="stacked"]) .plb-brk { display: none; }
  .plb-rw[data-span="m"]:not([data-fit="stacked"]) .plb-axn { display: block; padding-top: 7px; padding-inline-end: 14px; }
  .plb-rw[data-span="m"]:not([data-fit="stacked"]) .plb-rwn { grid-column: 2 / -1; }
  .plb-rw[data-span="m"]:not([data-fit="stacked"]) .plb-land { grid-column: var(--plb-from) / -1; flex-direction: column; flex-wrap: nowrap; align-items: flex-start; justify-content: flex-start; gap: 0; margin: 0; padding: 0 0 5px; padding-inline-start: 16px; text-align: start; }
  .plb-rw[data-span="m"]:not([data-fit="stacked"]) .plb-rwl--reg .plb-land { min-width: 112px; padding-bottom: 2px; }
}
@container plbgrad (min-width: 620px) {
  .plb-rw[data-span="l"]:not([data-fit="stacked"]) { display: grid; grid-template-columns: max-content repeat(var(--plb-cols), minmax(0, 1fr)) fit-content(16rem); align-items: end; gap: 2px 0; }
  .plb-rw[data-span="l"]:not([data-fit="stacked"]) .plb-rwl { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; align-items: end; }
  .plb-rw[data-span="l"]:not([data-fit="stacked"]) .plb-rwl > :not(.sr-only) { grid-row: 1; order: 0; }
  .plb-rw[data-span="l"]:not([data-fit="stacked"]) .plb-rwl .plb-rl, .plb-rw[data-span="l"]:not([data-fit="stacked"]) .plb-axn { grid-column: 1; }
  .plb-rw[data-span="l"]:not([data-fit="stacked"]) .plb-brk { display: none; }
  .plb-rw[data-span="l"]:not([data-fit="stacked"]) .plb-axn { display: block; padding-top: 7px; padding-inline-end: 14px; }
  .plb-rw[data-span="l"]:not([data-fit="stacked"]) .plb-rwn { grid-column: 2 / -1; }
  .plb-rw[data-span="l"]:not([data-fit="stacked"]) .plb-land { grid-column: var(--plb-from) / -1; flex-direction: column; flex-wrap: nowrap; align-items: flex-start; justify-content: flex-start; gap: 0; margin: 0; padding: 0 0 5px; padding-inline-start: 16px; text-align: start; }
  .plb-rw[data-span="l"]:not([data-fit="stacked"]) .plb-rwl--reg .plb-land { min-width: 112px; padding-bottom: 2px; }
}
@container plbgrad (min-width: 900px) {
  .plb-rw[data-span="xl"]:not([data-fit="stacked"]) { display: grid; grid-template-columns: max-content repeat(var(--plb-cols), minmax(0, 1fr)) fit-content(16rem); align-items: end; gap: 2px 0; }
  .plb-rw[data-span="xl"]:not([data-fit="stacked"]) .plb-rwl { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; align-items: end; }
  .plb-rw[data-span="xl"]:not([data-fit="stacked"]) .plb-rwl > :not(.sr-only) { grid-row: 1; order: 0; }
  .plb-rw[data-span="xl"]:not([data-fit="stacked"]) .plb-rwl .plb-rl, .plb-rw[data-span="xl"]:not([data-fit="stacked"]) .plb-axn { grid-column: 1; }
  .plb-rw[data-span="xl"]:not([data-fit="stacked"]) .plb-brk { display: none; }
  .plb-rw[data-span="xl"]:not([data-fit="stacked"]) .plb-axn { display: block; padding-top: 7px; padding-inline-end: 14px; }
  .plb-rw[data-span="xl"]:not([data-fit="stacked"]) .plb-rwn { grid-column: 2 / -1; }
  .plb-rw[data-span="xl"]:not([data-fit="stacked"]) .plb-land { grid-column: var(--plb-from) / -1; flex-direction: column; flex-wrap: nowrap; align-items: flex-start; justify-content: flex-start; gap: 0; margin: 0; padding: 0 0 5px; padding-inline-start: 16px; text-align: start; }
  .plb-rw[data-span="xl"]:not([data-fit="stacked"]) .plb-rwl--reg .plb-land { min-width: 112px; padding-bottom: 2px; }
}

/* ── Parity with the approved mock-up (S5): white surfaces, header bars, the mock-up's type ── */
.plb { --plb-kv: var(--text-lg); }
/* title: a micro kicker over the serif heading; the id/term chip stays in the DOM for screen readers only */
.plb-kicker {
  font-family: var(--font-mono); font-size: var(--text-micro); font-weight: 600; line-height: 16px;
  letter-spacing: .06em; text-transform: uppercase; color: var(--t3);
}
.plb-kicker:lang(ar) { letter-spacing: 0; }
main#main-content .page-header-left:has(.plb-kicker) { flex-direction: column; align-items: flex-start; gap: 4px; }
main#main-content .page-header-left:has(.plb-kicker) .page-header-chips { order: -1; }
main#main-content .page-header-left:has(.plb-kicker) .page-header-module {
  font-family: var(--font-serif); font-size: var(--text-xl); font-weight: 400; line-height: 1.15; letter-spacing: 0; color: var(--ink);
}
.plb-ctx {
  position: absolute; inline-size: 1px; block-size: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}
.plb-ctx[hidden] { display: none; }

/* the student band is a white card; the closed timetable is its bottom row */
.plb-sband { padding: 12px 22px; background: var(--card); border-block: 1px solid var(--rule-strong); }
.plb-sband:has(+ .plb-curtt:not([hidden])) { border-block-end: 0; }
.plb-sband + .plb-curtt { margin-block-start: -8px; }
.plb-curtt { padding-inline: 22px; background: var(--card); border-block: 1px solid var(--line); border-block-end-color: var(--rule-strong); }
.plb-curtt > summary { min-height: 40px; }
.plb-curtt-d { font-size: var(--text-xs); }
.plb-curtt-s { font-weight: 500; color: var(--t3); }
.plb-sf { gap: 4px; }
.plb-big { font-size: var(--plb-kv); }
.plb-sf:first-child .plb-big { font-size: var(--text-md); }
.plb-big--muted {
  font-family: var(--font-body); font-size: var(--text-xs); line-height: 18px; color: var(--t3);
}
.plb-bar { block-size: 6px; border-radius: 3px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); margin-block-start: 4px; }
.plb-smeta { font-size: var(--text-xs); line-height: 16px; }

/* rules: micro labels */
.plb-rc-l { font-family: var(--font-mono); font-size: var(--text-micro); font-weight: 600; line-height: 14px; letter-spacing: .06em; text-transform: uppercase; color: var(--t3); }
.plb-rc-l:lang(ar) { letter-spacing: 0; }
.plb-usual { font-size: var(--text-xs); color: var(--t3); }
.plb-mic { font-weight: 600; letter-spacing: .06em; }
.plb-mic:lang(ar) { letter-spacing: 0; }

/* the source row: the find field takes the rest of the row */
.plb-find { flex: 1 1 260px; max-width: none; }

/* panels: a header bar over a white body, framed by two rules */
.plb-pane { padding-top: 0; background: var(--card); border-block: 1px solid var(--rule-strong); }
.plb-pane .plb-ph {
  justify-content: space-between; flex-wrap: wrap; min-height: 0; padding: 10px 14px; gap: 2px 12px;
  background: var(--surface); border-block-end: 1px solid var(--line);
}
.plb-pane .plb-h3 { flex: 0 1 auto; font-size: var(--text-base); font-weight: 600; line-height: 20px; }
.plb-h3-n { font-weight: 500; color: var(--t3); }
.plb-pane .plb-phn, .plb-pane .plb-pload { margin-inline-start: auto; font-size: var(--text-xs); }
.plb-pane .plb-pload b { font-size: var(--text-base); font-weight: 600; }
.plb-pane--plan .plb-meter { margin: 10px 14px 6px; block-size: 6px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.plb-pane--plan .plb-mline { margin: 0; padding: 6px 14px 10px; border-block-end: 1px solid var(--line); }
.plb-pane--plan .plb-meter:not([hidden]) + .plb-mline { padding-block-start: 0; }
#plbAvailList { max-height: none; overflow-y: visible; }
.plb-showall-row { display: flex; justify-content: center; padding: 10px 14px; border-top: 1px solid var(--line); }
.plb-pane .plb-hint { margin: 12px 14px; }
.plb-pane--plan .plb-pop { inset-inline: 14px; }

/* rows */
.plb-ar-main { padding-inline: 14px; min-height: 44px; }
.plb-nm { font-size: var(--text-md); line-height: 20px; }
.plb-code { font-size: var(--text-sm); font-weight: 600; }
.plb-meta .plb-flag, .plb-sl .plb-flag { font-size: var(--text-micro); font-weight: 600; padding: 2px 7px; border-radius: var(--radius-pill); line-height: 16px; }
.plb-fxt--strong.plb-flag { background: var(--sev-warning-bg); color: var(--sev-warning-ink); }
.plb-fxt--muted.plb-flag { background: var(--surface); color: var(--t2); }
.plb-prow { padding-inline: 14px; min-height: 52px; }
.plb-sec { min-height: 38px; background: var(--bg); }
.plb-sec--h { min-height: 0; padding-block: 6px 4px; }
.plb-arow[data-ticked="true"] { background: transparent; }
.plb-arow[data-ticked="true"] > .plb-ar-main { background: rgba(10,142,110,.11); }
html[data-theme="dark"] .plb-arow[data-ticked="true"] > .plb-ar-main { background: rgba(46,201,160,.14); }
.plb-only-row { display: flex; justify-content: flex-end; padding: 8px 14px; background: var(--bg); border-top: 1px solid var(--line); }

/* Required: a framed 32px button; on = tinted brand with the pin and its word */
.plb-req {
  min-height: var(--control-h-sm); padding: 0 10px; gap: 6px; border-radius: var(--radius-sm);
  box-shadow: inset 0 0 0 1px var(--rule-strong); font-weight: 600;
}
.plb-req[aria-pressed="true"] { background: rgba(10,142,110,.11); color: var(--text-brand); box-shadow: inset 0 0 0 1px var(--text-brand); }
html[data-theme="dark"] .plb-req[aria-pressed="true"] { background: rgba(46,201,160,.14); }

/* the build row: a state line with a dot, then the button */
.plb-bstate { margin: 0; display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); font-weight: 600; line-height: 18px; color: var(--text-brand); }
.plb-bstate::before { content: ""; flex: none; inline-size: 8px; block-size: 8px; border-radius: 50%; background: var(--text-brand); }
/* Empty (no build, or one running), the live region stays in the accessibility tree and takes no room. */
.plb-bstate:empty { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.plb-bstate[data-kind="warn"] { color: var(--sev-warning-ink); }
.plb-bstate[data-kind="warn"]::before { background: var(--sev-warning-ink); }
.plb-buildrow[data-stale="true"] #plbBuildLine {
  position: absolute; inline-size: 1px; block-size: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.plb-buildnotes { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 2px 14px; }

/* zone 03: the graduation header is a card too; the week and the glance sit on the page */
.plb-band { padding: 12px 22px; background: var(--card); border-block: 1px solid var(--rule-strong); }
@container plb (max-width: 560px) { .plb-applybar { padding-inline: 0; } .plb-band { padding-inline: 12px; } }
.plb-gpill[data-result="sooner"] { color: var(--text-brand); }
.plb-tabs { border-bottom: 1px solid var(--rule-strong); gap: 0; }
.plb-tablist { gap: 0; }
.plb-tab { padding: 12px 16px; }
.plb-tab[aria-selected="true"] { background: rgba(10,142,110,.11); }
.plb-applybar { padding: 12px 16px; border-top: 1px solid var(--rule-strong); }
.plb-glance-t { padding-block-end: 6px; border-bottom: 1px solid var(--rule-strong); }
.plb-facts { padding-block: 8px 10px; border-bottom: 1px solid var(--line); }
.plb-sr { border-block-end: 1px solid var(--line); }
.plb-sr .plb-code { font-size: var(--text-sm); }

/* laptop width */
@container plb (max-width: 1361px) {
  .plb { --plb-gap: 20px; }
}
@container plb (max-width: 900px) {
  .plb-sgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* the picker stacks: Available, the arrows as one row, then the plan; "towards the plan" is down */
  .plb-pick { grid-template-columns: minmax(0, 1fr); row-gap: 8px; }
  .plb-xfer { flex-direction: row; padding-block: 4px; }
  .plb-xgap { block-size: auto; inline-size: 16px; }
  .plb-xb[data-side="list-to-plan"] .plb-dir, html[dir="rtl"] .plb-xb[data-side="list-to-plan"] .plb-dir { transform: rotate(90deg); }
  .plb-xb[data-side="plan-to-list"] .plb-dir, html[dir="rtl"] .plb-xb[data-side="plan-to-list"] .plb-dir { transform: rotate(-90deg); }
}
/* Zone 03, one colour per course (--plb-c1..10 and their tints, light and dark above) */
.plb-sw { display: inline-block; flex: none; inline-size: 10px; block-size: 10px; border-radius: 3px; background: var(--t4); }
.plb-sw[data-hue="1"] { background: var(--plb-c1); } .plb-sw[data-hue="2"] { background: var(--plb-c2); }
.plb-sw[data-hue="3"] { background: var(--plb-c3); } .plb-sw[data-hue="4"] { background: var(--plb-c4); }
.plb-sw[data-hue="5"] { background: var(--plb-c5); } .plb-sw[data-hue="6"] { background: var(--plb-c6); }
.plb-sw[data-hue="7"] { background: var(--plb-c7); } .plb-sw[data-hue="8"] { background: var(--plb-c8); }
.plb-sw[data-hue="9"] { background: var(--plb-c9); } .plb-sw[data-hue="10"] { background: var(--plb-c10); }
.plb-sw:not([data-hue]) { display: none; }
.plb-prow .plb-code:has(> .plb-sw) { display: inline-flex; align-items: center; gap: 6px; }
/* Each row is its own grid. Where the list has room (600px: a screen about 1550px wide or more), the code
   cell is as wide as a 7-letter code (and its swatch) in every row, so the names start on one line
   down the list; a longer code still widens its own row. A narrower list keeps each row's own code
   width: there the line under a name needs every pixel. Measured: at 1152 the 17px wrapped
   "3 cr · §M2" on option tabs; at 1440 in Arabic it wrapped "Registered §M15 · §M15" (199px in a
   189px cell; 207px without it), so a row changed height from one option tab to the next. */
.plb-plist { container: plblist / inline-size; }
@container plblist (min-width: 600px) {
  .plb-prow > .plb-code { min-inline-size: calc(7ch + 16px); }
  .plb-ar-main > .plb-code { min-inline-size: 7ch; }
}
.plb-b[data-hue="1"] { --h: var(--plb-c1); --ht: var(--plb-c1-t); }
.plb-b[data-hue="2"] { --h: var(--plb-c2); --ht: var(--plb-c2-t); }
.plb-b[data-hue="3"] { --h: var(--plb-c3); --ht: var(--plb-c3-t); }
.plb-b[data-hue="4"] { --h: var(--plb-c4); --ht: var(--plb-c4-t); }
.plb-b[data-hue="5"] { --h: var(--plb-c5); --ht: var(--plb-c5-t); }
.plb-b[data-hue="6"] { --h: var(--plb-c6); --ht: var(--plb-c6-t); }
.plb-b[data-hue="7"] { --h: var(--plb-c7); --ht: var(--plb-c7-t); }
.plb-b[data-hue="8"] { --h: var(--plb-c8); --ht: var(--plb-c8-t); }
.plb-b[data-hue="9"] { --h: var(--plb-c9); --ht: var(--plb-c9-t); }
.plb-b[data-hue="10"] { --h: var(--plb-c10); --ht: var(--plb-c10-t); }
.plb-b[data-hue] { background: var(--ht); border: 1px solid var(--h); border-inline-start: 3px solid var(--h); }

/* the options zone: week and the "at a glance" aside */
.plb-ow { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--plb-gap); align-items: start; }
.plb-ow:has(> .plb-glance[hidden]) { grid-template-columns: minmax(0, 1fr); }
.plb-glance { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.plb-glance[hidden] { display: none; }
.plb-glance-t { margin: 0; }
.plb-facts { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.plb-fact { min-width: 0; display: flex; flex-direction: column; gap: 2px; padding-block: 6px; border-block-start: 1px solid var(--rule); }
.plb-fact .plb-mic { overflow-wrap: anywhere; }
.plb-fv { margin: 0; font-family: var(--font-serif); font-size: var(--text-lg); font-weight: 400; line-height: 1.2; color: var(--ink); overflow-wrap: anywhere; }
.plb-secs { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; }
.plb-sr { display: flex; align-items: center; gap: 8px; min-width: 0; padding-block: 6px; border-block-start: 1px solid var(--rule); }
.plb-sr .plb-sw { margin-inline-end: -2px; }
.plb-sr .plb-code { flex: none; }
.plb-sr .plb-nm { flex: 1 1 auto; min-width: 0; white-space: normal; overflow-wrap: anywhere; font-size: var(--text-xs); color: var(--t2); }
.plb-sch { flex: none; padding: 0 6px; border: 1px solid var(--rule-strong); border-radius: var(--radius-pill); font-family: var(--font-mono); font-size: var(--text-micro); font-weight: 700; line-height: 16px; color: var(--t2); }
.plb-sch[data-only="true"] { border-color: var(--text-brand); color: var(--text-brand); }
.plb-kt { flex: none; font-size: var(--text-micro); line-height: 16px; color: var(--t2); }
.plb-sr--kept { opacity: .8; }
.plb-sr--kept .plb-code { color: var(--t2); }
.plb-glance .plb-guide { padding-block-start: 4px; }

/* the graduation band's header */
.plb-gtop { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 4px 12px; padding-block-end: 6px; }
.plb-gtop[hidden], .plb-gpill[hidden] { display: none; }
.plb-gtop-l { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.plb-gterm { font-family: var(--font-serif); font-size: var(--text-xl); font-weight: 400; line-height: 1.1; color: var(--ink); overflow-wrap: anywhere; }
.plb-gpill { padding: 2px 10px; border-radius: var(--radius-pill); font-size: var(--text-xs); font-weight: 700; line-height: 18px; color: var(--ink); background: var(--plb-reg); border: 1px solid var(--plb-reg-edge); }
.plb-gpill[data-result="sooner"] { background: var(--plb-new); border-color: var(--plb-new-edge); }
.plb-gpill[data-result="later"] { background: var(--plb-c8-t); border-color: var(--plb-c8); }

/* the apply bar's status */
.plb-acts-st { margin: 0; display: flex; align-items: center; gap: 6px; font-size: var(--text-sm); font-weight: 700; line-height: 20px; color: var(--ink); }
.plb-acts-st[hidden] { display: none; }
.plb-acts-st[data-kind="ok"] svg { color: var(--plb-new-edge); }
.plb-acts-st[data-kind="warn"] { color: var(--sev-warning-ink); }
.plb-acts-st svg { flex: none; }
@container plb (max-width: 980px) {
  .plb-ow { grid-template-columns: minmax(0, 1fr); }
}
@container plb (max-width: 320px) {
  .plb-sgrid { grid-template-columns: minmax(0, 1fr); }
}
@container plb (max-width: 480px) {
  .plb-rc-row, .plb-seg { width: 100%; }
  .plb-seg-o { flex: 1 1 0; text-align: center; }
  .plb-rc-row--max .plb-rc-in { width: 100%; }
}
@container plb (max-width: 560px) {
  .plb-ar-main { grid-template-columns: 36px 20px max-content minmax(0, 1fr); row-gap: 0; padding-block: 4px; }
  .plb-ar-main > .plb-meta { grid-column: 3 / -1; justify-content: flex-start; }
  .plb-prow { grid-template-columns: 20px max-content minmax(0, 1fr) 44px; row-gap: 2px; }
  .plb-prow > .plb-secbtn { grid-column: 2 / 4; grid-row: 2; justify-self: start; }
  .plb-prow > .plb-req { grid-column: 4; grid-row: 2; justify-self: end; }
  .plb-prow > .plb-ib { grid-column: 4; grid-row: 1; }
  .plb-tablist { flex: 1 1 100%; }
  .plb-tab { flex: 1 1 100%; max-width: none; }
  .plb-more { flex: 1 1 100%; }
  .plb-more-btn { width: 100%; justify-content: center; }
  .plb-more-list { inset-inline: 0; max-width: none; }
  .plb-sc { white-space: normal; }
}
@media (max-width: 768px) {
  .plb-cap, .plb-lk, .plb-check, .plb-tab, .plb-more-btn, .plb-more-item, .plb-buildrow .btn, .plb-applybar .btn, .plb-seg-o, .plb-rc-in, .plb-zh-act, .plb-confirm .btn, .plb-curtt > summary { min-height: var(--control-h-lg); }
  .plb-ib, .plb-chev, .plb-fold, .plb-secbtn, .plb-req { min-width: var(--control-h-lg); min-height: var(--control-h-lg); }
  .plb-ib { width: var(--control-h-lg); height: var(--control-h-lg); }
  .plb-gh .plb-lk { margin-block: 0; }
  .plb-view { margin-block: 0; }
  .plb-load .btn.btn-sm { min-height: var(--control-h-lg); }
  .plb-dt-close, .plb-dt-sec, .plb-why-btn { min-height: var(--control-h-lg); }
}

/* Planner board on phones (<= 768px). The picker shows one panel (a two-tab switch), every available
   row carries its own "+", the section popover is a sheet in the flow, and nothing makes the page
   scroll sideways: the week and the option tabs scroll inside their own boxes. */
.plb-ptabs, .plb-phsum, .plb-addbtn { display: none; }
@media (max-width: 768px) {
  /* masthead: the Student ID alone on a line, then the term and Fetch side by side */
  .plb-load { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; width: 100%; }
  .plb-load > .plb-cap { grid-column: 1 / -1; }
  .plb-load .plb-w-id { width: 100%; flex: 1 1 auto; }
  .plb-termwrap { position: static; min-width: 0; }
  .plb-termbtn, .plb-load #plbFetch { width: 100%; justify-content: center; }
  .plb-termpop { inset-inline: 0; margin-top: 4px; }
  .plb-termpop .plb-cap { flex: 1 1 120px; }
  .plb-w-year { width: 6ch; }
  /* rules: one per line, segmented controls in equal halves */
  .plb-rules { flex-direction: column; align-items: stretch; gap: 14px; }
  .plb-rc-row, .plb-seg { width: 100%; }
  .plb-rc-row--checks { align-self: stretch; }
  .plb-seg-o { flex: 1 1 0; text-align: center; padding-inline: 8px; }
  .plb-rc-row--max .plb-rc-in { width: 100%; }
  /* courses */
  .plb-srcrow { flex-direction: column; align-items: stretch; }
  .plb-srcf, .plb-find { flex: 1 1 auto; max-width: none; width: 100%; }
  .plb-select { width: 100%; min-height: var(--control-h-lg); }
  .plb-find { min-height: var(--control-h-lg); }
  .plb-ptabs { display: flex; border-radius: var(--radius-sm); box-shadow: inset 0 0 0 1px var(--control-edge); }
  .plb-ptab {
    flex: 1 1 0; min-width: 0; min-height: var(--control-h-lg); padding: 0 8px; border: 0; border-radius: var(--radius-sm);
    background: none; cursor: pointer; font: inherit; font-size: var(--text-sm); font-weight: 600; color: var(--t2);
  }
  .plb-ptab[aria-selected="true"] { background: var(--brand-soft); color: var(--text-brand); box-shadow: inset 0 0 0 1px var(--text-brand); }
  .plb-ptab:focus-visible { outline: 2px solid var(--text-brand); outline-offset: 2px; }
  #plbZoneCourses[data-tab="avail"] #plbPlan, #plbZoneCourses[data-tab="plan"] #plbAvail { display: none; }
  .plb-pick { display: block; }
  .plb-xfer { display: none; }
  .plb-pane { border-top: 0; }
  #plbAvailList { max-height: none; }
  .plb-tick[data-act="tick"], .plb-tick[data-act="ptick"] { display: none; }
  .plb-ar-main:not(.plb-ar-main--off) { grid-template-columns: 44px max-content minmax(0, 1fr) 44px; column-gap: 8px; padding-inline-end: 0; }
  .plb-ar-main > .plb-chev { inline-size: 44px; block-size: 44px; }
  .plb-ar-main > .plb-meta { grid-column: 2 / 4; grid-row: 2; justify-content: flex-start; }
  .plb-addbtn {
    grid-column: 4; grid-row: 1 / span 2; display: inline-flex; align-items: center; justify-content: center;
    inline-size: 44px; block-size: 44px; padding: 0; border: 0; border-radius: var(--radius-sm);
    background: transparent; color: var(--text-brand); box-shadow: inset 0 0 0 1px var(--control-edge); cursor: pointer;
  }
  .plb-addbtn:hover:not(:disabled) { background: var(--brand-soft); }
  .plb-addbtn:disabled { color: var(--t4); box-shadow: inset 0 0 0 1px var(--rule); cursor: default; opacity: .6; }
  .plb-addbtn:focus-visible { outline: 2px solid var(--text-brand); outline-offset: 2px; }
  .plb-fxl { padding-inline: 12px 8px; }
  .plb-secs { padding-inline-start: 8px; }
  .plb-sec { grid-template-columns: 44px 36px minmax(0, 1fr) auto; min-height: var(--control-h-lg); cursor: pointer; }
  .plb-sec--h { min-height: 22px; cursor: default; }
  .plb-sec .plb-tick { justify-self: center; }
  .plb-prow { grid-template-columns: max-content minmax(0, 1fr) 44px; row-gap: 2px; }
  .plb-prow > .plb-code { grid-column: 1; grid-row: 1; }
  .plb-prow > .plb-pmain { grid-column: 2; grid-row: 1; }
  .plb-prow > .plb-ib { grid-column: 3; grid-row: 1; }
  .plb-prow > .plb-secbtn { grid-column: 1 / 3; grid-row: 2; justify-self: start; }
  .plb-prow > .plb-req { grid-column: 3; grid-row: 2; justify-self: end; }
  .plb-pop { position: static; width: auto; max-height: none; margin-block: 4px 8px; overflow: visible; box-shadow: 0 0 0 1px var(--rule); }
  .plb-phsum { display: block; margin: 0; font-size: var(--text-sm); font-weight: 600; line-height: 20px; color: var(--ink); }
  .plb-phsum[data-over="true"] { color: var(--sev-warning-ink); }
  .plb-buildrow { flex-direction: column; align-items: stretch; }
  .plb-buildrow .btn, .plb-applybar .btn { width: 100%; }
  /* options: the tabs scroll sideways in their own row; the week scrolls inside its box */
  .plb-tablist { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; padding-inline-end: 2px; scrollbar-width: thin; }
  .plb-tab { flex: 0 0 200px; max-width: none; }
  .plb-more { flex: 1 1 100%; }
  .plb-more-btn { width: 100%; justify-content: center; }
  .plb-wkwrap, .plb-curtt-body { overflow-x: auto; max-width: 100%; }
  .plb-applybar { flex-direction: column; align-items: stretch; }
  .plb-applynotes, .plb-buildnotes { flex: 0 0 auto; }
}

/* ============================================================
   DASHBOARD — feature-specific styles
   ------------------------------------------------------------
   Moved out of core/templates/core/partials/dashboard/_css.html.
   ============================================================ */

/* ═══════════════════════════════════════════════════════
   UX ENHANCEMENTS  (no existing classes overridden)
   ═══════════════════════════════════════════════════════ */

/* ── REC 4: HP advanced settings ───────────────────── */
.hp-advanced { border: none; }

.hp-advanced-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  list-style: none;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--muted);
  padding: 0.3rem 0;
  user-select: none;
}

.hp-advanced-toggle::-webkit-details-marker { display: none; }

.hp-adv-arrow {
  font-size: var(--text-micro);
  transition: transform 0.2s var(--ease);
  display: inline-block;
}

.hp-advanced[open] .hp-adv-arrow { transform: rotate(90deg); }

.hp-adv-defaults-badge {
  font-size: var(--text-micro);
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--bg);
  color: var(--muted);
  border-radius: var(--radius-xs);
  padding: 0.1rem 0.4rem;
}

.hp-advanced[open] .hp-adv-defaults-badge { display: none; }

/* ── Trace action micro-buttons ────────────────────── */
.trace-actions { display: inline-flex; gap: 4px; }
.trace-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  padding: 3px 10px; border-radius: var(--radius-sm); border: none;
  font-size: var(--text-xs); font-weight: 600; font-family: inherit;
  cursor: pointer; transition: all 0.15s var(--ease);
  line-height: 1.3;
}
.trace-btn .i { width: 12px; height: 12px; opacity: 0.7; }
.trace-btn-view { background: var(--teal-dim); color: var(--text-brand); }
.trace-btn-view:hover { background: color-mix(in srgb, var(--teal) 20%, transparent); box-shadow: 0 1px 4px var(--teal-border); }
.trace-btn-copy { background: var(--pl-overlay-3); color: var(--t3); }
.trace-btn-copy:hover { background: rgba(17,17,68,0.1); box-shadow: 0 1px 4px var(--pl-overlay-5); }
.trace-btn-copy.copied {
  background: var(--teal-dim); color: var(--text-brand);
}

/* ── Scrape log viewer (neumorphic style) ────────────── */
.scrape-term {
  border-radius: var(--radius); overflow: hidden;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(255,255,255,0.5);
  box-shadow: 6px 6px 16px rgba(163,177,198,0.35),
              -6px -6px 16px rgba(255,255,255,0.65);
}
.scrape-term-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: rgba(255,255,255,0.45);
  border-bottom: 1px solid rgba(163,177,198,0.18);
}
.scrape-term-status { display: flex; align-items: center; gap: 8px; }
.scrape-term-status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--teal);
  box-shadow: var(--shadow-glow);
  animation: scrape-pulse 2s ease-in-out infinite;
}
@keyframes scrape-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.scrape-term-label {
  font-size: var(--text-micro); font-weight: 700; color: var(--t1);
  letter-spacing: 0.06em; text-transform: uppercase;
}
.scrape-term-file {
  font-size: var(--text-micro); font-family: var(--font-mono); color: var(--t4);
  background: var(--teal-dim); padding: 2px 8px; border-radius: var(--radius-sm);
}
.scrape-term-body {
  padding: 14px 16px;
  background: rgba(240,243,246,0.6);
  font-family: var(--font-mono); font-size: var(--text-xs); line-height: 1.85;
  max-height: 280px; overflow-y: auto; color: var(--t2);
  box-shadow: inset 3px 3px 8px rgba(163,177,198,0.3),
              inset -3px -3px 8px rgba(255,255,255,0.5);
}
/* the empty log's placeholder line (it was an inline #a0aec0, 2.08:1) */
.scrape-term-empty { color: var(--t4); }
.scrape-term-body::-webkit-scrollbar { width: 6px; }
.scrape-term-body::-webkit-scrollbar-track { background: transparent; }
.scrape-term-body::-webkit-scrollbar-thumb { background: rgba(163,177,198,0.4); border-radius: 3px; }
.scrape-term-body::-webkit-scrollbar-thumb:hover { background: rgba(163,177,198,0.6); }
.scrape-term-body div { padding: 1px 0; border-bottom: 1px solid rgba(163,177,198,0.08); }
.scrape-term-body div:last-child { border-bottom: none; }
.t-ts { color: var(--t4); font-size: var(--text-micro); }
.t-ok { color: var(--text-brand); font-weight: 600; }
.t-er { color: var(--danger); font-weight: 600; }
.t-hl { color: var(--royal); font-weight: 600; }
.t-wrn { color: var(--sev-warning); font-weight: 600; }

/* ── REC 8: Advisor admin wizard bar ────────────────── */
.adm-wizard-bar {
  display: flex;
  align-items: center;
  margin-bottom: 1.5rem;
  padding: 1rem 1rem 0.75rem;
  background: var(--brand-soft);
  border: 1px solid var(--teal-border);
  border-radius: var(--radius);
}

.adm-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
}

.adm-step-circle {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 700;
  box-shadow: 0 0 0 3px var(--teal-border);
}

.adm-step-inactive .adm-step-circle {
  background: var(--card);
  color: var(--muted);
  border: 2px solid var(--line-strong);
  box-shadow: none;
}

.adm-step-label {
  font-size: var(--text-micro);
  font-weight: 600;
  color: var(--brand-dark);
  white-space: nowrap;
}

.adm-step-inactive .adm-step-label { color: var(--muted); }

.adm-step-line {
  flex: 1;
  height: 2px;
  background: var(--brand);
  margin: 0 0.5rem;
  margin-bottom: 1.1rem; /* align with circle center */
}

.adm-step-line-inactive { background: var(--line-strong); }

/* ── REC 6: ⌘K Command palette ──────────────────────── */
.cmd-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13,21,38,0.5);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}

/* .d-none (!important) hides the palette; this class re-shows it when d-none is removed */
.cmd-backdrop.d-none { display: none !important; }

.cmd-modal {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  width: 560px;
  max-width: 90vw;
  box-shadow: 0 24px 64px rgba(13,21,38,0.25);
  overflow: hidden;
}

.cmd-search-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
}

.cmd-search-icon { font-size: var(--text-lg); color: var(--text-brand); }

.cmd-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: var(--text-md);
  font-family: var(--font-body);
  color: var(--ink);
  background: transparent;
}

.cmd-input::placeholder { color: var(--muted-light); }

.cmd-esc {
  font-family: var(--font-mono);
  font-size: var(--text-micro);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-xs);
  padding: 0.1rem 0.4rem;
  color: var(--muted);
}

.cmd-results { max-height: 320px; overflow-y: auto; }

.cmd-hint {
  padding: 1rem;
  font-size: var(--text-sm);
  color: var(--muted-light);
  text-align: center;
}

.cmd-section-label {
  padding: 0.5rem 1rem 0.25rem;
  font-size: var(--text-micro);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-light);
  border-top: 1px solid var(--line);
}

.cmd-section-label:first-child { border-top: none; }

.cmd-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  cursor: pointer;
  transition: background 0.1s var(--ease);
  font-size: var(--text-base);
}

.cmd-item:hover, .cmd-item.selected {
  background: var(--royal-dim);
}

.cmd-item-id {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-brand);
  min-width: 70px;
}

.cmd-item-name { flex: 1; color: var(--ink); }

.cmd-item-badge {
  font-size: var(--text-micro);
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-pill);
  background: var(--teal-dim);
  color: var(--text-brand);
  border: 1px solid var(--teal-border);
  flex-shrink: 0;
}

/* ── REC 3: Sidebar badges ──────────────────────────── */
.sidebar-badge {
  margin-inline-start: auto;
  font-family: var(--font-mono);
  font-size: var(--text-micro);
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-pill);
  min-width: 1.4rem;
  text-align: center;
  display: none; /* shown via JS when count > 0 */
}

.sidebar-badge.danger { background: rgba(248,81,73,0.2); color: #f87171; }
.sidebar-badge.warning { background: rgba(210,153,34,0.18); color: #f59e0b; }
.sidebar-badge.ready { background: rgba(63,185,80,0.18); color: #4ade80; font-size: var(--text-micro); }

/* Fix sidebar nav-link layout for badge */
.sidebar .nav-link { display: flex; align-items: center; }

/* ── Overview landing panel ─── */
.ov-greeting { font-family: var(--font-serif); font-size: var(--text-xl); color: var(--navy); margin-bottom: 0.25rem; padding-bottom: 0.5rem; border: none; border-bottom: 2px solid var(--teal-border); box-shadow: none; outline: none; }
.ov-date { font-size: var(--text-sm); color: var(--t3); margin-bottom: 1.5rem; }
.ov-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.ov-kpi { padding: 1.25rem;     transition: transform 0.15s, box-shadow 0.15s; cursor: pointer; }
/* Nothing is floating, so nothing lifts. A recoloured 1px top line is too
   little for a pointer target, so the cue is a wash plus the rule going teal. */
.ov-kpi:hover {
  transform: none;
  box-shadow: none;
  border-top-color: var(--teal);
  background: color-mix(in srgb, var(--teal) 7%, transparent);
}
.ov-kpi-label {
  font-size: var(--text-micro); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--t3); font-family: var(--font-mono); margin-bottom: 0.35rem; }
.ov-kpi-value { font-family: var(--font-serif); font-size: 2rem; color: var(--text-brand); font-weight: 700; line-height: 1; }
.ov-kpi-icon {
  width: 36px; height: 36px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; margin-bottom: 0.75rem; }
.ov-kpi-icon svg {
  width: 20px; height: 20px; stroke-width: 1.8; }
.ov-kpi-icon.teal {
  background: var(--teal-dim); color: var(--text-brand); }
.ov-kpi-icon.royal {
  background: var(--royal-dim); color: var(--royal); }
.ov-kpi-icon.warning {
  background: rgba(154,106,8,0.08); color: var(--sev-warning); }
.ov-kpi-icon.danger {
  background: rgba(192,48,48,0.08); color: var(--danger); }
.ov-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.75rem; margin-bottom: 1.5rem; }
.ov-action {  display: flex; align-items: center; gap: 0.75rem; padding: 1rem 1.25rem;     cursor: pointer; transition: all 0.15s; text-decoration: none; color: inherit; }
.ov-action:hover {
  border-top-color: var(--teal);
  background: color-mix(in srgb, var(--teal) 7%, transparent);
  box-shadow: none;
}
.ov-action-icon {
  width: 40px; height: 40px; border-radius: var(--radius); background: var(--teal-dim); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ov-action-icon svg {
  width: 20px; height: 20px; stroke: var(--teal); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ov-action-text { font-weight: 600; font-size: var(--text-base); color: var(--ink); }
.ov-activity { padding: 1rem 1.25rem; }
.ov-activity-title {
  font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--t3); margin-bottom: 0.75rem; }
.ov-activity-item {
  display: flex; gap: 0.75rem; padding: 0.5rem 0; border-bottom: var(--border-subtle); font-size: var(--text-base); color: var(--t2); }
.ov-activity-item:last-child { border-bottom: none; }
.ov-activity-ts { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--t4); white-space: nowrap; }

/* Dashboard Command Center */
/* ── Sheet sections (dashboard) ───────────────────────────────────────
   The dashboard was a grid of white cards on grey: every panel carried a
   border, a radius and two shadows, which made the page one repeating texture
   and spent the brand colour on a gradient that said nothing. Here the page is
   one sheet and the structure is drawn with rules and space. A card still
   exists in the system (--card, --shadow-card) for things that genuinely float.

   Only the dashboard's own `dcc-` namespace is converted. Nothing shared is
   touched, and in particular no selector that also names the MRI page. */
/* ── Section kicker (eyebrow) — unified base; variants set only font-size ── */
/* The MRI page's and the classic MRI tab's kickers keep exactly what they had
   (owner: MRI unchanged). Kept apart from the app's kickers below so that no
   change to those can reach the MRI page through a shared selector list. */
.twm-kicker, .tw-mri-kicker {
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-brand);
}
/* The app's own kickers take the type scale's weight (700, not 800). */
.dcc-panel-kicker, .va-kicker, .ga-kicker, .tg-kicker {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-brand);
}
.dcc-panel-kicker {
  font-family: var(--font-mono);
  font-size: var(--text-micro);
}
/* Cards carried their own padding, so a tight gap was enough to separate them.
   Rules do not: the space between sections IS the separation now, so both grids
   open up. */
.dcc-kpis,
.dcc-grid {
  display: grid;
  gap: 2.2rem 2rem;
}
.dcc-kpis {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin-bottom: 2.4rem;
  padding-bottom: 1.6rem;
  border-bottom: 1px solid var(--rule);
}
.dcc-kpi,
.dcc-panel,
.dcc-launcher {
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}
/* The four figures are one row divided by rules, not four boxes. `border-inline-start`
   rather than `border-left`: in Arabic the row runs the other way and a left
   border would leave the first figure ruled and the last one open. */
.dcc-kpi {
  display: flex;
  flex-direction: column;
  min-height: 124px;
  padding: 0.1rem 1.15rem;
  border-inline-start: 1px solid var(--rule);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.16s var(--ease);
}
.dcc-kpis > .dcc-kpi:first-child { border-inline-start: 0; padding-inline-start: 0; }
/* No lift on hover: nothing is floating, so there is nothing to lift. The rule
   the figure already sits against is what responds. */
.dcc-kpi:hover { border-color: var(--teal); }
.dcc-kpi:hover .dcc-kpi-label { color: var(--text-brand); }
.dcc-kpi:hover strong {
  text-decoration: underline;
  text-decoration-color: var(--teal);
  text-underline-offset: 6px;
}
.dcc-kpi-label {
  font-family: var(--font-mono);
  font-size: var(--text-micro);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--t3);
}
/* Tabular figures: these four numbers sit in a row and change on every refresh,
   so proportional digits made the column edges shuffle between loads. */
.dcc-kpi strong {
  margin: 0.45rem 0 0.3rem;
  font-family: var(--font-serif);
  font-size: var(--text-numeral);
  line-height: 1.04;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.dcc-kpi-note {
  color: var(--t3);
  font-size: var(--text-sm);
  line-height: 1.35;
}
.dcc-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
/* Each panel opens with a rule, the way a bulletin opens a section — that one
   line does the job the card's four borders were doing. */
.dcc-panel {
  min-width: 0;
  padding: 0.9rem 0 0;
  border-top: 1px solid var(--rule-strong);
}
.dcc-panel-wide {
  grid-column: span 2;
}
/* The dashboard grid has five fixed panels in three columns, so the closing wide
   panel (recent activity) sat in the first two with a 370px blank strip beside it.
   Last, it takes the whole row. */
.dcc-grid > .dcc-panel-wide:last-child { grid-column: 1 / -1; }
.dcc-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.85rem;
}
.dcc-panel h3 {
  margin: 0.15rem 0 0;
  font-size: var(--text-md);
  color: var(--ink);
  border: none;
  padding: 0;
  box-shadow: none;
}
.dcc-link,
.dcc-panel-actions a,
.dcc-launcher a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* the compact tier of the control ladder */
  min-height: var(--control-h-sm);
  padding: 0 var(--control-px-sm);
  border-radius: var(--control-radius);
  border: 1px solid color-mix(in srgb, var(--teal) 25%, transparent);
  color: var(--text-brand);
  background: color-mix(in srgb, var(--teal) 8%, transparent);
  text-decoration: none;
  font-size: var(--control-fs-sm);
  line-height: var(--control-lh);
  font-weight: 600;
}
/* A panel's header link is a 32px button beside its title, not a tile
   stretched to the height of the kicker and title (it measured 46px). */
.dcc-link,
.dcc-panel-actions a { align-self: center; }
.dcc-link:hover,
.dcc-panel-actions a:hover,
.dcc-launcher a:hover {
  border-color: color-mix(in srgb, var(--teal) 42%, transparent);
  background: color-mix(in srgb, var(--teal) 14%, transparent);
}
.dcc-triage,
.dcc-activity-list,
.dcc-program-list,
.dcc-readiness-list {
  display: grid;
  gap: 0;
}
/* Rows were tinted chips stacked with a gap — a third surface on top of the
   card on top of the page. On the sheet they are ruled lines. */
.dcc-triage-row,
.dcc-activity-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.72rem 0;
  border-radius: 0;
  color: inherit;
  text-decoration: none;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--rule);
}
.dcc-triage-row:hover,
.dcc-activity-row:hover { background: color-mix(in srgb, var(--teal) 6%, transparent); }
.dcc-triage-row strong,
.dcc-activity-row strong {
  display: block;
  color: var(--ink);
  font-size: var(--text-base);
}
.dcc-triage-row small {
  display: block;
  margin-top: 0.12rem;
  color: var(--t3);
  font-size: var(--text-xs);
  line-height: 1.35;
}
/* Two lines at most for a list of ids: a broken audit chain listed about a
   hundred row ids, five lines at 1440 and fourteen on a phone. The row links
   to the audit log, and the full list is the line's title. */
.dcc-triage-row small.dcc-triage-ids {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
/* Severity was a coloured dot and nothing else. A dot alone tells a reader who
   cannot separate the hues nothing at all, and tells everyone else nothing
   about rank — amber and red are a guess until you hover the row. The margin
   now carries the word, in the severity colour, and the colours come from the
   severity vocabulary the tokens already define (--sev-*, each measured to pass
   as text) rather than from --warning / --danger, which are fill colours.
   The word is real text in the markup, not CSS `content`, so it is in the
   accessibility tree and in the page a translator would work from. */
.dcc-triage-dot {
  width: auto;
  height: auto;
  min-width: 4.4rem;
  border-radius: 0;
  margin-top: 0.1rem;
  background: none;
  font-size: var(--text-micro);
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--sev-ok);
}
.dcc-triage-row.is-warning .dcc-triage-dot { color: var(--sev-warning); }
.dcc-triage-row.is-danger  .dcc-triage-dot { color: var(--sev-critical); }
/* Arabic letters join, so spacing them apart breaks the word, and there is no
   upper case to go to — the same guard the other micro-labels carry. */
html[dir="rtl"] .dcc-triage-dot { letter-spacing: 0; text-transform: none; }
.dcc-program-row,
.dcc-readiness-list div {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-radius: 0;
  background: none;
  border-bottom: 1px solid var(--rule);
}
.dcc-program-row span,
.dcc-readiness-list span {
  color: var(--t3);
  font-size: var(--text-sm);
}
.dcc-program-row strong,
.dcc-readiness-list strong {
  color: var(--ink);
  font-family: var(--font-mono);
}
.dcc-mini-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.75rem;
}
.dcc-mini-stats span {
  padding: 0.36rem 0.52rem;
  border-radius: var(--radius-pill);
  background: rgba(0,174,218,0.09);
  color: var(--t2);
  font-size: var(--text-xs);
  font-weight: 700;
}
.dcc-scenario-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
  color: var(--ink);
  /* A scenario name runs in its own direction: on an Arabic page a Latin name
     was laid out right-to-left, so the ellipsis ate its START ("…hand-made
     timetable 1448-2"). It still sits at the right edge of an Arabic card. */
  unicode-bidi: plaintext;
}
html[dir="rtl"] .dcc-scenario-name { text-align: right; }
.dcc-scenario-meta {
  margin-top: 0.2rem;
  color: var(--t3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}
.dcc-mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
  margin: 0.85rem 0;
}
.dcc-mini-grid div {
  padding: 0.72rem;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--teal) 8%, transparent);
}
.dcc-mini-grid strong {
  display: block;
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  color: var(--ink);
  line-height: 1;
}
.dcc-mini-grid span {
  display: block;
  margin-top: 0.18rem;
  color: var(--t3);
  font-size: var(--text-xs);
}
.dcc-panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.dcc-activity-row {
  grid-template-columns: 150px minmax(0, 1fr) minmax(90px, auto) auto;
  align-items: center;
}
.dcc-activity-time {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--t4);
}
.dcc-activity-row > span:not(.dcc-activity-time) {
  color: var(--t3);
  font-size: var(--text-sm);
}
.dcc-activity-status {
  padding: 0.24rem 0.45rem;
  border-radius: var(--radius-pill);
  font-size: var(--text-micro);
  font-style: normal;
  font-weight: 700;
  background: rgba(148,163,184,0.12);
  color: var(--t2);
}
.dcc-activity-status.is-success,
.dcc-activity-status.is-allow {
  background: color-mix(in srgb, var(--teal) 12%, transparent);
  color: var(--text-brand);
}
.dcc-activity-status.is-error,
.dcc-activity-status.is-critical,
.dcc-activity-status.is-deny {
  background: rgba(192,48,48,0.12);
  color: var(--danger);
}
.dcc-empty {
  padding: 0.8rem;
  color: var(--t3);
  border-radius: var(--radius-sm);
  background: rgba(148,163,184,0.07);
}
.dcc-launcher {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.85rem;
  padding: 0.85rem;
}

/* The dashboard's dark block. Every selector here is (0,2,1), so it outranks
   the light-mode conversion above AND the new hover rules (0,2,0): left as it
   was, dark painted the figures, the panels and the launcher back as navy
   cards with tinted chips, and the hover affordances on the KPI and triage
   links — both are <a> — never fired at all. Dark is the same sheet as light.
   The borders take --rule / --rule-strong rather than slate at 0.07-0.16, which
   were weaker than the dividers this layout is built from.
   `.dcc-kpi-primary` is dropped: the template no longer carries it, and
   `.dcc-hero` / `.dcc-hero-status` went the same way with the hero block. */
html[data-theme="dark"] .dcc-kpi,
html[data-theme="dark"] .dcc-panel,
html[data-theme="dark"] .dcc-launcher {
  background-color: transparent;
  border-color: var(--rule);
}
html[data-theme="dark"] .dcc-panel { border-top-color: var(--rule-strong); }
html[data-theme="dark"] .dcc-triage-row,
html[data-theme="dark"] .dcc-activity-row,
html[data-theme="dark"] .dcc-program-row,
html[data-theme="dark"] .dcc-readiness-list div,
html[data-theme="dark"] .dcc-mini-grid div,
html[data-theme="dark"] .dcc-empty {
  background: none;
  border-color: var(--rule);
}
/* Re-stated at (0,3,0) so it outranks the (0,2,1) dark rules just above; at
   (0,2,0) the light hover never reached dark and these links had no hover at
   all there. */
html[data-theme="dark"] .dcc-triage-row:hover,
html[data-theme="dark"] .dcc-activity-row:hover { background: rgba(10,142,110,0.14); }
html[data-theme="dark"] .dcc-kpi:hover { border-color: var(--teal); }
/* ── Student context sidebar ── */
.student-ctx-sidebar { width: 280px; flex-shrink: 0; transition: transform 0.25s var(--ease), opacity 0.25s var(--ease); }
.student-ctx-sidebar.hidden {
  display: none; }
.student-ctx-card { padding: 1rem; }
.student-ctx-card h3 {
  font-family: var(--font-body); font-weight: 700; font-size: var(--text-md); color: var(--navy); margin: 0 0 0.75rem; }
.student-ctx-row {
  display: flex; justify-content: space-between; align-items: center; padding: 0.35rem 0; border-bottom: var(--border-subtle); font-size: var(--text-sm); }
.student-ctx-row:last-child { border-bottom: none; }
.student-ctx-label {
  color: var(--t3); font-weight: 600; font-family: var(--font-mono); font-size: var(--text-micro); text-transform: uppercase; letter-spacing: 0.04em; }
.student-ctx-value { font-weight: 700; color: var(--ink); font-family: var(--font-mono); font-size: var(--text-base); }
.student-ctx-link {
  display: inline-flex; align-items: center; gap: 0.35rem; margin-top: 0.75rem; padding: 0.45rem 0.85rem; border-radius: var(--radius-sm); background: var(--teal-dim);  color: var(--text-brand); font-weight: 600; font-size: var(--text-sm); text-decoration: none; transition: all 0.15s; }
.student-ctx-link:hover { background: var(--teal-border); }
@media (max-width: 991px) {
  .student-ctx-sidebar {
  width: 100%; margin-top: 1rem; }
}

/* ── Mobile density: compact dashboard KPIs + actions ── */
@media (max-width: 768px) {
  .ov-greeting { font-size: var(--text-lg); }
  .ov-date { margin-bottom: 0.75rem; }
  .ov-kpis { gap: 0.5rem; margin-bottom: 0.75rem; grid-template-columns: 1fr 1fr; }
  .ov-kpi { padding: 0.65rem 0.75rem; }
  .ov-kpi-icon { width: 28px; height: 28px; margin-bottom: 0.35rem; }
  .ov-kpi-icon svg { width: 16px; height: 16px; }
  .ov-kpi-value { font-size: var(--text-xl); }
  .ov-kpi-label { font-size: var(--text-micro); margin-bottom: 0.2rem; }
  .ov-actions { gap: 0.5rem; margin-bottom: 0.75rem; grid-template-columns: 1fr 1fr; }
  .ov-action { padding: 0.6rem 0.75rem; gap: 0.5rem; }
  .ov-action-icon { width: 32px; height: 32px; }
  .ov-action-text { font-size: var(--text-sm); }
  .ov-activity { padding: 0.65rem 0.75rem; }
  .ov-activity-title { margin-bottom: 0.4rem; }
  .dcc-kpis,
  .dcc-grid {
    grid-template-columns: 1fr;
  }
  /* The figures stack here, so the rule that divides them has to turn with
     them: an inline-start border on a one-column stack draws a vertical line
     down the left of every figure instead of separating them from each other. */
  .dcc-kpi {
    min-height: 0;
    padding: 0.85rem 0;
    border-inline-start: 0;
    border-bottom: 1px solid var(--rule);
  }
  .dcc-kpis > .dcc-kpi:last-child { border-bottom: 0; }
  .dcc-kpis { padding-bottom: 0.4rem; }
  .dcc-kpi strong { font-size: var(--text-xl); }
  .dcc-panel-wide { grid-column: auto; }
  .dcc-activity-row {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }
  .dcc-launcher a {
    flex: 1 1 130px;
  }
}

/* ── Issue #15: Export button loading state ── */
.ux-loading { pointer-events: none; opacity: 0.7; position: relative; }
.ux-loading::after { content: ''; position: absolute; top: 50%; right: 10px; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: ux-spin 0.6s linear infinite; margin-top: -7px; }
@keyframes ux-spin { to { transform: rotate(360deg); } }

/* ── Issue #20: Batch progress indicator ── */
.batch-progress { height: 4px; background: var(--teal-dim); border-radius: 2px; margin-bottom: 1rem; overflow: hidden; }
.batch-progress-bar { height: 100%; background: var(--teal); border-radius: 2px; transition: width 0.3s var(--ease); width: 0%; }

/* ── Issue #28: Scrape log expanded ── */
.scrape-term-body.expanded { max-height: 600px; }
.scrape-term-toggle {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: var(--radius-sm); border: none;
  background: var(--teal-dim); color: var(--text-brand);
  font-size: var(--text-micro); font-weight: 700; font-family: var(--font-mono);
  cursor: pointer; transition: all 0.2s; letter-spacing: 0.02em;
  box-shadow: 2px 2px 5px rgba(163,177,198,0.2),
              -2px -2px 5px rgba(255,255,255,0.6);
}
.scrape-term-toggle:hover {
  background: color-mix(in srgb, var(--teal) 14%, transparent); color: var(--text-brand);
  box-shadow: 3px 3px 6px rgba(163,177,198,0.25),
              -3px -3px 6px rgba(255,255,255,0.7);
}
.scrape-term-toggle:active {
  box-shadow: inset 2px 2px 4px rgba(163,177,198,0.3),
              inset -2px -2px 4px rgba(255,255,255,0.5);
}

/* ── Scrape history pagination ── */
.scrape-hist-pager {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; margin-top: 6px;
  background: rgba(255,255,255,0.45);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.5);
  box-shadow: 3px 3px 8px rgba(163,177,198,0.2),
              -3px -3px 8px rgba(255,255,255,0.5);
}
.scrape-hist-page-info { font-size: var(--text-xs); color: var(--t2); font-family: var(--font-mono); }
.scrape-hist-page-info strong { color: var(--t1); }
.scrape-hist-page-btns { display: flex; align-items: center; gap: 6px; }
.sh-page-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: var(--radius-sm); border: none;
  background: var(--glass-bg); color: var(--t2); cursor: pointer;
  box-shadow: 2px 2px 5px rgba(163,177,198,0.25),
              -2px -2px 5px rgba(255,255,255,0.6);
  transition: all 0.15s;
}
.sh-page-btn:hover:not(:disabled) {
  color: var(--text-brand);
  box-shadow: 3px 3px 6px rgba(163,177,198,0.3),
              -3px -3px 6px rgba(255,255,255,0.7);
}
.sh-page-btn:active:not(:disabled) {
  box-shadow: inset 2px 2px 4px rgba(163,177,198,0.3),
              inset -2px -2px 4px rgba(255,255,255,0.5);
}
.sh-page-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.sh-page-num {
  font-size: var(--text-xs); font-weight: 600; color: var(--t1); min-width: 50px;
  text-align: center; font-family: var(--font-mono);
}

/* ── Command palette keyboard navigation ── */
.cmd-item.kbd-active { background: var(--royal-dim); outline: 2px solid var(--teal); outline-offset: -2px; }

/* ── Client-side table pagination ── */
.tbl-pager { display:flex; align-items:center; gap:12px; justify-content:space-between; padding:10px 0; font-size:var(--text-base); color:var(--t4); }
.tbl-pager button { background:none; border:1px solid var(--line); border-radius:var(--radius-sm); padding:4px 12px; cursor:pointer; font-size:var(--text-base); }
.tbl-pager button:disabled { opacity:0.6; cursor:default; }
.tbl-pager button:hover:not(:disabled) { background:var(--teal-dim); }
.tbl-pager select { border:1px solid var(--line); border-radius:var(--radius-sm); padding:2px 6px; font-size:var(--text-base); }

/* ── Extracted utility classes (inline → class) ──── */
.mb-14 { margin-bottom: 14px; }
.mb-12 { margin-bottom: 12px; }
.mb-18 { margin-bottom: 18px; }
.mb-16 { margin-bottom: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-6 { margin-bottom: 6px; }
.mb-10 { margin-bottom: 10px; }
.mt-6 { margin-top: 6px; }
.mt-8 { margin-top: 8px; }
.mt-10 { margin-top: 10px; }
.mt-12 { margin-top: 12px; }
.mt-14 { margin-top: 14px; }
.mt-16 { margin-top: 16px; }

.flex-card { flex: 1; min-width: 0; }
.flex-field { flex: 1; min-width: 140px; }
.flex-spacer { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }

.field-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.field-row-mt { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-top: 4px; }
.field-action { flex: 0 0 auto; padding-bottom: 1px; }

.metrics-row-12 { display: flex; gap: 12px; }
.metrics-row-14 { display: flex; gap: 14px; }
.skel-row { display: flex; gap: 12px; align-items: center; }

.overflow-x { overflow-x: auto; }

.empty-icon-32 { width: 32px; height: 32px; }
.empty-icon-48 { width: 48px; height: 48px; opacity: 0.30; margin-bottom: 12px; }
.empty-icon-muted { width: 32px; height: 32px; color: var(--t4); margin-bottom: 8px; }

.fb-search-full { max-width: none; }
.fb-w-110 { max-width: 110px; }
/* a floor, so a field that no longer fits beside its neighbour wraps instead
   of being crushed (the scrape form's programme field: 28px on an Arabic phone) */
.fb-search.fb-w-110 { min-width: 64px; }
/* `padding: 8px 14px` indented the controls 14px while the bar's rule still
   spanned the full width, so a small bar read as misaligned against every
   other one on the page. */
.filter-bar-sm { padding: 8px 0; }

.meta-mono { font-family: var(--font-mono); font-size: var(--text-xs); border-radius: var(--radius-sm); padding: 10px 14px; }
.ts-updated { font-size: var(--text-xs); color: var(--t3); font-family: var(--font-body); font-variant-numeric: tabular-nums; }
.color-t3 { color: var(--t3); }
.i-faint { opacity: 0.4; }
.filter-pad { padding: 8px 0; }

.step-circle    { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; background: var(--teal-dim); border: 1px solid var(--teal-border); color: var(--text-brand); font-family: var(--font-mono); font-size: var(--text-micro); font-weight: 700; }
.step-label { font-size: var(--text-xs); color: var(--t3); font-weight: 600; white-space: nowrap; }
.step-arrow { stroke: var(--t5); fill: none; stroke-width: 2; stroke-linecap: round; }

.section-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 8px; }
.section-heading h3 { font-family: var(--font-body); font-weight: 700; font-size: var(--text-md); color: var(--navy); margin: 0; }
.section-badge  { font-family: var(--font-mono); font-size: var(--text-micro); font-weight: 700; padding: 3px 9px; border-radius: var(--radius-pill); background: var(--teal-dim); color: var(--text-brand); border: 1px solid var(--teal-border); }

.dlg-box-lg { max-width: 800px; }
.dlg-body-scroll { max-height: 70vh; overflow-y: auto; }

.mc-val-lg { font-size: var(--text-xl); }
.mc-val-sm { font-size: var(--text-lg); }
.mc-val-mono-sm { font-size: var(--text-md); font-family: var(--font-mono); letter-spacing: 0; }

.adv-textarea { border-radius: var(--radius-sm); border: var(--border-subtle); background: var(--glass-bg); font-size: var(--text-sm); }
.sticky-16 {  }

.plan-side-col { width: 340px; flex-shrink: 0; }
.plan-layout { display: flex; gap: 16px; align-items: flex-start; }
/* Before a plan is loaded the term column is empty, and a "Course Inspector ·
   LIVE" card with nothing to inspect stood alone under the empty state. Both
   arrive with the plan (an error message fills the column, so it shows too). */
.plan-layout:has(#studentPlanTerms:empty) { display: none; }

.can-register-pill { background: var(--teal-dim); }
.scrape-metrics-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }

/* ── Inline style extractions (panels) ── */
.btn-compact { padding: 6px 14px; font-size: var(--text-xs); }
.btn-adv-ensure { padding: 8px 14px; }
.sp-empty-hero { padding: 2.5rem 1.5rem 1.8rem; }
.sp-empty-title { font-size: var(--text-lg); margin-bottom: 6px; }
.sp-empty-hint { max-width: 420px; margin-bottom: 22px; }
.sp-build-plan { background: var(--teal-dim); border-color: var(--teal-border); color: var(--text-brand); }
.dbg-col-btn { font-size: var(--text-xs); padding: 4px 10px; border-radius: var(--radius-sm); background: var(--glass-bg); border: var(--border-subtle); color: var(--t3); cursor: pointer; }

/* ═══════════════════════════════════════════════════════
   DARK MODE OVERRIDES  (Deep Navy theme)
   ═══════════════════════════════════════════════════════ */

/* ── Scrape terminal ──────────────────────────────────── */
html[data-theme="dark"] .scrape-term {
  border-color: rgba(255,255,255,0.06);
  box-shadow: 6px 6px 16px rgba(0,0,0,0.4), -6px -6px 16px rgba(255,255,255,0.02);
}
html[data-theme="dark"] .scrape-term-head {
  background: rgba(255,255,255,0.04);
  border-bottom-color: rgba(255,255,255,0.06);
}
html[data-theme="dark"] .scrape-term-label { color: var(--t0); }
html[data-theme="dark"] .scrape-term-file { color: var(--t3); }
html[data-theme="dark"] .scrape-term-body {
  background: rgba(255,255,255,0.03);
  color: var(--t2);
  box-shadow: inset 3px 3px 8px rgba(0,0,0,0.3), inset -3px -3px 8px rgba(255,255,255,0.02);
}
html[data-theme="dark"] .scrape-term-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); }
html[data-theme="dark"] .scrape-term-body::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }html[data-theme="dark"] .scrape-term-body div,
html[data-theme="dark"] .student-ctx-row,
html[data-theme="dark"] .ov-activity-item,
html[data-theme="dark"] .sp-adv-table td,
html[data-theme="dark"] #umTable tbody td {
  border-bottom-color: rgba(255,255,255,0.04);
}

/* ── Terminal token colours ───────────────────────────── */
html[data-theme="dark"] .t-ts  { color: var(--t4); }
html[data-theme="dark"] .t-er  { color: var(--danger); }
html[data-theme="dark"] .t-hl  { color: var(--royal-bright); }
html[data-theme="dark"] .t-wrn { color: var(--sev-warning); }

/* ── Trace buttons ────────────────────────────────────── */
html[data-theme="dark"] .trace-btn-copy { background: rgba(255,255,255,0.05); }
html[data-theme="dark"] .trace-btn-copy:hover {
  background: rgba(255,255,255,0.1);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* ── Command palette ──────────────────────────────────── */
html[data-theme="dark"] .cmd-modal {
  background: var(--card);
  border-color: rgba(255,255,255,0.08);
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}html[data-theme="dark"] .cmd-esc {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.1);
}
html[data-theme="dark"] .cmd-section-label { border-top-color: rgba(255,255,255,0.06); }
html[data-theme="dark"] .cmd-item:hover,
html[data-theme="dark"] .cmd-item.selected,
html[data-theme="dark"] .cmd-item.kbd-active {
  background: rgba(255,255,255,0.04);
}
html[data-theme="dark"] .cmd-item-badge {
  background: rgba(10,142,110,0.15);
  border-color: rgba(10,142,110,0.25);
}

/* ── Advisor wizard bar ───────────────────────────────── */
html[data-theme="dark"] .adm-wizard-bar {
  background: rgba(10,142,110,0.08);
  border-color: rgba(10,142,110,0.2);
}
html[data-theme="dark"] .adm-step-inactive .adm-step-circle {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.12);
}
html[data-theme="dark"] .adm-step-label { color: var(--text-brand); }
html[data-theme="dark"] .adm-step-line-inactive { background: rgba(255,255,255,0.1); }

/* ── Scrape history pager ─────────────────────────────── */
html[data-theme="dark"] .scrape-hist-pager {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.06);
  box-shadow: 3px 3px 8px rgba(0,0,0,0.3), -3px -3px 8px rgba(255,255,255,0.02);
}
/* scrape-hist-page-info: see consolidated overrides below */
html[data-theme="dark"] .sh-page-btn {
  color: var(--t2);
  box-shadow: 2px 2px 5px rgba(0,0,0,0.3), -2px -2px 5px rgba(255,255,255,0.02);
}
html[data-theme="dark"] .sh-page-btn:hover:not(:disabled) {
  box-shadow: 3px 3px 6px rgba(0,0,0,0.35), -3px -3px 6px rgba(255,255,255,0.03);
}
html[data-theme="dark"] .sh-page-btn:active:not(:disabled) {
  box-shadow: inset 2px 2px 4px rgba(0,0,0,0.3), inset -2px -2px 4px rgba(255,255,255,0.02);
}
html[data-theme="dark"] .sh-page-num { color: var(--t0); }

/* ── Neumorphic shadow flips ──────────────────────────── */
html[data-theme="dark"] .scrape-term-toggle {
  box-shadow: 2px 2px 5px rgba(0,0,0,0.3), -2px -2px 5px rgba(255,255,255,0.02);
}
html[data-theme="dark"] .scrape-term-toggle:hover {
  box-shadow: 3px 3px 6px rgba(0,0,0,0.35), -3px -3px 6px rgba(255,255,255,0.03);
}
html[data-theme="dark"] .scrape-term-toggle:active {
  box-shadow: inset 2px 2px 4px rgba(0,0,0,0.3), inset -2px -2px 4px rgba(255,255,255,0.02);
}

/* ── HP advanced defaults badge ───────────────────────── */
html[data-theme="dark"] .hp-adv-defaults-badge {
  background: rgba(255,255,255,0.04);
}

/* ── Scrape terminal bg ─── */
html[data-theme="dark"] .scrape-term {
  background: rgba(255,255,255,0.04) !important;
  border-color: rgba(255,255,255,0.06) !important;
}

/* ── Cmd item badge (light green → dark teal) ─── */
html[data-theme="dark"] .cmd-item-badge {
  background: rgba(10,142,110,0.15) !important;
  color: var(--text-brand) !important;
  border-color: rgba(10,142,110,0.25) !important;
}

/* ── Cmd item hover ─── */
html[data-theme="dark"] .cmd-item:hover,
html[data-theme="dark"] .cmd-item.selected {
  background: rgba(255,255,255,0.06) !important;
}

/* ── Scrape hist page info hardcoded colors ─── */
html[data-theme="dark"] .scrape-hist-page-info { color: var(--t3) !important; }
html[data-theme="dark"] .scrape-hist-page-info strong { color: var(--t1) !important; }
html[data-theme="dark"] .sh-page-num { color: var(--t1) !important; }

/* ── Trace btn copy hardcoded color ─── */
html[data-theme="dark"] .trace-btn-copy { color: var(--t3) !important; }

/* Dashboard-card dark surface moved to V2 UNIFIED rule above *//* ============================================================
   DB ADMIN — feature-specific styles
   ------------------------------------------------------------
   Moved out of core/templates/core/db_admin.html.
   ============================================================ */

/* ── DB Admin Console layout ─────────────────────────── */
    pre { white-space: pre-wrap; word-break: break-all; overflow-x: auto; }

    /* Stacked layout: horizontal tabs on top, work area below */
    .dba-shell {
      display:        flex;
      flex-direction: column;
      gap:            1rem;
      min-height:     calc(100vh - 120px);
    }

    /* TOP: horizontal tab bar */
    .dba-nav {
      display:        flex;
      flex-wrap:      wrap;
      gap:            0.35rem;
      width:          100%;
      padding-bottom: 0.5rem;
      border-bottom:  1px solid var(--pl-overlay-5);
    }

    .dba-nav-label {
      display:        none;
    }

    .dba-nav-item {
      display:        flex;
      align-items:    center;
      gap:            0.4rem;
      padding:        0.4rem 0.7rem;
      border-radius:  var(--radius-sm, 7px);
      border:         1px solid transparent;
      cursor:         pointer;
      transition:     background 0.12s, border-color 0.12s, box-shadow 0.12s;
      background:     var(--glass-bg);
      backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
      border-color:   var(--pl-overlay-3);
      box-shadow:     0 1px 2px rgba(13,21,38,.04);
      user-select:    none;
      text-decoration: none;
      color:          inherit;
      white-space:    nowrap;
    }

    .dba-nav-item:hover {
      background:   var(--glass-bg-data);
      border-color: var(--pl-overlay-5);
    }

    .dba-nav-item.active {
      background:   var(--glass-bg-data);
      border-color: var(--teal);
      box-shadow:   0 0 0 2px color-mix(in srgb, var(--teal) 10%, transparent);
    }

    .dba-nav-item.danger-item.active {
      background:   rgba(255,245,245,0.7);
      border-color: var(--danger);
      box-shadow:   0 0 0 2px rgba(224,52,52,.1);
    }

    .dba-nav-icon {
      flex-shrink: 0;
      width:       26px;
      height:      26px;
      border-radius: var(--radius-sm);
      display:     flex;
      align-items: center;
      justify-content: center;
    }
    .dba-nav-icon .i { width: 14px; height: 14px; }

    .icon-safe    { background: #f0fdf4; color: #16a34a; }
    .icon-danger  { background: #fff1f2; color: #dc2626; }
    .icon-warning { background: #fffbeb; color: var(--sev-warning); }
    .icon-system  { background: #f0f9ff; color: #0284c7; }

    .dba-nav-text { flex: 1; min-width: 0; }

    .dba-nav-name {
      font-size:   var(--text-sm);
      font-weight: 600;
      color:       var(--ink);
      line-height: 1.2;
    }

    .dba-nav-desc {
      display: none;
    }

    /* SAFE / WARNING / DANGER is the only cue that separates a harmless
       operation from a destructive one, and it was 8.3px: it is 12px now, the
       same as body labels, with room around it. */
    .dba-risk-badge {
      flex-shrink: 0;
      font-size:   var(--text-xs);
      font-weight: 700;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      padding:     0.12rem 0.4rem;
      border-radius: var(--radius-xs);
    }
    .risk-danger  { background: #fee2e2; color: #991b1b; }
    .risk-danger-icon { font-size: 1em; line-height: 1; }
    .risk-warning { background: #fef3c7; color: #92400e; }
    .risk-safe    { background: #c6f6d5; color: #14532d; border: 1px solid #86efac; }

    /* BOTTOM: work area — full width */
    .dba-work {
      flex:     1;
      min-width: 0;
      width:    100%;
    }

    /* Individual panels */
    .dba-panel { display: none; }
    .dba-panel.active { display: block; }

    /* Panel header */
    .dba-panel-header {
      display:      flex;
      align-items:  center;
      gap:          0.875rem;
      margin-bottom: 1.25rem;
      padding-bottom: 1rem;
      border-bottom: var(--border-subtle);
    }

    .dba-panel-icon {
      width:         48px;
      height:        48px;
      border-radius: var(--radius-md);
      display:       flex;
      align-items:   center;
      justify-content: center;
      flex-shrink:   0;
    }
    .dba-panel-icon .i { width: 24px; height: 24px; }

    .dba-panel-title {
      font-size:      var(--text-lg);
      font-weight:    700;
      color:          var(--ink);
      letter-spacing: -0.01em;
      margin-bottom:  0.2rem;
    }

    .dba-panel-subtitle {
      font-size:   var(--text-base);
      color:       var(--muted);
      line-height: 1.45;
    }

    /* Danger zone panel accent */
    .dba-panel.danger-panel .dba-panel-header {
      background:    #fff5f5;
      border:        1px solid var(--pl-conflict-cell);
      border-radius: var(--radius);
      padding:       1rem;
      margin-bottom: 1.25rem;
    }

    /* Output pre block */
    .dba-output {
      background:    rgba(248,250,252,0.85);
      backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
      color:         var(--t2);
      border-radius: var(--radius);
      padding:       0.875rem 1rem;
      font-family:   var(--font-mono);
      font-size:     var(--text-sm);
      line-height:   1.7;
      border:        1px solid color-mix(in srgb, var(--teal) 10%, transparent);
      min-height:    60px;
      margin-top:    0.75rem;
      white-space:   pre-wrap;
      word-break:    break-all;
      box-shadow:    inset 0 1px 3px rgba(0,0,0,0.04);
    }
    .dba-output:empty::before { content: '—'; color: var(--t4); }

    .dba-output.has-error {
      color: #991b1b;
      background: rgba(254,226,226,0.6);
      border-color: rgba(220,53,69,0.18);
    }
    .dba-output.has-success {
      color: #065f46;
      background: rgba(209,250,229,0.5);
      border-color: var(--brand-glow);
    }

    /* Output wrapper (collapsible details) */
    .dba-output-wrap { margin-top: 0.75rem; }
    .dba-output-wrap summary {
      cursor: pointer; font-size: var(--text-micro); font-weight: 700;
      text-transform: uppercase; letter-spacing: 0.04em;
      color: var(--t3); padding: 4px 0; user-select: none;
      display: inline-flex; align-items: center; gap: 4px;
    }
    .dba-output-wrap summary::marker { content: ''; }
    .dba-output-wrap summary::before { content: '▸'; font-size: max(var(--fs-floor), 0.7rem); transition: transform 0.15s; }
    .dba-output-wrap[open] summary::before { transform: rotate(90deg); }

    /* Action section within panel */
    .dba-section {
      background:    var(--card);
      border:        1px solid var(--line);
      border-radius: var(--radius);
      padding:       1.125rem 1.25rem;
      margin-bottom: 0.875rem;
    }

    /* .dba-section-title base (font/color/margin/layout) handled by
       the canonical card-heading rule. Only the state ::before
       definition lives here — the default is hidden via that rule,
       but .danger-panel variant re-enables it. */
    .dba-section-title::before {
      content:       '';
      width:         3px;
      height:        0.8rem;
      border-radius: 2px;
      background:    var(--brand);
      opacity:       0.55;
    }

    .danger-panel .dba-section-title::before { background: var(--danger); }

    /* Programme Capacities: an edited limit is a draft until it is saved
       (tokens only, so dark mode follows). Save stays focusable when it
       cannot run (aria-disabled); the status line under it says why. */
    #capBody .cap-input { max-width: 110px; }
    #capBody tr.cap-draft td { background: color-mix(in srgb, var(--warning) 8%, transparent); }
    #capBody tr.cap-draft .cap-input { border-color: var(--warning); }
    #capBody tr.cap-invalid .cap-input { border-color: var(--danger); }
    .cap-state { display: block; font-size: var(--text-micro); font-weight: 700; color: var(--sev-warning); }
    #capBody tr.cap-invalid .cap-state { color: var(--danger); }
    #capSave[aria-disabled="true"] { opacity: .5; cursor: default; }

    /* Current section snapshot: preview-first destructive workflow */
    .dba-snapshot-status {
      margin-bottom: 0.875rem;
      padding: 0.75rem 0.9rem;
      border: 1px solid var(--line);
      border-radius: var(--radius);
      color: var(--t2);
      background: var(--glass-bg-data);
      font-size: var(--text-sm);
      line-height: 1.55;
    }
    .dba-snapshot-status.is-success {
      border-color: color-mix(in srgb, var(--success) 30%, var(--line));
      color: color-mix(in srgb, var(--sev-ok) 75%, var(--ink));
      background: color-mix(in srgb, var(--success) 7%, var(--card));
    }
    .dba-snapshot-status.is-error {
      border-color: color-mix(in srgb, var(--danger) 32%, var(--line));
      color: color-mix(in srgb, var(--danger) 78%, var(--ink));
      background: color-mix(in srgb, var(--danger) 7%, var(--card));
    }
    .dba-snapshot-status.is-info {
      border-color: color-mix(in srgb, var(--royal) 24%, var(--line));
      background: color-mix(in srgb, var(--royal) 5%, var(--card));
    }
    .dba-snapshot-lock-note {
      display: flex;
      align-items: flex-start;
      gap: 0.4rem;
      margin-top: 0.75rem;
      color: var(--t3);
      font-size: var(--text-xs);
      line-height: 1.5;
    }
    .dba-snapshot-lock-note > span:first-child { flex: 0 0 auto; }

    .dba-snapshot-heading,
    .dba-snapshot-table-head,
    .dba-snapshot-actions {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 1rem;
    }
    .dba-snapshot-scope {
      color: var(--t3);
      font-size: var(--text-sm);
    }
    .dba-preview-ready {
      flex: 0 0 auto;
      padding: 0.28rem 0.55rem;
      border: 1px solid color-mix(in srgb, var(--success) 28%, var(--line));
      border-radius: var(--radius-pill);
      color: var(--sev-ok);
      background: color-mix(in srgb, var(--success) 7%, var(--card));
      font-size: var(--text-xs);
      font-weight: 700;
    }

    .dba-snapshot-metrics {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 0.6rem;
      margin-top: 1rem;
    }
    .dba-snapshot-metric {
      display: flex;
      min-height: 70px;
      flex-direction: column;
      justify-content: center;
      gap: 0.2rem;
      padding: 0.7rem 0.8rem;
      border: 1px solid var(--line);
      border-radius: var(--radius);
      background: var(--glass-bg-data);
    }
    .dba-snapshot-metric span {
      color: var(--t3);
      font-size: var(--text-xs);
      font-weight: 700;
    }
    .dba-snapshot-metric strong {
      color: var(--danger);
      font-family: var(--font-serif);
      font-size: var(--text-xl);
      line-height: 1;
    }

    .dba-snapshot-note {
      margin-top: 0.75rem;
      padding: 0.65rem 0.75rem;
      border-inline-start: 3px solid var(--amber);
      border-radius: var(--radius-sm);
      color: var(--t2);
      background: color-mix(in srgb, var(--warning) 7%, var(--card));
      font-size: var(--text-sm);
      line-height: 1.55;
      white-space: pre-line;
    }
    .dba-snapshot-table-head {
      margin-bottom: 0.5rem;
      color: var(--t2);
      font-size: var(--text-xs);
    }
    .dba-snapshot-table-head span { color: var(--t3); font-size: var(--text-xs); }
    .dba-snapshot-table-wrap {
      max-height: 320px;
      border: 1px solid var(--line);
      border-radius: var(--radius);
    }
    .dba-snapshot-table {
      color: var(--t2);
      font-size: var(--text-xs);
    }
    .dba-snapshot-table thead th {
      position: sticky;
      z-index: 1;
      top: 0;
      border-color: var(--line);
      color: var(--t3);
      background: var(--card);
      font-size: var(--text-micro);
      white-space: nowrap;
    }
    .dba-snapshot-table td { border-color: var(--line); }
    .dba-snapshot-table tr.is-retained td { opacity: 0.72; }
    .dba-snapshot-code { color: var(--text-brand); font-weight: 700; }
    .dba-program-chips {
      display: flex;
      align-items: center;
      gap: 0.25rem;
      flex-wrap: wrap;
    }
    .dba-program-chip {
      display: inline-flex;
      padding: 0.16rem 0.4rem;
      border: 1px solid var(--teal-border);
      border-radius: var(--radius-pill);
      color: var(--text-brand);
      background: color-mix(in srgb, var(--teal) 6%, var(--card));
      font-size: var(--text-micro);
      font-weight: 700;
    }
    .dba-snapshot-action {
      display: inline-flex;
      padding: 0.18rem 0.4rem;
      border: 1px solid var(--line);
      border-radius: var(--radius-pill);
      font-size: var(--text-micro);
      font-weight: 700;
      white-space: nowrap;
    }
    .dba-snapshot-action.is-delete {
      border-color: color-mix(in srgb, var(--danger) 28%, var(--line));
      color: var(--danger);
      background: color-mix(in srgb, var(--danger) 6%, var(--card));
    }
    .dba-snapshot-action.is-retained {
      color: var(--t3);
      background: var(--glass-bg-data);
    }

    .dba-snapshot-preserved {
      border-color: color-mix(in srgb, var(--success) 22%, var(--line));
      background: color-mix(in srgb, var(--success) 3%, var(--card));
    }
    .dba-snapshot-preserved ul {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 0.45rem 1.25rem;
      margin: 0;
      padding-inline-start: 1.1rem;
      color: var(--t2);
      font-size: var(--text-xs);
      line-height: 1.5;
    }

    .dba-snapshot-actions {
      padding: 0.9rem 1rem;
      border: 1px solid color-mix(in srgb, var(--danger) 22%, var(--line));
      border-radius: var(--radius);
      background: color-mix(in srgb, var(--danger) 4%, var(--card));
    }
    .dba-snapshot-actions > div {
      display: flex;
      min-width: 0;
      flex-direction: column;
      gap: 0.15rem;
    }
    .dba-snapshot-actions strong { color: var(--t1); font-size: var(--text-sm); }
    .dba-snapshot-actions span { color: var(--t3); font-size: var(--text-xs); }
    .dba-snapshot-actions .btn { flex: 0 0 auto; }

    /* Current-section CSV merge workflow */
    .dba-current-import-route,
    .dba-current-import-actions,
    .dba-current-import-preview-head,
    .dba-current-import-table-head,
    .dba-current-import-confirm {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 1rem;
    }
    .dba-current-import-route {
      margin-bottom: 1rem;
      padding: 0.8rem 0.9rem;
      border: 1px solid var(--teal-border);
      border-radius: var(--radius);
      background: color-mix(in srgb, var(--teal) 5%, var(--card));
    }
    .dba-current-import-route > div,
    .dba-current-import-confirm > div {
      display: flex;
      min-width: 0;
      flex-direction: column;
      gap: 0.15rem;
    }
    .dba-current-import-route strong,
    .dba-current-import-confirm strong { color: var(--t1); font-size: var(--text-sm); }
    .dba-current-import-route span,
    .dba-current-import-confirm span { color: var(--t3); font-size: var(--text-xs); line-height: 1.5; }
    .dba-current-import-route .btn { flex: 0 0 auto; }

    .dba-source-choice {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 0.5rem;
    }
    .dba-source-choice > label {
      display: flex;
      min-height: 64px;
      align-items: flex-start;
      gap: 0.55rem;
      padding: 0.65rem 0.7rem;
      border: 1px solid var(--line);
      border-radius: var(--radius);
      cursor: pointer;
      background: var(--glass-bg-data);
    }
    .dba-source-choice > label:has(input:checked) {
      border-color: var(--teal);
      box-shadow: 0 0 0 2px color-mix(in srgb, var(--teal) 9%, transparent);
    }
    .dba-source-choice input { margin-top: 0.15rem; }
    .dba-source-choice label > span { display: flex; flex-direction: column; gap: 0.1rem; }
    .dba-source-choice strong { color: var(--t1); font-size: var(--text-xs); }
    .dba-source-choice small { color: var(--t3); font-size: var(--text-micro); line-height: 1.35; }

    .dba-default-programmes {
      margin-top: 1rem;
      padding-top: 0.9rem;
      border-top: 1px solid var(--line);
    }
    .dba-default-programmes legend {
      width: auto;
      margin-bottom: 0.15rem;
      color: var(--t1);
      font-size: var(--text-sm);
      font-weight: 700;
    }
    .dba-default-programmes p {
      margin-bottom: 0.55rem;
      color: var(--t3);
      font-size: var(--text-xs);
      line-height: 1.5;
    }
    .dba-programme-selector { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
    .dba-programme-option {
      display: inline-flex;
      min-height: 36px;
      align-items: center;
      gap: 0.4rem;
      padding: 0.35rem 0.65rem;
      border: 1px solid var(--line);
      border-radius: var(--radius-pill);
      cursor: pointer;
      color: var(--t2);
      background: var(--glass-bg-data);
      font-size: var(--text-xs);
      font-weight: 700;
    }
    .dba-programme-option:has(input:checked) {
      border-color: var(--teal);
      color: var(--text-brand);
      background: color-mix(in srgb, var(--teal) 7%, var(--card));
    }
    .dba-programme-option input { margin: 0; }

    .dba-current-import-actions {
      align-items: flex-start;
      margin-top: 1rem;
    }
    .dba-current-import-actions > span {
      max-width: 54rem;
      color: var(--t3);
      font-size: var(--text-xs);
      line-height: 1.55;
    }
    .dba-current-import-actions .btn { flex: 0 0 auto; }

    .dba-current-import-preview-head { align-items: flex-start; }
    .dba-current-import-preview-head p { color: var(--t3); font-size: var(--text-xs); }
    .dba-preview-ready.is-blocked {
      border-color: color-mix(in srgb, var(--danger) 28%, var(--line));
      color: var(--danger);
      background: color-mix(in srgb, var(--danger) 6%, var(--card));
    }
    .dba-current-import-metrics {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 0.55rem;
      margin-top: 1rem;
    }
    .dba-current-import-metric {
      display: flex;
      min-height: 68px;
      flex-direction: column;
      justify-content: center;
      gap: 0.2rem;
      padding: 0.65rem 0.75rem;
      border: 1px solid var(--line);
      border-radius: var(--radius);
      background: var(--glass-bg-data);
    }
    .dba-current-import-metric span { color: var(--t3); font-size: var(--text-micro); font-weight: 700; }
    .dba-current-import-metric strong { color: var(--t1); font-size: var(--text-xl); line-height: 1; }
    .dba-current-import-metric.is-new strong,
    .dba-current-import-metric.is-add strong { color: var(--sev-ok); }
    .dba-current-import-metric.is-remove strong { color: var(--royal); }
    .dba-current-import-metric.is-warning strong { color: var(--sev-warning); }

    .dba-current-import-programme-status {
      margin-top: 0.7rem;
      padding: 0.65rem 0.75rem;
      border-inline-start: 3px solid var(--teal);
      border-radius: var(--radius-sm);
      color: var(--t2);
      background: color-mix(in srgb, var(--teal) 5%, var(--card));
      font-size: var(--text-xs);
      line-height: 1.55;
    }
    .dba-current-import-table-head { margin-bottom: 0.45rem; }
    .dba-current-import-table-head strong { color: var(--t2); font-size: var(--text-xs); }
    .dba-current-import-table-head span { color: var(--t3); font-size: var(--text-xs); }
    .dba-current-import-table-wrap {
      max-height: 340px;
      border: 1px solid var(--line);
      border-radius: var(--radius);
    }
    .dba-current-import-table { color: var(--t2); font-size: var(--text-xs); }
    .dba-current-import-table thead th {
      position: sticky;
      z-index: 1;
      top: 0;
      border-color: var(--line);
      color: var(--t3);
      background: var(--card);
      font-size: var(--text-micro);
      white-space: nowrap;
    }
    .dba-current-import-table td { border-color: var(--line); vertical-align: middle; }
    .dba-current-import-table td:first-child small {
      display: block;
      max-width: 15rem;
      overflow: hidden;
      margin-top: 0.08rem;
      color: var(--t3);
      font-size: var(--text-micro);
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .dba-programme-unassigned { color: var(--sev-warning); font-size: var(--text-micro); font-weight: 700; }
    .dba-assignment-source {
      display: inline-flex;
      padding: 0.16rem 0.4rem;
      border: 1px solid var(--line);
      border-radius: var(--radius-pill);
      color: var(--t3);
      background: var(--glass-bg-data);
      font-size: var(--text-micro);
      font-weight: 700;
      white-space: nowrap;
    }
    .dba-assignment-source.is-csv { border-color: var(--teal-border); color: var(--text-brand); }
    .dba-assignment-source.is-default { border-color: color-mix(in srgb, var(--royal) 28%, var(--line)); color: var(--royal); }
    .dba-assignment-source.is-preserved { border-color: var(--line); color: var(--t2); }
    .dba-assignment-source.is-mixed { border-color: color-mix(in srgb, var(--warning) 35%, var(--line)); color: var(--sev-warning); }
    .dba-assignment-source.is-unassigned { border-color: color-mix(in srgb, var(--warning) 35%, var(--line)); color: var(--sev-warning); }

    .dba-current-import-confirm {
      padding: 0.9rem 1rem;
      border: 1px solid var(--teal-border);
      border-radius: var(--radius);
      background: color-mix(in srgb, var(--teal) 4%, var(--card));
    }
    .dba-current-import-confirm .btn { flex: 0 0 auto; }

    /* Step flow indicator (for term sections) */
    .dba-steps {
      display:      flex;
      align-items:  center;
      gap:          0.5rem;
      margin-bottom: 1rem;
      font-size:    var(--text-sm);
    }

    .dba-step {
      display:      flex;
      align-items:  center;
      gap:          0.35rem;
      padding:      0.3rem 0.65rem;
      border-radius: var(--radius-pill);
      font-weight:  600;
      color:        var(--muted);
      background:   #f1f5f9;
      border:       1px solid var(--line);
    }

    .dba-step.active {
      color:      var(--brand-dark);
      background: var(--brand-soft);
      border-color: #a8e6d4;
    }

    .dba-step.done {
      color:      var(--sev-ok);
      background: #f0fdf4;
      border-color: #bbf7d0;
    }

    .dba-step-arrow { color: var(--muted); font-size: var(--text-micro); }

    /* Double-confirm delete pattern */
    .dba-delete-confirm {
      background: #fff5f5 !important; color: var(--danger) !important;
      border: 1px solid var(--pl-conflict-cell) !important;
      animation: dba-pulse 0.5s var(--ease);
    }
    @keyframes dba-pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }
    .dba-confirm-text { font-size: var(--text-xs); font-weight: 700; }

    /* Mobile: single-row scrollable strip */
    @media (max-width: 768px) {
      .dba-nav {
        flex-wrap:  nowrap;
        overflow-x: auto;
        scrollbar-width: thin;
        padding-bottom: 0.35rem;
      }
      .dba-nav-item {
        flex-shrink: 0;
      }
      /* it stays: on a phone, too, the label is the only cue that tells a
         harmless operation from a destructive one (see the note on the strip) */
      .dba-risk-badge { padding: 1px 6px; }
      .dba-nav-name  { font-size: var(--text-xs); }
      .dba-snapshot-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .dba-snapshot-preserved ul { grid-template-columns: 1fr; }
      .dba-snapshot-actions { align-items: stretch; flex-direction: column; }
      .dba-snapshot-actions .btn { width: 100%; }
      .dba-current-import-route,
      .dba-current-import-actions,
      .dba-current-import-confirm { align-items: stretch; flex-direction: column; }
      .dba-current-import-route .btn,
      .dba-current-import-actions .btn,
      .dba-current-import-confirm .btn { width: 100%; }
      .dba-current-import-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    }

    /* ═══════════════════════════════════════════════════════════
       DARK MODE — Deep Navy overrides
       Selector: html[data-theme="dark"]
       ═══════════════════════════════════════════════════════════ */

    /* Nav items — background and hover states */
    html[data-theme="dark"] .dba-nav-item:hover {
      background: rgba(255,255,255,0.04);
      border-color: rgba(255,255,255,0.08);
    }
    html[data-theme="dark"] .dba-nav-item.active {
      background: rgba(255,255,255,0.04);
      border-color: var(--teal);
    }
    html[data-theme="dark"] .dba-nav-item.danger-item.active {
      background: rgba(220,53,69,0.08);
      border-color: var(--danger);
      box-shadow: 0 0 0 3px rgba(224,52,52,0.12), var(--shadow-card);
    }

    /* Icon backgrounds */
    html[data-theme="dark"] .icon-safe {
      background: rgba(34,197,94,0.1);
      color: #4ade80;
    }
    html[data-theme="dark"] .icon-danger {
      background: rgba(220,38,38,0.1);
      color: #f87171;
    }
    html[data-theme="dark"] .icon-warning {
      background: rgba(245,158,11,0.1);
      color: #fbbf24;
    }
    html[data-theme="dark"] .icon-system {
      background: rgba(14,165,233,0.1);
      color: #38bdf8;
    }

    /* Risk badges */
    html[data-theme="dark"] .risk-danger {
      background: rgba(220,38,38,0.12);
      color: #fca5a5;
    }
    html[data-theme="dark"] .risk-warning {
      background: rgba(245,158,11,0.12);
      color: #fcd34d;
    }
    html[data-theme="dark"] .risk-safe {
      background: rgba(34,197,94,0.12);
      color: #86efac;
      border-color: rgba(34,197,94,0.25);
    }

    /* Danger zone panel header */
    html[data-theme="dark"] .dba-panel.danger-panel .dba-panel-header {
      background: rgba(220,53,69,0.08);
      border-color: rgba(220,53,69,0.2);
    }

    /* Output pre block */
    html[data-theme="dark"] .dba-output {
      background: rgba(255,255,255,0.04);
      color: #c0c4d4;
      border-color: rgba(10,142,110,0.15);
      box-shadow: inset 0 1px 3px rgba(0,0,0,0.15);
    }
    html[data-theme="dark"] .dba-output.has-error {
      color: #fca5a5;
      background: rgba(220,53,69,0.08);
      border-color: rgba(220,53,69,0.2);
    }
    html[data-theme="dark"] .dba-output.has-success {
      color: #6ee7b7;
      background: rgba(10,142,110,0.08);
      border-color: rgba(10,142,110,0.2);
    }

    html[data-theme="dark"] .dba-snapshot-table thead th { background: var(--card); }
    html[data-theme="dark"] .dba-snapshot-status.is-success,
    html[data-theme="dark"] .dba-snapshot-preserved {
      background: rgba(34,197,94,0.06);
    }
    html[data-theme="dark"] .dba-snapshot-status.is-error,
    html[data-theme="dark"] .dba-snapshot-actions {
      background: rgba(220,38,38,0.07);
    }
    html[data-theme="dark"] .dba-snapshot-note { background: rgba(245,158,11,0.07); }
    html[data-theme="dark"] .dba-current-import-route,
    html[data-theme="dark"] .dba-current-import-programme-status,
    html[data-theme="dark"] .dba-current-import-confirm { background: rgba(10,142,110,0.07); }
    html[data-theme="dark"] .dba-current-import-table thead th { background: var(--card); }

    /* Step indicators */
    html[data-theme="dark"] .dba-step {
      background: rgba(255,255,255,0.04);
      color: #a0a4b8;
      border-color: rgba(255,255,255,0.06);
    }
    html[data-theme="dark"] .dba-step.done {
      background: rgba(34,197,94,0.1);
      color: #86efac;
      border-color: rgba(34,197,94,0.25);
    }

    /* Double-confirm delete */
    html[data-theme="dark"] .dba-delete-confirm {
      background: rgba(220,53,69,0.12) !important;
      color: #f87171 !important;
      border-color: rgba(220,53,69,0.25) !important;
    }

    /* Panel header border */
    /* Sections */
    /* Nav bar border */
    html[data-theme="dark"] .dba-nav {
      border-bottom-color: rgba(255,255,255,0.08);
    }

    /* Nav item borders */
    /* Flat inputs inside oracle preview table */
    #oTableBody .form-control,
    #oTableBody .form-select,
    #oTableBody .form-control-sm,
    #oTableBody .form-select-sm {
      border-radius: 2px !important;
      padding: 0.25rem 0.4rem !important;
    }

/* ============================================================
   AUDIT EXPLORER — feature-specific styles
   ------------------------------------------------------------
   Moved out of core/templates/core/audit_explorer.html.
   ============================================================ */

/* Page-specific: audit table — neumorphic style */
    .audit-table { border-collapse: collapse; width: 100%; font-size: var(--text-xs); }
    .audit-table th, .audit-table td {
      border-bottom: var(--border-subtle);
      padding: 0.55rem 0.75rem;
    }
    .audit-table th {
      /* Composited over --bg, as the other table headers are: the wrapper's
         card is gone, so a translucent white tint would read as the only white
         band on the sheet. This header is not sticky, so the fill is about
         appearance rather than protecting the rows. */
      background: linear-gradient(var(--glass-bg-data), var(--glass-bg-data)), var(--bg);
      backdrop-filter: none;
      -webkit-backdrop-filter: none;
      font-family: var(--font-mono); font-size: var(--text-micro);
      text-transform: uppercase; letter-spacing: 0.06em;
      color: var(--t3); font-weight: 700; white-space: nowrap;
      user-select: none; text-align: start;
      /* the label sits in the middle of its band, not on its top edge */
      vertical-align: middle;
    }
    .audit-table td {
      background: transparent;
      transition: background 0.1s var(--ease);
      vertical-align: top;
    }
    /* Issue #3 fix — row hover more visible */
    .audit-table tbody tr:hover td { background: color-mix(in srgb, var(--teal) 7%, transparent); }
    .audit-table tbody tr:focus-within td { background: color-mix(in srgb, var(--teal) 4%, transparent); }
    .audit-status-success { color: var(--pl-ok-text); font-weight: 700; }
    .audit-status-error   { color: var(--pl-danger-text); font-weight: 700; }
    .audit-status-allow   { color: var(--pl-ok-text); font-weight: 600; }
    .audit-status-deny    { color: var(--pl-warn-text); font-weight: 700; }
    .audit-status-critical { color: #991b1b; font-weight: 700; }
    .audit-hash { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--t4); letter-spacing: 0.02em; }
    .audit-id { font-family: var(--font-mono); font-weight: 700; color: var(--text-brand); font-size: var(--text-xs); }
    .audit-ts { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--t3); white-space: nowrap; }
    .audit-endpoint { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--t2); }
    /* This bar's neumorphic pair is written out here rather than taken from
       --shadow-neu, so retiring the tokens never reached it. Same treatment as
       every other filter bar: a ruled band, opaque because it sits above a
       scrolling table. */
    .audit-filter-row {
      display: flex; gap: 0.5rem; flex-wrap: wrap;
      margin-bottom: 1rem; align-items: flex-end;
      padding: 0.75rem 0;
      background: var(--bg);
      backdrop-filter: none;
      -webkit-backdrop-filter: none;
      border: none; border-block-end: 1px solid var(--rule); border-radius: 0;
      box-shadow: none;
    }
    .audit-filter-row .form-control,
    .audit-filter-row .form-select { max-width: 180px; }
    /* One 36px control height: the date fields were 39px, the text fields 37px
       and Apply 30px, so the LIMIT row and the FROM / TO labels sat 2-9px apart. */
    .audit-filter-row .form-control,
    .audit-filter-row .form-select,
    .audit-filter-row .btn { box-sizing: border-box; height: 36px; min-height: 36px; }
    .audit-filter-row #audit-f-limit { width: 96px !important; }
    /* .audit-table-wrap is declared TWICE. This one is later with the same
       specificity, so it wins, and converting only the earlier rule left the
       audit table rendering as the old neumorphic card while the diff claimed
       otherwise. Both now say the same thing. */
    .audit-table-wrap {
      background: none;
      backdrop-filter: none;
      -webkit-backdrop-filter: none;
      border: none; border-block-end: 1px solid var(--rule); border-radius: 0;
      overflow-x: auto; overflow-y: auto;
      max-height: 520px;
      -webkit-overflow-scrolling: touch;
      box-shadow: none;
      scrollbar-width: thin;
      scrollbar-color: var(--line-strong) transparent;
    }
    /* Record count summary */
    .audit-count {
      font-family: var(--font-mono); font-size: var(--text-sm);
      color: var(--t3); font-weight: 600;
    }
    .audit-count strong { color: var(--text-brand); }

    /* -- AE-02: Hash chain info tooltip icon -- */
    .hash-chain-info {
      display: inline-flex; align-items: center; justify-content: center;
      margin-inline-start: 0.35rem; cursor: help;
      text-decoration: none; border-bottom: none;
      color: inherit; opacity: 0.7; vertical-align: middle;
      border-radius: 50%;
    }
    .hash-chain-info:hover, .hash-chain-info:focus-visible {
      opacity: 1;
    }
    .hash-chain-info:focus-visible {
      outline: 2px solid var(--teal); outline-offset: 2px;
    }
    .hash-chain-info-icon { display: block; }

    /* -- AE-04: Truncated cell tooltip for Endpoint / resource columns -- */
    .audit-cell-truncate {
      max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }

    /* -- Issue #5: Visible filter labels -- */
    .audit-filter-group { display: flex; flex-direction: column; gap: 0.2rem; }
    .audit-filter-label {
      font-size: var(--text-micro); font-weight: 700; text-transform: uppercase;
      letter-spacing: 0.04em; color: var(--t3); font-family: var(--font-mono);
    }

    /* -- Issue #5: Export CSV button styling -- */
    .btn-export {
      display: inline-flex; align-items: center; gap: 0.4rem;
      padding: 0.35rem 1rem; border-radius: var(--radius-lg);
      font-size: var(--text-sm); font-weight: 600;
      background: var(--glass-bg); color: var(--text-brand);
      text-decoration: none;
      box-shadow: var(--shadow-neu-sm);
      transition: all 0.15s;
    }
    .btn-export:hover { color: var(--text-brand); box-shadow: inset 0 0 0 1px var(--teal); }

    /* -- Issue #19: Color-only status indicators — icon prefixes -- */
    .audit-status-icon { display: inline-flex; align-items: center; gap: 0.25rem; }
    .audit-status-icon::before { font-size: max(var(--fs-floor), 0.7rem); line-height: 1; }
    .audit-status-icon.audit-status-success::before,
    .audit-status-icon.audit-status-allow::before { content: '\2713'; }
    .audit-status-icon.audit-status-error::before,
    .audit-status-icon.audit-status-critical::before { content: '\26A0'; }
    .audit-status-icon.audit-status-deny::before { content: '\2715'; }

    /* -- Pagination controls -- */
    .audit-pagination {
      display: flex; align-items: center; justify-content: space-between;
      gap: 1rem; flex-wrap: wrap; padding: 0.75rem 0; margin-top: 0.75rem;
      background: none; backdrop-filter: none;
      -webkit-backdrop-filter: none;
      border-block-start: 1px solid var(--rule); border-radius: 0;
      box-shadow: none;
      font-size: var(--text-sm); color: var(--t3);
    }
    .audit-page-nav { display: flex; align-items: center; gap: 0.35rem; }
    .audit-page-btn {
      width: 32px; height: 32px; border-radius: var(--radius-sm); border: none;
      background: var(--btn-neutral-bg); color: var(--t3);
      font-size: var(--text-md); font-weight: 700; cursor: pointer;
      box-shadow: inset 0 0 0 1px var(--btn-neutral-border);
      transition: all 0.15s;
      display: flex; align-items: center; justify-content: center;
    }
    .audit-page-btn:hover:not(:disabled) { color: var(--text-brand); background: rgba(17,17,68,0.11); box-shadow: inset 0 0 0 1px var(--control-edge); }
    .audit-page-btn:disabled { opacity: 0.6; cursor: not-allowed; }
    .audit-page-btn:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
    .audit-page-current { font-weight: 600; font-family: var(--font-mono); font-size: var(--text-sm); }
    .audit-page-info { font-family: var(--font-mono); font-size: var(--text-sm); }
    .audit-page-info strong { color: var(--text-brand); }
    .audit-page-size { display: flex; align-items: center; gap: 0.5rem; font-size: var(--text-sm); }

    /* -- View toggle (table / timeline) -- */
    .audit-view-toggle {
      display: flex; gap: 0; border-radius: var(--radius-sm); overflow: hidden; width: fit-content;
      box-shadow: none;
    }
    .audit-view-btn {
      padding: 0.4rem 1.2rem; border: none; background: var(--btn-neutral-bg);
      box-shadow: inset 0 0 0 1px var(--btn-neutral-border);
      font-size: var(--text-sm); font-weight: 700; color: var(--t3); cursor: pointer;
      transition: all 0.15s; font-family: var(--font-mono);
      text-transform: uppercase; letter-spacing: 0.04em;
    }
    .audit-view-btn:focus-visible { outline: 2px solid var(--teal); outline-offset: -2px; }
    .audit-view-btn.active { background: var(--btn-primary-bg); color: var(--btn-primary-ink); box-shadow: none; }

    /* -- Timeline view -- */
    .audit-timeline { max-height: 600px; overflow-y: auto; padding: 1rem; }
    .atl-day { font-family: var(--font-body); font-weight: 700; font-size: var(--text-md); color: var(--navy); margin-bottom: 0.75rem; margin-top: 1.25rem; }
    .atl-day:first-child { margin-top: 0; }
    .atl-item {
      display: flex; gap: 1rem; padding: 0.75rem 0;
      border-left: 2px solid color-mix(in srgb, var(--teal) 15%, transparent);
      margin-left: 0.5rem; padding-left: 1rem; position: relative;
    }
    [dir="rtl"] .atl-item {
      border-left: none; border-right: 2px solid color-mix(in srgb, var(--teal) 15%, transparent);
      margin-left: 0; margin-right: 0.5rem; padding-left: 0; padding-right: 1rem;
    }
    .atl-item::before {
      content: ''; position: absolute; left: -5px; top: 1rem;
      width: 8px; height: 8px; border-radius: 50%; background: var(--teal);
      border: 2px solid #fff; box-shadow: 0 0 0 2px color-mix(in srgb, var(--teal) 15%, transparent);
    }
    [dir="rtl"] .atl-item::before { left: auto; right: -5px; }
    .atl-time { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--t4); white-space: nowrap; min-width: 70px; }
    .atl-content { flex: 1; }
    .atl-action { font-weight: 700; font-size: var(--text-base); color: var(--ink); text-transform: uppercase; letter-spacing: 0.02em; }
    .atl-detail { font-size: var(--text-sm); color: var(--t3); margin-top: 0.15rem; }
    .atl-status { display: inline-block; padding: 0.1rem 0.5rem; border-radius: var(--radius-xs); font-size: var(--text-micro); font-weight: 700; text-transform: uppercase; }
    .atl-status-success, .atl-status-allow { background: #dcfce7; color: #15803d; }
    .atl-status-error { background: #fee2e2; color: var(--pl-danger-text); }
    .atl-status-deny { background: #fff7ed; color: #9a3412; }
    .atl-status-critical { background: #fef2f2; color: #991b1b; }
    .atl-expand {
      font-size: var(--text-xs); color: var(--text-brand); cursor: pointer;
      text-decoration: none; margin-top: 0.25rem; display: inline-block;
      background: none; border: none; padding: 0; font-family: inherit;
    }
    .atl-expand:hover { text-decoration: underline; }
    .atl-expand:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
    .atl-extra { display: none; margin-top: 0.35rem; font-family: var(--font-mono); font-size: var(--text-xs); color: var(--t4); }
    .atl-extra.open { display: block; }

    /* Mobile filter details: collapsed on mobile, open on desktop */
    .audit-filter-details { border: none; }
    .audit-filter-details summary {
      display: none; /* hidden on desktop */
      cursor: pointer; font-weight: 600; font-size: var(--text-sm); color: var(--text-brand);
      padding: 0.5rem 0; list-style: none;
    }
    .audit-filter-details summary::-webkit-details-marker { display: none; }

    @media (max-width: 768px) {
      .audit-filter-details summary { display: block; }
      .audit-filter-row { flex-direction: column; align-items: stretch; }
      .audit-filter-row .form-control,
      .audit-filter-row .form-select { max-width: 100% !important; width: 100%; }
      .audit-filter-row .btn { width: 100%; }
      .audit-table { font-size: var(--text-xs); }
      .audit-table th, .audit-table td { padding: 0.4rem 0.5rem; }
      .audit-table-wrap { max-height: none; }
      .audit-pagination { flex-direction: column; align-items: stretch; text-align: center; }
      .audit-page-nav { justify-content: center; }
      .audit-page-size { justify-content: center; }
      .audit-page-info { text-align: center; }
      .audit-view-toggle { width: 100%; }
      .audit-view-btn { flex: 1; text-align: center; }
      /* Hide low-priority columns on mobile: Role, Reason, Error, Hash */
      .audit-table th:nth-child(4),  .audit-table td:nth-child(4),
      .audit-table th:nth-child(7),  .audit-table td:nth-child(7),
      .audit-table th:nth-child(9),  .audit-table td:nth-child(9),
      .audit-table th:nth-child(10), .audit-table td:nth-child(10) { display: none; }
    }

    /* ── Dark mode overrides (Deep Navy) ───────────────────── */
    html[data-theme="dark"] .audit-table th {
      background: rgba(255,255,255,0.04);
      color: #a0a4b8;
    }    html[data-theme="dark"] .audit-table tbody tr:hover td { background: rgba(10,142,110,0.10); }
    html[data-theme="dark"] .audit-table tbody tr:focus-within td { background: rgba(10,142,110,0.06); }

    html[data-theme="dark"] .audit-status-success { color: #2ec9a0; }
    html[data-theme="dark"] .audit-status-error   { color: #f06060; }
    html[data-theme="dark"] .audit-status-allow   { color: #2ec9a0; }
    html[data-theme="dark"] .audit-status-deny    { color: #f5a060; }
    html[data-theme="dark"] .audit-status-critical { color: #f06060; }/* These dark rules re-boxed the audit screen on top of the light conversion:
   a translucent fill plus a full 1px border, which with the new flush padding
   put the controls hard against the box edge. Dark is the same sheet now. The
   filter row keeps an OPAQUE fill because it can sit over a scrolling table. */
html[data-theme="dark"] .audit-filter-row {
  background: var(--bg);
  box-shadow: none;
  border: none;
  border-block-end: 1px solid var(--rule);
}
html[data-theme="dark"] .audit-table-wrap {
  background: none;
  box-shadow: none;
  border: none;
  border-block-end: 1px solid var(--rule);
}
html[data-theme="dark"] .audit-pagination {
  background: none;
  box-shadow: none;
  border: none;
  border-block-start: 1px solid var(--rule);
}
html[data-theme="dark"] .btn-export {
  background: rgba(255,255,255,0.04);
  box-shadow: inset 0 0 0 1px var(--btn-neutral-border);
  border: none;
}    /* `box-shadow: none` plus a 6%-alpha border left these at about 1.1:1 in
       dark — no boundary at rest, only on hover. */
    html[data-theme="dark"] .audit-page-btn {
      background: rgba(255,255,255,0.04);
      color: #a0a4b8;
      box-shadow: inset 0 0 0 1px var(--btn-neutral-border);
      border: none;
    }
    html[data-theme="dark"] .audit-page-btn:hover:not(:disabled) { color: var(--text-brand); background: rgba(255,255,255,0.10); box-shadow: inset 0 0 0 1px var(--control-edge); }

    html[data-theme="dark"] .audit-view-toggle { box-shadow: none; }
    html[data-theme="dark"] .audit-view-btn { color: #a0a4b8; }
    html[data-theme="dark"] .audit-view-btn.active { background: var(--btn-primary-bg); color: var(--btn-primary-ink); }    html[data-theme="dark"] .btn-export:hover { box-shadow: inset 0 0 0 1px var(--teal); background: rgba(255,255,255,0.10); }

    /* Timeline view dark overrides */
    html[data-theme="dark"] .atl-day { color: #e2e4ec; }
    html[data-theme="dark"] .atl-item { border-left-color: rgba(12,168,126,0.20); }
    html[data-theme="dark"] [dir="rtl"] .atl-item { border-right-color: rgba(12,168,126,0.20); }
    html[data-theme="dark"] .atl-item::before { border-color: #151826; }
    html[data-theme="dark"] .atl-action { color: #e2e4ec; }
    html[data-theme="dark"] .atl-detail { color: #c0c4d4; }
    html[data-theme="dark"] .atl-time { color: var(--t4); }
    html[data-theme="dark"] .atl-extra { color: var(--t4); }

    html[data-theme="dark"] .atl-status-success,
    html[data-theme="dark"] .atl-status-allow  { background: rgba(22,163,74,0.15); color: #4ade80; }
    html[data-theme="dark"] .atl-status-error   { background: rgba(185,28,28,0.15); color: #f87171; }
    html[data-theme="dark"] .atl-status-deny    { background: rgba(154,52,18,0.15); color: #fb923c; }
    html[data-theme="dark"] .atl-status-critical { background: rgba(153,27,27,0.15); color: #f87171; }

/* ============================================================
   SECTION PLANNING — feature-specific styles
   ------------------------------------------------------------
   Moved out of core/templates/core/section_planning.html.
   ============================================================ */
    .sp-caps { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 10px 16px; border-radius: var(--radius); background: color-mix(in srgb, var(--teal) 3%, transparent); border: 1px dashed color-mix(in srgb, var(--teal) 20%, transparent); margin-bottom: 4px; }
    /* an upper-cased code field: its placeholder is a sentence, not a code */
    .text-caps::placeholder { text-transform: none; letter-spacing: normal; }
    .sp-caps-lbl { font-size: var(--text-micro); color: var(--t3); text-transform: uppercase; font-family: var(--font-mono); letter-spacing: 0.04em; font-weight: 700; margin-bottom: 2px; }
    .sp-cap-grp { display: flex; flex-direction: column; min-width: 100px; }
    .sp-cap-grp input { width: 80px; text-align: center; }
    .sp-caps-info { font-size: var(--text-micro); color: var(--t3); align-self: center; margin-inline-start: auto; }
    /* a disclosure, told by its chevron: not an underlined brand link running
       through an emoji (the third label's drew as a missing-glyph box) */
    .sp-toggle-caps { display: inline-flex; align-items: center; gap: .4rem; font-size: var(--text-sm); color: var(--t1); cursor: pointer; background: none; border: none; font-weight: 600; padding: 2px 0; text-decoration: none; }
    .sp-toggle-caps:hover { color: var(--text-brand); }

    /* Scope fields: each as wide as its value, never the 80px compact cap.
       Widths are in ch, so a wider font (Arabic, a CI machine's fonts)
       widens the field with it. Year holds 4 digits, Semester 1, Program a
       few codes and grows into spare room. */
    .sp-page .sp-fb-field { flex: 0 0 auto; max-width: none; }
    .sp-page .sp-fb-field .fb-lbl { flex: none; white-space: nowrap; }
    .sp-page .sp-fb-input { flex: 0 0 auto; min-width: 0; font-variant-numeric: tabular-nums; }
    .sp-page .sp-fb-year { width: 6ch; }
    .sp-page .sp-fb-term { width: 3ch; }
    .sp-page .sp-fb-grow { flex: 1 1 auto; max-width: 26rem; }
    .sp-page .sp-fb-codes { flex: 1 1 auto; width: 15ch; }
    .sp-page .sp-dept-filter { gap: 8px; }
    .sp-page .sp-dept-filter-input { width: calc(22ch + 2.5rem); }
    /* The capsule is the field: a keyboard user sees a full-strength ring. */
    .sp-page .fb-search:focus-within { box-shadow: var(--shadow-neu-inset), 0 0 0 2px var(--teal); }
    /* Dark mode's shared field glow is a 20% ring set with !important; the
       page's full-strength ring has to win there too (4.6:1 on Deep Navy). */
    html[data-theme="dark"] .sp-page .fb-search:focus-within { box-shadow: inset 0 1px 3px rgba(0,0,0,0.2), 0 0 0 2px var(--teal) !important; }

    /* Section: the plan's one section, M or F. A capsule like the scope
       fields holding two neumorphic chips over native radios (one Tab stop;
       the arrows move the choice). The chosen chip is raised, inked and has
       a filled dot, so the choice never rests on colour alone; the focused
       chip has the fields' full-strength teal ring. Logical properties only,
       so Arabic mirrors it. */
    /* The capsule's only boundary was the dished inset, and it sat at 14px
       beside .fb-search capsules now at 7px in the same bar. */
    .sp-page .sp-seg-group { display: inline-flex; align-items: center; flex: 0 0 auto; gap: 3px; padding-block: 3px; padding-inline: 1rem 3px; border-radius: var(--radius-sm); box-shadow: inset 0 0 0 1px var(--control-edge); }
    .sp-page .sp-seg-group .fb-lbl { flex: none; white-space: nowrap; margin-inline-end: 3px; }
    .sp-page .sp-seg { position: relative; display: inline-flex; align-items: center; gap: 5px; padding: .38rem .55rem; border-radius: var(--radius); color: var(--t3); font-size: var(--text-base); font-weight: 600; white-space: nowrap; cursor: pointer; user-select: none; transition: box-shadow .18s var(--ease), color .18s var(--ease), background-color .18s var(--ease); }
    .sp-page .sp-seg:hover { color: var(--t1); }
    /* The radio covers its chip, unseen: a click anywhere on the chip is the radio's own. */
    .sp-page .sp-seg input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
    .sp-page .sp-seg-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--t4); }
    /* Generate and Reset: one unit at the end of the bar, wrapping together. */
    .sp-page .sp-fb-actions { display: flex; align-items: center; gap: 10px; flex: none; margin-inline-start: auto; }
    .sp-page .sp-seg:has(input:checked) { background: var(--card); color: var(--brand-dark); font-weight: 700; box-shadow: var(--shadow-neu-sm); }
    .sp-page .sp-seg:has(input:checked) .sp-seg-dot { border-color: var(--teal); background: var(--teal); box-shadow: inset 0 0 0 2px var(--card); }
    /* Drawn on the chip's own edge (inset): it stays inside the capsule and
       clear of the "Section" / "الشطر" label, whose Arabic tail overhangs its box. */
    .sp-page .sp-seg:has(input:focus) { outline: 2px solid var(--teal); outline-offset: -2px; }
    /* Generate with no section chosen: the capsule and the words under the bar say so. */
    .sp-page .sp-seg-group[aria-invalid="true"] { box-shadow: var(--shadow-neu-inset), 0 0 0 2px var(--danger); }
    /* Windows High Contrast (forced colours) drops backgrounds and shadows and
       the native radio is transparent: the chosen chip keeps a filled
       Highlight dot and a Highlight edge, and the error an outline. */
    @media (forced-colors: active) {
      .sp-page .sp-seg:has(input:checked) { outline: 1px solid Highlight; outline-offset: -1px; }
      .sp-page .sp-seg:has(input:checked) .sp-seg-dot { forced-color-adjust: none; background: Highlight; border-color: Highlight; box-shadow: inset 0 0 0 2px Canvas; }
      .sp-page .sp-seg:has(input:focus) { outline: 2px solid CanvasText; outline-offset: -2px; }
      .sp-page .sp-seg-group[aria-invalid="true"] { outline: 2px solid CanvasText; outline-offset: 1px; }
    }
    .sp-page .sp-section-msg { margin: 8px 0 0; font-size: var(--text-base); font-weight: 600; color: var(--danger); }
    .sp-page .sp-section-msg:empty { margin: 0; }
    /* What the result on screen is for: "AI · 1448 T1 · Female (F)". */
    .sp-page .sp-results-scope { margin: 0 0 10px; font-size: var(--text-md); font-weight: 700; color: var(--navy); }

    /* KPI cards */
    .sp-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 14px; }
    .sp-mc { padding: .65rem .85rem; }
    .sp-mc .k { font-size: var(--text-micro); color: var(--t3); text-transform: uppercase; font-family: var(--font-mono); letter-spacing: 0.06em; font-weight: 700; }
    .sp-mc .v { font-weight: 700; font-family: var(--font-serif); font-size: var(--text-xl); color: var(--text-brand); }
    .sp-mc.mc-navy .v { color: var(--navy); }
    /* The hero tile's teal marker. It survived on the light sheet at (0,2,0),
       but dark's (0,2,1) `border-color: var(--rule)` greyed it out, so the one
       tile meant to stand out stopped doing so in dark only. Naming the edge
       explicitly keeps it teal in both themes. */
    .sp-mc.mc-hero { border-inline-start: 3px solid var(--teal); }
    html[data-theme="dark"] .sp-mc.mc-hero { border-inline-start-color: var(--teal); }

    /* Progress bar */
    .sp-progress { height: 3px; border-radius: 2px; background: var(--t5); overflow: hidden; margin-bottom: 10px; }
    .sp-progress-bar { height: 100%; background: var(--teal); width: 0%; transition: width 0.3s var(--ease); }

    /* Status pills */
    .sp-pill { display: inline-block; padding: 1px 8px; border-radius: var(--radius); font-size: var(--text-micro); font-weight: 700; text-transform: capitalize; }
    .sp-pill-full { background: color-mix(in srgb, var(--teal) 12%, transparent); color: var(--brand-dark); }
    .sp-pill-under { background: rgba(192,48,48,0.10); color: var(--danger); }
    .sp-pill-ext { background: rgba(100,120,140,0.10); color: var(--t4); font-size: var(--text-micro); font-weight: 600; }

    /* Fill bar */
    .sp-fill-wrap { width: 100%; height: 6px; border-radius: 3px; background: var(--t5); overflow: hidden; }
    .sp-fill { height: 100%; border-radius: 3px; transition: width 0.3s var(--ease); }
    .sp-fill-cell { min-width: 80px; }
    .sp-fill-hi { background: var(--teal); }
    .sp-fill-md { background: var(--warning); }
    .sp-fill-lo { background: var(--danger); }

    /* Department summary */
    /* Department summary: one table, our departments then the service
       departments, a subtotal each, and a total row equal to the KPIs.
       Numbers end-aligned in tabular figures; it scrolls in its own box
       if a phone is narrower than its seven columns. Scoped to .sp-page so
       they outrank the global dark table rules (html[data-theme] table td,
       table th), which would otherwise fade the row lines, the teal total
       rule and the "Total" label under every column but the first. */
    .sp-sum-scroll { overflow-x: auto; }
    .sp-page .sp-sum-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
    .sp-page .sp-sum-table th, .sp-page .sp-sum-table td { padding: 5px 8px; border-bottom: 1px solid var(--t5); text-align: end; }
    .sp-page .sp-sum-table thead th { font-size: var(--text-xs); font-weight: 700; color: var(--t3); vertical-align: bottom; }
    .sp-page .sp-sum-table thead th:first-child, .sp-page .sp-sum-table th[scope="row"] { text-align: start; }
    .sp-page .sp-sum-table tbody th[scope="row"] { font-weight: 700; color: var(--navy); }
    .sp-page .sp-sum-table .sp-sum-group th { text-align: start; font-size: var(--text-xs); font-weight: 700; color: var(--t2); padding-top: 10px; background: color-mix(in srgb, var(--teal) 6%, transparent); }
    .sp-page .sp-sum-table .sp-sum-sub th, .sp-page .sp-sum-table .sp-sum-sub td { color: var(--t2); font-weight: 600; border-bottom-style: dashed; }
    .sp-page .sp-sum-table [data-col="sections"] { font-weight: 700; }
    .sp-page .sp-sum-table tfoot th, .sp-page .sp-sum-table tfoot td { font-weight: 700; color: var(--t1); border-top: 2px solid var(--teal); border-bottom: 0; }

    /* Export bar */
    .sp-export-bar { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 8px 0; }

    /* Alert */
    .sp-alert { padding: 8px 14px; border-radius: var(--radius); font-size: var(--text-sm); margin-bottom: 10px; }
    .sp-alert-ok { background: var(--teal-dim); color: var(--brand-dark); border: 1px solid var(--teal-border); }
    .sp-alert-err { background: rgba(192,48,48,0.08); color: var(--danger); border: 1px solid rgba(192,48,48,0.15); }

    /* Advanced per-course table */
    .sp-adv-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
    .sp-adv-search { width: 24ch; min-width: 220px; }
    .sp-adv-count { font-size: var(--text-micro); color: var(--t3); margin-inline-start: auto; }
    .sp-adv-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
    .sp-adv-table th { font-size: var(--text-micro); text-transform: uppercase; letter-spacing: .04em; color: var(--t3); font-weight: 700; font-family: var(--font-mono); padding: 5px 8px; border-bottom: 1.5px solid var(--t5); text-align: start; white-space: nowrap; }
    .sp-adv-table td { padding: 4px 8px; border-bottom: 1px solid var(--t5); vertical-align: middle; }
    .sp-adv-table tr:hover { background: color-mix(in srgb, var(--teal) 3%, transparent); }
    .sp-adv-table .adv-input { width: 60px; text-align: center; padding: 2px 4px; font-size: var(--text-sm); }
    .sp-adv-table .adv-input:not(:placeholder-shown) { border-color: var(--teal); background: color-mix(in srgb, var(--teal) 4%, transparent); font-weight: 700; }
    .sp-adv-table .adv-default { color: var(--t3); font-size: var(--text-xs); }
    .sp-adv-wrap { max-height: 400px; overflow-y: auto; border: var(--border-subtle); border-radius: var(--radius); padding: 0; }
    .sp-adv-reset { font-size: var(--text-xs); color: var(--t3); cursor: pointer; background: none; border: 1px solid var(--t4); border-radius: var(--radius-xs); padding: 2px 8px; }
    .sp-adv-reset:hover { color: var(--danger); border-color: var(--danger); }
    .sp-adv-badge { display: inline-block; padding: 0 6px; border-radius: var(--radius-sm); font-size: var(--text-micro); font-weight: 700; background: var(--btn-primary-bg); color: var(--btn-primary-ink); margin-inline-start: 4px; }
    /* Drafts: a limit edit is marked until it is saved or discarded (tokens only, so dark mode follows). */
    .sp-alert-warn { background: color-mix(in srgb, var(--warning) 10%, transparent); color: var(--sev-warning); border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent); }
    .sp-adv-drafts { font-size: var(--text-xs); color: var(--t3); }
    .sp-adv-note { margin: 0 0 8px; }
    .sp-adv-reset:disabled { opacity: .62; cursor: default; }
    /* Save stays focusable when it cannot run (aria-disabled): the status line says why. */
    #spAdvSaveDb[aria-disabled="true"] { opacity: .5; cursor: default; }
    .sp-adv-table tr.sp-adv-draft td { background: color-mix(in srgb, var(--warning) 8%, transparent); }
    .sp-adv-table tr.sp-adv-draft .adv-input { border-color: var(--warning); }
    .sp-adv-table tr.sp-adv-invalid .adv-input { border-color: var(--danger); }
    .sp-adv-state { display: block; font-size: var(--text-micro); font-weight: 700; color: var(--sev-warning); min-height: 0; }
    .sp-adv-table tr.sp-adv-invalid .sp-adv-state { color: var(--danger); }
    .sp-adv-all { display: inline-flex; align-items: center; gap: 4px; font-size: var(--text-xs); color: var(--t3); cursor: pointer; white-space: nowrap; }
    .sp-limit-review { margin-top: 8px; }
    /* A line under a cell's value (where a limit comes from) */
    .sp-cell-sub { font-size: var(--text-xs); color: var(--t3); font-variant-numeric: tabular-nums; white-space: nowrap; }
    /* A resolved elective names the slot it fills */
    .sp-slot { font-size: var(--text-xs); color: var(--t3); white-space: nowrap; }
    .sp-adv-table tr.sp-adv-sub td { font-size: var(--text-xs); padding-inline-start: 24px; color: var(--t2); border-bottom-style: dashed; }

    /* Multi-program headings */
    .sp-prog-heading { font-size: var(--text-md); font-weight: 700; color: var(--navy); padding: 10px 0 6px; margin-top: 18px; border-bottom: 2px solid var(--teal); display: flex; align-items: baseline; gap: 8px; }
    .sp-prog-heading:first-child { margin-top: 0; }
    .sp-prog-heading .sp-prog-count { font-size: var(--text-xs); font-weight: 600; color: var(--t3); font-family: var(--font-mono); }
    .sp-prog-toggle { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; width: 100%; padding: 0; border: 0; background: none; font: inherit; color: inherit; text-align: start; cursor: pointer; user-select: none; }
    .sp-prog-toggle:hover { opacity: .85; }
    /* Disclosure chevron: along the reading direction when closed (right in
       English, left in Arabic), down when open. */
    .sp-page .sp-chev { flex: none; display: inline-block; vertical-align: -1px; margin-inline-end: 4px; color: var(--t3); transition: transform .15s var(--ease); }
    html[dir="rtl"] .sp-page .sp-chev { transform: scaleX(-1); }
    html[dir] .sp-page [aria-expanded="true"] > .sp-chev { transform: rotate(90deg); }
    .sp-prog-block { margin-bottom: 20px; }
    .sp-prog-block .tbl-card { margin-bottom: 8px; }

    /* A results table is 11 columns: when wider than the pane it scrolls
       inside its own box, never the page. */
    .sp-page .sp-table-scroll { overflow-x: auto; }
    /* Its headers wrap between words with a narrower gutter: one-word
       numbers under two-word headers ("Course Name", "الحد الأقصى") must not
       make the table wider than the pane at 1440px in Arabic, in a wider font
       and with every programme's tags. */
    .sp-page .sp-plan-table thead th { white-space: normal; padding-inline: 8px; vertical-align: bottom; }
    /* The line above sets padding-inline wholesale and ties with
       `.tbl-card thead th[data-sort]`, winning on order -- so the sort arrow's
       gutter has to be restated at a specificity that beats it. */
    .sp-page .sp-plan-table thead th[data-sort] { padding-inline-end: 1.5rem; }
    /* When it does scroll sideways (769px and up), the course code stays in
       view. It is opaque only while the box is scrolled (the page script
       sets .sp-scrolled), so at rest it looks like every other column. */
    @media (min-width: 769px) {
      .sp-page .sp-plan-table > thead > tr > th:nth-child(3),
      .sp-page .sp-plan-table > tbody > tr > td:nth-child(3) { position: sticky; inset-inline-start: 0; z-index: 1; }
      .sp-page .sp-table-scroll.sp-scrolled .sp-plan-table > thead > tr > th:nth-child(3),
      .sp-page .sp-table-scroll.sp-scrolled .sp-plan-table > tbody > tr > td:nth-child(3) {
        background: var(--surface) !important;
        box-shadow: 1px 0 0 var(--t5);
      }
      html[dir="rtl"] .sp-page .sp-table-scroll.sp-scrolled .sp-plan-table > thead > tr > th:nth-child(3),
      html[dir="rtl"] .sp-page .sp-table-scroll.sp-scrolled .sp-plan-table > tbody > tr > td:nth-child(3) { box-shadow: -1px 0 0 var(--t5); }
    }

    /* Responsive */
    @media(max-width:768px) {
      .sp-kpi { grid-template-columns: repeat(2, 1fr); }
      .sp-caps { flex-direction: column; align-items: stretch; }
      .sp-cap-grp input { width: 100%; }
      .sp-adv-search { width: 100%; }

      /* A phone shows each course as a card with its numbers (the global
         rule that hides every column after the fourth is overridden for
         these tables): code and name, then demand | sections | max, then
         the fill bar across the card, then the status when there is one. */
      .sp-page .sp-plan-table.mobile-cards tbody td:not(.mc-hide) { display: flex; }
      .sp-page .sp-plan-table.mobile-cards tbody tr { grid-template-columns: repeat(3, minmax(0, 1fr)); }
      .sp-page .sp-plan-table.mobile-cards td.mc-primary { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; }
      .sp-page .sp-plan-table.mobile-cards td.mc-primary::before,
      .sp-page .sp-plan-table.mobile-cards td:not([data-label])::before { content: none; }
      .sp-page .sp-plan-table.mobile-cards td[colspan] { grid-column: 1 / -1; }
      .sp-page .sp-plan-table .sp-c-demand { order: 1; }
      .sp-page .sp-plan-table .sp-c-sections { order: 2; }
      .sp-page .sp-plan-table .sp-c-max { order: 3; }
      .sp-page .sp-plan-table .sp-c-fill { order: 4; min-width: 0; grid-column: 1 / -1; }
      .sp-page .sp-plan-table .sp-c-status { order: 5; grid-column: 1 / -1; align-items: flex-start; }
      .sp-page .sp-plan-table.mobile-cards tbody td.sp-c-status:empty { display: none; }
      .sp-page .sp-sum-table { font-size: var(--text-xs); }
      .sp-page .sp-sum-table th, .sp-page .sp-sum-table td { padding: 4px 5px; }
    }

    /* ═══════════════════════════════════════════════════════════
       DARK MODE — Deep Navy overrides
       html[data-theme="dark"]
       ═══════════════════════════════════════════════════════════ */
    /* .sp-panel / .sp-mc dark surface moved to V2 UNIFIED rule */
    html[data-theme="dark"] .sp-caps {
      background: rgba(10,142,110,0.06);
      border-color: rgba(10,142,110,0.15);
    }

    /* Status pills */
    html[data-theme="dark"] .sp-pill-full {
      background: rgba(12,168,126,0.15);
      color: #2ec9a0;
    }
    html[data-theme="dark"] .sp-pill-under {
      background: rgba(220,53,69,0.15);
      color: #f06060;
    }
    html[data-theme="dark"] .sp-pill-ext {
      background: rgba(255,255,255,0.06);
      color: #a0a4b8;
    }

    /* Fill bars: no dark overrides. --teal, --warning and --danger are
       already the Deep Navy theme's own, and an alpha tint on the dark track
       made the amber and red bars all but invisible. */
    /* Progress bar track */
    /* Alerts */
    html[data-theme="dark"] .sp-alert-ok {
      background: rgba(12,168,126,0.10);
      color: #2ec9a0;
      border-color: rgba(12,168,126,0.20);
    }
    html[data-theme="dark"] .sp-alert-err {
      background: rgba(220,53,69,0.10);
      color: #f06060;
      border-color: rgba(220,53,69,0.20);
    }

    /* Advanced table */
    html[data-theme="dark"] .sp-adv-table th {
      border-bottom-color: rgba(255,255,255,0.08);
    }    html[data-theme="dark"] .sp-adv-table tr:hover {
      background: rgba(12,168,126,0.06);
    }
    html[data-theme="dark"] .sp-adv-table .adv-input:not(:placeholder-shown) {
      border-color: rgba(12,168,126,0.4);
      background: rgba(12,168,126,0.08);
    }
    /* Multi-program headings */
    html[data-theme="dark"] .sp-prog-heading {
      color: #e2e4ec;
      border-bottom-color: rgba(12,168,126,0.35);
    }
    html[data-theme="dark"] .sp-prog-heading .sp-prog-count {
      color: #a0a4b8;
    }

    /* Reset button hover */
    html[data-theme="dark"] .sp-adv-reset {
      border-color: rgba(255,255,255,0.10);
    }
    html[data-theme="dark"] .sp-adv-reset:hover {
      color: #f06060;
      border-color: #f06060;
    }

/* ============================================================
   ADVISOR PORTFOLIO — feature-specific styles
   ------------------------------------------------------------
   Moved out of core/templates/core/advisor_portfolio.html.
   ============================================================ */

/* ═══════════════════════════════════════════════════════════
   ADVISOR PORTFOLIO — Page-specific styles
   ═══════════════════════════════════════════════════════════ */

/* ── Component basics: what the top section below styles in place ─── */
.ap-insights { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.ap-insight {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.3rem 0.65rem; border-radius: var(--radius-pill);
  font-size: var(--text-xs); font-weight: 700;
}
.ap-programs { display: flex; gap: 0.3rem; flex-wrap: wrap; align-items: center; }
/* no program on record */
.ap-programs-none { font-size: var(--text-xs); color: var(--t3); }
.ap-prog-pill {
  display: inline-flex; align-items: center;
  cursor: pointer;
  transition: background-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}
.ap-gpa-chart { display: flex; align-items: flex-end; }
.ap-gpa-chart.is-empty { align-items: center; justify-content: center; }
.ap-gpa-bar { flex: 1; transition: height 0.3s var(--ease); }
/* The alert tiles are buttons that open the list they count. */
.mc-drill { text-align: start; font: inherit; color: inherit; cursor: pointer; }
/* An alert tile at zero is not an alert. */
.ap-metrics .mc.is-zero .mc-val { color: var(--t3); }
.ap-metrics .mc.is-zero .mc-icon { color: var(--t3); }

/* ═══ Advisor Portfolio — top section ═══════════════════════════════════
   Three zones, each opened once and each named:
   (a) scope    — the advisor and program pickers sit level with the title,
                  the page's one sentence under both (no picker row);
   (b) overview — one band under a rule, in two named halves:
                  "Needs action" (the three alert tiles that filter the roster)
                  | "Cohort profile" (students, average GPA with its spread,
                  programs);
   (c) roster   — a stronger rule with more air above it, the "Student roster"
                  heading with the exports, the toolbar, then the table.
   Every selector is scoped to the portfolio (#ap*, .ap-*). Approved by the
   owner as a rendered mock-up (2026-11-28) and ported rule for rule. */

/* ── (a) Masthead ────────────────────────────────────────────────────── */
#main-content > .content-wrap:has(#apScope) { container: ap-page / inline-size; }

/* Title and scope on one line, the sentence under both: a grid, with the
   left column's box dissolved so the title and the sentence are its cells. */
#main-content > .content-wrap > .page-header:has(#apScope) {
  display: grid;
  /* the title keeps its width; the scope takes the rest and sits at its end */
  grid-template-columns: max-content minmax(0, 1fr);
  grid-template-areas: "title scope" "intro intro";
  align-items: center;
  gap: var(--space-2) var(--space-12);
}
.page-header:has(#apScope) > .page-header-left { display: contents; }
.page-header:has(#apScope) .page-header-module { grid-area: title; min-width: 0; }
.page-header:has(#apScope) .page-header-chips { grid-area: intro; }
.page-header:has(#apScope) > .page-header-right {
  grid-area: scope; min-width: 0; padding-top: 0;
  justify-content: flex-end;
}
.ap-intro { margin: 0; }
@media (min-width: 769px) {
  /* the sentence now closes the masthead; the band's rule follows it */
  #main-content > .content-wrap > .page-header:has(#apScope) { margin-bottom: var(--space-7) !important; }
}

#apScope {
  display: flex; align-items: center; justify-content: flex-end;
  flex-wrap: wrap; gap: var(--space-4);
  min-width: 0;
}
/* Each field names itself inside its capsule, set off by a hairline. */
#apScope .fb-lbl {
  display: inline-flex; align-items: center;
  padding-inline-end: var(--space-5);
  border-inline-end: 1px solid var(--rule);
  line-height: 1.2;
  font-size: var(--text-micro); font-weight: 700;
  letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--t3);
  cursor: pointer;
}
html[dir="rtl"] #apScope .fb-lbl { letter-spacing: 0; }
#apScope select { color: var(--t1); font-weight: 600; cursor: pointer; }
/* The advisor field is as wide as the advisor shown. A browser without
   field-sizing keeps the longest option's width, so the cap holds it to a
   header's worth and a long name ends in an ellipsis. */
#apScope #apAdvisorSelect {
  field-sizing: content;
  min-width: 12ch;
  max-width: min(100%, 26rem);
  text-overflow: ellipsis;
}

/* A narrow sheet: title, sentence, then the scope fields, in reading order. */
@container ap-page (max-width: 820px) {
  #main-content > .content-wrap > .page-header:has(#apScope) {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "title" "intro" "scope";
  }
  .page-header:has(#apScope) > .page-header-right { justify-content: flex-start; margin-top: var(--space-4); }
  #apScope { justify-content: flex-start; }
}

/* ── (b) Overview band ───────────────────────────────────────────────── */
#apMetricsWrap {
  --ap-cell-px: var(--space-6);
  container: ap-ov / inline-size;
  border-top: 1px solid var(--rule);
  padding-block: var(--space-6) var(--space-12);
}
#apMetricsWrap .ap-metrics {
  display: flex; align-items: stretch; flex-wrap: nowrap;
  gap: 0; margin: 0;
  /* the cells' padding hangs outside the sheet's edges, so the titles and the
     first label line up with the page title above and the toolbar below */
  margin-inline: calc(-1 * var(--ap-cell-px));
}
#apMetricsWrap .ap-ov-group {
  position: relative;
  display: flex; flex-direction: column;
  min-width: 0;
}
#apMetricsWrap .ap-ov-alerts { flex: 3 0 auto; }
#apMetricsWrap .ap-ov-profile { flex: 3 1 auto; }
/* The halves are told apart by their names and one hairline, not by boxes. */
#apMetricsWrap .ap-ov-group + .ap-ov-group {
  border-inline-start: 1px solid var(--rule);
  margin-inline-start: var(--ap-cell-px);
  padding-inline-start: var(--ap-cell-px);
}

/* One title style for the three zones' names: the body face, a step up. */
.ap-zone-title {
  margin: 0;
  font-family: var(--font-body); font-size: var(--text-md); font-weight: 700;
  line-height: 1.3; letter-spacing: -0.005em; color: var(--t0);
}
html[dir="rtl"] .ap-zone-title { letter-spacing: 0; }
#apMetricsWrap .ap-ov-head {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: var(--space-3) var(--space-8);
  min-height: 22px;
  padding-inline: var(--ap-cell-px);
  margin-bottom: var(--space-2);
}

#apMetricsWrap .ap-ov-cells { display: flex; align-items: stretch; min-width: 0; flex: 1 1 auto; }
/* Programs gives way first: an adviser with many programs has the pills wrap
   inside the cell (down to two pills' width) and the band keeps one row. */
#apMetricsWrap .ap-cell.ap-cell-programs { flex: 1 1 auto; min-width: 10rem; }
/* A sheet narrower than the band's one-row width (measured: 845px English,
   879px Arabic, with Programs at its 10rem floor): Programs takes a second
   line of its own half. */
@container ap-ov (max-width: 880px) {
  #apMetricsWrap .ap-ov-profile .ap-ov-cells { flex-wrap: wrap; }
  #apMetricsWrap .ap-cell.ap-cell-programs { flex: 1 0 100%; }
}

/* Every cell: a label, then its value, on one shared rhythm. */
#apMetricsWrap .ap-cell {
  flex: 1 1 auto; min-width: 0;
  padding: var(--space-4) var(--ap-cell-px) var(--space-3);
}
#apMetricsWrap .mc.ap-cell {
  min-width: 6.5rem; width: auto;
  border: 0; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: none; box-shadow: none;
}
#apMetricsWrap .ap-cell-gpa { flex: 1 0 auto; }
#apMetricsWrap .mc::before { content: none; }
#apMetricsWrap .mc:not(.mc-drill):hover { background: none; }

/* The alert tiles are buttons: a wash on hover, a tint and a status underline
   while the list below shows only their students. */
/* a button centres its content in the row's height; a tile reads top-down */
#apMetricsWrap .mc-drill {
  display: flex; flex-direction: column; justify-content: flex-start; align-items: stretch;
  transition: background-color .15s var(--ease), box-shadow .15s var(--ease);
}
#apMetricsWrap .mc-drill:hover { background: color-mix(in srgb, var(--mc-c) 7%, transparent); }
#apMetricsWrap .mc-drill.is-zero:hover { background: var(--pl-overlay-2); }
#apMetricsWrap .mc-drill.active {
  background: color-mix(in srgb, var(--mc-c) 10%, transparent);
  box-shadow: inset 0 -2px 0 var(--mc-c);
}
/* Keyboard focus is the system's own (global.css "*:focus-visible": a teal
   outline and a glow, both !important). A pressed tile that has focus keeps
   its status underline under that glow. */
#apMetricsWrap .mc-drill.active:focus-visible { box-shadow: 0 0 0 4px var(--brand-glow), inset 0 -2px 0 var(--mc-c) !important; }

/* Dark draws every .mc as a ruled tile and removes every .mc box-shadow, all
   with !important (global.css, "html[data-theme=dark] .mc"). The band's rule
   and hairline replace the per-tile rules; the drill tiles' wash, pressed
   underline and focus glow are restated here (that rule also takes the
   system focus glow off every dark .mc today, leaving the outline alone). */
html[data-theme="dark"] #apMetricsWrap .mc { border: 0 !important; background: none !important; box-shadow: none !important; }
html[data-theme="dark"] #apMetricsWrap .mc-drill:hover { background: color-mix(in srgb, var(--mc-c) 10%, transparent) !important; }
html[data-theme="dark"] #apMetricsWrap .mc-drill.is-zero:hover { background: var(--pl-overlay-2) !important; }
html[data-theme="dark"] #apMetricsWrap .mc-drill.active {
  background: color-mix(in srgb, var(--mc-c) 14%, transparent) !important;
  box-shadow: inset 0 -2px 0 var(--mc-c) !important;
}
html[data-theme="dark"] #apMetricsWrap .mc-drill:focus-visible { box-shadow: 0 0 0 4px var(--brand-glow) !important; }
html[data-theme="dark"] #apMetricsWrap .mc-drill.active:focus-visible { box-shadow: 0 0 0 4px var(--brand-glow), inset 0 -2px 0 var(--mc-c) !important; }
html[data-theme="dark"] #apMetricsWrap .mc-icon { box-shadow: none !important; }

#apMetricsWrap .mc-head,
#apMetricsWrap .ap-cell-head {
  display: flex; align-items: center;
  gap: var(--space-3); margin: 0 0 var(--space-3);
  min-height: 1.25rem;
}
#apMetricsWrap .mc-icon { width: auto; height: auto; border-radius: 0; background: none; }
#apMetricsWrap .mc-icon .i { width: 14px; height: 14px; }
#apMetricsWrap .ap-ov-profile .mc-icon { display: none; }
#apMetricsWrap .mc-lbl,
#apMetricsWrap .ap-cell-lbl {
  font-size: var(--text-micro); font-weight: 700;
  letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--t3); white-space: nowrap; line-height: 1.25;
}
html[dir="rtl"] #apMetricsWrap :is(.mc-lbl, .ap-cell-lbl) { letter-spacing: 0; }
#apMetricsWrap .mc-val {
  display: block;
  font-size: var(--text-display);
  line-height: 1;
  font-variant-numeric: lining-nums tabular-nums;
}

/* The one insight no tile states (often none): beside "Needs action". */
#apMetricsWrap .ap-insights {
  margin: 0; margin-inline-start: auto;
  margin-block: calc(-1 * var(--space-1));   /* it shares the title's line, never heightens it */
  min-width: 0; gap: var(--space-3);
}
#apMetricsWrap .ap-insights:empty { display: none; }
#apMetricsWrap .ap-insight {
  border: 0; border-radius: var(--radius-pill);
  padding: var(--space-1) var(--space-5);
  font-size: var(--text-xs); font-weight: 600;
  line-height: 1.4;   /* the chip fits the title's line: the band never grows by it */
}
#apMetricsWrap .ap-insight-warn { background: var(--sev-warning-bg); color: var(--sev-warning-ink); }
#apMetricsWrap .ap-insight-danger { background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); }
#apMetricsWrap .ap-insight-info { background: var(--brand-soft); color: var(--text-brand); }

/* Average GPA: the spread sits beside the numeral, its bars as tall as the
   numeral, its ranges under the bars. */
#apMetricsWrap .ap-gpa-row { display: flex; align-items: flex-start; gap: var(--space-8); }
#apMetricsWrap .ap-gpa-row > .mc-val { flex: none; }
#apMetricsWrap .ap-gpa { --ap-chart-w: 10rem; flex: 0 1 var(--ap-chart-w); min-width: 8rem; }
#apMetricsWrap .ap-gpa-chart {
  width: 100%; min-width: 0; height: 28px; gap: 3px;
  border-bottom: 1px solid var(--rule-strong);
}
#apMetricsWrap .ap-gpa-bar { min-width: 0; border-radius: 2px 2px 0 0; }
#apMetricsWrap .ap-gpa-bar-danger { background: var(--danger); }
/* amber, not --warning's dark gold (olive beside the teal); the 20% of
   --warning keeps its edge at 3:1 on the sheet */
#apMetricsWrap .ap-gpa-bar-warn { background: color-mix(in srgb, var(--amber) 80%, var(--warning)); }
/* a half-strength teal fill reads as the step below 3.5+; its teal edge
   carries the 3:1 the pale fill alone cannot */
#apMetricsWrap .ap-gpa-bar-ok {
  background: color-mix(in srgb, var(--teal) 38%, transparent);
  box-shadow: inset 0 0 0 1px var(--teal);
}
#apMetricsWrap .ap-gpa-bar-ok.is-zero { box-shadow: none; }
#apMetricsWrap .ap-gpa-bar-great { background: var(--teal); }
html[data-theme="dark"] #apMetricsWrap .ap-gpa-bar-ok {
  background: color-mix(in srgb, var(--teal) 60%, var(--t0));
  box-shadow: none;
}
#apMetricsWrap .ap-gpa-labels {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px;
  width: 100%; margin-top: var(--space-2);
  font-size: var(--text-micro); font-weight: 600; font-variant-numeric: tabular-nums;
  color: var(--t4); text-align: center; line-height: 1.2; white-space: nowrap;
}
#apMetricsWrap .ap-gpa-labels.d-none { display: none; }
/* No GPA yet: the same footprint as the chart and its ranges. */
#apMetricsWrap .ap-gpa-chart.is-empty {
  height: calc(28px + var(--space-2) + 1.2 * var(--text-micro));
  border: 1px dashed var(--rule-strong); border-radius: var(--radius-sm);
  padding-inline: var(--space-4);
  font-size: var(--text-xs); color: var(--t3); white-space: nowrap;
}

/* Programs: filters, in the capsules' language (a ring, no fill). */
#apMetricsWrap .ap-programs { flex: none; min-width: 0; flex-wrap: wrap; gap: var(--space-3); }
#apMetricsWrap .ap-prog-pill {
  min-height: var(--control-h-sm); padding: 0 var(--space-5); gap: var(--space-3);
  border: 0; border-radius: var(--control-radius);
  background: transparent; color: var(--t1);
  box-shadow: inset 0 0 0 1px var(--control-edge);
  font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 700;
  line-height: 1;
}
#apMetricsWrap .ap-prog-pill:hover { background: var(--pl-overlay-3); color: var(--t0); }
#apMetricsWrap .ap-prog-pill[aria-pressed="true"] {
  background: var(--brand-soft); color: var(--text-brand);
  box-shadow: inset 0 0 0 1px var(--teal);
}
#apMetricsWrap .ap-prog-pill .ap-prog-n {
  font-size: var(--text-micro); font-weight: 500; color: var(--t3);
}
#apMetricsWrap .ap-prog-pill[aria-pressed="true"] .ap-prog-n { color: var(--text-brand); }

/* Phones: the halves stack under their names, the cells on a three-column grid. */
@container ap-ov (max-width: 640px) {
  #apMetricsWrap .ap-metrics { flex-direction: column; }
  #apMetricsWrap .ap-ov-group + .ap-ov-group {
    border-inline-start: 0;
    margin-inline-start: 0;
    padding-inline-start: 0;
    margin-top: var(--space-6);
    padding-top: var(--space-8);
  }
  #apMetricsWrap .ap-ov-group + .ap-ov-group::before {
    content: ""; position: absolute; top: 0;
    inset-inline: var(--ap-cell-px);
    border-top: 1px solid var(--rule);
  }
  #apMetricsWrap .ap-ov-cells {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
  }
  #apMetricsWrap .ap-cell-gpa { grid-column: span 2; }
  #apMetricsWrap .ap-cell-programs { grid-column: 1 / -1; }
  #apMetricsWrap .mc.ap-cell { min-width: 0; display: flex; flex-direction: column; justify-content: flex-start; }
  /* an alert label may take two lines in a third of a phone: the numerals
     still share one line */
  #apMetricsWrap .ap-ov-alerts .mc.ap-cell { justify-content: space-between; }
  /* a third of a phone is a word's width: the label keeps it, the icon goes */
  #apMetricsWrap .mc-icon { display: none; }
  #apMetricsWrap .mc-lbl { white-space: normal; }
  #apMetricsWrap .ap-gpa-row { gap: var(--space-6); }
  #apMetricsWrap .ap-gpa { flex: 1 1 auto; max-width: 10rem; }
}
@media (max-width: 576px) {
  #apMetricsWrap { --ap-cell-px: var(--space-4); }
}
/* A phone's bar already ends in a rule: the band opens under it, not under a second one. */
@media (max-width: 768px) {
  #apMetricsWrap { border-top: 0; padding-top: 0; }
}
@media (max-width: 768px), (pointer: coarse) {
  #apMetricsWrap .ap-prog-pill { min-height: var(--control-h); }
}

/* ── (c) Roster: a stronger rule with more air above it, its heading, its actions ── */
.ap-roster-head {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: var(--space-4) var(--space-8);
  border-top: 1px solid var(--rule-strong);
  padding-top: var(--space-10);
}
.ap-roster-head .fb-actions { margin-inline-start: auto; }
.ap-roster-head + .filter-bar {
  container: ap-tb / inline-size;
  padding-block: var(--space-4) var(--space-5);
  margin-bottom: var(--space-4);
}
@media (max-width: 768px), (pointer: coarse) {
  /* the exports were 44px touch targets in the toolbar; beside the heading they
     stay so (out-ranking "html body .btn.btn-sm", the compact tier's 40px) */
  .ap-roster-head .fb-actions > .btn { min-height: var(--control-h); }
}
@media (max-width: 480px) {
  /* as in the toolbar: the label carries the meaning, the icon gives up its room */
  html body .ap-roster-head .btn-export > .i { display: none; }
}
/* A phone's toolbar: the search takes the line, the six filters a 2-column grid. */
@container ap-tb (max-width: 640px) {
  .ap-roster-head + .filter-bar .fb-search.fb-grow { flex: 1 1 100%; max-width: none; }
  .ap-roster-head + .filter-bar .fb-spacer { display: none; }
  .ap-roster-head + .filter-bar #apFilters {
    flex: 1 1 100%;
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
  }
  .ap-roster-head + .filter-bar #apFilters .fb-dd { justify-content: space-between; }
}

/* ── Phones: the bar holds the menu and the title, then the scope fields,
   each on its own full-width line ──────────────────────────────────────── */
@media (max-width: 768px) {
  #main-content > .content-wrap > .page-header:has(#apScope) {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "menu title" "scope scope";
    gap: var(--space-4) var(--space-4) !important;
  }
  .page-header:has(#apScope) > .sidebar-toggle { grid-area: menu; }
  .page-header:has(#apScope) > .page-header-right { margin-top: 0; }
  /* the bar carries the page's actions (the system's phone pattern); the
     page's sentence would land between them and the title, so a phone,
     where the roster is a long list of cards, shows it only to a screen
     reader (hidden to the eye, not removed) */
  .page-header:has(#apScope) .page-header-chips {
    position: absolute; width: 1px; height: 1px;
    margin: -1px; padding: 0; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  }
  #apScope { flex: 1 1 100%; }
  #apScope .fb-search { flex: 1 1 100%; }
  #apScope .fb-search > select { flex: 1 1 auto; max-width: none; }
}

/* 72px rows showed three students above the fold. */
#apTable tbody tr.cr-row td { padding-block: 9px; }

/* Filter chips layout */
.ap-filters { display:flex; gap:0.25rem; flex-wrap:wrap; }

/* ── Batch bar ─── */
.ap-batch-bar {
  display: none; align-items: center; gap: 0.75rem;
  padding: 0.45rem 0.75rem; border-radius: var(--radius);
  background: var(--brand-soft); border: 1px solid var(--teal-border);
  margin-bottom: 0.5rem; font-size: var(--text-sm); color: var(--brand-dark);
  animation: dlg-fade-in 0.15s var(--ease);
}
.ap-batch-bar.active { display: flex; }
.ap-batch-count { font-weight: 700; font-family: var(--font-mono); }

/* ── Table — using global .tbl-card + .cr-row ─── */
#apTable .ap-check { width:15px; height:15px; cursor:pointer; }
/* The cells are start-aligned and the headers were centred, so each title sat
   20-130px off its column. */
#apTable thead th { text-align: start; }
/* "<2" and "2–3" are LTR runs: in an Arabic page "<" mirrored to ">" and the
   range ran backwards ("3–2"). */
.ap-gpa-labels > span { direction: ltr; unicode-bidi: isolate; }
/* the CSV pill is a link; it is a pill, not underlined text */
a.fb-dd, a.fb-dd:hover { text-decoration: none; }
.ap-expand[aria-expanded="true"] { transform:rotate(90deg); }
.ap-expand[aria-expanded="true"] .i { color:var(--text-brand); }

/* Detail row */
.ap-detail-row td { background: rgba(255,255,255,0.7) !important; border-top: 1px dashed var(--pl-overlay-4) !important; }
.ap-detail-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.5rem; padding: 0.65rem 0.5rem; font-size: var(--text-sm); color: var(--ink);
}
.ap-detail-full { grid-column: 1 / -1; }
.ap-detail-label {
  display: block; font-size: var(--text-micro); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin-bottom: 0.1rem;
}

/* ── Student drawer (slide-out) — neumorphic ─── */
.ap-drawer-backdrop {
  position: fixed; inset: 0; z-index: 1500;
  background: rgba(10,18,40,0.4); backdrop-filter: blur(3px);
  animation: dlg-fade-in 0.15s var(--ease);
}
.ap-drawer-backdrop.closing {
  animation: dlg-fade-out 0.2s var(--ease) forwards;
}
@keyframes dlg-fade-out { to { opacity: 0; } }

/* The drawer is docked at the inline end, so it slides in from that edge: the
   distance is a custom property flipped in Arabic. (`[dir="rtl"] @keyframes`
   is not valid CSS; the browser dropped both rules, and in Arabic the drawer
   swept in across the whole page from the far side, stage 3 SW-27.) */
.ap-drawer {
  --ap-drawer-from: 100%;
  position: fixed; top: 0; bottom: 0; z-index: 1501;
  inset-inline-end: 0; width: 420px; max-width: 92vw;
  background: var(--bg);
  box-shadow: -12px 0 40px rgba(163,177,198,0.4), 4px 0 16px rgba(255,255,255,0.6);
  overflow-y: auto; padding: 1.5rem;
  animation: ap-drawer-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
[dir="rtl"] .ap-drawer {
  --ap-drawer-from: -100%;
  box-shadow: 12px 0 40px rgba(163,177,198,0.4), -4px 0 16px rgba(255,255,255,0.6);
}
.ap-drawer.closing {
  animation: ap-drawer-out 0.2s var(--ease) forwards;
}

@keyframes ap-drawer-in {
  from { transform: translateX(var(--ap-drawer-from)); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
@keyframes ap-drawer-out {
  from { transform: translateX(0); opacity: 1; }
  to   { transform: translateX(var(--ap-drawer-from)); opacity: 0; }
}

.ap-drawer-close {
  position: absolute; top: 0.75rem; inset-inline-end: 0.75rem;
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: var(--bg);
  box-shadow: 3px 3px 7px rgba(163,177,198,0.35), -3px -3px 7px rgba(255,255,255,0.7);
  cursor: pointer; display: flex;
  align-items: center; justify-content: center; font-size: var(--text-base);
  color: var(--muted); transition: all 0.15s var(--ease);
}
.ap-drawer-close:hover {
  box-shadow: inset 2px 2px 5px rgba(163,177,198,0.35), inset -2px -2px 5px rgba(255,255,255,0.7);
  color: var(--danger);
}
.ap-drawer-close:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.ap-drawer-name { font-size: var(--text-xl); font-weight: 700; color: var(--navy); margin-bottom: 0.15rem; }
.ap-drawer-id {
  font-family: var(--font-mono); font-size: var(--text-sm); color: var(--muted);
  margin-bottom: 0.75rem;
}
.ap-drawer-id-pill {
  background: var(--teal-dim); padding: 4px 10px; border-radius: var(--radius-sm);
  display: inline-block;
}

.ap-drawer-section {
  margin-bottom: 0.75rem;
  background: var(--glass-bg); border-radius: var(--radius-md); padding: 12px 14px;
  box-shadow: inset 2px 2px 5px rgba(163,177,198,0.2), inset -2px -2px 5px rgba(255,255,255,0.7);
}
/* .ap-drawer-section-title base styling handled by canonical heading rule.
   Keep ::before shape definition — hidden by default, could be re-enabled
   for variants in future. */
.ap-drawer-section-title::before {
  content: ""; width: 3px; height: 0.7rem; border-radius: 2px;
  background: var(--teal); opacity: 1;
}
.ap-drawer-kv { display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem; }
.ap-drawer-kv-item { font-size: var(--text-base); }
.ap-drawer-kv-item strong { color: var(--navy); }
.ap-drawer-kv-label {
  font-size: var(--text-micro); font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}

/* HP Missing table inside drawer — neumorphic inset */
.ap-drawer-section .table-wrap {
  background: var(--glass-bg); border-radius: var(--radius);
  box-shadow: inset 2px 2px 5px rgba(163,177,198,0.15), inset -2px -2px 5px rgba(255,255,255,0.5);
  overflow: hidden;
}
.ap-drawer-section .table-wrap table {
  margin-bottom: 0;
}
.ap-drawer-section .table-wrap th {
  font-size: var(--text-micro); font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted); background: rgba(232,236,241,0.5);
  border-bottom: 1px solid rgba(163,177,198,0.2);
}
.ap-drawer-section .table-wrap td {
  font-size: var(--text-sm); border-bottom: 1px solid rgba(163,177,198,0.12);
}

.ap-drawer-actions {
  display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.75rem;
  padding-top: 0.75rem; border-top: none;
}
.ap-drawer-actions .btn,
.ap-drawer-actions a.btn {
  border-radius: var(--radius-pill); border: none; padding: 6px 14px;
  font-size: var(--text-sm); font-weight: 600; transition: all 0.15s var(--ease);
}
.ap-drawer-actions .btn-outline-primary,
.ap-drawer-actions a.btn-outline-primary {
  background: var(--btn-primary-bg); color: var(--btn-primary-ink); border: none;
  box-shadow: 3px 3px 7px rgba(163,177,198,0.35), -3px -3px 7px rgba(255,255,255,0.7);
}
.ap-drawer-actions .btn-outline-primary:hover,
.ap-drawer-actions a.btn-outline-primary:hover {
  box-shadow: inset 2px 2px 5px rgba(8,110,85,0.25), inset -2px -2px 5px rgba(12,170,130,0.15);
  background: var(--btn-primary-hover);
}
.ap-drawer-actions .btn-export {
  background: var(--bg); color: var(--t1); border: none;
  box-shadow: 3px 3px 7px rgba(163,177,198,0.35), -3px -3px 7px rgba(255,255,255,0.7);
}
.ap-drawer-actions .btn-export:hover {
  box-shadow: inset 2px 2px 5px rgba(163,177,198,0.35), inset -2px -2px 5px rgba(255,255,255,0.7);
}
.ap-drawer-actions .btn:focus-visible,
.ap-drawer-actions a.btn:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}

/* ── Graduation plan presentation ─────────────────────────── */
.ap-drawer.ap-drawer--graduation {
  width: min(920px, 96vw);
  box-sizing: border-box;
}
.ap-grad-panel {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.ap-grad-panel[hidden] { display: none; }
.ap-grad-panel-head,
.ap-grad-graph-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
}
.ap-grad-panel-head h2 {
  margin: 0;
  color: var(--navy);
  font-size: var(--text-lg);
}
.ap-grad-panel-head h2:focus { outline: none; }
.ap-grad-readonly {
  padding: .2rem .55rem;
  border: 1px solid var(--teal-border);
  border-radius: var(--radius-pill);
  background: var(--teal-dim);
  color: var(--brand-dark);
  font-size: var(--text-micro);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.ap-grad-advisory {
  margin: .4rem 0 .8rem;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.55;
}
.ap-grad-tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  max-width: 440px;
  width: 100%;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--navy) 5%, transparent);
}
.ap-grad-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: .45rem .75rem;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  /* a label longer than its third of the bar wraps inside its own segment
     ("Formal recommendation" ran under its neighbour on a phone) */
  min-width: 0;
  line-height: 1.25;
  overflow-wrap: break-word;
  hyphens: auto;
}
@media (max-width: 480px) {
  .ap-grad-tab { padding-inline: .4rem; }
}
.ap-grad-tab:hover { color: var(--ink); }
.ap-grad-tab.is-active {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-ink);
  box-shadow: 0 2px 8px rgba(8, 110, 85, .2);
}
.ap-grad-tab:focus-visible,
.ap-grad-retry:focus-visible,
.ap-grad-graph-modes button:focus-visible,
.ap-grad-table-scroll:focus-visible,
.ap-grad-graph-scroll:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}
.ap-grad-tabpanel { min-height: 140px; padding-top: .8rem; }
.ap-grad-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .65rem;
  min-height: 110px;
  padding: 1rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  color: var(--muted);
  font-size: var(--text-sm);
  text-align: center;
}
.ap-grad-state-error {
  flex-direction: column;
  border-color: color-mix(in srgb, var(--danger) 28%, transparent);
  background: color-mix(in srgb, var(--danger) 6%, transparent);
  color: var(--danger);
}
.ap-grad-retry {
  padding: .35rem .8rem;
  border: 1px solid currentColor;
  border-radius: var(--radius-pill);
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}
.ap-grad-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--teal-border);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: ap-grad-spin .7s linear infinite;
}
@keyframes ap-grad-spin { to { transform: rotate(360deg); } }
.ap-grad-section {
  margin-top: .75rem;
  padding: .85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--glass-bg);
}
.ap-grad-section h3 {
  margin: 0 0 .65rem;
  color: var(--navy);
  font-size: var(--text-base);
}
.ap-grad-section h4 {
  margin: .75rem 0 .4rem;
  color: var(--t2);
  font-size: var(--text-xs);
}
.ap-grad-summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: .5rem;
}
.ap-grad-metric {
  min-width: 0;
  padding: .65rem;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--navy) 4%, transparent);
}
.ap-grad-metric > span {
  display: block;
  min-height: 2.2em;
  color: var(--muted);
  font-size: var(--text-micro);
  font-weight: 700;
}
.ap-grad-metric strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--navy);
  font-size: var(--text-md);
}
.ap-grad-metric small { color: var(--muted); font-size: var(--text-micro); }
.ap-grad-metric-emphasis {
  background: var(--teal-dim);
  border: 1px solid var(--teal-border);
}
.ap-grad-metric-emphasis strong { color: var(--brand-dark); }
.ap-grad-progress {
  height: 5px;
  margin-top: .65rem;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--line);
}
.ap-grad-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}
.ap-grad-provenance {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .75rem;
  padding: .7rem;
  border-inline-start: 3px solid var(--teal);
  border-radius: var(--radius-sm);
  background: var(--teal-dim);
}
.ap-grad-provenance strong { color: var(--brand-dark); font-size: var(--text-sm); }
.ap-grad-provenance p { margin: .2rem 0 0; color: var(--muted); font-size: var(--text-xs); }
.ap-grad-provenance dl { display: flex; flex-wrap: wrap; gap: .8rem; margin: 0; }
.ap-grad-provenance dl div { min-width: 88px; }
.ap-grad-provenance dt { color: var(--muted); font-size: var(--text-micro); }
.ap-grad-provenance dd { margin: .1rem 0 0; color: var(--ink); font-size: var(--text-sm); font-weight: 700; }
.ap-grad-course-list,
.ap-grad-term-courses,
.ap-grad-blockers,
.ap-grad-tree-fallback ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.ap-grad-course-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: .35rem;
}
.ap-grad-course-list li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: .35rem;
  align-items: baseline;
  padding: .45rem .55rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
}
.ap-grad-course-code { color: var(--text-brand); font-family: var(--font-mono); font-weight: 700; }
.ap-grad-course-name { overflow: hidden; color: var(--ink); text-overflow: ellipsis; white-space: nowrap; }
.ap-grad-course-credits { color: var(--muted); font-size: var(--text-micro); white-space: nowrap; }
.ap-grad-muted { margin: 0; color: var(--muted); font-size: var(--text-xs); }
.ap-grad-table-scroll,
.ap-grad-graph-scroll {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  border-radius: var(--radius);
}
.ap-grad-term-table {
  width: 100%;
  min-width: 710px;
  border-collapse: collapse;
  font-size: var(--text-xs);
}
.ap-grad-term-table th {
  padding: .5rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--navy) 5%, transparent);
  color: var(--muted);
  /* type: the shared table-header recipe (G6, at the end of this sheet) */
  text-align: start;
  white-space: nowrap;
}
.ap-grad-term-table td { padding: .55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.ap-grad-term-table tbody tr:last-child td { border-bottom: 0; }
.ap-grad-waiting-row { background: color-mix(in srgb, var(--warning) 6%, transparent); }
.ap-grad-term-state {
  display: inline-block;
  padding: .15rem .45rem;
  border-radius: var(--radius-pill);
  font-size: var(--text-micro);
  font-weight: 700;
  white-space: nowrap;
}
.ap-grad-term-state.is-planned { background: var(--teal-dim); color: var(--brand-dark); }
.ap-grad-term-state.is-waiting { background: color-mix(in srgb, var(--warning) 16%, transparent); color: #9a5b08; }
.ap-grad-term-courses { display: grid; gap: .25rem; }
.ap-grad-term-courses li { display: grid; grid-template-columns: auto minmax(120px, 1fr) auto; gap: .45rem; }
.ap-grad-term-courses bdi { color: var(--text-brand); font-family: var(--font-mono); font-weight: 700; }
.ap-grad-term-courses span { color: var(--ink); }
.ap-grad-term-courses small { color: var(--muted); font-size: var(--text-micro); }
.ap-grad-wait-text { color: #9a5b08; font-style: italic; }
.ap-grad-blockers { display: grid; gap: .4rem; }
.ap-grad-blockers li {
  padding: .55rem .65rem;
  border-inline-start: 3px solid var(--warning);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--warning) 7%, transparent);
}
.ap-grad-blockers li > div { display: flex; gap: .45rem; align-items: baseline; }
.ap-grad-blockers li > div span { color: var(--ink); font-size: var(--text-xs); }
.ap-grad-blockers p { margin: .25rem 0 0; color: var(--muted); font-size: var(--text-micro); }
.ap-grad-blocker-empty { color: var(--muted); font-size: var(--text-xs); }
.ap-grad-graph-head h3 { margin-bottom: 0; }
.ap-grad-graph-modes {
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--navy) 5%, transparent);
}
.ap-grad-graph-modes button {
  padding: .3rem .65rem;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: var(--text-micro);
  font-weight: 700;
}
.ap-grad-graph-modes button.is-active { background: var(--teal-dim); color: var(--brand-dark); }
.ap-grad-graph-scroll { margin-top: .65rem; border: 1px solid var(--line); background: var(--bg); }
.ap-grad-graph { min-width: 680px; padding: .35rem; }
.ap-grad-tree-fallback { display: grid; gap: .6rem; padding: .75rem; }
.ap-grad-tree-fallback section { border-inline-start: 2px solid var(--teal); padding-inline-start: .65rem; }
.ap-grad-tree-fallback h4 { margin: 0 0 .35rem; }
.ap-grad-tree-fallback li { display: flex; gap: .5rem; padding: .2rem 0; font-size: var(--text-xs); }
.ap-grad-tree-fallback bdi { color: var(--text-brand); font-family: var(--font-mono); font-weight: 700; }
.ap-grad-tree-fallback span { color: var(--muted); }

/* ── Dedicated adviser graduation workspace ──────────────── */
main[data-page="advisor-student-graduation"] > .content-wrap {
  width: 100%;
  max-width: 1480px; /* a little wider than the 1440px default, as the exam pages */
}

.advisor-grad-page,
.advisor-grad-page #advisorGraduationResults {
  min-width: 0;
}
.advisor-grad-page {
  display: grid;
  gap: .75rem;
}
.admin-grad-search {
  display: grid;
  grid-template-columns: minmax(210px, .8fr) minmax(360px, 1.2fr);
  align-items: end;
  gap: 1rem;
  width: 100%;
  max-width: 960px;
  margin-inline: auto;
  padding: 1rem;
  border: 1px solid var(--teal-border);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--teal) 4%, var(--glass-bg));
  box-shadow: var(--shadow-soft);
}
.admin-grad-search h2 {
  margin: 0;
  color: var(--navy);
  font-size: var(--text-md);
}
.admin-grad-search p {
  margin: .25rem 0 0;
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.55;
}
.admin-grad-search-form {
  min-width: 0;
}
.admin-grad-search-form label {
  display: block;
  margin-bottom: .35rem;
  color: var(--navy);
  font-size: var(--text-xs);
  font-weight: 700;
}
.admin-grad-search-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: .55rem;
}
.admin-grad-search-controls input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: .65rem .8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: 0;
  background: var(--glass-bg-data);
  color: var(--navy);
  font: 700 var(--text-base)/1.2 var(--font-mono);
  direction: ltr;
}
.admin-grad-search-controls input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 18%, transparent);
}
.admin-grad-search-controls input[aria-invalid="true"] {
  border-color: var(--danger);
}
.admin-grad-search-controls .btn {
  min-height: 44px;
  white-space: nowrap;
}
.admin-grad-search-form .admin-grad-search-error {
  margin-top: .45rem;
  color: var(--danger);
  font-weight: 700;
}

/* ── Graduation planning: focused admin landing ─────────── */
main[data-page="advisor-student-graduation"][data-graduation-workspace="admin"][data-graduation-state="landing"]
  > .content-wrap > .page-intro {
  display: none;
}
.admin-grad-landing.admin-grad-search {
  display: grid;
  grid-template-columns: 1fr;
  align-content: center;
  gap: 1rem;
  width: min(1120px, 100%);
  max-width: none;
  min-height: max(580px, calc(100dvh - 180px));
  margin: 0 auto;
  padding: clamp(1rem, 2.6vw, 2.4rem) 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.admin-grad-landing-shell {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(370px, .88fr);
  overflow: hidden;
  /* Two radial washes in sky and teal over a teal-to-royal linear gradient,
     inside a 26px radius under a 65px shadow. The same gradient-wash idiom the
     page mesh and the dashboard hero carried, at the largest scale in the app.
     The layout keeps its two columns; the decoration goes, and the rule that
     divides it from the page is the one the rest of the app uses. */
  border: 0;
  border-top: 1px solid var(--rule-strong);
  border-radius: 0;
  background: none;
  box-shadow: none;
}
.admin-grad-landing-shell::before,
.admin-grad-landing-shell::after {
  position: absolute;
  z-index: -1;
  content: "";
  border: 1px solid color-mix(in srgb, var(--teal) 16%, transparent);
  border-radius: 50%;
  pointer-events: none;
}
.admin-grad-landing-shell::before {
  width: 260px;
  height: 260px;
  inset: -155px auto auto -105px;
}
.admin-grad-landing-shell::after {
  width: 170px;
  height: 170px;
  inset: auto auto -115px 43%;
}
.admin-grad-landing-copy {
  display: flex;
  min-width: 0;
  padding: clamp(2rem, 4vw, 3.6rem);
  flex-direction: column;
  justify-content: center;
}
.admin-grad-eyebrow {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: .45rem;
  margin-bottom: 1rem;
  padding: .35rem .65rem;
  border: 1px solid var(--teal-border);
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--teal) 8%, transparent);
  color: var(--text-brand);
  font: 700 var(--text-micro)/1.2 var(--font-mono);
  letter-spacing: .07em;
  text-transform: uppercase;
}
.admin-grad-eyebrow svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}
.admin-grad-search .admin-grad-landing-copy h2 {
  max-width: 680px;
  margin: 0;
  color: var(--navy);
  font-family: var(--font-serif);
  font-size: clamp(2rem, 1.5rem + 1.35vw, 3.05rem);
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1.06;
}
.admin-grad-search .admin-grad-landing-copy > p {
  max-width: 62ch;
  margin: 1rem 0 0;
  color: var(--t3);
  font-size: var(--text-md);
  line-height: 1.7;
}
.admin-grad-journey {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .5rem;
  margin: clamp(1.6rem, 3vw, 2.35rem) 0 0;
  padding: 0;
  list-style: none;
}
.admin-grad-journey li {
  position: relative;
  display: flex;
  min-width: 0;
  align-items: center;
  gap: .55rem;
  padding: .65rem;
  border: 1px solid color-mix(in srgb, var(--teal) 14%, var(--line));
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--glass-bg-data) 78%, transparent);
}
.admin-grad-journey li > span {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: var(--radius);
  place-items: center;
  background: color-mix(in srgb, var(--teal) 12%, transparent);
  color: var(--text-brand);
  font: 700 var(--text-micro)/1 var(--font-mono);
}
.admin-grad-journey li > div {
  display: grid;
  min-width: 0;
  gap: .12rem;
}
.admin-grad-journey strong {
  color: var(--navy);
  font-size: var(--text-xs);
  line-height: 1.25;
}
.admin-grad-journey small {
  color: var(--muted);
  font-size: var(--text-micro);
  line-height: 1.3;
}
.admin-grad-lookup-wrap {
  display: grid;
  min-width: 0;
  padding: clamp(1.15rem, 2.7vw, 2.25rem);
  border-inline-start: 1px solid color-mix(in srgb, var(--teal) 16%, var(--line));
  place-items: center;
  background: linear-gradient(165deg,
    color-mix(in srgb, var(--glass-bg-data) 72%, transparent),
    color-mix(in srgb, var(--royal) 4%, var(--glass-bg)));
}
.admin-grad-lookup-card {
  width: min(100%, 420px);
  padding: clamp(1.15rem, 2.2vw, 1.6rem);
  /* The "start here" panel. It is a section of the sheet, not a floating
     card: the inline-start rule separates it from the copy beside it. */
  border: 0;
  border-inline-start: 1px solid var(--rule);
  border-radius: 0;
  background: none;
  box-shadow: none;
}
.admin-grad-lookup-head {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.35rem;
}
.admin-grad-lookup-head > div {
  display: grid;
  gap: .12rem;
}
.admin-grad-lookup-head > div > span {
  color: var(--text-brand);
  font: 700 var(--text-micro)/1.2 var(--font-mono);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.admin-grad-lookup-head h3 {
  margin: 0;
  color: var(--navy);
  font-size: var(--text-lg);
  letter-spacing: -.015em;
}
.admin-grad-lookup-icon,
.admin-grad-capability-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  color: var(--text-brand);
  background: linear-gradient(145deg,
    color-mix(in srgb, var(--teal) 14%, var(--glass-bg-data)),
    color-mix(in srgb, var(--sky) 8%, var(--glass-bg-data)));
  box-shadow: 0 8px 20px color-mix(in srgb, var(--teal) 13%, transparent);
}
.admin-grad-lookup-icon {
  width: 46px;
  height: 46px;
  border: 1px solid var(--teal-border);
  border-radius: var(--radius-lg);
}
.admin-grad-lookup-icon svg,
.admin-grad-capability-icon svg,
.admin-grad-id-field > svg,
.admin-grad-readonly-note svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}
.admin-grad-lookup-icon svg { width: 23px; height: 23px; }
.admin-grad-landing-form {
  display: grid;
  gap: .65rem;
}
.admin-grad-search-form.admin-grad-landing-form label {
  margin: 0;
  font-size: var(--text-micro);
  letter-spacing: .035em;
  text-transform: uppercase;
}
.admin-grad-id-field {
  position: relative;
  min-width: 0;
}
.admin-grad-id-field > svg {
  position: absolute;
  z-index: 1;
  top: 50%;
  inset-inline-start: .9rem;
  width: 20px;
  height: 20px;
  color: var(--muted);
  pointer-events: none;
  transform: translateY(-50%);
}
.admin-grad-id-field input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 56px;
  padding: .8rem .95rem .8rem 2.75rem;
  border: 1px solid color-mix(in srgb, var(--teal) 22%, var(--line));
  border-radius: var(--radius-md);
  outline: 0;
  background: var(--glass-bg-data);
  color: var(--navy);
  font: 700 var(--text-md)/1.2 var(--font-mono);
  direction: ltr;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
html[dir="rtl"] .admin-grad-id-field input {
  padding: .8rem 2.75rem .8rem .95rem;
}
.admin-grad-id-field input::placeholder {
  color: var(--t4);
  font-weight: 600;
}
.admin-grad-id-field input:hover { border-color: color-mix(in srgb, var(--teal) 40%, var(--line)); }
.admin-grad-id-field input:focus {
  border-color: var(--teal);
  background: color-mix(in srgb, var(--teal) 2%, var(--glass-bg-data));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--teal) 15%, transparent);
}
.admin-grad-id-field input[aria-invalid="true"] { border-color: var(--danger); }
.admin-grad-id-hint {
  margin: -.18rem 0 .1rem !important;
  color: var(--muted) !important;
  font-size: var(--text-micro) !important;
  line-height: 1.4 !important;
}
.admin-grad-lookup-submit {
  display: flex !important;
  width: 100%;
  min-height: 50px !important;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-top: .1rem;
  padding-inline: 1rem !important;
  border-radius: var(--radius-md) !important;
  font-size: var(--text-sm) !important;
}
.admin-grad-lookup-submit svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  transition: transform .18s ease;
}
.admin-grad-lookup-submit:hover svg { transform: translateX(3px); }
html[dir="rtl"] .admin-grad-lookup-submit svg { transform: scaleX(-1); }
html[dir="rtl"] .admin-grad-lookup-submit:hover svg { transform: scaleX(-1) translateX(3px); }
.admin-grad-readonly-note {
  display: flex;
  align-items: flex-start;
  gap: .45rem;
  margin-top: 1rem;
  padding-top: .85rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--text-micro);
  line-height: 1.5;
}
.admin-grad-readonly-note svg {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  margin-top: .08rem;
  color: var(--text-brand);
}
.admin-grad-capabilities {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .75rem;
}
.admin-grad-capabilities article {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: .8rem;
  padding: .9rem 1rem;
  border: 1px solid color-mix(in srgb, var(--teal) 13%, var(--line));
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--glass-bg) 88%, transparent);
  box-shadow: var(--shadow-soft);
}
.admin-grad-capability-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
}
.admin-grad-capability-icon svg { width: 19px; height: 19px; }
.admin-grad-capabilities article > div {
  display: grid;
  min-width: 0;
  gap: .16rem;
}
.admin-grad-capabilities strong {
  color: var(--navy);
  font-size: var(--text-xs);
}
.admin-grad-search .admin-grad-capabilities p {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-micro);
  line-height: 1.45;
}

@media (max-width: 980px) {
  .admin-grad-landing-shell { grid-template-columns: 1fr; }
  .admin-grad-landing-copy { padding-bottom: 1.5rem; }
  .admin-grad-lookup-wrap {
    border-top: 1px solid color-mix(in srgb, var(--teal) 16%, var(--line));
    border-inline-start: 0;
  }
  .admin-grad-lookup-card { width: min(100%, 620px); }
}

@media (max-width: 640px) {
  .admin-grad-landing.admin-grad-search {
    min-height: 0;
    padding: .25rem 0 1rem;
  }
  .admin-grad-landing-shell { border-radius: var(--radius-lg); }
  .admin-grad-landing-copy { padding: 1.35rem 1.15rem 1.2rem; }
  .admin-grad-search .admin-grad-landing-copy h2 {
    font-size: clamp(1.65rem, 1.35rem + 1.5vw, 2rem);
    line-height: 1.1;
  }
  .admin-grad-search .admin-grad-landing-copy > p { margin-top: .75rem; font-size: var(--text-sm); }
  .admin-grad-eyebrow { margin-bottom: .75rem; font-size: var(--text-micro); }
  .admin-grad-journey {
    grid-template-columns: 1fr;
    gap: .35rem;
    margin-top: 1.1rem;
  }
  .admin-grad-journey li { padding: .5rem .6rem; }
  .admin-grad-lookup-wrap { padding: .9rem; }
  .admin-grad-lookup-card { padding: 1rem; border-radius: var(--radius-lg); }
  .admin-grad-capabilities { grid-template-columns: 1fr; gap: .5rem; }
  .admin-grad-capabilities article { padding: .75rem .85rem; }
}

.admin-grad-scenario {
  display: grid;
  gap: .85rem;
  padding: 1rem;
  border: 1px solid color-mix(in srgb, var(--royal) 22%, var(--line));
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--royal) 3%, var(--glass-bg));
  box-shadow: var(--shadow-soft);
}
.admin-grad-scenario-head,
.admin-grad-scenario-result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.admin-grad-scenario h2 {
  margin: 0;
  color: var(--navy);
  font-size: var(--text-md);
}
.admin-grad-scenario-head p,
.admin-grad-field p {
  margin: .25rem 0 0;
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.5;
}
.admin-grad-readonly-badge {
  flex: 0 0 auto;
  padding: .35rem .6rem;
  border: 1px solid color-mix(in srgb, var(--royal) 28%, var(--line));
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--royal) 8%, transparent);
  /* --royal on the dark page was 4.2:1; the info severity ink passes in both themes */
  color: var(--sev-info);
  font-size: var(--text-micro);
  font-weight: 700;
  white-space: nowrap;
}
.admin-grad-scenario-form {
  display: grid;
  gap: .8rem;
}
.admin-grad-scenario-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: .8rem;
}
.admin-grad-field { min-width: 0; }
.admin-grad-field > label {
  display: block;
  margin-bottom: .35rem;
  color: var(--navy);
  font-size: var(--text-xs);
  font-weight: 700;
}
.admin-grad-picker-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: .5rem;
}
.admin-grad-picker-controls select,
.admin-grad-field input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: .6rem .7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: 0;
  background: var(--glass-bg-data);
  color: var(--navy);
  font-size: var(--text-sm);
}
.admin-grad-field input {
  direction: ltr;
  font-family: var(--font-mono);
  font-weight: 700;
}
.admin-grad-picker-controls select:focus,
.admin-grad-field input:focus,
.admin-grad-exception-toggle:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 18%, transparent);
}
.admin-grad-field input[aria-invalid="true"] { border-color: var(--danger); }
.admin-grad-picker-controls .btn { min-height: 44px; white-space: nowrap; }
.admin-grad-selected {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  min-height: 30px;
  margin-top: .45rem;
}
.admin-grad-selected-chip,
.admin-grad-course-tag,
.admin-grad-course-role {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  border: 1px solid color-mix(in srgb, var(--royal) 32%, var(--line));
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--royal) 8%, transparent);
  color: var(--royal);
  font-size: var(--text-micro);
  font-weight: 700;
}
.admin-grad-selected-chip { padding: .22rem .3rem .22rem .55rem; }
.admin-grad-selected-chip button {
  display: inline-grid;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  place-items: center;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: var(--text-md);
}
.admin-grad-selected-chip button:hover,
.admin-grad-selected-chip button:focus-visible {
  background: color-mix(in srgb, var(--royal) 14%, transparent);
  outline: 2px solid color-mix(in srgb, var(--royal) 40%, transparent);
}
.admin-grad-selection-empty {
  align-self: center;
  color: var(--muted);
  font-size: var(--text-xs);
}
.admin-grad-exception-toggle {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  padding: .7rem;
  border: 1px solid color-mix(in srgb, #b45309 28%, var(--line));
  border-radius: var(--radius);
  background: color-mix(in srgb, #f59e0b 6%, transparent);
  cursor: pointer;
}
.admin-grad-exception-toggle input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: .1rem;
  accent-color: #b45309;
}
.admin-grad-exception-toggle span { display: grid; gap: .15rem; }
.admin-grad-exception-toggle strong { color: var(--navy); font-size: var(--text-xs); }
.admin-grad-exception-toggle small { color: var(--muted); font-size: var(--text-micro); line-height: 1.45; }
.admin-grad-scenario-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.admin-grad-scenario-actions .btn { min-height: 42px; }
.admin-grad-scenario-alert,
.admin-grad-scenario-result {
  padding: .8rem;
  border-radius: var(--radius);
  font-size: var(--text-xs);
  line-height: 1.5;
}
.admin-grad-scenario-alert.is-error {
  border: 1px solid color-mix(in srgb, var(--danger) 38%, var(--line));
  background: color-mix(in srgb, var(--danger) 7%, transparent);
  color: var(--danger);
}
.admin-grad-scenario-alert:focus { outline: 2px solid var(--danger); outline-offset: 3px; }
.admin-grad-scenario-alert ul { margin: .35rem 0 0; padding-inline-start: 1.25rem; }
.admin-grad-scenario-result {
  display: grid;
  gap: .65rem;
  border: 1px solid color-mix(in srgb, var(--teal) 34%, var(--line));
  background: color-mix(in srgb, var(--teal) 6%, transparent);
}
.admin-grad-scenario-result-head > div:first-child { display: grid; gap: .15rem; }
.admin-grad-scenario-result-head strong { color: var(--navy); font-size: var(--text-sm); }
.admin-grad-scenario-result-head span { color: var(--muted); font-size: var(--text-micro); }
.admin-grad-impact {
  display: grid;
  min-width: 190px;
  gap: .1rem;
  padding: .45rem .6rem;
  border-radius: var(--radius);
  background: var(--glass-bg-data);
  text-align: end;
}
.admin-grad-impact strong { color: var(--text-brand); }
.admin-grad-term-comparison { color: var(--navy); font: 700 var(--text-xs)/1.4 var(--font-mono); }
.admin-grad-scenario-groups { display: grid; gap: .4rem; }
.admin-grad-scenario-groups > div { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.admin-grad-scenario-groups > div > span:first-child { min-width: 185px; color: var(--muted); font-weight: 700; }
.admin-grad-course-tag { padding: .2rem .5rem; }
.admin-grad-course-tag.is-prerequisite,
.admin-grad-course-role.is-prerequisite {
  border-color: color-mix(in srgb, #b45309 38%, var(--line));
  background: color-mix(in srgb, #f59e0b 10%, transparent);
  color: #9a4a08;
}
.admin-grad-course-tag.is-displaced {
  border-color: color-mix(in srgb, var(--muted) 35%, var(--line));
  background: color-mix(in srgb, var(--muted) 8%, transparent);
  color: var(--muted);
  text-decoration: line-through;
}
.admin-grad-course-role { margin-inline-start: .35rem; padding: .16rem .45rem; }
.admin-grad-special-warning {
  margin: 0;
  padding-top: .55rem;
  border-top: 1px solid color-mix(in srgb, #b45309 25%, var(--line));
  color: #9a4a08;
  font-weight: 700;
}
.advisor-grad-switcher {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--glass-bg);
  box-shadow: var(--shadow-soft);
}
.advisor-grad-switcher h2 {
  margin: 0;
  color: var(--navy);
  font-size: var(--text-md);
}
.advisor-grad-switcher p,
.advisor-grad-map-head p {
  margin: .2rem 0 0;
  color: var(--muted);
  font-size: var(--text-xs);
}
.advisor-grad-switcher .ap-grad-tabs {
  flex: 0 1 620px;
  max-width: 620px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.advisor-grad-summary { margin-top: 0; }
.advisor-grad-error { min-height: 180px; }
.advisor-grad-error .ap-grad-retry { text-decoration: none; }
.advisor-grad-map-details > summary {
  color: var(--navy);
  cursor: pointer;
  font-size: var(--text-base);
  font-weight: 700;
}
.advisor-grad-map-details > summary:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 4px;
}
.advisor-grad-map-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-top: .65rem;
}
.advisor-grad-page .ap-grad-graph {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  padding: .4rem;
}

/* Row count / pagination: using global .pg-bar, .pg-btn */

/* ── Empty state ─── */
.ap-empty { text-align: center; padding: 2.5rem 1.5rem; color: var(--t4); display: flex; flex-direction: column; align-items: center; }
/* .ap-empty-icon, -title and -hint share the global look ("Empty states"). */

/* Override: remove default table styling on tbl-card */

/* Mobile: always show row actions & checkboxes */
@media (max-width: 768px) {
  .ap-drawer {
    inset-inline-start: 0;
    width: auto;
    max-width: none;
    box-sizing: border-box;
    padding: 1.25rem;
  }
  .ap-drawer.ap-drawer--graduation { width: auto; max-width: none; }
  .ap-grad-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ap-grad-metric-emphasis { grid-column: 1 / -1; }
  .ap-grad-provenance { grid-template-columns: 1fr; }
  .ap-grad-provenance dl { justify-content: space-between; }
  .ap-grad-course-list { grid-template-columns: 1fr; }
  .ap-grad-graph-head { align-items: flex-start; }
  .advisor-grad-switcher,
  .advisor-grad-map-head {
    align-items: stretch;
    flex-direction: column;
  }
  .admin-grad-search {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .admin-grad-search-controls { grid-template-columns: 1fr; }
  .admin-grad-search-controls .btn { width: 100%; }
  .admin-grad-scenario-head,
  .admin-grad-scenario-result-head { align-items: stretch; flex-direction: column; }
  .admin-grad-readonly-badge { align-self: flex-start; white-space: normal; }
  .admin-grad-scenario-fields { grid-template-columns: 1fr; }
  .admin-grad-picker-controls { grid-template-columns: 1fr; }
  .admin-grad-picker-controls .btn { width: 100%; }
  .admin-grad-scenario-actions { display: grid; grid-template-columns: 1fr; }
  .admin-grad-scenario-actions .btn { width: 100%; }
  .admin-grad-impact { min-width: 0; text-align: start; }
  .admin-grad-scenario-groups > div > span:first-child { flex-basis: 100%; min-width: 0; }
  .advisor-grad-switcher .ap-grad-tabs { flex-basis: auto; max-width: none; }
  .advisor-grad-page .ap-grad-section { padding: .7rem; }
}

/* ═══════════════════════════════════════════════════════════
   DARK MODE — Deep Navy overrides
   Selector: html[data-theme="dark"]
   ═══════════════════════════════════════════════════════════ */
/* Detail row */
html[data-theme="dark"] .ap-detail-row td {
  background: rgba(255,255,255,0.04) !important;
  border-top-color: rgba(255,255,255,0.06) !important;
}

/* Drawer — neumorphic overrides */
html[data-theme="dark"] .ap-drawer {
  background: #151826;
  box-shadow: -12px 0 40px rgba(0,0,0,0.5), 4px 0 16px rgba(255,255,255,0.02);
}
html[data-theme="dark"] [dir="rtl"] .ap-drawer {
  box-shadow: 12px 0 40px rgba(0,0,0,0.5), -4px 0 16px rgba(255,255,255,0.02);
}
html[data-theme="dark"] .ap-drawer-close {
  background: #1a1e30;
  box-shadow: 3px 3px 7px rgba(0,0,0,0.4), -3px -3px 7px rgba(255,255,255,0.03);
  color: #a0a4b8;
}
html[data-theme="dark"] .ap-drawer-close:hover {
  box-shadow: inset 2px 2px 5px rgba(0,0,0,0.4), inset -2px -2px 5px rgba(255,255,255,0.03);
  color: #f87171;
}
html[data-theme="dark"] .ap-drawer-name {
  color: #e2e4ec;
}
html[data-theme="dark"] .ap-drawer-id {
  color: #a0a4b8;
}
html[data-theme="dark"] .ap-drawer-id-pill {
  background: rgba(10,142,110,0.12);
}
html[data-theme="dark"] .ap-drawer-section {
  background: rgba(255,255,255,0.04);
  box-shadow: inset 2px 2px 5px rgba(0,0,0,0.25), inset -2px -2px 5px rgba(255,255,255,0.02);
}
html[data-theme="dark"] .ap-drawer-kv-item strong {
  color: #e2e4ec;
}
html[data-theme="dark"] .ap-grad-panel {
  border-top-color: rgba(255,255,255,.08);
}
html[data-theme="dark"] .ap-grad-panel-head h2,
html[data-theme="dark"] .ap-grad-section h3,
html[data-theme="dark"] .ap-grad-metric strong {
  color: #e2e4ec;
}
html[data-theme="dark"] .ap-grad-readonly,
html[data-theme="dark"] .ap-grad-metric-emphasis,
html[data-theme="dark"] .ap-grad-provenance,
html[data-theme="dark"] .ap-grad-term-state.is-planned,
html[data-theme="dark"] .ap-grad-graph-modes button.is-active {
  background: rgba(10,142,110,.14);
  border-color: rgba(10,142,110,.28);
  color: #5ee8b7;
}
html[data-theme="dark"] .ap-grad-tabs,
html[data-theme="dark"] .ap-grad-graph-modes,
html[data-theme="dark"] .ap-grad-metric,
html[data-theme="dark"] .ap-grad-term-table th {
  background: rgba(255,255,255,.045);
}
html[data-theme="dark"] .ap-grad-tab.is-active {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-ink);
}
html[data-theme="dark"] .ap-grad-section,
html[data-theme="dark"] .ap-grad-graph-scroll {
  background: rgba(255,255,255,.025);
  border-color: rgba(255,255,255,.07);
}
html[data-theme="dark"] .ap-grad-course-list li,
html[data-theme="dark"] .ap-grad-term-table th,
html[data-theme="dark"] .ap-grad-term-table td {
  border-color: rgba(255,255,255,.07);
}
html[data-theme="dark"] .ap-grad-course-code,
html[data-theme="dark"] .ap-grad-term-courses bdi,
html[data-theme="dark"] .ap-grad-tree-fallback bdi {
  color: #5ee8b7;
}
html[data-theme="dark"] .ap-grad-course-name,
html[data-theme="dark"] .ap-grad-term-courses span,
html[data-theme="dark"] .ap-grad-provenance dd,
html[data-theme="dark"] .ap-grad-blockers li > div span {
  color: #e2e4ec;
}
html[data-theme="dark"] .ap-grad-waiting-row,
html[data-theme="dark"] .ap-grad-blockers li {
  background: rgba(245,158,11,.08);
}
html[data-theme="dark"] .ap-grad-term-state.is-waiting {
  background: rgba(245,158,11,.14);
  color: #f5b760;
}
html[data-theme="dark"] .ap-grad-wait-text { color: #f5b760; }

/* Drawer table wrap */
html[data-theme="dark"] .ap-drawer-section .table-wrap {
  background: rgba(255,255,255,0.04);
  box-shadow: inset 2px 2px 5px rgba(0,0,0,0.2), inset -2px -2px 5px rgba(255,255,255,0.02);
}
html[data-theme="dark"] .ap-drawer-section .table-wrap th {
  background: rgba(255,255,255,0.04);
  border-bottom-color: rgba(255,255,255,0.06);
}
/* Drawer action buttons — neumorphic flip */
html[data-theme="dark"] .ap-drawer-actions .btn-outline-primary,
html[data-theme="dark"] .ap-drawer-actions a.btn-outline-primary {
  box-shadow: 3px 3px 7px rgba(0,0,0,0.4), -3px -3px 7px rgba(255,255,255,0.03);
}
html[data-theme="dark"] .ap-drawer-actions .btn-outline-primary:hover,
html[data-theme="dark"] .ap-drawer-actions a.btn-outline-primary:hover {
  box-shadow: inset 2px 2px 5px rgba(0,0,0,0.35), inset -2px -2px 5px rgba(12,170,130,0.08);
}
html[data-theme="dark"] .ap-drawer-actions .btn-export {
  background: #1a1e30;
  color: #e2e4ec;
  box-shadow: 3px 3px 7px rgba(0,0,0,0.4), -3px -3px 7px rgba(255,255,255,0.03);
}
html[data-theme="dark"] .ap-drawer-actions .btn-export:hover {
  box-shadow: inset 2px 2px 5px rgba(0,0,0,0.4), inset -2px -2px 5px rgba(255,255,255,0.03);
}

/* Batch bar */
html[data-theme="dark"] .ap-batch-bar {
  background: rgba(10,142,110,0.12);
  border-color: rgba(10,142,110,0.25);
  color: #5ee8b7;
}


/* ============================================================
   LOGIN — feature-specific styles
   ------------------------------------------------------------
   Moved out of core/templates/core/login.html.
   Scoped with body:has(.login-wrap) so these rules only affect
   the login page — prior version leaked body{display:flex} to
   every page and collapsed shell width on narrow-content screens.
   ============================================================ */

body:has(.login-wrap) {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; margin: 0;
    font-family: 'Inter', 'Noto Kufi Arabic', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  }
  .login-wrap {
    width: 100%; max-width: 420px; padding: 1.5rem;
    animation: login-fade-up 0.5s var(--ease) both;
    /* Its own layer above the fixed .color-mesh (z-index 0, an opaque gradient
       in dark). The page replaces the shell, which is what lifts every other
       page above the mesh; until now only the fade-in's leftover transform did
       it here, so with animations off the dark card, title and fields painted
       UNDER the mesh and the page showed an avatar and a button on black. */
    position: relative; z-index: 1;
    min-width: 0;
  }
  .telegram-link-wrap {
    max-width: 720px;
    box-sizing: border-box;
  }
  @keyframes login-fade-up {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* ─── The card ───
     The app's raised surface on the paper ground, like every other card. It was
     a cool blue-grey (#e4e9ed) neumorphic slab: the one off-palette screen, and
     the first one anybody sees. Colours come from tokens, so dark needs no
     override of its own. */
  .login-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 2.5rem 2rem 2rem;
    box-shadow: var(--shadow-card);
    overflow: hidden;
  }
  .telegram-link-card {
    width: 100%;
  }
  .telegram-link-card--result {
    max-width: 640px;
    margin-inline: auto;
  }

  /* ─── Avatar circle ─── */
  .login-avatar {
    width: 80px; height: 80px;
    border-radius: 50%;
    margin: 0 auto 1.5rem;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--teal), var(--sky), var(--royal));
    box-shadow: var(--shadow-sm), 0 0 0 6px var(--card);
    position: relative;
  }
  .login-avatar svg {
    width: 36px; height: 36px;
    stroke: #fff; stroke-width: 1.8;
    fill: none; stroke-linecap: round; stroke-linejoin: round;
  }

  /* ─── Title & subtitle ─── */
  /* The serif headline of every reading page's masthead. */
  .login-title {
    font-family: var(--font-serif);
    font-size: var(--text-display); font-weight: 400; line-height: 1.15;
    color: var(--t0); text-align: center;
    margin-bottom: 0.4rem;
  }
  .login-sub {
    font-size: var(--text-base); color: var(--t3);
    text-align: center; margin-bottom: 2rem;
  }
  /* "Staff sign in" and "Use a different ID" were the browser's link blue
     (rgb(0,0,238) on the card, rgb(158,158,255) in dark): the brand text colour */
  .login-sub a {
    color: var(--text-brand); font-weight: 600;
    text-decoration: underline; text-underline-offset: 3px;
  }
  .login-sub a:hover { color: var(--btn-primary-hover); }
  .login-sub a:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; border-radius: 3px; }

  /* ─── Field capsules: the app's field (outlined, the control edge, the large
     tier of the control ladder), not an inset neumorphic well ─── */
  .neu-input-group {
    display: flex; align-items: center; gap: 0.75rem;
    background: transparent;
    border-radius: var(--control-radius);
    min-height: var(--control-h-lg);
    padding: 0 var(--control-px-sm);
    box-shadow: inset 0 0 0 1px var(--control-edge);
    margin-bottom: 1rem;
    transition: box-shadow 0.25s var(--ease);
  }
  .neu-input-group:focus-within {
    box-shadow: inset 0 0 0 1px var(--teal), 0 0 0 2px var(--teal);
  }
  .neu-input-group .neu-icon {
    flex-shrink: 0;
    width: 20px; height: 20px;
    stroke: var(--t4); stroke-width: 2;
    fill: none; stroke-linecap: round; stroke-linejoin: round;
    transition: stroke 0.2s;
  }
  .neu-input-group:focus-within .neu-icon {
    stroke: var(--teal);
  }
  .neu-input-group input {
    flex: 1; min-width: 0;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
    background-color: transparent !important;
    padding: 0;
    align-self: stretch;
    font-size: var(--text-md); color: var(--t1);
    line-height: var(--control-lh);
    font-family: inherit;
  }
  .neu-input-group input:focus {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
  }
  /* Autofill: delay bg-color change forever so Chrome never paints it */
  .neu-input-group input:-webkit-autofill,
  .neu-input-group input:-webkit-autofill:hover,
  .neu-input-group input:-webkit-autofill:focus,
  .neu-input-group input:-webkit-autofill:active {
    -webkit-text-fill-color: var(--t1) !important;
    caret-color: var(--t1);
    transition: background-color 9999s ease-in-out 0s,
                color 9999s ease-in-out 0s !important;
  }
  .neu-input-group input::-ms-reveal,
  .neu-input-group input::-ms-clear,
  .neu-input-group input::-webkit-credentials-auto-fill-button {
    display: none !important;
  }
  .neu-input-group input::placeholder {
    color: var(--t4);
    -webkit-text-fill-color: var(--t4);
    opacity: 1;
  }

  /* ─── The sign-in button: the app's primary button at the large tier ─── */
  .neu-btn {
    width: 100%;
    border: none; outline: none; cursor: pointer;
    background: var(--btn-primary-bg);
    color: var(--btn-primary-ink);
    font-size: var(--text-md); font-weight: 600;
    font-family: inherit;
    line-height: var(--control-lh);
    min-height: var(--control-h-lg);
    padding: var(--space-2) var(--control-px);
    border-radius: var(--control-radius);
    margin-top: 0.5rem;
    box-shadow: none;
    transition: all 0.25s var(--ease);
    position: relative; overflow: hidden;
  }
  .neu-btn:hover {
    background: var(--btn-primary-hover);
  }
  .neu-btn:active {
    background: var(--btn-primary-hover);
    transform: translateY(0);
    box-shadow: inset 0 0 0 999px rgba(0,0,0,0.12);
  }

  /* ─── Divider dots ─── */
  .login-dots {
    display: flex; justify-content: center; gap: 6px;
    margin-bottom: 1.75rem;
  }
  .login-dots span {
    width: 6px; height: 6px; border-radius: 50%;
    background: linear-gradient(135deg, var(--teal), var(--sky), var(--royal));
    opacity: 0.5;
  }
  .login-dots span:nth-child(2) { opacity: 0.75; }
  .login-dots span:nth-child(3) { opacity: 1; }

  /* ─── Alert ─── */
  .login-alert {
    background: rgba(220, 53, 69, 0.08);
    color: var(--danger);
    border-radius: var(--radius); padding: 0.6rem 1rem;
    font-size: var(--text-base); margin-bottom: 1.25rem;
    text-align: center;
  }

  /* ─── Language select ─── */
  .login-lang {
    text-align: center; margin-top: 1.5rem;
  }
  .login-lang select {
    border: none; outline: none; cursor: pointer;
    background-color: transparent;
    border-radius: var(--control-radius);
    min-height: var(--control-h-sm);
    padding: 0 2rem 0 0.8rem;
    font-size: var(--text-sm); color: var(--t2);
    font-family: inherit;
    box-shadow: inset 0 0 0 1px var(--control-edge);
    transition: box-shadow 0.2s;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238492a6' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    background-size: 12px;
  }
  [dir="rtl"] .login-lang select {
    padding: 0 0.8rem 0 2rem;
    background-position: left 0.6rem center;
  }
  .login-lang select:focus {
    box-shadow: inset 0 0 0 1px var(--teal), 0 0 0 2px var(--teal);
  }

  /* ─── Password visibility toggle ─── */
  .pw-toggle {
    flex-shrink: 0;
    background: none; border: none; outline: none; cursor: pointer;
    color: var(--t4); padding: 4px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    transition: color 0.2s, background 0.2s;
  }
  .pw-toggle:hover { color: var(--text-brand); background: color-mix(in srgb, var(--teal) 8%, transparent); }
  .pw-toggle:focus-visible {
    outline: 2px solid var(--teal); outline-offset: 1px;
  }

  /* RTL needs no rule here: a flex row already starts at the right in Arabic, so
     the field icon leads and the password toggle trails, mirrored. (A
     row-reverse here pinned both icons to the left in Arabic.) */

  /* ─── Button loading state ─── */
  .neu-btn:disabled {
    opacity: 0.6; cursor: not-allowed;
    box-shadow: none;
  }

  /* ─── Login spinner ─── */
  .neu-btn-spinner {
    display: none;
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: neu-spin 0.6s linear infinite;
    vertical-align: middle;
  }
  .neu-btn.is-loading .neu-btn-spinner { display: inline-block; }
  .neu-btn.is-loading .neu-btn-text { opacity: 0.6; }
  @keyframes neu-spin { to { transform: rotate(360deg); } }

  /* ─── Better focus ring for login inputs ─── */
  .neu-input-group input:focus-visible {
    outline: none !important;
    box-shadow: none !important;
  }

  .neu-btn:focus-visible {
    outline: 2px solid var(--teal);
    outline-offset: 3px;
    box-shadow: 0 0 0 4px var(--brand-glow);
  }

  /* ─── Alert icon ─── */
  .login-alert {
    display: flex; align-items: center; gap: 0.5rem; justify-content: center;
  }
  .login-alert::before {
    content: ''; display: inline-block;
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--danger); box-shadow: 0 0 4px var(--danger);
    flex-shrink: 0;
  }

  /* ─── Student OTP resend cooldown ─── */
  .otp-resend-block {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid color-mix(in srgb, var(--t4) 18%, transparent);
    text-align: center;
  }
  .otp-resend-hint {
    margin: 0 0 0.7rem;
    color: var(--t4);
    font-size: var(--text-sm);
    line-height: 1.75;
  }
  .otp-resend-form { margin: 0; }
  .otp-resend-btn {
    margin-top: 0;
    background: transparent;
    color: var(--text-brand);
    border: 1px solid color-mix(in srgb, var(--teal) 45%, transparent);
    box-shadow: none;
    text-transform: none;
    letter-spacing: 0;
  }
  .otp-resend-btn:hover:not(:disabled) {
    color: var(--btn-primary-ink);
    background: var(--btn-primary-bg);
  }
  .otp-resend-btn:disabled {
    color: var(--t4);
    background: color-mix(in srgb, var(--t4) 5%, transparent);
  }
  .otp-resend-countdown {
    min-height: 1.45rem;
    margin: 0.55rem 0 0;
    color: var(--t4);
    font-size: var(--text-xs);
    line-height: 1.6;
  }
  .otp-request-limit {
    margin-top: 1rem;
    margin-bottom: 1.25rem;
    line-height: 1.75;
  }
  .otp-delivery-notice {
    line-height: 1.75;
  }

  /* (The card no longer lifts on hover: it is not a control.) */

  /* ─── Responsive: mobile ─── */
  @media (max-width: 480px) {
    .login-wrap { padding: 1rem; }
    .login-card { padding: 2rem 1.5rem 1.5rem; border-radius: var(--radius-lg); }
    .login-avatar { width: 64px; height: 64px; }
    .login-avatar svg { width: 28px; height: 28px; }
    .login-title { font-size: var(--text-xl); }
    .login-dots { margin-bottom: 1rem; }
  }
  @media (max-width: 360px) {
    .login-dots { display: none; }
  }

  /* ============================================================
     DARK MODE — Login page overrides
     ============================================================ */
  /* Scoped to the login page: unscoped, this painted the body of EVERY dark page
     (the dark body rule near the top now states the same --t0 ink itself). */
  html[data-theme="dark"] body:has(.login-wrap) {
    background: #0d0f1a !important;
    color: #e2e4ec !important;
  }

  /* The card, avatar ring, title, subtitle and field capsules take their dark
     values from the tokens (--card, --line, --t0, --t3, --control-edge). */
  html[data-theme="dark"] .neu-input-group .neu-icon {
    stroke: #a0a4b8;
  }
  html[data-theme="dark"] .neu-input-group input::placeholder {
    color: var(--t4);
    -webkit-text-fill-color: var(--t4);
  }
  html[data-theme="dark"] .neu-input-group input:-webkit-autofill,
  html[data-theme="dark"] .neu-input-group input:-webkit-autofill:hover,
  html[data-theme="dark"] .neu-input-group input:-webkit-autofill:focus,
  html[data-theme="dark"] .neu-input-group input:-webkit-autofill:active {
    -webkit-text-fill-color: #e2e4ec !important;
    caret-color: #e2e4ec;
  }


  html[data-theme="dark"] .login-dots span {
    opacity: 0.25;
  }
  html[data-theme="dark"] .login-dots span:nth-child(2) { opacity: 0.4; }
  html[data-theme="dark"] .login-dots span:nth-child(3) { opacity: 0.55; }

  html[data-theme="dark"] .login-alert {
    background: rgba(220, 53, 69, 0.15);
  }

  html[data-theme="dark"] .otp-resend-block {
    border-top-color: rgba(255,255,255,0.1);
  }
  html[data-theme="dark"] .otp-resend-btn {
    color: #5ee8b7;
    border-color: rgba(94,232,183,0.35);
  }
  html[data-theme="dark"] .otp-resend-btn:hover:not(:disabled) {
    color: var(--btn-primary-ink);
    background: var(--btn-primary-bg);
  }
  html[data-theme="dark"] .otp-resend-btn:disabled {
    color: var(--t4);
    background: rgba(255,255,255,0.025);
  }

  html[data-theme="dark"] .login-lang select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a0a4b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  }
  html[data-theme="dark"] .login-lang select option {
    background: #151826;
    color: #e2e4ec;
  }

  html[data-theme="dark"] .pw-toggle {
    color: #a0a4b8;
  }
  html[data-theme="dark"] .pw-toggle:hover {
    color: var(--text-brand);
    background: rgba(10,142,110,0.12);
  }

  /* ─── Login theme toggle button (bottom-right corner) ─── */
  .login-theme-toggle {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    width: 40px; height: 40px;
    border-radius: 50%;
    border: none; outline: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    background: var(--card);
    box-shadow: inset 0 0 0 1px var(--btn-neutral-border), var(--shadow-sm);
    color: var(--t3);
    transition: all 0.25s var(--ease);
    z-index: 100;
  }
  .login-theme-toggle:hover {
    color: var(--t1);
  }
  .login-theme-toggle:focus-visible {
    outline: 2px solid var(--teal);
    outline-offset: 3px;
  }
  [dir="rtl"] .login-theme-toggle {
    right: auto;
    left: 1.25rem;
  }
  html[data-theme="dark"] .login-theme-toggle {
    color: #a0a4b8;
  }
  html[data-theme="dark"] .login-theme-toggle:hover {
    color: #F5B731;
    background: rgba(255,255,255,0.1);
  }

  /* Icon visibility driven by theme */
  .login-theme-toggle .lt-icon-light { display: inline; }
  .login-theme-toggle .lt-icon-dark  { display: none; }
  html[data-theme="dark"] .login-theme-toggle .lt-icon-light { display: none; }
  html[data-theme="dark"] .login-theme-toggle .lt-icon-dark  { display: inline; }

/* ============================================================
   PROFILE — feature-specific styles
   ------------------------------------------------------------
   Moved out of core/templates/core/profile.html.
   ============================================================ */

/* ═══════════════════════════════════════════════════════════
   PROFILE PAGE — Self-service credential management
   ═══════════════════════════════════════════════════════════ */

.pf-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  max-width: 860px;
}
@media (max-width: 768px) {
  .pf-grid { grid-template-columns: 1fr; }
}

/* Profile info card */
.pf-info-card {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 1.25rem;
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,0.45);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: none;
  box-shadow: 5px 5px 14px rgba(163,177,198,0.28),
              -5px -5px 14px rgba(255,255,255,0.8);
  transition: box-shadow 0.25s var(--ease), transform 0.25s var(--ease);
}
.pf-info-card:hover {
  box-shadow: 7px 7px 18px rgba(163,177,198,0.35),
              -7px -7px 18px rgba(255,255,255,0.9);
}
.pf-avatar {
  width: 64px; height: 64px; border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--btn-primary-bg), var(--btn-primary-hover));
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-xl); font-weight: 700; color: var(--btn-primary-ink);
  letter-spacing: 0.02em; flex-shrink: 0;
}
.pf-details { flex: 1; min-width: 0; }
.pf-username {
  font-size: var(--text-lg); font-weight: 700; color: var(--ink);
  margin-bottom: 0.2rem; word-break: break-word;
}
.pf-meta { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.pf-badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.18rem 0.6rem; border-radius: var(--radius-pill);
  font-size: var(--text-micro); font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pf-badge-role { background: #ecf9f4; color: var(--text-brand); border: 1px solid #a8e6d4; }
.pf-badge-dept { background: #eef2ff; color: #3b3fa0; border: 1px solid #c7d2fe; }

/* Form cards */
.pf-card {
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,0.45);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: none;
  box-shadow: 5px 5px 14px rgba(163,177,198,0.28),
              -5px -5px 14px rgba(255,255,255,0.8);
  transition: box-shadow 0.25s var(--ease), border-color 0.25s var(--ease);
}
.pf-card:hover {
  box-shadow: 7px 7px 18px rgba(163,177,198,0.35),
              -7px -7px 18px rgba(255,255,255,0.9);
}
/* .pf-card-title base styling handled by canonical card-heading rule.
   Only the inline icon size lives here. */
.pf-card-title .i { width: 18px; height: 18px; color: var(--muted); }

.pf-field { margin-bottom: 0.85rem; }
.pf-field:last-of-type { margin-bottom: 1rem; }
.pf-label {
  display: block; font-size: var(--text-xs); font-weight: 600;
  color: var(--muted); margin-bottom: 0.3rem;
  letter-spacing: 0.03em;
}
.pf-input {
  width: 100%; box-sizing: border-box; padding: 0.6rem 0.85rem;
  border-radius: var(--radius-md); border: none;
  background: transparent;
  font-size: var(--text-base); color: var(--ink);
  font-family: inherit;
  box-shadow: inset 0 0 0 1px var(--control-edge),
              inset 3px 3px 6px rgba(163,177,198,0.35),
              inset -3px -3px 6px rgba(255,255,255,0.9);
  transition: box-shadow 0.2s var(--ease);
  outline: none;
}
.pf-input:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--teal),
              inset 3px 3px 6px rgba(163,177,198,0.35),
              inset -3px -3px 6px rgba(255,255,255,0.9),
              0 0 0 2px var(--teal);
}
.pf-input::placeholder { color: var(--muted-light); }

/* Password field wrapper — border lives on the wrapper so the eye
   toggle sits visually *inside* the rounded container. */
.pf-pwd-wrap {
  position: relative;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--control-edge),
              inset 3px 3px 6px rgba(163,177,198,0.35),
              inset -3px -3px 6px rgba(255,255,255,0.9);
  transition: box-shadow 0.2s var(--ease);
}
.pf-pwd-wrap:focus-within {
  box-shadow: inset 0 0 0 1px var(--teal),
              inset 3px 3px 6px rgba(163,177,198,0.35),
              inset -3px -3px 6px rgba(255,255,255,0.9),
              0 0 0 2px var(--teal);
}
.pf-pwd-wrap .pf-input {
  padding-inline-end: 2.5rem;
  border: none; background: transparent;
  box-shadow: none;
}
.pf-pwd-wrap .pf-input:focus { outline: none; box-shadow: none; }
.pf-pwd-toggle {
  position: absolute; inset-inline-end: 0.5rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; padding: 0.25rem;
  color: var(--muted); border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  transition: color 0.15s;
}
.pf-pwd-toggle:hover { color: var(--ink); }
.pf-pwd-toggle .i { width: 18px; height: 18px; }
.pf-pwd-toggle .pf-eye-off { display: none; }
.pf-pwd-toggle.showing .pf-eye-on  { display: none; }
.pf-pwd-toggle.showing .pf-eye-off { display: block; }

.pf-hint {
  font-size: var(--text-micro); color: var(--muted-light);
  margin-top: 0.25rem;
}

.pf-submit {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.55rem 1.5rem; border-radius: var(--radius-md); border: none;
  font-size: var(--text-sm); font-weight: 700; cursor: pointer;
  transition: all 0.2s var(--ease);
  box-shadow: var(--shadow-neu-sm);
}
.pf-submit:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.pf-submit-primary {
  background: var(--btn-primary-bg); color: var(--btn-primary-ink);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--teal) 25%, transparent);
}
.pf-submit-primary:hover {
  background: var(--btn-primary-hover); color: var(--btn-primary-ink);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--teal) 35%, transparent);
}
.pf-submit-primary:active {
  background: var(--btn-primary-hover); color: var(--btn-primary-ink);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);
}
.pf-submit-primary:disabled {
  opacity: 0.5; cursor: not-allowed; color: #fff;
  box-shadow: 2px 2px 5px rgba(163,177,198,0.15),
              -2px -2px 5px rgba(255,255,255,0.5);
}

.pf-submit .pf-spinner {
  display: none; width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff; border-radius: 50%;
  animation: pf-spin 0.6s linear infinite;
}
.pf-submit.loading .pf-spinner { display: inline-block; }
.pf-submit.loading .pf-btn-text { opacity: 0.7; }

@keyframes pf-spin { to { transform: rotate(360deg); } }

/* Success animation */
.pf-card.pf-saved {
  animation: pf-flash 0.6s var(--ease);
}
@keyframes pf-flash {
  0% { box-shadow: 5px 5px 14px rgba(163,177,198,0.28), -5px -5px 14px rgba(255,255,255,0.8); }
  40% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 20%, transparent), 5px 5px 14px rgba(163,177,198,0.28), -5px -5px 14px rgba(255,255,255,0.8); }
  100% { box-shadow: 5px 5px 14px rgba(163,177,198,0.28), -5px -5px 14px rgba(255,255,255,0.8); }
}

/* ── Password strength indicator ── */
.pf-pw-strength {
  margin-top: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.pf-pw-bar-track {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--pl-overlay-4);
  overflow: hidden;
}
.pf-pw-bar {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  transition: width 0.3s var(--ease), background 0.3s var(--ease);
  background: var(--danger);
}
.pf-pw-bar[data-level="1"] { width: 25%; background: var(--danger); }
.pf-pw-bar[data-level="2"] { width: 50%; background: #dd6b20; }
.pf-pw-bar[data-level="3"] { width: 75%; background: var(--warning); }
.pf-pw-bar[data-level="4"] { width: 100%; background: var(--success); }
.pf-pw-label {
  font-size: var(--text-micro);
  font-weight: 600;
  min-width: 3rem;
  color: var(--muted-light);
  text-align: end;
}

/* ═══════════════════════════════════════════════════════════
   DARK MODE — Deep Navy overrides
   html[data-theme="dark"]
   ═══════════════════════════════════════════════════════════ */

/* Info card + form cards: glass bg → dark glass, neumorphic → dark shadows */
html[data-theme="dark"] .pf-info-card {
  background: rgba(255,255,255,0.04);
  box-shadow: 5px 5px 14px rgba(0,0,0,0.4),
              -5px -5px 14px rgba(255,255,255,0.02);
}
html[data-theme="dark"] .pf-info-card:hover {
  box-shadow: 7px 7px 18px rgba(0,0,0,0.5),
              -7px -7px 18px rgba(255,255,255,0.03);
}

html[data-theme="dark"] .pf-card {
  background: rgba(255,255,255,0.04);
  box-shadow: 5px 5px 14px rgba(0,0,0,0.4),
              -5px -5px 14px rgba(255,255,255,0.02);
}
html[data-theme="dark"] .pf-card:hover {
  box-shadow: 7px 7px 18px rgba(0,0,0,0.5),
              -7px -7px 18px rgba(255,255,255,0.03);
}

/* Badge backgrounds */
html[data-theme="dark"] .pf-badge-role {
  background: rgba(10,142,110,0.12);
  color: #2ec9a0;
  border-color: rgba(10,142,110,0.25);
}
html[data-theme="dark"] .pf-badge-dept {
  background: rgba(64,86,227,0.12);
  color: #8b9cf7;
  border-color: rgba(64,86,227,0.25);
}

/* Inputs: inset neumorphic → dark inset shadows */
html[data-theme="dark"] .pf-input {
  color: #e2e4ec;
  box-shadow: inset 0 0 0 1px var(--control-edge),
              inset 3px 3px 6px rgba(0,0,0,0.45),
              inset -3px -3px 6px rgba(255,255,255,0.03);
}
html[data-theme="dark"] .pf-input:focus {
  box-shadow: inset 0 0 0 1px var(--teal),
              inset 3px 3px 6px rgba(0,0,0,0.45),
              inset -3px -3px 6px rgba(255,255,255,0.03),
              0 0 0 2px var(--teal);
}
html[data-theme="dark"] .pf-input::placeholder {
  color: var(--t4);
}

/* Password field wrapper: inset neumorphic → dark inset shadows */
html[data-theme="dark"] .pf-pwd-wrap {
  box-shadow: inset 0 0 0 1px var(--control-edge),
              inset 3px 3px 6px rgba(0,0,0,0.45),
              inset -3px -3px 6px rgba(255,255,255,0.03);
}
html[data-theme="dark"] .pf-pwd-wrap:focus-within {
  box-shadow: inset 0 0 0 1px var(--teal),
              inset 3px 3px 6px rgba(0,0,0,0.45),
              inset -3px -3px 6px rgba(255,255,255,0.03),
              0 0 0 2px var(--teal);
}

/* Disabled submit button shadow */
html[data-theme="dark"] .pf-submit-primary:disabled {
  box-shadow: 2px 2px 5px rgba(0,0,0,0.3),
              -2px -2px 5px rgba(255,255,255,0.02);
}

/* Password strength bar track */
/* Saved flash animation — dark neumorphic variant */
html[data-theme="dark"] .pf-card.pf-saved {
  animation: pf-flash-dark 0.6s ease;
}
@keyframes pf-flash-dark {
  0%  { box-shadow: 5px 5px 14px rgba(0,0,0,0.4), -5px -5px 14px rgba(255,255,255,0.02); }
  40% { box-shadow: 0 0 0 3px rgba(12,168,126,0.25), 5px 5px 14px rgba(0,0,0,0.4), -5px -5px 14px rgba(255,255,255,0.02); }
  100%{ box-shadow: 5px 5px 14px rgba(0,0,0,0.4), -5px -5px 14px rgba(255,255,255,0.02); }
}

/* ============================================================
   USER MANAGEMENT — feature-specific styles
   ------------------------------------------------------------
   Moved out of core/templates/core/user_management.html.
   ============================================================ */

/* ── Page-specific styles ─────────────────────────────────── */

/* Stats bar */
.um-stats { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.um-stat {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.35rem 0.75rem; border-radius: var(--radius-pill);
  font-size: var(--text-sm); font-weight: 700;
  border: var(--border-subtle);
  background: var(--glass-bg); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
}
.um-stat .um-stat-n {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  color: var(--ink);
}
.um-stat-total { border-color: #a8e6d4; background: #ecf9f4; color: #045a3e; }
.um-stat-super { border-color: var(--pl-conflict-cell); background: #fff5f5; color: #991b1b; }
.um-stat-gen { border-color: #fed7aa; background: #fff7ed; color: #9a3412; }
.um-stat-adv { border-color: #a8e6d4; background: #ecf9f4; color: #056748; }
.um-stat-off { border-color: #e5e7eb; background: #f9fafb; color: #6b7280; }

/* Toolbar */
.um-toolbar {
  display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center;
  margin-bottom: 0.75rem;
}
.um-toolbar .um-search {
  flex: 1; min-width: 200px; max-width: 360px;
}
.um-toolbar .um-search input {
  padding-inline-start: 2.4rem !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242.156a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 0.75rem center;
  background-size: 14px;
}
[dir="rtl"] .um-toolbar .um-search input {
  background-position: calc(100% - 0.75rem) center;
  padding-inline-start: 2.4rem !important;
}

/* Table enhancements */
#umTable { border-collapse: separate; border-spacing: 0; }
#umTable thead th {
  padding: 6px 10px; font-size: var(--text-micro); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); white-space: nowrap;
  border-bottom: 2px solid var(--line);
  background: var(--glass-bg-header);
}
@media (max-width: 768px) {
  /* A phone keeps the columns an admin acts on (select, user, role, status,
     actions); the status toggle and the row actions were past the screen's
     edge. Hidden: advisor id, departments, last login, created. The indices
     follow the <thead> in user_management.html. */
  #umTable :is(th, td):is(:nth-child(4), :nth-child(5), :nth-child(7), :nth-child(8)) { display: none; }
}
#umTable tbody td {
  padding: 5px 10px; font-size: var(--text-sm);
  vertical-align: middle; border-bottom: 1px solid rgba(0,0,0,0.04);
}
#umTable tbody tr { cursor: pointer; transition: background 0.1s, box-shadow 0.1s; }
#umTable tbody tr:hover td { background: rgba(0,0,0,0.015); }
#umTable tbody tr.um-selected td { background: color-mix(in srgb, var(--teal) 4%, transparent) !important; }
#umTable tbody tr.um-selected { box-shadow: inset 3px 0 0 var(--teal); }
[dir="rtl"] #umTable tbody tr.um-selected { box-shadow: inset -3px 0 0 var(--brand); }

/* Role badges — compact inline pills */
.um-role-badge {
  display: inline-block; padding: 2px 8px;
  border-radius: var(--radius-xs); font-size: var(--text-micro); font-weight: 700;
  letter-spacing: 0.03em; text-transform: uppercase;
  line-height: 1.4; white-space: nowrap;
}
.um-role-super { background: #fff1f2; color: #be123c; border: 1px solid #fecdd3; }
.um-role-gen { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.um-role-adv { background: #ecf9f4; color: var(--text-brand); border: 1px solid #a8e6d4; }

/* Status — compact dot + label */
.um-active-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: var(--radius-xs);
  font-size: var(--text-micro); font-weight: 600; cursor: pointer;
  transition: all 0.12s; line-height: 1.4; white-space: nowrap;
}
.um-active-badge:hover { filter: brightness(0.95); }
.um-active-badge[role="button"] { user-select: none; }
.um-active-badge:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.um-active-on { background: #dcfce7; color: #15803d; }
.um-active-off { background: #fee2e2; color: var(--pl-danger-text); }

/* Row actions — always visible, compact icons */
.um-row-actions { display: inline-flex; gap: 2px; }
.um-row-btn {
  /* 32px: the 26px square was the whole hit area, three to a row */
  width: 32px; height: 32px; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: transparent; cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center;
  color: var(--t4); transition: all 0.1s; padding: 0;
}
.um-row-btn:hover { background: #f1f5f9; color: var(--ink); border-color: var(--line); }
.um-row-btn.um-btn-edit:hover { color: var(--text-brand); background: var(--brand-soft); border-color: #a8e6d4; }
.um-row-btn.um-btn-key:hover { color: var(--sev-warning); background: #fffbeb; border-color: #fde68a; }
.um-row-btn.um-btn-del:hover { color: #dc2626; background: #fff5f5; border-color: var(--pl-conflict-cell); }

/* Empty cell — subtle muted dash */
.um-empty-cell { color: var(--t4); font-size: var(--text-xs); }

/* Panels: Create & Edit */
.um-panel {
  border: var(--border-subtle); border-radius: var(--radius);
  background: var(--glass-bg); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  padding: 1rem 1.25rem; margin-bottom: 1rem;
  transition: box-shadow 0.15s;
}
.um-panel:hover { box-shadow: var(--shadow-card); }
.um-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.75rem;
}
/* .um-panel-title visual now handled by the canonical card-heading rule.
   Keep the ::before shape definition here so state variants (.edit / .danger)
   render the colored prefix. The default base is hidden via the canonical rule. */
.um-panel-title::before {
  content: ""; width: 3px; height: 0.8rem;
  border-radius: 2px; background: var(--brand); opacity: 0.6;
}
.um-panel-title.edit::before { background: #f59e0b; }
.um-panel-title.danger::before { background: var(--danger); }

/* Create panel — compact single-row form */
.um-create-row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: nowrap; }
.um-create-row .um-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.um-create-row .um-field label {
  font-size: var(--text-micro); font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted); white-space: nowrap;
}
/* Inherit project form-control / form-select styles; only override size for compact row */
.um-create-row .um-field .form-control,
.um-create-row .um-field .form-select {
  height: 36px; min-height: 36px !important;
  padding: 0.3rem 0.85rem !important;
  font-size: var(--text-sm) !important;
  width: 100%;
}
.um-create-row .um-field-user { flex: 1.2; }
.um-create-row .um-field-pw { flex: 1.4; }
.um-create-row .um-field-role { flex: 1; }
.um-create-row .um-field-scope { flex: 0.9; }
.um-pw-wrap { display: flex; gap: 0; }
/* The field and its Generate button are one capsule: logical corners and
   edges, so in Arabic the button closes it on the left (stage 3, SW-27). */
.um-pw-wrap .form-control {
  border-start-start-radius: var(--radius-lg) !important; border-end-start-radius: var(--radius-lg) !important;
  border-start-end-radius: 0 !important; border-end-end-radius: 0 !important;
  border-inline-end: none !important;
}
.um-pw-wrap .um-gen-pw {
  height: 36px;
  border-radius: 0; border-start-end-radius: var(--radius-lg); border-end-end-radius: var(--radius-lg);
  border: 1px solid rgba(17,17,68,0.07); border-inline-start: none;
  padding: 0 12px; white-space: nowrap;
  font-size: var(--text-micro); font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.03em; background: var(--glass-bg); color: var(--muted);
  cursor: pointer; transition: all 0.12s; display: flex; align-items: center; gap: 4px;
  box-shadow: inset -4px 0 8px rgba(163,177,198,0.15);
}
[dir="rtl"] .um-pw-wrap .um-gen-pw { box-shadow: inset 4px 0 8px rgba(163,177,198,0.15); }
.um-pw-wrap .um-gen-pw:hover { background: var(--card); color: var(--text-brand); border-color: var(--brand); }
.um-create-btn {
  height: 36px; padding: 0 20px; border: none; border-radius: var(--radius-sm);
  background: var(--btn-primary-bg); color: var(--btn-primary-ink); font-size: var(--text-sm);
  font-weight: 700; cursor: pointer; white-space: nowrap;
  transition: background 0.12s, transform 0.1s; flex-shrink: 0;
  box-shadow: 2px 2px 6px color-mix(in srgb, var(--teal) 20%, transparent), -1px -1px 4px rgba(255,255,255,0.7);
}
.um-create-btn:hover { background: var(--btn-primary-hover); }
.um-create-btn:active { transform: scale(0.97); }
@media (max-width: 768px) {
  .um-create-row { flex-wrap: wrap; }
  .um-create-row .um-field { flex: 1 1 calc(50% - 6px); min-width: 120px; }
  .um-create-btn { width: 100%; margin-top: 4px; }
}

/* Edit panel highlight */
.um-panel-edit { border-color: var(--teal-border); background: var(--brand-soft); }
.um-panel-edit .um-edit-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.um-panel-edit .um-editing-user {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.25rem 0.6rem; border-radius: var(--radius);
  background: var(--brand-soft); border: 1px solid var(--teal-border);
  font-size: var(--text-sm); font-weight: 600; color: var(--brand-dark);
}
.um-panel-edit .um-close-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: var(--radius); font-size: var(--text-xs);
  font-weight: 600; border: 1px solid var(--line);
  background: var(--glass-bg); color: var(--muted); cursor: pointer;
  transition: all 0.12s;
}
.um-panel-edit .um-close-btn:hover { border-color: var(--danger); color: var(--danger); background: var(--card); }

/* Edit row — compact single-line like create panel */
.um-edit-row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: nowrap; }
.um-edit-row .um-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.um-edit-row .um-field label {
  font-size: var(--text-micro); font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted); white-space: nowrap;
}
.um-edit-row .um-field .form-control,
.um-edit-row .um-field .form-select {
  height: 36px; min-height: 36px !important;
  padding: 0.3rem 0.85rem !important;
  font-size: var(--text-sm) !important;
  width: 100%;
}
.um-edit-row .um-field-role { flex: 1; }
.um-edit-row .um-field-scope { flex: 0.9; }
.um-edit-row .um-edit-actions {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
  padding-bottom: 1px;
}
.um-edit-row .um-edit-actions .um-act-btn {
  height: 36px; padding: 0 14px; border: none; border-radius: var(--radius-sm);
  font-size: var(--text-xs); font-weight: 700; cursor: pointer;
  white-space: nowrap; transition: all 0.12s; display: inline-flex;
  align-items: center; gap: 5px;
}
.um-act-btn.um-act-save {
  background: var(--btn-primary-bg); color: var(--btn-primary-ink);
  box-shadow: 2px 2px 6px color-mix(in srgb, var(--teal) 20%, transparent), -1px -1px 4px rgba(255,255,255,0.7);
}
.um-act-btn.um-act-save:hover { background: var(--btn-primary-hover); }
.um-act-btn.um-act-reset {
  background: rgba(255,255,255,0.7); color: #92610a;
  border: 1px solid rgba(217,170,67,0.3) !important;
  box-shadow: inset 2px 2px 4px rgba(163,177,198,0.15), inset -2px -2px 4px rgba(255,255,255,0.6);
}
.um-act-btn.um-act-reset:hover { background: #fffbeb; border-color: #d9aa43 !important; }
.um-act-btn.um-act-delete {
  background: rgba(255,255,255,0.7); color: var(--pl-danger-text);
  border: 1px solid rgba(239,68,68,0.2) !important;
  box-shadow: inset 2px 2px 4px rgba(163,177,198,0.15), inset -2px -2px 4px rgba(255,255,255,0.6);
}
.um-act-btn.um-act-delete:hover { background: #fef2f2; border-color: #ef4444 !important; }
@media (max-width: 768px) {
  .um-edit-row { flex-wrap: wrap; }
  .um-edit-row .um-field { flex: 1 1 calc(50% - 6px); min-width: 120px; }
  .um-edit-row .um-edit-actions { width: 100%; justify-content: stretch; }
  .um-edit-row .um-edit-actions .um-act-btn { flex: 1; justify-content: center; }
}

/* (Bulk bar styles moved to fixed-bottom .bulk-bar below) */

/* ── Fixed-bottom floating bulk action bar ─────────────────── */
.bulk-bar {
  /* A floating panel inside the content column. It was full width from edge to
     edge, so when it rose it covered the sidebar, with square corners and a
     translucent white that read as a second footer. */
  position: fixed; bottom: 12px; z-index: 900;
  inset-inline: calc(var(--sb-w) + 16px) 16px;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lift);
  /* parked below the viewport, margin included */
  transform: translateY(calc(100% + 24px));
  transition: transform 0.25s var(--ease);
}
.bulk-bar.visible { transform: translateY(0); }
/* The page's entry animation holds a transform on .content-wrap, which made it the
   containing block of this "fixed" bar: it sat at the foot of the page, under the
   footer, instead of the window. This page does not animate in. */
.content-wrap:has(#bulkBar) { animation: none; }
.bulk-bar .bulk-count { font-weight: 600; color: var(--text-brand); }
.bulk-bar button {
  border-radius: var(--radius); padding: 6px 16px; font-size: var(--text-sm);
  font-weight: 600;
  border: 1px solid var(--line); cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}
.bulk-bar button:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
/* the severity vocabulary, so both themes take the pair that passes (the old
   fixed greens and reds were hand-picked for light and re-picked for dark) */
.bulk-bar .bulk-deactivate {
  /* 7% of the ink over the card: --sev-critical-bg (12% in dark) left the label at 4.4:1 */
  background: color-mix(in srgb, var(--sev-critical) 7%, var(--card)); color: var(--sev-critical);
  border-color: color-mix(in srgb, var(--sev-critical) 45%, transparent);
}
.bulk-bar .bulk-deactivate:hover { background: color-mix(in srgb, var(--sev-critical) 18%, transparent); }
.bulk-bar .bulk-activate {
  background: var(--sev-ok-bg); color: var(--sev-ok);
  border-color: color-mix(in srgb, var(--sev-ok) 45%, transparent);
}
.bulk-bar .bulk-activate:hover { background: color-mix(in srgb, var(--sev-ok) 18%, transparent); }
.bulk-bar .bulk-cancel { background: transparent; color: var(--t2); border-color: var(--control-edge); }
.bulk-bar .bulk-cancel:hover { background: var(--btn-neutral-bg); }

/* Subtle time display */
.um-time { font-size: var(--text-xs); color: var(--muted); white-space: nowrap; }
.um-time-never { font-size: var(--text-xs); color: var(--t4); font-style: italic; }

/* Checkbox in table */
#umTable .um-check { width: 17px; height: 17px; cursor: pointer; accent-color: var(--brand); }

/* Empty state */
.um-empty { text-align: center; padding: 2.5rem 1.5rem; color: var(--t4); }
.um-empty-icon { display: block; font-size: 2.2rem; margin-bottom: 0.5rem; opacity: 0.6; }
.um-empty-title { font-weight: 600; font-size: var(--text-base); color: var(--t4); margin-bottom: 0.3rem; }
.um-empty-hint { font-size: var(--text-sm); color: var(--t4); }

/* Scope fields fade animation */
.um-scope-field { transition: opacity 0.2s, max-height 0.25s; overflow: hidden; }
.um-scope-field.hidden { opacity: 0; max-height: 0; padding: 0; margin: 0; }

/* Subtle alternating rows */
#umTable tbody tr:nth-child(even) td { background: rgba(0,0,0,0.012); }
#umTable tbody tr:hover td { background: rgba(0,0,0,0.025) !important; }

/* ── Dark mode overrides (Deep Navy) ───────────────────── */
html[data-theme="dark"] .um-stat-total  { border-color: rgba(10,142,110,0.3); background: rgba(10,142,110,0.12); color: #5ee8ba; }
html[data-theme="dark"] .um-stat-super  { border-color: rgba(239,68,68,0.25); background: rgba(239,68,68,0.10); color: #f87171; }
html[data-theme="dark"] .um-stat-gen    { border-color: rgba(249,115,22,0.25); background: rgba(249,115,22,0.10); color: #fb923c; }
html[data-theme="dark"] .um-stat-adv    { border-color: rgba(10,142,110,0.3); background: rgba(10,142,110,0.12); color: #34d399; }
html[data-theme="dark"] .um-stat-off    { border-color: rgba(255,255,255,0.08); background: rgba(255,255,255,0.04); color: #a0a4b8; }
html[data-theme="dark"] .um-stat .um-stat-n { color: #e2e4ec; }

html[data-theme="dark"] #umTable thead th {
  background: rgba(255,255,255,0.04);
  color: #a0a4b8;
  border-bottom-color: rgba(255,255,255,0.06);
}html[data-theme="dark"] #umTable tbody tr:nth-child(even) td { background: rgba(255,255,255,0.015); }
html[data-theme="dark"] #umTable tbody tr:hover td { background: rgba(255,255,255,0.04) !important; }
html[data-theme="dark"] #umTable tbody tr.um-selected td { background: rgba(10,142,110,0.08) !important; }

html[data-theme="dark"] .um-role-super { background: rgba(190,18,60,0.12); color: #f87171; border-color: rgba(190,18,60,0.25); }
html[data-theme="dark"] .um-role-gen   { background: rgba(194,65,12,0.12); color: #fb923c; border-color: rgba(194,65,12,0.25); }
html[data-theme="dark"] .um-role-adv   { background: rgba(10,142,110,0.12); color: #34d399; border-color: rgba(10,142,110,0.25); }

html[data-theme="dark"] .um-active-on  { background: rgba(22,163,74,0.15); color: #4ade80; }
html[data-theme="dark"] .um-active-off { background: rgba(185,28,28,0.15); color: #f87171; }

html[data-theme="dark"] .um-row-btn { color: #a0a4b8; }
html[data-theme="dark"] .um-row-btn:hover { background: rgba(255,255,255,0.06); color: #e2e4ec; border-color: rgba(255,255,255,0.08); }
html[data-theme="dark"] .um-row-btn.um-btn-edit:hover { color: var(--text-brand); background: rgba(10,142,110,0.10); border-color: rgba(10,142,110,0.25); }
html[data-theme="dark"] .um-row-btn.um-btn-key:hover  { color: #fbbf24; background: rgba(217,119,6,0.10); border-color: rgba(217,119,6,0.25); }
html[data-theme="dark"] .um-row-btn.um-btn-del:hover  { color: #f87171; background: rgba(220,38,38,0.10); border-color: rgba(220,38,38,0.25); }

html[data-theme="dark"] .um-empty { color: #a0a4b8; }
html[data-theme="dark"] .um-empty-icon { opacity: 0.5; }
html[data-theme="dark"] .um-empty-title { color: #c0c4d4; }
html[data-theme="dark"] .um-empty-hint { color: #a0a4b8; }
html[data-theme="dark"] .um-empty-cell { color: var(--t4); }

html[data-theme="dark"] .um-panel-edit {
  border-color: rgba(10,142,110,0.25);
  background: rgba(10,142,110,0.04);
}
html[data-theme="dark"] .um-panel-edit .um-editing-user {
  background: rgba(10,142,110,0.10);
  border-color: rgba(10,142,110,0.25);
  color: #34d399;
}
html[data-theme="dark"] .um-panel-edit .um-close-btn {
  background: rgba(255,255,255,0.04);
  color: #a0a4b8;
  border-color: rgba(255,255,255,0.08);
}
html[data-theme="dark"] .um-panel-edit .um-close-btn:hover {
  background: rgba(220,38,38,0.08);
  color: #f87171;
  border-color: rgba(220,38,38,0.2);
}

html[data-theme="dark"] .um-act-btn.um-act-reset {
  background: rgba(255,255,255,0.04);
  color: #fbbf24;
  border-color: rgba(217,170,67,0.2) !important;
  box-shadow: none;
}
html[data-theme="dark"] .um-act-btn.um-act-reset:hover { background: rgba(217,119,6,0.10); }
html[data-theme="dark"] .um-act-btn.um-act-delete {
  background: rgba(255,255,255,0.04);
  color: #f87171;
  border-color: rgba(239,68,68,0.2) !important;
  box-shadow: none;
}
html[data-theme="dark"] .um-act-btn.um-act-delete:hover { background: rgba(220,38,38,0.10); }

html[data-theme="dark"] .um-pw-wrap .um-gen-pw {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.06);
  color: #a0a4b8;
  box-shadow: none;
}
html[data-theme="dark"] .um-pw-wrap .um-gen-pw:hover { background: rgba(255,255,255,0.08); color: var(--text-brand); border-color: rgba(10,142,110,0.3); }

/* (the dark bulk bar needs no overrides: --card, --line-strong and the severity
   tokens are the dark values) */

html[data-theme="dark"] .um-time { color: #a0a4b8; }
html[data-theme="dark"] .um-time-never { color: var(--t4); }

html[data-theme="dark"] .um-create-btn {
  box-shadow: 2px 2px 6px rgba(0,0,0,0.3), -1px -1px 4px rgba(255,255,255,0.03);
}
html[data-theme="dark"] .um-act-btn.um-act-save {
  box-shadow: 2px 2px 6px rgba(0,0,0,0.3), -1px -1px 4px rgba(255,255,255,0.03);
}

/* Virtual Advisor */
.va-shell {
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.va-side,
.va-chat,
.va-panel {
  min-width: 0;
}

.va-side {
  display: grid;
  gap: 0.9rem;
  align-content: start;
}

.va-panel,
.va-chat {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.va-panel {
  padding: 1rem;
  overflow: hidden;
}

.va-panel-head,
.va-chat-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.8rem;
}

.va-kicker {
  font-size: var(--text-micro);
}

.va-panel h2,
.va-chat h2 {
  margin: 0.1rem 0 0;
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--t1);
}

.va-status {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 0.35rem 0.55rem;
  color: var(--t3);
  font-size: var(--text-sm);
  margin-bottom: 0.8rem;
}

.va-status-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 3px rgba(217,119,6,0.12);
}

.va-status.is-ok .va-status-dot {
  background: var(--teal);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 14%, transparent);
}

.va-status.is-bad .va-status-dot {
  background: #dc2626;
  box-shadow: 0 0 0 3px rgba(220,38,38,0.12);
}

.va-runtime {
  display: grid;
  gap: 0.45rem;
  margin: 0 0 0.9rem;
}

.va-runtime div,
.va-context-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 0.35rem;
}

.va-runtime dt,
.va-context-row span {
  color: var(--t4);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.va-runtime dd,
.va-context-row strong {
  margin: 0;
  color: var(--t2);
  font-size: var(--text-sm);
  text-align: end;
  overflow-wrap: anywhere;
}

.va-label {
  display: block;
  color: var(--t3);
  font-size: var(--text-sm);
  font-weight: 700;
  margin: 0.65rem 0 0.28rem;
}

.va-input,
.va-composer textarea {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  /* the shared control edge (3:1+), not --line (1.2:1): the field was the
     faintest thing in its panel */
  border: 1px solid var(--control-edge);
  background: var(--surface);
  color: var(--t1);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
  outline: none;
}

.va-input:focus,
.va-composer textarea:focus {
  border-color: color-mix(in srgb, var(--teal) 55%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 11%, transparent);
}

.va-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.va-grid-2 > div {
  min-width: 0;
}

.va-context-card {
  margin-top: 0.9rem;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--brand) 7%, transparent);
  color: var(--t3);
  font-size: var(--text-sm);
  display: grid;
  gap: 0.35rem;
}

.va-examples {
  display: grid;
  gap: 0.45rem;
}

.va-examples button {
  min-width: 0;
  /* `left` strands Arabic labels against the wrong edge while every neighbouring
     control is start-aligned. */
  text-align: start;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--t2);
  padding: 0.62rem 0.7rem;
  font-weight: 700;
}

.va-examples button:hover {
  border-color: color-mix(in srgb, var(--teal) 45%, transparent);
  color: var(--text-brand);
}

.va-chat {
  display: grid;
  grid-template-rows: auto minmax(420px, 1fr) auto;
  grid-column: 2;
  grid-row: 1 / span 3;
  overflow: hidden;
}

.va-prompt-panel {
  grid-column: 1;
}

.va-results-panel {
  grid-column: 1;
}

.va-tool-results {
  display: grid;
  gap: 0.75rem;
  color: var(--t3);
  font-size: var(--text-sm);
}

.va-tool-card {
  display: grid;
  gap: 0.7rem;
}

.va-tool-loading {
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  color: var(--t3);
}

.va-tool-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.va-tool-card-head span {
  color: var(--text-brand);
  font-size: var(--text-micro);
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.va-tool-card-head strong {
  color: var(--t2);
  font-size: var(--text-sm);
}

.va-tool-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}

.va-tool-summary span,
.va-tool-meta span {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--t3);
  padding: 0.55rem 0.6rem;
}

.va-tool-summary b {
  display: block;
  color: var(--t1);
  font-size: var(--text-md);
}

.va-tool-meta {
  display: grid;
  gap: 0.45rem;
}

.va-tool-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.va-tool-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
  font-size: var(--text-sm);
}

.va-tool-table th,
.va-tool-table td {
  padding: 0.48rem 0.55rem;
  border-bottom: 1px solid var(--line);
  text-align: start;
  vertical-align: top;
}

.va-tool-table th {
  color: var(--text-brand);
  font-size: var(--text-micro);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.va-tool-table td {
  color: var(--t2);
}

.va-chat-top {
  margin: 0;
  padding: 1rem 1rem 0.8rem;
  border-bottom: 1px solid var(--line);
}

.va-messages {
  overflow: auto;
  padding: 1rem;
  display: grid;
  align-content: start;
  gap: 0.85rem;
}

.va-message {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 0.7rem;
  align-items: start;
}

.va-message-user {
  grid-template-columns: minmax(0, 1fr) 42px;
}

.va-message-user .va-avatar {
  grid-column: 2;
}

.va-message-user .va-bubble {
  grid-column: 1;
  grid-row: 1;
  justify-self: end;
  background: color-mix(in srgb, var(--teal) 12%, transparent);
  border-color: color-mix(in srgb, var(--teal) 24%, transparent);
}

.va-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-ink);
  font-size: var(--text-xs);
  font-weight: 700;
}

.va-bubble {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--t2);
  padding: 0.85rem 0.95rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.va-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  padding: 1rem;
  border-top: 1px solid var(--line);
}

.va-composer textarea {
  resize: vertical;
  min-height: 76px;
}

.va-composer .btn {
  min-width: 104px;
  /* the button is a 40px control at the foot of the box, not a 76px slab */
  align-self: end;
  min-height: 40px;
}
/* The opening line is pretty-printed in the template: under pre-wrap its leading
   newline and indent showed as a blank first line and an indented second.
   Replies are written by script and keep pre-wrap. */
.va-messages > .va-message:first-child .va-bubble { white-space: normal; }

@media (max-width: 980px) {
  .va-shell {
    grid-template-columns: 1fr;
  }

  .va-side {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .va-examples {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .va-chat {
    grid-column: auto;
    grid-row: auto;
    grid-template-rows: auto minmax(180px, 1fr) auto;
  }

  .va-prompt-panel {
    grid-column: auto;
  }

  .va-results-panel {
    grid-column: auto;
  }

  .va-tool-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .va-side,
  .va-examples,
  .va-grid-2,
  .va-tool-summary,
  .va-composer {
    grid-template-columns: 1fr;
  }

  .va-chat {
    grid-template-rows: auto minmax(280px, 1fr) auto;
  }
}

html[data-theme="dark"] .va-panel,
html[data-theme="dark"] .va-chat {
  background: rgba(18,21,34,0.9);
  border-color: rgba(255,255,255,0.08);
}

html[data-theme="dark"] .va-input,
html[data-theme="dark"] .va-composer textarea,
html[data-theme="dark"] .va-examples button,
html[data-theme="dark"] .va-bubble,
html[data-theme="dark"] .va-tool-summary span,
html[data-theme="dark"] .va-tool-meta span {
  background: rgba(255,255,255,0.035);
  border-color: rgba(255,255,255,0.08);
}
html[data-theme="dark"] .va-input,
html[data-theme="dark"] .va-composer textarea { border-color: var(--control-edge); }
/* a select draws the design-system chevron instead of the browser's (after the
   dark surface rule above, whose background shorthand would reset the image) */
html body select.va-input.va-input {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  padding-inline-end: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239aa5b4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
}
html[dir="rtl"] body select.va-input.va-input { background-position: left 0.75rem center; }

/* ============================================================
   COURSE ASSIGNMENT
   ============================================================ */

/* ── Status Pills ── */
.ca-pill {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
}

.ca-pill.is-assigned {
  background: var(--teal-dim);
  color: var(--text-brand);
}

.ca-pill.is-unassigned {
  background: var(--amber-dim);
  color: var(--sev-warning);
}

.ca-pill-count {
  font-family: var(--font-mono);
  font-weight: 700;
  min-width: 20px;
  text-align: center;
}

.ca-pill-label {
  white-space: nowrap;
}

/* ── Bulk Action Bar ── */
.ca-bulkbar {
  background: var(--teal-dim);
  border: 1px solid var(--teal-border);
  border-radius: var(--radius);
  margin-bottom: var(--space-4);
  padding: var(--space-3) var(--space-4);
  animation: slideDown var(--dur) var(--ease);
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.ca-bulk-content {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.ca-bulk-content .fb-search {
  max-width: 300px;
}

/* ── Assignment Cells ── */
.ca-assign-cell {
  min-width: 140px;
}

.ca-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--teal-dim);
  color: var(--text-brand);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur-fast);
  border: 1px solid var(--teal-border);
}

.ca-chip:hover {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-ink);
  box-shadow: var(--shadow-sm);
}

.ca-chip-x {
  background: none;
  border: none;
  color: inherit;
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  opacity: 0.7;
  transition: opacity var(--dur-fast);
}

.ca-chip-x:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.2);
}

.ca-assign-add {
  background: transparent;
  border: 2px dashed var(--line-strong);
  color: var(--t3);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  font-size: var(--text-xs);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur-fast);
}

.ca-assign-add:hover {
  border-color: var(--teal);
  color: var(--text-brand);
  background: var(--teal-dim);
}

/* ── Elective tag (real course resolved from a placeholder slot) ── */
.ca-elective-tag {
  display: inline-block;
  margin-inline-start: var(--space-2);
  padding: 1px var(--space-2);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.6;
  vertical-align: middle;
  white-space: nowrap;
  background: transparent;
  color: var(--t3);
  border: 1px solid var(--line-strong);
}

/* Offered this term — the placeholder is actually mapped to this course now. */
.ca-elective-tag.is-offered {
  background: var(--teal-dim);
  color: var(--text-brand);
  border-color: var(--teal-border);
}

/* Legacy/orphaned assignment — a code no longer scheduled; clear it. */
.ca-elective-tag.ca-tag-warn {
  background: var(--amber-dim);
  color: var(--sev-warning);
  border-color: color-mix(in srgb, var(--warning) 35%, transparent);
}

/* Unmapped elective slot — its assign control is disabled. */
.ca-assign-add[disabled],
.ca-assign-add[aria-disabled="true"] {
  opacity: 0.62;
  cursor: not-allowed;
}

.ca-assign-add[disabled]:hover,
.ca-assign-add[aria-disabled="true"]:hover {
  border-color: var(--line-strong);
  color: var(--t3);
  background: transparent;
}

/* ── Assignment Popover ── */
.ca-pop {
  position: fixed;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  z-index: var(--z-drawer);
  width: min(280px, calc(100vw - 16px));
  max-height: 240px;
  overflow: hidden;
}

.ca-pop-search {
  padding: var(--space-3);
  border-bottom: 1px solid var(--line);
  transition: box-shadow var(--dur-fast);
}

.ca-pop-search:focus-within {
  box-shadow: inset 0 -2px 0 var(--teal);
}

.ca-pop-input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-size: var(--text-sm);
  padding: var(--space-2) 0;
  color: var(--ink);
}

.ca-pop-input::placeholder {
  color: var(--t4);
}

.ca-pop-results {
  max-height: 200px;
  overflow-y: auto;
}

.ca-pop-opt {
  padding: var(--space-3);
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  transition: background var(--dur-fast);
}

.ca-pop-opt:last-child {
  border-bottom: none;
}

.ca-pop-opt:hover,
.ca-pop-opt.is-active {
  background: var(--teal-dim);
}

.ca-pop-opt.is-active {
  box-shadow: inset 2px 0 0 var(--teal);
}

.ca-pop-opt strong {
  display: block;
  color: var(--ink);
  font-size: var(--text-sm);
  margin-bottom: var(--space-1);
}

.ca-pop-dept {
  font-size: var(--text-xs);
  color: var(--t3);
}

.ca-pop-hint,
.ca-pop-loading,
.ca-pop-error {
  padding: var(--space-4);
  text-align: center;
  color: var(--t4);
  font-size: var(--text-xs);
}

.ca-pop-error {
  color: var(--danger);
}


[dir="rtl"] .ca-chip {
  flex-direction: row-reverse;
}

[dir="rtl"] .ca-bulk-content {
  flex-direction: row-reverse;
}

/* ============================================================
   INSTRUCTOR MANAGEMENT
   ============================================================ */
/* ── Page frame: global tabs over three panes ── */
.im-tabs { margin: 0 0 14px; }
/* Page tabs sit at the start at their own width (the global tabs share a
   pane's width equally, which spreads three short labels across a page). */
.im-tabs > .ux-tab { flex: 0 0 auto; padding-inline: 18px; }
.im-pane { display: grid; gap: 12px; min-width: 0; }
.im-pane-lead { margin: 0; color: var(--t2); font-size: var(--text-sm); }
.im-col-check { width: 40px; }
.im-col-num { width: 44px; color: var(--t3); font-variant-numeric: tabular-nums; }
.im-none { color: var(--t3); }
.im-name-other { display: block; color: var(--t3); font-size: var(--text-xs); font-weight: 500; }

/* The chip of an assigned course: the name opens the picker, × clears it. */
.ca-chip-name {
  padding: 0; border: 0; background: none; color: inherit; font: inherit;
  cursor: pointer; text-align: start;
}
.ca-chip-name:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: var(--radius-xs); }

/* A course's teachers: one line each (name, optional max sections, remove),
   wrapping at phone width; Add / Remove all sit under them. */
.ca-teachers { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2); min-width: 0; max-width: 100%; }
.ca-teacher { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); max-width: 100%; }
.ca-teacher-name { color: var(--text-brand); font-size: var(--text-sm); font-weight: 500; overflow-wrap: anywhere; }
.ca-limit { display: inline-flex; align-items: center; gap: var(--space-2); margin: 0; }
.ca-limit-label { color: var(--t3); font-size: var(--text-xs); }
.ca-limit-input { width: 76px; min-height: 32px; padding: 2px var(--space-2); font-size: var(--text-sm); }
.ca-teacher-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%;
  background: none; color: var(--t3); font-size: var(--text-sm); font-weight: 700; cursor: pointer;
}
.ca-teacher-x:hover { color: var(--text-brand); background: var(--teal-dim); }
.ca-teacher-x:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.ca-teachers-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.ca-teachers-actions:empty { display: none; }
.im-limits-help { margin: 0; color: var(--t3); font-size: var(--text-xs); }

/* ── The add/edit dialog (UXControls.dialog): two columns of fields ── */
.im-dialog { width: min(680px, calc(100vw - 32px)); }
.im-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
@media (max-width: 560px) { .im-form-grid { grid-template-columns: 1fr; } }
.im-form-check { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--t1); font-size: var(--text-sm); cursor: pointer; }
.im-form-check input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--teal); }
.im-form-error { margin: 0; color: var(--sev-critical); font-size: var(--text-sm); font-weight: 600; }
.im-dialog input[aria-invalid="true"] { border-color: var(--sev-critical); }

/* ── Load report: the summary above the table ── */
.im-report-summary { padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--card); }



/* ── Toolbar ── */

.im-filter-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--t2);
  cursor: pointer;
}

.im-filter-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

/* ── Instructor Names ── */
.im-instructor-name {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.im-instructor-name strong {
  color: var(--t1);
  font-weight: 600;
}

/* ── Row Actions ── */
.im-row-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* ── Assignment Notices ── */
.im-assignment-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-12);
  color: var(--t3);
  font-size: var(--text-sm);
  background: var(--surface);
  border-radius: var(--radius);
  margin: var(--space-8);
}

.im-assignment-notice svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
}

/* ── Report Table ── */
.im-report-table {
  font-size: var(--text-sm);
}

.im-report-totals {
  background: var(--surface);
  border-top: 2px solid var(--teal);
}

.im-report-totals td {
  font-weight: 600;
  color: var(--t1);
}

/* ── Dark Theme ── */
html[data-theme="dark"] .im-assignment-notice {
  background: rgba(255,255,255,0.035);
  border-color: rgba(255,255,255,0.08);
}

/* ── Advisor-seed typeahead (custom dropdown, replaces native datalist) ── */
.im-ac {
  position: relative;
}

.im-ac-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lift);
  max-height: 240px;
  overflow-y: auto;
  z-index: 20;
}

.im-ac-opt {
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  transition: background var(--dur-fast);
}

.im-ac-opt:last-child {
  border-bottom: none;
}

.im-ac-opt:hover,
.im-ac-opt.is-active {
  background: var(--teal-dim);
}

.im-ac-main {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.im-ac-main strong {
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 600;
}

.im-ac-sub {
  font-size: var(--text-xs);
  color: var(--t3);
  margin-top: 2px;
}

.im-ac-badge {
  font-size: var(--text-micro);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--amber-dim);
  color: var(--sev-warning);
}

.im-ac-empty {
  padding: var(--space-4);
  text-align: center;
  color: var(--t4);
  font-size: var(--text-xs);
}

/* ── Teaching times (static/js/instructor-time-rules.js) ──
   The roster's pill, and the rules dialog (#imRulesDialog): quick adds, one
   card per rule, and the live preview of what the rules leave open. Open and
   blocked are told by an icon's shape and words, never by colour alone. */
.im-times-pill { white-space: nowrap; }
.im-times-pill bdi { font-variant-numeric: tabular-nums; }
.im-rules-notice {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 8px 12px;
  border-inline-start: 3px solid var(--sev-info); border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--sev-info) 7%, var(--card));
  color: var(--t1); font-size: var(--text-sm);
}
.im-rules-notice[data-tone="warning"] {
  border-inline-start-color: var(--sev-warning);
  background: color-mix(in srgb, var(--sev-warning) 7%, var(--card));
}
.im-rules-notice[hidden] { display: none; }
.im-rules-notice > p { flex: 1 1 16rem; min-width: 0; margin: 0; font-weight: 600; }
.im-rules-notice-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.im-rules-quick { display: grid; gap: 6px; min-width: 0; }
.im-rules-quick-list { display: flex; flex-wrap: wrap; gap: 6px; }
.im-rules-section { display: grid; gap: 8px; min-width: 0; }
.im-rules-heading { margin: 0; color: var(--t0); font-size: var(--text-sm); font-weight: 700; }
.im-rules-subheading { margin: 0; color: var(--t2); font-size: var(--text-xs); font-weight: 600; }
.im-rules-empty { margin: 0; font-size: var(--text-sm); }
.im-rules-list { display: grid; gap: 8px; min-width: 0; margin: 0; padding: 0; list-style: none; }
.im-rule {
  display: grid; gap: 8px; min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--card);
}
.im-rule-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; min-width: 0; }
.im-rule-num { color: var(--t2); font-size: var(--text-xs); font-weight: 700; white-space: nowrap; }
.im-rule .im-rule-kind { width: auto; min-width: 9rem; }
/* The days are toggles (aria-pressed), so they wrap rather than scroll. */
.im-days { flex-wrap: wrap; overflow: visible; }
.im-day[aria-pressed="true"] {
  background: color-mix(in srgb, var(--teal) 9%, var(--card));
  color: var(--t0); font-weight: 600;
  box-shadow: inset 0 0 0 2px var(--text-brand);
}
.im-day-mark {
  display: none; flex: none; width: 12px; height: 12px;
  background: currentColor;
  -webkit-mask: var(--ux-icon-ok) center / contain no-repeat;
          mask: var(--ux-icon-ok) center / contain no-repeat;
}
.im-day[aria-pressed="true"] .im-day-mark { display: inline-block; }
.im-rule-remove { margin-inline-start: auto; }
.im-rule-times { align-items: flex-end; }
.im-rule-allday { min-height: var(--control-h); }
.im-rule-field { display: grid; gap: 4px; min-width: 0; }
.im-rule-field > label { color: var(--t2); font-size: var(--text-xs); font-weight: 600; }
.im-rule .ux-rows-time { width: 5.5rem; min-width: 5.5rem; }
.im-rule-note { flex: 1 1 12rem; }
.im-rule[aria-invalid="true"] { border-color: var(--sev-critical); box-shadow: inset 0 0 0 1px var(--sev-critical); }
.im-rule .ux-field-error { margin: 0; }
/* A phone: the rule's number and its Remove share the first line; the kind
   and the days take the lines under it. */
@media (max-width: 560px) {
  .im-rule-line:first-child > * { order: 1; }
  .im-rule-line:first-child > .im-rule-num { order: 0; flex: 1 1 auto; }
  .im-rule-line:first-child > .im-rule-remove { order: 0; }
  .im-rule-line:first-child > .im-rule-kind { flex: 1 1 100%; }
}
/* The preview, under the rules. */
.im-rules-effect { display: grid; gap: 10px; min-width: 0; padding-top: 14px; border-top: 1px solid var(--line); }
.im-rules-effect-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.im-rules-line { margin: 0; color: var(--t1); font-size: var(--text-sm); }
.im-rules-hint { margin: 0; color: var(--t3); font-size: var(--text-xs); }
.im-rules-warning:not(:empty) {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 8px 12px;
  border-inline-start: 3px solid var(--sev-warning); border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--sev-warning) 7%, var(--card));
  color: var(--t1); font-size: var(--text-sm); font-weight: 600;
}
.im-rules-warning[data-tone="critical"]:not(:empty) {
  border-inline-start-color: var(--sev-critical);
  background: color-mix(in srgb, var(--sev-critical) 7%, var(--card));
}
.im-rules-warning .ux-tone-icon { margin-top: 3px; }
.im-shapes { display: grid; gap: 4px; min-width: 0; margin: 0; padding: 0; list-style: none; }
.im-shape { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--t1); font-size: var(--text-sm); }
.im-shape-name { flex: 1 1 auto; min-width: 0; }
.im-shape-verdict { flex: none; color: var(--t2); font-size: var(--text-xs); font-weight: 600; }
.im-shape[data-feasible="false"] .im-shape-name { color: var(--t2); }
/* A period table scrolls inside its own frame, under its title; the page
   never does. */
.im-grid-block { display: grid; gap: 4px; min-width: 0; }
.im-grid-scroll { position: relative; min-width: 0; max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.im-grid-scroll:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.im-grid { width: 100%; border-collapse: collapse; font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
.im-grid th,
.im-grid td { padding: 4px 6px; border-top: 1px solid var(--line); text-align: center; white-space: nowrap; }
/* A period's times may break after the dash, so seven of them fit a dialog. */
.im-grid thead th { color: var(--t2); font-weight: 600; white-space: normal; }
.im-grid tbody th { color: var(--t1); font-weight: 600; text-align: start; }
.im-grid td[data-open="true"] { background: color-mix(in srgb, var(--sev-ok) 6%, var(--card)); }
.im-grid td[data-open="false"] { background: color-mix(in srgb, var(--sev-critical) 6%, var(--card)); }


/* ── Student adviser: durable conversations ──────────────────────
   Layout is a sidebar of conversations beside the open thread. Everything here
   is direction-agnostic — margin-inline / padding-inline rather than left and
   right — because the page renders RTL in Arabic and LTR in English from the
   same rules. */

/* `--space-8`, not `--space-3`. The scale here is in PIXELS — `--space-3` is 6px
   — so `var(--space-3, 1rem)` was a declaration whose fallback contradicted its
   token: written to mean 1rem, resolving to 6px, and looking deliberate. */
main[data-page="student-advisor"] {
  min-height: 100dvh;
  padding: .75rem clamp(.65rem, 2vw, 1.25rem);
}
main[data-page="student-advisor"] > .content-wrap {
  width: 100%;
  min-height: 100%;
}
main[data-page="student-advisor"] > .content-wrap > .page-header,
main[data-page="student-advisor"] > .content-wrap > .page-intro {
  display: none;
}

.sa-layout {
  position: relative;
  width: 100%;
  max-width: 1180px;
  height: var(--sa-workspace-height, calc(100dvh - 12rem));
  min-height: 26rem;
  margin-inline: auto;
}

.sa-drawer-backdrop {
  position: absolute;
  inset: 0;
  z-index: 30;
  border: 0;
  border-radius: var(--radius);
  background: rgba(15, 23, 42, .24);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .18s ease, visibility .18s ease;
}
.sa-layout > .sa-sidebar {
  position: absolute;
  inset-block: .65rem;
  inset-inline-end: .65rem;
  z-index: 40;
  display: flex;
  width: min(22rem, calc(100% - 1.3rem));
  padding: .75rem;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(.5rem) scale(.985);
  transform-origin: top center;
  box-shadow: var(--shadow-lg, 0 24px 60px rgba(15,23,42,.22));
  transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
}
.sa-layout.history-open .sa-drawer-backdrop {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.sa-layout.history-open .sa-sidebar {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
}
.sa-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .2rem .25rem .7rem;
  border-bottom: 1px solid var(--line);
}
.sa-sidebar-head h2 { margin: 0; color: var(--t1); font-size: var(--text-md); }
.sa-icon-btn {
  display: grid;
  width: 2rem;
  height: 2rem;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--t2);
  font: inherit;
  font-size: var(--text-xl);
  cursor: pointer;
}
.sa-icon-btn:hover { border-color: var(--teal-border); color: var(--text-brand); }
.sa-drawer-logout {
  flex: 0 0 auto;
  margin-top: .55rem;
  padding-top: .65rem;
  border-top: 1px solid var(--line);
}
.sa-conv-list {
  display: flex;
  min-height: 0;
  margin: .55rem 0 0;
  padding: 0;
  flex: 1 1 auto;
  flex-direction: column;
  gap: .25rem;
  overflow-y: auto;
  list-style: none;
}
.sa-conv-item { display: block; }

/* `.va-chat` is shared with the older adviser page, whose first child is a
   `.va-chat-top` this page does not have. Inheriting its row template therefore
   shifts every row by one: the 420px flexible row lands on the three suggestion
   chips (which stretch to fill it — 280px of them on a phone) while the message
   thread gets an `auto` row, so it sizes to its content and its `overflow: auto`
   never produces a scrollbar. The effect is that answering a question appears to
   do nothing: the view cannot scroll to the reply, and the composer is pushed
   below the fold. Re-state the rows for THIS page rather than editing the shared
   rule the other page still depends on. */
.sa-main .va-chat {
  position: relative;
  display: flex;
  min-height: 0;
  flex-direction: column;
  grid-column: auto;
  grid-row: auto;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
/* No `min-height: 0` here on purpose: .va-messages already carries `overflow:
   auto`, which by itself sets a grid item's automatic minimum size to zero, so the
   usual guard would be a rule nothing depends on. */

.sa-layout > .sa-main {
  display: grid;
  height: 100%;
  min-width: 0;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  padding: 0;
}
.sa-workspace-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .8rem 1rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--card) 92%, var(--teal) 8%);
}
.sa-workspace-identity,
.sa-workspace-actions { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.sa-workspace-mark,
.sa-empty-mark {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--btn-primary-hover), var(--btn-primary-bg));
  color: var(--btn-primary-ink);
  font-weight: 700;
  letter-spacing: -.03em;
  box-shadow: 0 7px 18px color-mix(in srgb, var(--teal) 22%, transparent);
}
.sa-workspace-mark { width: 2.25rem; height: 2.25rem; font-size: var(--text-xs); }
.sa-workspace-kicker { margin: 0 0 .08rem; color: var(--t3); font-size: var(--text-micro); }
.sa-workspace-program {
  display: inline-flex;
  margin-inline-start: .3rem;
  padding: .05rem .34rem;
  border: 1px solid var(--teal-border);
  border-radius: var(--radius-pill);
  background: var(--teal-dim);
  color: var(--text-brand);
  direction: ltr;
  font-size: var(--text-micro);
  font-weight: 700;
  unicode-bidi: isolate;
}
.sa-workspace-head h2 {
  max-width: min(48vw, 34rem);
  margin: 0;
  overflow: hidden;
  color: var(--t1);
  font-size: var(--text-md);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sa-history-toggle,
.sa-new-chat { display: inline-flex; align-items: center; gap: .35rem; }
.sa-main .va-chat.has-messages .va-examples { display: none; }

/* One conversation viewport, matching the agent-chat/conversation pattern. */
.sa-main .va-messages {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  padding: 1.25rem clamp(.85rem, 3vw, 2.25rem);
  gap: 1rem;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}
.sa-empty-state {
  display: grid;
  width: min(100%, 48rem);
  min-height: 100%;
  margin: auto;
  padding: clamp(1rem, 5vh, 3.5rem) 0;
  place-content: center;
  justify-items: center;
  text-align: center;
}
.sa-empty-mark { width: 3.2rem; height: 3.2rem; margin-bottom: .85rem; font-size: var(--text-sm); }
.sa-empty-state h3 { margin: 0 0 .35rem; color: var(--t1); font-size: var(--text-lg); }
.sa-empty-state > p { max-width: 38rem; margin: 0 0 1.15rem; line-height: 1.55; }
.sa-main .va-examples {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .55rem;
}
.sa-main .va-examples button {
  display: flex;
  min-height: 3.25rem;
  align-items: center;
  gap: .55rem;
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: 0 5px 16px rgba(15, 23, 42, .045);
  cursor: pointer;
}
.sa-main .va-examples button > span {
  display: grid;
  width: 1.7rem;
  height: 1.7rem;
  flex: 0 0 auto;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--teal-dim);
  color: var(--text-brand);
}
.sa-main .va-examples strong { min-width: 0; font-size: var(--text-sm); font-weight: 700; }

.sa-main .va-message {
  display: flex;
  width: min(100%, 68rem);
  grid-template-columns: none;
  gap: .6rem;
  align-items: flex-start;
}
.sa-main .va-message-assistant { align-self: center; }
.sa-main .va-message-user {
  width: auto;
  max-width: min(78%, 46rem);
  margin-inline-start: auto;
  grid-template-columns: none;
}
.sa-main .va-message-user .va-avatar { display: none; }
.sa-main .va-avatar {
  width: 1.9rem;
  height: 1.9rem;
  flex: 0 0 auto;
  background: linear-gradient(135deg, var(--btn-primary-bg), var(--btn-primary-hover));
  box-shadow: 0 5px 14px color-mix(in srgb, var(--teal) 18%, transparent);
  font-size: var(--text-micro);
}
.sa-main .va-bubble { min-width: 0; }
.sa-main .va-message-assistant .va-bubble {
  flex: 1 1 auto;
  padding: .15rem 0 1rem;
  border: 0;
  background: transparent;
  line-height: 1.65;
}
.sa-main .va-message-user .va-bubble {
  padding: .62rem .82rem;
  border-color: color-mix(in srgb, var(--teal) 26%, var(--line));
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-xs) var(--radius-lg);
  background: color-mix(in srgb, var(--teal) 12%, var(--card));
  box-shadow: 0 4px 14px rgba(15, 23, 42, .035);
}
[dir="rtl"] .sa-main .va-message-user .va-bubble { border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--radius-xs); }
.sa-main .sa-body { color: var(--t1); font-size: var(--text-md); }
.sa-main .sa-para { margin-bottom: .72rem; }

.sa-main .sa-thinking-message {
  align-self: center;
  color: var(--t3);
}
.sa-main .sa-thinking-message .va-bubble {
  display: inline-flex;
  min-height: 2.25rem;
  padding: .38rem .7rem;
  align-items: center;
  gap: .55rem;
  border: 1px solid color-mix(in srgb, var(--teal) 18%, var(--line));
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--teal) 6%, var(--card));
  box-shadow: none;
  font-size: var(--text-sm);
}
.sa-thinking-dots { display: inline-flex; align-items: center; gap: .2rem; }
.sa-thinking-dots > span {
  width: .32rem;
  height: .32rem;
  border-radius: 50%;
  background: var(--brand);
  opacity: .3;
  animation: sa-thinking-pulse 1.05s ease-in-out infinite;
}
.sa-thinking-dots > span:nth-child(2) { animation-delay: .14s; }
.sa-thinking-dots > span:nth-child(3) { animation-delay: .28s; }
@keyframes sa-thinking-pulse {
  0%, 70%, 100% { opacity: .25; transform: translateY(0); }
  35% { opacity: 1; transform: translateY(-.14rem); }
}
.sa-main .va-message-assistant.is-revealing .va-bubble > [hidden] {
  display: none !important;
}
.sa-answer-caret {
  display: inline-block;
  width: .12rem;
  height: 1em;
  margin-inline-start: .12rem;
  vertical-align: -.12em;
  border-radius: var(--radius-pill);
  background: var(--brand);
  animation: sa-answer-caret .72s steps(1, end) infinite;
}
@keyframes sa-answer-caret { 50% { opacity: 0; } }

.sa-jump-latest {
  position: absolute;
  inset-inline-start: 50%;
  bottom: 5.35rem;
  z-index: 12;
  display: grid;
  width: 2.15rem;
  height: 2.15rem;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  color: var(--t2);
  box-shadow: var(--shadow-sm);
  transform: translateX(-50%);
  cursor: pointer;
}
.sa-jump-latest:hover { border-color: var(--teal-border); color: var(--text-brand); }

.sa-main .va-composer {
  position: sticky;
  bottom: 0;
  z-index: 12;
  display: grid;
  flex: 0 0 auto;
  margin: .65rem clamp(.75rem, 2.5vw, 1.5rem) 1rem;
  padding: .35rem;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: .35rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(15, 23, 42, .06);
}
.sa-main .va-input {
  min-height: 2.9rem;
  max-height: 9rem;
  padding: .72rem .75rem;
  overflow-y: auto;
  resize: none;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  line-height: 1.45;
}
.sa-main .va-input:focus { border-color: transparent; box-shadow: none; }
.sa-main .va-composer:focus-within {
  border-color: color-mix(in srgb, var(--teal) 58%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 10%, transparent), 0 8px 24px rgba(15,23,42,.06);
}
.sa-main .va-composer .btn {
  display: grid;
  width: 2.75rem;
  height: 2.75rem;
  min-width: 2.75rem;
  padding: 0;
  place-items: center;
  align-self: end;
  border-radius: var(--radius-md);
}
.sa-send-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.sa-send-icon { display: grid; place-items: center; font-size: var(--text-lg); line-height: 1; }
.va-composer.is-busy .sa-send-icon { font-size: 0; }
.va-composer.is-busy .sa-send-icon::after {
  content: '';
  width: .9rem;
  height: .9rem;
  border: 2px solid rgba(255,255,255,.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: sa-spin .75s linear infinite;
}
@keyframes sa-spin { to { transform: rotate(360deg); } }
.sa-main > .va-chat > .sa-error { margin: 0 clamp(.9rem, 3vw, 1.75rem); padding: .45rem .55rem 0; }

.sa-conv {
  display: block;
  width: 100%;
  text-align: start;
  padding: .5rem .625rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm, 8px);
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sa-conv:hover { background: var(--surface-2, rgba(127,127,127,.08)); }
/* The app already has a selected state, 250px away in the same viewport:
   `.nav-a.active` uses a teal wash and a teal inset edge. This used a grey border
   that measures 1.19:1 against the sidebar, leaving `font-weight: 600` as the only
   reliable cue for which conversation a student is in — and weight alone is not a
   distinction someone can rely on. Same language as the navigation, so the two
   selected states on one screen agree. */
.sa-conv.is-active {
  background: linear-gradient(135deg,
              color-mix(in srgb, var(--teal) 14%, transparent),
              rgba(0,174,218,0.05));
  border-color: transparent;
  box-shadow: 0 0 0 1px var(--teal-border) inset;
  color: var(--text-brand);
  font-weight: 600;
}
.sa-conv:focus-visible,
.sa-fb-btn:focus-visible,
.sa-fb-reason:focus-visible,
.sa-retry:focus-visible { outline: 2px solid var(--accent, #4c8bf5); outline-offset: 2px; }

/* --text-muted was never defined, so the fallback grey (3.75:1 on the dark page) always applied */
.sa-muted { color: var(--t3); font-size: var(--text-base); }
.sa-empty { padding: .75rem .25rem; }
.sa-error { color: var(--danger, #b42318); padding: .75rem; }
/* The answer body. `pre-wrap` moved off the container and onto the paragraph:
   the container now holds real <p> and <ul> elements, and pre-wrap on a parent
   turns the whitespace BETWEEN those elements into visible blank lines. */
/* …and the SAME trap one level higher. `.va-bubble` is shared with the older
   adviser page, which puts raw text in it and needs `pre-wrap`; this page puts
   elements in it, and every newline BETWEEN those elements became a blank line,
   so each paragraph and list carried a doubled gap the stylesheet never asked
   for. Reset here rather than on the shared rule the other page depends on. */
.sa-layout .va-bubble { white-space: normal; }
.sa-body { display: flow-root; }
.sa-para { white-space: pre-wrap; margin: 0 0 .6rem; }
.sa-body > :last-child { margin-bottom: 0; }

/* `padding-inline-start`, not `padding-left`: the marker belongs on the side the
   text starts from, and an Arabic answer inside an English interface is exactly
   the case this screen got wrong. */
.sa-list { margin: 0 0 .6rem; padding-inline-start: 1.35rem; }
.sa-list li { margin: 0 0 .2rem; }
.sa-list li::marker { color: var(--t2); }

/* Structured timetable evidence inside the answer. It is deliberately a set of
   read-only disclosure cards: there is no select/apply affordance because the
   adviser cannot save a timetable or register a course. */
.sa-timetable {
  min-width: 0;
  max-width: 100%;
  margin-top: .8rem;
  padding-top: .75rem;
  border-top: 1px solid var(--line);
}
.sa-tt-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .4rem;
}
.sa-tt-title { margin: 0; color: var(--t1); font-size: var(--text-md); }
.sa-tt-term,
.sa-tt-coverage,
.sa-tt-credits {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: .12rem .45rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--t2);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}
.sa-tt-boundary {
  margin: 0 0 .65rem;
  padding: .5rem .6rem;
  border-inline-start: 3px solid var(--brand);
  border-radius: var(--radius-sm);
  background: var(--teal-dim);
  color: var(--t2);
  font-size: var(--text-sm);
}
.sa-tt-replacement {
  display: grid;
  gap: .35rem;
  margin: 0 0 .65rem;
  padding: .55rem .65rem;
  border: 1px solid var(--teal-border);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--teal-dim) 78%, var(--surface));
}
.sa-tt-replacement-swap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .2rem;
  margin: 0;
  color: var(--t1);
  font-size: var(--text-sm);
  font-weight: 700;
}
.sa-tt-replacement-code {
  display: inline-flex;
  padding: .12rem .42rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-size: var(--text-sm);
}
.sa-tt-replacement-code.is-removed {
  color: var(--danger);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}
.sa-tt-replacement-code.is-added {
  border-color: var(--teal-border);
  color: var(--brand-strong);
}
.sa-tt-replacement-caution {
  margin: 0;
  padding-top: .35rem;
  border-top: 1px solid color-mix(in srgb, var(--warning) 30%, var(--line));
  color: var(--t2);
  font-size: var(--text-xs);
  line-height: 1.45;
}
.sa-tt-constraints {
  margin: 0 0 .65rem;
  padding: .55rem .6rem;
  border: 1px solid var(--teal-border);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--teal-dim) 70%, var(--surface));
}
.sa-tt-constraints .sa-tt-subtitle { margin-top: 0; color: var(--brand-strong); }
.sa-tt-constraint-chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.sa-tt-constraint-chip {
  display: inline-flex;
  align-items: center;
  gap: .2rem;
  min-width: 0;
  padding: .24rem .5rem;
  border: 1px solid var(--teal-border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--t1);
  font-size: var(--text-xs);
}
.sa-tt-constraint-chip.is-pinned { border-style: dashed; }
.sa-tt-constraint-alert {
  margin: 0 0 .65rem;
  padding: .58rem .65rem;
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--line));
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--danger) 7%, var(--surface));
  color: var(--t1);
  font-size: var(--text-sm);
}
.sa-tt-constraint-alert .sa-tt-subtitle { margin-top: 0; color: var(--danger); }
.sa-tt-constraint-alert ul { margin: 0; padding-inline-start: 1.2rem; }
.sa-tt-constraint-alert li + li { margin-top: .25rem; }
.sa-tt-current,
.sa-tt-option {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.sa-tt-current { margin-bottom: .55rem; }
.sa-tt-current > summary,
.sa-tt-summary {
  position: relative;
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .58rem .65rem;
  color: var(--t1);
  cursor: pointer;
  list-style: none;
}
.sa-tt-current > summary::-webkit-details-marker,
.sa-tt-summary::-webkit-details-marker { display: none; }
.sa-tt-current > summary::before,
.sa-tt-summary::before {
  content: '›';
  flex: 0 0 auto;
  color: var(--text-brand);
  font-size: 1.15rem;
  line-height: 1;
  transition: transform .15s ease;
}
.sa-tt-current[open] > summary::before,
.sa-tt-option[open] > .sa-tt-summary::before { transform: rotate(90deg); }
.sa-tt-current > summary:focus-visible,
.sa-tt-summary:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.sa-tt-current-list { display: grid; gap: .4rem; padding: 0 .65rem .65rem; }
.sa-tt-current-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .12rem .65rem;
  padding: .42rem .5rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.sa-tt-course-name { min-width: 0; color: var(--t2); font-size: var(--text-sm); }
.sa-tt-current-meeting { grid-column: 2; color: var(--t2); font-size: var(--text-xs); }
.sa-tt-options { display: grid; gap: .5rem; }
.sa-tt-option[open] { border-color: var(--teal-border); box-shadow: inset 3px 0 0 var(--brand); }
.sa-tt-option-name { min-width: 0; overflow-wrap: anywhere; }
.sa-tt-summary-meta {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .3rem;
  margin-inline-start: auto;
}
.sa-tt-option-body { padding: 0 .65rem .65rem; }
.sa-tt-subtitle { margin: .1rem 0 .35rem; color: var(--t2); font-size: var(--text-xs); }
.sa-tt-meetings,
.sa-tt-unplaced { display: grid; gap: .32rem; margin: 0; padding: 0; list-style: none; }
.sa-tt-meeting {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: .5rem;
  padding: .42rem .5rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.sa-tt-meeting-course { display: flex; min-width: 0; flex-direction: column; }
.sa-tt-meeting-course small { overflow: hidden; color: var(--t2); text-overflow: ellipsis; white-space: nowrap; }
.sa-tt-course-key { color: var(--t1); font-size: var(--text-sm); }
.sa-tt-when { display: flex; align-items: center; gap: .45rem; white-space: nowrap; }
.sa-tt-day { color: var(--t2); font-size: var(--text-sm); }
.sa-tt-time { color: var(--t1); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.sa-tt-empty { margin: .1rem 0 0; color: var(--t2); font-size: var(--text-sm); }
.sa-tt-unplaced-title { margin-top: .65rem; color: var(--danger); }
.sa-tt-unplaced li {
  padding: .42rem .5rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: var(--text-sm);
}
.sa-tt-reason { display: block; margin-top: .15rem; color: var(--t2); }

@media (max-width: 520px) {
  .sa-tt-summary { align-items: flex-start; flex-wrap: wrap; }
  .sa-tt-summary-meta { width: 100%; margin-inline-start: 1.7rem; justify-content: flex-start; }
  .sa-tt-current-row,
  .sa-tt-meeting { grid-template-columns: 1fr; }
  .sa-tt-current-meeting { grid-column: 1; }
  .sa-tt-when { justify-content: space-between; }
}

/* Graduation scenarios reuse the shared prerequisite SVG, but the vertical
   bands are simulated academic terms rather than declared programme levels. */
.sa-graduation-map {
  min-width: 0;
  max-width: 100%;
  margin-top: .8rem;
  padding-top: .75rem;
  border-top: 1px solid var(--line);
}
.sa-grad-heading-actions { display: flex; align-items: center; justify-content: flex-end; gap: .4rem; }
.sa-grad-expand { white-space: nowrap; }
html.sa-overlay-open { overflow: hidden; }
.sa-graduation-map.is-expanded {
  position: fixed;
  inset: clamp(.5rem, 2vw, 1.5rem);
  z-index: 2000;
  display: block;
  max-width: none;
  margin: 0;
  padding: clamp(.8rem, 2vw, 1.4rem);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 30px 90px rgba(15, 23, 42, .35);
}
.sa-graduation-map.is-expanded .sa-tt-heading {
  position: sticky;
  top: -.05rem;
  z-index: 3;
  padding: .25rem 0 .7rem;
  background: var(--card);
}
.sa-graduation-map.is-expanded .sa-grad-desktop { display: block; overflow-x: auto; }
.sa-graduation-map.is-expanded .sa-grad-mobile { display: none; }
.sa-graduation-map.is-expanded .sa-grad-panel { min-height: 60vh; }
.sa-grad-result {
  margin: 0 0 .55rem;
  padding: .5rem .6rem;
  border-radius: var(--radius-sm);
  color: var(--t2);
  font-size: var(--text-sm);
}
.sa-grad-result.is-complete {
  background: color-mix(in srgb, var(--success) 10%, transparent);
  border-inline-start: 3px solid var(--success);
}
.sa-grad-result.is-incomplete {
  background: color-mix(in srgb, #b45309 9%, transparent);
  border-inline-start: 3px solid #b45309;
}
.sa-grad-change {
  margin: 0 0 .55rem;
  padding: .45rem .55rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--t2);
  font-size: var(--text-sm);
}
.sa-grad-panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.sa-grad-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .5rem .6rem;
  border-bottom: 1px solid var(--line);
}
.sa-grad-toolbar .pg-modes { margin-inline-start: 0; }
.sa-graduation-map:not(.is-expanded) .sa-grad-toolbar .pg-modes { display: none; }
.sa-graduation-map.is-expanded .sa-grad-toolbar .pg-modes { display: flex; }
.sa-grad-desktop {
  display: none;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  padding: .45rem;
}
.sa-grad-mobile {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(13rem, 100%), 1fr));
  align-items: start;
  gap: .5rem;
  padding: .55rem;
}
.sa-grad-blockers {
  margin-top: .55rem;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, #b45309 28%, var(--line));
  border-radius: var(--radius-sm);
}
.sa-grad-blockers > summary {
  padding: .5rem .6rem;
  color: var(--t1);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 700;
}
.sa-grad-blocker-list {
  display: grid;
  gap: .35rem;
  margin: 0;
  padding: 0 .6rem .6rem;
  list-style: none;
}
.sa-grad-blocker {
  padding: .42rem .5rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: var(--text-sm);
}
.sa-grad-blocker-reason { display: block; margin-top: .12rem; color: var(--t2); }
.sa-grad-mobile-term {
  min-width: 0;
  padding: .55rem .6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.sa-grad-band-title { margin: 0 0 .35rem; color: var(--t2); font-size: var(--text-xs); }
.sa-grad-mobile-courses { display: flex; flex-wrap: wrap; gap: .3rem; }
.sa-grad-course {
  display: inline-flex;
  align-items: center;
  padding: .18rem .42rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--t2);
  font-size: var(--text-xs);
  font-weight: 700;
}
.sa-grad-course.is-passed { border-color: color-mix(in srgb, var(--success) 45%, var(--line)); color: var(--sev-ok); }
.sa-grad-course.is-studying { border-color: color-mix(in srgb, var(--royal) 45%, var(--line)); color: var(--royal); }
.sa-grad-course.is-open { border-color: color-mix(in srgb, var(--teal) 45%, var(--line)); color: var(--text-brand); }
.sa-grad-more { margin-top: .45rem; }
.sa-grad-more > summary {
  min-height: 2.25rem;
  padding: .35rem .45rem;
  border-radius: var(--radius-sm);
  color: var(--text-brand);
  cursor: pointer;
  font-size: var(--text-xs);
  font-weight: 700;
}
.sa-grad-more > .sa-grad-mobile-courses { padding-top: .4rem; }

@media (max-width: 768px) {
  .sa-grad-toolbar { justify-content: flex-end; }
}

/* Status is informative, not decorative: a failed turn has to be visibly
   different from an answered one, or a student retries something that worked. */
.sa-status { margin: .5rem 0 0; font-size: var(--text-base); }
.sa-status-failed { color: var(--danger, #b42318); }
.sa-status-pending { color: var(--text-muted, #6b7280); font-style: italic; }
.sa-status-abstained,
.sa-status-escalated { color: var(--sev-warning); }

/* A failed question is still the student's message, so its recovery action stays
   inside that bubble as one compact unit instead of looking like a second reply. */
.sa-retry-state {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem .75rem;
  margin-top: .65rem;
  padding-top: .6rem;
  border-top: 1px solid color-mix(in srgb, var(--danger, #b42318) 24%, var(--line));
}
.sa-retry-state .sa-status {
  flex: 1 1 13rem;
  margin: 0;
  line-height: 1.45;
}
.sa-retry-state .sa-retry {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  gap: .35rem;
  min-height: 44px;
  margin: 0;
  padding: .48rem .78rem;
  border: 1px solid color-mix(in srgb, var(--danger, #b42318) 42%, var(--line));
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--danger, #b42318) 6%, var(--card));
  color: var(--danger, #b42318);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color .15s ease, background-color .15s ease, transform .15s ease;
}
.sa-retry-state .sa-retry:hover {
  border-color: color-mix(in srgb, var(--danger, #b42318) 64%, var(--line));
  background: color-mix(in srgb, var(--danger, #b42318) 11%, var(--card));
}
.sa-retry-state .sa-retry:active { transform: translateY(1px); }
.sa-retry-icon { font-size: var(--text-md); line-height: 1; }

/* ── citations ── */
.sa-citations {
  margin-top: .75rem;
  padding-top: .625rem;
  border-top: 1px solid var(--border, rgba(127,127,127,.25));
}
.sa-citations-title { margin: 0 0 .375rem; font-size: var(--text-sm); font-weight: 600; opacity: .85; }
.sa-citation-list { margin: 0; padding-inline-start: 1.1rem; display: flex; flex-direction: column; gap: .375rem; }
.sa-citation { font-size: var(--text-base); }
.sa-citation-text { display: block; }
.sa-citation-details { margin-top: .25rem; font-size: var(--text-sm); }
.sa-citation-details summary { cursor: pointer; color: var(--text-muted, #6b7280); }
.sa-citation-meta { display: grid; grid-template-columns: auto 1fr; gap: .125rem .5rem; margin: .375rem 0 0; }
.sa-citation-meta dt { font-weight: 600; opacity: .8; }
.sa-citation-meta dd { margin: 0; overflow-wrap: anywhere; }
.sa-citation-approved { margin: .375rem 0 0; opacity: .75; }

/* ── feedback ── */
.sa-feedback {
  margin-top: .9rem;
  padding-top: .6rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .375rem;
  border-top: 1px solid var(--line);
}
.sa-feedback-q { color: var(--t3); font-size: var(--text-sm); margin-inline-end: .25rem; }
.sa-feedback .sa-fb-btn {
  min-height: 1.9rem;
  padding: .2rem .55rem;
  border-color: transparent;
  background: transparent;
  color: var(--t2);
  font-size: var(--text-xs);
}
.sa-feedback .sa-fb-btn:hover { border-color: var(--line); background: var(--surface-2); }
.sa-fb-btn.is-selected,
.sa-fb-reason.is-selected {
  background: var(--accent, #4c8bf5);
  border-color: var(--accent, #4c8bf5);
  color: #fff;
}
.sa-fb-reasons { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .25rem; }
/* `display` wins over the `hidden` ATTRIBUTE, so a flex container marked hidden
   stays visible. Without this the negative-feedback reasons were on screen
   before the student had said anything was wrong. */
/* Scoped to this screen rather than to one class: `hidden` is an attribute the UA
   sheet implements as `display: none`, so ANY rule giving an element a display
   value silently outranks it. That is how the negative-feedback reasons came to be
   on screen before the student had said anything was wrong, and the same trap is
   one declaration away for every other element here that JS toggles. */
.sa-layout [hidden] { display: none !important; }

/* ── adviser inbox ───────────────────────────────────────────────
   The queue is a working view: dense, scannable, and left-to-right even though the
   questions inside it are Arabic. Each cell that holds student prose carries
   dir="auto" so the text runs the way it was written without turning the table
   round. */
/* The form is also a .card, and bootstrap-compat's `.card{flex-direction:column}`
   (same specificity, loaded later) stacked the filters into one ragged column that
   spilled off a phone. Two classes win; an even grid of columns that wrap. */
.card.ai-filters,
.ai-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: var(--space-6);
  align-items: end;
}
.ai-filter { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.ai-filter label { font-size: var(--text-sm); color: var(--t2); }
/* The shared field recipe: the control ladder's height, the control edge (the
   hairline --line measured 1.4:1, under the 3:1 a control boundary needs). */
.ai-filter select, .ai-filter input:not([type="checkbox"]):not([type="radio"]) {
  border: 1px solid var(--control-edge);
  border-radius: var(--control-radius);
  min-height: var(--control-h);
  padding: 0 var(--control-px-sm);
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: var(--field-fs);
  line-height: var(--control-lh);
  width: 100%;
}
.ai-filter-check label { flex-direction: row; align-items: center; gap: .375rem; display: flex; }

.table-wrap { overflow-x: auto; }
.ai-cases { width: 100%; border-collapse: collapse; }
.ai-cases th, .ai-cases td {
  padding: .5rem .625rem;
  border-bottom: 1px solid var(--line);
  text-align: start;
  vertical-align: top;
  font-size: var(--text-base);
}
.ai-cases thead th { color: var(--t2); white-space: nowrap; vertical-align: middle; }
.ai-question { max-width: 22rem; }
.ai-empty { text-align: center; color: var(--t2); padding: 1.5rem; }
.ai-muted { color: var(--t2); }

.ai-status { border-radius: var(--radius-pill); padding: .0625rem .5rem; font-size: var(--text-sm); white-space: nowrap; }
.ai-status-open { background: color-mix(in srgb, var(--teal) 18%, transparent); }
.ai-status-assigned { background: color-mix(in srgb, var(--brand) 18%, transparent); }
.ai-status-needs_information { background: color-mix(in srgb, orange 22%, transparent); }
.ai-status-resolved { background: color-mix(in srgb, green 18%, transparent); }
.ai-status-closed { background: var(--surface-2, rgba(127,127,127,.14)); }

.ai-case-h { font-size: var(--text-md); margin: 0 0 .5rem; }
.ai-case-sub { font-size: var(--text-base); margin: .75rem 0 .25rem; color: var(--t2); }
.ai-case-body { margin: 0 0 .5rem; white-space: pre-wrap; }
.ai-case-meta { display: grid; grid-template-columns: auto 1fr; gap: .125rem .75rem; margin: 0; }
.ai-case-meta dt { color: var(--t2); font-size: var(--text-base); }
.ai-case-meta dd { margin: 0; font-size: var(--text-base); }
.ai-case-pre {
  white-space: pre-wrap;
  background: var(--surface-2, rgba(127,127,127,.06));
  padding: .625rem;
  border-radius: var(--radius-sm, 8px);
  margin: .5rem 0 0;
  font: inherit;
}
.ai-citations, .ai-missing, .ai-events { margin: 0; padding-inline-start: 1.25rem; }
.ai-events li { margin-bottom: .25rem; font-size: var(--text-base); }
.ai-event-kind { font-weight: 600; margin-inline-end: .375rem; }

.ai-action-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }
.ai-two-up { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.ai-two-up textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm, 8px);
  padding: .5rem;
  background: var(--surface);
  color: inherit;
  font: inherit;
  resize: vertical;
  margin-bottom: .5rem;
}
.ai-label { display: block; margin-bottom: .25rem; font-size: var(--text-base); font-weight: 600; }
.ai-notes { max-height: 12rem; overflow-y: auto; }
.ai-action-error { color: var(--danger, #b42318); margin: .75rem 0 0; }

@media (max-width: 900px) {
  .ai-two-up { grid-template-columns: 1fr; }
}

/* ── handing a case to a person ──────────────────────────────────
   Direction-agnostic like the rest of this screen: padding-inline and text-align
   start, so the same rules serve Arabic and English. */
.sa-escalate { margin-top: .5rem; }
.sa-escalate.is-prominent {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm, 8px);
  padding: .625rem .75rem;
  background: var(--surface-2, rgba(127,127,127,.06));
}
.sa-escalate-lead { margin: 0 0 .5rem; font-weight: 600; text-align: start; }

.sa-preview {
  margin-top: .5rem;
  padding: .75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm, 8px);
  background: var(--surface);
  text-align: start;
}
.sa-preview-title { margin: 0 0 .375rem; font-size: var(--text-md); }
.sa-preview-list { margin: 0 0 .5rem; padding-inline-start: 1.25rem; }
.sa-preview-list li { margin-bottom: .125rem; }
.sa-preview-limit { margin: 0 0 .625rem; color: var(--t2); font-size: var(--text-base); }
.sa-preview-note-label { display: block; margin-bottom: .25rem; font-size: var(--text-base); }
.sa-preview-note {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm, 8px);
  padding: .5rem;
  font: inherit;
  background: var(--surface);
  color: inherit;
  resize: vertical;
}
.sa-preview-actions { display: flex; gap: .5rem; margin-top: .625rem; flex-wrap: wrap; }
.sa-preview-error { margin: .5rem 0 0; color: var(--danger, #b42318); font-size: var(--text-base); }

.sa-case {
  margin-top: .5rem;
  padding: .75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm, 8px);
  background: var(--surface-2, rgba(127,127,127,.06));
  text-align: start;
}
.sa-case-title { margin: 0 0 .5rem; font-size: var(--text-md); }
.sa-case-meta { display: grid; grid-template-columns: auto 1fr; gap: .125rem .75rem; margin: 0; }
.sa-case-meta dt { color: var(--t2); font-size: var(--text-base); }
.sa-case-meta dd { margin: 0; font-size: var(--text-base); }
/* A case number is quoted over a telephone and read back; it must not be
   ellipsised, reflowed or bidi-reordered. */
.sa-case-ref { font-weight: 700; font-variant-numeric: tabular-nums; unicode-bidi: isolate; }
.sa-case-reply { margin-top: .625rem; padding-top: .625rem; border-top: 1px solid var(--line); }
.sa-case-reply h5 { margin: 0 0 .25rem; font-size: var(--text-base); color: var(--t2); }
.sa-case-reply p { margin: 0; }

.sa-fb-reason { font-size: var(--text-sm); }
.sa-retry { margin-top: .5rem; }

@media (max-width: 768px) {
  .sa-layout > .sa-main { height: 100%; }
  .sa-layout > .sa-sidebar {
    position: absolute;
    inset-block: .4rem;
    inset-inline: .4rem;
    width: auto;
  }
  .sa-workspace-head { padding: .65rem .7rem; }
  .sa-workspace-kicker { display: none; }
  /* 34vw (132px at 390) was fitted to 13px: the Arabic title was cut beside
     150px of empty header */
  .sa-workspace-head h2 { max-width: 56vw; font-size: var(--text-sm); }
  .sa-workspace-actions { gap: .35rem; }
  .sa-workspace-actions .btn { padding-inline: .55rem; }
  .sa-history-toggle span:last-child,
  .sa-new-chat span:last-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .sa-main .va-messages { padding: .85rem .75rem; }
  .sa-main .va-message-user { max-width: 90%; }
  .sa-main .va-message-assistant { gap: .45rem; }
  .sa-main .va-avatar { width: 1.65rem; height: 1.65rem; }
  .sa-main .va-examples { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sa-main .va-examples button { min-height: 3.5rem; }
  .sa-empty-state { padding-block: 1rem; }
  .sa-empty-state > p { margin-bottom: .8rem; }
  .sa-main .va-composer { margin: .5rem .6rem .65rem; }
  .sa-jump-latest { bottom: 4.9rem; }
  .sa-grad-heading-actions { width: 100%; justify-content: space-between; }
  .sa-graduation-map .sa-tt-heading { align-items: flex-start; flex-wrap: wrap; }
  .sa-grad-expand { flex: 1 1 auto; }
}

@media (max-width: 359px) {
  .sa-main .va-examples { grid-template-columns: 1fr; }
  .sa-retry-state .sa-status { flex-basis: 100%; }
  .sa-retry-state .sa-retry { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .sa-drawer-backdrop,
  .sa-sidebar,
  .sa-main .va-messages { scroll-behavior: auto; transition: none; }
  .sa-thinking-dots > span,
  .sa-answer-caret { animation: none; }
  .va-composer.is-busy .sa-send-icon::after { animation-duration: 1.5s; }
}

/* ── student timetable planner ───────────────────────────────────
   Three stacked cards: what was asked for, how to build it, and what came back.
   The order is the decision order, so the destructive choice sits between the
   selection and its consequences rather than beside the results.

   Every colour below is a real token. The first draft reached for `--warn`, `--ok`
   and `--accent-soft`, none of which this design system defines — so the hardcoded
   fallbacks always won, and the two affordances that most need to read as
   destructive and as chosen were the only ones that did not follow Deep Navy. */
.sp-layout { display: flex; flex-direction: column; }

.sp-boundary {
  display: flex; align-items: flex-start; gap: .75rem; margin-bottom: 1rem;
  padding: .875rem 1rem; border: 1px solid var(--teal-border);
  border-radius: var(--radius); background: var(--teal-dim); color: var(--t1);
}
.sp-boundary-icon {
  display: grid; place-items: center; flex: 0 0 1.5rem; height: 1.5rem;
  border-radius: 50%; background: var(--btn-primary-bg); color: var(--btn-primary-ink); font-weight: 700;
  font-family: var(--font-serif);
}
.sp-boundary p { margin: .2rem 0 0; color: var(--t2); font-size: var(--text-base); }

.sp-kpis {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem;
  margin-bottom: 1rem;
}
.sp-kpi-card {
  display: flex; flex-direction: column; gap: .15rem; padding: .75rem .875rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
}
.sp-kpi-card span { color: var(--t2); font-size: var(--text-xs); }
/* margin-block-start: the values of a row share a line when one label wraps
   and its neighbour does not */
.sp-kpi-card strong { color: var(--text-brand); font-size: var(--text-lg); font-variant-numeric: tabular-nums; margin-block-start: auto; }

.sp-section-head {
  display: flex; justify-content: space-between; gap: 1rem; margin-bottom: 1rem;
}
.sp-section-head > div { display: grid; grid-template-columns: auto 1fr; column-gap: .6rem; align-items: center; }
.sp-section-head p { grid-column: 2; }
.sp-step {
  grid-row: 1 / span 2; display: grid; place-items: center; width: 1.8rem; height: 1.8rem;
  border-radius: 50%; background: var(--btn-primary-bg); color: var(--btn-primary-ink); font-weight: 700; font-size: var(--text-sm);
}

.sp-current-summary { display: flex; flex-wrap: wrap; gap: .45rem; }
.sp-current-chip {
  display: inline-flex; align-items: center; gap: .45rem; padding: .35rem .65rem;
  border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--surface);
}
.sp-current-section { color: var(--t2); font-size: var(--text-sm); }
.sp-current-details { margin-top: .75rem; }
.sp-current-details > summary,
.sp-option-details > summary { color: var(--text-brand); cursor: pointer; font-weight: 700; }
.sp-current-details[open] > summary { margin-bottom: .75rem; }
.sp-week { overflow-x: auto; }
.sp-week:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.sp-week .wg-blocks { min-width: 620px; }
.sp-course-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .75fr); gap: 1rem; }
.sp-catalog-panel, .sp-selection-panel { min-width: 0; }
.sp-selection-panel {
  padding: .875rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface) 94%, var(--brand) 6%);
}
.sp-search {
  display: flex; align-items: center; gap: .5rem; padding: .55rem .7rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
}
.sp-search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 2px var(--teal-dim); }
.sp-search input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--t1); }
.sp-filter-row { display: flex; flex-wrap: wrap; gap: .4rem; margin: .65rem 0; }
.sp-filter {
  border: 1px solid var(--line); border-radius: var(--radius-pill); background: transparent;
  color: var(--t2); padding: .25rem .7rem; font-size: var(--text-sm); font-weight: 600;
}
.sp-filter:hover, .sp-filter.is-active { border-color: var(--brand); background: var(--teal-dim); color: var(--text-brand); }
.sp-catalog-scope {
  margin: -.1rem 0 .65rem; padding-inline-start: .65rem; border-inline-start: 2px solid var(--teal-border);
  color: var(--t2); font-size: var(--text-xs); line-height: 1.55;
}
.sp-catalog { display: flex; flex-direction: column; gap: .45rem; max-height: 30rem; overflow-y: auto; padding-inline-end: .2rem; }
.sp-course-card {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .65rem .7rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface);
}
.sp-course-card.is-selected { border-color: var(--brand); box-shadow: inset 3px 0 0 var(--brand); }
[dir="rtl"] .sp-course-card.is-selected { box-shadow: inset -3px 0 0 var(--brand); }
.sp-course-card.is-disabled { opacity: .65; }
.sp-course-main { min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.sp-course-title, .sp-course-meta { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; }
.sp-course-meta { font-size: var(--text-xs); }
.sp-tag.sp-tag-rec { border-color: var(--brand); background: var(--teal-dim); color: var(--text-brand); }
.sp-tag.sp-tag-ready { border-color: var(--success); color: var(--sev-ok); }
.sp-tag.sp-tag-blocked, .sp-tag.sp-tag-warning { border-color: var(--warning); color: var(--sev-warning); }
.sp-tag.sp-tag-current { border-color: var(--line); background: var(--glass-bg); color: var(--t2); }
.sp-requested { gap: .6rem; }
.sp-requested-item {
  display: flex; flex-direction: column; align-items: stretch; gap: .55rem;
  min-width: 0; padding: .15rem 0 .75rem; border-bottom: 1px solid var(--line);
}
.sp-requested-item:last-child { border-bottom: 0; }
.sp-requested-label { min-width: 0; width: 100%; display: flex; flex-direction: column; gap: .12rem; }
.sp-requested-title { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem; }
.sp-requested-label .sp-code { font-size: var(--text-md); }
.sp-requested-label .sp-name {
  display: block; max-width: 100%; font-size: var(--text-base); line-height: 1.5;
  white-space: normal; overflow-wrap: break-word; word-break: normal;
}
.sp-requested-controls {
  display: flex; align-items: stretch; flex-wrap: wrap; gap: .5rem; min-width: 0; width: 100%;
}
.sp-section-select {
  flex: 1 1 15rem; width: auto; max-width: 100%; min-width: min(15rem, 100%); min-height: 44px;
}
html body .btn.sp-requested-remove {
  flex: 0 0 auto; min-height: 44px; padding-inline: .75rem; white-space: nowrap;
}
.sp-section-select:disabled { opacity: .8; color: var(--t1); }
.sp-fixed-label { color: var(--t2); text-decoration: none; cursor: default; }
.sp-selection-note { margin: .75rem 0 0; color: var(--t2); font-size: var(--text-xs); }
.sp-modes {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem;
  min-width: 0; margin: 0; padding: 0; border: 0;
}
.sp-mode-card {
  display: flex; align-items: flex-start; gap: .65rem; padding: .8rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer;
}
.sp-mode-card:has(input:checked) { border-color: var(--brand); background: var(--teal-dim); }
.sp-mode-card input { margin-top: .2rem; accent-color: var(--brand); }
.sp-mode-card span { display: flex; flex-direction: column; gap: .2rem; }
.sp-mode-card small { color: var(--t2); }
.sp-generate-row { display: flex; align-items: center; flex-wrap: wrap; gap: .75rem; margin-top: 1rem; }
.sp-generate-row .sp-status { flex: 1 1 18rem; margin: 0; }

.sp-option-choices {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
  gap: .65rem; margin-bottom: 1rem;
}
.sp-option-choice {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .35rem .6rem;
  width: 100%; padding: .75rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--t1); text-align: start;
}
.sp-option-choice:hover, .sp-option-choice:focus-visible { border-color: var(--brand); }
.sp-option-choice.is-active { border-color: var(--brand); background: var(--teal-dim); box-shadow: inset 0 0 0 1px var(--brand); }
.sp-option-choice-title, .sp-option-choice-coverage, .sp-option-choice > .sp-muted,
.sp-option-choice-missing { grid-column: 1; }
.sp-option-choice > .sp-tag { grid-column: 2; grid-row: 1; }
.sp-option-choice-coverage { font-weight: 700; color: var(--text-brand); }
.sp-option-choice-missing { color: var(--sev-warning); font-size: var(--text-xs); }
.sp-option-preview:empty { display: none; }
.sp-option { padding: 1rem; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.sp-option-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.sp-option-coverage { display: flex; align-items: center; flex-wrap: wrap; gap: .45rem; }
.sp-option-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin: .75rem 0; }
.sp-option-facts > div { display: flex; flex-direction: column; padding: .5rem .6rem; border-radius: var(--radius-sm); background: var(--teal-dim); }
.sp-option-facts span { color: var(--t2); font-size: var(--text-xs); }
.sp-option-facts strong { color: var(--t1); font-variant-numeric: tabular-nums; }
.sp-option-week { margin-bottom: .75rem; }
.sp-option-legend { display: flex; align-items: center; flex-wrap: wrap; gap: .75rem; margin: .25rem 0 .65rem; color: var(--t2); font-size: var(--text-xs); }
.sp-option-legend span::before { content: ""; display: inline-block; width: .65rem; height: .65rem; margin-inline-end: .3rem; border-radius: 50%; vertical-align: -.02rem; }
.sp-legend-current::before { background: #64748b; }
.sp-legend-proposed::before { background: var(--brand); }
.sp-recorded-clear { margin-inline-start: auto; color: var(--sev-ok); font-weight: 700; }
.sp-recorded-clear::before { background: var(--success); }
.sp-option-missing { margin: .75rem 0; padding: .7rem; border: 1px solid var(--warning); border-radius: var(--radius-sm); }
.sp-option-missing > strong { display: block; margin-bottom: .35rem; color: var(--sev-warning); }
.sp-unplaced-box { margin-top: 1rem; padding: .75rem; border: 1px solid var(--warning); border-radius: var(--radius-sm); }
.sp-copy-buffer { position: fixed; inset: -9999px auto auto -9999px; }
.sp-layout.is-busy .sp-course-card button,
.sp-layout.is-busy .sp-section-select,
.sp-layout.is-busy .sp-filter { pointer-events: none; opacity: .6; }

/* The same guard the adviser layout needs: a flex or grid `display` on a child
   beats the `hidden` attribute, and an "empty" message then sits under the list
   it was meant to replace. */
.sp-layout [hidden] { display: none !important; }

.sp-muted { color: var(--t2); }
.sp-note { margin: .75rem 0 .25rem; font-weight: 600; }
.sp-status { min-height: 1.5em; color: var(--t2); }
.sp-scroll-hint { margin: .35rem 0 0; color: var(--t2); font-size: var(--text-micro); }

/* Present to a screen reader, absent to the eye. The table caption names which
   option a row belongs to; on screen the heading above it already says so. */
.sp-visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.sp-requested, .sp-unplaced { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .375rem; }
.sp-code { font-weight: 600; }
.sp-name { color: var(--t2); }
.sp-reason { color: var(--t2); font-size: var(--text-base); }
.sp-added { font-size: var(--text-sm); color: var(--t2); margin: 0 0 .5rem; }

/* Fixed vs automatic is the distinction the student is actually managing, so it
   is a badge rather than a sentence. */
.sp-tag { font-size: var(--text-xs); border-radius: var(--radius-pill); padding: .125rem .5rem; border: 1px solid var(--line); }
.sp-tag-fixed { border-color: var(--brand); color: var(--text-brand); }
.sp-tag-auto { color: var(--t2); }

.sp-confirm { margin-top: .75rem; padding: .75rem; border: 1px solid var(--warning); border-radius: var(--radius-sm); }
.sp-warning { margin: 0 0 .5rem; font-weight: 600; color: var(--sev-warning); }

.sp-option-selected { border-color: var(--success); border-width: 2px; }
.sp-option .sp-option-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.sp-option header h3 { margin: 0; }

/* The timetable is wide and the page must not be, so the scroll lives on a
   WRAPPER. Putting `display:block` on the <table> itself scrolled correctly and
   silently stripped its table semantics. */
.sp-grid-wrap { overflow-x: auto; margin-bottom: .75rem; }
.sp-grid-wrap:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.sp-grid { width: 100%; border-collapse: collapse; font-size: var(--text-base); }
.sp-grid th, .sp-grid td { border-bottom: 1px solid var(--line); padding: .25rem .375rem; text-align: start; white-space: nowrap; }

@media (max-width: 480px) {
  /* `main` clips horizontal overflow, so a track wider than the viewport does not
     scroll — it disappears. The `min()` above is the real fix; this keeps the
     option cards readable once they are the full width. */
  .sp-option { padding: .5rem; }
  .sp-option-head { align-items: flex-start; flex-direction: column; }
  .sp-option-head .btn { width: 100%; }
}

@media (max-width: 900px) {
  .sp-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sp-course-layout { grid-template-columns: 1fr; }
  .sp-selection-panel { grid-row: 1; }
  .sp-catalog-panel { grid-row: 2; }
  .sp-catalog { max-height: 20rem; }
}

@media (max-width: 600px) {
  .sp-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sp-modes { grid-template-columns: 1fr; }
  .sp-selection-panel { padding: .75rem; }
  .sp-requested-controls { display: grid; grid-template-columns: minmax(0, 1fr); }
  .sp-requested-remove { width: 100%; justify-content: center; }
  .sp-current-chip { flex: 1 1 calc(50% - .45rem); justify-content: space-between; }
  .sp-recorded-clear { width: 100%; margin-inline-start: 0; }
}

/* ── student course detail ───────────────────────────────────────
   Server-rendered and zero-JavaScript, like the locked-course page it is reached
   from. Every string here arrived translated from `services/course_detail.py`;
   this file chooses a layout and nothing else. */
.cd-layout { display: flex; flex-direction: column; }
.cd-muted { color: var(--t2); }
.cd-empty { color: var(--t2); }

.cd-status { font-weight: 600; margin: 0 0 .5rem; }
.cd-status-blocked { color: var(--sev-warning); }
.cd-status-passed, .cd-status-open_now { color: var(--sev-ok); }

.cd-reasons, .cd-prereqs, .cd-options {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: .375rem;
}
.cd-reasons li { color: var(--t2); }
.cd-prereq, .cd-option { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.cd-code { font-weight: 600; }
/* a course code that links to its course: the brand colour, not the
   browser's default blue and underline */
a.cd-code { color: var(--text-brand); text-decoration: none; }
a.cd-code:hover,
a.cd-code:focus-visible { text-decoration: underline; text-underline-offset: 2px; }
.cd-name { color: var(--t2); }

/* The prerequisite's own state, as a badge — the affordance a chat answer cannot
   give: three of five marked passed, readable at a glance. */
.cd-tag { font-size: var(--text-xs); border-radius: var(--radius-pill); padding: .125rem .5rem; border: 1px solid var(--line); }
.cd-tag-passed { border-color: var(--success); color: var(--sev-ok); }
.cd-tag-blocked { border-color: var(--warning); color: var(--sev-warning); }
.cd-tag-studying, .cd-tag-open { color: var(--t2); }

.cd-actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }

/* ── student course guidance and prerequisite map ───────────────
   The course page is a decision surface; the full graph lives on its own route.
   These layouts keep the same server data readable from desktop down to phone. */
.student-course-jumps {
  display: flex;
  align-items: center;
  gap: .45rem;
  flex-wrap: wrap;
}
.student-course-jumps a {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  /* compact chips on the control ladder (32px; 40px on touch) */
  min-height: var(--control-h-sm);
  padding: 0 var(--control-px-sm);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--card);
  color: var(--t2);
  font-size: var(--control-fs-sm);
  line-height: var(--control-lh);
  font-weight: 600;
  text-decoration: none;
  transition: border-color .15s, color .15s, background .15s;
}
.student-course-jumps a:hover,
.student-course-jumps a:focus-visible {
  border-color: var(--teal);
  background: var(--teal-dim);
  color: var(--text-brand);
}
.student-course-jumps .student-course-jumps-map {
  margin-inline-start: auto;
  border-color: var(--teal-border);
  color: var(--text-brand);
}

.student-guidance-note {
  max-width: 72rem;
  padding: .55rem .7rem;
  border-inline-start: 3px solid var(--teal-border);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--teal) 5%, transparent);
  color: var(--t2);
  font-size: var(--text-sm);
  line-height: 1.55;
}

.student-section-title {
  display: flex;
  align-items: center;
  gap: .45rem;
  margin: 0 0 .75rem;
  color: var(--t1);
  font-family: var(--font-body);
  font-size: var(--text-md);
  font-weight: 700;
  line-height: 1.35;
}
.student-home-intro {
  display: flex;
  align-items: baseline;
  /* start-aligned under the start-aligned title, like every other page intro */
  justify-content: flex-start;
  gap: .25rem .4rem;
  flex-wrap: wrap;
}
.student-home-name {
  max-width: 100%;
  color: var(--t1);
  font-weight: 700;
  overflow-wrap: anywhere;
}
.student-home-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.student-home-jumps,
#student-home-summary,
.student-timetable-comparison-card,
.student-home-timetable-card,
#student-home-recommendations {
  scroll-margin-top: 1rem;
}
.student-timetable-comparison-card {
  border-inline-start: 4px solid var(--teal);
  background: color-mix(in srgb, var(--teal) 3%, var(--glass-bg-data));
}
.student-timetable-comparison-scope,
.student-timetable-state {
  display: inline-flex;
  align-items: center;
  width: max-content;
  min-height: 25px;
  padding: .18rem .5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  font-size: var(--text-micro);
  font-weight: 700;
  line-height: 1.2;
}
.student-timetable-comparison-scope {
  flex: 0 0 auto;
  color: var(--t2);
  background: var(--glass-bg-header);
}
.student-home-timetable-card {
  position: relative;
  overflow: hidden;
}
.student-home-timetable-card--registered { border-inline-start: 4px solid var(--teal); }
.student-home-timetable-card--expected { border-inline-start: 4px dashed var(--line-strong); }
.student-timetable-card-title {
  display: grid;
  gap: .35rem;
  min-width: 0;
}
.student-timetable-state--registered {
  border-color: var(--teal-border);
  background: var(--teal-dim);
  color: var(--text-brand);
}
.student-timetable-state--expected {
  border-style: dashed;
  background: var(--glass-bg-header);
  color: var(--t2);
}
.student-summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.student-summary-advisor {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  min-height: 34px;
  padding: .38rem .7rem;
  border: 1px solid var(--teal-border);
  border-radius: var(--radius-pill);
  background: var(--teal-dim);
  color: var(--text-brand);
  font-size: var(--text-sm);
  font-weight: 700;
  text-decoration: none;
  transition: border-color .15s, background .15s, color .15s;
}
.student-summary-advisor:hover,
.student-summary-advisor:focus-visible {
  border-color: var(--teal);
  background: color-mix(in srgb, var(--teal) 11%, transparent);
  color: var(--text-brand);
}

.student-timetable-host { min-width: 0; }
.student-timetable-calendar {
  overflow-x: auto;
  scrollbar-width: thin;
}
.student-timetable-calendar:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
}
.student-timetable-calendar .wg-blocks {
  min-width: 720px;
  border-color: var(--line-strong);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--line) 82%, var(--t3) 18%);
  box-shadow: 0 5px 16px rgba(17, 17, 68, .06);
}
.student-timetable-calendar .wg-segmented {
  display: grid;
  gap: .35rem;
  min-width: 720px;
}
.student-timetable-calendar .wg-segmented .wg-blocks {
  width: 100%;
  min-width: 0;
}
.student-timetable-calendar .wg-blocks .wg-h {
  background: var(--glass-bg-header);
  color: var(--t1);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: .015em;
}
.student-timetable-calendar .wg-blocks .wg-cor { color: var(--t2); }
.student-timetable-calendar .wg-blocks .wg-t {
  background: var(--glass-bg-header);
  color: var(--t2);
  font-size: var(--text-micro);
  font-weight: 700;
}
.student-timetable-calendar .wg-blocks .wg-cell {
  background: color-mix(in srgb, var(--glass-bg-data) 94%, var(--t2) 6%);
}
.student-timetable-calendar .wg-time-break {
  display: grid;
  grid-template-columns: minmax(24px, 1fr) auto auto minmax(24px, 1fr);
  align-items: center;
  gap: .55rem;
  min-height: 42px;
  padding: .3rem .6rem;
  color: var(--t2);
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
}
.student-timetable-calendar .wg-time-break::before,
.student-timetable-calendar .wg-time-break::after {
  content: "";
  height: 1px;
  background: repeating-linear-gradient(90deg, var(--line-strong) 0 6px, transparent 6px 11px);
}
.student-timetable-calendar .wg-time-break-label { white-space: nowrap; }
.student-timetable-calendar .wg-time-break-range {
  padding: .15rem .4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--glass-bg-header);
  color: var(--t1);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.student-timetable-calendar .wg-filled.student-timetable-block {
  justify-content: flex-start;
  gap: .14rem;
  padding: .34rem .42rem;
  border: 1px solid var(--line-strong);
  border-inline-start-width: 4px;
  border-radius: var(--radius-sm);
  box-shadow: 0 3px 10px rgba(17, 17, 68, .10);
}
.student-timetable-calendar .student-timetable-block--current {
  border-color: color-mix(in srgb, var(--teal) 42%, var(--line));
  border-inline-start-color: var(--teal);
  background: color-mix(in srgb, var(--surface) 82%, var(--teal) 18%);
}
.student-timetable-calendar .student-timetable-block--proposed {
  border-color: color-mix(in srgb, var(--t3) 40%, var(--line));
  border-inline-start-color: var(--t3);
  border-inline-start-style: dashed;
  background: color-mix(in srgb, var(--surface) 91%, var(--t2) 9%);
}
/* The student portal's own weighting. It used to hang off #studentHomeTimetable,
   which no longer exists: the portal now renders one host per snapshot
   (#studentHomeTimetable-registered / -expected). Left orphaned, the registered
   grid fell through to the neutral grey `--current` rule while the expected grid
   kept the brand accent — the emphasis exactly inverted, with the forecast
   looking like the fact. Keyed on the card class so it survives the next rename. */
.student-home-timetable-card .student-timetable-block--current {
  border-color: color-mix(in srgb, var(--teal) 46%, var(--line));
  border-inline-start-color: var(--teal);
  background: color-mix(in srgb, var(--surface) 80%, var(--teal) 20%);
}
/* The forecast reads as secondary: dashed edge, no brand fill. Colour is not the
   only carrier — the card heading and its "not an actual registration" line say
   it in words, and the agenda table repeats it for anyone who cannot see either. */
.student-home-timetable-card .student-timetable-block--proposed {
  border-inline-start-color: var(--t3);
  border-inline-start-style: dashed;
  background: color-mix(in srgb, var(--surface) 92%, var(--t2) 8%);
}
.student-timetable-block-section {
  flex: 0 0 auto;
  padding: .08rem .28rem;
  border: 1px solid color-mix(in srgb, var(--t3) 30%, var(--line));
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  color: var(--t2);
  font-family: var(--font-mono);
  font-size: var(--text-micro);
  font-weight: 700;
  line-height: 1.2;
}
.student-timetable-block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .3rem;
  min-width: 0;
}
.student-timetable-calendar .student-timetable-block > .wg-meta {
  display: block;
  color: var(--t1);
  font-size: var(--text-micro);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: start;
}
.student-timetable-calendar .student-timetable-block .wg-cid {
  color: var(--t1);
  font-size: var(--text-sm);
  font-weight: 700;
}
/* Dark: the blocks are light washes over a light segment, so the grey text on
   them was 3.6-4.1:1; the brightest ink gives 4.8:1 or better. */
html[data-theme="dark"] .student-timetable-calendar :is(.wg-h, .wg-cid, .wg-meta,
  .student-timetable-block-name, .student-timetable-block-time) { color: var(--t0); }
.student-timetable-block-name {
  display: -webkit-box;
  overflow: hidden;
  color: var(--t2);
  font-size: var(--text-micro);
  font-weight: 600;
  line-height: 1.25;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.student-timetable-block-source {
  overflow: hidden;
  color: var(--t2);
  font-size: var(--text-micro);
  font-weight: 700;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.student-timetable-agenda {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  border: 0;
  white-space: nowrap;
}
.student-timetable-day {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--glass-bg-data);
}
.student-timetable-day-title {
  margin: 0;
  padding: .55rem .7rem;
  border-block-end: 1px solid var(--line);
  background: color-mix(in srgb, var(--teal) 5%, var(--glass-bg-header));
  color: var(--t1);
  font-size: var(--text-sm);
  font-weight: 700;
}
.student-timetable-list {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}
.student-timetable-meeting {
  border-block-end: 1px solid var(--line);
}
.student-timetable-meeting:last-child { border-block-end: 0; }
.student-timetable-meeting > article {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .18rem .65rem;
  padding: .65rem .7rem;
}
.student-timetable-meeting--proposed > article {
  box-shadow: inset 3px 0 0 var(--brand);
}
[dir="rtl"] .student-timetable-meeting--proposed > article {
  box-shadow: inset -3px 0 0 var(--brand);
}
.student-timetable-meeting-head {
  display: flex;
  align-items: center;
  gap: .4rem;
  min-width: 0;
}
.student-timetable-code {
  color: var(--text-brand);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 700;
}
.student-timetable-section,
.student-timetable-source {
  padding: .08rem .36rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--t3);
  font-size: var(--text-micro);
  font-weight: 700;
  line-height: 1.35;
}
.student-timetable-source--proposed {
  border-color: var(--teal-border);
  color: var(--text-brand);
  background: var(--teal-dim);
}
.student-timetable-time {
  color: var(--t2);
  font-size: var(--text-xs);
  font-weight: 700;
  white-space: nowrap;
}
.student-timetable-name,
.student-timetable-meta {
  grid-column: 1 / -1;
  line-height: 1.45;
}
.student-timetable-name { color: var(--t1); font-size: var(--text-sm); overflow-wrap: anywhere; }
.student-timetable-meta { color: var(--t3); font-size: var(--text-xs); }
.student-timetable-empty {
  margin: 0;
  padding: .75rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--glass-bg-data);
  color: var(--t2);
  font-size: var(--text-sm);
}
.student-timetable-exact {
  border-top: 1px solid var(--line);
  padding-top: .7rem;
}
.student-disclosure > summary,
.student-timetable-exact > summary {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  width: max-content;
  max-width: 100%;
  min-height: 44px;
  padding: .35rem .15rem;
  cursor: pointer;
  color: var(--text-brand);
  font-size: var(--text-sm);
  font-weight: 700;
  list-style: none;
}
.student-disclosure > summary::after,
.student-timetable-exact > summary::after {
  content: "⌄";
  display: inline-block;
  color: currentColor;
  font-size: .95rem;
  transition: transform .15s ease;
}
.student-disclosure[open] > summary::after,
.student-timetable-exact[open] > summary::after { transform: rotate(180deg); }
.student-disclosure > summary:focus-visible,
.student-timetable-exact > summary:focus-visible {
  border-radius: var(--radius-sm);
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}
.student-timetable-exact[open] > summary { margin-bottom: .65rem; }
.student-timetable-table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  scrollbar-width: thin;
}
.student-timetable-table-scroll:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
}
.student-timetable-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  color: var(--t1);
  font-size: var(--text-sm);
}
.student-timetable-table th,
.student-timetable-table td {
  padding: .5rem .6rem;
  border-block-end: 1px solid var(--line);
  text-align: start;
  vertical-align: top;
}
.student-timetable-table thead th {
  background: var(--glass-bg-header);
  color: var(--t2);
  font-size: var(--text-xs);
  font-weight: 700;
  white-space: nowrap;
}
.student-timetable-table tbody tr:last-child > * { border-block-end: 0; }
.student-timetable-table td:nth-child(n + 2) { white-space: nowrap; }
.student-home-subtitle {
  margin-bottom: .5rem;
  color: var(--t2);
  font-size: var(--text-sm);
  font-weight: 700;
}
.student-home-unscheduled {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  list-style: none;
}
.student-home-unscheduled li {
  padding: .35rem .55rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--glass-bg-data);
  color: var(--t2);
  font-size: var(--text-xs);
  font-weight: 700;
}
.student-home-empty {
  padding: .75rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--glass-bg-data);
  color: var(--t2);
  font-size: var(--text-sm);
  line-height: 1.6;
}
.student-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .5rem;
}
.student-kpi-grid .kpi { min-width: 0; }
.student-course-progress-grid {
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
}
.student-course-progress-caption {
  color: var(--t3);
  font-size: var(--text-sm);
  line-height: 1.55;
}

.student-next-step {
  display: flex;
  align-items: baseline;
  gap: .55rem;
  padding: .65rem .75rem;
  border: 1px solid var(--teal-border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--teal) 6%, transparent);
  color: var(--t2);
}
.student-next-step-label {
  flex: 0 0 auto;
  color: var(--text-brand);
  font-family: var(--font-mono);
  font-size: var(--text-micro);
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.student-evidence-note {
  padding-inline-start: .7rem;
  border-inline-start: 3px solid var(--line-strong);
  line-height: 1.6;
}

.student-course-group + .student-course-group {
  padding-top: .85rem;
  border-top: 1px solid var(--line);
}
.student-course-group-head {
  display: flex;
  align-items: center;
  gap: .45rem;
  margin-bottom: .2rem;
}
.student-course-group-head h3,
.student-blocker-body h3 {
  margin: 0;
  color: var(--t2);
  font-size: var(--text-sm);
  font-weight: 700;
}
.student-course-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .55rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.student-course-list > li { min-width: 0; }
.student-course-list > li > .student-course-row { height: 100%; }
.student-course-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: .35rem .75rem;
  min-height: 96px;
  padding: .75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--glass-bg-data);
  color: inherit;
  text-decoration: none;
  transition: border-color .15s, background .15s, transform .15s;
}
.student-course-row:hover,
.student-course-row:focus-visible {
  transform: translateY(-1px);
  border-color: var(--teal-border);
  background: color-mix(in srgb, var(--teal) 5%, var(--glass-bg-data));
}
.student-course-row:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}
.student-course-code {
  width: max-content;
  color: var(--text-brand);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 700;
  text-decoration: none;
}
.student-course-code:hover,
.student-course-code:focus-visible { text-decoration: underline; text-underline-offset: 3px; }
.student-course-code { grid-column: 1; grid-row: 1; }
.student-course-name {
  grid-column: 1 / -1;
  grid-row: 2;
  min-width: 0;
  color: var(--t1);
  font-size: var(--text-base);
  line-height: 1.45;
}
.student-course-credits {
  grid-column: 1 / -1;
  grid-row: 3;
  color: var(--t3);
  font-size: var(--text-xs);
  white-space: nowrap;
}
.student-course-status {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
}

.student-elective-note {
  display: flex;
  align-items: center;
  gap: .55rem;
  flex-wrap: wrap;
  padding: .65rem .75rem;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--royal) 5%, transparent);
}

.student-blocker-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .55rem;
  align-items: start;
}
.student-blocker-item {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--glass-bg-data);
}
.student-blocker-item[open] { border-color: var(--teal-border); }
.student-blocker-item > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  min-height: 48px;
  padding: .55rem .7rem;
  cursor: pointer;
  list-style: none;
}
.student-blocker-item > summary::-webkit-details-marker { display: none; }
.student-blocker-item > summary::after {
  content: '+';
  flex: 0 0 auto;
  color: var(--text-brand);
  font-size: 1rem;
  font-weight: 700;
}
.student-blocker-item[open] > summary::after { content: '−'; }
.student-blocker-course { display: flex; min-width: 0; align-items: baseline; gap: .4rem; }
.student-blocker-course span {
  overflow: hidden;
  color: var(--t3);
  font-size: var(--text-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.student-blocker-badges { display: flex; gap: .25rem; margin-inline-start: auto; }
.student-blocker-body {
  padding: .7rem;
  border-top: 1px solid var(--line);
  color: var(--t2);
  font-size: var(--text-sm);
}
.student-blocker-body ul { padding-inline-start: 1.25rem; }

.student-map-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-color: var(--teal-border);
  background: linear-gradient(115deg, color-mix(in srgb, var(--teal) 8%, var(--card)), var(--card));
}
.student-map-cta .student-section-title { display: block; }

.student-map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.student-map-counts {
  display: flex;
  align-items: center;
  gap: .8rem;
  flex-wrap: wrap;
  color: var(--t3);
  font-size: var(--text-xs);
  font-weight: 700;
}
.student-map-counts span { display: inline-flex; align-items: center; gap: .3rem; }
.student-map-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--t4); }
.student-map-dot.is-passed { background: var(--success); }
.student-map-dot.is-studying { background: var(--royal); }
.student-map-dot.is-open { background: var(--teal); }
.student-map-dot.is-locked { background: var(--t4); }
.student-plan-map-card { min-height: 480px; }
.student-plan-map-intro { display: flex; align-items: start; justify-content: space-between; gap: 1rem; }
.student-plan-map-host {
  min-height: 0;
  max-width: 100%;
  overflow-x: auto;
  padding-block: 1rem;
  scrollbar-gutter: stable;
  overscroll-behavior-inline: contain;
}

@media (max-width: 768px) {
  .page-header-chips .student-program-chip { display: none; }
  .page-header-chips .student-term-chip { flex: 0 0 auto; }
  .student-summary-header { align-items: flex-start; flex-wrap: wrap; }
  .student-home-section-head { align-items: flex-start; }
  .student-timetable-comparison-card .student-home-section-head { flex-wrap: wrap; }
  .student-summary-advisor { min-height: 44px; padding: .45rem .7rem; font-size: var(--text-xs); }
  .student-timetable-calendar { display: none; }
  .student-timetable-agenda {
    position: static !important;
    display: grid;
    width: auto;
    height: auto;
    padding: 0;
    margin: 0;
    overflow: visible;
    clip: auto;
    clip-path: none;
    border: 0;
    gap: .65rem;
    white-space: normal;
  }
  .sp-week .student-timetable-agenda { margin-top: .1rem; }
  .sp-scroll-hint { display: none; }
  .student-course-jumps { gap: .35rem; }
  .student-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .student-kpi-grid .kpi { padding: .55rem; }
  .student-next-step { align-items: flex-start; flex-direction: column; gap: .25rem; }
  .student-course-list { grid-template-columns: 1fr; }
  .student-course-row {
    min-height: 92px;
    padding: .7rem;
  }
  .student-course-name { font-size: var(--text-sm); }
  .student-blocker-list { grid-template-columns: 1fr; }
  .student-blocker-course { flex-direction: column; gap: .05rem; }
  .student-blocker-course span { max-width: 13rem; }
  .student-blocker-badges { flex-direction: column; align-items: flex-end; }
  .student-map-cta,
  .student-map-toolbar { align-items: stretch; flex-direction: column; }
  .student-map-cta .btn { width: 100%; }
  .student-map-counts { justify-content: space-between; gap: .4rem; }
  .student-plan-map-card { min-height: 0; padding: .75rem !important; }
  .student-plan-map-card .cp-h { align-items: flex-start; flex-wrap: wrap; padding: .75rem; }
  .student-plan-map-host { min-height: 0; padding: .75rem; }
  .student-map-device-note { line-height: 1.5; }
}

/* On a phone the section links are ONE row you swipe, not a grid of two-line
   pill blobs with an orphan on the last line. It bleeds to the screen edges
   (main pads 1rem) so the next chip peeks in as the cue that the row runs on. */
@media (max-width: 480px) {
  .student-course-jumps {
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    /* snap to the padded edge: the first chip was snapped to x=0, border cut */
    scroll-padding-inline: 1rem;
    scrollbar-width: none;
    margin-inline: -1rem;
    padding-inline: 1rem;
    padding-block: 2px;
  }
  .student-course-jumps::-webkit-scrollbar { display: none; }
  .student-course-jumps a {
    flex: none;
    white-space: nowrap;
    scroll-snap-align: start;
  }
  .student-course-jumps .student-course-jumps-map { margin-inline-start: 0; }
}

/* Student graduation progress and read-only completion scenario. */
.student-grad-progress-head,
.student-grad-path-heading,
.student-grad-term-head,
.student-grad-blocker-title,
.student-page-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.student-grad-progress-value {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  white-space: nowrap;
}
.student-grad-progress-value strong {
  color: var(--text-brand);
  font-family: var(--font-serif);
  font-size: 1.85rem;
  line-height: 1;
}
.student-grad-progress-value span { color: var(--t3); font-size: var(--text-xs); }
.student-grad-progress-track {
  width: 100%;
  height: 10px;
  margin-top: .75rem;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--brand-soft);
  box-shadow: 0 1px 2px rgba(0,0,0,.04) inset;
}
.student-grad-progress-track > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--sky));
}
.student-grad-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .5rem;
}
.student-grad-record-note {
  padding-top: .55rem;
  border-top: 1px solid var(--line);
  color: var(--t2);
  font-size: var(--text-sm);
}
.student-grad-record-note > summary,
.student-grad-map-details > summary {
  width: max-content;
  /* never wider than its card: the Arabic summary ran out of it on a phone */
  max-width: 100%;
  overflow-wrap: anywhere;
  cursor: pointer;
  color: var(--text-brand);
  font-weight: 700;
}
.student-grad-result {
  padding: .9rem 1rem;
  border: 1px solid var(--teal-border);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--teal) 6%, var(--card));
}
.student-grad-result.is-incomplete {
  border-color: color-mix(in srgb, var(--warning) 40%, var(--line));
  background: color-mix(in srgb, var(--warning) 7%, var(--card));
}
.student-grad-result-status {
  display: block;
  margin-bottom: .35rem;
  color: var(--t2);
  font-size: var(--text-xs);
  font-weight: 700;
}
.student-grad-result-answer {
  display: flex;
  align-items: baseline;
  gap: .65rem;
  margin-bottom: .35rem;
}
.student-grad-result-answer strong {
  color: var(--text-brand);
  font-family: var(--font-serif);
  font-size: var(--text-numeral);
  line-height: 1;
}
.student-grad-result.is-incomplete .student-grad-result-answer strong { color: var(--sev-warning); }
.student-grad-result-answer span { color: var(--t1); font-size: var(--text-md); font-weight: 700; }
.student-grad-support-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .55rem;
}
.student-grad-support {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .18rem .55rem;
  padding: .7rem .75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--glass-bg-data);
}
.student-grad-support > span { color: var(--t2); font-size: var(--text-sm); font-weight: 700; }
.student-grad-support > strong { grid-column: 2; grid-row: 1 / span 2; align-self: center; color: var(--text-brand); font-size: var(--text-xl); }
.student-grad-support > small { grid-column: 1; color: var(--t3); font-size: var(--text-xs); line-height: 1.4; }
.student-grad-assumptions,
.student-grad-code-list {
  display: flex;
  align-items: center;
  gap: .35rem;
  flex-wrap: wrap;
}
.student-grad-assumptions > span,
.student-grad-code-list > bdi {
  padding: .25rem .5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--glass-bg-data);
  color: var(--t2);
  font-size: var(--text-micro);
  font-weight: 700;
}
.student-grad-current-assumption {
  display: flex;
  align-items: center;
  gap: .35rem .5rem;
  flex-wrap: wrap;
  color: var(--t2);
  font-size: var(--text-sm);
  line-height: 1.55;
}
.student-grad-expected-comparison {
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--teal) 34%, var(--line));
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--teal) 5%, var(--card));
}
.student-grad-expected-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
  padding: .8rem;
  border-bottom: 1px solid var(--line);
}
.student-grad-expected-heading h3 {
  margin: 0 0 .25rem;
  color: var(--t1);
  font-size: var(--text-base);
  font-weight: 700;
}
.student-grad-expected-heading p {
  color: var(--t2);
  font-size: var(--text-sm);
  line-height: 1.65;
}
.student-grad-expected-courses {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .45rem;
  margin: 0;
  padding: .7rem .8rem;
  list-style: none;
}
.student-grad-expected-courses li {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: .12rem .5rem;
  padding: .55rem .6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--glass-bg-data);
}
.student-grad-expected-courses bdi { color: var(--text-brand); font-size: var(--text-sm); font-weight: 700; }
.student-grad-expected-courses span { overflow: hidden; color: var(--t1); font-size: var(--text-xs); font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.student-grad-expected-courses small { grid-column: 1 / -1; color: var(--t3); font-size: var(--text-micro); }
.student-grad-expected-impact {
  margin-inline: .8rem;
  padding: .65rem .75rem;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--teal) 9%, var(--glass-bg-data));
  color: var(--t1);
  font-size: var(--text-sm);
  line-height: 1.6;
}
.student-grad-expected-comparison > .student-guidance-note { margin-inline: .8rem; margin-bottom: .8rem !important; }
.student-grad-blockers {
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--warning) 35%, var(--line));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--warning) 4%, var(--card));
}
.student-grad-blockers > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  min-height: 44px;
  padding: .6rem .75rem;
  cursor: pointer;
  color: var(--t1);
  font-weight: 700;
}
.student-grad-blocker-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .5rem;
  padding: .65rem;
  border-top: 1px solid var(--line);
}
.student-grad-blocker {
  padding: .65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--glass-bg-data);
  color: var(--t2);
  font-size: var(--text-sm);
  line-height: 1.55;
}
/* An unsatisfiable prerequisite is a curriculum fault, not a course the student
   has yet to take. It must not read like the ordinary missing-prerequisite line
   directly above it. */
.student-grad-blocker-unsatisfiable,
.ap-grad-blocker-unsatisfiable {
  margin-top: .3rem;
  padding: .35rem .5rem;
  border-inline-start: 3px solid var(--amber);
  border-radius: var(--radius-sm);
  background: var(--amber-dim);
  color: var(--sev-warning);
  font-weight: 700;
}
.student-grad-blocker-unsatisfiable bdi,
.ap-grad-blocker-unsatisfiable bdi { font-weight: 700; }
.student-grad-blocker-title { align-items: baseline; justify-content: flex-start; margin-bottom: .3rem; }
.student-grad-blocker-title bdi { color: var(--text-brand); font-weight: 700; }
.student-grad-blocker-title span { overflow: hidden; color: var(--t1); font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.student-grad-path {
  display: flex;
  flex-direction: column;
}
.student-grad-path-heading { order: 0; align-items: flex-start; }
.student-grad-map-details { order: 1; }
.student-grad-timeline { order: 2; }
.student-grad-timeline {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .65rem;
}
.student-grad-term {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--glass-bg-data);
}
.student-grad-term::before {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 3px;
  background: var(--teal-border);
  content: '';
}
.student-grad-term.is-current { border-color: color-mix(in srgb, var(--royal) 32%, var(--line)); }
.student-grad-term.is-current::before { background: var(--royal); }
.student-grad-term.is-blocked { border-color: color-mix(in srgb, var(--warning) 45%, var(--line)); }
.student-grad-term.is-blocked::before { background: var(--warning); }
.student-grad-term-head {
  align-items: flex-start;
  padding: .65rem .75rem;
  border-bottom: 1px solid var(--line);
}
.student-grad-term-head > div { display: flex; flex-direction: column; gap: .08rem; }
.student-grad-term-head > div span { color: var(--t1); font-size: var(--text-sm); font-weight: 700; }
.student-grad-term-head > div strong,
.student-grad-term-head > span { color: var(--t3); font-size: var(--text-xs); }
.student-grad-term-courses { list-style: none; margin: 0; padding: .35rem .75rem .55rem; }
.student-grad-term-courses li {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) auto;
  align-items: baseline;
  gap: .5rem;
  padding: .3rem 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.student-grad-term-courses li:last-child { border-bottom: 0; }
.student-grad-term-courses bdi { color: var(--text-brand); font-size: var(--text-xs); font-weight: 700; }
.student-grad-term-courses li > span { overflow: hidden; color: var(--t2); font-size: var(--text-xs); text-overflow: ellipsis; white-space: nowrap; }
.student-grad-term-courses small { color: var(--t3); font-size: var(--text-micro); white-space: nowrap; }
.student-grad-map-details {
  padding-top: .7rem;
  border-top: 1px solid var(--line);
}
.student-grad-map-host {
  min-height: 320px;
  padding: .75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--glass-bg-data);
}
.student-page-actions { justify-content: flex-start; flex-wrap: wrap; }

@media (max-width: 768px) {
  .student-grad-progress-head,
  .student-grad-path-heading { align-items: flex-start; flex-direction: column; }
  .student-grad-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .student-grad-kpis .kpi:last-child { grid-column: 1 / -1; }
  .student-grad-result-answer { align-items: flex-start; flex-direction: column; gap: .25rem; }
  .student-grad-support-grid,
  .student-grad-blocker-list,
  .student-grad-timeline { grid-template-columns: 1fr; }
  .student-grad-expected-heading { flex-direction: column; }
  .student-grad-expected-courses { grid-template-columns: 1fr; }
  .student-grad-map-details { display: none; }
  .student-page-actions { align-items: stretch; flex-direction: column; }
  .student-page-actions .btn { width: 100%; }
}

/* ============================================================
   STYLE CHECK S1 — shared recipes that need the last word
   ------------------------------------------------------------
   Rules here repair drift between pages. They sit at the END so they win
   over the page-by-page rules above at equal specificity, and each one names
   the finding it closes (docs: the UI styling check, G-numbers).
   ============================================================ */

/* G6 — ONE table-header recipe. Four tables used four: mono 12.7px, mono 11.2px,
   mono 10px, Inter 10.9px. Now Inter 12px 700, uppercase, 0.06em, the --t3 label
   (6.4:1 light; 6.0:1 on the dark header). Arabic has no capitals and joins its
   letters, so it takes neither case nor tracking. */
.table-wrap thead th,
.tbl-card thead th,
.audit-table th,
#umTable thead th,
.dba-snapshot-table thead th,
.dba-current-import-table thead th,
.ap-grad-term-table th,
.ai-cases thead th {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1.3;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
html[dir="rtl"] .table-wrap thead th,
html[dir="rtl"] .tbl-card thead th,
html[dir="rtl"] .audit-table th,
html[dir="rtl"] #umTable thead th,
html[dir="rtl"] .dba-snapshot-table thead th,
html[dir="rtl"] .dba-current-import-table thead th,
html[dir="rtl"] .ap-grad-term-table th,
html[dir="rtl"] .ai-cases thead th {
  text-transform: none;
  letter-spacing: 0;
  /* the header is told from the body by weight alone, and 700 Kufi closes up
     at 14px; a header that wraps (narrow columns do) needs the Arabic leading */
  font-weight: 600;
  line-height: 1.5;
}

/* G7 — no Latin typography on Arabic. Letter-spacing pulls apart letters that
   must join; case and italics are Latin devices. Latin islands (`dir="ltr"`,
   <code>) keep their tracking. */
html[dir="rtl"] *:not(code, kbd, samp, pre, [dir="ltr"], [dir="ltr"] *) {
  letter-spacing: normal;
}
html[dir="rtl"] :is(th, label, legend, .form-label, .pf-label, .wg-h, .card-heading,
    [class*="label"], [class*="lbl"], [class*="kicker"], [class*="eyebrow"],
    [class*="badge"], [role="tab"], [id^="lbl-"], [id^="tab-"], [id$="Badge"]) {
  text-transform: none;
}
html[dir="rtl"] :is(.empty-note, .um-time-never, .ap-grad-wait-text, .sa-status-pending) {
  font-style: normal;
}
/* a rule with three classes outranks the universal one above */
html[dir="rtl"] .student-timetable-calendar .wg-blocks .wg-h { letter-spacing: 0; }
/* Nor a Latin face. JetBrains Mono has no Arabic, so an Arabic label set in it
   is drawn in Noto Kufi, but its spaces stay the mono's: 0.6em against Kufi's
   0.34em, so the words of a kicker stood almost twice as far apart. Labels
   take the body face; codes, fields and Latin islands keep the mono. */
html[dir="rtl"] body:not(.twm-root):not(.tws-root) :is([class*="kicker"], [class*="eyebrow"],
    .dcc-kpi-label, .audit-filter-label, .audit-count, .audit-view-btn, .audit-page-info,
    .audit-page-current, .scrape-term-toggle, .scrape-term-empty, .section-badge,
    .si-dropzone-file, .si-dropzone-copy small,
    .admin-grad-lookup-head > div > span):not(code, kbd, samp, pre, input, textarea, select,
    [dir="ltr"] *, .tw-mri *, .sidebar *, .sbp *, .tg-shell *) {
  font-family: var(--font-body);
  letter-spacing: normal;
}
/* The prerequisite graph is a left-to-right island (its tiers run left to
   right in both languages), so the rule above skips it: its Arabic band
   labels, legend and mode buttons are named here. */
html[dir="rtl"] :is(.pg-band-lbl, .pg-legend, .pg-legend *, .pg-mode, .pg-info) {
  font-family: var(--font-body);
  letter-spacing: normal;
}
/* the audit log's times stay in step down the column without the mono */
html[dir="rtl"] .audit-ts { font-family: var(--font-body); font-variant-numeric: tabular-nums; }
/* Small Arabic labels at 700 close their counters up; Latin small labels are
   700 for the capitals Arabic does not have. Headings keep 700. */
html[dir="rtl"] body:not(.twm-root):not(.tws-root) :is([class*="kicker"], [class*="eyebrow"],
    .badge, .section-badge, .dcc-kpi-label, .audit-filter-label, .pf-label, .ph-chip,
    .kpi .k):not(.tw-mri *, .sidebar *, .sbp *, .tg-shell *) {
  font-weight: 600;
}

/* G18 — Arabic leading. Noto Kufi's letters reach higher (alef, hamza) and
   lower (descenders, kasra) than Inter's, so the Latin 1.0-1.3 leading crowds
   or crops them wherever a line wraps, is clamped, or sits on a background.
   These are the places the Arabic probe measured under 1.4 that do. */
html[dir="rtl"] body:not(.twm-root):not(.tws-root) .badge:not(.tw-mri *, .sidebar *, .sbp *) {
  line-height: 1.5;
  padding-block: 0;  /* the pill keeps its height: 0.25em + 1 + 0.25em before */
}
html[dir="rtl"] :is(.ux-toast-title, .dba-nav-name, .admin-grad-journey strong, .admin-grad-eyebrow,
    .student-timetable-comparison-scope, .student-timetable-state, .student-timetable-block-name) {
  line-height: 1.5;
}
html[dir="rtl"] :is(.dcc-triage-row small, .admin-grad-journey small) { line-height: 1.6; }
html[dir="rtl"] .admin-grad-search .admin-grad-landing-copy h2 { line-height: 1.3; }
/* the sign-in title and the overview greeting: no Arabic in DM Serif Display,
   so the body face at 600 rather than Kufi at the serif's one weight */
html[dir="rtl"] .login-title { font-family: var(--font-body); font-weight: 600; line-height: 1.4; }
html[dir="rtl"] .ov-greeting { font-family: var(--font-body); font-weight: 600; }
/* The exam builder's course card: the Arabic name is a two-line clamp whose cap
   was 2.6em, two lines at 1.3; at 1.5 it is 3em. In the dense grid it takes one
   step (13px) and the Latin code stays at 12px. */
html[dir="rtl"] main.exam-builder-page .et-course-card .et-course-short-name {
  font-size: var(--text-sm);
  line-height: 1.5;
  max-height: 3em;
}
html[dir="rtl"] main.exam-builder-page .et-quick-metric { line-height: 1.5; }
@media (min-width: 769px) {
  /* the edit toolbar's buttons take one step on a desktop (12 to 13px); the
     phone's six-column grid has no width to give */
  html[dir="rtl"] main.exam-builder-page .et-edit-controls { --text-xs: max(13px, 0.8125rem); }
}
/* Wrapped card and section headings take the Arabic leading too. */
html[dir="rtl"] body:not(.twm-root):not(.tws-root) :is(.advisor-block h3, .zone-title, .um-panel-title,
    .cp-t, .dba-section-title, .pf-card-title, .pane-title, .ap-drawer-section-title,
    .student-section-title):not(.tw-mri *, .sidebar *, .sbp *) {
  line-height: 1.5;
  text-wrap: balance;
}
/* the intro's heading does not take its paragraph's 1.75 */
html[dir="rtl"] .page-intro h2 { line-height: 1.4; }
html[dir="rtl"] :is(.page-intro p, .panel-sub, .empty-hint) { text-wrap: pretty; }
/* An Arabic placeholder is prose: the body face, even in a mono field (the
   graduation lookup's "مثال: 4504484" was JetBrains Mono at 700). */
html[dir="rtl"] body:not(.twm-root):not(.tws-root) :is(input, textarea):not(.tw-mri *, .sidebar *, .sbp *)::placeholder {
  font-family: var(--font-body);
  font-weight: 400;
}

/* G19 — Arabic fits. What the larger Arabic steps no longer fitted where they
   were (measured, before and after, in Chrome and in the fit tests' wide font). */
/* The audit log's table holds Latin data at the Latin step (held above); its
   Arabic headers and its Arabic dates take the Arabic one. */
html[dir="rtl"] .audit-table thead,
html[dir="rtl"] .audit-table .audit-ts { --text-xs: max(14px, 0.875rem); }
/* The exam rosters' lookup: its fixed period column held "08:00-10:00" at
   13px; at 15px it broke the time at the hyphen. */
html[dir="rtl"] main.exam-rosters-page .et-lookup-table th.et-col-period { width: 128px; }
@media (max-width: 760px) {
  /* Group availability: three equal tabs that may wrap, not a strip that cut
     its third ("اليوم الكامل (10 د)") */
  html[dir="rtl"] .ga-tab {
    flex: 1 1 0; min-width: 0;
    padding-inline: 0.4rem;
    white-space: normal; line-height: 1.4; text-align: center;
  }
}
@media (max-width: 480px) {
  /* The advisor portfolio's three export buttons share one phone line at the
     Latin button step: any one that wrapped would be left alone on its line. */
  html[dir="rtl"] .fb-fit .fb-actions:has(> #apCsvLink) { --control-fs-sm: max(13px, 0.8125rem); }
}

/* G11 — DM Serif Display has ONE weight (400). Every element set in it says so,
   so nothing is asked for a bold that the browser would have to fake. */
.logo-title, .metric .v, .mc-val, .kpi .v, .ov-greeting,
.ov-kpi-value, .dcc-kpi strong, .dcc-mini-grid strong,
.dba-snapshot-metric strong, .sp-mc .v,
.admin-grad-search .admin-grad-landing-copy h2,
.sp-boundary-icon, .student-grad-progress-value strong,
.student-grad-result-answer strong {
  font-weight: 400;
}
/* (Section, card, table and empty-state headings are set in the body face now —
   serif is for the page title and display numerals — so they left this list.) */

/* G13 — codes, hashes and paths are left-to-right text: in an Arabic line the
   browser otherwise reorders the neutral characters around them (a path such as
   /ops/exam-timetable/488/ reads in segments backwards). An isolated LTR run is
   what <bdi dir="ltr"> does; these classes get it from CSS. */
code, kbd, samp {
  direction: ltr;
  unicode-bidi: isolate;
}
.audit-hash, .audit-id, .audit-endpoint {
  unicode-bidi: isolate;
}
html[dir="rtl"] .audit-endpoint {
  direction: ltr;
  text-align: right;
}

/* G14 — the bespoke buttons join the .btn scale. Measured heights 24/25/29/30px
   and radii 7/8/10px beside the 32px `.btn-sm`: the planner's Fetch was 24px
   next to a 37px field. Small = the compact tier of the control ladder. */
.bulk-bar button {
  min-height: var(--control-h-sm);
  border-radius: var(--control-radius);
}
.bulk-bar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* G16 — the sidebar menu is taller than a laptop screen (1188px of links in 690px)
   and gave no sign of it: the active row was cut in half and the last groups were
   out of sight. A visible thin scrollbar, and a fade at whichever edge has more
   to scroll to: the bottom fade is full at the top and gone at the end, the top
   fade grows in once you have scrolled. Scroll-linked, no script. A menu that
   fits does not scroll, so its timeline is inactive and no fade is drawn. */
/* Its own scrollbar, not the operating system's.

   `scrollbar-width: thin` is the whole of what the standard property offers:
   it cannot set a width, a radius or a track, and what it draws is still the
   platform's bar. The ::-webkit-scrollbar pseudo-elements can draw all three
   — but a browser ignores them for a scroller as soon as `scrollbar-width` or
   `scrollbar-color` is set on it to anything but `auto`, and `*` near the top
   of this sheet sets `scrollbar-width: thin` on everything. Putting both back
   to `auto` here is what hands this scroller to the rules below.

   Firefox has no such pseudo-elements, so it keeps the standard properties
   and gets the thin bar in the same colour. */
.nav-sec,
.sbp-list { scrollbar-width: auto; scrollbar-color: auto; }

@supports not selector(::-webkit-scrollbar) {
  .nav-sec,
  .sbp-list { scrollbar-width: thin; scrollbar-color: var(--sb-thumb) transparent; }
}

/* A 4px pill inside an 8px gutter: the transparent border is the padding, and
   `background-clip: padding-box` keeps the fill off it.

   Each selector names the ancestor as well. The sheet already carries global
   `html[data-theme="dark"] ::-webkit-scrollbar-*` rules, dormant until now
   because `scrollbar-width` was set on everything; the reset above wakes them
   for this scroller, and at (0,1,1) they outrank a bare `.nav-sec::...`. The
   ancestor takes these to (0,2,0), which wins on specificity rather than on
   where they happen to sit in the file. */
.sidebar .nav-sec::-webkit-scrollbar,
.sbp-panel .sbp-list::-webkit-scrollbar { width: 7px; height: 7px; }

.sidebar .nav-sec::-webkit-scrollbar-track,
.sbp-panel .sbp-list::-webkit-scrollbar-track { background: transparent; }

.sidebar .nav-sec::-webkit-scrollbar-thumb,
.sbp-panel .sbp-list::-webkit-scrollbar-thumb {
  background:      var(--sb-thumb);
  background-clip: padding-box;
  /* 2px of transparent padding in a 7px gutter leaves a 3px pill. A browser
     snaps a scrollbar border to whole pixels, so 2.5px in 8px gives 4px. */
  border:          2px solid transparent;
  border-radius:   99px;
}

/* The full teal while the pointer is over the list. */
.sidebar .nav-sec:hover::-webkit-scrollbar-thumb,
.sbp-panel .sbp-list:hover::-webkit-scrollbar-thumb {
  /* The longhand, not `background`: a var() inside a shorthand is dropped from
     the CSSOM, and getComputedStyle on a pseudo-element does not follow the
     host's :hover — so the longhand is the only way a test can read this. */
  background-color: var(--sb-thumb-strong);
  background-clip:  padding-box;
}
@property --nav-fade-t { syntax: '<length>'; inherits: false; initial-value: 0px; }
@property --nav-fade-b { syntax: '<length>'; inherits: false; initial-value: 0px; }
@keyframes nav-scroll-cue {
  0%   { --nav-fade-t: 0px;  --nav-fade-b: 28px; }
  8%   { --nav-fade-t: 24px; --nav-fade-b: 28px; }
  92%  { --nav-fade-t: 24px; --nav-fade-b: 28px; }
  100% { --nav-fade-t: 24px; --nav-fade-b: 0px; }
}
@supports (animation-timeline: scroll()) {
  .nav-sec {
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 var(--nav-fade-t),
                        #000 calc(100% - var(--nav-fade-b)), transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0, #000 var(--nav-fade-t),
                #000 calc(100% - var(--nav-fade-b)), transparent 100%);
    animation: nav-scroll-cue linear both;
    animation-timeline: scroll(self block);
  }
}
@media (prefers-reduced-motion: reduce) {
  /* the reduced-motion rule above shortens every animation to 0.01ms; a scroll
     timeline has no duration, and a fade is not motion */
  .nav-sec { animation-duration: auto !important; }
}

/* G17 — a table wider than its frame scrolls sideways and said nothing of it:
   the exports table's Copy column, the audit log's hash and the batch table's
   share column were cut at the frame's edge with no sign of more (UI review 3).
   The menu's cue (G16), across: the far edge fades while there is more that
   way, the near edge once you have scrolled. A table that fits does not
   scroll, so no fade is drawn; an Arabic table fades its left edge first.
   Only where scrollbars are overlays, on a touch screen: there the fade is the
   only cue, while a mouse desktop already draws the scrollbar, which a mask
   would fade with the table. And not while the frame has keyboard focus: a
   mask also clips what is drawn outside the box, which is where its focus
   ring is (the audit log's table is a tab stop). */
@property --tbl-fade-s { syntax: '<length>'; inherits: false; initial-value: 0px; }
@property --tbl-fade-e { syntax: '<length>'; inherits: false; initial-value: 0px; }
@keyframes tbl-scroll-cue {
  0%   { --tbl-fade-s: 0px;  --tbl-fade-e: 28px; }
  8%   { --tbl-fade-s: 24px; --tbl-fade-e: 28px; }
  92%  { --tbl-fade-s: 24px; --tbl-fade-e: 28px; }
  100% { --tbl-fade-s: 24px; --tbl-fade-e: 0px; }
}
@supports (animation-timeline: scroll()) {
  @media (pointer: coarse) {
    :where(body:not(.twm-root):not(.tws-root)) :where(.table-wrap, .audit-table-wrap):where(:not(.tw-mri *)) {
      -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--tbl-fade-s),
                          #000 calc(100% - var(--tbl-fade-e)), transparent 100%);
      mask-image: linear-gradient(to right, transparent 0, #000 var(--tbl-fade-s),
                  #000 calc(100% - var(--tbl-fade-e)), transparent 100%);
      animation: tbl-scroll-cue linear both;
      animation-timeline: scroll(self inline);
    }
    :where(html[dir="rtl"] body:not(.twm-root):not(.tws-root)) :where(.table-wrap, .audit-table-wrap):where(:not(.tw-mri *)) {
      -webkit-mask-image: linear-gradient(to left, transparent 0, #000 var(--tbl-fade-s),
                          #000 calc(100% - var(--tbl-fade-e)), transparent 100%);
      mask-image: linear-gradient(to left, transparent 0, #000 var(--tbl-fade-s),
                  #000 calc(100% - var(--tbl-fade-e)), transparent 100%);
    }
    :where(body:not(.twm-root):not(.tws-root)) :where(.table-wrap, .audit-table-wrap):where(:not(.tw-mri *)):focus-visible {
      -webkit-mask-image: none;
      mask-image: none;
    }
  }
  @media (pointer: coarse) and (prefers-reduced-motion: reduce) {
    /* the reduced-motion rule shortens every animation to 0.01ms; a scroll
       timeline has no duration, and a fade is not motion */
    :where(body:not(.twm-root):not(.tws-root)) :where(.table-wrap, .audit-table-wrap):where(:not(.tw-mri *)) {
      animation-duration: auto !important;
    }
  }
}

/* G5 (Arabic) — Arabic at 11px is not legible; the sidebar's micro-labels that
   sit between 11 and 12px in Latin are 12px in Arabic (the owner's sidebar keeps
   the sizes it was fitted at). Everything else this list used to hold at 12px
   follows the Arabic type scale near the top of this sheet. */
html[dir="rtl"] :is(.nav-lbl, .logo-sub, .u-rl) {
  font-size: max(12px, 0.75rem);
}
/* The sidebar in Arabic (UI review 3, from the owner's screenshot). Its text sat
   a step below the page's Arabic scale; the two-line product name was thin
   Kufi at the serif's one weight with its marks touching at 1.1 leading; and
   the role and the university line were set in the mono face, whose 0.6em
   space opened their word gaps. No width moves and the tested values hold: the
   section headings stay 14px in 40px rows, and the 210/195px rails below
   1201px keep their sizes. */
html[dir="rtl"] .logo-title {
  font-family: var(--font-body);
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0;
  text-wrap: balance;
}
html[dir="rtl"] :is(.logo-sub, .u-rl) { font-family: var(--font-body); letter-spacing: 0; }
@media (min-width: 1201px) {
  /* the full 252px rail: links one step up (13 to 14px), the search row, the
     user's lines and the university line one step up (12 to 13px) */
  html[dir="rtl"] .sidebar .nav-a { font-size: var(--text-base); }
  html[dir="rtl"] .sidebar .nav-find-btn,
  html[dir="rtl"] .sidebar .u-nm,
  html[dir="rtl"] .sidebar .u-rl,
  html[dir="rtl"] .sidebar .logo-sub { font-size: var(--text-sm); }
}
html[dir="rtl"] .form-label { font-size: var(--text-xs) !important; font-weight: 600 !important; }
/* (not the viewport-filling tool pages: their footer is one pinned 11px line) */
html[dir="rtl"] main:not([data-fill="viewport"]) .system-footer { font-size: var(--text-xs); }

/* ── Database admin: the scope form's three controls share one baseline ─────
   The help line under "Academic programme" made that column 44px taller, and the
   row aligns to the bottom, so "Section group" and the button sat lower than their
   neighbour. The line hangs below the field instead of stretching its column
   (the columns stack under 768px, where it stays in the flow). */
@media (min-width: 768px) {
  .dba-section:has(#ssProgram) .row > .col-md-5 { position: relative; }
  .dba-section:has(#ssProgram) .row > .col-md-5 > .form-text {
    position: absolute; inset-inline: 0.375rem; top: 100%; margin-top: 0.25rem;
  }
  .dba-section:has(#ssProgram) .row { margin-block-end: 3.5rem; }
}

/* G5 (Arabic), the pages the first block did not name: the portfolio's status
   pills and row count, the graduation graph's mode buttons, a planner toggle and
   a graduation note were still 11-11.9px. The classic workspace is left to its own
   sheet, whose cards and slots are sized to a 96px slot and pinned by tests. */
html[dir="rtl"] :is(#apTable .pill-status, #apShowing, .pg-mode, .pg-info,
    .filter-bar > label.text-t3, p.small.text-secondary) {
  font-size: var(--text-xs);
}

/* Small hit areas: the portfolio's "View (n)" pill was 23px high and the section
   planner's two disclosure toggles 20px; 28px is a comfortable pointer target
   and does not move the row they sit in. */
.ap-hp-btn { min-height: 28px; }
#spToggleCaps, #spToggleAdv, #spToggleMeet { min-height: 28px; display: inline-flex; align-items: center; }
