/* ===========================================================================
   Aegis ID brand layer — loaded last, so it is the final word on colour.
   ===========================================================================

   Why a layer and not a rewrite. Aegis SA grew four token families, and every
   rule in the app reads one of them:

     --vg-*   public/css/aegis-design.css (502 lines, the design system)
     --cs-*   defined inline in views/layouts/main.hbs and home.hbs
     --gc-*   aliases of --cs-*, also inline in main.hbs
     --bs-*   Bootstrap 5

   Redefining all four from a single palette turns the whole application over
   to the Aegis ID design without touching the 82 templates that use them, and
   gives it a dark theme at the same time. Deleting the <link> to this file
   reverts the entire facelift, which is why it is one file and not a rewrite.

   The palette is Aegis ID's, ported verbatim from its brand-layer.css: #0F75BC
   from the Aegis mark, zinc neutrals, Saira display / Inter body / JetBrains
   Mono data. The contrast ratios in the comments are theirs and were measured;
   keep them attached to the values so the next person inherits the reasoning.

   Three theme states, because that is what a viewer actually has:
     - no data-theme attribute -> follow the operating system
     - data-theme="light"      -> light, whatever the OS says
     - data-theme="dark"       -> dark, whatever the OS says
   Every token is first defined on bare :root. The two dark blocks only
   redefine. A token declared only inside a media query is the classic
   unreadable-page bug, so nothing is declared that way.
   ========================================================================= */

:root {
  /* --- brand ------------------------------------------------------------ */
  --ag-brand:        #0F75BC;   /* the logo blue, exactly — fills and borders */
  --ag-brand-ink:    #0B5A91;
  /* Brand as TEXT is a shade darker than the logo: #0F75BC is 4.89:1 on pure
     white but only 4.45:1 on --ag-bg, and most brand-coloured text sits on the
     canvas rather than on a card. This passes on both. */
  --ag-brand-text:   #0E6EB0;
  --ag-brand-on:     #ffffff;   /* 4.9:1 on the brand fill */
  --ag-brand-hover:    #0B5A91;
  --ag-brand-hover-on: #ffffff; /* 8.0:1 */
  --ag-brand-soft:   #e8f3fb;
  --ag-brand-line:   #b9d9ef;

  /* --- the icon plate --------------------------------------------------- */
  --ag-plate:        #eef1f6;
  --ag-plate-ink:    #16222f;   /* 15.4:1 on --ag-plate */
  --ag-plate-line:   #d6dce6;

  /* --- surfaces --------------------------------------------------------- */
  --ag-bg:           #f4f4f5;
  --ag-surface:      #ffffff;
  --ag-surface-2:    #f4f4f5;
  --ag-surface-3:    #ebebed;
  --ag-line:         #e4e4e7;
  --ag-line-strong:  #d4d4d8;

  /* --- ink -------------------------------------------------------------- */
  --ag-text:         #09090b;
  --ag-muted:        #5f5f6a;   /* 6.3:1 on --ag-surface */
  --ag-subtle:       #65656e;   /* 5.1:1 on --ag-surface-2 */

  /* --- state ------------------------------------------------------------ */
  --ag-good:         #047857;  --ag-good-soft: #ecfdf5;  --ag-good-line: #a7f3d0;
  --ag-warn:         #92400e;  --ag-warn-soft: #fffbeb;  --ag-warn-line: #fde68a;
  --ag-bad:          #b91c1c;  --ag-bad-soft:  #fef2f2;  --ag-bad-line:  #fecaca;
  /* Text on a status FILL. The status colours invert between themes — dark
     inks on the light page, light inks on the dark one — so used as a fill
     they need the opposite label colour. A hard-coded white fails in dark. */
  --ag-good-on:      #ffffff;   /* 5.6:1 */
  --ag-warn-on:      #ffffff;   /* 7.1:1 */
  --ag-bad-on:       #ffffff;   /* 6.5:1 */
  --ag-teal:         #0e7490;
  --ag-teal-on:      #ffffff;   /* 5.1:1 */
  --ag-info:         #0F75BC;  --ag-info-soft: #e8f3fb;  --ag-info-line: #b9d9ef;
  --ag-info-on:      #ffffff;  /* label on an info fill */
  /* The AI surfaces -- the assistant, the AI panel, the model picker -- carry a
     cyan so they read as one feature rather than several, and so that the AI
     surfaces are not mistaken for the brand blue, a state colour, or the
     collaboration launcher. The tints invert with everything else. */
  --ag-ai:           #0e7490;  --ag-ai-soft:   #ecfeff;  --ag-ai-line:   #a5f3fc;
  --ag-ai-on:        #ffffff;  /* 4.9:1 */

  /* --- dark chrome (the app's navy bar keeps its own scale) ------------- */
  --ag-nav:          #0b1a26;
  --ag-nav-2:        #12283a;
  --ag-nav-line:     #1d3b52;
  --ag-nav-text:     #e6eef6;
  --ag-nav-muted:    #9db4c7;

  /* --- type ------------------------------------------------------------- */
  --ag-display: Saira, "Segoe UI", system-ui, -apple-system, sans-serif;
  --ag-sans:    Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ag-mono:    "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;

  /* --- shape ------------------------------------------------------------ */
  --ag-r:       8px;
  --ag-r-sm:    6px;
  --ag-r-lg:    12px;
  --ag-r-pill:  999px;
  --ag-sh:      0 1px 2px rgba(9, 9, 11, .05), 0 1px 3px rgba(9, 9, 11, .04);
  --ag-sh-lg:   0 12px 32px rgba(9, 9, 11, .10);
  /* The raised panel. A card is an object sitting on the page rather than a
     rectangle drawn on it: a contact shadow that holds the edge, a soft cast
     below it, and a one-pixel highlight along the top where the light would
     catch. --ag-raise-lift is the hover state. Ported from aegis-id, where
     --aeg-sh IS the raise; mapping it to the flat shadow is what left every
     tile looking printed on the page instead of resting on it. */
  --ag-raise:      inset 0 1px 0 rgba(255,255,255,.9), 0 1px 1px rgba(9,22,37,.05), 0 10px 26px rgba(9,22,37,.08);
  --ag-raise-hi:   inset 0 1px 0 rgba(255,255,255,.9);
  --ag-raise-lift: 0 1px 1px rgba(9,22,37,.06), 0 18px 40px rgba(9,22,37,.14);

  /* --- component scale (aegis-id main.css) ------------------------------ */
  --aeg-space-1: 4px;  --aeg-space-2: 8px;  --aeg-space-3: 12px; --aeg-space-4: 16px;
  --aeg-space-5: 20px; --aeg-space-6: 24px; --aeg-space-7: 28px; --aeg-space-8: 32px;
  --aeg-r: 7px; --aeg-r-lg: 11px; --aeg-r-pill: 999px;
  --aeg-t-page: 23px; --aeg-t-section: 15.5px; --aeg-t-card: 14px; --aeg-t-body: 13.5px;
  --aeg-t-hint: 12.5px; --aeg-t-th: 11px; --aeg-t-eyebrow: 10.5px;
  --aeg-w-reg: 400; --aeg-w-md: 550; --aeg-w-sb: 600; --aeg-w-bd: 650; --aeg-w-hd: 700;

  color-scheme: light;
}

/* --- dark: OS preference, unless an explicit light choice overrides ------ */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ag-brand:        #0F75BC;
    --ag-brand-ink:    #3B9FE0;
    --ag-brand-text:   #3B9FE0;   /* 6.8:1 on --ag-bg; #0F75BC is only 4.0:1 */
    --ag-brand-on:     #ffffff;
    --ag-brand-hover:    #3B9FE0;
    --ag-brand-hover-on: #06243a; /* 5.5:1 — dark ink on the lifted blue */
    --ag-brand-soft:   #0b1f2e;
    --ag-brand-line:   #1c3f5c;

    --ag-plate:        #2a3444;
    --ag-plate-ink:    #e8eef7;
    --ag-plate-line:   #3d4a5d;

    --ag-bg:           #09090b;
    --ag-surface:      #111113;
    --ag-surface-2:    #18181b;
    --ag-surface-3:    #1f1f23;
    --ag-line:         #27272a;
    --ag-line-strong:  #3f3f46;

    --ag-text:         #fafafa;
    --ag-muted:        #a1a1aa;
    --ag-subtle:       #8b8b94;

    --ag-good: #34d399; --ag-good-soft: #052e22; --ag-good-line: #10b981;
    --ag-warn: #fbbf24; --ag-warn-soft: #2b1f04; --ag-warn-line: #a16207;
    --ag-bad:  #f87171; --ag-bad-soft:  #2d1113; --ag-bad-line:  #b91c1c;
    --ag-good-on: #09090b;  /* 10.4:1 */
    --ag-warn-on: #09090b;  /* 12.0:1 */
    --ag-bad-on:  #09090b;  /*  7.2:1 */
    --ag-teal:    #22d3ee;
    --ag-teal-on: #09090b;  /* 11.0:1 */
    --ag-info: #3B9FE0; --ag-info-soft: #0b1f2e; --ag-info-line: #1c3f5c;
    --ag-info-on: #06243a;  /* 5.5:1 -- white on the lifted blue is 2.9:1 */
    --ag-ai: #22d3ee; --ag-ai-soft: #082f33; --ag-ai-line: #155e68;
    --ag-ai-on: #09090b;  /* 11.0:1 on the lifted cyan */

    --ag-nav:   #060d14;
    --ag-nav-2: #0e1d2a;
    --ag-nav-line: #17303f;

    --ag-sh:    0 1px 2px rgba(0, 0, 0, .40), 0 1px 3px rgba(0, 0, 0, .30);
    --ag-sh-lg: 0 12px 32px rgba(0, 0, 0, .45);
    /* In the dark the cast does almost nothing -- a shadow on near-black is
       invisible -- so the highlight does the separating instead. */
    --ag-raise:      inset 0 1px 0 rgba(255,255,255,.06), 0 1px 1px rgba(0,0,0,.55), 0 10px 26px rgba(0,0,0,.42);
    --ag-raise-hi:   inset 0 1px 0 rgba(255,255,255,.06);
    --ag-raise-lift: 0 1px 1px rgba(0,0,0,.6), 0 20px 44px rgba(0,0,0,.55);

    color-scheme: dark;
  }
}

/* --- dark: explicit choice, so the toggle wins both ways ----------------- */
:root[data-theme="dark"] {
  --ag-brand:        #0F75BC;
  --ag-brand-ink:    #3B9FE0;
  --ag-brand-text:   #3B9FE0;
  --ag-brand-on:     #ffffff;
  --ag-brand-hover:    #3B9FE0;
  --ag-brand-hover-on: #06243a;
  --ag-brand-soft:   #0b1f2e;
  --ag-brand-line:   #1c3f5c;

  --ag-plate:        #2a3444;
  --ag-plate-ink:    #e8eef7;
  --ag-plate-line:   #3d4a5d;

  --ag-bg:           #09090b;
  --ag-surface:      #111113;
  --ag-surface-2:    #18181b;
  --ag-surface-3:    #1f1f23;
  --ag-line:         #27272a;
  --ag-line-strong:  #3f3f46;

  --ag-text:         #fafafa;
  --ag-muted:        #a1a1aa;
  --ag-subtle:       #8b8b94;

  --ag-good: #34d399; --ag-good-soft: #052e22; --ag-good-line: #10b981;
  --ag-warn: #fbbf24; --ag-warn-soft: #2b1f04; --ag-warn-line: #a16207;
  --ag-bad:  #f87171; --ag-bad-soft:  #2d1113; --ag-bad-line:  #b91c1c;
  --ag-good-on: #09090b;
  --ag-warn-on: #09090b;
  --ag-bad-on:  #09090b;
  --ag-teal:    #22d3ee;
  --ag-teal-on: #09090b;
  --ag-info: #3B9FE0; --ag-info-soft: #0b1f2e; --ag-info-line: #1c3f5c;
  --ag-info-on: #06243a;  /* 5.5:1 -- white on the lifted blue is 2.9:1 */
  --ag-ai: #22d3ee; --ag-ai-soft: #082f33; --ag-ai-line: #155e68;
  --ag-ai-on: #09090b;  /* 11.0:1 on the lifted cyan */

  --ag-nav:   #060d14;
  --ag-nav-2: #0e1d2a;
  --ag-nav-line: #17303f;

  --ag-sh:    0 1px 2px rgba(0, 0, 0, .40), 0 1px 3px rgba(0, 0, 0, .30);
  --ag-sh-lg: 0 12px 32px rgba(0, 0, 0, .45);
    /* In the dark the cast does almost nothing -- a shadow on near-black is
     invisible -- so the highlight does the separating instead. */
  --ag-raise:      inset 0 1px 0 rgba(255,255,255,.06), 0 1px 1px rgba(0,0,0,.55), 0 10px 26px rgba(0,0,0,.42);
  --ag-raise-hi:   inset 0 1px 0 rgba(255,255,255,.06);
  --ag-raise-lift: 0 1px 1px rgba(0,0,0,.6), 0 20px 44px rgba(0,0,0,.55);

  color-scheme: dark;
}

/* ===========================================================================
   Family 1 — --vg-* (public/css/aegis-design.css)

   The gradients are deliberately flattened to the single accent. Aegis ID has
   no gradient anywhere; leaving --vg-grad as periwinkle would keep the old
   signature alive wherever a rule still reads it.
   ========================================================================= */
:root {
  --vg-navy-950: var(--ag-nav);
  --vg-navy-900: var(--ag-nav-2);
  --vg-navy-800: var(--ag-brand-ink);
  --vg-navy-700: var(--ag-brand);
  --vg-sky-300:  var(--ag-brand-line);
  --vg-sky-400:  var(--ag-brand-line);
  --vg-sky-500:  var(--ag-brand);
  --vg-sky-600:  var(--ag-brand-text);
  --vg-peri-500: var(--ag-brand);
  --vg-peri-400: var(--ag-brand-line);
  --vg-cyan-500: var(--ag-teal);

  --vg-ink:   var(--ag-text);
  --vg-muted: var(--ag-muted);
  --vg-line:  var(--ag-line);
  --vg-paper: var(--ag-surface);
  --vg-mist:  var(--ag-surface-2);
  --vg-soft:  var(--ag-brand-soft);

  --vg-amber: var(--ag-warn);
  --vg-rose:  var(--ag-bad);
  --vg-green: var(--ag-good);
  --vg-red:   var(--ag-bad);

  --vg-grad:      var(--ag-brand);
  --vg-grad-soft: var(--ag-brand);
  --vg-grad-diag: var(--ag-brand);

  --vg-radius:      var(--aeg-r-lg);
  --vg-radius-sm:   var(--aeg-r);
  --vg-radius-lg:   var(--ag-r-lg);
  --vg-radius-pill: var(--ag-r-pill);
  --vg-shadow-sm: var(--ag-sh);
  --vg-shadow:    var(--ag-raise);
  --vg-shadow-lg: var(--ag-raise-lift);

  --vg-font: var(--ag-sans);
  --vg-font-display: var(--ag-display);
  --vg-font-mono: var(--ag-mono);
}

/* .vg-gradient-text clipped a gradient to the glyphs. With a flat accent the
   clip would paint nothing readable, so it becomes plain brand text. */
.vg-gradient-text {
  background: none !important;
  -webkit-background-clip: border-box !important;
  background-clip: border-box !important;
  color: var(--ag-brand-text) !important;
}
.vg-rule { background: var(--ag-brand) !important; }

/* ===========================================================================
   Families 2 and 3 — --cs-* and --gc-*

   These are declared in an inline <style> inside each layout's <head>. This
   file is linked AFTER that block, so these win on source order.
   ========================================================================= */
:root {
  --cs-nav:        var(--ag-nav);
  --cs-nav-hover:  var(--ag-nav-2);
  --cs-link:       var(--ag-brand-text);
  --cs-link-hover: var(--ag-brand-ink);
  --cs-visited:    var(--ag-brand-text);
  --cs-blue:       var(--ag-text);
  --cs-brand:      var(--ag-brand);
  --cs-white:      var(--ag-surface);
  --cs-light:      var(--ag-bg);
  --cs-border:     var(--ag-line);
  --cs-text:       var(--ag-text);
  --cs-muted:      var(--ag-muted);
  --cs-mist:       var(--ag-surface-2);
  --cs-ink:        var(--ag-text);
  --cs-success:    var(--ag-good);
  --cs-green:      var(--ag-good);
  --cs-warning:    var(--ag-warn);
  --cs-gold:       var(--ag-warn);
  --cs-danger:     var(--ag-bad);
  --cs-info:       var(--ag-info);
  --cs-accent:     var(--ag-brand);
  --cs-accent-dk:  var(--ag-brand-ink);
  --cs-grad:       var(--ag-brand);

  --gc-nav: var(--cs-nav); --gc-nav-hover: var(--cs-nav-hover);
  --gc-link: var(--cs-link); --gc-link-hover: var(--cs-link-hover); --gc-visited: var(--cs-visited);
  --gc-blue: var(--cs-blue); --gc-red: var(--cs-brand);
  --gc-white: var(--cs-white); --gc-light: var(--cs-light); --gc-border: var(--cs-border);
  --gc-text: var(--cs-text); --gc-muted: var(--cs-muted);
  --gc-success: var(--cs-success); --gc-warning: var(--cs-warning);
  --gc-danger: var(--cs-danger); --gc-info: var(--cs-info);
  --gc-accent: var(--cs-accent); --gc-accent-dk: var(--cs-accent-dk);
}

/* ===========================================================================
   Family 4 — Bootstrap

   Bootstrap 5 compiles literal hexes into its component variables: .btn-primary
   sets --bs-btn-bg: #0d6efd directly, NOT from --bs-primary. So remapping the
   theme variables alone leaves every button the old blue. The component blocks
   below are the ones the admin templates actually use.
   ========================================================================= */
:root {
  --bs-body-bg: var(--ag-bg);
  --bs-body-color: var(--ag-text);
  --bs-emphasis-color: var(--ag-text);
  --bs-secondary-color: var(--ag-muted);
  --bs-tertiary-color: var(--ag-subtle);
  --bs-border-color: var(--ag-line);
  --bs-border-color-translucent: var(--ag-line);
  --bs-secondary-bg: var(--ag-surface-2);
  --bs-tertiary-bg: var(--ag-surface-3);
  --bs-primary: var(--ag-brand);
  --bs-primary-rgb: 15, 117, 188;
  --bs-link-color: var(--ag-brand-text);
  --bs-link-hover-color: var(--ag-brand-ink);
  --bs-success: var(--ag-good);
  --bs-warning: var(--ag-warn);
  --bs-danger: var(--ag-bad);
  --bs-info: var(--ag-info);
  --bs-border-radius: var(--aeg-r);
  --bs-border-radius-sm: var(--ag-r-sm);
  --bs-border-radius-lg: var(--ag-r-lg);
  --bs-box-shadow: var(--ag-sh);
  --bs-box-shadow-sm: var(--ag-sh);
  --bs-box-shadow-lg: var(--ag-sh-lg);
  --bs-font-sans-serif: var(--ag-sans);
  --bs-body-font-family: var(--ag-sans);
  --bs-font-monospace: var(--ag-mono);
}

.btn {
  --bs-btn-border-radius: var(--aeg-r);
  --bs-btn-font-weight: var(--aeg-w-md);
}
.btn-primary {
  --bs-btn-bg: var(--ag-brand); --bs-btn-border-color: var(--ag-brand); --bs-btn-color: var(--ag-brand-on);
  --bs-btn-hover-bg: var(--ag-brand-hover); --bs-btn-hover-border-color: var(--ag-brand-hover); --bs-btn-hover-color: var(--ag-brand-hover-on);
  --bs-btn-active-bg: var(--ag-brand-hover); --bs-btn-active-border-color: var(--ag-brand-hover); --bs-btn-active-color: var(--ag-brand-hover-on);
  --bs-btn-disabled-bg: var(--ag-brand); --bs-btn-disabled-border-color: var(--ag-brand); --bs-btn-disabled-color: var(--ag-brand-on);
}
/* An outline button has a transparent fill. Grouping it with the solid
   secondary gave it --ag-surface, which reads as a filled button. */
.btn.btn-outline-secondary, .btn.btn-outline-light {
  --bs-btn-bg: transparent; --bs-btn-border-color: var(--ag-line-strong); --bs-btn-color: var(--ag-text);
  --bs-btn-hover-bg: var(--ag-surface-2); --bs-btn-hover-border-color: var(--ag-line-strong); --bs-btn-hover-color: var(--ag-text);
  --bs-btn-active-bg: var(--ag-surface-3); --bs-btn-active-border-color: var(--ag-line-strong); --bs-btn-active-color: var(--ag-text);
  --bs-btn-disabled-color: var(--ag-muted); --bs-btn-disabled-border-color: var(--ag-line);
}
.btn-outline-primary {
  --bs-btn-color: var(--ag-brand-text); --bs-btn-border-color: var(--ag-brand-line);
  --bs-btn-hover-bg: var(--ag-brand); --bs-btn-hover-border-color: var(--ag-brand); --bs-btn-hover-color: var(--ag-brand-on);
  --bs-btn-active-bg: var(--ag-brand); --bs-btn-active-border-color: var(--ag-brand); --bs-btn-active-color: var(--ag-brand-on);
  --bs-btn-disabled-color: var(--ag-muted); --bs-btn-disabled-border-color: var(--ag-line);
}
.btn.btn-secondary, .btn.btn-light {
  --bs-btn-bg: var(--ag-surface); --bs-btn-border-color: var(--ag-line-strong); --bs-btn-color: var(--ag-text);
  --bs-btn-hover-bg: var(--ag-surface-2); --bs-btn-hover-border-color: var(--ag-line-strong); --bs-btn-hover-color: var(--ag-text);
  --bs-btn-active-bg: var(--ag-surface-3); --bs-btn-active-border-color: var(--ag-line-strong); --bs-btn-active-color: var(--ag-text);
}
.btn-dark { --bs-btn-bg: var(--ag-nav); --bs-btn-border-color: var(--ag-nav); --bs-btn-color: var(--ag-nav-text);
  --bs-btn-hover-bg: var(--ag-nav-2); --bs-btn-hover-border-color: var(--ag-nav-2); --bs-btn-hover-color: var(--ag-nav-text); }
.btn-success { --bs-btn-bg: var(--ag-good); --bs-btn-border-color: var(--ag-good); --bs-btn-color: var(--ag-good-on);
  --bs-btn-hover-bg: var(--ag-good); --bs-btn-hover-border-color: var(--ag-good); --bs-btn-hover-color: var(--ag-good-on); }
.btn-warning { --bs-btn-bg: var(--ag-warn); --bs-btn-border-color: var(--ag-warn); --bs-btn-color: var(--ag-warn-on);
  --bs-btn-hover-bg: var(--ag-warn); --bs-btn-hover-border-color: var(--ag-warn); --bs-btn-hover-color: var(--ag-warn-on); }
.btn-danger { --bs-btn-bg: var(--ag-bad); --bs-btn-border-color: var(--ag-bad); --bs-btn-color: var(--ag-bad-on);
  --bs-btn-hover-bg: var(--ag-bad); --bs-btn-hover-border-color: var(--ag-bad); --bs-btn-hover-color: var(--ag-bad-on); }
.btn-outline-danger { --bs-btn-color: var(--ag-bad); --bs-btn-border-color: var(--ag-bad-line);
  --bs-btn-hover-bg: var(--ag-bad); --bs-btn-hover-border-color: var(--ag-bad); --bs-btn-hover-color: var(--ag-bad-on); }
.btn-outline-success { --bs-btn-color: var(--ag-good); --bs-btn-border-color: var(--ag-good-line);
  --bs-btn-hover-bg: var(--ag-good); --bs-btn-hover-border-color: var(--ag-good); --bs-btn-hover-color: var(--ag-good-on); }
.btn-outline-warning { --bs-btn-color: var(--ag-warn); --bs-btn-border-color: var(--ag-warn-line);
  --bs-btn-hover-bg: var(--ag-warn); --bs-btn-hover-border-color: var(--ag-warn); --bs-btn-hover-color: var(--ag-warn-on); }
.btn-outline-info { --bs-btn-color: var(--ag-info); --bs-btn-border-color: var(--ag-info-line);
  --bs-btn-hover-bg: var(--ag-info); --bs-btn-hover-border-color: var(--ag-info); --bs-btn-hover-color: var(--ag-brand-on); }

.card {
  --bs-card-bg: var(--ag-surface);
  --bs-card-border-color: var(--ag-line);
  --bs-card-border-radius: var(--aeg-r-lg);
  --bs-card-cap-bg: var(--ag-surface-2);
  --bs-card-color: var(--ag-text);
  box-shadow: var(--ag-sh);
}
.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--ag-text);
  --bs-table-border-color: var(--ag-line);
  --bs-table-striped-bg: var(--ag-surface-2);
  --bs-table-striped-color: var(--ag-text);
  --bs-table-hover-bg: var(--ag-surface-2);
  --bs-table-hover-color: var(--ag-text);
}
.table > thead th {
  color: var(--ag-muted);
  background: var(--ag-surface-2);
  font-size: var(--aeg-t-th);
  font-weight: var(--aeg-w-hd);
  letter-spacing: .055em;
  text-transform: uppercase;
}
.form-control, .form-select {
  background-color: var(--ag-surface);
  border-color: var(--ag-line-strong);
  color: var(--ag-text);
  border-radius: var(--aeg-r);
}
.form-control:focus, .form-select:focus {
  background-color: var(--ag-surface);
  border-color: var(--ag-brand);
  color: var(--ag-text);
  box-shadow: 0 0 0 3px var(--ag-brand-soft);
}
.form-control::placeholder { color: var(--ag-subtle); }
.input-group-text { background: var(--ag-surface-2); border-color: var(--ag-line-strong); color: var(--ag-muted); }
.form-check-input:checked { background-color: var(--ag-brand); border-color: var(--ag-brand); }
.modal-content, .dropdown-menu, .offcanvas, .list-group-item, .accordion-item, .popover {
  background-color: var(--ag-surface);
  border-color: var(--ag-line);
  color: var(--ag-text);
}
.dropdown-item { color: var(--ag-text); }
.dropdown-item:hover, .dropdown-item:focus { background: var(--ag-surface-2); color: var(--ag-text); }
.dropdown-divider, hr { border-color: var(--ag-line); }
.modal-header, .modal-footer, .offcanvas-header { border-color: var(--ag-line); }
.alert-success { --bs-alert-bg: var(--ag-good-soft); --bs-alert-border-color: var(--ag-good-line); --bs-alert-color: var(--ag-text); }
.alert-warning { --bs-alert-bg: var(--ag-warn-soft); --bs-alert-border-color: var(--ag-warn-line); --bs-alert-color: var(--ag-text); }
.alert-danger  { --bs-alert-bg: var(--ag-bad-soft);  --bs-alert-border-color: var(--ag-bad-line);  --bs-alert-color: var(--ag-text); }
.alert-info, .alert-primary { --bs-alert-bg: var(--ag-info-soft); --bs-alert-border-color: var(--ag-info-line); --bs-alert-color: var(--ag-text); }
.alert-light, .alert-secondary { --bs-alert-bg: var(--ag-surface-2); --bs-alert-border-color: var(--ag-line); --bs-alert-color: var(--ag-text); }
.alert-dark { --bs-alert-bg: var(--ag-nav); --bs-alert-border-color: var(--ag-nav-line); --bs-alert-color: var(--ag-nav-text); }
.badge.bg-primary { background: var(--ag-brand) !important; color: var(--ag-brand-on); }
.badge.bg-success { background: var(--ag-good) !important; color: var(--ag-good-on); }
.badge.bg-warning { background: var(--ag-warn) !important; color: var(--ag-warn-on); }
.badge.bg-danger  { background: var(--ag-bad)  !important; color: var(--ag-bad-on); }
.badge.bg-secondary, .badge.bg-light { background: var(--ag-surface-3) !important; color: var(--ag-muted); }
/* Bootstrap's colour utilities are absolute values carrying !important, so
   they survive the token layer and mean the wrong thing in dark: .text-dark is
   near-black, and .bg-light became a near-black surface, so "badge bg-light
   text-dark" rendered near-black on near-black.

   Inside a badge the badge's own fill/ink pairing is already correct, so the
   utility is neutralised there rather than redefined. Elsewhere .text-dark
   means "the page's ink", which is exactly what --ag-text is. */
/* `color: inherit` was wrong here: it takes the PAGE ink, not the badge's own.
   A badge states its pairing explicitly instead, and wins on specificity --
   .badge.bg-warning.text-dark is three classes against .text-dark's one. */
.badge.bg-warning, .badge.bg-warning.text-dark { background: var(--ag-warn) !important; color: var(--ag-warn-on) !important; }
.badge.bg-success, .badge.bg-success.text-dark { background: var(--ag-good) !important; color: var(--ag-good-on) !important; }
.badge.bg-danger,  .badge.bg-danger.text-dark  { background: var(--ag-bad)  !important; color: var(--ag-bad-on)  !important; }
.badge.bg-info, .badge.bg-info.text-dark, .badge.bg-info.text-white { background: var(--ag-info) !important; color: var(--ag-info-on) !important; }
.badge.bg-light,   .badge.bg-light.text-dark   { background: var(--ag-surface-3) !important; color: var(--ag-text) !important; }
.badge.bg-secondary, .badge.bg-secondary.text-dark { background: var(--ag-surface-3) !important; color: var(--ag-muted) !important; }
/* The AI badges carry their fill inline, so the label follows the AI token
   rather than a hard-coded white that fails on the lifted violet. */
.badge.text-white[style*="--ag-ai"], .ai-badge { color: var(--ag-ai-on) !important; }

/* The semantic text utilities are fixed hues chosen against white. On the dark
   surface #ffc107 is 1.6:1 and #dc3545 is 4.2:1 -- both below the 4.5 a label
   needs -- so they take the palette's state inks, which are tuned per theme. */
.text-primary { color: var(--ag-brand-text) !important; }
.text-success { color: var(--ag-good) !important; }
.text-warning { color: var(--ag-warn) !important; }
.text-danger  { color: var(--ag-bad) !important; }
.text-info    { color: var(--ag-info) !important; }

/* Bootstrap paints inline <code> in its pink (#d63384), which lands at 4.2:1
   on the dark surface. */
code:not(.hljs) { color: var(--ag-brand-text); background: var(--ag-surface-2); padding: .1em .35em; border-radius: var(--ag-r-sm); }
pre code:not(.hljs) { color: inherit; background: none; padding: 0; }
.text-dark, .text-black { color: var(--ag-text) !important; }
.text-light { color: var(--ag-nav-text) !important; }
.text-black-50 { color: var(--ag-muted) !important; }
.bg-dark { background: var(--ag-nav) !important; }
.text-muted { color: var(--ag-muted) !important; }
.bg-light { background: var(--ag-surface-2) !important; }
.bg-white { background: var(--ag-surface) !important; }
.border { border-color: var(--ag-line) !important; }
.progress { background: var(--ag-surface-3); }
.progress-bar { background: var(--ag-brand); }
.nav-tabs { border-color: var(--ag-line); }
.nav-tabs .nav-link { color: var(--ag-muted); }
.nav-tabs .nav-link.active {
  color: var(--ag-brand-text);
  background: var(--ag-surface);
  border-color: var(--ag-line) var(--ag-line) var(--ag-surface);
}

/* ===========================================================================
   The raise, and the lift on hover

   This is the single thing that most separates the two products on screen. A
   panel in Aegis ID sits ON the page: a contact shadow holding its edge, a
   soft cast below, a one-pixel highlight along the top. On hover it rises two
   pixels and the cast spreads. Flat borders alone read as the old design.

   Applied by class list, as aegis-id does it, so a card, a tile, a plan and a
   stat are all the same kind of object at the same scale.
   ========================================================================= */
.card,
.stat-card,
.aeg-card,
.aeg-stat-card,
.vg-card,
.vg-plan,
.control-card,
.section-card,
.cap-item,
.sa-hero-card {
  box-shadow: var(--ag-raise);
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

/* Only things that DO something lift. A card the reader cannot click should
   not pretend otherwise, so the lift is scoped to a link, a button, or a card
   the app has marked interactive. */
a.card:hover, a.stat-card:hover, a.aeg-stat-card:hover, a.aeg-card:hover,
button.card:hover, .stat-card:hover, .vg-plan:hover, .cap-item:hover,
.card.is-interactive:hover, .aeg-card.is-interactive:hover,
a.card:focus-visible, a.stat-card:focus-visible, a.aeg-stat-card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--ag-brand-line);
  box-shadow: var(--ag-raise-lift);
}

/* Buttons and pills get the same gesture, so a row of actions behaves like the
   tiles above it rather than like two different products. */
.btn, .vg-btn, .aeg-btn, .pill, .badge, .vg-badge, .vg-nav-link, .gc-app-nav li a {
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease,
              background-color 140ms ease, color 140ms ease;
}
.btn:hover, .vg-btn:hover, .aeg-btn:hover,
a.pill:hover, a.badge:hover, a.vg-badge:hover,
.btn:focus-visible, .vg-btn:focus-visible, .aeg-btn:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--ag-raise-lift);
}
/* Pressing puts it back down, so the gesture reads as a press and not a drift. */
.btn:active, .vg-btn:active, .aeg-btn:active { transform: translateY(0); box-shadow: var(--ag-raise); }
/* A button inside a dense toolbar or a table row stays put: twenty of them
   lifting at once is noise, not feedback. */
.ra-bar .btn, .record-actions .btn, .aeg-table .btn, .table .btn,
.btn-group .btn, .input-group .btn, .dropdown-menu .btn {
  transform: none !important;
  box-shadow: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .card, .stat-card, .aeg-card, .aeg-stat-card, .vg-card, .vg-plan,
  .btn, .vg-btn, .aeg-btn { transition: none; }
  .card:hover, .stat-card:hover, .aeg-stat-card:hover, .vg-plan:hover,
  .btn:hover, .vg-btn:hover, .aeg-btn:hover { transform: none; }
}

/* ===========================================================================
   Base
   ========================================================================= */
body {
  background: var(--ag-bg);
  color: var(--ag-text);
  font-family: var(--ag-sans);
  -webkit-font-smoothing: antialiased;
}
/* Saira on every heading, once, globally — which is how Aegis ID applies it.
   The weight stays with the component; 650 is its heaviest, not 700. */
h1, h2, h3, h4, h5, h6, .vg-h, .aeg-page-title, .aeg-section-title {
  font-family: var(--ag-display);
  letter-spacing: -.01em;
  text-wrap: balance;
  color: var(--ag-text);
}
code, pre, kbd, samp, .mono, .font-monospace { font-family: var(--ag-mono); }
pre { background: var(--ag-nav); color: var(--ag-nav-text); border-color: var(--ag-nav-line); }
a { color: var(--ag-brand-text); }
a:hover { color: var(--ag-brand-ink); }
:focus-visible { outline: 2px solid var(--ag-brand); outline-offset: 2px; }

/* The public nav keeps the dark chrome; it now reads the nav scale. */
.vg-nav { background: var(--ag-nav); border-bottom-color: var(--ag-nav-line); }
.vg-nav-link { color: var(--ag-nav-muted); }
.vg-nav-link:hover { color: var(--ag-nav-text); background: var(--ag-nav-2); }
.vg-nav-current { color: var(--ag-nav-text); }

/* --- bands that are dark in BOTH themes ---------------------------------
   The hero, the footer and the app chrome are dark surfaces by design, in
   light mode as much as in dark. The global heading colour above would paint
   near-black text on them, so inside these the headings inherit the band's
   own light ink instead. Without this the pricing hero reads as a dark
   heading on a dark field. */
.vg-hero,
.vg-footer,
.vg-nav,
.gc-fip,
.gc-app-bar,
.vg-btn-dark,
.vg-tip .bub {
  color: var(--ag-nav-text);
}
.vg-hero :is(h1, h2, h3, h4, h5, h6),
.vg-footer :is(h1, h2, h3, h4, h5, h6),
.vg-nav :is(h1, h2, h3, h4, h5, h6),
.gc-fip :is(h1, h2, h3, h4, h5, h6),
.gc-app-bar :is(h1, h2, h3, h4, h5, h6),
.vg-tip .bub :is(h1, h2, h3, h4, h5, h6) {
  color: inherit;
}
/* Inline text inside a permanently dark band inherits the band's ink. The
   tooltip body and the footer were keeping the light theme's dark blue, which
   is 2.8:1 on the navy. Block-level nav links keep their own rules. */
.vg-tip .bub *,
.vg-footer :is(span, p, li, small, b, strong, dt, dd) { color: inherit; }
.vg-footer a { color: var(--ag-nav-text); }
.vg-tip .bub b, .vg-tip .bub dt { color: var(--ag-nav-text); }

/* Brand-coloured text is a link colour; on these dark bands it does not have
   the contrast, so it takes the band's ink too. */
.vg-hero .vg-gradient-text,
.vg-footer .vg-gradient-text,
.vg-hero .vg-eyebrow {
  color: var(--ag-nav-text) !important;
}

/* ===========================================================================
   The launchers and the record toolbar

   There are three launcher classes, not two, and only two of them are live:
     .as-fab      the Guide, built by public/js/assistant.js. Violet, and it
                  stays violet -- assistant.css explains that the colour ties
                  it to the assistant section of the help centre, and it has
                  the contrast on both grounds.
     .cb-launch   Collaboration, from views/partials/collab-panel.hbs. Already
                  teal; it now reads the teal token instead of a literal.
     .aia-launch  dead on this branch. fab-dock.css still styles it and
                  assessment-detail still hides it, but nothing creates it.
                  Left alone rather than restyled.
   The panels are the part that actually needed work: their surfaces were
   literal white, so in dark they were white sheets on a near-black page.
   ========================================================================= */
.cb-launch {
  background: var(--ag-brand) !important;
  color: var(--ag-brand-on) !important;
  box-shadow: var(--ag-sh-lg) !important;
}
.cb-launch:hover { filter: brightness(1.08); }
.cb-launch .cb-badge { background: var(--ag-brand-on) !important; color: var(--ag-brand) !important; }
.as-fab, .cb-launch { box-shadow: var(--ag-sh-lg); }
.fab-dockable.fab-near-dock {
  outline-color: var(--ag-brand) !important;
  box-shadow: 0 0 0 4px var(--ag-brand-soft), var(--ag-sh-lg) !important;
}
.fab-dock-ghost { border-color: var(--ag-brand); background: var(--ag-brand-soft); }
.fab-dock-ghost i { color: var(--ag-brand-text); }

/* The assistant and collaboration panels.

   .aia-panel / .assistant-panel do not exist: the assistant's markup is built
   by public/js/assistant.js and uses .as-panel / .as-head / .as-body. An
   earlier pass here named the wrong classes and therefore styled nothing,
   which is why the assistant still looked like a different product.

   It keeps its violet -- assistant.css explains that the colour ties it to the
   assistant section of the help centre -- but flat rather than a gradient,
   because Aegis ID has no gradient anywhere, and on the product's panel
   chrome: a strong edge, the raise, and a tinted body. */
.as-panel, .cb-panel {
  background: var(--ag-surface-2) !important;
  border-left: 1px solid var(--ag-line-strong) !important;
  box-shadow: var(--ag-raise-lift) !important;
  color: var(--ag-text);
}
.as-body, .cb-msgs { background: var(--ag-surface-2) !important; }
.as-call, .as-next, .as-act {
  background: var(--ag-surface) !important;
  border: 1px solid var(--ag-line) !important;
  box-shadow: var(--ag-raise);
}
.as-act { transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease; }
.as-act:hover:not(.is-blocked) {
  transform: translateY(-2px);
  border-color: var(--ag-brand-line) !important;
  box-shadow: var(--ag-raise-lift);
}
.as-sec-label { color: var(--ag-subtle); }
.as-btn.as-primary { background: var(--ag-ai) !important; color: var(--ag-ai-on) !important; }

.record-actions.ra-floating {
  background: var(--ag-surface);
  border-color: var(--ag-line-strong);
  border-radius: var(--ag-r-lg);
  box-shadow: var(--ag-sh-lg);
}
.record-actions.ra-near-dock { outline-color: var(--ag-brand); box-shadow: 0 0 0 3px var(--ag-brand-soft), var(--ag-sh-lg); }
.ra-grip { color: var(--ag-subtle); }
.ra-grip:hover { background: var(--ag-surface-2); color: var(--ag-text); }
.ra-dock-ghost { border-color: var(--ag-brand); background: var(--ag-brand-soft); }

/* The action cluster on a record page sits flush with the right edge of the
   content column, so it lines up with the cards and tables below it. */
.ra-head { justify-content: space-between; }
.ra-head > .record-actions:last-child { margin-left: auto; }

/* ===========================================================================
   The left rail

   Ported from aegis-id's .app-side: a surface with a hairline on its right,
   grouped by eyebrow labels, rows at 13px/450 in the muted ink, and the active
   row marked by a brand-soft fill with a two-pixel accent down its left edge.

   The rail already existed here as a dockable nav with the user's position,
   pin and label preferences. This restyles it; it does not replace it, because
   those preferences are a feature and a fixed rail would throw them away.
   ========================================================================= */

/* A group heading is meaningless in the horizontal menu, and there is no room
   for it in the icon-only rail. */
.gc-nav-group { display: none; }

@media (min-width: 992px) {
  body.nav-dock.nav-pos-left .gc-app-bar,
  body.nav-dock.nav-pos-right .gc-app-bar {
    background: var(--ag-surface);
    border-image: none;
    box-shadow: none;
  }
  body.nav-dock.nav-pos-left  .gc-app-bar { border-right: 1px solid var(--ag-line); }
  body.nav-dock.nav-pos-right .gc-app-bar { border-left: 1px solid var(--ag-line); }

  body.nav-dock.nav-pos-left.nav-labels-text .gc-nav-group,
  body.nav-dock.nav-pos-right.nav-labels-text .gc-nav-group,
  body.nav-dock.nav-rail-expanded .gc-nav-group {
    display: block;
    margin: 15px 0 5px;
    padding: 0 18px;
    color: var(--ag-subtle);
    font-family: var(--ag-display);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
  }
  body.nav-dock.nav-pos-left .gc-nav-group:first-child,
  body.nav-dock.nav-pos-right .gc-nav-group:first-child { margin-top: 2px; }

  body.nav-dock.nav-pos-left .gc-app-nav li a,
  body.nav-dock.nav-pos-right .gc-app-nav li a {
    gap: 9px;
    padding: 6px 9px;
    margin: 1px 8px;
    border-radius: var(--ag-r-sm);
    color: var(--ag-muted);
    font-size: 13px;
    font-weight: 450;
  }
  body.nav-dock.nav-pos-left .gc-app-nav li a:hover,
  body.nav-dock.nav-pos-right .gc-app-nav li a:hover {
    background: var(--ag-surface-2);
    color: var(--ag-text);
    transform: none;
    box-shadow: none;
  }
  /* The accent down the left edge, not a ring around the row. */
  body.nav-dock.nav-pos-left .gc-app-nav li a.active,
  body.nav-dock.nav-pos-right .gc-app-nav li a.active {
    background: var(--ag-brand-soft);
    color: var(--ag-brand-text);
    font-weight: 600;
    box-shadow: inset 2px 0 0 var(--ag-brand);
  }

  /* --- the in-context sub-menu ------------------------------------------
     Indented under its parent with a hairline down the side, so it reads as
     part of that row rather than as a second menu. */
  body.nav-dock.nav-pos-left .gc-nav-sub,
  body.nav-dock.nav-pos-right .gc-nav-sub { display: block; }
  .gc-nav-sub { display: none; }
  .gc-nav-sub > ul {
    list-style: none;
    margin: 2px 8px 7px 22px;
    padding: 0 0 0 11px;
    border-left: 1px solid var(--ag-line);
    display: grid;
    gap: 1px;
  }
  .gc-nav-sub a {
    display: block;
    padding: 5px 9px !important;
    margin: 0 !important;
    border-radius: var(--ag-r-sm);
    color: var(--ag-muted) !important;
    font-size: 12.5px !important;
    font-weight: 450 !important;
  }
  .gc-nav-sub a:hover { background: var(--ag-surface-2); color: var(--ag-text) !important; }
  .gc-nav-sub a.active {
    background: var(--ag-surface-2) !important;
    color: var(--ag-text) !important;
    font-weight: 600 !important;
    box-shadow: none !important;
  }

  /* Icon-only rail: a column of unlabelled sub-rows says nothing, so the
     sub-menu and the group headings fold away with the labels. */
  body.nav-dock.nav-pos-left:not(.nav-labels-text):not(.nav-rail-expanded) .gc-nav-sub,
  body.nav-dock.nav-pos-right:not(.nav-labels-text):not(.nav-rail-expanded) .gc-nav-sub,
  body.nav-dock.nav-pos-left:not(.nav-labels-text):not(.nav-rail-expanded) .gc-nav-group,
  body.nav-dock.nav-pos-right:not(.nav-labels-text):not(.nav-rail-expanded) .gc-nav-group { display: none; }
}

/* ===========================================================================
   Lists: the same rows as a table or as cards

   A table compares rows; a card reads one. Which you want depends on the
   record and on how much width you have, so both are presentations of the one
   table markup -- see public/js/ag-list.js, which labels each cell from its
   column heading so a template does not have to repeat its headings.
   ========================================================================= */
.ag-list__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.ag-list__views { display: inline-flex; border: 1px solid var(--ag-line-strong); border-radius: var(--aeg-r); overflow: hidden; }
.ag-list__views[aria-hidden="true"] { display: none; }
.ag-list__views button {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border: 0; background: transparent; color: var(--ag-muted);
  font: inherit; font-size: 12.5px; font-weight: var(--aeg-w-md); cursor: pointer;
}
.ag-list__views button:hover { background: var(--ag-surface-2); color: var(--ag-text); transform: none; box-shadow: none; }
.ag-list__views button[aria-pressed="true"] { background: var(--ag-brand); color: var(--ag-brand-on); }

.ag-list__size select {
  padding: 5px 9px;
  border: 1px solid var(--ag-line-strong);
  border-radius: var(--aeg-r);
  background: var(--ag-surface);
  color: var(--ag-text);
  font: inherit;
  font-size: 12.5px;
}
/* A way out, not one of the page's actions, so it is quiet until wanted. */
.ag-list__csv {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--aeg-r);
  background: transparent;
  color: var(--ag-subtle);
  cursor: pointer;
  font-size: 14px;
}
.ag-list__csv:hover {
  background: var(--ag-surface-2);
  border-color: var(--ag-line-strong);
  color: var(--ag-text);
  transform: none;
  box-shadow: none;
}
.ag-list__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.ag-list__count { color: var(--ag-muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.ag-list__pager { display: inline-flex; gap: 6px; }
.ag-list__pager button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--ag-line-strong);
  border-radius: var(--aeg-r);
  background: var(--ag-surface);
  color: var(--ag-text);
  cursor: pointer;
  font-size: 13px;
}
.ag-list__pager button:hover:not(:disabled) { background: var(--ag-surface-2); transform: none; box-shadow: none; }
.ag-list__pager button:disabled { color: var(--ag-subtle); cursor: default; opacity: 1; }

/* --- the card view ------------------------------------------------------ */
.ag-list[data-view="cards"] table,
.ag-list[data-view="cards"] tbody,
.ag-list[data-view="cards"] tr,
.ag-list[data-view="cards"] td { display: block; }
.ag-list[data-view="cards"] thead { display: none; }
.ag-list[data-view="cards"] table { border-collapse: separate; border-spacing: 0; background: none; }
.ag-list[data-view="cards"] tbody {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--aeg-space-4);
  padding: var(--aeg-space-4);
}
.ag-list[data-view="cards"] tr {
  /* A column, so the action row can be ordered to the bottom of the card even
     though it is the first cell in the markup -- it is first because a wide
     table must not hide it behind a sideways scroll. */
  display: flex;
  flex-direction: column;
  padding: 14px 16px;
  background: var(--ag-surface);
  border: 1px solid var(--ag-line);
  border-radius: var(--aeg-r-lg);
  box-shadow: var(--ag-raise);
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}
.ag-list[data-view="cards"] tr:hover {
  transform: translateY(-2px);
  border-color: var(--ag-brand-line);
  box-shadow: var(--ag-raise-lift);
  background: var(--ag-surface-2);
}
/* Bootstrap paints .table-hover's tint as `inset 0 0 0 9999px` on each CELL,
   not on the row. In a table the cells tile the row, so it reads as one band;
   in the card view they are blocks stacked inside the card's own padding, so
   the tint covered the middle of the tile and stopped short of its edges and
   corners -- lit unevenly rather than lit. The cells go transparent and the
   card itself takes the tint, which is the shape the reader is pointing at. */
.ag-list[data-view="cards"] tbody tr > * {
  background-color: transparent;
  box-shadow: none;
}
.ag-list[data-view="cards"] td {
  padding: 4px 0;
  border: 0;
  display: flex;
  gap: 10px;
  align-items: baseline;
  justify-content: space-between;
}
/* The heading, carried over by the script. */
.ag-list[data-view="cards"] td::before {
  content: attr(data-label);
  flex: none;
  color: var(--ag-subtle);
  font-size: var(--aeg-t-th);
  font-weight: var(--aeg-w-hd);
  letter-spacing: .055em;
  text-transform: uppercase;
}
/* The cell after the actions is the record's name: it reads as the card's
   title, not as a labelled field. */
.ag-list[data-view="cards"] td.is-actions + td::before,
.ag-list[data-view="cards"] td.is-actions::before { display: none; }
.ag-list[data-view="cards"] td.is-actions + td {
  order: -1;
  display: block;
  margin-bottom: 4px;
  font-family: var(--ag-display);
  font-size: var(--aeg-t-card);
  font-weight: var(--aeg-w-bd);
  line-height: 1.3;
}
.ag-list[data-view="cards"] td.is-actions {
  order: 99;
  justify-content: flex-start;
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid var(--ag-line);
}

/* --- actions first ------------------------------------------------------
   A table wide enough to scroll sideways hides its right-hand column, which
   is exactly where the actions used to be: the reader had to discover the
   scroll to find the button. They sit first instead, where they are always on
   screen, and the column does not grow with the content beside it. */
.aeg-table th:first-child.is-actions,
.aeg-table td.is-actions,
.table th.is-actions,
.table td.is-actions { width: 1%; white-space: nowrap; }

/* ===========================================================================
   Header and footer

   The header is a surface, as it is in Aegis ID, not a navy band: the product
   reads lighter and the rail below it continues the same plane. The wordmark
   therefore needs its dark-ink file on a light header and its reversed file on
   a dark one, which CSS decides so it is right before any script runs.
   ========================================================================= */
/* Two class names deep, because .gc-sig .brand-logo already sets display:block
   at that weight -- a one-class hide loses to it and BOTH wordmarks render,
   which is exactly the trap aegis-id's own comment warns about. */
.ag-logo.ag-logo { display: block; width: auto; }
.ag-logo.ag-logo--dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ag-logo.ag-logo--light { display: none; }
  :root:not([data-theme="light"]) .ag-logo.ag-logo--dark { display: block; }
}
:root[data-theme="dark"] .ag-logo.ag-logo--light { display: none; }
:root[data-theme="dark"] .ag-logo.ag-logo--dark { display: block; }

/* The header stays put, which is what the rail already assumed.

   The rail is fixed at top:var(--brand-h) -- it holds its place while the page
   scrolls. The header was static, so it scrolled away and left an empty band
   exactly the height of the header above the rail, with nothing in it. Aegis
   ID keeps its header fixed for the same reason; sticky does it without taking
   the header out of flow, so nothing below has to be re-offset. */
@media (min-width: 992px) {
  /* On <header>, not on .gc-fip inside it: a sticky element travels only
     within its parent's box, and that parent is barely taller than the bar
     itself once the nav is taken out of flow by position:fixed. Stuck to
     .gc-fip it scrolled away regardless. */
  body.nav-dock.nav-pos-left > header[role="banner"],
  body.nav-dock.nav-pos-right > header[role="banner"] {
    position: sticky;
    top: 0;
    z-index: 1040;
  }
}

/* The header's own controls, now on a surface rather than the navy. */
.gc-fip .brand-portal-link {
  color: var(--ag-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--aeg-r);
  padding: 5px 9px;
  text-decoration: none;
}
.gc-fip .brand-portal-link:hover { color: var(--ag-text); background: var(--ag-surface-2); transform: none; box-shadow: none; }
.gc-fip .ag-theme { border-color: var(--ag-line-strong); }
.gc-fip .ag-theme button { color: var(--ag-muted); }
.gc-fip .ag-theme button:hover { color: var(--ag-text); background: var(--ag-surface-2); }

/* The footer: one quiet line on the surface. */
.gc-footer-main {
  background: var(--ag-surface) !important;
  border-top: 1px solid var(--ag-line);
  color: var(--ag-muted) !important;
  padding: 18px 0 !important;
}
.gc-footer-main .container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: center;
  justify-content: center;
}
.gc-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.gc-footer-main a { color: var(--ag-muted); font-size: 12.5px; text-decoration: none; }
.gc-footer-main a:hover { color: var(--ag-brand-text); text-decoration: underline; }
.gc-footer-main p { margin: 0; font-size: 12.5px; }

/* A page whose first element paints its own full-width band should start at
   the breadcrumb, not 24px below it. .gc-main pads the top for ordinary pages;
   where the first child is a band, that padding shows as a strip of page
   background above it -- the gap on /releases. */
/* No :first-child: these pages open with their own <style> block, so the band
   is the first element that RENDERS but not the first child. */
.gc-main:has(> .rn-hero),
.gc-main:has(> .vg-hero),
.gc-main:has(> .pb-scope) { padding-top: 0; }

/* The record's actions in the rail, built from the page's own toolbar by
   public/js/ag-rail-actions.js. A third level, so it reads as belonging to
   the record rather than as another section of the app. */
.gc-nav-actions { display: block; }
.gc-nav-actions__head {
  display: flex;
  align-items: center;
  gap: 7px;
  width: calc(100% - 18px);
  margin: 4px 9px 2px;
  padding: 5px 9px;
  border: 0;
  border-radius: var(--ag-r-sm);
  background: transparent;
  color: var(--ag-subtle);
  cursor: pointer;
  font: inherit;
  font-size: 10.5px;
  font-weight: var(--aeg-w-hd);
  letter-spacing: .09em;
  text-transform: uppercase;
}
.gc-nav-actions__head:hover { background: var(--ag-surface-2); color: var(--ag-text); }
.gc-nav-actions__head i { font-size: 10px; transition: transform 140ms ease; }
.gc-nav-actions__head[aria-expanded="true"] i { transform: rotate(90deg); }
.gc-nav-actions__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.gc-nav-actions__item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: calc(100% - 18px);
  margin: 0 9px;
  padding: 5px 9px;
  border: 0;
  border-radius: var(--ag-r-sm);
  background: transparent;
  color: var(--ag-muted);
  cursor: pointer;
  font: inherit;
  font-size: 12.5px;
  font-weight: var(--aeg-w-md);
  text-align: left;
}
.gc-nav-actions__item:hover { background: var(--ag-surface-2); color: var(--ag-text); }
.gc-nav-actions__item i { flex: none; font-size: 12px; opacity: .8; }
.gc-nav-actions__item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { .gc-nav-actions__head i { transition: none; } }

/* ===========================================================================
   Resizing the rail
   ========================================================================= */
.ag-rail-toggle { display: none; }
.ag-rail-grip { display: none; }

@media (min-width: 992px) {
  /* .gc-app-inner is justify-content:space-between from the horizontal top
     bar, where it put the menu button at one end and the nav at the other.
     In the vertical rail it had nothing to push apart while the nav was its
     only visible child -- adding the collapse toggle gave it a second, and it
     opened a 157px hole between them. The rail stacks from the top. */
  body.nav-dock.nav-pos-left .gc-app-inner,
  body.nav-dock.nav-pos-right .gc-app-inner { justify-content: flex-start; }

  body.nav-dock.nav-pos-left .ag-rail-toggle,
  body.nav-dock.nav-pos-right .ag-rail-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: flex-end;
    width: 26px;
    height: 26px;
    margin: 2px 8px 6px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--ag-r-sm);
    background: transparent;
    color: var(--ag-subtle);
    cursor: pointer;
    font-size: 12px;
    transition: color 120ms ease, background-color 120ms ease, transform 160ms ease;
  }
  body.nav-dock.nav-pos-left .ag-rail-toggle:hover,
  body.nav-dock.nav-pos-right .ag-rail-toggle:hover {
    background: var(--ag-surface-2);
    color: var(--ag-text);
  }
  /* The chevron points the way it will move the edge, which is the convention
     everywhere else this control appears. */
  body.ag-rail-collapsed .ag-rail-toggle i { transform: rotate(180deg); }
  body.nav-pos-right .ag-rail-toggle i { transform: rotate(180deg); }
  body.nav-pos-right.ag-rail-collapsed .ag-rail-toggle i { transform: none; }
  body.ag-rail-collapsed .ag-rail-toggle { align-self: center; margin-inline: auto; }

  /* The drag handle: the rail's inner edge, four pixels wide, invisible until
     it is wanted. */
  body.nav-dock.nav-pos-left .ag-rail-grip,
  body.nav-dock.nav-pos-right .ag-rail-grip {
    display: block;
    position: absolute;
    top: 0;
    bottom: 0;
    width: 5px;
    cursor: col-resize;
    touch-action: none;
    background: transparent;
    transition: background-color 120ms ease;
    z-index: 2;
  }
  body.nav-dock.nav-pos-left .ag-rail-grip { right: -2px; }
  body.nav-dock.nav-pos-right .ag-rail-grip { left: -2px; }
  .ag-rail-grip:hover,
  .ag-rail-grip:focus-visible,
  body.ag-rail-dragging .ag-rail-grip { background: var(--ag-brand); outline: none; }

  /* While dragging, nothing should select or animate under the pointer. */
  body.ag-rail-dragging { user-select: none; }
  body.ag-rail-dragging .gc-app-bar,
  body.ag-rail-dragging .gc-shell { transition: none !important; }

  /* Collapsed: icons centred, no group headings, no sub-menu.
     The width that keeps the active pill inside the rail lives in nav-dock.css
     (--rail-w, 76px) and in ag-rail.js (MIN), not here: nav-dock's own
     `body.nav-dock.nav-pos-left .gc-app-inner` is a more specific !important,
     so a side-margin override written at this specificity would be inert. The
     8px padding and 8px margin it already sets centre the 43px pill. */
  /* The icon has to be centred in the pill, and `justify-content` alone cannot
     do it: the link is `display: block` from the layout's own stylesheet, so
     the property was inert and the icon sat against the pill's left edge, a
     dozen pixels off centre. It needs to be a flex row first. The selector
     carries .nav-dock so it matches nav-dock's own specificity and wins on
     order, this file being loaded last. */
  body.nav-dock.ag-rail-collapsed .gc-app-nav li a,
  body.nav-dock.ag-rail-collapsed .gc-app-nav li > span {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }
  body.ag-rail-collapsed .gc-app-nav li a .me-1 { margin-right: 0 !important; }
  body.ag-rail-collapsed .gc-nav-group,
  body.ag-rail-collapsed .gc-nav-sub { display: none !important; }
}

/* The section the rail just jumped to. A ring rather than a fill, so the
   card's own colours are undisturbed, and it fades out on its own. */
.ag-jumped {
  outline: 2px solid var(--ag-brand);
  outline-offset: 3px;
  border-radius: var(--aeg-r-lg);
  transition: outline-color 400ms ease 1s;
}
.ag-jumped:focus-visible { outline: 2px solid var(--ag-brand); }
@media (prefers-reduced-motion: reduce) { .ag-jumped { transition: none; } }

/* The notification bell in the header. The count is a badge on the icon
   rather than a row in the menu, so an unread message is visible from any
   page without opening anything. */
.gc-bell { position: relative; display: inline-flex; align-items: center; }
.gc-bell__count {
  position: absolute;
  top: -3px;
  right: -6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--ag-r-pill);
  background: var(--ag-bad);
  color: var(--ag-bad-on);
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}
@media (max-width: 620px) { .brand-portal-link .hide-sm { display: none; } }

/* ===========================================================================
   Theme toggle
   ========================================================================= */
.ag-theme {
  display: inline-flex;
  border: 1px solid var(--ag-nav-line);
  border-radius: var(--aeg-r);
  overflow: hidden;
}
.ag-theme button {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border: 0;
  background: transparent;
  color: var(--ag-nav-muted);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  line-height: 1;
}
.ag-theme button:hover { color: var(--ag-nav-text); background: var(--ag-nav-2); }
.ag-theme button[aria-pressed="true"] { background: var(--ag-brand); color: var(--ag-brand-on); }
/* On a light surface rather than the dark nav. */
.ag-theme--light { border-color: var(--ag-line-strong); }
.ag-theme--light button { color: var(--ag-muted); }
.ag-theme--light button:hover { color: var(--ag-text); background: var(--ag-surface-2); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* A page whose content has a reading measure rather than filling the width --
   settings, preferences, a form. These used to centre themselves, which on a
   left-railed layout left a wide empty gutter between the menu and the first
   thing on the page, so the content looked detached from the navigation that
   led to it. They sit against the same left edge every other page starts at;
   the measure each page wants rides in on --ag-measure. */
.ag-measure {
  max-width: var(--ag-measure, 880px);
  margin-left: 0;
  margin-right: auto;
}

/* ────────────────────────────────────────────────────────────────────────────
   The dashboard pipeline
   ---------------------------------------------------------------------------
   Four stage cards in the order work actually travels, then one context strip
   underneath for projects, which are not a stage. Everything is drawn from the
   --ag-* tokens above, so the dark theme needs no rules of its own.

   The cards are <a> elements wrapping <span>s rather than <div>s: a stage is a
   link to its own list, and an anchor may not contain block-level children.
   `display:flex` on the spans gives them back the layout a div would have had.

   Equal height across the row comes from one min-height plus three fixed slots
   (step, title, figure); only the chips are free to wrap, and they are pushed
   to the bottom by `margin-top:auto`, so a tile with a long status name grows
   downward into its own slack instead of stretching its neighbours.
   ──────────────────────────────────────────────────────────────────────────── */

.ag-pipe {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.ag-stage,
.ag-ctx {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 14px 15px;
  background: var(--ag-surface);
  border: 1px solid var(--ag-line);
  border-radius: var(--ag-r-lg);
  box-shadow: var(--ag-sh);
  text-decoration: none;
  color: inherit;
  transition: box-shadow .16s ease, border-color .16s ease, transform .16s ease;
}
.ag-stage { min-height: 158px; }
.ag-ctx   { margin-top: 12px; gap: 10px; }

.ag-stage:hover, .ag-stage:focus-visible,
.ag-ctx:hover,   .ag-ctx:focus-visible {
  border-color: var(--ag-brand-line);
  box-shadow: var(--ag-raise-lift);
  transform: translateY(-2px);
  color: inherit;
}

/* STAGE 1, STAGE 2 … the only reason the cards read as a sequence rather than
   as four more counters. Small, quiet, and above everything else in the card. */
.ag-step {
  font-family: var(--ag-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ag-subtle);
}

.ag-thead {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.ag-ico {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: var(--ag-r-sm);
  display: grid;
  place-items: center;
  background: var(--ag-brand-soft);
  color: var(--ag-brand-text);
  font-size: 14px;
}
/* The title truncates rather than wraps: a second title line in one card would
   push its figure down and break the alignment across the row. */
.ag-tname {
  font-family: var(--ag-display);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ag-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.ag-bigrow {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  min-width: 0;
}
.ag-big {
  font-family: var(--ag-display);
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  color: var(--ag-text);
  font-variant-numeric: tabular-nums;
}
.ag-bigsub {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ag-subtle);
  padding-bottom: 3px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The drop-off bar. Its width is the stage's share of the first stage, so the
   four bars shortening left-to-right IS the funnel — no second chart needed. */
.ag-flow { display: flex; }
.ag-flowbar {
  flex: 1;
  height: 6px;
  border-radius: var(--ag-r-pill);
  background: var(--ag-surface-2);
  border: 1px solid var(--ag-line);
  overflow: hidden;
  min-width: 0;
}
.ag-flowbar > span {
  display: block;
  height: 100%;
  background: var(--ag-brand);
}

.ag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;   /* pins the statuses to the bottom edge of every card */
}
.ag-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.45;
  border-radius: var(--ag-r-pill);
  padding: 2px 9px;
  border: 1px solid var(--ag-line-strong);
  background: var(--ag-surface-2);
  color: var(--ag-muted);
  white-space: nowrap;
}
.ag-chip b {
  font-family: var(--ag-mono);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ag-text);
  font-variant-numeric: tabular-nums;
}
.ag-chip.t-ok   { background: var(--ag-good-soft); border-color: var(--ag-good-line); color: var(--ag-good); }
.ag-chip.t-warn { background: var(--ag-warn-soft); border-color: var(--ag-warn-line); color: var(--ag-warn); }
.ag-chip.t-bad  { background: var(--ag-bad-soft);  border-color: var(--ag-bad-line);  color: var(--ag-bad); }
.ag-chip.t-info { background: var(--ag-info-soft); border-color: var(--ag-info-line); color: var(--ag-info); }
.ag-chip.t-ok b   { color: var(--ag-good); }
.ag-chip.t-warn b { color: var(--ag-warn); }
.ag-chip.t-bad b  { color: var(--ag-bad); }
.ag-chip.t-info b { color: var(--ag-info); }

/* The context strip. Deliberately a different shape from a stage — one line, a
   proportion bar and a key — so nobody reads projects as a fifth stage. */
.ag-ctx-note {
  font-size: 11.5px;
  color: var(--ag-subtle);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.ag-ttotal {
  font-family: var(--ag-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--ag-text);
  margin-left: auto;
  flex: none;
  font-variant-numeric: tabular-nums;
}
.ag-pbar {
  display: flex;
  height: 8px;
  border-radius: var(--ag-r-pill);
  overflow: hidden;
  background: var(--ag-surface-2);
  border: 1px solid var(--ag-line);
}
.ag-pbar > span { display: block; height: 100%; }
.ag-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}
.ag-lg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--ag-muted);
  white-space: nowrap;
}
.ag-lg b {
  font-family: var(--ag-mono);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ag-text);
  font-variant-numeric: tabular-nums;
}
.ag-dot { width: 8px; height: 8px; border-radius: 3px; flex: none; }

.ag-pbar > .t-ok,   .ag-dot.t-ok   { background: var(--ag-good); }
.ag-pbar > .t-warn, .ag-dot.t-warn { background: var(--ag-warn); }
.ag-pbar > .t-bad,  .ag-dot.t-bad  { background: var(--ag-bad); }
.ag-pbar > .t-info, .ag-dot.t-info { background: var(--ag-info); }
.ag-pbar > .t-none, .ag-dot.t-none { background: var(--ag-line-strong); }

/* Two across on a tablet, one on a phone. The order is the whole point of the
   layout, so the cards stack in sequence rather than reflowing into a grid
   that reads in some other direction. */
@media (max-width: 1100px) {
  .ag-pipe { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .ag-pipe { grid-template-columns: 1fr; }
  .ag-stage { min-height: 0; }
  .ag-ctx-note { display: none; }   /* the strip is narrow; the label carries it */
}
