/* ============================================================================
 * Clever Transco · 3.0 Design System · shared override layer
 *
 * 📖 STANDARD: see _DESIGN-STANDARD.md (repo root) — single source of truth for
 *    dark/light surfaces, the surface-token PAIR rule, color palette, titles, shimmer.
 *    Read it before changing shared CSS. Fix shared sheets, never per-page copies.
 *
 * ONE source of truth for the 3.0 look. Linked by every page AFTER its own
 * inline <style> and after tms-shell.css, so it harmonizes the page content
 * to the locked 3.0 system without rewriting each page:
 *
 *     <link rel="stylesheet" href="../assets/clever-transco-3.0.css" />
 *
 * The 2.0 menu/shell (tms-shell.css, tms-shell-nav.js) is intentionally NOT
 * touched here — the topbar + tabnav keep their existing look. This sheet only
 * restyles PAGE CONTENT.
 *
 * Tokens (--surface-*, --text-*, --border-*, light/dark) are already defined by
 * tms-shell.css and are 3.0-aligned; this sheet adds the font, the status
 * palette, and the locked component polish (cards, card-head accent, banners,
 * KPIs, pills/tags/chips/badges, strips, fields).
 *
 * Color rule: color = STATUS only. good #059669 · warn #1C74A6 · danger #dc2626
 * · info/brand #1C74A6. Everything else is blue/neutral.
 * ========================================================================== */

/* ---- 0. status palette + a few 3.0 tokens layered on the shell's tokens ---- */
:root{
  /* Status palette UNIFIED — --ct3-good/warn/danger/info now alias the canonical
     --ct-success / --ct-warn / --ct-danger / --ct-info from clever-transco-tokens.css.
     Historical drift: --ct3-good was #059669 but --ct-success was #047857; --ct3-warn
     was #1C74A6 (brand blue masquerading as warn). One palette, one source of truth. */
  --ct-warn:    #f59e0b;                         /* amber — real warn hue (was #135883 navy) */
  --ct-warn-bg: rgba(245,158,11,0.12);
  --ct3-good:   var(--ct-success);
  --ct3-warn:   var(--ct-warn);
  --ct3-danger: var(--ct-danger);
  --ct3-info:   var(--ct-info);
  --ct3-brand:#1C74A6; --ct3-sky:#56C2EF; --ct3-edge:#135883; --ct3-ink:#0d3a5c;
  --ct3-glassx:rgba(255,255,255,.36); --ct3-glassbx:rgba(255,255,255,.6);
  --border-card-hover:rgba(86,194,239,0.45);
  --shadow-card-hover:0 1px 0 rgba(255,255,255,0.9) inset, 0 24px 60px -22px rgba(28,116,166,0.22), 0 6px 18px rgba(86,194,239,0.12);
}
:root[data-theme="dark"]{
  /* Dark-theme status palette — softer hues so they pop against dark glass.
     Still aliased so consumers reading either --ct-* or --ct3-* land in the same place. */
  --ct-success:    #6ee7b7;
  --ct-warn:       #fbbf24;   /* lighter amber for dark theme */
  --ct-warn-bg:    rgba(251,191,36,0.16);
  --ct-danger:     #fca5a5;
  --ct-info:       #7dd3fc;
  --ct3-good:      var(--ct-success);
  --ct3-warn:      var(--ct-warn);
  --ct3-danger:    var(--ct-danger);
  --ct3-info:      var(--ct-info);
  --ct3-glassx:rgba(16,26,46,.21); --ct3-glassbx:rgba(86,194,239,.22);
  --border-card-hover:rgba(86,194,239,0.42);
  --shadow-card-hover:0 1px 0 rgba(255,255,255,0.08) inset, 0 24px 60px -22px rgba(86,194,239,0.30), 0 6px 18px rgba(86,194,239,0.10);
}

/* ---- 1. TYPOGRAPHY — Archivo everywhere, bold, the single biggest 3.0 signal ---- */
/* Scope to body so the shell topbar/tabnav (own rules) are unaffected where they
   set their own family; Archivo still flows into page content + most chrome. */
body,
body button, body input, body select, body textarea,
.page, main, .card, .kpi, .banner, .strip,
h1, h2, h3, h4, h5, h6{
  font-family:var(--ct-font, 'Archivo','Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif);
}
body{ font-weight:600; }
/* display face for headlines + big numbers */
.page-title, .hero h1, .kpi .val, .rev-big .amt, .stat-tile .v, .day-tile .v,
.banner h3, .card-head h2, .strip .s-title{
  font-family:var(--ct-font, 'Archivo','Inter',sans-serif); letter-spacing:-.02em; font-weight:800;
}

/* ---- 2. CARD — glass surface + locked card-head accent ---- */
.card, .kpi{
  border-radius:var(--r-panel, 14px);
  border:1px solid var(--border-card);
  box-shadow:var(--shadow-card);
  transition:border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.card:hover, .kpi:hover{
  border-color:var(--border-card-hover);
  box-shadow:var(--shadow-card-hover);
  transform:translateY(-2px);
}
/* card-head: real left accent bar that follows the rounded corner (locked) */
.card-head{
  position:relative; display:flex; align-items:center; justify-content:space-between;
  gap:10px; padding:14px 18px;
  border-bottom:1px solid var(--border-divider);
  border-left:4px solid var(--ct3-edge);
  border-top-left-radius:14px;
}
.card-head h2{
  margin:0; font-size:var(--fz-17, 17px); font-weight:800; color:var(--text-heading); letter-spacing:-.01em;
  /* 3.0 standard = mixed case. Neutralizes a 2.0-era home override that forced
     .card-head h2 to UPPERCASE (made AP/AR, Ops, Sales, Finance homes all-caps
     while Tracker's .cell-head/.band-title headers stayed mixed-case). */
  text-transform:none !important;
}
.card-head .sub{ font-size:var(--fz-14, 14px); font-weight:700; color:var(--ct3-ink); }
:root[data-theme="dark"] .card-head{ border-left-color:var(--ct3-sky); }
:root[data-theme="dark"] .card-head h2{ color:var(--ct3-sky); }

/* ---- 3. KPI — value scale + status left-edge + delta colors ---- */
.kpi .lbl{ font-size:var(--fz-11, 11px); font-weight:700; color:var(--text-secondary);
  text-transform:uppercase; letter-spacing:.06em; }
.kpi .val{ font-size:var(--fz-27, 27px); font-weight:800; line-height:1; font-variant-numeric:tabular-nums;
  color:var(--text-heading); }
.kpi .delta.up{ color:var(--ct3-good); } .kpi .delta.down{ color:var(--ct3-danger); }
.kpi .delta.flat{ color:var(--text-muted); }
.kpi.danger{ border-left:3px solid var(--ct3-danger); }
.kpi.warn{ border-left:3px solid var(--ct3-warn); }
.kpi.good{ border-left:3px solid var(--ct3-good); }
.kpi.info{ border-left:3px solid var(--ct3-info); }

/* ---- 4. BANNER — blue-tinted, bold blue head ---- */
.banner h3{ font-size:var(--fz-17, 17px); font-weight:900; color:var(--ct3-brand); margin:0 0 4px; }
.banner p{ font-size:var(--fz-14, 14px); font-weight:700; color:var(--ct3-ink); margin:0; }
.banner.blue{ border-left:4px solid var(--ct3-edge); }
:root[data-theme="dark"] .banner h3{ color:var(--text-heading); }
:root[data-theme="dark"] .banner p{ color:var(--text-secondary); }

/* ---- 5. STRIP / status bar ---- */
.strip .s-title{ font-size:var(--fz-17, 17px); font-weight:800; letter-spacing:-.01em; color:var(--ct3-brand); }
.strip .s-sub{ font-size:var(--fz-14, 14px); font-weight:700; color:var(--ct3-ink); margin-top:2px; }
:root[data-theme="dark"] .strip .s-title{ color:var(--ct3-sky); }
:root[data-theme="dark"] .strip .s-sub{ color:var(--text-secondary); }

/* ---- 6. PILLS — color = status ---- */
.pill{ display:inline-flex; align-items:center; gap:5px; padding:3px 10px; border-radius:999px;
  font-size:var(--fz-11, 11px); font-weight:700; }
.pill.good{ background:var(--wash-good-3, rgba(5,150,105,.16)); color:var(--ct3-good); }
.pill.warn{ background:var(--tint-blue-3, rgba(28,116,166,.18)); color:var(--ct3-warn); }
.pill.danger{ background:var(--wash-bad-3, rgba(220,38,38,.16)); color:var(--ct3-danger); }
.pill.info{ background:var(--tint-blue-3, rgba(28,116,166,.16)); color:var(--ct3-info); }

/* ---- 7. TAGS — neutral blue (not status) ---- */
.tag{ display:inline-flex; align-items:center; padding:2px 9px; border-radius:7px;
  font-size:var(--fz-11, 11px); font-weight:700; background:var(--tint-blue-2, rgba(28,116,166,.10)); color:#2f5d7d; }
:root[data-theme="dark"] .tag{ background:var(--tint-sky-2, rgba(86,194,239,.12)); color:#9cc8e6; }

/* ---- 8. CHIPS — filter chips, active = brand gradient ---- */
.chip{ display:inline-flex; align-items:center; gap:6px; padding:6px 12px; border-radius:999px;
  font-size:var(--fz-12, 12px); font-weight:700; }
.chip .c-count{ background:var(--tint-blue-3, rgba(28,116,166,.14)); border-radius:999px; padding:1px 7px; font-size:var(--fz-11, 11px); }
.chip.active{ background:linear-gradient(135deg,var(--ct-blue, #1C74A6),#2aa3e0); color:var(--ct-white, #fff); border-color:transparent; }
.chip.active .c-count{ background:var(--tint-white-4, rgba(255,255,255,.25)); color:var(--ct-white, #fff); }

/* ---- 9. BADGES — neutral blue ---- */
.badge{ font-weight:700; }
:root[data-theme="dark"] .badge{ background:var(--tint-sky-2, rgba(86,194,239,.12)); color:#9cc8e6; }

/* ---- 10. PRIMARY ACTION — qa.primary / btn-sm.primary = brand gradient ---- */
.qa.primary, .btn-sm.primary{
  background:linear-gradient(135deg,var(--ct-blue, #1C74A6),#2aa3e0); color:var(--ct-white, #fff); border-color:transparent;
}
.qa.primary:hover, .btn-sm.primary:hover{
  background:linear-gradient(135deg,#2aa3e0,var(--ct-sky, #56C2EF)); color:var(--ct-white, #fff);
}

/* ---- 11. FORM CONTROLS — focus ring ---- */
.field input:focus, .field select:focus, .field textarea:focus{
  outline:none; border-color:var(--border-card-hover);
  box-shadow:0 0 0 3px rgba(86,194,239,.15);
}
.field select{ font-weight:700; color:var(--text-link); cursor:pointer; }

/* ---- 12. LINKS ---- */
a{ color:var(--text-link); }

/* ---- 13. FORM-PAGE VOCABULARY ----
   Bespoke form/wizard pages (create-load, quotes, wizards) label their panels
   with .section-head .label (small gray uppercase) instead of .card-head. Bring
   those into 3.0: brand-blue, Archivo, bolder — so form pages read as 3.0 too,
   without changing their compact layout. */
.section-head .label,
.sec-head .label,
.panel-head .label{
  font-family:var(--ct-font, 'Archivo','Inter',sans-serif);
  color:var(--text-heading);
  font-weight:800;
  letter-spacing:.04em;
}
:root[data-theme="dark"] .section-head .label,
:root[data-theme="dark"] .sec-head .label,
:root[data-theme="dark"] .panel-head .label{ color:var(--ct3-sky); }

/* Give the form panels the signature 3.0 left edge (matches .card-head accent).
   Scoped to panels that carry a .section-head so we don't touch arbitrary
   .section utility wrappers. */
.section:has(> .section-head){ border-left:3px solid var(--ct3-edge); }
:root[data-theme="dark"] .section:has(> .section-head){ border-left-color:var(--ct3-sky); }

/* ============================================================================
   14. BOLD 3.0 SKIN — the visible layer
   These pages were already built on the 3.0 tokens, so the subtle overrides
   above produced almost no visible change. This section makes 3.0 unmistakable
   on every page: a brand-blue accent edge on every card, bold Archivo blue on
   every card/panel header, and a crisper card depth. !important is used only on
   the few signature properties so it wins over each page's own component CSS.
   ========================================================================== */

/* 14a · every card/kpi gets the signature 3.0 left accent + crisper depth */
.card, .kpi{
  border-left:3px solid var(--ct3-edge) !important;
  border-radius:var(--r-panel, 14px) !important;
}
:root[data-theme="dark"] .card, :root[data-theme="dark"] .kpi{
  border-left-color:var(--ct3-sky) !important;
}

/* 14b · card/panel headers → bold Archivo, brand blue, on whatever class a page
   uses for its card title. Covers the common patterns across the codebase. */
.card-head h2, .card-head h3,
.card > h2, .card > h3,
.card-title, .card-hd, .card-header,
.panel-head, .panel-title, .panel-header,
.sec-head .label, .section-head .label, .section-title,
.kpi .lbl, .stat-title, .widget-title, .box-title{
  font-family:var(--ct-font, 'Archivo','Inter',sans-serif) !important;
  color:var(--text-heading) !important;
  font-weight:800 !important;
  letter-spacing:-.01em;
}
:root[data-theme="dark"] .card-head h2, :root[data-theme="dark"] .card-head h3,
:root[data-theme="dark"] .card > h2, :root[data-theme="dark"] .card > h3,
:root[data-theme="dark"] .card-title, :root[data-theme="dark"] .card-hd, :root[data-theme="dark"] .card-header,
:root[data-theme="dark"] .panel-head, :root[data-theme="dark"] .panel-title, :root[data-theme="dark"] .panel-header,
:root[data-theme="dark"] .sec-head .label, :root[data-theme="dark"] .section-head .label, :root[data-theme="dark"] .section-title,
:root[data-theme="dark"] .stat-title, :root[data-theme="dark"] .widget-title, :root[data-theme="dark"] .box-title{
  color:var(--ct3-sky) !important;
}

/* 14c · enforce Archivo on body text so the type change actually reads */
body, body *:not(.mono):not([class*="mono"]):not(code):not(pre){
  font-family:var(--ct-font, 'Archivo','Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif);
}

/* ============================================================================
   BC1 2026-06-03 (Bug chat, owner request) · STANDARD framed-page top spacing v2.
   CANONICAL copy — this sheet loads last on every page, so it wins over the
   older copies in tms-glass.css / clever-transco-3.0-home.css.
   THE GAP lives on the BODY (set per-page in each data-ct-iframe-hide block:
   body[data-in-iframe]{padding-top:14px}) because body padding shifts every
   layout uniformly and works on pages with or without their own .tabnav markup.
   THE WORDS rule below adds breathing room INSIDE the first block so header
   text doesn't sit on its top edge. margin forced to 0 so the gap is never
   doubled. customer-profile keeps a page-local opt-out (fixed-height band).
   NO SHADOW anywhere — the break is a real gap, owner's orders.
   ============================================================================ */
/* ============================================================================
   BC1 FINAL · 2026-06-03 · OWNER-TUNED SPACING — THE one rule.
   Niko set this value himself with a live slider: 16px below the shell menu on
   EVERY framed page. The `html body[...]` selector outranks every per-page
   data-ct-iframe-hide block regardless of document order, so all per-page
   padding values are now inert — DO NOT tune spacing per page anymore.
   Change the 16px here (and only here) if the owner ever wants it different.
   ============================================================================ */
/* 2026-10-21 · Niko, screenshot of the strip under the menu: "every page has this little
   gap, anyway to get rid of it on every page so it page sits right under the menu?"
   Measured: the page sat 32px below the menu, not the 16px chosen on 06-03 — this padding
   (16) AND the shell's `.tabnav + *` margin below (16) both applied. Both are now 0. */
html body[data-in-iframe] { padding-top: 0 !important; }
html body[data-in-iframe] .tabnav + *,
html body[data-in-iframe] .page { padding-top: 0 !important; margin-top: 0 !important; }
/* Words must not sit on the top edge of visible header BANDS (.pageheader):
   12px air inside the band. Pages without a band are unaffected. customer-profile
   and carrier-profile carry page-local opt-outs (fixed-height bands clip). */
html body[data-in-iframe] .pageheader { padding-top: 12px !important; }

/* ============================================================================
   STANDALONE MIRROR · 2026-06-08 · keep the gallery "open"/direct view identical
   to the framed TMS. When NOT framed the menu is visible, so the body-padding
   trick can't be used (it would add space ABOVE the menu). Instead translate the
   same 16px gap into a top margin on the first block below the nav, and mirror the
   12px band air. Pages with a framed .pageheader opt-out carry a matching
   :not([data-in-iframe]) opt-out locally (carrier-profile, customer-profile).
   ============================================================================ */
html body:not([data-in-iframe]) .tabnav + * { margin-top: 0 !important; }   /* 2026-10-21 · was 16px — see the note at padding-top above */
html body:not([data-in-iframe]) .pageheader { padding-top: 12px !important; }

/* ============================================================================
   GLASS CALLOUT NOTES · 2026-06-08 · bespoke callout/scope-note bands used a thin
   rgba(28,116,166,.08–.11) blue wash that reads see-through over the freight map.
   Tagged .gnote (and .scope-note) and given the proper glass surface in light mode.
   The blue left-accent stays (it's on the element). Light-scoped; dark mode keeps
   its own tint. ============================================================================ */
:root[data-theme="light"] .gnote,
:root[data-theme="light"] .scope-note { background: var(--t-glass) !important; }

/* ---- band-cell headers get the FULL locked card-head treatment (accent bar that
   follows the rounded corner, header wash, divider) — same as .card-head ---- */
.band-cell .cell-head{
  margin:-14px -16px 11px !important;          /* bleed to the cell edges (cell padding 14px 16px) */
  padding:12px 16px 10px !important;
  border-left:4px solid var(--ct3-edge) !important;
  border-bottom:1px solid var(--line-blue-1, rgba(28,116,166,.10)) !important;
  border-top-left-radius:14px;
  border-top-right-radius:14px;
  background:linear-gradient(180deg, rgba(248,251,253,.85) 0%, rgba(255,255,255,0) 100%);
}
:root[data-theme="dark"] .band-cell .cell-head{
  border-left-color:var(--ct3-sky) !important;
  border-bottom-color:var(--line-white-2, rgba(255,255,255,.08)) !important;
  background:linear-gradient(180deg, var(--tint-white-1, rgba(255,255,255,.05)) 0%, rgba(255,255,255,0) 100%);
}

/* ============================================================
   GLOBAL DARK secondary-text fix — TMS-WIDE (Niko 2026-06-06).
   Hardcoded greys / dark-blues / dark-greens are used as secondary text all
   over the app and are unreadable on dark surfaces. The design tokens were
   theme-aware but most elements bypass them with inline hex. Brighten the
   common offenders in dark mode only — light mode is untouched.
   ============================================================ */
:root[data-theme="dark"]{
  --text-secondary: rgba(226,240,250,0.84);
  --text-muted: rgba(196,220,238,0.68);
}
:root[data-theme="dark"] [style*="#4a5a6e"],
:root[data-theme="dark"] [style*="#4b5563"],
:root[data-theme="dark"] [style*="#6b7280"],
:root[data-theme="dark"] [style*="#5b6b7e"],
:root[data-theme="dark"] [style*="#3d4f63"],
:root[data-theme="dark"] [style*="#64748b"],
:root[data-theme="dark"] [style*="#6B7280"],
:root[data-theme="dark"] [style*="#9ca3af"],
:root[data-theme="dark"] [style*="#135883"],
:root[data-theme="dark"] [style*="#0d3a5c"],
:root[data-theme="dark"] [style*="#003258"]{
  color:var(--t-ink-2, #a9c6dd) !important;
}
:root[data-theme="dark"] [style*="#1a1d21"],
:root[data-theme="dark"] [style*="#1A1D21"],
:root[data-theme="dark"] [style*="#0a2540"],
:root[data-theme="dark"] [style*="#1f2937"],
:root[data-theme="dark"] [style*="#111827"]{ color:#EAF7FF !important; }

/* dark-green text on green status bars -> readable mint */
:root[data-theme="dark"] [style*="#064e3b"],
:root[data-theme="dark"] [style*="#065f46"],
:root[data-theme="dark"] [style*="#047857"]{
  color:var(--ct-good, #6ee7b7) !important;
}

/* Robust ID-based dark fixes for JS-toggled status notices whose inline hex
   gets re-serialized to rgb() when shown (breaks [style*=] matching). */
:root[data-theme="dark"] #rcPreviewClearNotice{ color:var(--ct-good, #6ee7b7) !important; background:var(--wash-good-4, rgba(5,150,105,0.18)) !important; border-color:rgba(110,231,183,0.45) !important; }
:root[data-theme="dark"] #rcPreviewClearNotice b{ color:var(--ct-good, #6EE7B7) !important; }
:root[data-theme="dark"] #rcPreviewBlindNotice{ color:#BFE3F5 !important; }
:root[data-theme="dark"] #rcPreviewBlindNotice b{ color:#EAF7FF !important; }

/* Document-row titles (.doc-name) hardcode near-black #1a1d21 with no dark
   override -> invisible on dark (Release-to-accounting modal, doc lists).
   Class-defined so the inline-grey sweep can't reach it. */
:root[data-theme="dark"] .doc-item .doc-name{ color:#EAF7FF !important; }
:root[data-theme="dark"] .doc-item .doc-meta{ color:var(--t-ink-2, #a9c6dd) !important; }
