/* ────────────────────────────────────────────────────────────────────
   theme-rateexceptions-v2 — sunstate@rates tenant theme

   Parent: system-base-theme (declares canonical tokens + light defaults +
   :root[data-theme="dark"] overrides + @font-face for Inter + JetBrains
   Mono with metric-tuned Fallback families for CLS=0).

   This file declares ONLY tenant brand overrides on TOP of canonical
   tokens. Per .claude/rules/26b-site-authoring-with-blueprints.md §2:
     - NEVER alias `--theme_*` tokens (parent doesn't define them; the
       alias resolves to "" and every consumer paints unstyled)
     - NEVER re-declare canonical greys/spacing/radius/shadows — they
       cascade from system-base-theme
     - DO override the brand-specific tokens (--accent, --accent-secondary)
       and any tenant-specific surface tone
   ──────────────────────────────────────────────────────────────────── */

:root {
  /* ─── Tenant brand ─────────────────────────────────────────────── */
  --accent:                 #1b2a4a;    /* Sunstate navy — chrome bar, submit buttons */
  --accent-hover:           #16223d;
  --accent-active:          #111a2e;
  --accent-soft:            #dbeafe;
  --on-accent:              #ffffff;

  --accent-secondary:       #e86a1a;    /* warm orange — active state, focus rings */
  --accent-secondary-hover: #c95a14;
  --accent-secondary-soft:  #fdebdc;
  --on-accent-secondary:    #ffffff;

  /* ─── Tenant surface tone (slight cool tint) ───────────────────── */
  --surface-base:           #f5f6fa;    /* canonical default is #FAFAFA — tenant prefers cool */

  /* ─── Chart palette (light) ─────────────────────────────────────
     Chart.js needs resolved hex; pages call
     getComputedStyle(document.documentElement).getPropertyValue('--chart-N')
     and pass into dataset.backgroundColor. See plan §7 + per-page
     bootstrap pattern. */
  --chart-1: #1b2a4a;     /* navy   — series 1 */
  --chart-2: #e86a1a;     /* orange — series 2 */
  --chart-3: #15803d;     /* green  — series 3 */
  --chart-4: #b45309;     /* amber  — series 4 */
  --chart-5: #1d4ed8;     /* blue   — series 5 */
  --chart-6: #7c3aed;     /* violet — series 6 */
  --chart-axis:        var(--border-default);
  --chart-grid:        var(--border-subtle);
  --chart-tooltip-bg:  var(--surface-raised);
  --chart-tooltip-fg:  var(--text-primary);

  /* ─── Brand navy as text-on-dark fallback ───────────────────────
     Pages that paint `color: var(--accent)` on dark surfaces get
     near-invisible navy. Use --accent-on-dark for that case. In
     light mode it resolves to the same navy. */
  --accent-on-dark:    #1b2a4a;

  /* ─── Tenant typography sizing ──────────────────────────────────
     Parent system-base-theme already declares the font-families
     (Inter / JetBrains Mono / Source Serif 4) with self-hosted
     @font-face + metric fallbacks. We only adjust the base body
     size to match the rates app's dense-data layout convention. */

  /* ─── Page-local rate-matrix tints ───────────────────────────────
     Used by rate-detail-rates-tab `.rxd-rates-table-region`. Declared
     here (tenant theme — NOT page-scoped) so the [data-theme="dark"]
     override below can match — page-CSS selectors get prefixed with
     [data-cmp="UID"] by the template-CSS scoping processor, which
     breaks [data-theme="dark"] rules that target <html>. */
  --rxd-active-tint:   #fffbf6;     /* ACTIVE RATES — orange tint */
  --rxd-proposed-tint: #f6fff6;     /* PROPOSED RATES — green tint */
  /* Zebra-stripe + row-hover overlays (2026-06-01 per Victor). Applied as a
     background-image gradient layered OVER the column tints, so striping/hover
     stay consistent across tinted AND untinted columns. Light theme darkens;
     the [data-theme="dark"] block below lightens. */
  --rxd-row-stripe:    rgba(15, 23, 42, 0.03);  /* even-row darkening — kept very subtle per Victor */
  --rxd-row-hover:     rgba(15, 23, 42, 0.09);  /* subtle gray hover */
  --rxd-row-hover-bar: rgba(15, 23, 42, 0.22);  /* thin left affordance */

  /* ─── TEMPORARY: --theme_* forwarding aliases ────────────────────
     13 pages still reference `var(--theme_X, #fallback)`. These
     resolved to "" (empty) before, so pages painted the fallback
     hex unconditionally — no theme adaptation. The forwarding
     declarations below restore theme adaptation while pages migrate.

     Plan §9 risk mitigation: keep aliases as forwarding for ONE
     push, then rewrite pages in Wave B/D, then delete this block.
     DO NOT add new --theme_* references — they are BANNED per
     26b-site-authoring-with-blueprints.md §2.11. */
  --theme_bg_card:              var(--surface-card);
  --theme_bg_subtle:            var(--surface-subtle);
  --theme_border:               var(--border-default);
  --theme_border_subtle:        var(--border-subtle);
  --theme_color_accent:         var(--accent-secondary);
  --theme_color_danger:         var(--danger);
  --theme_color_danger_hover:   var(--danger-hover);
  --theme_color_danger_subtle:  var(--danger-soft);
  --theme_color_primary:        var(--accent);
  --theme_color_primary_hover:  var(--accent-hover);
  --theme_color_primary_subtle: var(--accent-soft);
  --theme_text:                 var(--text-primary);
  --theme_text_muted:           var(--text-muted);
}

/* ────────────────────────────────────────────────────────────────────
   Dark-mode brand overrides

   Canonical surface / text / border / semantic-soft / shadow tokens
   cascade from system-base-theme's :root[data-theme="dark"] block
   (lines 342–401). We re-tone ONLY the brand-specific tokens:

     - --accent-soft: dark navy-tinted soft surface (canonical override
       is #1f2937 — generic dark; the tenant prefers a navy hint)
     - --accent-on-dark: sky-300 — replaces navy for text-on-dark use
       cases. Pages using --accent as `color` should switch to this.
       Pages using --accent as `background` keep navy (chrome stays
       brand-consistent).
     - --chart-*: re-bind to a chart-friendly dark palette. Series
       must remain distinguishable + readable against #161b22 card bg.
   ──────────────────────────────────────────────────────────────────── */
:root[data-theme="dark"] {
  /* Brand soft surfaces — tenant-tuned */
  --accent-soft:             #1e293b;       /* slate-tinted dark */
  --accent-secondary-soft:   rgba(232, 106, 26, 0.18);

  /* Text-on-dark accent — sky-300 ≥7:1 contrast on --surface-card */
  --accent-on-dark:          #93c5fd;

  /* Chart palette — saturation bumped so dark cards don't swallow series */
  --chart-1: #93c5fd;       /* sky    — was navy */
  --chart-2: #fbbf24;       /* amber  — was orange */
  --chart-3: #34d399;       /* mint   — was green */
  --chart-4: #fb923c;       /* peach  — was amber */
  --chart-5: #818cf8;       /* indigo — was blue */
  --chart-6: #c084fc;       /* fuchsia — was violet */

  /* Rate-matrix tints — warm/cool dark slates, ≥4.5:1 with --text-primary */
  --rxd-active-tint:   #33271a;     /* ACTIVE RATES — warm orange-slate (dark) */
  --rxd-proposed-tint: #1e2a1f;     /* PROPOSED RATES — cool forest-slate (dark) */
  /* Stripe/hover overlays LIGHTEN on dark theme (see light block above). */
  --rxd-row-stripe:    rgba(255, 255, 255, 0.035); /* very subtle on the dark base per Victor */
  --rxd-row-hover:     rgba(255, 255, 255, 0.10);
  --rxd-row-hover-bar: rgba(255, 255, 255, 0.24);

  /* TEMPORARY --theme_* dark overrides — same disclaimer as :root.
     Re-tone --theme_color_primary so navy-as-text on dark surfaces
     becomes readable. Pages using it as BACKGROUND now paint sky
     instead of navy — acceptable trade-off; pages get rewritten in
     Wave B/D to use --accent (background) vs --accent-on-dark (text)
     explicitly, then this block disappears. */
  --theme_color_primary:        var(--accent-on-dark);
  --theme_color_primary_hover:  #60a5fa;       /* sky-400 */
  --theme_color_primary_subtle: var(--accent-soft);
}

/* ────────────────────────────────────────────────────────────────────
   color-scheme — tells the browser to use its dark UA styles for native
   controls when `data-theme="dark"`. Without this, native widgets like
   <input type="date">'s popup calendar, <select> dropdowns, scrollbars,
   form-validation tooltips, and autofill chrome render in OS-default
   LIGHT styling even on a dark page — leading to white-popup-on-dark
   bug the user reported on the ACTIVATE DATE picker (Image #16).

   The light-mode default is `light`; the dark-mode override triggers
   the browser's dark UA forms. */
:root              { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* ────────────────────────────────────────────────────────────────────
   Section B — Reset + body
   Parent system-base-theme already sets html/body bg+color+font from
   tokens. Repeat here because we override the body --font-size for
   the dense-data layout, and a fresh body { ... } block is the only
   way to add font-size without reaching for !important.
   ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--surface-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ────────────────────────────────────────────────────────────────────
   Section C — Base typography
   ──────────────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  margin: 0;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-weight: 600;
  letter-spacing: -0.01em;
}
h1 { font-size: 22px; line-height: 1.2; }
h2 { font-size: 18px; line-height: 1.25; }
h3 { font-size: 16px; line-height: 1.3; }
h4 { font-size: 14px; line-height: 1.35; font-weight: 600; }
h5 { font-size: 13px; line-height: 1.4; font-weight: 600; }
h6 {
  font-size: 12px; line-height: 1.4; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted);
}

p { margin: 0; line-height: 1.5; }
small { font-size: 12px; color: var(--text-muted); }
strong, b { font-weight: 600; }
em, i { font-style: italic; }
ul, ol { margin: 0; padding-left: 20px; }
li { line-height: 1.55; }
a { color: var(--accent-secondary); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre {
  font-family: var(--font-mono);
  font-size: 12.5px;
}
code {
  background: var(--surface-subtle);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  color: var(--accent-secondary);
}
pre {
  background: var(--surface-subtle);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 12px;
  overflow-x: auto;
  line-height: 1.45;
}

/* ────────────────────────────────────────────────────────────────────
   Section D — Base form elements
   (Most forms render via blueprints; these rules cover plain HTML.)

   CRITICAL: `<input>` and `<textarea>` browser-default text color is
   `#000` and IGNORES the inherited `color` from body unless EVERY
   `<input>`/`<textarea>` selector explicitly sets `color`. Without
   this, dark mode renders invisible black-on-dark text. Same for
   `::placeholder` — browser default is a grayed text color which
   becomes near-invisible on the dark surface. Cover both with the
   universal selectors below.
   ──────────────────────────────────────────────────────────────────── */
input, select, textarea, button {
  font-family: inherit;
  font-size: inherit;
  color: var(--text-primary);
}
input::placeholder,
textarea::placeholder,
select::placeholder {
  color: var(--text-muted);
  opacity: 1;     /* Firefox default is 0.54; force consistent across browsers */
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="tel"],
input[type="url"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="month"],
input[type="week"],
textarea,
select {
  background: var(--surface-card);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
/* Native date / time / select pickers inherit OS-level chrome. Without
   `color-scheme` set, the popup calendar + dropdown options paint white
   on dark page even when the input itself is dark. Setting color-scheme
   per-element triggers the browser's dark UA chrome for the popup. */
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="month"],
input[type="week"],
select {
  color-scheme: light dark;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent-secondary);
  box-shadow: 0 0 0 3px rgba(232,106,26,0.18);
}
/* Page-local typeahead/search inputs that override `background: transparent`
   on the inner <input> (so the wrapper carries the surface). Without an
   explicit color, the input falls back to browser-default black, invisible
   on dark surfaces. The base `input { color: var(--text-primary) }` rule
   above already handles this — these selectors are a defensive belt for
   any page that scoped `color` away. */
[class$="tt-input"],
[class$="-input"]:not(button),
.typeahead input,
.search input {
  color: var(--text-primary);
}
[class$="tt-input"]::placeholder,
[class$="-input"]::placeholder,
.typeahead input::placeholder,
.search input::placeholder {
  color: var(--text-muted);
  opacity: 1;
}
button {
  cursor: pointer;
  background: var(--accent);
  color: var(--on-accent);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-weight: 500;
  transition: opacity 0.15s ease, background 0.15s ease;
}
button:hover { opacity: 0.92; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button[type="button"][data-variant="secondary"] {
  background: var(--surface-card);
  color: var(--text-primary);
  border-color: var(--border-default);
}
button[type="button"][data-variant="ghost"] {
  background: transparent;
  color: var(--text-primary);
  border-color: transparent;
}
button[type="button"][data-variant="danger"] {
  background: var(--danger);
  color: var(--on-danger);
}

/* ────────────────────────────────────────────────────────────────────
   Section E — Utility classes (page-shareable layout patterns)
   ──────────────────────────────────────────────────────────────────── */

/* Page wrapper — pages render their content inside this */
.page-content {
  max-width: 1440px;
  margin: 0 auto;
  padding: var(--space-6);
  display: grid;
  gap: var(--space-6);
}

/* Page header strip (eyebrow + title + actions) */
.page-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--space-4);
}
.page-header__title { font-size: 22px; font-weight: 600; color: var(--text-primary); }
.page-header__sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* KPI grid — used by dashboard + reports. 4-up by default, responsive. */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-4);
}

/* Filter bar — toolbar pattern from dashboard / accounts / approvals */
.filter-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-3) var(--space-4);
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
}
.filter-bar__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Card primitive — used everywhere. Page-instance styles override as needed. */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
}
.card--elevated { box-shadow: var(--shadow-md); }
.card__title { font-size: 15px; font-weight: 600; color: var(--text-primary); margin-bottom: var(--space-3); }

/* Pill (used in approvals and accounts for status indicators) */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.pill--pending  { background: var(--warning-soft); color: var(--warning); }
.pill--approved { background: var(--success-soft); color: var(--success); }
.pill--declined { background: var(--danger-soft);  color: var(--danger); }
.pill--info     { background: var(--info-soft);    color: var(--info); }

/* Visually-hidden — for accessible labels */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ────────────────────────────────────────────────────────────────────
   Section F — Blueprint chrome (light-touch overrides)
   The platform's registered blueprints carry their own internal CSS.
   These rules tune the theming knobs each blueprint exposes.
   ──────────────────────────────────────────────────────────────────── */

/* able-table */
.abt-table { border-radius: var(--radius-lg); overflow: hidden; }
.abt-thead th { background: var(--surface-subtle); color: var(--text-secondary); font-weight: 600; }
.abt-tbody tr:hover td { background: var(--surface-hover); cursor: pointer; }

/* able-offcanvas */
.aoff { box-shadow: var(--shadow-lg); border-left: 1px solid var(--border-default); }
.aoff__scrim { background: var(--surface-overlay); }

/* able-spinner (top-bar progress strip) */
.abp-bar { background: var(--accent-secondary); }

/* able-toast-stack */
.toast { box-shadow: var(--shadow-md); border-radius: var(--radius-lg); }
.toast--success { border-left: 3px solid var(--success); }
.toast--warning { border-left: 3px solid var(--warning); }
.toast--error   { border-left: 3px solid var(--danger); }
.toast--info    { border-left: 3px solid var(--info); }

/* able-tabs */
.atabs__bar { border-bottom: 1px solid var(--border-default); }
.atabs__tab[data-active="true"] {
  color: var(--accent-secondary);
  border-bottom: 2px solid var(--accent-secondary);
  font-weight: 600;
}

/* ────────────────────────────────────────────────────────────────────
   Section G — Print fallback (rare but cheap)
   ──────────────────────────────────────────────────────────────────── */
@media print {
  body { background: white; }
  .no-print, .filter-bar, .page-header__actions { display: none !important; }
}
