/*
 * SackNova — Design System (2026-09-06 — Phase 10 dual-theme rebuild)
 *
 * This file is the single source of visual truth for SackNova. It ships:
 *   1. Semantic design tokens (--sn-*) for LIGHT and DARK themes
 *   2. A typography system anchored on Manrope with a strong system fallback
 *   3. Bootstrap 5 component overrides that read from the tokens so the
 *      whole application follows the active theme with zero markup change
 *   4. ERP shell overrides (appbar, sidebar, cards, tables, forms) so the
 *      hundreds of existing .cshtml views become theme-aware automatically
 *   5. Utility classes (.ds-*, .sn-*) used by the redesigned partials
 *
 * Theme selection:
 *   <html data-theme="light">   → light tokens (default)
 *   <html data-theme="dark">    → dark tokens
 *   <html data-theme="system">  → the theme.js bootstrap sets one of the two
 *                                  above based on prefers-color-scheme
 *
 * Rollback: `git checkout master` (tag pre-ui-redesign) fully reverts.
 * Loading order (see _Layout / _StudentLayout / _LoginLayout):
 *   bootstrap.min.css → bootstrap-icons.min.css → app.css → design-system.css
 * design-system.css MUST come last so its token remapping wins.
 */


/* ============================================================
   0. FONT — Manrope self-hosted (optional; drop the .woff2
      files into /wwwroot/fonts/manrope/ to activate; falls back
      to system-ui otherwise which is still a strong choice).
   ============================================================ */
@font-face {
    font-family: "Manrope";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: local("Manrope"),
         url("/fonts/manrope/Manrope-Regular.woff2") format("woff2");
}
@font-face {
    font-family: "Manrope";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: local("Manrope Medium"),
         url("/fonts/manrope/Manrope-Medium.woff2") format("woff2");
}
@font-face {
    font-family: "Manrope";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: local("Manrope SemiBold"),
         url("/fonts/manrope/Manrope-SemiBold.woff2") format("woff2");
}
@font-face {
    font-family: "Manrope";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: local("Manrope Bold"),
         url("/fonts/manrope/Manrope-Bold.woff2") format("woff2");
}
@font-face {
    font-family: "Manrope";
    font-style: normal;
    font-weight: 800;
    font-display: swap;
    src: local("Manrope ExtraBold"),
         url("/fonts/manrope/Manrope-ExtraBold.woff2") format("woff2");
}


/* ============================================================
   1. LIGHT THEME TOKENS — the default. Cool white surfaces with
      subtle blue-gray hierarchy. Deliberately restrained.
   ============================================================ */
:root, [data-theme="light"] {
    color-scheme: light;

    /* Brand — SackNova blue */
    --sn-brand:              #0b5cab;
    --sn-brand-hover:        #094a8c;
    --sn-brand-active:       #073c73;
    --sn-brand-subtle:       #e8f0fb;
    --sn-brand-soft:         #f0f6fd;
    --sn-brand-fg:           #ffffff;
    --sn-brand-focus-ring:   rgba(11, 92, 171, 0.20);

    /* Surface hierarchy — five layered depths in cool white/blue-gray */
    --sn-bg-app:             #f6f8fc;
    --sn-bg-surface:         #ffffff;
    --sn-bg-elevated:        #ffffff;
    --sn-bg-sunken:          #eef2f8;
    --sn-bg-muted:           #f2f5fa;
    --sn-bg-hover:           #f1f5fa;
    --sn-bg-selected:        rgba(11, 92, 171, 0.06);
    --sn-bg-code:            #f5f7fb;

    /* Foreground text hierarchy */
    --sn-fg-primary:         #0f1729;    /* body */
    --sn-fg-secondary:       #40506b;    /* secondary body */
    --sn-fg-muted:           #5f7189;    /* muted */
    --sn-fg-subtle:          #8595a8;    /* subtle / meta */
    --sn-fg-inverse:         #ffffff;
    --sn-fg-link:            var(--sn-brand);
    --sn-fg-link-hover:      var(--sn-brand-hover);

    /* Borders */
    --sn-border:             #e2e8f0;
    --sn-border-strong:      #cbd5e1;
    --sn-border-subtle:      #eef2f7;
    --sn-border-focus:       var(--sn-brand);

    /* Sidebar (light) — pure white rail with subtle blue-gray hover */
    --sn-sidebar-bg:         #ffffff;
    --sn-sidebar-border:     #e2e8f0;
    --sn-sidebar-fg:         #40506b;
    --sn-sidebar-fg-strong:  #0f1729;
    --sn-sidebar-fg-muted:   #8595a8;
    --sn-sidebar-hover-bg:   #f2f5fa;
    --sn-sidebar-active-bg:  rgba(11, 92, 171, 0.08);
    --sn-sidebar-active-fg:  var(--sn-brand);
    --sn-sidebar-active-bar: var(--sn-brand);
    --sn-sidebar-caret:      #8595a8;

    /* Top app-bar — refined navy gradient (stays dark in both themes for identity) */
    --sn-appbar-bg:          linear-gradient(120deg, #063265 0%, #0b5cab 55%, #1670c8 100%);
    --sn-appbar-fg:          #ffffff;
    --sn-appbar-fg-muted:    rgba(255, 255, 255, 0.72);
    --sn-appbar-border:      rgba(255, 255, 255, 0.08);
    --sn-appbar-shadow:      0 1px 0 rgba(11, 92, 171, 0.35), 0 6px 24px rgba(6, 50, 101, 0.28);
    --sn-appbar-control-bg:  rgba(255, 255, 255, 0.10);
    --sn-appbar-control-bg-hover: rgba(255, 255, 255, 0.18);

    /* Semantic status */
    --sn-success:            #059669;
    --sn-success-fg:         #065f46;
    --sn-success-bg:         #d1fadf;
    --sn-success-soft:       #ecfdf5;
    --sn-success-border:     #a7f0c1;

    --sn-warning:            #d97706;
    --sn-warning-fg:         #92400e;
    --sn-warning-bg:         #fef3c7;
    --sn-warning-soft:       #fffbeb;
    --sn-warning-border:     #fcd77b;

    --sn-danger:             #dc2626;
    --sn-danger-fg:          #991b1b;
    --sn-danger-bg:          #fee2e2;
    --sn-danger-soft:        #fef2f2;
    --sn-danger-border:      #fca5a5;

    --sn-info:               #0891b2;
    --sn-info-fg:            #155e75;
    --sn-info-bg:            #cffafe;
    --sn-info-soft:          #ecfeff;
    --sn-info-border:        #67e8f9;

    --sn-neutral-bg:         #eef2f7;
    --sn-neutral-fg:         #40506b;
    --sn-neutral-border:     #d5dde8;

    /* Elevation — light theme uses very soft shadows for depth */
    --sn-shadow-xs:          0 1px 2px rgba(15, 23, 42, 0.04);
    --sn-shadow-sm:          0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 1px rgba(15, 23, 42, 0.03);
    --sn-shadow-md:          0 4px 12px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.04);
    --sn-shadow-lg:          0 12px 32px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.05);
    --sn-shadow-xl:          0 24px 48px rgba(15, 23, 42, 0.12), 0 8px 20px rgba(15, 23, 42, 0.06);
    --sn-focus-ring:         0 0 0 3px var(--sn-brand-focus-ring);

    /* Backdrop for modal overlays */
    --sn-backdrop:           rgba(15, 23, 42, 0.42);

    /* Attention / warmth palette (used sparingly) */
    --sn-attention-bg-1:     #fff8ee;
    --sn-attention-bg-2:     #fff2ee;
    --sn-attention-border:   #f4d5a0;
    --sn-attention-fg:       #b45309;

    /* Radius scale — subtle at small sizes, more generous for surfaces */
    --sn-r-xs:               4px;
    --sn-r-sm:               6px;
    --sn-r-md:               10px;
    --sn-r-lg:               14px;
    --sn-r-xl:               20px;
    --sn-r-pill:             999px;

    /* Spacing — 4-pt cadence with 8-pt jumps */
    --sn-s-0:                0;
    --sn-s-1:                4px;
    --sn-s-2:                8px;
    --sn-s-3:                12px;
    --sn-s-4:                16px;
    --sn-s-5:                20px;
    --sn-s-6:                24px;
    --sn-s-8:                32px;
    --sn-s-10:               40px;
    --sn-s-12:               48px;
    --sn-s-16:               64px;

    /* Typography */
    --sn-font-sans:          "Manrope", system-ui, -apple-system, "Segoe UI Variable Text",
                             "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif,
                             "Apple Color Emoji", "Segoe UI Emoji";
    --sn-font-mono:          ui-monospace, "JetBrains Mono", "Cascadia Code",
                             "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

    /* Type scale (fluid at large sizes) */
    --sn-fs-2xs:             0.6875rem;   /* 11px */
    --sn-fs-xs:              0.75rem;     /* 12px */
    --sn-fs-sm:              0.8125rem;   /* 13px */
    --sn-fs-md:              0.875rem;    /* 14px  ← default body */
    --sn-fs-base:            0.9375rem;   /* 15px  ← comfortable read */
    --sn-fs-lg:              1rem;        /* 16px */
    --sn-fs-xl:              1.125rem;    /* 18px */
    --sn-fs-2xl:             1.25rem;     /* 20px */
    --sn-fs-3xl:             1.5rem;      /* 24px */
    --sn-fs-4xl:             1.875rem;    /* 30px */
    --sn-fs-5xl:             2.25rem;     /* 36px */
    --sn-fs-display:         2.75rem;     /* 44px */

    --sn-fw-regular:         400;
    --sn-fw-medium:          500;
    --sn-fw-semibold:        600;
    --sn-fw-bold:            700;
    --sn-fw-extrabold:       800;

    --sn-lh-tight:           1.15;
    --sn-lh-snug:            1.3;
    --sn-lh-normal:          1.5;
    --sn-lh-loose:           1.7;

    --sn-ls-tight:           -0.02em;
    --sn-ls-snug:            -0.005em;
    --sn-ls-normal:          0;
    --sn-ls-wide:            0.04em;
    --sn-ls-caps:            0.08em;

    /* Motion — quick, purposeful */
    --sn-t-fast:             120ms;
    --sn-t-med:              180ms;
    --sn-t-slow:             280ms;
    --sn-ease:               cubic-bezier(0.2, 0, 0, 1);
    --sn-ease-emphasized:    cubic-bezier(0.22, 0.9, 0.32, 1);
    --sn-ease-spring:        cubic-bezier(0.16, 1, 0.3, 1);

    /* Layout dimensions */
    --sn-appbar-height:      56px;
    --sn-sidebar-width:      264px;
    --sn-sidebar-collapsed:  68px;

    /* Bootstrap backfill — remap Bootstrap CSS vars so legacy markup
       inherits our tokens without needing !important everywhere. */
    --bs-body-bg:            var(--sn-bg-app);
    --bs-body-color:         var(--sn-fg-primary);
    --bs-border-color:       var(--sn-border);
    --bs-body-font-family:   var(--sn-font-sans);
    --bs-primary:            var(--sn-brand);
    --bs-primary-rgb:        11, 92, 171;

    /* ERP legacy backfill — the existing --erp-* tokens (used in
       sidebar.css and hundreds of inline styles) now derive from
       the semantic tokens so switching theme flips them too. */
    --erp-primary:           var(--sn-brand);
    --erp-primary-dark:      var(--sn-brand-active);
    --erp-primary-light:     #1c7bd0;
    --erp-primary-lighter:   var(--sn-brand-subtle);
    --erp-accent:            var(--sn-warning);
    --erp-surface:           var(--sn-bg-app);
    --erp-surface-alt:       var(--sn-bg-muted);
    --erp-border:            var(--sn-border);
    --erp-text:              var(--sn-fg-primary);
    --erp-text-muted:        var(--sn-fg-muted);

    /* Legacy --ds-* backfill so anything still reading old tokens works */
    --ds-surface-page:       var(--sn-bg-app);
    --ds-surface-card:       var(--sn-bg-surface);
    --ds-surface-muted:      var(--sn-bg-muted);
    --ds-surface-sunken:     var(--sn-bg-sunken);
    --ds-border-subtle:      var(--sn-border-subtle);
    --ds-border-strong:      var(--sn-border-strong);
    --ds-text-1:             var(--sn-fg-primary);
    --ds-text-2:             var(--sn-fg-secondary);
    --ds-text-3:             var(--sn-fg-muted);
    --ds-text-inverse:       var(--sn-fg-inverse);
    --ds-status-success-fg:  var(--sn-success-fg);
    --ds-status-success-bg:  var(--sn-success-bg);
    --ds-status-success-bd:  var(--sn-success-border);
    --ds-status-warning-fg:  var(--sn-warning-fg);
    --ds-status-warning-bg:  var(--sn-warning-bg);
    --ds-status-warning-bd:  var(--sn-warning-border);
    --ds-status-danger-fg:   var(--sn-danger-fg);
    --ds-status-danger-bg:   var(--sn-danger-bg);
    --ds-status-danger-bd:   var(--sn-danger-border);
    --ds-status-info-fg:     var(--sn-info-fg);
    --ds-status-info-bg:     var(--sn-info-bg);
    --ds-status-info-bd:     var(--sn-info-border);
    --ds-status-neutral-fg:  var(--sn-neutral-fg);
    --ds-status-neutral-bg:  var(--sn-neutral-bg);
    --ds-status-neutral-bd:  var(--sn-neutral-border);
    --ds-r-sm:               var(--sn-r-sm);
    --ds-r-md:               var(--sn-r-md);
    --ds-r-lg:               var(--sn-r-lg);
    --ds-r-xl:               var(--sn-r-xl);
    --ds-r-pill:             var(--sn-r-pill);
    --ds-sh-1:               var(--sn-shadow-xs);
    --ds-sh-2:               var(--sn-shadow-sm);
    --ds-sh-3:               var(--sn-shadow-md);
    --ds-sh-ring-primary:    var(--sn-focus-ring);
    --ds-sh-ring-danger:     0 0 0 3px rgba(220, 38, 38, 0.22);
    --ds-sp-0:               0;
    --ds-sp-1:               var(--sn-s-1);
    --ds-sp-2:               var(--sn-s-2);
    --ds-sp-3:               var(--sn-s-3);
    --ds-sp-4:               var(--sn-s-4);
    --ds-sp-5:               var(--sn-s-5);
    --ds-sp-6:               var(--sn-s-6);
    --ds-sp-7:               var(--sn-s-8);
    --ds-fs-xs:              var(--sn-fs-xs);
    --ds-fs-sm:              var(--sn-fs-sm);
    --ds-fs-md:              var(--sn-fs-md);
    --ds-fs-lg:              var(--sn-fs-lg);
    --ds-fs-xl:              var(--sn-fs-xl);
    --ds-fs-2xl:             var(--sn-fs-2xl);
    --ds-fw-regular:         var(--sn-fw-regular);
    --ds-fw-medium:          var(--sn-fw-medium);
    --ds-fw-semibold:        var(--sn-fw-semibold);
    --ds-fw-bold:            var(--sn-fw-bold);
    --ds-motion-fast:        var(--sn-t-fast);
    --ds-motion-med:         var(--sn-t-med);
    --ds-motion-slow:        var(--sn-t-slow);
    --ds-ease-standard:      var(--sn-ease);
    --ds-ease-emphasized:    var(--sn-ease-emphasized);

    /* Sidebar/appbar dimensions for legacy layout code */
    --erp-sidebar-width:          var(--sn-sidebar-width);
    --erp-sidebar-collapsed-width: var(--sn-sidebar-collapsed);
    --erp-appbar-height:          var(--sn-appbar-height);
}


/* ============================================================
   2. DARK THEME TOKENS — deep navy surface hierarchy. Layered
      not flat. Uses subtle borders + selective shadows for depth.
   ============================================================ */
[data-theme="dark"] {
    color-scheme: dark;

    /* Brand — slightly brighter blue on dark so it reads without shouting */
    --sn-brand:              #6ba8f5;
    --sn-brand-hover:        #85b8fa;
    --sn-brand-active:       #a1c8fc;
    --sn-brand-subtle:       rgba(107, 168, 245, 0.12);
    --sn-brand-soft:         rgba(107, 168, 245, 0.06);
    --sn-brand-fg:           #0b1220;
    --sn-brand-focus-ring:   rgba(107, 168, 245, 0.32);

    /* Surface hierarchy — deep navy, 5 layered depths */
    --sn-bg-app:             #0b1220;
    --sn-bg-surface:         #131c2e;
    --sn-bg-elevated:        #1a2438;
    --sn-bg-sunken:          #070c17;
    --sn-bg-muted:           #172035;
    --sn-bg-hover:           #1c2740;
    --sn-bg-selected:        rgba(107, 168, 245, 0.14);
    --sn-bg-code:            #131c2e;

    /* Foreground text hierarchy */
    --sn-fg-primary:         #eef3fb;
    --sn-fg-secondary:       #b8c4d8;
    --sn-fg-muted:           #8a99b3;
    --sn-fg-subtle:          #64758f;
    --sn-fg-inverse:         #0f1729;
    --sn-fg-link:            var(--sn-brand);
    --sn-fg-link-hover:      var(--sn-brand-hover);

    /* Borders */
    --sn-border:             #2a3550;
    --sn-border-strong:      #3a4767;
    --sn-border-subtle:      #1e2a44;
    --sn-border-focus:       var(--sn-brand);

    /* Sidebar (dark) — deeper navy than the content area */
    --sn-sidebar-bg:         #0f1729;
    --sn-sidebar-border:     #1e2a44;
    --sn-sidebar-fg:         #b8c4d8;
    --sn-sidebar-fg-strong:  #eef3fb;
    --sn-sidebar-fg-muted:   #8a99b3;
    --sn-sidebar-hover-bg:   #1a2438;
    --sn-sidebar-active-bg:  rgba(107, 168, 245, 0.14);
    --sn-sidebar-active-fg:  var(--sn-brand);
    --sn-sidebar-active-bar: var(--sn-brand);
    --sn-sidebar-caret:      #64758f;

    /* Top app-bar — richer, slightly moodier gradient in dark */
    --sn-appbar-bg:          linear-gradient(120deg, #05122a 0%, #0a2a5c 55%, #0d3d8e 100%);
    --sn-appbar-fg:          #ffffff;
    --sn-appbar-fg-muted:    rgba(255, 255, 255, 0.70);
    --sn-appbar-border:      rgba(255, 255, 255, 0.06);
    --sn-appbar-shadow:      0 1px 0 rgba(0, 0, 0, 0.4), 0 6px 24px rgba(0, 0, 0, 0.5);
    --sn-appbar-control-bg:  rgba(255, 255, 255, 0.08);
    --sn-appbar-control-bg-hover: rgba(255, 255, 255, 0.14);

    /* Semantic status — tuned for dark bg legibility */
    --sn-success:            #34d399;
    --sn-success-fg:         #6ee7b7;
    --sn-success-bg:         rgba(52, 211, 153, 0.14);
    --sn-success-soft:       rgba(52, 211, 153, 0.06);
    --sn-success-border:     rgba(52, 211, 153, 0.30);

    --sn-warning:            #fbbf24;
    --sn-warning-fg:         #fde68a;
    --sn-warning-bg:         rgba(251, 191, 36, 0.14);
    --sn-warning-soft:       rgba(251, 191, 36, 0.06);
    --sn-warning-border:     rgba(251, 191, 36, 0.30);

    --sn-danger:             #f87171;
    --sn-danger-fg:          #fca5a5;
    --sn-danger-bg:          rgba(248, 113, 113, 0.14);
    --sn-danger-soft:        rgba(248, 113, 113, 0.06);
    --sn-danger-border:      rgba(248, 113, 113, 0.30);

    --sn-info:               #22d3ee;
    --sn-info-fg:            #67e8f9;
    --sn-info-bg:            rgba(34, 211, 238, 0.14);
    --sn-info-soft:          rgba(34, 211, 238, 0.06);
    --sn-info-border:        rgba(34, 211, 238, 0.30);

    --sn-neutral-bg:         rgba(148, 163, 184, 0.14);
    --sn-neutral-fg:         #cbd5e1;
    --sn-neutral-border:     rgba(148, 163, 184, 0.30);

    /* Elevation — dark uses layered surfaces + very subtle top-light shadows */
    --sn-shadow-xs:          0 1px 0 rgba(255, 255, 255, 0.03) inset;
    --sn-shadow-sm:          0 2px 4px rgba(0, 0, 0, 0.35), 0 1px 0 rgba(255, 255, 255, 0.03) inset;
    --sn-shadow-md:          0 8px 24px rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
    --sn-shadow-lg:          0 20px 40px rgba(0, 0, 0, 0.55), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
    --sn-shadow-xl:          0 32px 60px rgba(0, 0, 0, 0.65), 0 1px 0 rgba(255, 255, 255, 0.05) inset;

    /* Modal backdrop deeper */
    --sn-backdrop:           rgba(0, 0, 0, 0.68);

    --sn-attention-bg-1:     rgba(251, 191, 36, 0.08);
    --sn-attention-bg-2:     rgba(248, 113, 113, 0.06);
    --sn-attention-border:   rgba(251, 191, 36, 0.28);
    --sn-attention-fg:       #fbbf24;

    /* Bootstrap backfill overrides */
    --bs-body-bg:            var(--sn-bg-app);
    --bs-body-color:         var(--sn-fg-primary);
    --bs-border-color:       var(--sn-border);
    --bs-primary:            var(--sn-brand);
    --bs-primary-rgb:        107, 168, 245;
    --bs-tertiary-bg:        var(--sn-bg-muted);
    --bs-secondary-bg:       var(--sn-bg-elevated);

    /* Legacy --erp-* backfill (dark) */
    --erp-primary:           var(--sn-brand);
    --erp-primary-dark:      #094a8c;
    --erp-primary-light:     var(--sn-brand-hover);
    --erp-primary-lighter:   var(--sn-brand-subtle);
    --erp-surface:           var(--sn-bg-app);
    --erp-surface-alt:       var(--sn-bg-muted);
    --erp-border:            var(--sn-border);
    --erp-text:              var(--sn-fg-primary);
    --erp-text-muted:        var(--sn-fg-muted);

    /* Legacy --ds-* backfill (dark) */
    --ds-surface-page:       var(--sn-bg-app);
    --ds-surface-card:       var(--sn-bg-surface);
    --ds-surface-muted:      var(--sn-bg-muted);
    --ds-surface-sunken:     var(--sn-bg-sunken);
    --ds-border-subtle:      var(--sn-border-subtle);
    --ds-border-strong:      var(--sn-border-strong);
    --ds-text-1:             var(--sn-fg-primary);
    --ds-text-2:             var(--sn-fg-secondary);
    --ds-text-3:             var(--sn-fg-muted);
    --ds-status-success-fg:  var(--sn-success-fg);
    --ds-status-success-bg:  var(--sn-success-bg);
    --ds-status-success-bd:  var(--sn-success-border);
    --ds-status-warning-fg:  var(--sn-warning-fg);
    --ds-status-warning-bg:  var(--sn-warning-bg);
    --ds-status-warning-bd:  var(--sn-warning-border);
    --ds-status-danger-fg:   var(--sn-danger-fg);
    --ds-status-danger-bg:   var(--sn-danger-bg);
    --ds-status-danger-bd:   var(--sn-danger-border);
    --ds-status-info-fg:     var(--sn-info-fg);
    --ds-status-info-bg:     var(--sn-info-bg);
    --ds-status-info-bd:     var(--sn-info-border);
    --ds-sh-1:               var(--sn-shadow-xs);
    --ds-sh-2:               var(--sn-shadow-sm);
    --ds-sh-3:               var(--sn-shadow-md);
    --ds-sh-ring-primary:    var(--sn-focus-ring);
}


/* ============================================================
   3. BASE — body, headings, links, focus, selection, scrollbars.
      All values derived from tokens so they flip with the theme.
   ============================================================ */
html {
    background: var(--sn-bg-app);
    color: var(--sn-fg-primary);
}
body {
    font-family: var(--sn-font-sans);
    font-size: var(--sn-fs-md);
    font-weight: var(--sn-fw-regular);
    line-height: var(--sn-lh-normal);
    color: var(--sn-fg-primary);
    background: var(--sn-bg-app);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: "cv11", "ss01", "ss03";
}

/* Selection */
::selection {
    background: var(--sn-brand);
    color: var(--sn-brand-fg);
}

/* Scrollbar — subtle track that follows theme */
* { scrollbar-color: var(--sn-border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--sn-border-strong);
    border-radius: var(--sn-r-pill);
    border: 2px solid var(--sn-bg-app);
}
::-webkit-scrollbar-thumb:hover { background: var(--sn-fg-subtle); }

/* Headings — Manrope reads especially well in these weights + tracking */
h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6 {
    font-family: var(--sn-font-sans);
    color: var(--sn-fg-primary);
    font-weight: var(--sn-fw-bold);
    letter-spacing: var(--sn-ls-snug);
    line-height: var(--sn-lh-snug);
    margin-bottom: var(--sn-s-3);
}
h1, .h1 { font-size: var(--sn-fs-4xl); letter-spacing: var(--sn-ls-tight); line-height: var(--sn-lh-tight); }
h2, .h2 { font-size: var(--sn-fs-3xl); letter-spacing: var(--sn-ls-tight); }
h3, .h3 { font-size: var(--sn-fs-2xl); }
h4, .h4 { font-size: var(--sn-fs-xl); }
h5, .h5 { font-size: var(--sn-fs-lg); }
h6, .h6 { font-size: var(--sn-fs-md); }

/* Page-title patterns used across the app — <h1 class="h5">Title</h1>.
   Give them their own confident size so a page header reads as one. */
h1.h5, h1.h6 {
    font-size: 1.25rem;
    font-weight: var(--sn-fw-bold);
    letter-spacing: var(--sn-ls-snug);
    line-height: var(--sn-lh-snug);
    color: var(--sn-fg-primary);
    margin-bottom: 2px;
}
h1.h4 {
    font-size: var(--sn-fs-2xl);
    font-weight: var(--sn-fw-bold);
    letter-spacing: var(--sn-ls-tight);
    line-height: var(--sn-lh-tight);
    color: var(--sn-fg-primary);
}
h1.h5 > .bi, h1.h6 > .bi, h1.h4 > .bi {
    color: var(--sn-brand);
    margin-right: 0.4em;
}

/* Links */
a { color: var(--sn-fg-link); text-decoration: none; transition: color var(--sn-t-fast) var(--sn-ease); }
a:hover { color: var(--sn-fg-link-hover); text-decoration: underline; text-underline-offset: 2px; }
a.text-decoration-none:hover { text-decoration: none; }

/* Muted helpers */
.text-muted { color: var(--sn-fg-muted) !important; }
.text-secondary { color: var(--sn-fg-secondary) !important; }
.small, small { color: inherit; font-size: var(--sn-fs-sm); }

/* Code + monospace */
code, kbd, samp, pre {
    font-family: var(--sn-font-mono);
    font-size: 0.9em;
}
code {
    padding: 1px 5px;
    background: var(--sn-bg-code);
    color: var(--sn-brand);
    border-radius: var(--sn-r-xs);
    border: 1px solid var(--sn-border-subtle);
}

/* Numbers — tabular figures + slightly tighter tracking for tables/dashboards */
.sn-tabular, td, .h1, .h2, .h3, .h4 {
    font-variant-numeric: tabular-nums;
}

/* Universal focus ring — brand color halo, works in both themes */
:where(a, button, [role="button"], input, select, textarea, .form-control, .form-select, .btn):focus-visible {
    outline: none;
    box-shadow: var(--sn-focus-ring);
    border-color: var(--sn-border-focus);
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    :root, [data-theme="dark"] {
        --sn-t-fast: 0ms;
        --sn-t-med: 0ms;
        --sn-t-slow: 0ms;
    }
}

/* Theme transition — subtle so it doesn't feel jarring on toggle */
html.sn-theme-switching, html.sn-theme-switching * {
    transition: background-color var(--sn-t-med) var(--sn-ease),
                color var(--sn-t-med) var(--sn-ease),
                border-color var(--sn-t-med) var(--sn-ease) !important;
}


/* ============================================================
   4. BOOTSTRAP COMPONENT OVERRIDES — all values from tokens.
   ============================================================ */

/* --- Buttons -------------------------------------------------- */
.btn {
    font-family: var(--sn-font-sans);
    font-weight: var(--sn-fw-semibold);
    font-size: var(--sn-fs-md);
    padding: 0.45rem 0.9rem;
    border-radius: var(--sn-r-sm);
    letter-spacing: -0.005em;
    transition: background-color var(--sn-t-fast) var(--sn-ease),
                border-color var(--sn-t-fast) var(--sn-ease),
                box-shadow var(--sn-t-fast) var(--sn-ease),
                transform var(--sn-t-fast) var(--sn-ease),
                color var(--sn-t-fast) var(--sn-ease);
}
.btn-sm { font-size: var(--sn-fs-sm); padding: 0.32rem 0.7rem; }
.btn-lg { font-size: var(--sn-fs-lg); padding: 0.62rem 1.1rem; }
.btn-icon { padding: 0.32rem 0.42rem; line-height: 1; }

.btn-primary {
    background: var(--sn-brand);
    border-color: var(--sn-brand);
    color: var(--sn-brand-fg);
    box-shadow: 0 1px 2px rgba(11, 92, 171, 0.18);
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--sn-brand-hover);
    border-color: var(--sn-brand-hover);
    color: var(--sn-brand-fg);
    box-shadow: 0 4px 12px rgba(11, 92, 171, 0.28);
    transform: translateY(-1px);
}
.btn-primary:active, .btn-primary.active {
    background: var(--sn-brand-active);
    border-color: var(--sn-brand-active);
    color: var(--sn-brand-fg);
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(11, 92, 171, 0.18);
}
.btn-primary:disabled, .btn-primary.disabled { opacity: 0.55; box-shadow: none; transform: none; }

.btn-outline-primary { color: var(--sn-brand); border-color: var(--sn-brand); background: transparent; }
.btn-outline-primary:hover, .btn-outline-primary:focus {
    background: var(--sn-brand);
    border-color: var(--sn-brand);
    color: var(--sn-brand-fg);
}
.btn-outline-secondary {
    color: var(--sn-fg-secondary);
    border-color: var(--sn-border-strong);
    background: transparent;
}
.btn-outline-secondary:hover, .btn-outline-secondary:focus {
    background: var(--sn-bg-hover);
    border-color: var(--sn-border-strong);
    color: var(--sn-fg-primary);
}
.btn-outline-success { color: var(--sn-success); border-color: var(--sn-success); }
.btn-outline-success:hover { background: var(--sn-success); color: #fff; }
.btn-outline-warning { color: var(--sn-warning); border-color: var(--sn-warning); }
.btn-outline-warning:hover { background: var(--sn-warning); color: #fff; }
.btn-outline-danger { color: var(--sn-danger); border-color: var(--sn-danger); }
.btn-outline-danger:hover { background: var(--sn-danger); color: #fff; }
.btn-outline-info { color: var(--sn-info); border-color: var(--sn-info); }
.btn-outline-info:hover { background: var(--sn-info); color: #fff; }
.btn-outline-dark {
    color: var(--sn-fg-primary);
    border-color: var(--sn-border-strong);
}
.btn-outline-dark:hover {
    background: var(--sn-fg-primary);
    color: var(--sn-fg-inverse);
    border-color: var(--sn-fg-primary);
}

.btn-success { background: var(--sn-success); border-color: var(--sn-success); color: #fff; }
.btn-warning { background: var(--sn-warning); border-color: var(--sn-warning); color: #fff; }
.btn-danger  { background: var(--sn-danger);  border-color: var(--sn-danger);  color: #fff; }
.btn-info    { background: var(--sn-info);    border-color: var(--sn-info);    color: #fff; }
.btn-secondary {
    background: var(--sn-bg-elevated);
    border-color: var(--sn-border-strong);
    color: var(--sn-fg-primary);
}
.btn-secondary:hover { background: var(--sn-bg-hover); color: var(--sn-fg-primary); }

.btn-link {
    color: var(--sn-fg-link);
    text-decoration: none;
    padding: 0.28rem 0.4rem;
}
.btn-link:hover { color: var(--sn-fg-link-hover); background: var(--sn-bg-hover); }
.btn-link.text-primary { color: var(--sn-brand) !important; }
.btn-link.text-danger  { color: var(--sn-danger) !important; }
.btn-link.text-success { color: var(--sn-success) !important; }
.btn-link.text-warning { color: var(--sn-warning) !important; }
.btn-link.text-muted   { color: var(--sn-fg-muted) !important; }
.btn-link.text-info    { color: var(--sn-info) !important; }
.btn-link.text-dark    { color: var(--sn-fg-primary) !important; }


/* --- Forms / inputs ------------------------------------------ */
/* Use background-color (not the "background" shorthand) so Bootstrap's
   chevron SVG on .form-select survives our theme. The shorthand would
   reset background-image to none and strip the down-arrow. */
.form-control, .form-select, textarea.form-control {
    background-color: var(--sn-bg-surface);
    color: var(--sn-fg-primary);
    border: 1px solid var(--sn-border-strong);
    border-radius: var(--sn-r-sm);
    padding: 0.42rem 0.7rem;
    font-size: var(--sn-fs-md);
    line-height: 1.4;
    transition: border-color var(--sn-t-fast) var(--sn-ease),
                background-color var(--sn-t-fast) var(--sn-ease),
                box-shadow var(--sn-t-fast) var(--sn-ease);
}
/* Reserve room for the chevron so long option text never overlaps it.
   Bootstrap's baseline padding-right is 2.25rem; matched here. Sizes
   below adjust for -sm / -lg variants. */
.form-select                       { padding-right: 2.25rem; }
.form-select-sm                    { padding-right: 2rem; }
.form-select-lg                    { padding-right: 2.5rem; }

.form-control::placeholder { color: var(--sn-fg-subtle); }
.form-control:hover, .form-select:hover { border-color: var(--sn-fg-subtle); }
.form-control:focus, .form-select:focus {
    background-color: var(--sn-bg-surface);
    color: var(--sn-fg-primary);
    border-color: var(--sn-brand);
    box-shadow: var(--sn-focus-ring);
}
.form-control-sm, .form-select-sm { font-size: var(--sn-fs-sm); padding-top: 0.32rem; padding-bottom: 0.32rem; padding-left: 0.55rem; }
.form-control-lg, .form-select-lg { font-size: var(--sn-fs-lg); padding-top: 0.55rem; padding-bottom: 0.55rem; padding-left: 0.9rem; }

.form-control:disabled, .form-control[readonly],
.form-select:disabled {
    background-color: var(--sn-bg-muted);
    color: var(--sn-fg-muted);
    opacity: 1;
}

.form-label {
    font-size: var(--sn-fs-sm);
    font-weight: var(--sn-fw-medium);
    color: var(--sn-fg-secondary);
    margin-bottom: var(--sn-s-1);
    letter-spacing: 0;
}
.form-label.text-muted { color: var(--sn-fg-secondary) !important; }
.form-text { font-size: var(--sn-fs-xs); color: var(--sn-fg-muted); }

.input-group-text {
    background: var(--sn-bg-muted);
    color: var(--sn-fg-muted);
    border-color: var(--sn-border-strong);
    font-size: var(--sn-fs-md);
}

.form-check-input {
    background-color: var(--sn-bg-surface);
    border-color: var(--sn-border-strong);
}
.form-check-input:checked {
    background-color: var(--sn-brand);
    border-color: var(--sn-brand);
}
.form-check-input:focus { border-color: var(--sn-brand); box-shadow: var(--sn-focus-ring); }
.form-check-label { color: var(--sn-fg-primary); font-size: var(--sn-fs-md); }

.form-switch .form-check-input { background-color: var(--sn-bg-muted); border-color: var(--sn-border-strong); }
.form-switch .form-check-input:checked { background-color: var(--sn-brand); border-color: var(--sn-brand); }

/* Required / optional label utilities preserved from Phase 5 */
.form-label.ds-required::after {
    content: "*";
    color: var(--sn-danger);
    margin-left: 2px;
    font-weight: var(--sn-fw-bold);
}
.form-label.ds-optional::after {
    content: " (optional)";
    color: var(--sn-fg-subtle);
    font-weight: var(--sn-fw-regular);
    font-size: 0.85em;
}


/* --- Cards --------------------------------------------------- */
.card {
    background: var(--sn-bg-surface);
    color: var(--sn-fg-primary);
    border: 1px solid var(--sn-border);
    border-radius: var(--sn-r-md);
    box-shadow: none;
    transition: box-shadow var(--sn-t-med) var(--sn-ease),
                border-color var(--sn-t-med) var(--sn-ease),
                transform var(--sn-t-med) var(--sn-ease);
}
.card.shadow-sm { box-shadow: var(--sn-shadow-sm) !important; }
.card.shadow    { box-shadow: var(--sn-shadow-md) !important; }
.card.shadow-lg { box-shadow: var(--sn-shadow-lg) !important; }
.card.border-0  { border-color: transparent !important; }
.card > .card-header,
.card > .card-body,
.card > .card-footer { padding: var(--sn-s-4) var(--sn-s-5); }
.card > .card-header {
    background: transparent;
    border-bottom: 1px solid var(--sn-border);
    color: var(--sn-fg-primary);
    font-weight: var(--sn-fw-semibold);
}
.card > .card-footer {
    background: transparent;
    border-top: 1px solid var(--sn-border);
    color: var(--sn-fg-secondary);
}
.card .card { box-shadow: none !important; }

/* Card hover lift for shadow-sm */
.card.shadow-sm:hover { box-shadow: var(--sn-shadow-md) !important; }
.card[data-tile]:hover, .card.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: var(--sn-shadow-lg) !important;
    border-color: var(--sn-border-strong);
}


/* --- Tables --------------------------------------------------- */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--sn-fg-primary);
    --bs-table-border-color: var(--sn-border-subtle);
    --bs-table-striped-bg: var(--sn-bg-muted);
    --bs-table-striped-color: var(--sn-fg-primary);
    --bs-table-hover-bg: var(--sn-bg-hover);
    --bs-table-hover-color: var(--sn-fg-primary);
    color: var(--sn-fg-primary);
    background: transparent;
    margin-bottom: 0;
}
.table > thead > tr > th {
    background: var(--sn-bg-muted);
    color: var(--sn-fg-muted);
    font-size: var(--sn-fs-xs);
    font-weight: var(--sn-fw-semibold);
    text-transform: uppercase;
    letter-spacing: var(--sn-ls-caps);
    border-bottom: 1px solid var(--sn-border);
    padding: var(--sn-s-3) var(--sn-s-3);
    white-space: nowrap;
}
.table > thead > tr > th a {
    color: var(--sn-fg-muted) !important;
    text-decoration: none;
}
.table > thead > tr > th a:hover { color: var(--sn-fg-primary) !important; }
.table > tbody > tr > td {
    background: var(--sn-bg-surface);
    color: var(--sn-fg-primary);
    border-color: var(--sn-border-subtle);
    padding: var(--sn-s-3) var(--sn-s-3);
    vertical-align: middle;
    font-size: var(--sn-fs-md);
}
.table > tbody > tr > td code {
    background: var(--sn-bg-muted);
    color: var(--sn-fg-primary);
    border-color: var(--sn-border);
}
.table-hover > tbody > tr > td {
    transition: background-color var(--sn-t-fast) var(--sn-ease),
                box-shadow var(--sn-t-fast) var(--sn-ease);
}
.table-hover > tbody > tr:hover > td {
    background: var(--sn-bg-hover);
}
.table-hover > tbody > tr:hover > td:first-child {
    box-shadow: inset 3px 0 0 var(--sn-brand);
}
.table-light,
.table > :not(caption) > * > .table-light {
    --bs-table-bg: var(--sn-bg-muted);
    --bs-table-color: var(--sn-fg-primary);
}
.table thead.table-light { background: transparent; }
.table-striped > tbody > tr:nth-of-type(odd) > td { background: var(--sn-bg-muted); }
.table-bordered { border-color: var(--sn-border); }
.table-bordered > :not(caption) > * > * { border-color: var(--sn-border); }

.table-sm > thead > tr > th,
.table-sm > tbody > tr > td { padding: var(--sn-s-1) var(--sn-s-2); font-size: var(--sn-fs-sm); }


/* --- Badges & chips ------------------------------------------ */
.badge {
    font-family: var(--sn-font-sans);
    font-weight: var(--sn-fw-semibold);
    font-size: 0.72rem;
    letter-spacing: 0.02em;
    padding: 0.35em 0.6em;
    border-radius: var(--sn-r-sm);
}
.bg-primary   { background: var(--sn-brand) !important; color: #fff !important; }
.bg-success   { background: var(--sn-success) !important; color: #fff !important; }
.bg-warning   { background: var(--sn-warning) !important; color: #fff !important; }
.bg-danger    { background: var(--sn-danger) !important;  color: #fff !important; }
.bg-info      { background: var(--sn-info) !important;    color: #fff !important; }
.bg-secondary { background: var(--sn-fg-secondary) !important; color: #fff !important; }
.bg-dark      { background: var(--sn-fg-primary) !important; color: var(--sn-fg-inverse) !important; }
.bg-light     { background: var(--sn-bg-muted) !important; color: var(--sn-fg-primary) !important; }

/* .bg-white / .text-black are Bootstrap LITERAL utilities — they render pure
   white / pure black regardless of theme. In dark mode that leaks white-on-
   white when a view hardcodes e.g. <div class="card-header bg-white"> and
   the child text inherits our themed light-on-dark foreground. Scope the
   override to dark mode only so light mode still gets a literal white when
   someone explicitly asks for it. Same treatment for Bootstrap 5.3's
   .bg-body / .bg-body-tertiary in case a view hardcoded those too. */
[data-theme="dark"] .bg-white,
[data-theme="dark"] .bg-body,
[data-theme="dark"] .bg-body-tertiary {
    background-color: var(--sn-bg-surface) !important;
    color: var(--sn-fg-primary) !important;
}
[data-theme="dark"] .text-black {
    color: var(--sn-fg-primary) !important;
}

.bg-primary-subtle,   .badge.bg-primary-subtle   { background: var(--sn-brand-subtle) !important; }
.bg-success-subtle,   .badge.bg-success-subtle   { background: var(--sn-success-bg) !important; }
.bg-warning-subtle,   .badge.bg-warning-subtle   { background: var(--sn-warning-bg) !important; }
.bg-danger-subtle,    .badge.bg-danger-subtle    { background: var(--sn-danger-bg) !important; }
.bg-info-subtle,      .badge.bg-info-subtle      { background: var(--sn-info-bg) !important; }
.bg-secondary-subtle, .badge.bg-secondary-subtle { background: var(--sn-neutral-bg) !important; }
.bg-dark-subtle,      .badge.bg-dark-subtle      { background: var(--sn-bg-muted) !important; }
.bg-light-subtle,     .badge.bg-light-subtle     { background: var(--sn-bg-muted) !important; }

.text-primary   { color: var(--sn-brand) !important; }
.text-success   { color: var(--sn-success-fg) !important; }
.text-warning   { color: var(--sn-warning-fg) !important; }
.text-danger    { color: var(--sn-danger-fg) !important; }
.text-info      { color: var(--sn-info-fg) !important; }
.text-secondary { color: var(--sn-fg-secondary) !important; }
.text-dark      { color: var(--sn-fg-primary) !important; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: var(--sn-s-1);
    padding: 2px 8px;
    border-radius: var(--sn-r-pill);
    font-size: var(--sn-fs-xs);
    font-weight: var(--sn-fw-medium);
    line-height: 1.5;
    background: var(--sn-neutral-bg);
    color: var(--sn-neutral-fg);
    border: 1px solid var(--sn-neutral-border);
    white-space: nowrap;
}
.chip-success { background: var(--sn-success-bg); color: var(--sn-success-fg); border-color: var(--sn-success-border); }
.chip-warning { background: var(--sn-warning-bg); color: var(--sn-warning-fg); border-color: var(--sn-warning-border); }
.chip-danger  { background: var(--sn-danger-bg);  color: var(--sn-danger-fg);  border-color: var(--sn-danger-border); }
.chip-info    { background: var(--sn-info-bg);    color: var(--sn-info-fg);    border-color: var(--sn-info-border); }


/* --- Alerts --------------------------------------------------- */
.alert {
    background: var(--sn-bg-surface);
    color: var(--sn-fg-primary);
    border: 1px solid var(--sn-border);
    border-left-width: 4px;
    border-radius: var(--sn-r-sm);
    padding: 0.72rem 0.9rem;
    font-size: var(--sn-fs-md);
    box-shadow: var(--sn-shadow-xs);
}
.alert-success { background: var(--sn-success-soft); color: var(--sn-success-fg); border-color: var(--sn-success-border); border-left-color: var(--sn-success); }
.alert-warning { background: var(--sn-warning-soft); color: var(--sn-warning-fg); border-color: var(--sn-warning-border); border-left-color: var(--sn-warning); }
.alert-danger  { background: var(--sn-danger-soft);  color: var(--sn-danger-fg);  border-color: var(--sn-danger-border);  border-left-color: var(--sn-danger); }
.alert-info    { background: var(--sn-info-soft);    color: var(--sn-info-fg);    border-color: var(--sn-info-border);    border-left-color: var(--sn-info); }
.alert-secondary { background: var(--sn-bg-muted); color: var(--sn-fg-secondary); }

.alert .btn-close {
    filter: invert(0);
}
[data-theme="dark"] .alert .btn-close { filter: invert(1) grayscale(1) brightness(2); }


/* --- Modals -------------------------------------------------- */
.modal-content {
    background: var(--sn-bg-elevated);
    color: var(--sn-fg-primary);
    border: 1px solid var(--sn-border);
    border-radius: var(--sn-r-lg);
    box-shadow: var(--sn-shadow-xl);
}
.modal-header {
    background: linear-gradient(180deg, var(--sn-brand-soft), transparent);
    border-bottom: 1px solid var(--sn-border);
    padding: var(--sn-s-4) var(--sn-s-5);
}
.modal-body   { padding: var(--sn-s-5); }
.modal-footer {
    background: var(--sn-bg-muted);
    border-top: 1px solid var(--sn-border);
    padding: var(--sn-s-3) var(--sn-s-5);
}
.modal-title  { color: var(--sn-fg-primary); font-weight: var(--sn-fw-bold); font-size: var(--sn-fs-lg); }
.modal-backdrop.show { background-color: var(--sn-backdrop); opacity: 1; }

/* 2026-09-17 — Fix scrollable modal when a <form> wraps header + body +
   footer. Bootstrap's .modal-dialog-scrollable assumes .modal-header,
   .modal-body, .modal-footer are direct children of .modal-content and
   applies overflow only to .modal-body. When a <form> wraps them the
   scroll container is broken: tall content pushes the footer off-
   screen and Cancel / Save are unreachable. Make the form transparent
   to the flex layout so the internal body-scroll still works. */
.modal-dialog-scrollable .modal-content > form {
    display: flex;
    flex-direction: column;
    max-height: 100%;
    overflow: hidden;
    min-height: 0;
}
.modal-dialog-scrollable .modal-content > form > .modal-body {
    overflow-y: auto;
    min-height: 0;
}
[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(1) brightness(2);
    opacity: 0.8;
}


/* --- Dropdowns ----------------------------------------------- */
.dropdown-menu {
    background: var(--sn-bg-elevated);
    color: var(--sn-fg-primary);
    border: 1px solid var(--sn-border);
    border-radius: var(--sn-r-md);
    box-shadow: var(--sn-shadow-lg);
    padding: var(--sn-s-1);
    font-size: var(--sn-fs-md);
    min-width: 200px;
}
.dropdown-item {
    color: var(--sn-fg-primary);
    padding: 0.42rem 0.7rem;
    border-radius: var(--sn-r-xs);
    font-size: var(--sn-fs-md);
    display: flex;
    align-items: center;
    gap: var(--sn-s-2);
}
.dropdown-item:hover, .dropdown-item:focus {
    background: var(--sn-brand-subtle);
    color: var(--sn-brand);
}
.dropdown-item.text-danger:hover {
    background: var(--sn-danger-bg);
    color: var(--sn-danger-fg);
}
.dropdown-item.disabled, .dropdown-item:disabled { color: var(--sn-fg-subtle); }
.dropdown-header { color: var(--sn-fg-muted); font-size: var(--sn-fs-xs); text-transform: uppercase; letter-spacing: var(--sn-ls-caps); }
.dropdown-divider { border-top-color: var(--sn-border); margin: var(--sn-s-1) 0; }


/* --- Nav-tabs ------------------------------------------------- */
.nav-tabs {
    border-bottom: 1px solid var(--sn-border);
    gap: var(--sn-s-1);
}
.nav-tabs .nav-link {
    color: var(--sn-fg-muted);
    border: 1px solid transparent;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 0.55rem 0.9rem;
    font-weight: var(--sn-fw-medium);
    background: transparent;
    margin-bottom: -1px;
    transition: color var(--sn-t-fast), border-color var(--sn-t-fast);
}
.nav-tabs .nav-link:hover {
    color: var(--sn-fg-primary);
    border-bottom-color: var(--sn-border-strong);
}
.nav-tabs .nav-link.active {
    color: var(--sn-brand);
    background: transparent;
    border: 1px solid transparent;
    border-bottom: 2.5px solid var(--sn-brand);
    font-weight: var(--sn-fw-semibold);
}
.nav-pills .nav-link { color: var(--sn-fg-secondary); border-radius: var(--sn-r-sm); }
.nav-pills .nav-link.active { background: var(--sn-brand); color: var(--sn-brand-fg); }


/* --- Progress ------------------------------------------------- */
.progress {
    background: var(--sn-bg-muted);
    border-radius: var(--sn-r-pill);
    overflow: hidden;
    height: 8px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}
.progress-bar {
    background: var(--sn-brand);
    font-weight: var(--sn-fw-semibold);
    letter-spacing: 0.02em;
    transition: width var(--sn-t-slow) var(--sn-ease-emphasized);
}
.progress-bar.bg-success { background: var(--sn-success) !important; }
.progress-bar.bg-warning { background: var(--sn-warning) !important; }
.progress-bar.bg-danger  { background: var(--sn-danger) !important; }
.progress-bar.bg-secondary { background: var(--sn-neutral-fg) !important; }


/* --- List-group ---------------------------------------------- */
.list-group {
    border-radius: var(--sn-r-md);
    background: var(--sn-bg-surface);
}
.list-group-item {
    background: var(--sn-bg-surface);
    color: var(--sn-fg-primary);
    border-color: var(--sn-border);
    font-size: var(--sn-fs-md);
}
/* Non-active items get the muted hover tint. Excluding .active preserves
   Bootstrap's blue-bg + white-text on the selected item — earlier rule
   made the selected finder result unreadable because it repainted the
   background to near-white on hover while text stayed white. */
.list-group-item:not(.active):hover { background: var(--sn-bg-hover); }
.list-group-item.active,
.list-group-item.active:hover,
.list-group-item.active:focus {
    background-color: var(--sn-brand);
    color: var(--sn-brand-fg);
    border-color: var(--sn-brand);
}


/* --- Pagination ---------------------------------------------- */
.pagination { --bs-pagination-focus-box-shadow: var(--sn-focus-ring); }
.page-link {
    background: var(--sn-bg-surface);
    color: var(--sn-fg-primary);
    border-color: var(--sn-border);
    font-size: var(--sn-fs-sm);
}
.page-link:hover { background: var(--sn-bg-hover); color: var(--sn-brand); border-color: var(--sn-border-strong); }
.page-item.active .page-link {
    background: var(--sn-brand);
    color: var(--sn-brand-fg);
    border-color: var(--sn-brand);
}
.page-item.disabled .page-link { color: var(--sn-fg-subtle); background: var(--sn-bg-muted); }


/* --- Tooltips + popovers ------------------------------------- */
.tooltip .tooltip-inner {
    background: var(--sn-fg-primary);
    color: var(--sn-fg-inverse);
    border-radius: var(--sn-r-sm);
    font-size: var(--sn-fs-xs);
    padding: 0.35rem 0.55rem;
}
.tooltip .tooltip-arrow::before { border-top-color: var(--sn-fg-primary); }
.popover {
    background: var(--sn-bg-elevated);
    border-color: var(--sn-border);
    box-shadow: var(--sn-shadow-lg);
}
.popover-header {
    background: var(--sn-bg-muted);
    color: var(--sn-fg-primary);
    border-bottom-color: var(--sn-border);
    font-size: var(--sn-fs-sm);
    font-weight: var(--sn-fw-semibold);
}
.popover-body { color: var(--sn-fg-primary); font-size: var(--sn-fs-sm); }


/* --- Offcanvas ----------------------------------------------- */
.offcanvas {
    background: var(--sn-bg-elevated);
    color: var(--sn-fg-primary);
    border-left-color: var(--sn-border);
}


/* --- Spinner ------------------------------------------------- */
.spinner-border { color: var(--sn-brand); }


/* ============================================================
   5. ERP SHELL — appbar, sidebar, main, footer. These override
      the older sidebar.css / app.css definitions using tokens.
   ============================================================ */

/* Top app-bar */
.erp-appbar {
    background: var(--sn-appbar-bg) !important;
    box-shadow: var(--sn-appbar-shadow);
    height: var(--sn-appbar-height);
    padding: 0 var(--sn-s-4);
    color: var(--sn-appbar-fg);
    z-index: 1040;
}
.erp-appbar a,
.erp-appbar .nav-link,
.erp-appbar .navbar-brand,
.erp-appbar .fw-semibold,
.erp-appbar .fs-6,
.erp-appbar .text-white-50 { color: var(--sn-appbar-fg) !important; }
.erp-appbar .text-white-50 { color: var(--sn-appbar-fg-muted) !important; }
.erp-appbar .nav-link:hover { color: var(--sn-appbar-fg) !important; opacity: 0.85; }
.erp-appbar-toggler { color: var(--sn-appbar-fg); }
.erp-appbar-toggler:hover { color: var(--sn-appbar-fg); opacity: 0.85; }

.erp-appbar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: var(--sn-appbar-fg);
    transition: opacity var(--sn-t-fast) var(--sn-ease);
}
.erp-appbar-brand:hover { opacity: 0.92; color: var(--sn-appbar-fg); }
.erp-appbar-brand img { height: 34px; width: auto; }

.erp-appbar-product-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: var(--sn-r-sm);
    transition: background var(--sn-t-fast) var(--sn-ease);
}
.erp-appbar-product-chip:hover { background: var(--sn-appbar-control-bg); }
.erp-appbar-product-chip img { height: 28px; }

.erp-session-top {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 4px 10px;
    color: var(--sn-appbar-fg) !important;
    background: var(--sn-appbar-control-bg);
    border-radius: var(--sn-r-pill);
    font-size: var(--sn-fs-xs);
    font-weight: var(--sn-fw-semibold);
    transition: background var(--sn-t-fast) var(--sn-ease);
}
.erp-session-top:hover { background: var(--sn-appbar-control-bg-hover); color: var(--sn-appbar-fg) !important; }
.erp-session-green { color: #a3f0c1 !important; }
.erp-session-yellow { color: #fde68a !important; }
.erp-session-red { color: #fca5a5 !important; }

/* Shell */
.erp-shell { background: var(--sn-bg-app); min-height: 100vh; }

/* Sidebar */
.erp-sidebar {
    width: var(--sn-sidebar-width);
    background: var(--sn-sidebar-bg);
    border-right: 1px solid var(--sn-sidebar-border);
    overflow-y: auto;
    overflow-x: hidden;
    transition: width var(--sn-t-med) var(--sn-ease),
                background var(--sn-t-med) var(--sn-ease);
    flex-shrink: 0;
    position: sticky;
    top: var(--sn-appbar-height);
    height: calc(100vh - var(--sn-appbar-height));
    font-family: var(--sn-font-sans);
}
.erp-sidebar.collapsed { width: var(--sn-sidebar-collapsed); }

.erp-sidebar-toggle {
    background: transparent;
    border-bottom: 1px solid var(--sn-sidebar-border);
    color: var(--sn-sidebar-fg-muted);
    font-size: var(--sn-fs-xs);
    padding: var(--sn-s-2) var(--sn-s-3);
}
.erp-sidebar-toggle:hover { color: var(--sn-brand); background: var(--sn-sidebar-hover-bg); }

.erp-sidebar-dashboard-link {
    background: linear-gradient(135deg, var(--sn-brand-active), var(--sn-brand)) !important;
    color: #fff !important;
    font-weight: var(--sn-fw-semibold);
    padding: 0.75rem var(--sn-s-4);
    border-bottom: 1px solid var(--sn-sidebar-border);
    letter-spacing: -0.005em;
}
.erp-sidebar-dashboard-link:hover, .erp-sidebar-dashboard-link:focus-visible { color: #fff !important; filter: brightness(1.06); }
.erp-sidebar-dashboard-link.active { filter: brightness(0.94); box-shadow: inset 3px 0 0 #fff; }

.erp-sidebar-module { border-bottom: 1px solid var(--sn-sidebar-border); }
.erp-sidebar-module-header {
    color: var(--sn-sidebar-fg);
    padding: 0.6rem var(--sn-s-4);
    font-size: 0.75rem;
    font-weight: var(--sn-fw-semibold);
    text-transform: uppercase;
    letter-spacing: var(--sn-ls-caps);
    background: transparent;
    transition: background var(--sn-t-fast) var(--sn-ease), color var(--sn-t-fast) var(--sn-ease);
}
.erp-sidebar-module-header:hover { background: var(--sn-sidebar-hover-bg); color: var(--sn-sidebar-fg-strong); }
.erp-sidebar-module-header .bi { color: var(--sn-brand); }
.erp-sidebar-module-header .erp-sidebar-caret { color: var(--sn-sidebar-caret); }

.erp-sidebar-link {
    color: var(--sn-sidebar-fg);
    padding: 0.45rem 1rem 0.45rem 2.4rem;
    font-size: var(--sn-fs-sm);
    border-left: 3px solid transparent;
    transition: background var(--sn-t-fast) var(--sn-ease),
                color var(--sn-t-fast) var(--sn-ease),
                box-shadow var(--sn-t-fast) var(--sn-ease);
}
.erp-sidebar-link:hover { background: var(--sn-sidebar-hover-bg); color: var(--sn-sidebar-active-fg); }
.erp-sidebar-link:hover .bi { color: var(--sn-brand); }
.erp-sidebar-link.active {
    background: var(--sn-sidebar-active-bg);
    color: var(--sn-sidebar-active-fg);
    border-left-color: transparent;
    box-shadow: inset 3px 0 0 var(--sn-sidebar-active-bar);
    font-weight: var(--sn-fw-semibold);
}
.erp-sidebar-subgroup-header { color: var(--sn-sidebar-fg); }
.erp-sidebar-subgroup-header:hover { background: var(--sn-sidebar-hover-bg); }

.erp-sidebar-backdrop {
    background: var(--sn-backdrop);
}

/* Sidebar brand block (mobile) */
.erp-sidebar-brand {
    padding: var(--sn-s-3) var(--sn-s-4);
    border-bottom: 1px solid var(--sn-sidebar-border);
    background: var(--sn-sidebar-bg);
}
.erp-sidebar-brand-img { max-height: 32px; width: auto; }
[data-theme="dark"] .erp-sidebar-brand-img.sn-logo-light { display: none; }
[data-theme="light"] .erp-sidebar-brand-img.sn-logo-dark { display: none; }

/* Content main */
.erp-content {
    background: var(--sn-bg-app);
    color: var(--sn-fg-primary);
    padding: var(--sn-s-5);
    min-width: 0;
    flex: 1 1 auto;
}
.erp-footer { color: var(--sn-fg-muted); padding-top: var(--sn-s-6); }
.erp-footer a { color: var(--sn-fg-secondary); }
.erp-footer-brand-img,
.erp-footer-company-img { height: 22px; width: auto; opacity: 0.9; }


/* ============================================================
   6. DS UTILITIES — .ds-* (preserved from Phase 5-9, re-tokenised)
   ============================================================ */

.ds-listpage {
    background: var(--sn-bg-surface);
    border: 1px solid var(--sn-border);
    border-radius: var(--sn-r-md);
    box-shadow: var(--sn-shadow-sm);
    overflow: hidden;
    transition: box-shadow var(--sn-t-med) var(--sn-ease);
}
.ds-listpage:hover { box-shadow: var(--sn-shadow-md); }
.ds-listpage-filter {
    padding: var(--sn-s-3) var(--sn-s-4);
    background: var(--sn-bg-muted);
    border-bottom: 1px solid var(--sn-border);
    display: flex; flex-wrap: wrap; gap: var(--sn-s-3); align-items: flex-end;
}
.ds-listpage-filter .form-label { margin-bottom: 2px; }
.ds-listpage-filter > .row { width: 100%; margin: 0; }
.ds-listpage-filter > form { flex: 1 1 100%; }
.ds-listpage-table { background: var(--sn-bg-surface); }
.ds-listpage-footer {
    padding: var(--sn-s-2) var(--sn-s-4);
    background: var(--sn-bg-surface);
    border-top: 1px solid var(--sn-border);
    display: flex; justify-content: space-between; align-items: center;
    font-size: var(--sn-fs-sm);
    color: var(--sn-fg-secondary);
    gap: var(--sn-s-3);
    flex-wrap: wrap;
}

.ds-density-cozy > table > tbody > tr > td { padding: var(--sn-s-3) var(--sn-s-3); }
.ds-density-compact > table > tbody > tr > td { padding: 4px var(--sn-s-2); font-size: var(--sn-fs-sm); line-height: 1.35; }
.ds-density-compact > table > thead > tr > th { padding: 4px var(--sn-s-2); }
.ds-density-toggle {
    display: inline-flex; align-items: center; gap: var(--sn-s-1);
    padding: 3px 8px;
    font-size: var(--sn-fs-xs);
    color: var(--sn-fg-secondary);
    border: 1px solid var(--sn-border);
    border-radius: var(--sn-r-sm);
    background: var(--sn-bg-surface);
    cursor: pointer;
    transition: background var(--sn-t-fast) var(--sn-ease), color var(--sn-t-fast) var(--sn-ease), border-color var(--sn-t-fast) var(--sn-ease);
}
.ds-density-toggle:hover { background: var(--sn-bg-hover); color: var(--sn-brand); border-color: var(--sn-brand); }
.ds-density-toggle .bi { font-size: 0.875em; }

.ds-section-header {
    display: flex; align-items: center; gap: var(--sn-s-3);
    margin: var(--sn-s-6) 0 var(--sn-s-3);
    padding-left: var(--sn-s-4);
    position: relative;
}
.ds-section-header::before {
    content: "";
    position: absolute;
    left: 0; top: 6px; bottom: 6px;
    width: 4px;
    border-radius: 2px;
    background: linear-gradient(180deg, var(--sn-brand), var(--sn-brand-hover));
}
.ds-section-header .ds-section-title {
    font-size: var(--sn-fs-xl);
    font-weight: var(--sn-fw-bold);
    color: var(--sn-fg-primary);
    letter-spacing: var(--sn-ls-snug);
    margin: 0;
}
.ds-section-header .ds-section-sub {
    color: var(--sn-fg-muted);
    font-size: var(--sn-fs-sm);
}

.ds-empty {
    text-align: center;
    padding: var(--sn-s-8) var(--sn-s-4);
    color: var(--sn-fg-secondary);
}
.ds-empty > .bi {
    font-size: 2.25rem;
    width: 88px; height: 88px;
    border-radius: 50%;
    background: var(--sn-brand-subtle);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto var(--sn-s-3);
    color: var(--sn-brand);
}
.ds-empty-title { font-size: var(--sn-fs-lg); font-weight: var(--sn-fw-semibold); color: var(--sn-fg-primary); margin-bottom: var(--sn-s-2); }
.ds-empty-sub { font-size: var(--sn-fs-sm); color: var(--sn-fg-muted); max-width: 42ch; margin: 0 auto var(--sn-s-4); }

.ds-attention-strip {
    display: flex; flex-wrap: wrap; gap: var(--sn-s-3);
    background: linear-gradient(120deg, var(--sn-attention-bg-1) 0%, var(--sn-attention-bg-2) 100%);
    border: 1px solid var(--sn-attention-border);
    border-radius: var(--sn-r-lg);
    padding: var(--sn-s-3) var(--sn-s-4);
    margin-bottom: var(--sn-s-4);
    box-shadow: var(--sn-shadow-xs);
}
.ds-attention-strip .ds-attention-item {
    display: flex; align-items: center; gap: var(--sn-s-2);
    padding: var(--sn-s-1) var(--sn-s-3);
    background: var(--sn-bg-surface);
    border-radius: var(--sn-r-sm);
    font-size: var(--sn-fs-sm);
    color: var(--sn-fg-primary);
    text-decoration: none;
    border: 1px solid var(--sn-border);
    transition: transform var(--sn-t-fast) var(--sn-ease), box-shadow var(--sn-t-fast) var(--sn-ease);
}
.ds-attention-strip .ds-attention-item:hover {
    transform: translateY(-1px);
    box-shadow: var(--sn-shadow-sm);
    color: var(--sn-fg-primary);
}
.ds-attention-strip .ds-attention-item .bi { font-size: 1.1rem; color: var(--sn-attention-fg); flex-shrink: 0; }
.ds-attention-strip .ds-attention-item .ds-attention-count {
    font-weight: var(--sn-fw-bold);
    color: var(--sn-attention-fg);
    font-size: var(--sn-fs-lg);
    line-height: 1;
}
.ds-attention-strip .ds-attention-item .ds-attention-label {
    color: var(--sn-fg-muted);
    font-size: var(--sn-fs-xs);
    text-transform: uppercase;
    letter-spacing: var(--sn-ls-wide);
}
.ds-attention-empty { color: var(--sn-fg-secondary); font-size: var(--sn-fs-sm); padding: var(--sn-s-1) var(--sn-s-3); }

.ds-skeleton {
    display: inline-block;
    background: linear-gradient(90deg, var(--sn-bg-muted) 0%, var(--sn-bg-hover) 50%, var(--sn-bg-muted) 100%);
    background-size: 200% 100%;
    animation: ds-shimmer 1.4s ease-in-out infinite;
    border-radius: var(--sn-r-sm);
    height: 1em;
    min-width: 60px;
    color: transparent;
    user-select: none;
}
@keyframes ds-shimmer {
    from { background-position: 200% 0; }
    to   { background-position: -200% 0; }
}
.ds-skeleton.h-24 { height: 24px; }
.ds-skeleton.w-25 { width: 25%; }
.ds-skeleton.w-50 { width: 50%; }
.ds-skeleton.w-75 { width: 75%; }

.ds-toast-container {
    position: fixed;
    top: calc(var(--sn-appbar-height) + 12px);
    right: 20px;
    z-index: 1080;
    display: flex; flex-direction: column; gap: var(--sn-s-2);
    pointer-events: none;
    max-width: min(360px, calc(100vw - 40px));
}
.ds-toast {
    background: var(--sn-bg-elevated);
    color: var(--sn-fg-primary);
    border: 1px solid var(--sn-border);
    border-left: 3px solid var(--sn-info);
    border-radius: var(--sn-r-sm);
    padding: var(--sn-s-2) var(--sn-s-3);
    box-shadow: var(--sn-shadow-lg);
    font-size: var(--sn-fs-sm);
    display: flex; align-items: center; gap: var(--sn-s-2);
    animation: ds-toast-in var(--sn-t-med) var(--sn-ease-emphasized) both;
    pointer-events: auto;
}
.ds-toast.ds-toast-success { border-left-color: var(--sn-success); }
.ds-toast.ds-toast-warning { border-left-color: var(--sn-warning); }
.ds-toast.ds-toast-danger  { border-left-color: var(--sn-danger); }
@keyframes ds-toast-in {
    from { opacity: 0; transform: translate3d(10px, -6px, 0); }
    to   { opacity: 1; transform: translate3d(0, 0, 0); }
}

.ds-icon-lead { display: inline-flex; align-items: center; gap: var(--sn-s-2); }

.ds-icon-halo {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px;
    border-radius: var(--sn-r-md);
    background: var(--sn-brand-subtle);
    color: var(--sn-brand);
    font-size: 1.1rem;
    flex-shrink: 0;
}
.ds-icon-halo-lg { width: 56px; height: 56px; font-size: 1.5rem; border-radius: var(--sn-r-lg); }
.ds-icon-halo-success { background: var(--sn-success-bg); color: var(--sn-success-fg); }
.ds-icon-halo-warning { background: var(--sn-warning-bg); color: var(--sn-warning-fg); }
.ds-icon-halo-danger  { background: var(--sn-danger-bg);  color: var(--sn-danger-fg); }
.ds-icon-halo-info    { background: var(--sn-info-bg);    color: var(--sn-info-fg); }
.ds-icon-halo-neutral { background: var(--sn-neutral-bg); color: var(--sn-neutral-fg); }

.ds-eyebrow {
    text-transform: uppercase;
    letter-spacing: var(--sn-ls-caps);
    font-size: 0.7rem;
    font-weight: var(--sn-fw-semibold);
    color: var(--sn-fg-muted);
}

/* KPI dashboard tiles — bigger, tighter numbers */
.card[data-tile] .card-body .h4 {
    font-size: 1.85rem;
    font-weight: var(--sn-fw-bold);
    line-height: 1.15;
    letter-spacing: var(--sn-ls-tight);
    color: var(--sn-fg-primary);
    margin-bottom: 2px;
}
.card[data-tile] .card-body > div:last-child > .small.text-muted:first-child {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: var(--sn-fw-semibold);
    color: var(--sn-fg-muted) !important;
}
.erp-stat-icon {
    width: 52px; height: 52px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--sn-r-lg);
    font-size: 1.5rem;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
    transition: transform var(--sn-t-fast) var(--sn-ease);
    flex-shrink: 0;
}
[data-theme="dark"] .erp-stat-icon { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06); }
.card[data-tile]:hover .erp-stat-icon { transform: scale(1.06) rotate(-2deg); }


/* ============================================================
   7. SN-THEME-SWITCHER — three-state segmented control
   ============================================================ */
.sn-theme-switcher {
    display: inline-flex;
    background: var(--sn-appbar-control-bg);
    border-radius: var(--sn-r-pill);
    padding: 3px;
    gap: 2px;
    border: 1px solid rgba(255, 255, 255, 0.10);
}
.sn-theme-switcher button {
    background: transparent;
    color: var(--sn-appbar-fg-muted);
    border: 0;
    border-radius: var(--sn-r-pill);
    padding: 4px 9px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: var(--sn-fw-semibold);
    transition: background var(--sn-t-fast) var(--sn-ease), color var(--sn-t-fast) var(--sn-ease);
    line-height: 1;
}
.sn-theme-switcher button:hover { color: var(--sn-appbar-fg); background: rgba(255, 255, 255, 0.08); }
.sn-theme-switcher button[aria-pressed="true"] {
    background: rgba(255, 255, 255, 0.22);
    color: #ffffff;
}
.sn-theme-switcher button .bi { font-size: 0.95em; }
.sn-theme-switcher button .sn-theme-switcher-label { display: none; }
@media (min-width: 992px) {
    .sn-theme-switcher button .sn-theme-switcher-label { display: inline; }
}

/* Login-page variant (renders on a light OR dark surface, not the appbar) */
.sn-theme-switcher.sn-theme-switcher-local {
    background: var(--sn-bg-muted);
    border-color: var(--sn-border);
}
.sn-theme-switcher.sn-theme-switcher-local button { color: var(--sn-fg-muted); }
.sn-theme-switcher.sn-theme-switcher-local button:hover { color: var(--sn-fg-primary); background: var(--sn-bg-hover); }
.sn-theme-switcher.sn-theme-switcher-local button[aria-pressed="true"] {
    background: var(--sn-bg-surface);
    color: var(--sn-brand);
    box-shadow: var(--sn-shadow-xs);
}


/* ============================================================
   8. LOGO SWAP — theme-aware. Add class="sn-logo-light" for the
      light-bg variant, "sn-logo-dark" for the dark-bg (blue)
      variant, and both show/hide based on the active theme.
   ============================================================ */
[data-theme="dark"] .sn-logo-light { display: none !important; }
[data-theme="light"] .sn-logo-dark { display: none !important; }


/* ============================================================
   8b. LOGIN PAGE — token-driven overrides + polish
   ============================================================ */
.sn-login-theme-toolbar {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1050;
}
@media (max-width: 575.98px) {
    .sn-login-theme-toolbar { top: 10px; right: 10px; }
}

/* Body background — sophisticated ambient wash in both themes.
   Light: cool white with brand + accent glows. Dark: deep navy with
   subtle brand halo (no glowing hotspots). */
.erp-login-body {
    background:
        radial-gradient(1400px 700px at 12% -12%, rgba(11, 92, 171, 0.09), transparent 55%),
        radial-gradient(1000px 550px at 100% 110%, rgba(245, 158, 11, 0.07), transparent 50%),
        var(--sn-bg-app) !important;
}
[data-theme="dark"] .erp-login-body {
    background:
        radial-gradient(1600px 800px at 12% -12%, rgba(107, 168, 245, 0.10), transparent 55%),
        radial-gradient(1200px 600px at 100% 110%, rgba(107, 168, 245, 0.06), transparent 50%),
        var(--sn-bg-app) !important;
}

/* Sign-in card — token-driven so it flips with the theme */
.erp-login-card {
    background: var(--sn-bg-surface) !important;
    border: 1px solid var(--sn-border) !important;
    box-shadow: var(--sn-shadow-xl) !important;
    border-radius: var(--sn-r-lg) !important;
    color: var(--sn-fg-primary);
}
.erp-login-card .brand-lockup .name { color: var(--sn-fg-primary); font-weight: var(--sn-fw-bold); }
.erp-login-card .brand-lockup .code { color: var(--sn-fg-muted); font-size: var(--sn-fs-sm); }
.erp-login-card .brand-lockup img {
    background: var(--sn-bg-surface) !important;
    border-color: var(--sn-border) !important;
}
.erp-login-card .brand-lockup-divider {
    background: linear-gradient(90deg, transparent, var(--sn-border), transparent) !important;
    height: 1px !important;
    width: 60% !important;
    margin: 6px auto !important;
}

/* Sign-in headline — bump it so it reads as the primary anchor */
.erp-login-card h2.h5 {
    font-size: 1.35rem;
    font-weight: var(--sn-fw-bold);
    letter-spacing: var(--sn-ls-snug);
    color: var(--sn-fg-primary);
    margin-bottom: 4px;
}
.erp-login-card p.text-muted {
    color: var(--sn-fg-muted);
    font-size: var(--sn-fs-md);
}

/* Sign-in form inputs get a slightly beefier feel */
.erp-login-form .form-control { padding: 0.55rem 0.85rem; font-size: var(--sn-fs-base); }
.erp-login-form .form-control.has-pw-toggle { padding-right: 2.6rem; }
.erp-login-form .input-icon {
    position: relative;
}
.erp-login-form .input-icon > .bi:first-child {
    position: absolute;
    left: 12px; top: 50%;
    transform: translateY(-50%);
    color: var(--sn-fg-muted);
    font-size: 1rem;
    pointer-events: none;
    z-index: 2;
}
.erp-login-form .input-icon > .form-control { padding-left: 2.4rem; }
.erp-login-form .input-icon > .input-pw-toggle {
    position: absolute;
    right: 8px; top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: 0;
    color: var(--sn-fg-muted);
    padding: 4px 6px;
    border-radius: var(--sn-r-xs);
    z-index: 2;
    cursor: pointer;
}
.erp-login-form .input-icon > .input-pw-toggle:hover { color: var(--sn-brand); background: var(--sn-bg-muted); }

/* Primary sign-in button — full width, generous */
.erp-login-form .btn-primary {
    width: 100%;
    padding: 0.65rem 1rem;
    font-size: var(--sn-fs-lg);
    font-weight: var(--sn-fw-semibold);
    border-radius: var(--sn-r-sm);
}

/* Brand panel (left) — same on both themes since it's the brand identity.
   Just refine the animated orbs to be gentler + refine the shadow. */
.erp-login-brand {
    background: linear-gradient(135deg, #063265 0%, var(--sn-brand) 55%, #1e7bd0 100%) !important;
    box-shadow: var(--sn-shadow-xl) !important;
    border-radius: var(--sn-r-xl) !important;
}
[data-theme="dark"] .erp-login-brand {
    background: linear-gradient(135deg, #05122a 0%, #0a3672 55%, #1466c4 100%) !important;
    box-shadow: 0 20px 40px -20px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.03) inset !important;
}
.erp-login-brand h1 {
    font-family: var(--sn-font-sans);
    letter-spacing: var(--sn-ls-tight);
    font-weight: var(--sn-fw-bold);
    font-size: clamp(1.75rem, 2.6vw, 2.4rem);
}
.erp-login-brand p.tagline {
    font-family: var(--sn-font-sans);
    line-height: var(--sn-lh-normal);
}
.erp-login-brand .brand-highlights .hi .fw-semibold { font-weight: var(--sn-fw-semibold); }

/* Footer note under sign-in card */
.erp-login-shell > main > p.text-muted {
    color: var(--sn-fg-muted) !important;
    font-size: var(--sn-fs-sm);
}


/* ============================================================
   8c. LEGACY OVERRIDES — hardcoded #fff / #f8fafc in app.css that
       need to flip in dark theme. Kept surgical.
   ============================================================ */

/* Footer — legacy .erp-footer { background: #fff; } → theme-aware. */
.erp-footer { background: transparent !important; border-top-color: var(--sn-border) !important; }

/* Institute-picker card + search input on the public shell */
.erp-institute-card {
    background: var(--sn-bg-surface) !important;
    border-color: var(--sn-border) !important;
    color: var(--sn-fg-primary) !important;
}
.erp-institute-card:hover,
.erp-institute-card:focus-visible {
    border-color: var(--sn-brand) !important;
    box-shadow: var(--sn-shadow-md) !important;
}
.erp-institute-card .name { color: var(--sn-fg-primary) !important; }
.erp-institute-card .desc { color: var(--sn-fg-muted) !important; }
.erp-institute-card img {
    background: var(--sn-bg-surface) !important;
    border-color: var(--sn-border) !important;
}
.erp-institute-search .form-control { background: var(--sn-bg-surface) !important; }

/* Attendance roster card (used by mass-marking screens) */
.att-roster-card {
    background: var(--sn-bg-surface) !important;
    border-color: var(--sn-border) !important;
    color: var(--sn-fg-primary) !important;
}
.att-roster-card:hover { background: var(--sn-bg-hover) !important; }

/* Sortable table header hover — subtle brand tint that works both themes */
.sortable-table > thead > tr > th.sortable-th:hover {
    background: var(--sn-bg-hover) !important;
    color: var(--sn-fg-primary) !important;
}

/* Sidebar (legacy hardcoded #fff in sidebar.css) — already handled
   by our .erp-sidebar rule above, but layer !important as a safety
   in case of specificity fights. */
.erp-sidebar { background: var(--sn-sidebar-bg) !important; border-right-color: var(--sn-sidebar-border) !important; }

/* 2026-09-06 — horizontal SackNova wordmark sizing overrides. The
   previous vertical/near-square SVG was ~1.44:1; the horizontal
   variant is much wider (~4:1) so height-only sizing lets it
   stretch too wide. Cap height + generous max-width per slot. */

/* Login left brand-panel hero: horizontal wordmark reads best as
   a compact chunk that respects the panel's vertical rhythm. */
.erp-login-brand-hero-img.on-blue {
    height: 72px !important;
    max-width: 320px !important;
    width: auto !important;
    margin: 0 0 1.5rem !important;
    display: block !important;
}

/* Top app-bar product chip: horizontal wordmark needs more width. */
.erp-appbar-product-chip .erp-login-brand-hero-img,
.erp-appbar-product-chip img.erp-login-brand-hero-img {
    height: 34px !important;
    max-width: 180px !important;
    width: auto !important;
    margin: 0 !important;
}

/* SuperAdmin welcome banner — real horizontal wordmark on the always-blue
   .erp-welcome gradient. Sized so it echoes the SackNova mark in the
   appbar without dominating the greeting. */
.erp-welcome-brand-img {
    height: 44px;
    max-width: 220px;
    width: auto;
    object-fit: contain;
    display: block;
    opacity: 0.95;
}

/* 2026-09-06 — Dashboard "My Widgets" — dashboard-widgets.css had
   hardcoded #212529 title, #6c757d divider, and white card header
   which all disappeared or lost contrast in dark theme. Override
   to tokens so both themes read cleanly. */
.dwg-section-divider {
    color: var(--sn-fg-muted) !important;
}
.dwg-section-divider::before,
.dwg-section-divider::after {
    background: var(--sn-border) !important;
}
.dwg-section-label {
    color: var(--sn-fg-secondary) !important;
    font-weight: var(--sn-fw-semibold);
    letter-spacing: var(--sn-ls-caps);
}
.dwg-card { border-color: var(--sn-border) !important; }
.dwg-card-header {
    background: var(--sn-bg-surface) !important;
    border-bottom-color: var(--sn-border) !important;
    color: var(--sn-fg-primary) !important;
}
.dwg-card-placeholder .dwg-card-header {
    background: var(--sn-bg-muted) !important;
}
.dwg-title {
    color: var(--sn-fg-primary) !important;
    font-weight: var(--sn-fw-semibold);
}
.dwg-title .bi { color: var(--sn-brand); }
.dwg-card-body { color: var(--sn-fg-primary); }
.dwg-table th, .dwg-table td { color: var(--sn-fg-primary); }
.dwg-table th { color: var(--sn-fg-muted); }


/* ============================================================
   8b. MOBILE RESET (2026-09-17) — win-over-base media rules
   ============================================================
   design-system.css loads AFTER sidebar.css, so the base
   `.erp-sidebar { position: sticky; height: 90vh; width: 264px; }`
   at section 5 was silently overriding the mobile `position: fixed;
   translateX(-100%)` written in sidebar.css. Symptom: on <lg
   viewports the sidebar sat IN FLOW at 90vh, pushing main content a
   full viewport-height below the appbar (see screenshot 2026-09-17).
   Re-apply the mobile overrides here so they win by source-order.
   ============================================================ */
@media (max-width: 991.98px) {
    .erp-shell-row {
        display: block;
        min-height: 0;
    }
    .erp-sidebar {
        position: fixed;
        top: var(--sn-appbar-height);
        left: 0;
        height: calc(100vh - var(--sn-appbar-height));
        width: var(--sn-sidebar-width);
        transform: translateX(-100%);
        z-index: 1050;
        box-shadow: 2px 0 8px rgba(0,0,0,0.15);
    }
    .erp-sidebar.mobile-open {
        transform: translateX(0);
    }
    .erp-content {
        width: 100%;
        max-width: 100vw;
        min-width: 0;
        margin-left: 0;
        flex: none;
        padding: 1rem;
    }
    .erp-sidebar-toggle { display: none; }
}
@media (max-width: 575.98px) {
    /* Phone — cinch the modal footer so Cancel + Save don't clip off
       the right edge on a narrow viewport. Bootstrap defaults to
       flex-wrap: nowrap and design-system's own padding is roomy. */
    .modal-footer {
        flex-wrap: wrap;
        row-gap: 0.5rem;
        padding: 0.75rem 1rem;
    }
    .modal-footer > .btn { flex: 1 1 auto; min-width: 0; }
    .modal-body   { padding: 0.75rem 1rem; }
    .modal-header { padding: 0.75rem 1rem; }
    .modal-dialog.modal-lg,
    .modal-dialog.modal-xl {
        margin: 0.5rem;
        max-width: calc(100vw - 1rem);
    }
}

/* ============================================================
   9. PRINT — kill dark theme + all interactive states for paper
   ============================================================ */
@media print {
    :root, [data-theme="dark"] {
        --sn-bg-app: #fff;
        --sn-bg-surface: #fff;
        --sn-bg-muted: #fff;
        --sn-bg-hover: #fff;
        --sn-fg-primary: #000;
        --sn-fg-secondary: #333;
        --sn-fg-muted: #555;
        --sn-border: #ccc;
    }
    body, html { background: #fff !important; color: #000 !important; }
    .card, .table, .ds-listpage { box-shadow: none !important; }
    .erp-appbar, .erp-sidebar, .erp-sidebar-backdrop { display: none !important; }
    .card[data-tile]:hover, .card.shadow-sm:hover,
    .table-hover > tbody > tr:hover > td { transform: none !important; box-shadow: none !important; background: transparent !important; }
}
