/* =============================================================================
   App — Al-Aqsa Private and International Schools identity
   -----------------------------------------------------------------------------
   Single source of truth for the dashboard's design tokens. Implements
   docs/design-system.md; that document is the specification, this file is the
   binding. If the two disagree, the document wins and this file is wrong.

   Loaded LAST, after the Steex theme. It only re-binds design tokens — it never
   re-declares layout or component structure. To re-brand the app, edit
   section 1; nothing below it holds a literal colour.

   NOTE: the app is served the prebuilt RTL stylesheets (app-rtl.css and
   friends), not the gulp `scss` output. Editing wwwroot/assets/scss changes
   nothing at runtime — brand work belongs here.

   Sections
     1. Design tokens ...................... the only place raw values live
     2. Bootstrap/Steex theme mapping ...... --tb-* built from section 1
     3. Component token re-binding ......... rules the theme hardcoded
     4. Application chrome ................. sidebar, topbar, page shell
     5. Typography ......................... family + the spec's type scale
     6. Brand lockup ....................... logo mark + wordmark
     6b. User preferences .................. reduced motion, contrast, forced colours
     7. Dark mode ........................... docs/design-system.md §6
   ========================================================================== */

/* -----------------------------------------------------------------------------
   1. Design tokens — docs/design-system.md §1–§5
   RGB triplets are authoritative; the hex-equivalent tokens are derived from
   them so an alpha variant can never drift from its solid counterpart.
   -------------------------------------------------------------------------- */
:root {
  /* --- §1 Brand & interactive -------------------------------------------- */
  /* Teal ramp, taken from the school's logo. 400 is the logo's own teal
     (#37A6B7; alaqsa.edu.sa ships the lighter #47ADBF). White on either is
     under 3:1, so 500 is the same hue deepened until white on it clears AA
     (#1A7C8C — the teal the planning documents print in). Tints are 500
     mixed towards white, shades towards black, so the ramp stays one curve. */
  --app-teal-50: #e8f2f4;
  --app-teal-100: #d1e5e8;
  --app-teal-200: #a3cbd1;
  --app-teal-300: #73c1cd;
  --app-teal-400-rgb: 55, 166, 183;
  --app-teal-400: rgb(var(--app-teal-400-rgb));
  --app-teal-500-rgb: 26, 124, 140;
  --app-teal-500: rgb(var(--app-teal-500-rgb));
  --app-teal-600-rgb: 21, 99, 112;
  --app-teal-600: rgb(var(--app-teal-600-rgb));
  --app-teal-700: #114f5a;
  --app-teal-800-rgb: 12, 60, 67;
  --app-teal-800: rgb(var(--app-teal-800-rgb));
  --app-teal-900: #092a30;

  /* Orange ramp — the logo's pen nib and tagline. 500 is #F4832C, the value
     alaqsa.edu.sa ships as its secondary and the logo's own orange. It is the
     Accent: a call to action, used sparingly, and never a state. */
  --app-orange-100: #fdecde;
  --app-orange-300: #f7bf92;
  --app-orange-400: #f39f5c;
  --app-orange-500-rgb: 244, 131, 44;
  --app-orange-500: rgb(var(--app-orange-500-rgb));
  --app-orange-600: #e5741b;

  /* Amber — the Warning state only. Kept apart from the orange Accent so a
     pending badge never reads as a button asking to be pressed. */
  --app-amber-100: #fef3d7;
  --app-amber-300: #fcd98a;
  --app-amber-700: #b45309;

  /* --- §1 Neutrals -------------------------------------------------------
     The planning documents' ink ramp, which leans towards the brand teal: a
     neutral grey beside this teal reads brown. 50 / 200 / 600 / 900 are the
     spec's Background, Border, Text Secondary and Text Primary; the steps
     between cover the states the spec does not name (sunken fills, disabled
     text, strong rules). */
  --app-gray-50-rgb: 243, 248, 249;
  --app-gray-50: rgb(var(--app-gray-50-rgb));
  --app-gray-100: #e9f1f3;
  --app-gray-200: #d8e1e4;
  --app-gray-300: #b6c6cb;
  --app-gray-400: #7d9299;
  --app-gray-600-rgb: 85, 106, 113;
  --app-gray-600: rgb(var(--app-gray-600-rgb));
  --app-gray-700: #39494f;
  --app-gray-800-rgb: 28, 58, 66;
  --app-gray-800: rgb(var(--app-gray-800-rgb));
  --app-gray-900-rgb: 12, 53, 64;
  --app-gray-900: rgb(var(--app-gray-900-rgb));

  /* --- Semantic aliases: what the UI actually consumes -------------------- */
  --app-brand: var(--app-teal-500);
  --app-brand-rgb: var(--app-teal-500-rgb);
  --app-brand-hover: var(--app-teal-600);
  --app-brand-active: var(--app-teal-700);
  --app-brand-deep: var(--app-teal-800);
  --app-brand-soft: var(--app-teal-50);
  --app-brand-border: var(--app-teal-200);

  --app-accent: var(--app-orange-500);
  --app-accent-rgb: var(--app-orange-500-rgb);
  --app-accent-hover: var(--app-orange-600);
  /* The label on an Accent fill. White is 2.6:1 on the orange, so the label is
     the deepest teal (5.9:1, 4.9:1 on hover) — and a fixed value rather than
     the body ink, because the orange does not move between themes either. */
  --app-on-accent: var(--app-teal-900);

  /* --- §1 Feedback --------------------------------------------------------
     Warning is kept distinct from --app-accent on purpose: the spec separates
     the Accent (orange #F4832C, a call to action) from Warning (amber
     #F59E0B, a state). */
  --app-success-rgb: 16, 185, 129;
  --app-success: rgb(var(--app-success-rgb));
  --app-success-deep: #047857; /* emphasis text: 5.5:1 on white, 5:1 on its subtle ground */
  --app-warning-rgb: 245, 158, 11;
  --app-warning: rgb(var(--app-warning-rgb));
  --app-danger-rgb: 239, 68, 68;
  --app-danger: rgb(var(--app-danger-rgb));

  /* --- Brand and feedback as INK — docs/design-system.md §6 ---------------
     A colour that carries content on top of it (a button, a badge, a filled
     header) and the same colour used AS content (a link, an icon, a hairline)
     have opposite requirements, and dark mode is where they come apart: white
     on the brand needs the brand dark, the brand on a dark canvas needs it
     light. One token cannot do both, so the ink half is named separately.

     In light mode the ink sits one step below the fill: the fill (#1A7C8C)
     is 4.9:1 on white, the ink (#156370) 6.9:1, which is the 6:1 bar the spec
     sets for text. Warning ink is amber-700: the amber fill is 2.1:1 on white
     and cannot carry text at any size. */
  --app-brand-ink: var(--app-teal-600);
  --app-brand-ink-rgb: var(--app-teal-600-rgb);
  --app-brand-ink-hover: var(--app-teal-700);
  --app-brand-ink-active: var(--app-teal-800);
  --app-success-ink: var(--app-success-deep);
  --app-warning-ink: var(--app-amber-700);
  --app-danger-ink: #b91c1c;
  /* Info reads as the deep teal: 9.2:1 on white, 8:1 on its teal-50 ground. */
  --app-info-ink: var(--app-teal-700);
  /* The Accent as ink — an edit label on its own 12% orange tint. The orange
     itself is 2.3:1 there; this burnt step of it is 6.1:1 (6.8:1 on white). */
  --app-accent-ink: #9a3f0a;
  /* Triplets for the .text-* utilities, which keep Bootstrap's --tb-text-opacity. */
  --app-success-ink-rgb: 4, 120, 87;
  --app-warning-ink-rgb: 180, 83, 9;
  --app-danger-ink-rgb: 185, 28, 28;
  --app-info-ink-rgb: 17, 79, 90;
  --app-accent-ink-rgb: 154, 63, 10;

  /* --- Feedback FILLS — what carries a white label ------------------------
     The spec's feedback hues (--app-success/-danger above, and the teal-400
     Info) are too light to carry white text: 2.5:1, 3.8:1 and 2.9:1. These are
     the same hues taken down the ramp until a white label clears AA, and they
     are what .bg-*, .btn-* and every badge fill with (section 2/3). Hover and
     active go one step deeper still. White on: success 5.5:1 (hover 7.7:1),
     danger 6.5:1 (hover 8.3:1), info 6.9:1 (hover 9.2:1). */
  --app-success-fill-rgb: 4, 120, 87;
  --app-success-fill: rgb(var(--app-success-fill-rgb)); /* #047857 */
  --app-success-fill-hover: #065f46;
  --app-danger-fill-rgb: 185, 28, 28;
  --app-danger-fill: rgb(var(--app-danger-fill-rgb)); /* #b91c1c */
  --app-danger-fill-hover: #991b1b;
  --app-info-fill-rgb: var(--app-teal-600-rgb);
  --app-info-fill: var(--app-teal-600);
  --app-info-fill-hover: var(--app-teal-700);

  /* --- Labels on a filled ground ------------------------------------------
     White, named, so a component never writes the literal. The fills above
     and the brand fill do not move between themes, so neither does this. The
     translucent steps are for chips and hovers laid over a brand fill (the
     notifications header): 95% white is 4.6:1 on teal-500, where the 75%
     it replaced was 3.5:1. */
  --app-on-brand-rgb: 255, 255, 255;
  --app-on-brand: rgb(var(--app-on-brand-rgb));
  --app-on-brand-muted: rgba(var(--app-on-brand-rgb), 0.95);
  --app-on-brand-wash: rgba(var(--app-on-brand-rgb), 0.25);
  --app-on-brand-wash-hover: rgba(var(--app-on-brand-rgb), 0.4);

  /* --- §6 Dark neutrals ---------------------------------------------------
     The dark counterpart of the grey ramp above, cooled towards blue: the
     brand is a teal, and a neutral grey beside it on a dark ground reads
     brown. Consumed only by section 7 — nothing here is used in light mode. */
  --app-slate-950: #0d1117; /* canvas */
  --app-slate-900: #151b23; /* surface card, sidebar, topbar, dropdowns */
  --app-slate-850: #1c232c; /* sunken fills, hovers */
  --app-slate-800: #232c36; /* border / divider */
  --app-slate-700: #303b47; /* strong border, input outline */
  --app-slate-600: #3a4553; /* filled neutral chips */
  --app-slate-400: #7d8998; /* faint text: placeholders, disabled */
  --app-slate-300: #9aa6b5; /* secondary text */
  --app-slate-100-rgb: 227, 232, 238;
  --app-slate-100: rgb(var(--app-slate-100-rgb)); /* primary text */
  --app-slate-50: #f2f5f8; /* headings */
  /* Deep teal tint — the dark counterpart of the spec's #E8F2F4 Surface Tint.
     Opaque, for the same reason the sidebar fills below are. */
  --app-teal-tint-dark: #16303a;
  --app-teal-tint-dark-border: #184c58;

  /* Text */
  --app-ink: var(--app-gray-900);
  --app-ink-rgb: var(--app-gray-900-rgb);
  --app-ink-strong: var(--app-gray-900);
  --app-ink-muted: var(--app-gray-600);
  --app-ink-faint: var(--app-gray-400);

  /* Surfaces */
  --app-canvas: var(--app-gray-50);
  /* The veil the full-page loading screen draws over the app. Slightly
     translucent so the layout behind it stays readable while it fades. */
  --app-scrim: rgba(var(--app-gray-50-rgb), 0.9);
  /* A different thing: the DARK backdrop behind a modal (app-components.css
     .app-modal__scrim). Flat — the no-gradient rule applies to scrims too. */
  --app-modal-scrim: rgba(var(--app-gray-900-rgb), 0.55);
  --app-surface: #ffffff;
  /* The sheet a print preview renders on. White in BOTH themes: it stands for
     paper, and a printed page is never dark. */
  --app-paper: #ffffff;
  --app-surface-sunken: var(--app-gray-100);
  --app-line: var(--app-gray-200);
  --app-line-strong: var(--app-gray-300);

  /* Sidebar item fills. The shell runs a light sidebar, so these are neutral
     for hover and the spec's Surface Tint for the selected item. Opaque on
     purpose — the collapsed sidebar widens a hovered item out over the page,
     where a translucent fill would leak the content behind. See section 4. */
  --app-sidebar-hover: var(--app-gray-100);
  --app-sidebar-active: var(--app-teal-50);

  /* No gradient tokens. The last consumers (Modifications.css's form buttons,
     role-group header and active page; .badge-gradient-primary) are solid
     fills now: a gradient has no single contrast ratio against the text on it,
     and depth is the surface step, the hairline and the shadow. */

  /* --- §4 Elevation ------------------------------------------------------- */
  --app-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --app-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --app-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  /* Legacy aliases — the app's resting/hover/glow surfaces map onto the
     spec's three steps rather than carrying a fourth set of values. */
  --app-shadow-soft: var(--app-shadow-sm);
  --app-shadow-card: var(--app-shadow-md);
  --app-shadow-glow: 0 10px 15px -3px rgba(var(--app-brand-rgb), 0.25);

  /* --- §4 Border radius --------------------------------------------------- */
  --app-radius-sm: 4px; /* badges, tooltips, inline tags */
  --app-radius-md: 8px; /* buttons, inputs, dropdowns */
  --app-radius-lg: 12px; /* cards, modals */
  --app-radius-full: 9999px; /* avatars, pills */
  /* Legacy aliases so pre-existing rules resolve onto the spec's four steps */
  --app-radius: var(--app-radius-md);
  --app-radius-xl: var(--app-radius-lg);
  --app-radius-2xl: var(--app-radius-lg);

  /* --- §3 Spacing grid (8px standard) ------------------------------------- */
  --app-space-1: 4px;
  --app-space-2: 8px;
  --app-space-3: 12px;
  --app-space-4: 16px;
  --app-space-6: 24px;
  --app-space-8: 32px;

  /* --- §2 Typography scale ------------------------------------------------ */
  --app-text-display: 36px;
  --app-text-display-lh: 1.2;
  --app-text-h1: 24px;
  --app-text-h1-lh: 1.3;
  --app-text-h2: 20px;
  --app-text-h2-lh: 1.35;
  --app-text-subtitle: 16px;
  --app-text-subtitle-lh: 1.4;
  --app-text-body: 14px;
  --app-text-body-lh: 1.5;
  --app-text-caption: 12px;
  --app-text-caption-lh: 1.4;

  --app-weight-regular: 400;
  --app-weight-medium: 500;
  --app-weight-semibold: 600;

  /* --- §5 Core component metrics ------------------------------------------ */
  --app-control-height: 40px; /* buttons and inputs, web */
  --app-control-height-touch: 48px; /* mobile touch target */
  --app-focus-ring: 0 0 0 3px rgba(var(--app-brand-rgb), 0.15);

  /* Motion */
  --app-ease: cubic-bezier(0.22, 1, 0.36, 1);

  /* --- Stacking ------------------------------------------------------------
     The layers the app adds on top of Bootstrap's own scale (dropdown 1000,
     sticky 1020, fixed 1030, modal 1055, popover 1070, tooltip 1080, toast
     1090; app-components.css puts SweetAlert at 1095). The offline notice sits
     above the page and any open modal, below toasts and dialogs; the loading
     veil covers everything; the skip link must beat even the veil. The
     "please wait" notice sits above an open modal and SweetAlert, since the
     save it reports on is usually one made from inside them. */
  --app-z-offline: 1085;
  --app-z-busy: 1099;
  --app-z-loading: 9999;
  --app-z-skip-link: 10000;

  /* --- Type family --------------------------------------------------------
     The spec's stack, verbatim. El Messiri is self-hosted and declared in
     assets/css/brand/app-fonts.css, which must load first.

     Body and display are the same family — the spec names one. They stay two
     tokens because every rule in section 5 already reads through them, so a
     future display face is a one-line change rather than a sweep.

     The tail is now an ordinary fallback. Under the previous family it was
     load-bearing: that face carried no Latin letters at all, so every Latin
     word in the UI was rendered by the first system face in this list. El
     Messiri covers Latin, so the stack behaves the way it reads. */
  --app-font-body:
    "El Messiri", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  --app-font-display: var(--app-font-body);
}
/* -----------------------------------------------------------------------------
   2. Bootstrap / Steex theme mapping
   The theme's own tokens are re-pointed at section 1. Every `.text-primary`,
   `.bg-primary`, `.border-primary`, badge, alert and utility resolves through
   these, so they are all covered by this one block.
   -------------------------------------------------------------------------- */
:root,
[data-bs-theme="light"] {
  --tb-blue: var(--app-brand);
  --tb-teal: var(--app-teal-400);

  --tb-primary: var(--app-brand);
  --tb-primary-rgb: var(--app-brand-rgb);
  --tb-primary-text-emphasis: var(--app-teal-700);
  --tb-primary-bg-subtle: var(--app-teal-50);
  --tb-primary-border-subtle: var(--app-teal-200);

  --tb-secondary: var(--app-ink);
  --tb-secondary-rgb: var(--app-ink-rgb);
  --tb-secondary-text-emphasis: var(--app-gray-900);
  --tb-secondary-bg-subtle: var(--app-gray-50);
  --tb-secondary-border-subtle: var(--app-gray-200);

  /* Warning is the spec's feedback colour, not the Accent — see section 1 */
  --tb-warning: var(--app-warning);
  --tb-warning-rgb: var(--app-warning-rgb);
  --tb-warning-text-emphasis: var(--app-amber-700);
  --tb-warning-bg-subtle: var(--app-amber-100);
  --tb-warning-border-subtle: var(--app-amber-300);

  /* Success and Error are the spec's feedback colours. Both were previously
     left on the Steex defaults, which is why a green toast and a red validation
     message were the only two things on screen still off-palette. */
  /* The FILL steps (section 1), not the spec hue: .bg-success/.bg-danger/.bg-info
     and every badge on them carry a white label. */
  --tb-success: var(--app-success-fill);
  --tb-success-rgb: var(--app-success-fill-rgb);
  --tb-success-text-emphasis: var(--app-success-deep);
  --tb-success-bg-subtle: #e7f8f2;
  --tb-success-border-subtle: #a7e8d0;

  --tb-danger: var(--app-danger-fill);
  --tb-danger-rgb: var(--app-danger-fill-rgb);
  --tb-danger-text-emphasis: var(--app-danger-ink);
  --tb-danger-bg-subtle: #fdeaea;
  --tb-danger-border-subtle: #f7b9b9;

  /* Info reads as a lighter teal so it never competes with primary */
  --tb-info: var(--app-info-fill);
  --tb-info-rgb: var(--app-info-fill-rgb);
  --tb-info-text-emphasis: var(--app-info-ink);
  --tb-info-bg-subtle: var(--app-teal-50);
  --tb-info-border-subtle: var(--app-teal-200);

  --tb-dark: var(--app-ink-strong);
  --tb-dark-rgb: var(--app-gray-900-rgb);
  --tb-dark-text-emphasis: var(--app-gray-700);
  --tb-dark-bg-subtle: var(--app-gray-100);
  --tb-dark-border-subtle: var(--app-gray-200);

  --tb-light: var(--app-gray-50);
  --tb-light-rgb: var(--app-gray-50-rgb);
  --tb-light-bg-subtle: var(--app-canvas);
  --tb-light-border-subtle: var(--app-line);

  /* Surfaces and text */
  --tb-body-bg: var(--app-canvas);
  --tb-body-bg-rgb: var(--app-gray-50-rgb);
  --tb-body-color: var(--app-ink);
  --tb-body-color-rgb: var(--app-ink-rgb);
  --tb-emphasis-color: var(--app-ink-strong);
  --tb-emphasis-color-rgb: var(--app-gray-900-rgb);
  --tb-heading-color: var(--app-ink-strong);
  --tb-secondary-color: var(--app-ink-muted);
  --tb-secondary-color-rgb: var(--app-gray-600-rgb);
  --tb-secondary-bg: var(--app-surface);
  /* .bg-body-secondary reads the triplet, not the colour above */
  --tb-secondary-bg-rgb: 255, 255, 255;
  --tb-tertiary-color: var(--app-ink-faint);
  --tb-tertiary-bg: var(--app-surface-sunken);

  --tb-border-color: var(--app-line);
  --tb-border-color-translucent: var(--app-line);

  /* Links */
  --tb-link-color: var(--app-brand-ink-hover);
  --tb-link-color-rgb: var(--app-brand-ink-rgb);
  --tb-link-hover-color: var(--app-brand-ink-active);
  --tb-link-hover-color-rgb: var(--app-teal-800-rgb);

  /* Focus — Bootstrap's own default wraps a hex in rgb(), which never resolves */
  --tb-focus-ring-color: rgba(var(--app-brand-rgb), 0.25);

  /* Radii — the spec's four steps. --tb-border-radius is the default every
     button, input and dropdown resolves to, so it carries Medium (8px);
     Small (4px) is for badges and tags, Large (12px) for cards and modals. */
  --tb-border-radius: var(--app-radius-md);
  --tb-border-radius-sm: var(--app-radius-sm);
  --tb-border-radius-lg: var(--app-radius-lg);
  --tb-border-radius-xl: var(--app-radius-lg);
  --tb-border-radius-xxl: var(--app-radius-lg);
  --tb-border-radius-pill: var(--app-radius-full);

  --tb-highlight-bg: var(--app-orange-100);
  --tb-highlight-color: var(--app-ink-strong);
}

/* Theme-level tokens the Steex layer sets on [data-theme] */
[data-theme="default"] {
  --tb-font-sans-serif: var(--app-font-body);
  --tb-font-monospace: var(--app-font-body);
  /* --tb-body-font-size resolves through this, so it sets the spec's Body Main */
  --tb-font-base: var(--app-text-body);
  --tb-body-line-height: var(--app-text-body-lh);
  --tb-shadow-sm: var(--app-shadow-sm);
  --tb-shadow: var(--app-shadow-md);
  --tb-shadow-lg: var(--app-shadow-lg);
  --tb-card-shadow: var(--app-shadow-sm);

  /* Legacy accents kept for markup that still asks for them, now on-brand */
  --tb-deep-teal-rgb: var(--app-gray-800-rgb);
  --tb-strong-teal-rgb: var(--app-brand-rgb);
  --tb-deep-teal-bg-subtle: rgba(var(--app-brand-rgb), 0.12);
}

/* -----------------------------------------------------------------------------
   3. Component token re-binding
   Bootstrap writes literal hexes inside these component scopes, so a :root
   override cannot reach them. Each rule below only re-points the component's
   own variables back at section 1 — no new declarations.
   -------------------------------------------------------------------------- */
.btn-primary {
  --tb-btn-bg: var(--app-brand);
  --tb-btn-border-color: var(--app-brand);
  --tb-btn-hover-bg: var(--app-brand-hover);
  --tb-btn-hover-border-color: var(--app-brand-hover);
  --tb-btn-active-bg: var(--app-brand-active);
  --tb-btn-active-border-color: var(--app-brand-active);
  --tb-btn-disabled-bg: var(--app-brand);
  --tb-btn-disabled-border-color: var(--app-brand);
  --tb-btn-focus-shadow-rgb: var(--app-brand-rgb);
}

.btn-outline-primary {
  --tb-btn-color: var(--app-brand-ink-hover);
  --tb-btn-border-color: var(--app-brand-ink);
  --tb-btn-hover-bg: var(--app-brand);
  --tb-btn-hover-border-color: var(--app-brand);
  --tb-btn-active-bg: var(--app-brand-hover);
  --tb-btn-active-border-color: var(--app-brand-hover);
  --tb-btn-disabled-color: var(--app-brand-ink);
  --tb-btn-disabled-border-color: var(--app-brand-ink);
  --tb-btn-focus-shadow-rgb: var(--app-brand-rgb);
}

/* The spec's Secondary Button: Surface Tint ground, Primary text. It reads as
   a quiet companion to .btn-primary, which is exactly how the app already used
   it — every .btn-secondary in the views is a close / cancel / reset action. */
.btn-secondary {
  --tb-btn-color: var(--app-brand-ink);
  --tb-btn-bg: var(--app-brand-soft);
  --tb-btn-border-color: var(--app-brand-soft);
  --tb-btn-hover-color: var(--app-on-brand);
  --tb-btn-hover-bg: var(--app-brand);
  --tb-btn-hover-border-color: var(--app-brand);
  --tb-btn-active-color: var(--app-on-brand);
  --tb-btn-active-bg: var(--app-brand-hover);
  --tb-btn-active-border-color: var(--app-brand-hover);
  --tb-btn-disabled-color: var(--app-ink-faint);
  --tb-btn-disabled-bg: var(--app-surface-sunken);
  --tb-btn-disabled-border-color: var(--app-surface-sunken);
  --tb-btn-focus-shadow-rgb: var(--app-brand-rgb);
}

.btn-outline-secondary {
  --tb-btn-color: var(--app-ink);
  --tb-btn-border-color: var(--app-line-strong);
  --tb-btn-hover-bg: var(--app-ink);
  --tb-btn-hover-border-color: var(--app-ink);
  --tb-btn-active-bg: var(--app-ink-strong);
  --tb-btn-active-border-color: var(--app-ink-strong);
  --tb-btn-disabled-color: var(--app-ink-muted);
  --tb-btn-disabled-border-color: var(--app-line-strong);
  --tb-btn-focus-shadow-rgb: var(--app-ink-rgb);
}

/* The spec's Accent Button — Accent ground, --app-on-accent label, SemiBold.
   `.btn-accent` is the name the spec uses; `.btn-warning` is the same button
   under the name the views already carry (edit actions, the edit-modal
   header), so the two are bound together rather than drifting apart. Note this
   is the Accent (orange #F4832C), not the Warning feedback colour (#F59E0B) that
   `.text-warning` and `.alert-warning` resolve to through --tb-warning. */
.btn-accent,
.btn-warning,
.btn-outline-warning:hover,
.btn-outline-warning:active {
  --tb-btn-color: var(--app-on-accent);
  --tb-btn-hover-color: var(--app-on-accent);
  --tb-btn-active-color: var(--app-on-accent);
  --tb-btn-font-weight: var(--app-weight-semibold);
}

.btn-accent,
.btn-warning {
  --tb-btn-bg: var(--app-accent);
  --tb-btn-border-color: var(--app-accent);
  --tb-btn-hover-bg: var(--app-accent-hover);
  --tb-btn-hover-border-color: var(--app-accent-hover);
  --tb-btn-active-bg: var(--app-accent-hover);
  --tb-btn-active-border-color: var(--app-accent-hover);
  --tb-btn-disabled-bg: var(--app-accent);
  --tb-btn-disabled-border-color: var(--app-accent);
  --tb-btn-focus-shadow-rgb: var(--app-accent-rgb);
}

/* .btn-light / .btn-dark / .btn-info pin literals the same way .btn-primary
   does. The outline, subtle and ghost variants all resolve through --tb-* and
   are already covered by section 2. */
.btn-light {
  --tb-btn-color: var(--app-ink);
  --tb-btn-bg: var(--app-surface-sunken);
  --tb-btn-border-color: var(--app-line);
  --tb-btn-hover-color: var(--app-ink);
  --tb-btn-hover-bg: var(--app-line);
  --tb-btn-hover-border-color: var(--app-line-strong);
  --tb-btn-active-color: var(--app-ink);
  --tb-btn-active-bg: var(--app-line-strong);
  --tb-btn-active-border-color: var(--app-line-strong);
  --tb-btn-disabled-color: var(--app-ink-faint);
  --tb-btn-disabled-bg: var(--app-surface-sunken);
  --tb-btn-disabled-border-color: var(--app-line);
  --tb-btn-focus-shadow-rgb: var(--app-ink-rgb);
}

.btn-dark {
  --tb-btn-bg: var(--app-ink-strong);
  --tb-btn-border-color: var(--app-ink-strong);
  --tb-btn-hover-bg: var(--app-ink);
  --tb-btn-hover-border-color: var(--app-ink);
  --tb-btn-active-bg: var(--app-gray-700);
  --tb-btn-active-border-color: var(--app-gray-700);
  --tb-btn-disabled-bg: var(--app-ink-strong);
  --tb-btn-disabled-border-color: var(--app-ink-strong);
  --tb-btn-focus-shadow-rgb: var(--app-gray-900-rgb);
}

.btn-info {
  --tb-btn-color: var(--app-on-brand);
  --tb-btn-bg: var(--app-info-fill);
  --tb-btn-border-color: var(--app-info-fill);
  --tb-btn-hover-color: var(--app-on-brand);
  --tb-btn-hover-bg: var(--app-info-fill-hover);
  --tb-btn-hover-border-color: var(--app-info-fill-hover);
  --tb-btn-active-color: var(--app-on-brand);
  --tb-btn-active-bg: var(--app-brand-active);
  --tb-btn-active-border-color: var(--app-brand-active);
  --tb-btn-disabled-bg: var(--app-info-fill);
  --tb-btn-disabled-border-color: var(--app-info-fill);
  --tb-btn-focus-shadow-rgb: var(--app-info-fill-rgb);
}

/* Danger and Success fill with the deep FILL steps (section 1) so the white
   label clears AA; the theme derived hover from the -text-emphasis token, which
   is now the same colour as the fill, so both are pinned here. */
.btn-danger {
  --tb-btn-color: var(--app-on-brand);
  --tb-btn-bg: var(--app-danger-fill);
  --tb-btn-border-color: var(--app-danger-fill);
  --tb-btn-hover-color: var(--app-on-brand);
  --tb-btn-hover-bg: var(--app-danger-fill-hover);
  --tb-btn-hover-border-color: var(--app-danger-fill-hover);
  --tb-btn-active-color: var(--app-on-brand);
  --tb-btn-active-bg: var(--app-danger-fill-hover);
  --tb-btn-active-border-color: var(--app-danger-fill-hover);
  --tb-btn-disabled-bg: var(--app-danger-fill);
  --tb-btn-disabled-border-color: var(--app-danger-fill);
  --tb-btn-focus-shadow-rgb: var(--app-danger-fill-rgb);
}

.btn-success {
  --tb-btn-color: var(--app-on-brand);
  --tb-btn-bg: var(--app-success-fill);
  --tb-btn-border-color: var(--app-success-fill);
  --tb-btn-hover-color: var(--app-on-brand);
  --tb-btn-hover-bg: var(--app-success-fill-hover);
  --tb-btn-hover-border-color: var(--app-success-fill-hover);
  --tb-btn-active-color: var(--app-on-brand);
  --tb-btn-active-bg: var(--app-success-fill-hover);
  --tb-btn-active-border-color: var(--app-success-fill-hover);
  --tb-btn-disabled-bg: var(--app-success-fill);
  --tb-btn-disabled-border-color: var(--app-success-fill);
  --tb-btn-focus-shadow-rgb: var(--app-success-fill-rgb);
}

/* The feedback text utilities read the INK, not the fill. Bootstrap drives
   .text-success & co. from the same triplet .bg-success fills with, so as
   text they were the fill colour on white: 2.5:1 (success), 2.1:1 (warning),
   3.8:1 (danger), 2.9:1 (info). The ink tokens are 5.5:1, 5.0:1, 6.5:1 and
   9.2:1 on white, and still >= 4.5:1 on their own -subtle badge grounds
   (5.0, 4.55, 5.6, 8.0). Section 7.1 re-points the same tokens for dark mode,
   so this one rule serves both themes. .text-primary needs no entry in light:
   the brand fill is already 4.9:1 on white. */
.text-success {
  color: rgba(var(--app-success-ink-rgb), var(--tb-text-opacity, 1)) !important;
}
.text-warning {
  color: rgba(var(--app-warning-ink-rgb), var(--tb-text-opacity, 1)) !important;
}
.text-danger {
  color: rgba(var(--app-danger-ink-rgb), var(--tb-text-opacity, 1)) !important;
}
.text-info {
  color: rgba(var(--app-info-ink-rgb), var(--tb-text-opacity, 1)) !important;
}

/* -----------------------------------------------------------------------------
   Core component metrics — docs/design-system.md §5
   Shape and size for the two controls the spec measures. Colour still comes
   from the variant rules above, so a new variant needs no entry here.
   -------------------------------------------------------------------------- */
.btn {
  --tb-btn-border-radius: var(--app-radius-md);
  --tb-btn-padding-x: var(--app-space-4);
  --tb-btn-font-size: var(--app-text-body);
  --tb-btn-font-weight: var(--app-weight-medium);
  min-height: var(--app-control-height);
  /* inline-flex, not the theme's inline-block: min-height alone would leave a
     button's label sitting at the top of the taller box. No `gap` here on
     purpose — icons in this app carry their own me-1/me-2 utility margins, and
     a gap would double the spacing on every button that has one. */
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* The sizing modifiers stay proportional rather than inheriting the 40px floor,
   and the icon-only and table-action buttons keep their own compact geometry. */
.btn-sm,
.btn-group-sm > .btn {
  --tb-btn-padding-x: var(--app-space-3);
  --tb-btn-font-size: var(--app-text-caption);
  min-height: 32px;
}

.btn-lg,
.btn-group-lg > .btn {
  --tb-btn-padding-x: var(--app-space-6);
  --tb-btn-font-size: var(--app-text-subtitle);
  min-height: var(--app-control-height-touch);
}

.btn-icon,
.btn-action,
.page-link,
.btn-close {
  min-height: 0;
}

/* Coarse pointers get the spec's 48px touch target */
@media (pointer: coarse) {
  .btn:not(.btn-sm):not(.btn-icon):not(.btn-action) {
    min-height: var(--app-control-height-touch);
  }
}

.form-control,
.form-select {
  --tb-border-radius: var(--app-radius-md);
  min-height: var(--app-control-height);
  font-size: var(--app-text-body);
}

/* The sizing modifiers, and the controls that set their own box, opt out of
   the 40px floor: a textarea grows past it, and .form-control-color is a
   fixed square swatch that the floor would stretch. */
textarea.form-control,
.form-control-sm,
.form-select-sm,
.form-control-color {
  min-height: 0;
}

.form-control-sm,
.form-select-sm {
  font-size: var(--app-text-caption);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--app-brand-ink);
  box-shadow: var(--app-focus-ring);
}

/* Dismiss glyph — the theme swaps in an icon font, so this is a plain colour */
.btn-close {
  color: var(--app-ink);
}
.btn-close-white,
.btn-close-light {
  color: var(--app-on-brand);
}

.link-primary {
  color: var(--app-brand-ink-hover) !important;
}
.link-primary:focus,
.link-primary:hover {
  color: var(--app-brand-ink-active) !important;
}

/* Selection controls */
.card-radio .form-check-input:checked + .form-check-label {
  border-color: var(--app-brand-ink) !important;
}
.card-radio .form-check-input:checked + .form-check-label:before {
  color: var(--app-brand-ink);
}
.table-custom-effect tr.table-active {
  border-right-color: var(--app-brand-ink);
}
/* Kept for markup that still asks for it, as the solid brand fill. */
.badge-gradient-primary {
  background: var(--app-brand);
}
.alert-label-icon.label-arrow .label-icon:after {
  border-right-color: var(--app-brand);
}

/* FullCalendar primary events */
.fc-daygrid-event-harness .fc-daygrid-event.bg-primary-subtle .fc-event-main,
.fc-daygrid-event-harness .fc-daygrid-event.bg-primary-subtle .fc-event-title,
.fc-timegrid-event-harness .fc-timegrid-event.bg-primary-subtle .fc-event-title,
.fc-list-table .fc-list-event.bg-primary-subtle .fc-list-event-title > a {
  color: var(--app-brand-ink-hover) !important;
}
.fc-list-table .fc-list-event.bg-primary-subtle .fc-list-event-dot {
  border-color: var(--app-brand-ink);
}

/* -----------------------------------------------------------------------------
   4. Application chrome
   -------------------------------------------------------------------------- */

/* Breadcrumbs — the theme pins a literal teal on these two rules */
.breadcrumb-item > a {
  color: var(--app-brand-ink-hover);
}
.breadcrumb-item.active {
  color: var(--app-ink-muted);
}

/* Sidebar — the shell the app ships (_Layout sets data-sidebar="light").
   Surface Card ground, Surface Tint on the selected item with Primary text,
   which is the spec's stated use for #E6F4F1. Hover is a neutral step so it
   reads as a pointer response rather than a second kind of selection. */
[data-theme="default"][data-sidebar="light"] {
  --tb-vertical-menu-bg: var(--app-surface);
  --tb-vertical-menu-border: var(--app-line);
  --tb-vertical-menu-item-color: var(--app-ink-muted);
  --tb-vertical-menu-item-hover-color: var(--app-brand-ink-hover);
  --tb-vertical-menu-item-hover-bg: var(--app-sidebar-hover);
  --tb-vertical-menu-item-active-color: var(--app-brand-ink);
  --tb-vertical-menu-item-active-bg: var(--app-sidebar-active);
  --tb-vertical-menu-sub-item-color: var(--app-ink-muted);
  --tb-vertical-menu-sub-item-hover-color: var(--app-brand-ink-hover);
  --tb-vertical-menu-sub-item-active-color: var(--app-brand-ink);
  --tb-vertical-menu-title-color: var(--app-ink-faint);
  --tb-vertical-menu-box-shadow: var(--app-shadow-sm);
  --tb-twocolumn-menu-iconview-bg: var(--app-surface);
}

/* Brand box sits flush with the light sidebar surface */
[data-layout="vertical"][data-sidebar="light"] .navbar-brand-box {
  background-color: var(--tb-vertical-menu-bg);
  border-bottom: 1px solid var(--app-line);
}

/* Collapsed sidebar (data-sidebar-size="sm"): hovering an icon widens the item
   into a flyout that reveals its label. The theme paints that label and its
   caret `#fff` — a literal, written for the dark sidebar it shipped with — so
   on the light sidebar the title was white on a near-white hover fill and
   effectively invisible. Both rules are re-pointed at the brand, matching the
   colour the same item takes when the sidebar is open. */
[data-layout="vertical"][data-sidebar="light"][data-sidebar-size="sm"]
  .navbar-menu
  .navbar-nav
  .nav-item:hover
  > a.menu-link,
[data-layout="vertical"][data-sidebar="light"][data-sidebar-size="sm"]
  .navbar-menu
  .navbar-nav
  .nav-item:hover
  > a.menu-link:after {
  color: var(--app-brand-ink);
}

/* The flyout panel is opaque and sits over page content, so it carries the
   sidebar's own surface and an elevation to lift it off what is behind. */
[data-layout="vertical"][data-sidebar="light"][data-sidebar-size="sm"]
  .navbar-menu
  .navbar-nav
  .nav-item:hover
  > .menu-dropdown {
  border: 1px solid var(--app-line);
  border-radius: var(--app-radius-md);
  box-shadow: var(--app-shadow-lg);
}

/* Dark sidebar — kept on-brand for anyone who switches the shell over */
[data-theme="default"][data-sidebar="dark"] {
  --tb-vertical-menu-bg: var(--app-teal-900);
  --tb-vertical-menu-border: rgba(255, 255, 255, 0.06);
  --tb-vertical-menu-item-color: rgba(255, 255, 255, 0.66);
  --tb-vertical-menu-item-hover-color: #ffffff;
  --tb-vertical-menu-item-hover-bg: var(--app-teal-800);
  --tb-vertical-menu-item-active-color: #ffffff;
  --tb-vertical-menu-item-active-bg: var(--app-teal-700);
  --tb-vertical-menu-sub-item-color: rgba(255, 255, 255, 0.55);
  --tb-vertical-menu-sub-item-hover-color: #ffffff;
  --tb-vertical-menu-sub-item-active-color: var(--app-teal-300);
  --tb-vertical-menu-title-color: rgba(255, 255, 255, 0.42);
  --tb-vertical-menu-box-shadow: var(--app-shadow-md);
  --tb-twocolumn-menu-iconview-bg: var(--app-teal-900);
}

/* Brand box sits flush with the sidebar surface */
[data-layout="vertical"][data-sidebar="dark"] .navbar-brand-box {
  background-color: var(--tb-vertical-menu-bg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* Menu items read as soft pills, as on the landing site's product shell */
.navbar-menu .navbar-nav .nav-link {
  border-radius: var(--app-radius-md);
  transition:
    background-color 0.18s var(--app-ease),
    color 0.18s var(--app-ease);
}
.navbar-menu .navbar-nav .nav-link.active {
  font-weight: 600;
}

/* Topbar — the shell the app ships (_Layout sets data-topbar="light").
   Surface Card ground, hairline separated, ink glyphs. --tb-topbar-user-bg is
   transparent on purpose: the theme paints the user block with it above 768px,
   which otherwise cuts a visibly different panel out of the topbar. */
[data-theme="default"][data-topbar="light"] {
  --tb-header-bg: var(--app-surface);
  --tb-header-item-color: var(--app-ink);
  --tb-header-item-sub-color: var(--app-ink-muted);
  --tb-header-border-color: var(--app-line);
  --tb-topbar-user-bg: transparent;
  --tb-topbar-user-color: var(--app-ink);
  --tb-topnav-bg: var(--app-surface);
  --tb-topnav-item-color: var(--app-ink-muted);
  --tb-topnav-item-color-active: var(--app-brand-ink);
  --tb-topnav-sub-item-color: var(--app-ink-muted);
  --tb-topnav-sub-item-color-active: var(--app-brand-ink);
}

/* Dark topbar — not the shipped shell; kept on-brand for anyone who switches
   data-topbar over. Primary ground with white glyphs. */
[data-theme="default"][data-topbar="dark"] {
  --tb-header-bg: var(--app-brand);
  --tb-header-item-color: #ffffff;
  --tb-header-item-sub-color: rgba(255, 255, 255, 0.82);
  --tb-header-border-color: rgba(255, 255, 255, 0.14);
  --tb-topbar-user-bg: rgba(255, 255, 255, 0.12);
  --tb-topbar-user-color: #ffffff;
  --tb-topnav-bg: var(--app-brand);
  --tb-topnav-item-color: rgba(255, 255, 255, 0.82);
  --tb-topnav-item-color-active: #ffffff;
  --tb-topnav-sub-item-color: rgba(255, 255, 255, 0.82);
  --tb-topnav-sub-item-color-active: #ffffff;
}

/* Three things the theme still paints for its own dark topbar (a near-black),
   which do not carry over to a Primary one. */
[data-topbar="dark"] #page-topbar .btn-ghost-dark {
  color: #ffffff;
}
[data-topbar="dark"] #page-topbar .btn-ghost-dark:active,
[data-topbar="dark"] #page-topbar .btn-ghost-dark:focus,
[data-topbar="dark"] #page-topbar .btn-ghost-dark:hover {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.16);
}

/* The user block's name, role and caret sit directly on the Primary ground */
[data-topbar="dark"] #page-topbar .topbar-user .user-name-text,
[data-topbar="dark"] #page-topbar .topbar-user .user-role-text,
[data-topbar="dark"] #page-topbar .topbar-user .topbar-user-caret {
  color: #ffffff;
}
[data-topbar="dark"] #page-topbar .topbar-user .topbar-user-btn:hover,
[data-topbar="dark"] #page-topbar .topbar-user.show .topbar-user-btn {
  background-color: rgba(255, 255, 255, 0.16);
}

/* The dropdowns hanging off it are Surface Card, so their contents stay ink */
[data-topbar="dark"] #page-topbar .dropdown-menu {
  color: var(--app-ink);
}

/* Footer */
[data-theme="default"] {
  --tb-footer-bg: var(--app-surface);
  /* Muted, not faint: the faint step is 3.3:1 on white, the muted one 5.7:1. */
  --tb-footer-color: var(--app-ink-muted);
}

/* Page shell — cards on an off-white canvas with hairline borders */
.card {
  border: 1px solid var(--app-line);
  border-radius: var(--app-radius-lg);
  box-shadow: var(--app-shadow-soft);
  transition:
    box-shadow 0.25s var(--app-ease),
    transform 0.25s var(--app-ease);
}
.card:hover {
  box-shadow: var(--app-shadow-card);
}

.page-title-box,
.page-content {
  background-color: transparent;
}

/* -----------------------------------------------------------------------------
   Table row actions
   One shape for every action in every table: same height, radius, padding and
   icon size, with an Arabic label alongside the glyph. Semantics come from a
   single --action-rgb per modifier, so a variant is one line, not a rule set.
   -------------------------------------------------------------------------- */
.btn-action {
  --action-rgb: var(--app-ink-rgb);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  height: 30px;
  padding: 0 0.7rem;
  border: 1px solid transparent;
  border-radius: var(--app-radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  /* The label reads the variant's INK where it names one: the fill hue on its
     own 12% tint is under 3:1 for success, danger and the Accent. */
  color: var(--action-ink, rgb(var(--action-rgb)));
  background-color: rgba(var(--action-rgb), 0.12);
  /* Several of these are <a> without href, so they inherit no affordance from
     the browser; the label would otherwise show a text caret. */
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  text-decoration: none;
  transition:
    background-color 0.16s var(--app-ease),
    color 0.16s var(--app-ease);
}

.btn-action i {
  font-size: 1rem;
  line-height: 1;
}

.btn-action:hover:not(:disabled),
.btn-action:focus-visible:not(:disabled) {
  color: var(--app-on-brand);
  background-color: rgb(var(--action-rgb));
}

.btn-action:disabled,
.btn-action.disabled {
  color: var(--app-ink-faint);
  background-color: var(--app-surface-sunken);
  opacity: 1;
  cursor: not-allowed;
  pointer-events: auto;
}

/* Semantic variants — the glyph and label inherit these automatically.
   --action-rgb is the tint and the hover fill; --action-ink the resting label.
   Resting labels on the 12% tint: edit 6.1:1, delete 5.3:1, add 4.6:1,
   view 5.7:1. Hover labels: white on the danger/success fills (6.5/5.5:1),
   the Accent's own dark label on orange (5.9:1). */
.btn-action--edit {
  --action-rgb: var(--app-accent-rgb);
  --action-ink: var(--app-accent-ink);
}
.btn-action--edit:hover:not(:disabled),
.btn-action--edit:focus-visible:not(:disabled) {
  color: var(--app-on-accent);
}
.btn-action--delete,
.btn-action--remove {
  --action-rgb: var(--app-danger-fill-rgb);
  --action-ink: var(--app-danger-ink);
}
.btn-action--view {
  --action-rgb: var(--app-brand-ink-rgb);
}
.btn-action--add {
  --action-rgb: var(--app-success-fill-rgb);
  --action-ink: var(--app-success-ink);
}
.btn-action--print {
  --action-rgb: var(--app-ink-rgb);
}

/* Action cells keep their buttons on one centred row */
.table td .table-actions {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

/* -----------------------------------------------------------------------------
   Pagination
   Lives here rather than in a per-page stylesheet so every table paginates
   identically — several views never linked the old assets/css/General file.
   -------------------------------------------------------------------------- */
.pagination {
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0;
}

.pagination .page-item {
  margin: 0;
}

.pagination .page-link {
  --tb-pagination-padding-x: 0;
  --tb-pagination-padding-y: 0;
  min-width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.4rem;
  border: 0;
  border-radius: var(--app-radius-sm);
  background-color: var(--app-surface-sunken);
  color: var(--app-ink);
  font-size: 0.8125rem;
  font-weight: 500;
  transition:
    background-color 0.16s var(--app-ease),
    color 0.16s var(--app-ease);
}

.pagination .page-link .page-icon {
  color: var(--app-brand-ink-hover);
}

.pagination .page-link:hover {
  background-color: var(--app-brand-hover);
  color: var(--app-on-brand);
}

.pagination .page-link:hover .page-icon {
  color: var(--app-on-brand);
}

.pagination .page-item.active .page-link {
  background-color: var(--app-brand);
  color: var(--app-on-brand);
  font-weight: 700;
}

.pagination .page-item.active .page-link .page-icon {
  color: var(--app-on-brand);
}

.pagination .page-item.disabled .page-link {
  background-color: var(--app-surface-sunken);
  color: var(--app-ink-faint);
  opacity: 0.55;
}

.pagination .page-item.disabled .page-link .page-icon {
  color: var(--app-ink-faint);
}

.pagination .ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  color: var(--app-ink-faint);
  font-weight: 500;
  pointer-events: none;
}

.pagination .ellipsis span {
  background: none;
  border: 0;
  padding: 0;
}

/* -----------------------------------------------------------------------------
   Page shell additions — skip link, loading veil, header clock, placeholders,
   offline notice. They belong to the shell, not to a component, so they live here.
   -------------------------------------------------------------------------- */

/* «تخطَّ إلى المحتوى» — the first focusable element on every page. Off-screen
   (not display:none, which would take it out of the tab order) until focused,
   then pinned to the reading-start corner above everything, the veil included. */
.app-skip-link {
  position: fixed;
  inset-block-start: var(--app-space-2);
  inset-inline-start: var(--app-space-2);
  z-index: var(--app-z-skip-link);
  padding: var(--app-space-2) var(--app-space-4);
  border-radius: var(--app-radius-md);
  background-color: var(--app-brand-active);
  color: var(--app-on-brand);
  font-weight: var(--app-weight-semibold);
  text-decoration: none;
  box-shadow: var(--app-shadow-lg);
  transform: translateY(-200%);
}
.app-skip-link:focus,
.app-skip-link:focus-visible {
  transform: none;
  color: var(--app-on-brand);
  outline: 2px solid var(--app-brand-ink);
  outline-offset: 2px;
}

/* The skip target takes programmatic focus (tabindex="-1"); outlining the
   entire content region would only be noise. */
#main-content:focus {
  outline: none;
}

/* The full-page loading veil (_Layout). layout.js hides it on DOMContentLoaded. */
.app-loading-screen {
  position: fixed;
  inset: 0;
  z-index: var(--app-z-loading);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--app-space-4);
  background: var(--app-scrim);
}
.app-loading-screen__spinner {
  width: 3rem;
  height: 3rem;
}
.app-loading-screen__text {
  color: var(--app-ink-muted);
  font-size: var(--app-text-body);
}

/* The header clock in _page_title */
.app-page-clock {
  color: var(--app-brand-ink-hover);
}

/* Placeholders read the muted ink (5.7:1 on white), never the faint step. */
.form-control::placeholder,
.form-select::placeholder,
textarea::placeholder {
  color: var(--app-ink-muted);
  opacity: 1;
}

/* Offline notice (app-base.js). Persistent until the connection returns, at
   the bottom so it covers no control the user was reaching for. */
.app-offline-banner {
  position: fixed;
  inset-inline: var(--app-space-4);
  inset-block-end: var(--app-space-4);
  z-index: var(--app-z-offline);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--app-space-2);
  max-width: 40rem;
  margin-inline: auto;
  padding: var(--app-space-3) var(--app-space-4);
  border: 1px solid var(--tb-warning-border-subtle);
  border-radius: var(--app-radius-md);
  background-color: var(--tb-warning-bg-subtle);
  color: var(--tb-warning-text-emphasis);
  font-size: var(--app-text-body);
  font-weight: var(--app-weight-medium);
  box-shadow: var(--app-shadow-lg);
}
.app-offline-banner i {
  font-size: 1.1rem;
}

/* "Please wait" (app-base.js). Shown only once a save has taken 300ms, at the
   top centre where the eye already is after pressing a modal's button, and
   above an open modal. A notice, not a veil: nothing behind it is blocked, and
   the button that started the wait is the one disabled. */
.app-busy {
  position: fixed;
  inset-block-start: var(--app-space-4);
  inset-inline: var(--app-space-4);
  z-index: var(--app-z-busy);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--app-space-2);
  width: fit-content;
  max-width: calc(100% - 2 * var(--app-space-4));
  margin-inline: auto;
  padding: var(--app-space-2) var(--app-space-4);
  border: 1px solid var(--app-brand-border);
  border-radius: var(--app-radius-full);
  background-color: var(--app-surface);
  color: var(--app-ink);
  font-size: var(--app-text-body);
  font-weight: var(--app-weight-medium);
  box-shadow: var(--app-shadow-lg);
  pointer-events: none;
}
.app-busy[hidden] {
  display: none;
}

/* The spinner, shared by the notice and a busy button. Under reduced motion it
   stops (the global rule below) and still reads as a ring beside the words. */
.app-busy__spinner,
.is-busy::before {
  content: "";
  display: inline-block;
  flex: none;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-inline-end-color: transparent;
  border-radius: var(--app-radius-full);
  animation: app-busy-spin 0.7s linear infinite;
}
.app-busy__spinner {
  color: var(--app-brand-ink);
}

/* A busy button keeps its colour and its label; the spinner takes its icon's
   place, so an icon-only row action still shows something turning. */
.is-busy {
  cursor: progress !important;
}
.is-busy::before {
  vertical-align: -0.125em;
  margin-inline-end: 0.35em;
}
.is-busy > i.bi,
.is-busy > i.ph {
  display: none;
}
.btn.is-busy:disabled {
  opacity: 0.85;
}

@keyframes app-busy-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Dialogs — Bootstrap modals and SweetAlert2 share the identity's surface */
.modal-content {
  border-radius: var(--app-radius-lg);
  box-shadow: var(--app-shadow-card);
}

/* SweetAlert2 ships its own look; bring it onto the same surface as the app.
   Button colours are set per-dialog from App.color (assets/js/brand.js) — the
   rules here only govern shape, type and focus.

   v11 exposes its surface as custom properties, so re-pointing them at section 1
   is enough and covers dark mode with no second block: the light values below
   resolve to what the library already shipped. Its own [data-swal2-theme] and
   prefers-color-scheme hooks are left unset on purpose — the dialog follows the
   app's theme, not the operating system's. */
:root {
  --swal2-background: var(--app-surface);
  --swal2-color: var(--app-ink);
  --swal2-footer-border-color: var(--app-line);
  --swal2-input-background: var(--app-surface);
  --swal2-validation-message-background: var(--app-surface-sunken);
  --swal2-validation-message-color: var(--app-ink-muted);
  --swal2-close-button-color: var(--app-ink-faint);
}

.swal2-popup {
  border-radius: var(--app-radius-2xl);
  box-shadow: var(--app-shadow-card);
  font-family: var(--app-font-body);
  color: var(--app-ink);
}

.swal2-title {
  font-family: var(--app-font-display);
  font-weight: 700;
  color: var(--app-ink-strong);
}

.swal2-html-container {
  color: var(--app-ink-muted);
}

.swal2-actions .swal2-styled {
  border-radius: var(--app-radius-md);
  padding: 0.55rem 1.5rem;
  font-family: var(--app-font-body);
  font-weight: 600;
  box-shadow: none;
  transition: transform 0.16s var(--app-ease);
}

.swal2-actions .swal2-styled:hover {
  transform: translateY(-1px);
}

.swal2-actions .swal2-styled:focus {
  box-shadow: 0 0 0 3px rgba(var(--app-brand-rgb), 0.25);
}

/* Status icons — SweetAlert's stock amber/green/red are close to, but not, ours */
.swal2-icon.swal2-warning {
  border-color: var(--app-accent);
  color: var(--app-accent);
}
.swal2-icon.swal2-error {
  border-color: var(--app-danger);
  color: var(--app-danger);
}
.swal2-icon.swal2-error [class^="swal2-x-mark-line"] {
  background-color: var(--app-danger);
}
.swal2-icon.swal2-success {
  border-color: var(--app-success);
  color: var(--app-success);
}
.swal2-icon.swal2-success [class^="swal2-success-line"] {
  background-color: var(--app-success);
}
.swal2-icon.swal2-success .swal2-success-ring {
  border-color: rgba(var(--app-success-rgb), 0.3);
}
.swal2-icon.swal2-info,
.swal2-icon.swal2-question {
  border-color: var(--app-brand-ink);
  color: var(--app-brand-ink);
}

.swal2-input,
.swal2-textarea,
.swal2-select {
  border-radius: var(--app-radius-md);
  border: 1px solid var(--app-line-strong);
  font-family: var(--app-font-body);
}

.swal2-input:focus,
.swal2-textarea:focus,
.swal2-select:focus {
  border-color: var(--app-brand-ink);
  box-shadow: var(--app-focus-ring);
}

/* -----------------------------------------------------------------------------
   5. Typography — docs/design-system.md §2
   The spec names six steps. h1 and h2 map to Heading 1 and Heading 2; h3–h6
   and .card-title fall to Subtitle, which is what a card heading is. h3 sits
   one step above Subtitle so a nested section still reads as subordinate to
   its H2 — the spec is silent there and this keeps the ramp monotonic.
   -------------------------------------------------------------------------- */
body {
  font-family: var(--app-font-body);
  font-size: var(--app-text-body);
  font-weight: var(--app-weight-regular);
  line-height: var(--app-text-body-lh);
}

h1,
h2,
h3,
h4,
h5,
h6,
.h1,
.h2,
.h3,
.h4,
.h5,
.h6,
.page-title,
.card-title {
  font-family: var(--app-font-display);
  letter-spacing: -0.01em;
  color: var(--app-ink-strong);
}

/* Heading 1 — screen titles */
h1,
.h1,
.page-title {
  font-size: var(--app-text-h1);
  font-weight: var(--app-weight-semibold);
  line-height: var(--app-text-h1-lh);
}

/* Heading 2 — section headers */
h2,
.h2 {
  font-size: var(--app-text-h2);
  font-weight: var(--app-weight-medium);
  line-height: var(--app-text-h2-lh);
}

h3,
.h3 {
  font-size: 18px;
  font-weight: var(--app-weight-medium);
  line-height: var(--app-text-subtitle-lh);
}

/* Subtitle / card title */
h4,
h5,
h6,
.h4,
.h5,
.h6,
.card-title {
  font-size: var(--app-text-subtitle);
  font-weight: var(--app-weight-medium);
  line-height: var(--app-text-subtitle-lh);
}

/* Caption / helper text */
small,
.small,
.form-text,
.caption {
  font-size: var(--app-text-caption);
  line-height: var(--app-text-caption-lh);
}

/* Display / hero */
.display-1,
.display-2,
.display-3,
.display-4,
.display-5,
.display-6 {
  font-family: var(--app-font-display);
  font-size: var(--app-text-display);
  font-weight: var(--app-weight-semibold);
  line-height: var(--app-text-display-lh);
}

::selection {
  background: var(--app-teal-200);
  color: var(--app-gray-900);
}

:focus-visible {
  outline: 2px solid var(--app-brand-ink);
  outline-offset: 2px;
}

/* -----------------------------------------------------------------------------
   6. Brand lockup — the school's own artwork (docs/identity/)
   logo.png is the horizontal lockup — the dome mark with the Arabic and
   English school name beside it — and logo-sm.png the dome mark on its own.
   The wordmark is part of the artwork and is never typed out in markup.
   Only sizing and the dark-ground treatment live here.
   -------------------------------------------------------------------------- */
.app-logo {
  align-items: center;
  gap: 0.55rem;
  line-height: 1;
  text-decoration: none;
}

.app-logo__mark,
.app-logo__lockup {
  width: auto;
  height: 60px;
  flex-shrink: 0;
}

/* The school's horizontal lockup is 4.6:1 — two lines of name beside the dome —
   so at the mark's 60px it would overrun the 250px sidebar. 46px keeps it
   inside the brand box with the Arabic line still legible. */
.app-logo__lockup {
  height: 46px;
}

/* Dark surfaces (the dark sidebar): the artwork keeps its palette, lifted just
   enough for the teal to read against the ink. The auth and error pages are a
   white card on a light wash, and brand/app-auth.css does the lift for the dark
   theme itself. */
.logo-light .app-logo__mark,
.logo-light .app-logo__lockup,
.app-logo--on-dark .app-logo__mark,
.app-logo--on-dark .app-logo__lockup {
  filter: brightness(1.35);
}

/* The "powered by" row sits at caption scale */
.auth-poweredby .app-logo__mark,
.auth-poweredby .app-logo__lockup {
  height: 1.375rem;
}

/* Hero lockup for the auth and error pages */
.app-logo--lg .app-logo__mark,
.app-logo--lg .app-logo__lockup {
  height: 3.5rem;
}

/* -----------------------------------------------------------------------------
   6b. User preferences — motion, contrast, forced colours
   Before section 7 on purpose: the dark block has to stay last.
   -------------------------------------------------------------------------- */

/* Reduced motion. Every transition and keyframe in the app — the card and
   button lifts, fadeInUp, dropdownFadeIn, the skeleton pulse, the modal scale,
   the spinners — collapses to an instant step. Durations are shortened rather
   than animations removed, so an animation's end state (and any animationend
   listener) still arrives. */
@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;
  }
}

/* More contrast, when the operating system asks for it: hairlines become real
   rules, secondary text drops to the body ink, and the focus ring thickens. */
@media (prefers-contrast: more) {
  :root {
    --app-line: var(--app-gray-400);
    --app-line-strong: var(--app-gray-600);
    --app-ink-muted: var(--app-ink);
    --app-ink-faint: var(--app-ink-muted);
  }
  /* html:root outranks section 7.1's :root[...] — the dark block has to stay
     last, so this one wins on specificity instead of order. */
  html:root[data-bs-theme="dark"] {
    --app-line: var(--app-slate-400);
    --app-line-strong: var(--app-slate-300);
    --app-ink-muted: var(--app-slate-100);
    --app-ink-faint: var(--app-slate-300);
  }
  :focus-visible {
    outline-width: 3px;
    outline-offset: 3px;
  }
}

/* Windows High Contrast / forced colours: box-shadow focus rings are dropped
   by the browser, so every focusable thing gets a real outline in the system
   highlight colour. */
@media (forced-colors: active) {
  :focus-visible,
  .form-control:focus,
  .form-select:focus,
  .btn:focus-visible {
    outline: 2px solid Highlight !important;
    outline-offset: 2px;
  }
  .app-skip-link:focus {
    outline: 2px solid Highlight;
  }
}

/* -----------------------------------------------------------------------------
   7. Dark mode — docs/design-system.md §6

   Dark mode is not a second design system. Typography, spacing, radii and every
   component's geometry are untouched; only colour is restated, and almost all of
   it through section 1's semantic aliases. Because the whole file reads through
   those aliases, re-pointing them on <html data-bs-theme="dark"> flips the entire
   app — cards, modals, dropdowns, offcanvases, popovers, toasts, the sidebar, the
   topbar and the footer all resolve to --app-surface and follow automatically.

   Order and specificity both matter. Section 2 binds --tb-* under
   `:root, [data-bs-theme="light"]`, and `:root` matches a dark document too, so
   the token blocks below only win by sitting later in the file — keep this
   section last. They are also written as `:root[data-bs-theme="dark"]` rather
   than the bare attribute, because app-rtl.css sets --tb-secondary*, --tb-light*,
   --tb-dark* and --tb-body-bg for its own dark mode at (0,2,0) — once through
   `[data-theme="default"][data-bs-theme="dark"]` and once through
   `[data-bs-theme="dark"]:is([data-theme="default"], ...)`. A bare
   `[data-bs-theme="dark"]` is (0,1,0) and loses to those no matter where it
   sits; `:root[...]` ties and wins on order, without requiring data-theme to be
   present the way an attribute pair would.

   What is NOT covered by the alias flip, and so is restated here:
     7.1  the aliases themselves
     7.2  --tb-* families holding light-locked literals (the -subtle/-emphasis
          triples, and the light/dark utility pair, which swap sides)
     7.3  rules that pin a colour for a light ground — white labels on fills that
          become bright, and the theme's own dark-mode literals
   -------------------------------------------------------------------------- */

/* --- 7.1 Semantic aliases -------------------------------------------------- */
:root[data-bs-theme="dark"] {
  /* Tells the browser to render form controls, scrollbars and the caret dark */
  color-scheme: dark;

  /* Surfaces. Elevation runs the other way here: a raised surface is a LIGHTER
     step, not a heavier shadow, because a shadow on a dark ground reads as
     nothing. The card is lighter than the canvas, the sunken fill lighter still. */
  --app-canvas: var(--app-slate-950);
  --app-scrim: rgba(13, 17, 23, 0.92);
  --app-surface: var(--app-slate-900);
  --app-surface-sunken: var(--app-slate-850);
  --app-line: var(--app-slate-800);
  --app-line-strong: var(--app-slate-700);

  /* Text */
  --app-ink: var(--app-slate-100);
  --app-ink-rgb: var(--app-slate-100-rgb);
  --app-ink-strong: var(--app-slate-50);
  --app-ink-muted: var(--app-slate-300);
  --app-ink-faint: var(--app-slate-400);

  /* Brand as ink — see the token's definition in section 1. The FILL half
     (--app-brand and friends) is deliberately absent: it does not change, so
     every white-on-teal button, badge and header carries over untouched. */
  --app-brand-ink: var(--app-teal-300);
  --app-brand-ink-rgb: 115, 193, 205;
  --app-brand-ink-hover: var(--app-teal-200);
  --app-brand-ink-active: var(--app-teal-100);

  /* Feedback as ink. The fills stay put for the same reason the brand's does.
     The -rgb triplets drive the .text-* utilities (section 3). */
  --app-success-ink: #34d399;
  --app-warning-ink: #fbbf24;
  --app-danger-ink: #f87171;
  --app-info-ink: var(--app-brand-ink);
  --app-accent-ink: var(--app-accent);
  --app-success-ink-rgb: 52, 211, 153;
  --app-warning-ink-rgb: 251, 191, 36;
  --app-danger-ink-rgb: 248, 113, 113;
  --app-info-ink-rgb: var(--app-brand-ink-rgb);
  --app-accent-ink-rgb: var(--app-accent-rgb);

  /* A modal's backdrop has to be darker than a canvas that is already dark. */
  --app-modal-scrim: rgba(0, 0, 0, 0.65);

  /* Tints. The spec's #E6F4F1 Surface Tint inverts to a deep teal wash. */
  --app-brand-soft: var(--app-teal-tint-dark);
  --app-brand-border: var(--app-teal-tint-dark-border);
  --app-sidebar-hover: var(--app-slate-850);
  --app-sidebar-active: var(--app-teal-tint-dark);

  /* Elevation — same geometry, near-opaque black, per §6 */
  --app-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --app-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.55);
  --app-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
  --app-shadow-glow: 0 10px 15px -3px rgba(var(--app-brand-ink-rgb), 0.25);

  /* The focus ring is drawn in the ink teal at a higher alpha: the fill teal at
     15% over a near-black ground is not visible, and this ring is the only
     keyboard affordance in the app. */
  --app-focus-ring: 0 0 0 3px rgba(var(--app-brand-ink-rgb), 0.32);
}

/* --- 7.2 --tb-* families that hold light-locked values --------------------- */
:root[data-bs-theme="dark"] {
  /* The -text-emphasis / -bg-subtle / -border-subtle triples drive every badge,
     alert and soft chip in the app. Each becomes ink-on-wash instead of
     deep-on-tint; the subtle grounds are opaque rather than the theme's
     rgba(...,0.15), which would leak whatever sits behind a nested chip. */
  --tb-primary-text-emphasis: var(--app-brand-ink);
  --tb-primary-bg-subtle: var(--app-teal-tint-dark);
  --tb-primary-border-subtle: var(--app-teal-tint-dark-border);

  --tb-secondary: var(--app-ink);
  --tb-secondary-rgb: var(--app-ink-rgb);
  --tb-secondary-text-emphasis: var(--app-ink-muted);
  --tb-secondary-bg-subtle: var(--app-slate-850);
  --tb-secondary-border-subtle: var(--app-slate-700);
  --tb-secondary-bg-rgb: 21, 27, 35;

  --tb-success-text-emphasis: var(--app-success-ink);
  --tb-success-bg-subtle: #0d2b22;
  --tb-success-border-subtle: #17604a;

  --tb-warning-text-emphasis: var(--app-warning-ink);
  --tb-warning-bg-subtle: #33260a;
  --tb-warning-border-subtle: #7a5c19;

  --tb-danger-text-emphasis: var(--app-danger-ink);
  --tb-danger-bg-subtle: #331a1a;
  --tb-danger-border-subtle: #7a3434;

  --tb-info-text-emphasis: var(--app-brand-ink);
  --tb-info-bg-subtle: var(--app-teal-tint-dark);
  --tb-info-border-subtle: var(--app-teal-tint-dark-border);

  /* .text-dark / .bg-dark and .text-light / .bg-light swap sides. "Dark" names
     the high-contrast end of the neutral ramp, and on a dark ground that end is
     light — 43 views say .text-dark meaning "the strongest text I have". */
  --tb-dark: var(--app-ink);
  --tb-dark-rgb: var(--app-ink-rgb);
  --tb-dark-text-emphasis: var(--app-ink-muted);
  --tb-dark-bg-subtle: var(--app-slate-850);
  --tb-dark-border-subtle: var(--app-slate-700);

  --tb-light: var(--app-surface-sunken);
  --tb-light-rgb: 28, 35, 44;
  --tb-light-text-emphasis: var(--app-ink-muted);
  --tb-light-bg-subtle: var(--app-surface-sunken);
  --tb-light-border-subtle: var(--app-line);

  /* The literal triplets section 2 could not express through an alias */
  --tb-body-bg-rgb: 13, 17, 23;
  --tb-emphasis-color-rgb: var(--app-slate-100-rgb);
  --tb-secondary-color-rgb: 154, 166, 181;
  --tb-link-hover-color-rgb: 163, 203, 209;

  --tb-highlight-bg: #4a2c12;
  --tb-focus-ring-color: rgba(var(--app-brand-ink-rgb), 0.35);

  /* The theme's own .text-deep-teal / .text-strong-teal / .bg-deep-teal-subtle
     trio, which section 2 re-points at the identity. These are the record-count
     pill in _page_title (so: every list screen in the app) and any
     module's status chips. "Deep teal" is a misnomer inherited from the theme — the
     role is high-contrast ink on a teal wash, so on dark the ink goes light
     rather than teal, and only the wash carries the hue. Left as they were,
     the pill was near-black text on a dark teal tint. */
  --tb-deep-teal-rgb: var(--app-slate-100-rgb);
  --tb-deep-teal-bg-subtle: rgba(var(--app-brand-ink-rgb), 0.16);
  --tb-strong-teal-rgb: var(--app-brand-ink-rgb);

  /* Bootstrap's own dark block pins a literal on the dropdown surface, which
     would otherwise be the one popover in the app off the surface token. */
  --tb-dropdown-bg: var(--app-surface);
  --tb-dropdown-border-color: var(--app-line);
  --tb-dropdown-link-color: var(--app-ink);
  --tb-dropdown-link-hover-bg: var(--app-surface-sunken);
  --tb-dropdown-link-hover-color: var(--app-ink-strong);
}

/* --- 7.3 Rules written for a light ground ---------------------------------- */

/* Inputs sit BELOW the card they are on rather than flush with it. In light mode
   an input is white on an off-white card and its border does the separating; on
   dark, recessing it is what makes a field legible as a field. */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select,
[data-bs-theme="dark"] .input-group-text {
  background-color: var(--app-canvas);
}

/* Zebra striping and row states are lifts, not shadows. The row hover in
   General/Modifications.css is a 3% brand wash, which reads on white and
   disappears on near-black, so it is deepened rather than re-tinted. */
[data-bs-theme="dark"] .table > tbody > tr:hover {
  background-color: rgba(var(--app-brand-ink-rgb), 0.09) !important;
}

[data-bs-theme="dark"] .table {
  --tb-table-striped-bg: rgba(var(--app-slate-100-rgb), 0.04);
  --tb-table-active-bg: rgba(var(--app-slate-100-rgb), 0.07);
  --tb-table-hover-bg: rgba(var(--app-slate-100-rgb), 0.05);
}

/* The Accent Button needs no entry here: its label is --app-on-accent, which
   section 7.1 does not re-point, so it stays dark on an orange that stays put. */

/* .btn-dark and .btn-outline-secondary fill with the ink colour, which is now
   near-white; their labels have to come back down the ramp to stay readable. */
[data-bs-theme="dark"] .btn-dark,
[data-bs-theme="dark"] .btn-outline-secondary:hover,
[data-bs-theme="dark"] .btn-outline-secondary:active {
  --tb-btn-color: var(--app-slate-950);
  --tb-btn-hover-color: var(--app-slate-950);
  --tb-btn-active-color: var(--app-slate-950);
  --tb-btn-disabled-color: var(--app-slate-950);
}

/* Table row actions. Each variant tints and labels itself from one --action-rgb;
   on dark that triplet has to be the ink value so the resting label reads, which
   in turn makes the solid hover fill bright — so the hover label inverts too. */
[data-bs-theme="dark"] .btn-action,
[data-bs-theme="dark"] .btn-action--print {
  --action-rgb: var(--app-slate-100-rgb);
}
/* Edit keeps the Accent: #F4832C is already 6.7:1 on the dark card. It still
   needs an entry, because the base rule above out-specifies the light one. */
[data-bs-theme="dark"] .btn-action--edit {
  --action-rgb: var(--app-accent-rgb);
}
[data-bs-theme="dark"] .btn-action--view {
  --action-rgb: var(--app-brand-ink-rgb);
}
[data-bs-theme="dark"] .btn-action--add {
  --action-rgb: 52, 211, 153;
}
[data-bs-theme="dark"] .btn-action--delete,
[data-bs-theme="dark"] .btn-action--remove {
  --action-rgb: 248, 113, 113;
}
[data-bs-theme="dark"] .btn-action:hover:not(:disabled),
[data-bs-theme="dark"] .btn-action:focus-visible:not(:disabled) {
  color: var(--app-slate-950);
}

/* .text-primary (88 uses in the views) reads --tb-primary-rgb, the same triplet
   .bg-primary fills with, so the two cannot be told apart through the token
   layer. The fill has to stay where it is — white-on-teal buttons, badges and
   modal headers all depend on it — which leaves the text utility to be
   re-pointed at the ink here. #1A7C8C on the dark card is 3.6:1, under AA.

   The other four .text-* utilities need no entry: section 3 binds them to the
   ink tokens in both themes, and 7.1 re-points those (on the dark card:
   success 9.0:1, warning 10.4:1, danger 6.3:1, info 8.4:1). */
[data-bs-theme="dark"] .text-primary {
  color: rgba(var(--app-brand-ink-rgb), var(--tb-text-opacity, 1)) !important;
}

/* Subtle and outline feedback buttons label themselves with --tb-*, which is
   now the deep FILL (section 2) — right for white-on-fill, far too dark as text
   on a dark ground. Their text and outline read the ink instead. */
[data-bs-theme="dark"] .btn-subtle-danger,
[data-bs-theme="dark"] .btn-outline-danger {
  --tb-btn-color: var(--app-danger-ink);
}
[data-bs-theme="dark"] .btn-outline-danger {
  --tb-btn-border-color: var(--app-danger-ink);
}
[data-bs-theme="dark"] .btn-subtle-success,
[data-bs-theme="dark"] .btn-outline-success {
  --tb-btn-color: var(--app-success-ink);
}
[data-bs-theme="dark"] .btn-outline-success {
  --tb-btn-border-color: var(--app-success-ink);
}
[data-bs-theme="dark"] .btn-subtle-info,
[data-bs-theme="dark"] .btn-outline-info {
  --tb-btn-color: var(--app-info-ink);
}
[data-bs-theme="dark"] .btn-outline-info {
  --tb-btn-border-color: var(--app-info-ink);
}

/* The theme paints the close glyph by inverting it for its own dark mode; ours
   is already light, so the invert would push it back to black. */
[data-bs-theme="dark"] .btn-close {
  -webkit-filter: none;
  filter: none;
  color: var(--app-ink);
}

/* The brand artwork is teal, orange and a pale grey dome on transparency, with
   no dark ink in it, so it needs no alternate file — only the tone lift
   section 6 already defines for dark surfaces, at the gentler step a Surface
   Card ground calls for. */
[data-bs-theme="dark"] .logo .app-logo__mark,
[data-bs-theme="dark"] .logo .app-logo__lockup {
  filter: brightness(1.25);
}

/* Text selection */
[data-bs-theme="dark"] ::selection {
  background: var(--app-teal-700);
  color: var(--app-slate-50);
}
