/* ============================================================================
 * app.css — the design system of the whole site (every page that extends school_base.html or
 * school_today_base.html). The language is the one of the home board (school/static/home/board.css):
 * warm page, warm cards, navy text, ONE strong colour — the institution accent — large quiet radii.
 *
 * The accent comes from the institution: the shell sets  <html style="--accent: …">  from
 * institution.theme.accent_primary. Never write an institution colour, name or logo here.
 * RTL first: logical properties only (inset-inline-*, margin-inline-*, padding-inline-*, text-align: start).
 *
 * ─────────────────────────────────────────────────────────────────────────── CLASS REFERENCE
 * Page frame
 *   .container                 the page column (1280px). The shell provides it; pages do not add one.
 *   .page-head                 title row of a page (the shell renders it from {% block nav_title %},
 *                              {% block nav_subtitle %} and {% block nav_actions %}).
 *   .page-title / .page-sub    a title + a one-line subtitle, for a page that draws its own heading.
 *   .page-actions              buttons at the end of the title row.
 *   .section-head              a row with a section title (h2/h3 or .section-title) and actions at the end.
 *   .section-title             a 16px bold section title.
 *   .toolbar (.filter-bar)     a wrapping row of filters / actions above a list. `.spacer` pushes the rest
 *                              to the end. On a phone the controls go full width.
 * Surfaces
 *   .card                      the surface: warm card, 20px radius, padded. `.card > h2/h3` is its title.
 *   .card--flush               a card without padding (use .card-h / .card-b / .card-foot inside it).
 *   .card--soft                a quiet inner panel (soft background, no shadow). .card--accent: accent tint.
 *   .card-h                    card header row: .card-ic (icon tile) + .card-t (title) + actions at the end.
 *   .card-b / .card-foot       card body / a footer row divided by a hairline.
 *   .stats + .stat             a grid of number tiles:  <div class="stat"><b>12</b><span>label</span></div>
 *                              .stat--good / --warn / --bad colour a tile.
 * Buttons
 *   .btn                       base (40px high). Always combine with one of:
 *   .btn-primary               the one main action (accent).
 *   .btn-secondary             a secondary action (accent tint).  (.btn-soft is the same)
 *   .btn-ghost                 a quiet bordered button (cancel, back, filters).  (.btn-quiet is the same)
 *   .btn-plain                 no border, no background (toolbar icons, "more").
 *   .btn-danger / .btn-success / .btn-warning     solid status buttons.   .btn-danger-soft: a quiet delete.
 *   .btn-sm / .btn-lg          32px / 46px.   .btn-icon: a square icon button.   .btn-block: full width.
 *   .btn-inline                keeps a button at its own width on a phone (on a phone .btn is full width,
 *                              except inside .toolbar, .page-actions, .btn-row, .card-h, .modal-foot, tables).
 *   .btn-row                   a wrapping row of buttons.     .linkish: a button that looks like a link.
 * Forms
 *   .field                     one control with its label:  .field-label, the control, .field-help, .field-error
 *   .field.is-invalid          paints the control red.      .field-label .req: the red asterisk.
 *   .input / .select / .textarea     the controls (no outer margin). `.input-field` is the old name and
 *                              keeps its bottom margin; both look the same.
 *   .check                     <label class="check"><input type="checkbox|radio"> text</label>
 *   .form-grid                 a responsive grid of fields (.form-grid--2 / --3 fix the column count).
 *   .form-row                  a wrapping flex row of fields (the old name; children stack on a phone).
 *   .form-actions              the row of buttons that ends a form.
 * Tables
 *   .table-wrap                wraps a table: border, radius, and it scrolls sideways on a phone
 *                              instead of the page. Put EVERY wide table in one.
 *   .table                     an explicit data table (bare <table> already gets the same look).
 *   .table--compact / .table--zebra / .table--fixed
 *   .cell-num                  a numeric cell (LTR digits, tabular, at the end of the row).
 *   .cell-actions              the cell that holds row buttons (no wrap).
 * Navigation inside a page
 *   .tabs + .tab               a tab row; the selected tab has .active (or .is-on / aria-selected="true" /
 *                              aria-current="page").  .tabs--pills: pills instead of an underline.
 *   .pagination                page links; the current one has .is-current or aria-current="page".
 * Status
 *   .chip                      a small label. .chip--good / --warn / --bad / --plain / --line / --solid
 *   .badge                     the old name of a status label: .badge-green / -yellow / -red / -gray / -blue
 *                              (also -good / -warn / -bad / -neutral / -info).
 *   .pill                      a count in a circle (.pill--zero when it is 0).
 *   .alert                     a notice box. .alert-info / .alert-good / .alert-warn / .alert-bad
 *                              (also -success / -warning / -danger / -error; and the old `.alert ok|err|info`).
 *   .error-msg / .success-msg / .page-banner      the old notice names, same look.
 *   .empty-state               "nothing here yet": optional .empty-state-icon, a <b> title, a <p>, a button.
 *   .empty-line                the same as a single quiet row.
 *   .toasts + .toast-item      a toast stack (bottom, above the phone bar). .toast-item--good / --bad
 * Overlays
 *   .modal                     the backdrop + centring; add .is-open to show it. Inside: .modal-card with
 *                              .modal-head (.modal-title, .modal-close), .modal-body, .modal-foot.
 *   dialog.dialog              the same look for a native <dialog> (showModal()).
 * Data
 *   .kv                        a key-value list:  <dl class="kv"><dt>…</dt><dd>…</dd>…</dl>   (.kv--stack)
 * Small helpers
 *   .num-ltr                   a number / time / phone isolated LTR inside Hebrew (also <bdi class="num-ltr">)
 *   .text-muted / .text-2 / .text-good / .text-warn / .text-bad      text colours
 *   .stack (vertical, gap) / .cluster (wrapping row, gap) / .grid-2 / .grid-3 / .grid-4 / .divider / .sr-only
 *   .only-print / .no-print
 *
 * ─────────────────────────────────────────────────────────────────────────── TOKENS: OLD NAME → NEW VALUE
 * The pages were written against the old variable names. They all still exist and now carry the new
 * palette, so a page changes look without being edited. New code may use either column.
 *
 *   old name                      new token            value
 *   --bg-page, --brand-cream      --page               #f7f2e8
 *   --bg-card, --bg-surface,
 *   --card-bg, --surface          --card               #fffdf8
 *   --bg-soft, --bg-subtle        --surface-soft       #fbf7ef
 *   --bg-muted                    --surface-muted      #f1eadb
 *   --text-primary                --text               #162a4d
 *   --text-secondary              --text-2             #4d5b73
 *   --text-muted, --text-light,
 *   --text-soft                   --text-3             #667186      (AA on card and on page)
 *   --text-inverse                —                    #ffffff
 *   --accent-primary, --brand-navy,
 *   --brand-purple                --accent             institution.theme.accent_primary
 *   --accent-primary-hover,
 *   --brand-navy-deep, --brand-ink --accent-deep        accent mixed 78% with near-black
 *   --accent-soft                 --accent-soft        accent 9% on card
 *   (new)                         --accent-softer      accent 5% on card
 *   (new)                         --accent-line        accent 26% on card (borders of accent things)
 *   (new)                         --accent-text        accent 92% (accent used as text)
 *   --success / --success-bg      --good / --good-bg   #2a7346 / #e2f1e6
 *   --warning / --warning-bg      --warn / --warn-bg   #9a6207 / #fdf0cf
 *   --danger / --danger-bg        --bad / --bad-bg     #ad2a36 / #fae2e4
 *   --info / --info-bg            --accent-text / --accent-soft
 *   --border                      --border             #eadfc8
 *   --border-soft                 --hair               #f0e8d7
 *   --border-strong               —                    #dccfb1  (a firmer warm line; the gold line is gone)
 *   --brand-gold, --brand-gold-light  —                → the accent / the accent tint (no gold in the new look)
 *   --brand-gold-soft             —                    → --border
 *   --brand-burgundy              —                    → --bad
 *   --focus-ring                  —                    accent at 45%
 *   --font-body, --font-display   --font               Assistant, …  (font-size-adjust .525 on body)
 *   --font-mono                   —                    unchanged
 *   --fs-xs / sm / base / md / lg / xl / 2xl           12 / 13.5 / 15 / 17 / 20 / 25 / 32 px
 *                                                      (were 12/14/16/18/22/28/36: Assistant is now drawn
 *                                                      ~12% taller by font-size-adjust, so the px are lower)
 *   --fw-normal / medium / semi / bold                 400 / 500 / 600 / 700 (unchanged)
 *   --lh-tight / normal / loose                        1.25 / 1.5 / 1.75
 *   --sp-1 … --sp-16                                   unchanged (4 … 64px)
 *   --r-sm / --r-md / --r-lg / --r-xl / --r-full       10 / 12 / 20 / 24 / 9999 px  (were 6/10/16/24)
 *   (new)                         --r-card / --r-in    20 / 14 px
 *   --shadow-sm / --shadow-md / --shadow-lg            hairline shadow / --shadow (card) / --shadow-pop (popovers)
 *   --ease, --dur-fast, --dur-base                     unchanged
 *   --container-max / --navbar-h                       1280px / 60px
 *   --whatsapp                                         unchanged
 * Print keeps the old sizes (see the end of the file).
 * ========================================================================== */

/* ============================================================================ 1. tokens */
:root {
  --accent: #173f78;                      /* the shell overrides it per institution: <html style="--accent:…"> */
  --accent-deep: color-mix(in srgb, var(--accent) 78%, #05101f);
  --accent-soft: color-mix(in srgb, var(--accent) 9%, #fffdf8);
  --accent-softer: color-mix(in srgb, var(--accent) 5%, #fffdf8);
  --accent-line: color-mix(in srgb, var(--accent) 26%, #fffdf8);
  --accent-text: color-mix(in srgb, var(--accent) 92%, #000);

  --page: #f7f2e8;
  --card: #fffdf8;
  --surface-soft: #fbf7ef;
  --surface-muted: #f1eadb;
  --field: #fffefb;
  --text: #162a4d;
  --text-2: #4d5b73;
  --text-3: #667186;
  --border: #eadfc8;
  --border-strong: #dccfb1;
  --hair: #f0e8d7;

  --good: #2a7346;  --good-bg: #e2f1e6;
  --warn: #9a6207;  --warn-bg: #fdf0cf;
  --bad:  #ad2a36;  --bad-bg:  #fae2e4;
  --cream: #fff6df;

  --r-card: 20px;
  --r-in: 14px;
  --shadow: 0 1px 2px rgba(74, 56, 22, .05), 0 12px 28px -16px rgba(74, 56, 22, .22);
  --shadow-pop: 0 2px 6px rgba(22, 42, 77, .08), 0 18px 44px -12px rgba(22, 42, 77, .28);
  --gap: 20px;
  --font: "Assistant", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, "Noto Sans Hebrew", sans-serif;
  --bnav-h: 62px;                         /* the phone bottom bar */
  --fab: 44px;                            /* the floating launchers (chat, AI, ideas, accessibility) */
  --fab-gap: 8px;
  --fab-edge: 20px;                       /* their distance from the corner */
  --fab-rise: 0px;                        /* what they stand on: 0, or the phone bottom bar */
  --ic-chat: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20.5 11.6a8.2 8.2 0 0 1-12 7.2L4 20l1.3-4.2a8.2 8.2 0 1 1 15.2-4.2z'/%3E%3C/svg%3E");
  --ic-idea: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9.2 17.5h5.6M10.2 20.5h3.6'/%3E%3Cpath d='M12 3.5a6 6 0 0 0-3.7 10.7c.6.5.9 1.1.9 1.8v1.5h5.6V16c0-.7.3-1.3.9-1.8A6 6 0 0 0 12 3.5z'/%3E%3C/svg%3E");
  --ic-ai: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11 4l1.7 4.8 4.8 1.7-4.8 1.7L11 17l-1.7-4.8-4.8-1.7 4.8-1.7z'/%3E%3Cpath d='M18 15l.8 2.2 2.2.8-2.2.8-.8 2.2-.8-2.2-2.2-.8 2.2-.8z'/%3E%3C/svg%3E");
  --chev: 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%3Cpath d='m5 9 7 7 7-7'/%3E%3C/svg%3E");

  /* ---- the old names (see the table above) ---- */
  --bg-page: var(--page);
  --bg-card: var(--card);
  --bg-surface: var(--card);
  --card-bg: var(--card);
  --surface: var(--card);
  --bg-soft: var(--surface-soft);
  --bg-subtle: var(--surface-soft);
  --bg-muted: var(--surface-muted);

  --text-primary: var(--text);
  --text-secondary: var(--text-2);
  --text-muted: var(--text-3);
  --text-light: var(--text-3);
  --text-soft: var(--text-3);
  --text-inverse: #ffffff;

  --accent-primary: var(--accent);
  --accent-primary-hover: var(--accent-deep);

  --success: var(--good);   --success-bg: var(--good-bg);
  --warning: var(--warn);   --warning-bg: var(--warn-bg);
  --danger: var(--bad);     --danger-bg: var(--bad-bg);
  --info: var(--accent-text);  --info-bg: var(--accent-soft);
  --whatsapp: #25d366;

  --border-soft: var(--hair);
  --focus-ring: color-mix(in srgb, var(--accent) 45%, transparent);

  --font-body: var(--font);
  --font-display: var(--font);
  --font-mono: ui-monospace, "Menlo", monospace;
  --fs-xs: 12px;
  --fs-sm: 13.5px;
  --fs-base: 15px;
  --fs-md: 17px;
  --fs-lg: 20px;
  --fs-xl: 25px;
  --fs-2xl: 32px;
  --fw-normal: 400;
  --fw-medium: 500;
  --fw-semi: 600;
  --fw-bold: 700;
  --lh-tight: 1.25;
  --lh-normal: 1.5;
  --lh-loose: 1.75;

  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;
  --sp-12: 48px; --sp-16: 64px;

  --r-sm: 10px; --r-md: 12px; --r-lg: 20px; --r-xl: 24px; --r-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(74, 56, 22, .06);
  --shadow-md: var(--shadow);
  --shadow-lg: var(--shadow-pop);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 0.15s;
  --dur-base: 0.25s;

  --container-max: 1280px;
  --navbar-h: 60px;

  --brand-navy: var(--accent);
  --brand-navy-deep: var(--accent-deep);
  --brand-ink: var(--accent-deep);
  --brand-purple: var(--accent);
  --brand-gold: var(--accent);
  --brand-gold-light: var(--accent-soft);
  --brand-gold-soft: var(--border);
  --brand-cream: var(--page);
  --brand-burgundy: var(--bad);
}

/* ============================================================================ 2. base */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }              /* the pages were written on this reset — keep it */
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
html, body { height: 100%; }
body {
  min-height: 100vh;
  font-family: var(--font); font-size: var(--fs-base); line-height: var(--lh-normal); font-weight: 400;
  /* Assistant is drawn small for its size; this keeps its letters as tall as in the approved home design.
   * It is inherited. The `font:` shorthand resets it — after a shorthand, repeat `font-size-adjust: 0.525`. */
  font-size-adjust: 0.525;
  color: var(--text);
  background:
    radial-gradient(900px 380px at 88% -60px, #fffaf0 0%, rgba(255, 250, 240, 0) 70%),
    var(--page);
  background-repeat: no-repeat;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font); font-weight: 700; line-height: var(--lh-tight); color: var(--text); letter-spacing: -.005em; }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
h4 { font-size: var(--fs-base); }
a { color: var(--accent-text); text-underline-offset: 3px; }
button, input, select, textarea { font-family: inherit; }
label { color: var(--text-2); }
hr { border: 0; border-top: 1px solid var(--border); }
::selection { background: color-mix(in srgb, var(--accent) 20%, transparent); }
main:focus { outline: none; }
a:focus-visible, button:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--focus-ring); outline-offset: 2px; border-radius: 8px;
}
* { scrollbar-width: thin; scrollbar-color: #d9ccae transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #d9ccae; border-radius: 999px; border: 2px solid var(--page); }
*::-webkit-scrollbar-thumb:hover { background: #c2b38e; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition: none !important; }
}

.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; }
.num-ltr { unicode-bidi: isolate; direction: ltr; font-variant-numeric: tabular-nums; white-space: nowrap; display: inline-block; }
.text-muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.text-good { color: var(--good); }
.text-warn { color: var(--warn); }
.text-bad { color: var(--bad); }
.only-print { display: none !important; }
.ic { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: middle; }

/* ============================================================================ 3. the shell */

/* ---- strips above the header (read-only account, disconnected mailbox, version update) ---- */
.shell-strip { padding: 9px 18px; text-align: center; font-size: var(--fs-sm); font-weight: 600; line-height: 1.45; border-bottom: 1px solid var(--border); background: var(--accent-soft); color: var(--accent-text); }
.shell-strip a { color: inherit; font-weight: 700; }
.shell-strip--warn { background: var(--warn-bg); color: #6f4705; border-bottom-color: color-mix(in srgb, var(--warn) 35%, var(--warn-bg)); }
.shell-strip--sticky { position: sticky; top: 0; z-index: 5000; }
.shell-strip .soft { font-weight: 400; }
#maintenance-banner { position: sticky; top: 0; z-index: 9999; }
#maintenance-toast {
  position: fixed; top: 20px; inset-inline-start: 20px; z-index: 10000; max-width: 340px;
  background: var(--good-bg); color: var(--good); border: 1px solid color-mix(in srgb, var(--good) 40%, var(--good-bg));
  border-radius: var(--r-in); padding: 12px 16px; font-size: var(--fs-sm); font-weight: 600; box-shadow: var(--shadow-pop);
}
#maintenance-toast .row { display: flex; align-items: center; gap: 8px; }
#maintenance-toast button { background: none; border: 0; font-size: 18px; cursor: pointer; color: inherit; padding: 0 4px; }

/* ---- header: brand · group menu · year · user · menu button ---- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255, 253, 248, .94); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--container-max); margin: 0 auto; padding: 0 24px; min-height: var(--navbar-h);
  display: flex; align-items: center; gap: 10px; position: relative;
  /* the accessibility launcher is fixed in the top corner at the end of the row: leave it room when the
   * header reaches that corner, so it reads as the last item of the header and covers nothing */
  padding-inline-end: max(24px, calc(62px - max(0px, (100vw - var(--container-max)) / 2)));
}
body #a11y-launcher { top: 11px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); flex: 0 1 auto; min-width: 36px; }
.brand-mark {
  position: relative; width: 36px; height: 36px; border-radius: 12px; flex: none; overflow: hidden;
  background: var(--accent); color: var(--cream); display: grid; place-items: center;
}
.brand-mark .ic { width: 20px; height: 20px; }
.brand-logo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; background: #fff; border: 1px solid var(--border); border-radius: inherit; }
.brand-t { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-family: var(--font); font-weight: 700; font-size: 15.5px; white-space: nowrap; max-width: 210px; overflow: hidden; text-overflow: ellipsis; }
.brand-t small { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand:hover .brand-name { color: var(--accent-text); }
/* the old square "home" link, where a page still draws one */
.brand-icon-only { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; background: var(--accent); color: var(--cream); text-decoration: none; flex: none; }

.nav-desktop-wrap { position: relative; flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 4px; margin-inline-start: 2px; }
.nav-scroll-btn {
  flex: none; width: 28px; height: 28px; border: 1px solid var(--border); border-radius: 999px; background: var(--card);
  color: var(--text-2); cursor: pointer; display: none; align-items: center; justify-content: center; font-size: 12px; line-height: 1; z-index: 2;
}
.nav-scroll-btn:hover { border-color: var(--accent-line); color: var(--accent-text); }
.nav-scroll-btn:disabled { opacity: .35; cursor: default; }
.nav-desktop { display: flex; align-items: center; gap: 0; flex: 1; flex-wrap: wrap; justify-content: flex-start; overflow: visible; min-width: 0; }
.nav-group { position: relative; flex: none; }
.nav-desktop > a,
.nav-group > summary {
  display: inline-flex; align-items: center; gap: 5px; height: 36px; padding: 0 9px; border-radius: 10px;
  border: 0; background: none; text-decoration: none; font-size: 14px; font-weight: 500; color: var(--text-2);
  white-space: nowrap; cursor: pointer; list-style: none; user-select: none; flex: none;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-desktop > a > .nav-icon,
.nav-group > summary > .nav-icon { display: none; }          /* the header menu is text, like the home's */
.nav-desktop > a:hover,
.nav-group > summary:hover,
.nav-group[open] > summary { background: var(--surface-muted); color: var(--text); }
.nav-desktop > a.active,
.nav-group.has-active > summary { color: var(--accent-text); font-weight: 700; background: var(--accent-soft); }
.nav-group[open].has-active > summary { background: var(--accent-soft); }
/* the chevron: the markup carries "▾"; it is drawn as a thin line chevron */
.nav-group > summary .chevron,
.user-menu > summary .chevron,
.year-switch-caret,
.drawer-group-title .chevron,
.drawer-item-toggle .chevron {
  width: 12px; height: 12px; flex: none; display: inline-block; opacity: .6; overflow: hidden;
  direction: ltr; text-indent: -99px; white-space: nowrap;                      /* the "▾" text itself is moved out of the box */
  background: currentColor;
  -webkit-mask: var(--chev) center / 12px 12px no-repeat; mask: var(--chev) center / 12px 12px no-repeat;
  transition: transform var(--dur-fast);
}
.nav-group[open] > summary .chevron,
.user-menu[open] > summary .chevron,
.year-switch[open] .year-switch-caret,
.drawer-group[open] > summary .chevron,
.drawer-item-toggle[aria-expanded="true"] .chevron { transform: rotate(180deg); }

.nav-group-panel, .menu-pop {
  position: absolute; top: calc(100% + 8px); inset-inline-start: 0; z-index: 110;
  display: flex; flex-direction: column; gap: 1px; min-width: 214px; max-height: calc(100vh - 96px); overflow-y: auto;
  padding: 6px; background: var(--card); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-pop);
}
.nav-group-help .nav-group-panel { inset-inline-start: auto; inset-inline-end: 0; }
.nav-group-panel a, .menu-pop a, .menu-pop button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 10px; border: 0; background: none;
  text-decoration: none; font-size: 14px; font-weight: 500; text-align: start; color: var(--text); white-space: nowrap; cursor: pointer;
  font-family: inherit; line-height: 1.3;
}
.nav-group-panel a .nav-icon, .menu-pop .nav-icon { font-size: 16px; line-height: 1; width: 20px; text-align: center; flex: none; }
.nav-group-panel a:hover, .menu-pop a:hover, .menu-pop button:hover { background: var(--accent-soft); color: var(--accent-text); }
.nav-group-panel a.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 700; }
.menu-pop hr { border: 0; border-top: 1px solid var(--hair); margin: 5px 4px; }
/* the personal-tasks link the server injects into the menu row */
.nav-desktop > a .tasks-nav-badge { margin-inline-start: 2px; }

.user-strip { display: flex; align-items: center; gap: 8px; flex: none; margin-inline-start: auto; }

/* the year to display */
.year-switch { position: relative; display: inline-block; }
.year-switch > summary, .year-pill {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  background: var(--accent-soft); color: var(--accent-text); border: 1px solid var(--accent-line); border-radius: 999px;
  font-size: 13px; font-weight: 700; white-space: nowrap; user-select: none; text-decoration: none;
}
.year-switch > summary::-webkit-details-marker { display: none; }
.year-switch > summary .ic, .year-pill .ic, .view-year-banner .ic { width: 15px; height: 15px; flex: none; }
.view-year-banner .ic { vertical-align: -2px; }
.year-switch.is-override > summary { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, var(--warn-bg)); }
.year-switch-menu {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0; z-index: 110; min-width: 230px;
  background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-pop); padding: 6px; display: flex; flex-direction: column; gap: 1px;
}
.year-switch-title { font-size: 12px; font-weight: 700; color: var(--text-3); padding: 5px 10px 3px; }
.year-switch-form { margin: 0; }
.year-switch-item { width: 100%; text-align: start; background: none; border: 0; border-radius: 10px; padding: 8px 10px; font: inherit; font-size: 14px; cursor: pointer; color: inherit; }
.year-switch-item:hover, .year-switch-item:focus-visible { background: var(--accent-soft); outline: none; }
.year-switch-item.is-current { font-weight: 700; color: var(--accent-text); }
.year-switch-item small { color: var(--text-3); font-weight: 400; }
.year-switch-reset { color: var(--warn); border-top: 1px solid var(--hair); border-radius: 0 0 10px 10px; }
.year-switch-link { display: block; font-size: 13px; padding: 8px 10px; color: var(--accent-text); text-decoration: none; border-radius: 10px; }
.year-switch-link:hover { background: var(--accent-soft); }
.view-year-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 14px; padding: 10px 14px;
  background: var(--warn-bg); color: #6f4705; border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--warn-bg));
  border-radius: var(--r-in); font-size: var(--fs-sm);
}

/* the personal menu */
.user-menu { position: relative; }
.user-menu > summary {
  list-style: none; display: flex; align-items: center; gap: 9px; height: 44px; padding-inline: 6px 10px; border-radius: 14px;
  cursor: pointer; user-select: none; color: var(--text); max-width: 100%;
}
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary:hover, .user-menu[open] > summary { background: var(--surface-muted); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-line); display: grid; place-items: center; flex: none; }
.user-name { font-size: 13.5px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.user-menu .menu-pop { inset-inline-start: auto; inset-inline-end: 0; min-width: 220px; }
.user-menu .menu-pop .ic { color: var(--accent); width: 18px; height: 18px; }
.menu-pop .tour-trigger { width: 100% !important; height: auto !important; border-radius: 10px !important; padding: 9px 10px !important; }
/* the air-conditioning quick link the server injects next to the profile link: a row of the personal menu */
.menu-pop a[data-school-ac-quick] { display: flex !important; margin: 0 !important; font-size: 14px !important; }
.menu-pop a[data-school-ac-quick]::after { content: attr(title); }
/* signed out there is no personal menu: the same link is appended to the header itself — keep it in the row */
.topbar > a[data-school-ac-quick] { position: absolute; top: 14px; inset-inline-end: max(64px, calc((100vw - var(--container-max)) / 2 + 24px)); margin: 0 !important; line-height: 1; }

/* the menu button (opens the drawer: search, this page's sections, every screen) */
.hamburger {
  display: inline-flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px; flex: none;
  width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--border); background: var(--card); cursor: pointer;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.hamburger:hover { border-color: var(--accent-line); background: var(--accent-softer); }
.hamburger span { width: 16px; height: 1.8px; background: var(--text-2); border-radius: 2px; }

/* ---- personal shortcuts row (under the header) ---- */
.favs-bar { padding: 10px 24px 0; }
.favs-inner { display: flex; align-items: center; gap: 8px; max-width: calc(var(--container-max) - 48px); margin: 0 auto; flex-wrap: wrap; }
.favs-list { display: flex; gap: 6px 8px; flex-wrap: wrap; flex: 0 1 auto; }
.favs-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px;
  background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 999px;
  text-decoration: none; font-size: 13.5px; font-weight: 600; transition: border-color var(--dur-fast), background var(--dur-fast);
}
.favs-chip:hover { border-color: var(--accent); color: var(--accent-text); }
.favs-chip .icon { font-size: 14px; line-height: 1; }
.favs-empty { font-size: 12.5px; color: var(--text-3); padding: 4px 4px; }
.favs-add {
  background: var(--accent-softer); border: 1px dashed var(--accent-line); color: var(--accent-text); cursor: pointer;
  width: 32px; height: 32px; border-radius: 999px; font-size: 13px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.favs-add:hover { border-style: solid; border-color: var(--accent); }
.favs-add .ic { width: 15px; height: 15px; }
.favs-modal { position: fixed; inset: 0; z-index: 500; display: flex; align-items: center; justify-content: center; padding: 16px; }
.favs-modal[hidden] { display: none; }
.favs-modal-backdrop { position: absolute; inset: 0; background: rgba(22, 42, 77, .42); }
.favs-modal-panel {
  position: relative; background: var(--card); border: 1px solid var(--border); border-radius: var(--r-card);
  width: min(640px, 100%); max-height: 90vh; padding: 18px 20px; display: flex; flex-direction: column;
  box-shadow: var(--shadow-pop); overflow: hidden;
}
.favs-close { position: absolute; top: 12px; inset-inline-end: 12px; background: var(--surface-muted); border: 0; cursor: pointer; width: 32px; height: 32px; border-radius: 999px; font-size: 20px; line-height: 1; color: var(--text-2); }
.favs-modal-panel h3 { margin: 0 0 4px; font-size: 17px; padding-inline-end: 40px; }
.favs-hint { margin: 0 0 12px; color: var(--text-2); font-size: var(--fs-sm); }
.favs-catalog { display: grid; gap: 6px; grid-template-columns: 1fr; overflow-y: auto; flex: 1; padding: 4px 0; }
@media (min-width: 560px) { .favs-catalog { grid-template-columns: 1fr 1fr; } }
.favs-catalog label {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px; background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; cursor: pointer; user-select: none; font-size: var(--fs-sm); color: var(--text);
}
.favs-catalog label.disabled { opacity: .5; cursor: not-allowed; }
.favs-catalog label:has(input:checked) { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-text); font-weight: 600; }
.favs-catalog .fav-icon { font-size: 18px; }
.favs-actions { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
.favs-count { flex: 1; font-size: 12.5px; color: var(--text-3); }
.favs-result { margin-top: 6px; font-size: 12.5px; }
.favs-result.ok { color: var(--good); }
.favs-result.err { color: var(--bad); }

/* ---- the page column and the page title ---- */
.container { max-width: var(--container-max); margin: 0 auto; padding: 18px 24px 40px; }
.page-head { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 6px 16px; }
.page-head-t { min-width: 0; flex: 1 1 auto; }
.page-title-strip, .page-title {
  font-family: var(--font); font-weight: 700; font-size: 25px; line-height: 1.2; letter-spacing: -.01em; color: var(--text);
  margin: 4px 0 14px; overflow-wrap: anywhere;
}
.page-title-strip:empty { display: none; }
.page-sub { color: var(--text-2); font-size: 14px; margin: -10px 0 14px; }
.page-sub:empty { display: none; }
.page-title + .page-sub { margin-top: -10px; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 14px; margin-inline-start: auto; }
.page-actions:empty { display: none; }
.logo-strip { display: none; }            /* the big logo banner is print-only now (see the print rules) */

.section-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin: 22px 0 10px; }
.section-head:first-child { margin-top: 0; }
.section-head > :is(h2, h3, .section-title) { margin: 0; flex: 1 1 auto; min-width: 0; }
.section-title, .panel-title, .page-heading { font-size: 16px; font-weight: 700; color: var(--text); line-height: 1.3; }

/* the footer is the end of the page: under it, room for the phone bottom bar and the floating launchers' row,
 * so the last line scrolls clear of both (html and body have a fixed height, so body padding would not do it) */
.site-footer { text-align: center; padding: 18px 16px calc(var(--fab-rise) + var(--fab) + 2 * var(--fab-edge) + 4px); color: var(--text-3); font-size: 12.5px; line-height: 1.7; }
.site-footer a { color: inherit; text-decoration: none; }
.site-footer a:hover { color: var(--accent-text); text-decoration: underline; }

/* ---- the drawer (search · this page's sections · every screen) ---- */
.drawer { position: fixed; inset: 0; z-index: 260; pointer-events: none; }
.drawer[aria-hidden="false"] { pointer-events: auto; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(22, 42, 77, .42); opacity: 0; transition: opacity var(--dur-base) var(--ease); }
.drawer[aria-hidden="false"] .drawer-backdrop { opacity: 1; }
.drawer-panel {
  position: absolute; top: 0; bottom: 0; inset-inline-end: 0; width: min(340px, 88vw);
  background: var(--card); border-inline-start: 1px solid var(--border); box-shadow: var(--shadow-pop);
  padding: 14px 14px calc(18px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 2px; overflow-y: auto; overscroll-behavior: contain;
  transform: translateX(-100%); visibility: hidden;                 /* RTL: it slides in from the left edge */
  transition: transform var(--dur-base) var(--ease), visibility 0s linear var(--dur-base);
}
.drawer[aria-hidden="false"] .drawer-panel { transform: translateX(0); visibility: visible; transition: transform var(--dur-base) var(--ease), visibility 0s; }
.drawer-close {
  align-self: flex-start; width: 36px; height: 36px; flex: none; border-radius: 10px; border: 1px solid var(--border); background: var(--card);
  font-size: 22px; line-height: 1; cursor: pointer; color: var(--text-2); display: grid; place-items: center; margin-bottom: 8px;
}
.drawer-close:hover { border-color: var(--accent-line); color: var(--accent-text); }
.drawer-section { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.drawer-section[hidden] { display: none; }
.drawer-section-title { font-size: 12px; font-weight: 700; color: var(--text-3); margin: 2px 6px 4px; letter-spacing: 0; }
.drawer-panel[data-searching="true"] .drawer-section-title.is-empty { display: none; }
.drawer-search input[type="search"] {
  width: 100%; height: 40px; margin: 0; padding: 0 12px; font-family: inherit; font-size: 14px; color: var(--text);
  background: var(--surface-soft); border: 1px solid var(--border); border-radius: 12px; outline: 0; min-height: 0; box-shadow: none;
  transition: border-color var(--dur-fast), background var(--dur-fast), box-shadow var(--dur-fast);
}
.drawer-search input[type="search"]:focus { background: #fff; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
.drawer-search-empty { margin-top: 8px; padding: 9px 12px; background: var(--surface-soft); border: 1px dashed var(--border); color: var(--text-2); border-radius: 12px; font-size: 13px; text-align: center; }
.drawer-panel a {
  display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 10px; border-radius: 10px; background: none;
  color: var(--text); text-decoration: none; font-weight: 500; font-size: 14px; line-height: 1.3;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.drawer-panel a .nav-icon, .drawer-group-title .nav-icon { font-size: 16px; line-height: 1; width: 20px; text-align: center; flex: none; }
.drawer-panel a:hover { background: var(--accent-soft); color: var(--accent-text); }
.drawer-panel a.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 700; }
.drawer-item { display: flex; align-items: center; gap: 2px; }
.drawer-item .drawer-item-main { flex: 1; min-width: 0; }
.drawer-item-toggle { flex: none; width: 36px; height: 36px; border: 0; border-radius: 10px; background: none; color: var(--text-3); cursor: pointer; display: grid; place-items: center; }
.drawer-item-toggle:hover { background: var(--surface-muted); color: var(--text); }
.drawer-subitems { list-style: none; margin: 0 0 4px; padding: 0; padding-inline-start: 30px; display: flex; flex-direction: column; gap: 1px; }
.drawer-subitems[hidden] { display: none; }
.drawer-subitems a, .drawer-toc-list a { min-height: 34px; padding: 6px 10px; font-size: 13.5px; font-weight: 400; color: var(--text-2); }
.drawer-toc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.drawer-group { margin-bottom: 4px; border: 0; }
.drawer-group[hidden] { display: none; }
.drawer-group > summary.drawer-group-title {
  list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none;
  min-height: 40px; padding: 8px 10px; border-radius: 10px; font-size: 13px; font-weight: 700; color: var(--text-2);
  margin-top: 2px;
}
.drawer-group > summary.drawer-group-title:hover { background: var(--surface-soft); color: var(--text); }
.drawer-group > summary.drawer-group-title::-webkit-details-marker { display: none; }
.drawer-group > summary.drawer-group-title .chevron { margin-right: auto; }      /* the chevron box is LTR (see above); in this RTL row "right: auto" sends it to the end */
.drawer-divider { border: 0; border-top: 1px solid var(--hair); margin: 8px 0; }
.drawer-user { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; color: var(--text-3); font-size: 13.5px; }
.drawer-user a { color: var(--accent-text); font-weight: 600; padding: 4px 8px; min-height: 0; }

/* ---- phone: the bottom bar ---- */
.g-bnav { display: none; }
@media (max-width: 820px) {
  .g-bnav {
    position: fixed; inset-inline: 0; bottom: 0; z-index: 180; display: flex;
    height: calc(var(--bnav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: rgba(255, 253, 248, .97); border-top: 1px solid var(--border);
    box-shadow: 0 -8px 20px -16px rgba(74, 56, 22, .4); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  }
  .g-bnav a, .g-bnav button {
    flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    padding: 0; border: 0; background: none; cursor: pointer; text-decoration: none;
    font-family: inherit; font-size: 11.5px; font-weight: 600; color: var(--text-3); min-height: 44px;
  }
  .g-bnav .ico { display: grid; place-items: center; width: 50px; height: 28px; border-radius: 999px; font-size: 18px; line-height: 1; }
  .g-bnav .ico .ic { width: 21px; height: 21px; }
  .g-bnav .on { color: var(--accent-text); font-weight: 700; }
  .g-bnav .on .ico { background: var(--accent-soft); }
  body.has-bnav { padding-bottom: calc(var(--bnav-h) + env(safe-area-inset-bottom)); }
  /* the floating launchers stand on the bar (see "the floating launchers" below) */
  body.has-bnav { --fab-rise: calc(var(--bnav-h) + env(safe-area-inset-bottom)); }
  body.has-bnav #cookie-banner { bottom: calc(var(--bnav-h) + env(safe-area-inset-bottom)) !important; inset: auto 0 calc(var(--bnav-h) + env(safe-area-inset-bottom)) 0; }
  body.has-bnav .toasts { bottom: calc(var(--bnav-h) + 64px + env(safe-area-inset-bottom)); }      /* above the launchers' row */
}

/* ---- the floating launchers: chat + AI in the end corner, ideas in the start corner ----
 * One quiet look for all of them (a warm round button, the icon in the accent — no emoji, no fills), one
 * size, one line. On a phone they stand in one row on the bottom bar (--fab-rise), the accessibility
 * button joins the row instead of taking a header slot, and the footer leaves the row's height free, so
 * the end of every page scrolls clear of them. Their own files (chat_widget.css, ai_widget.css,
 * _ideas.html, accessibility.css) keep the behaviour; the `body` prefix only out-ranks their old look. */
body .chat-widget-fab, body .ai-widget-fab, body .ideas-fab {
  position: fixed; bottom: calc(var(--fab-rise) + var(--fab-edge)); width: var(--fab); height: var(--fab); padding: 0;
  display: grid; place-items: center; border-radius: 999px; cursor: pointer;
  background: var(--card); color: var(--accent); border: 1px solid var(--border); box-shadow: var(--shadow-pop);
  backdrop-filter: none; -webkit-backdrop-filter: none; filter: none;
  font-size: 0; line-height: 1;                                   /* hides the emoji the scripts write */
  transition: border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
body .chat-widget-fab::before, body .ai-widget-fab::before, body .ideas-fab::before {
  content: ""; width: 22px; height: 22px; background: currentColor;
  -webkit-mask: var(--fab-ic) center / contain no-repeat; mask: var(--fab-ic) center / contain no-repeat;
}
body .chat-widget-fab { --fab-ic: var(--ic-chat); inset-inline-end: var(--fab-edge); z-index: 170; }
body .ai-widget-fab { --fab-ic: var(--ic-ai); inset-inline-end: calc(var(--fab-edge) + var(--fab) + var(--fab-gap)); z-index: 170; }
body:not(:has(.chat-widget-fab)) .ai-widget-fab { inset-inline-end: var(--fab-edge); }       /* no chat: the AI button takes the corner */
body .ideas-fab { --fab-ic: var(--ic-idea); inset-inline-start: var(--fab-edge); z-index: 80; }
body :is(.chat-widget-fab, .ai-widget-fab, .ideas-fab):hover { background: var(--card); border-color: var(--accent-line); color: var(--accent-deep); transform: translateY(-1px); filter: none; }
body :is(.chat-widget-fab, .ai-widget-fab, .ideas-fab):focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
body :is(.chat-widget-fab, .ai-widget-fab).open { transform: none; background: var(--accent-soft); border-color: var(--accent-line); }
body .chat-widget-fab-badge {
  /* LTR so "99+" reads in order; the corner is then given from that direction (its end = the right) */
  direction: ltr; top: -6px; inset-inline: auto -7px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px;
  background: var(--accent); color: #fff; border: 2px solid var(--card);
  font-size: 10.5px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums;
}
body .ideas-fab-label { font-size: 12px; font-weight: 600; background: var(--text); color: #fff; border-radius: 8px; }
body :is(.chat-widget-panel, .ai-widget-panel) { bottom: calc(var(--fab-rise) + var(--fab-edge) + var(--fab) + 10px); max-height: calc(100vh - var(--fab-rise) - var(--fab) - var(--fab-edge) - 30px); }
@media (max-width: 820px) {
  :root { --fab: 42px; --fab-edge: 10px; }
  body :is(.chat-widget-fab, .ai-widget-fab, .ideas-fab) { box-shadow: var(--shadow); }
  /* signed in: the accessibility button leaves the header and stands next to the ideas button */
  body.has-bnav #a11y-launcher {
    top: auto; bottom: calc(var(--fab-rise) + var(--fab-edge)); inset-inline-end: auto;
    inset-inline-start: calc(var(--fab-edge) + var(--fab) + var(--fab-gap));
    width: var(--fab); height: var(--fab); border-radius: 999px; z-index: 80; box-shadow: var(--shadow);
  }
  body.has-bnav #a11y-panel { bottom: calc(var(--fab-rise) + var(--fab-edge) + var(--fab) + 10px); max-height: calc(100vh - var(--fab-rise) - var(--fab) - 40px); }
}
@media print { .chat-widget-fab, .ai-widget-fab, .ideas-fab, .chat-widget-panel, .ai-widget-panel { display: none !important; } }

/* ---- the admin "page settings" button (the last of the page's actions, in the title row) and its dialog ---- */
#admin-page-settings-btn {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 10px; margin: 0;
  background: none; color: var(--text-3); font-family: inherit; font-weight: 600; font-size: 12.5px; line-height: 1;
  border: 1px solid transparent; border-radius: 999px; cursor: pointer; white-space: nowrap;
}
#admin-page-settings-btn .ic { width: 16px; height: 16px; flex: none; }
#admin-page-settings-btn:hover { background: var(--card); border-color: var(--border); color: var(--accent-text); }
#admin-page-settings-btn:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
#page-settings-modal { position: fixed; inset: 0; background: rgba(22, 42, 77, .42); display: flex; align-items: center; justify-content: center; z-index: 1001; padding: 16px; }
#page-settings-modal.hidden { display: none; }
#page-settings-modal .modal-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-pop); padding: 18px 20px; max-width: 740px; width: 100%; max-height: 86vh; overflow-y: auto; }
#page-settings-modal .tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
#page-settings-modal .tab { padding: 9px 14px; border: 0; background: none; cursor: pointer; font-family: inherit; font-size: 14px; font-weight: 600; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; border-radius: 10px 10px 0 0; }
#page-settings-modal .tab:hover { color: var(--text); background: var(--surface-soft); }
#page-settings-modal .tab.active { color: var(--accent-text); border-bottom-color: var(--accent); }
#page-settings-modal .tab-panel { display: none; }
#page-settings-modal .tab-panel.active { display: block; }
#page-settings-modal .ps-label { display: block; font-weight: 600; font-size: var(--fs-sm); margin: 10px 0 4px; }
#page-settings-modal .ps-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; border-top: 1px solid var(--hair); padding-top: 14px; }

.maintenance-screen { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-card); padding: 40px 20px; text-align: center; color: var(--text-2); box-shadow: var(--shadow); }
.maintenance-screen h2 { color: var(--text); margin-bottom: 10px; }

/* ============================================================================ 4. components */

/* ---- surfaces ---- */
.card {
  position: relative; min-width: 0;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow);
  padding: 18px 20px; margin-bottom: var(--gap);
}
.card > h2, .card > h3 { font-size: 17px; line-height: 1.3; margin-bottom: 12px; color: var(--text); }
.card h2 { font-size: 17px; }
.card--flush { padding: 0; overflow: hidden; }
.card--soft { background: var(--surface-soft); border-color: var(--hair); box-shadow: none; border-radius: var(--r-in); }
.card--accent { background: var(--accent-softer); border-color: var(--accent-line); box-shadow: none; }
.card-h { display: flex; align-items: center; gap: 10px; width: 100%; padding: 14px 18px 8px; color: inherit; text-decoration: none; }
.card > .card-h { padding: 0 0 10px; }
.card-ic { width: 32px; height: 32px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; font-size: 16px; line-height: 1; }
.card-t { font-size: 15.5px; font-weight: 700; line-height: 1.25; min-width: 0; flex: 1 1 auto; margin: 0; }
.card-h > .btn, .card-h > .chip, .card-h > .badge, .card-h > a:not(.card-t) { flex: none; }
.card-b { padding: 2px 18px 16px; }
.card-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 18px 14px; border-top: 1px solid var(--hair); }
.card > .card-foot { padding: 12px 0 0; margin-top: 12px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat, .kpi, .stat-card, .summary-card, .metric-card {
  background: var(--surface-soft); border: 1px solid var(--hair); border-radius: var(--r-in); padding: 12px 14px; min-width: 0;
}
.stat { display: flex; flex-direction: column; gap: 1px; text-decoration: none; color: inherit; }
.stat b { font-size: 22px; line-height: 1.2; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12.5px; color: var(--text-2); }
.stat--good { background: var(--good-bg); border-color: color-mix(in srgb, var(--good) 22%, var(--good-bg)); }
.stat--good b { color: var(--good); }
.stat--warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 22%, var(--warn-bg)); }
.stat--warn b { color: var(--warn); }
.stat--bad { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 22%, var(--bad-bg)); }
.stat--bad b { color: var(--bad); }
.kpi strong, .stat-card strong, .summary-card strong, .metric-card strong { color: var(--text); }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 8px 16px;
  border-radius: 12px; border: 1px solid transparent; background: var(--card); color: var(--text-2); border-color: var(--border);
  font-family: var(--font); font-size: 14px; font-weight: 700; line-height: 1.25; text-align: center; text-decoration: none;
  cursor: pointer; transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.btn:hover { border-color: var(--accent-line); color: var(--accent-text); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; border-radius: 12px; }
/* disabled: a flat muted button whose text still reads (text-2 on surface-muted is 5.7:1), whatever the variant */
.btn:disabled, .btn[disabled], .btn.is-disabled,
.btn:disabled:hover, .btn[disabled]:hover, .btn.is-disabled:hover {
  background: var(--surface-muted); color: var(--text-2); border-color: var(--border); box-shadow: none; opacity: 1;
  cursor: not-allowed; transform: none; filter: none;
}
.btn .ic { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn-primary:hover { background: var(--accent-deep); color: #fff; border-color: transparent; }
.btn-secondary, .btn-soft { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-line); }
.btn-secondary:hover, .btn-soft:hover { background: color-mix(in srgb, var(--accent) 14%, #fffdf8); color: var(--accent-text); }
.btn-ghost, .btn-quiet { background: var(--card); color: var(--text-2); border-color: var(--border); font-weight: 600; }
.btn-ghost:hover, .btn-quiet:hover { background: var(--card); border-color: var(--accent-line); color: var(--accent-text); }
.btn-plain { background: none; border-color: transparent; color: var(--text-2); font-weight: 600; }
.btn-plain:hover { background: var(--surface-muted); border-color: transparent; color: var(--text); }
.btn-success { background: var(--good); color: #fff; border-color: transparent; }
.btn-success:hover { background: color-mix(in srgb, var(--good) 88%, #000); color: #fff; border-color: transparent; }
.btn-danger { background: var(--bad); color: #fff; border-color: transparent; }
.btn-danger:hover { background: color-mix(in srgb, var(--bad) 88%, #000); color: #fff; border-color: transparent; }
.btn-warning { background: var(--warn); color: #fff; border-color: transparent; }
.btn-warning:hover { background: color-mix(in srgb, var(--warn) 88%, #000); color: #fff; border-color: transparent; }
.btn-danger-soft { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, var(--bad-bg)); }
.btn-danger-soft:hover { background: color-mix(in srgb, var(--bad) 16%, #fffdf8); color: var(--bad); border-color: var(--bad); }
.btn-sm { min-height: 32px; padding: 4px 12px; font-size: 13px; border-radius: 10px; }
.btn-lg { min-height: 46px; padding: 10px 20px; font-size: 15px; border-radius: 14px; }
.btn-icon { width: 40px; padding: 0; flex: none; }
.btn-icon.btn-sm { width: 32px; }
.btn-block { width: 100%; }
.btn-inline { width: auto !important; }
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent-text); font-family: inherit; font-weight: 600; font-size: 13.5px; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.linkish:hover { text-decoration: underline; }

/* ---- forms ---- */
/* every plain text control gets the look; :where() keeps this at zero specificity, so any page rule wins */
:where(input:not([type]), input[type="text"], input[type="search"], input[type="email"], input[type="tel"], input[type="url"],
       input[type="password"], input[type="number"], input[type="date"], input[type="time"], input[type="datetime-local"],
       input[type="month"], input[type="week"], select, textarea) {
  font-family: inherit; font-size: inherit; color: var(--text);
  background-color: var(--field); border: 1px solid var(--border-strong); border-radius: 10px; padding: 6px 10px;
}
:where(input, select, textarea):focus-visible { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
:where(input, textarea)::placeholder { color: var(--text-3); opacity: 1; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
:where(input[type="checkbox"], input[type="radio"]) { width: 17px; height: 17px; vertical-align: -3px; }
:where(input[type="checkbox"], input[type="radio"]):focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; box-shadow: none; }
:where(textarea) { line-height: 1.5; resize: vertical; }
:where(input, select, textarea):disabled { background-color: var(--surface-muted); color: var(--text-3); cursor: not-allowed; }

.input-field, .input, .select, .textarea {
  display: block; width: 100%; min-height: 42px; padding: 9px 12px;
  background-color: var(--field); border: 1px solid var(--border-strong); border-radius: 12px;
  font-family: var(--font); font-size: var(--fs-base); color: var(--text); direction: rtl;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast), background-color var(--dur-fast);
}
.input-field { margin-bottom: var(--sp-3); }
.input-field:hover, .input:hover, .select:hover, .textarea:hover { border-color: var(--accent-line); }
.input-field:focus, .input:focus, .select:focus, .textarea:focus {
  outline: none; background-color: #fff; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
select.input-field, select.input, .select { appearance: auto; }
textarea.input-field, textarea.input, .textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input.input-field[dir="ltr"], input.input[dir="ltr"] { direction: ltr; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; min-width: 0; }
.field-label { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.field-label .req { color: var(--bad); margin-inline-start: 2px; }
.field-help { font-size: 12.5px; color: var(--text-3); line-height: 1.4; }
.field-error { font-size: 12.5px; font-weight: 600; color: var(--bad); line-height: 1.4; }
.field.is-invalid :is(.input, .input-field, .select, .textarea, input, select, textarea) { border-color: var(--bad); }
.field.is-invalid :is(.input, .input-field, .select, .textarea):focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 18%, transparent); }
.field > .input-field { margin-bottom: 0; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; font-size: 14px; color: var(--text); cursor: pointer; }
.check input { flex: none; margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.form-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid > .field--wide { grid-column: 1 / -1; }
.form-row { gap: 14px; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--hair); }

.toolbar, .filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-bottom: 14px; }
.toolbar .spacer, .filter-bar .spacer { flex: 1 1 auto; }
.toolbar :is(.input, .select, .input-field), .filter-bar :is(.input, .select, .input-field) { width: auto; min-width: 150px; margin-bottom: 0; min-height: 40px; padding-block: 7px; }
.toolbar .field, .filter-bar .field { margin-bottom: 0; }

/* attendance marks and class pickers (old names, used by the attendance pages) */
.att-group { display: flex; gap: 4px; justify-content: center; }
.att-radio { display: none; }
.att-label {
  padding: 6px 12px; border-radius: 10px; font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
  border: 1px solid var(--border-strong); background: var(--card); color: var(--text-2); transition: all var(--dur-fast);
}
.att-radio:checked + .att-label.lbl-class  { background: var(--good-bg); border-color: var(--good); color: var(--good); }
.att-radio:checked + .att-label.lbl-remote { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
.att-radio:checked + .att-label.lbl-absent { background: var(--bad-bg);  border-color: var(--bad);  color: var(--bad); }
.att-radio:focus-visible + .att-label { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.class-selector { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.class-btn {
  display: inline-flex; align-items: center; min-height: 36px; padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card); color: var(--text); cursor: pointer;
  font-family: inherit; font-size: 13.5px; font-weight: 600; text-decoration: none; transition: all var(--dur-fast);
}
.class-btn:hover { border-color: var(--accent); color: var(--accent-text); }
.class-btn.active { border-color: var(--accent); background: var(--accent); color: #fff; }

/* ---- tables ---- */
table { width: 100%; border-collapse: separate; border-spacing: 0; background: transparent; }
th, td { padding: 10px 14px; text-align: right; border-bottom: 1px solid var(--hair); vertical-align: middle; }
th { background: var(--surface-soft); color: var(--text-2); font-weight: 700; font-size: 13px; border-bottom-color: var(--border); white-space: nowrap; }
tr:hover td { background: var(--surface-soft); }
tbody tr:last-child td { border-bottom-color: transparent; }
.table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%;
  border: 1px solid var(--border); border-radius: var(--r-in); background: var(--card);
}
.card--flush > .table-wrap { border: 0; border-radius: 0; }
/* a table wider than its box: the side where more of it is hidden fades out, so it reads as "scroll me".
 * The shell sets the classes (physical sides, so it is right in RTL and LTR alike) while the box scrolls. */
.table-wrap.is-clip-left { -webkit-mask-image: linear-gradient(to right, rgba(0,0,0,.08), #000 44px); mask-image: linear-gradient(to right, rgba(0,0,0,.08), #000 44px); }
.table-wrap.is-clip-right { -webkit-mask-image: linear-gradient(to left, rgba(0,0,0,.08), #000 44px); mask-image: linear-gradient(to left, rgba(0,0,0,.08), #000 44px); }
.table-wrap.is-clip-left.is-clip-right { -webkit-mask-image: linear-gradient(to right, rgba(0,0,0,.08), #000 44px, #000 calc(100% - 44px), rgba(0,0,0,.08)); mask-image: linear-gradient(to right, rgba(0,0,0,.08), #000 44px, #000 calc(100% - 44px), rgba(0,0,0,.08)); }
.table { font-size: 14px; }
.table--compact :is(th, td) { padding: 6px 10px; }
.table--zebra tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-soft) 60%, transparent); }
.table--fixed { table-layout: fixed; }
.cell-num { direction: ltr; unicode-bidi: isolate; text-align: left; font-variant-numeric: tabular-nums; white-space: nowrap; }   /* LTR digits, at the end (left) of an RTL row */
.cell-actions { white-space: nowrap; width: 1%; }
.cell-actions .btn + .btn { margin-inline-start: 4px; }

/* ---- tabs ---- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 40px; padding: 8px 14px;
  border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; border-radius: 10px 10px 0 0; background: none;
  font-family: inherit; font-size: 14px; font-weight: 600; color: var(--text-2); text-decoration: none; white-space: nowrap; cursor: pointer;
}
.tab:hover { color: var(--text); background: var(--surface-soft); }
.tab.active, .tab.is-on, .tab[aria-selected="true"], .tab[aria-current="page"] { color: var(--accent-text); border-bottom-color: var(--accent); font-weight: 700; }
.tabs--pills { border-bottom: 0; gap: 6px; flex-wrap: wrap; overflow: visible; }
.tabs--pills .tab { min-height: 34px; padding: 4px 14px; border: 1px solid var(--border); border-radius: 999px; margin: 0; background: var(--card); }
.tabs--pills .tab:hover { border-color: var(--accent); background: var(--card); }
.tabs--pills :is(.tab.active, .tab.is-on, .tab[aria-selected="true"], .tab[aria-current="page"]) { background: var(--accent); border-color: var(--accent); color: #fff; }

.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin-top: 16px; font-size: 14px; }
.pagination :is(a, button, span) {
  display: inline-grid; place-items: center; min-width: 36px; height: 36px; padding: 0 10px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card); color: var(--text-2); text-decoration: none; font-family: inherit; font-weight: 600; cursor: pointer;
}
.pagination :is(a, button):hover { border-color: var(--accent); color: var(--accent-text); }
.pagination :is(.is-current, [aria-current="page"]) { background: var(--accent); border-color: var(--accent); color: #fff; cursor: default; }
.pagination :is(.is-disabled, [disabled], .gap) { opacity: .5; cursor: default; }
.pagination .gap { border: 0; background: none; min-width: 20px; padding: 0; }

/* ---- status ---- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; min-height: 22px; padding: 1px 9px; border-radius: 999px; max-width: 100%;
  font-size: 12px; font-weight: 600; line-height: 1.5; background: var(--accent-soft); color: var(--accent-text); white-space: nowrap; vertical-align: middle;
}
.chip--line { background: none; box-shadow: inset 0 0 0 1px var(--accent-line); }
.chip--solid { background: var(--accent); color: #fff; }
.chip--good { background: var(--good-bg); color: var(--good); }
.chip--warn { background: var(--warn-bg); color: var(--warn); }
.chip--bad { background: var(--bad-bg); color: var(--bad); }
.chip--plain { background: var(--surface-muted); color: var(--text-2); }
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.5;
  background: var(--surface-muted); color: var(--text-2); white-space: nowrap; vertical-align: middle;
}
.badge-green, .badge-good, .badge-success { background: var(--good-bg); color: var(--good); }
.badge-yellow, .badge-warn, .badge-warning { background: var(--warn-bg); color: var(--warn); }
.badge-red, .badge-bad, .badge-danger { background: var(--bad-bg); color: var(--bad); }
.badge-gray, .badge-neutral { background: var(--surface-muted); color: var(--text-2); }
.badge-blue, .badge-info { background: var(--accent-soft); color: var(--accent-text); }
.pill { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; flex: none; font-variant-numeric: tabular-nums; }
.pill--zero { background: var(--surface-muted); color: var(--text-3); }

.alert, .error-msg, .success-msg, .page-banner {
  display: block; padding: 10px 14px; border-radius: var(--r-in); margin-bottom: 14px;
  font-size: var(--fs-sm); line-height: 1.5; font-weight: 500;
  background: var(--accent-softer); color: var(--text); border: 1px solid var(--accent-line);
}
.alert.hidden, .alert[hidden] { display: none; }
.alert > :is(b, strong):first-child { font-weight: 700; }
.alert-info, .alert.info { background: var(--accent-softer); border-color: var(--accent-line); color: var(--text); }
.alert-good, .alert-success, .alert.ok, .success-msg { background: var(--good-bg); border-color: color-mix(in srgb, var(--good) 28%, var(--good-bg)); color: #1f5a36; }
.alert-warn, .alert-warning, .alert.warn, .page-banner { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 30%, var(--warn-bg)); color: #6f4705; }
.alert-bad, .alert-danger, .alert-error, .alert.err, .error-msg { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 28%, var(--bad-bg)); color: #8a1f2a; }
.alert a { color: inherit; font-weight: 700; }

.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 28px 18px; text-align: center;
  border-radius: var(--r-in); background: var(--surface-soft); border: 1px dashed var(--border); color: var(--text-2); font-size: 14px;
}
.empty-state-icon { width: 44px; height: 44px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 20px; line-height: 1; margin-bottom: 4px; }
.empty-state b { font-size: 15.5px; color: var(--text); }
.empty-state .btn { margin-top: 8px; }
.empty-line { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: var(--r-in); background: var(--surface-soft); border: 1px dashed var(--border); color: var(--text-2); font-size: 14px; }
.empty-line > :is(a, button):last-child { margin-inline-start: auto; }

.toasts { position: fixed; z-index: 700; inset-inline: 0; bottom: 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 14px; pointer-events: none; }
.toast-item {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: min(520px, 100%); padding: 11px 16px; border-radius: 14px;
  background: var(--text); color: #fff; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-pop);
}
.toast-item--good { background: var(--good); }
.toast-item--bad { background: var(--bad); }
.toast-item a, .toast-item button { color: inherit; font-weight: 700; }

/* ---- overlays ---- */
.modal { position: fixed; inset: 0; z-index: 600; display: none; align-items: center; justify-content: center; padding: 16px; background: rgba(22, 42, 77, .42); overflow-y: auto; }
.modal.is-open { display: flex; }
.modal-card, dialog.dialog {
  background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-pop);
  width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 0;
}
.modal-card--wide { width: min(860px, 100%); }
dialog.dialog { margin: auto; }
dialog.dialog::backdrop { background: rgba(22, 42, 77, .42); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px 10px; }
.modal-title { flex: 1 1 auto; min-width: 0; font-size: 17px; font-weight: 700; line-height: 1.3; margin: 0; }
.modal-close { flex: none; width: 34px; height: 34px; border-radius: 10px; border: 0; background: var(--surface-muted); color: var(--text-2); font-size: 20px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.modal-close:hover { background: var(--accent-soft); color: var(--accent-text); }
.modal-body { padding: 4px 20px 16px; }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--hair); }

/* ---- data ---- */
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0 18px; font-size: 14px; }
.kv > dt { color: var(--text-3); font-size: 13px; padding: 8px 0; border-bottom: 1px solid var(--hair); }
.kv > dd { color: var(--text); font-weight: 500; padding: 8px 0; border-bottom: 1px solid var(--hair); min-width: 0; overflow-wrap: anywhere; }
.kv > dt:last-of-type, .kv > dd:last-of-type { border-bottom: 0; }
.kv--stack { grid-template-columns: minmax(0, 1fr); }
.kv--stack > dt { border-bottom: 0; padding-bottom: 0; }
.kv--stack > dd { padding-top: 1px; }

/* ---- layout helpers ---- */
.stack { display: flex; flex-direction: column; gap: 12px; }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.grid-2, .grid-3, .grid-4 { gap: 16px !important; }
.grid-2 > *, .grid-3 > *, .grid-4 > * { min-width: 0; }
.divider { border: 0; border-top: 1px solid var(--hair); margin: 14px 0; }

/* ---- old .navbar (a few standalone pages still draw one) ---- */
.navbar {
  background: rgba(255, 253, 248, .94); color: var(--text); border-bottom: 1px solid var(--border); padding: 10px 20px;
  display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 100;
}
.navbar h1 { font-size: var(--fs-md); font-weight: 700; }
.navbar a { color: var(--accent-text); text-decoration: none; margin-right: 15px; font-size: var(--fs-sm); }
.nav-links { display: flex; gap: 12px; align-items: center; }

/* ============================================================================ 5. responsive */
/* the header: one row from 1280px (the user's name gives way first, as on the home); below that the menu
 * takes a second row; on a phone it lives in the drawer */
@media (max-width: 1439px) {
  .user-menu > summary .user-name { display: none; }
  .user-menu > summary { padding-inline: 4px 8px; }
}
@media (max-width: 1279px) {
  .topbar-inner { flex-wrap: wrap; row-gap: 0; }
  .nav-desktop-wrap { order: 5; flex: 1 1 100%; margin: 0; padding: 4px 0 6px; border-top: 1px solid var(--hair); margin-inline-end: -38px; }
  .nav-desktop > a, .nav-group > summary { font-size: 13.5px; padding: 0 8px; }
  .brand { min-height: var(--navbar-h); }
}
@media (max-width: 820px) {
  :root { --navbar-h: 54px; --gap: 14px; }
  .topbar-inner { padding: 0 12px; padding-inline-end: 56px; gap: 6px; flex-wrap: nowrap; }
  .user-strip { gap: 6px; }
  .brand { gap: 8px; }
  .brand-name { font-size: 15px; }
  body #a11y-launcher { top: 7px; inset-inline-end: 10px; }
  .nav-desktop-wrap { display: none; }
  .brand-mark { width: 32px; height: 32px; border-radius: 10px; }
  .brand-name { max-width: 100%; }
  .brand { flex: 1 1 auto; min-width: 32px; min-height: 0; overflow: hidden; }
  /* the personal menu and the year menu open as a sheet under the header, across the screen */
  .user-menu, .year-switch { position: static; }
  .user-menu .menu-pop, .year-switch-menu { inset-inline: 10px; top: calc(100% + 6px); min-width: 0; }
  .menu-pop a, .menu-pop button, .year-switch-item { min-height: 44px; }
  .user-menu > summary { padding: 0; height: 40px; }
  .user-menu > summary .user-name, .user-menu > summary .chevron { display: none; }
  .year-switch > summary, .year-pill { height: 30px; padding: 0 8px; font-size: 12px; gap: 4px; }
  .hamburger { width: 40px; height: 40px; }
  .favs-bar { padding: 8px 14px 0; }
  .container { padding: 14px 14px 28px; }
  .page-title-strip, .page-title { font-size: 21px; margin-bottom: 12px; }
  .card { padding: 16px; border-radius: 18px; }
  .navbar { flex-wrap: wrap; gap: 6px; padding: 10px 12px; }
  .navbar h1 { font-size: var(--fs-sm); width: 100%; }
  .nav-links { flex-wrap: wrap; gap: 8px; width: 100%; justify-content: flex-start; }
  .navbar a { margin-right: 0; font-size: var(--fs-xs); }
  body.has-bnav .topbar-inner { padding-inline-end: 12px; }      /* signed in, the accessibility button is in the bottom row */
}
@media (max-width: 600px) {
  :root { --fs-lg: 19px; --fs-xl: 22px; --fs-2xl: 27px; }
  .card { padding: 14px; }
  th, td { padding: 8px 10px; font-size: var(--fs-sm); }
  .att-label { padding: 5px 8px; font-size: 11.5px; }
  .table-wrap table { min-width: 560px; }
  /* on a phone a button fills its row, unless it is .btn-inline or sits in a row made for buttons */
  .btn { width: 100%; }
  .btn-inline, .btn-icon,
  :is(.toolbar, .filter-bar, .page-actions, .btn-row, .btn-group, .cluster, .card-h, .card-foot, .modal-foot, .form-actions, .pagination, .tabs, .cell-actions, .alert, .empty-line, .section-head, td, th,
      [class*="actions"], [class*="toolbar"], [class*="-nav"], [class*="btns"]) .btn { width: auto; }
  #admin-page-settings-btn { padding: 0; width: 34px; min-height: 34px; justify-content: center; border-color: var(--border); background: var(--card); }
  #admin-page-settings-btn .ps-btn-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .form-actions .btn, .modal-foot .btn { flex: 1 1 auto; }
  .grid-2 { grid-template-columns: 1fr !important; }
  .form-row > * { flex-basis: 100% !important; }
  .form-grid, .form-grid--2, .form-grid--3 { grid-template-columns: minmax(0, 1fr); }
  .toolbar :is(.input, .select, .input-field, .field), .filter-bar :is(.input, .select, .input-field, .field) { flex: 1 1 100%; min-width: 0; width: 100%; }
  .kv { grid-template-columns: minmax(0, 1fr); }
  .kv > dt { border-bottom: 0; padding-bottom: 0; }
  .kv > dd { padding-top: 1px; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-card { width: 100%; max-height: 92vh; border-radius: 20px 20px 0 0; }
  .favs-chip { font-size: 12.5px; min-height: 30px; padding: 0 10px; }
  .favs-add { width: 30px; height: 30px; }
  #maintenance-toast { inset-inline: 12px; max-width: none; }
}
@media (max-width: 380px) {
  .year-switch > summary { padding: 0 8px; }
}

/* ============================================================================ 6. print
 * Print keeps what it had before the redesign: the logo banner on top, the centred page title, the old
 * type sizes and cell padding — so a page that was tuned to fit a sheet still fits it. */
@media print {
  :root { --fs-xs: 12px; --fs-sm: 14px; --fs-base: 16px; --fs-md: 18px; --fs-lg: 22px; --fs-xl: 28px; --fs-2xl: 36px; --lh-normal: 1.55; }
  html, body { height: auto; }
  body { background: #fff !important; font-size-adjust: none; padding-bottom: 0 !important; }
  .topbar, .favs-bar, .favs-modal, .hamburger, .drawer, .g-bnav, .site-footer, .shell-strip,
  #maintenance-banner, #maintenance-toast, #admin-page-settings-btn, #page-settings-modal,
  .page-actions, .toasts, .no-print { display: none !important; }
  .only-print { display: revert !important; }
  .logo-strip { display: block; text-align: center; padding: 12px 0; border-bottom: 1px solid #ccc; }
  .logo-strip img { max-height: 140px; max-width: 92%; object-fit: contain; }
  .page-title-strip { text-align: center; font-size: 18px; font-weight: 600; margin: 0; padding: 6px 16px; border-bottom: 1px solid #ccc; }
  .container { max-width: 1220px; margin: 28px auto 40px; padding: 0 16px; }
  .card { padding: 28px; margin-bottom: 22px; }
  .card, .table-wrap { box-shadow: none !important; border-color: #ccc !important; }
  th, td { padding: 12px 14px; }
  th { font-size: 14px; }
}
