/* =========================================================
   Subsettle — Premium Dark Design System (styles.css)
   No-build, dependency-free SPA. Implements §0 tokens and
   the full §11 class catalog of the BUILD CONTRACT.
   Mobile-first: tabbar < 860px, sidebar >= 860px.
   Aesthetic: modern dark fintech / money app — layered dark
   surfaces, hairline borders, soft glows on money + CTAs.
   ========================================================= */

/* ---------- §0 Brand & tokens ---------- */
:root {
  /* App backgrounds (layered dark surfaces) */
  --bg:           #080c14;   /* near-black blue-slate, app background */
  --bg-2:         #0c111c;
  --surface:      #121a28;   /* cards */
  --surface-2:    #1a2433;   /* inputs, hover, elevated chips */
  --surface-3:    #222e43;   /* popovers / active rows */

  /* Hairline borders */
  --line:         rgba(148, 163, 184, .12);   /* hairline borders */
  --line-2:       rgba(148, 163, 184, .22);   /* hover / stronger borders */

  /* Text */
  --ink:          #f4f7fd;   /* headings / primary text */
  --body:         #b7c3d6;   /* body text */
  --muted:        #7d8ba2;   /* secondary text */

  /* Accent — safety amber (CTAs / highlights) */
  --accent:       #f9a826;
  --accent-600:   #e08e05;
  --accent-50:    rgba(249, 168, 38, .14);

  /* Money semantics */
  --good:         #34d399;   /* paid / owed-to-you (emerald) */
  --good-50:      rgba(52, 211, 153, .14);
  --warn:         #fbbf24;
  --warn-50:      rgba(251, 191, 36, .14);
  --danger:       #fb7185;   /* overdue (rose) */
  --danger-50:    rgba(251, 113, 133, .15);

  /* Retainage (teal — distinct from regular AR) */
  --retainage:    #2dd4bf;
  --retainage-50: rgba(45, 212, 191, .14);

  /* Brand (blue info accent) */
  --brand:        #6aa0ff;
  --brand-600:    #6aa0ff;
  --brand-50:     rgba(106, 160, 255, .14);

  /* Shape & depth */
  --radius:       14px;
  --radius-sm:    10px;
  --radius-lg:    20px;
  --shadow-sm:    0 1px 2px rgba(0, 0, 0, .45);
  --shadow:       0 12px 34px rgba(0, 0, 0, .5);
  --shadow-lg:    0 32px 80px rgba(0, 0, 0, .62);

  /* Glows & focus rings */
  --glow-accent:  0 8px 30px rgba(249, 168, 38, .30);
  --ring:         0 0 0 3px rgba(249, 168, 38, .38);
  --ring-accent:  0 0 0 3px rgba(249, 168, 38, .38);

  --transition:   .2s cubic-bezier(.4, 0, .2, 1);

  --font-head:    'Poppins', system-ui, sans-serif;
  --font-body:    'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  /* Sidebar & content both scale with the viewport (fluid), with comfortable
     min/max so laptops stay sane and ultra-wide doesn't go full-bleed. */
  --sidebar-w:    clamp(284px, 17vw, 340px);   /* slightly larger baseline; grows on wide screens */
  --content-max:  clamp(1280px, 76vw, 1560px); /* content column cap; +80px floor, scales up to 1560 */
  --tabbar-h:     64px;
  --tap:          44px;
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  font-family: var(--font-body);
  color: var(--body);
  background-color: var(--bg);
  /* Subtle layered depth — fixed radial glows behind everything. */
  background-image:
    radial-gradient(1100px 520px at 12% -8%, rgba(249, 168, 38, .06), transparent 60%),
    radial-gradient(900px 520px at 100% 0%, rgba(106, 160, 255, .05), transparent 55%);
  background-attachment: fixed;
  line-height: 1.62;
  font-size: 15.5px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
::selection { background: rgba(249, 168, 38, .30); color: #fff; }

/* Thin dark scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; padding: 0; }
button { font-family: inherit; font-size: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3, h4, h5 {
  font-family: var(--font-head);
  color: var(--ink);
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -.01em;
}
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }

/* Shared icon base (used by ui.icon -> class "ic") */
.ic {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* =========================================================
   §11 LAYOUT
   ========================================================= */
.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: stretch;
}

/* Sidebar — hidden on mobile, shown >= 860px */
.app__sidebar {
  display: none;
  flex-direction: column;
  width: var(--sidebar-w);
  flex: none;
  background: linear-gradient(180deg, #0e1524, #090d16);
  color: var(--body);
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  border-right: 1px solid var(--line);
}
.app__sidebar-foot {
  margin-top: auto;
  padding-top: 18px;
  font-size: .78rem;
  color: var(--muted);
  line-height: 1.5;
}
.app__sidebar-foot a { color: #fff; font-weight: 600; }
.app__sidebar-foot a:hover { color: var(--accent); }

/* Main column */
.app__main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  /* room for the mobile tabbar; reset >= 860px */
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  /* Ambient backdrop so the empty main area isn't a flat void: soft warm + cool blooms
     plus a subtle dot grid, sitting behind the centered .view content. */
  background-color: var(--bg);
  background-image:
    radial-gradient(1100px 580px at 82% -12%, rgba(249, 168, 38, .08), transparent 58%),
    radial-gradient(900px 620px at 2% 110%, rgba(106, 160, 255, .06), transparent 55%),
    radial-gradient(rgba(148, 163, 184, .09) 1px, transparent 1.4px);
  background-repeat: no-repeat, no-repeat, repeat;
  background-size: auto, auto, 24px 24px;
}
[data-theme="light"] .app__main {
  background-image:
    radial-gradient(1100px 580px at 82% -12%, rgba(249, 168, 38, .10), transparent 58%),
    radial-gradient(900px 620px at 2% 110%, rgba(106, 160, 255, .08), transparent 55%),
    radial-gradient(rgba(71, 85, 105, .08) 1px, transparent 1.4px);
}

/* Topbar (mobile header with brand + global actions) */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
  padding: 10px clamp(18px, 2.5vw, 36px);
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: rgba(8, 12, 20, .72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar__brand { gap: 9px; }
.topbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* Brand lockup */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: inherit;
}
.brand__logo {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  flex: none;
  border-radius: 11px;
  background: linear-gradient(140deg, #fbb43f, #f59412);
  color: #1c1304;
  box-shadow: var(--glow-accent);
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.05rem;
}
.brand__logo svg, .brand__logo .ic { width: 21px; height: 21px; color: #1c1304; }
.brand__name {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.32rem;
  letter-spacing: -.02em;
  color: var(--ink);
}
/* Brand sits on dark gradient inside the sidebar */
.app__sidebar .brand { margin-bottom: 22px; padding: 4px 6px; }
.app__sidebar .brand__name { color: #fff; }

/* The view shell + headers */
.view {
  flex: 1 1 auto;
  width: 100%;
  /* Centered content column so wide screens stay balanced (no wasted right side).
     Fluid cap (--content-max) lets it scale with the device instead of a hard 1200px. */
  max-width: var(--content-max);
  margin-inline: auto;
  outline: none;
  /* The gutter for ALL view content lives here, so a bare .view__header and a
     wrapped .container both clear the sidebar consistently. */
  padding: 22px clamp(18px, 2.5vw, 36px) 8px;
}
.view__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.view__titlewrap { min-width: 0; }
.view__title {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(1.45rem, 4.5vw, 1.85rem);
  color: var(--ink);
  letter-spacing: -.02em;
}
.view__subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: .95rem;
}
.view__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.container {
  width: 100%;
  /* Fills the centered .view; the view's max-width controls the content column. */
  max-width: none;
  margin-inline: 0;
  padding: 0 0 28px;
}

/* =========================================================
   §11 NAV (sidebar + tabbar share .nav / .nav__item)
   ========================================================= */
.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: var(--tap);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-family: var(--font-head);
  font-weight: 600;
  font-size: .96rem;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
}
.nav__item:hover { background: var(--surface-2); color: var(--ink); }
.nav__item.is-active {
  background: var(--accent-50);
  color: var(--ink);
  box-shadow: none;
}
.nav__item.is-active:hover { background: var(--accent-50); color: var(--ink); }
.nav__item.is-active .nav__icon { color: var(--accent); }
.nav__item.is-active::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(249, 168, 38, .7);
}
.nav__icon {
  display: grid;
  place-items: center;
  width: 22px; height: 22px;
  flex: none;
  color: inherit;
}
.nav__icon .ic { width: 21px; height: 21px; }
.nav__label { white-space: nowrap; }
.nav__badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  margin-left: auto;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: .72rem;
  line-height: 1;
}
.nav__item.is-active .nav__badge { background: var(--danger); color: #fff; }

/* Tabbar — bottom nav on mobile */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  display: flex;
  align-items: stretch;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(10, 14, 22, .94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar .nav__item {
  flex: 1 1 0;
  flex-direction: column;
  gap: 3px;
  min-height: var(--tabbar-h);
  padding: 8px 2px;
  border-radius: 0;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 600;
}
.tabbar .nav__item:hover { background: transparent; color: var(--ink); }
.tabbar .nav__item.is-active {
  background: transparent;
  color: var(--accent);
  box-shadow: none;
}
/* The sidebar's glowing left indicator bar doesn't belong in the bottom tabbar. */
.tabbar .nav__item.is-active::before { display: none; }
.tabbar .nav__item.is-active .nav__icon { color: var(--accent); }
.tabbar .nav__icon .ic { width: 23px; height: 23px; }
.tabbar .nav__label { font-size: .68rem; }
.tabbar .nav__badge {
  position: absolute;
  top: 5px;
  left: 50%;
  margin-left: 4px;
  min-width: 17px;
  height: 17px;
  font-size: .64rem;
}
.tabbar .nav__item.is-active .nav__badge { background: var(--danger); color: #fff; }

/* =========================================================
   §11 BUTTONS
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 11px 18px;
  border-radius: 999px;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: .94rem;
  line-height: 1;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition), color var(--transition), border-color var(--transition), filter var(--transition);
}
.btn .ic { width: 18px; height: 18px; }
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); border-color: var(--line-2); }
.btn:active { transform: translateY(0); }
.btn:disabled, .btn[disabled] {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
  box-shadow: var(--shadow-sm);
}

.btn--primary {
  background: linear-gradient(135deg, #fbb43f, #f59412);
  border-color: transparent;
  color: #1c1304;
  box-shadow: var(--glow-accent), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.btn--primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
  border-color: transparent;
  box-shadow: 0 10px 34px rgba(249, 168, 38, .45), inset 0 1px 0 rgba(255, 255, 255, .3);
}

.btn--accent {
  background: linear-gradient(135deg, #fbb43f, #f59412);
  border-color: transparent;
  color: #1c1304;
  box-shadow: var(--glow-accent), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.btn--accent:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
  border-color: transparent;
  box-shadow: 0 10px 34px rgba(249, 168, 38, .45), inset 0 1px 0 rgba(255, 255, 255, .3);
}

.btn--ghost {
  background: transparent;
  border: 1px solid transparent;
  color: var(--body);
  box-shadow: none;
}
.btn--ghost:hover { background: var(--surface-2); color: var(--ink); box-shadow: none; border-color: transparent; }

.btn--danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #1a0508;
  box-shadow: 0 8px 18px rgba(251, 113, 133, .28);
}
.btn--danger:hover { filter: brightness(1.05); transform: translateY(-1px); }

.btn--sm {
  min-height: 36px;
  padding: 7px 13px;
  font-size: .85rem;
  gap: 6px;
}
.btn--sm .ic { width: 16px; height: 16px; }

.btn--block { width: 100%; }

.btn--icon {
  min-height: var(--tap);
  width: var(--tap);
  padding: 0;
  border-radius: 50%;
}
.btn--icon.btn--sm { width: 36px; height: 36px; min-height: 36px; }
.btn--icon .ic { width: 20px; height: 20px; }

/* Icon-only danger buttons (e.g. per-row delete) stay subtle and only turn red on
   hover/focus — a solid red circle on every list row reads as an alarm. Full-size
   .btn--danger (prominent delete actions) keeps its solid fill. */
.btn--icon.btn--danger {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  box-shadow: none;
}
.btn--icon.btn--danger:hover,
.btn--icon.btn--danger:focus-visible {
  background: var(--danger-50);
  border-color: transparent;
  color: var(--danger);
  box-shadow: none;
}
/* Text danger buttons that are ALSO ghost (e.g. the GC "Delete") stay subtle:
   red text, no fill until hover — so they don't shout on every row. */
.btn--ghost.btn--danger {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  box-shadow: none;
}
.btn--ghost.btn--danger:hover,
.btn--ghost.btn--danger:focus-visible {
  background: var(--danger-50);
  border-color: transparent;
  color: var(--danger);
  box-shadow: none;
}

/* =========================================================
   §11 CARDS / SECTIONS
   ========================================================= */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .05);
  overflow: hidden;
}
/* Interactive/standalone cards get a refined tactile hover lift. Static panel
   cards (the default) stay put so wrapping a list/toolbar doesn't jump on hover. */
.card--interactive {
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.card--interactive:hover {
  border-color: var(--line-2);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, .06);
  transform: translateY(-2px);
}
.card--pad { padding: 22px 22px; }
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.card__title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--ink);
}
.card__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.card__body { padding: 18px 20px; }
.card--pad .card__body { padding: 0; }
/* A padded card WITH a header: detach the body from the header's divider so the first
   title ("Signed in as", "Business identity", "Demo data", "Subsettle"…) isn't crammed
   against the line above it. */
.card--pad .card__head + .card__body { padding-top: 18px; }

.section { margin-bottom: 30px; }
.section__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.08rem;
  color: var(--ink);
}
.section__action {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .9rem;
  color: var(--muted);
}
/* Severity group headings on the Alerts view ("High priority", "Worth a nudge") */
.sev-heading {
  font-family: var(--font-head);
  font-size: 1.28rem;
  font-weight: 800;
  letter-spacing: -.01em;
  color: var(--ink);
}
.divider {
  height: 1px;
  background: var(--line);
  border: 0;
  margin: 16px 0;
}

/* =========================================================
   §11 STATS
   ========================================================= */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}
.stat {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px;
  border: 1px solid var(--line);
  border-top: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(120% 80% at 50% -20%, rgba(255, 255, 255, .03), transparent 60%),
    var(--surface);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, .05);
}
.stat__icon {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  margin-bottom: 8px;
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--muted);
}
.stat__icon .ic { width: 20px; height: 20px; }
.stat__label {
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat__value {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.5rem;
  line-height: 1.2;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.stat__sub {
  font-size: .82rem;
  color: var(--muted);
}

/* Stat tints — a soft hue wash glowing from the top + a faint same-color rim,
   replacing the flat 3px top bar with layered, on-brand depth. */
.stat--good {
  background: radial-gradient(120% 80% at 50% -20%, rgba(52, 211, 153, .10), transparent 60%), var(--surface);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, .05), 0 0 0 1px rgba(52, 211, 153, .06);
}
.stat--good .stat__icon { background: var(--good-50); color: var(--good); }
.stat--good .stat__value { color: var(--good); }

.stat--retainage {
  background: radial-gradient(120% 80% at 50% -20%, rgba(45, 212, 191, .10), transparent 60%), var(--surface);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, .05), 0 0 0 1px rgba(45, 212, 191, .06);
}
.stat--retainage .stat__icon { background: var(--retainage-50); color: var(--retainage); }
.stat--retainage .stat__value { color: var(--retainage); }

.stat--danger {
  background: radial-gradient(120% 80% at 50% -20%, rgba(251, 113, 133, .10), transparent 60%), var(--surface);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, .05), 0 0 0 1px rgba(251, 113, 133, .06);
}
.stat--danger .stat__icon { background: var(--danger-50); color: var(--danger); }
.stat--danger .stat__value { color: var(--danger); }

.stat--accent {
  background: radial-gradient(120% 80% at 50% -20%, rgba(249, 168, 38, .10), transparent 60%), var(--surface);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, .05), 0 0 0 1px rgba(249, 168, 38, .06);
}
.stat--accent .stat__icon { background: var(--accent-50); color: var(--accent); }
.stat--accent .stat__value { color: var(--accent); }

/* Hero total — the dashboard centerpiece (signature moment) */
.hero-total {
  position: relative;
  overflow: hidden;
  padding: 26px 24px;
  border-radius: var(--radius-lg);
  color: #fff;
  background:
    radial-gradient(600px 300px at 88% -20%, rgba(249, 168, 38, .16), transparent 60%),
    linear-gradient(150deg, #17233b 0%, #0e1626 58%);
  border: 1px solid var(--line-2);
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, .08),
    inset 0 0 0 1px rgba(255, 255, 255, .02),
    0 0 60px -28px rgba(249, 168, 38, .35);
}
.hero-total::after {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px);
  background-size: 20px 20px;
  -webkit-mask-image: linear-gradient(to bottom, #000, transparent 80%);
  mask-image: linear-gradient(to bottom, #000, transparent 80%);
  pointer-events: none;
}
.hero-total > * { position: relative; z-index: 1; }
.hero-total__label {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: .82rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .66);
}
.hero-total__value {
  margin: 6px 0 4px;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(2.6rem, 7vw, 3.6rem);
  line-height: 1.02;
  letter-spacing: -.02em;
  background: linear-gradient(180deg, #ffffff 0%, #ffe9c2 78%, #ffd591 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 4px 22px rgba(249, 168, 38, .28));
  font-variant-numeric: tabular-nums;
}
.hero-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}
.hero-split .stat {
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .10);
  border-top-width: 1px;
  box-shadow: none;
  backdrop-filter: blur(4px);
}
.hero-split .stat__label { color: rgba(255, 255, 255, .74); }
.hero-split .stat__value { color: #fff; }
.hero-split .stat__sub { color: rgba(255, 255, 255, .66); }
.hero-split .stat--good .stat__value { color: var(--good); }
.hero-split .stat--retainage .stat__value { color: var(--retainage); }
.hero-split .stat__icon { background: rgba(255, 255, 255, .1); color: rgba(255, 255, 255, .85); }

/* =========================================================
   §11 MONEY / NUM
   ========================================================= */
.money, .num, .amt {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}
.money {
  font-family: var(--font-head);
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}
/* Semantic money figures glow faintly so owed/overdue/retainage balances feel
   lit; neutral .money stays un-glowed to keep the glow meaningful. */
.money--good { color: var(--good); font-weight: 700; text-shadow: 0 0 18px rgba(52, 211, 153, .30); }
.money--warn { color: var(--warn); font-weight: 700; text-shadow: 0 0 16px rgba(251, 191, 36, .26); }
.money--danger { color: var(--danger); font-weight: 700; text-shadow: 0 0 18px rgba(251, 113, 133, .30); }
.money--retainage { color: var(--retainage); font-weight: 700; text-shadow: 0 0 18px rgba(45, 212, 191, .28); }
.num { font-weight: 600; color: var(--ink); }
.amt {
  font-family: var(--font-head);
  font-weight: 700;
  color: var(--ink);
}

/* =========================================================
   §11 BADGES (translucent tint + bright text + faint hue border)
   ========================================================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: .76rem;
  line-height: 1.5;
  white-space: nowrap;
  background: var(--brand-50);
  color: #93b8ff;
  border: 1px solid rgba(106, 160, 255, .28);
}
.badge .ic { width: 13px; height: 13px; }

/* Job / lifecycle */
.badge--active    { background: var(--good-50);      color: #6ee7b7; border-color: rgba(52, 211, 153, .30); }
.badge--complete  { background: var(--brand-50);     color: #93b8ff; border-color: rgba(106, 160, 255, .28); }
.badge--closed    { background: rgba(148, 163, 184, .14); color: var(--muted); border-color: rgba(148, 163, 184, .22); }

/* Release */
.badge--pending   { background: var(--warn-50);      color: #fbbf24; border-color: rgba(251, 191, 36, .30); }
.badge--released  { background: var(--retainage-50); color: #5eead4; border-color: rgba(45, 212, 191, .30); }
.badge--disputed  { background: var(--danger-50);    color: #fda4af; border-color: rgba(251, 113, 133, .30); }

/* Pay app payment state */
.badge--paid      { background: var(--good-50);      color: #6ee7b7; border-color: rgba(52, 211, 153, .30); }
.badge--unpaid    { background: var(--warn-50);      color: #fbbf24; border-color: rgba(251, 191, 36, .30); }
.badge--overdue   { background: var(--danger-50);    color: #fda4af; border-color: rgba(251, 113, 133, .30); }

/* Letter state */
.badge--draft     { background: rgba(148, 163, 184, .14); color: var(--muted); border-color: rgba(148, 163, 184, .22); }
.badge--sent      { background: var(--brand-50);     color: #93b8ff; border-color: rgba(106, 160, 255, .28); }

/* Alert severity */
.badge--high      { background: var(--danger-50);    color: #fda4af; border-color: rgba(251, 113, 133, .30); }
.badge--medium    { background: var(--warn-50);      color: #fbbf24; border-color: rgba(251, 191, 36, .30); }
.badge--low       { background: var(--brand-50);     color: #93b8ff; border-color: rgba(106, 160, 255, .28); }

/* GC reliability */
.badge--good      { background: var(--good-50);      color: #6ee7b7; border-color: rgba(52, 211, 153, .30); }
.badge--ok        { background: var(--warn-50);      color: #fbbf24; border-color: rgba(251, 191, 36, .30); }
.badge--poor      { background: var(--danger-50);    color: #fda4af; border-color: rgba(251, 113, 133, .30); }
.badge--unknown   { background: rgba(148, 163, 184, .14); color: var(--muted); border-color: rgba(148, 163, 184, .22); }

/* =========================================================
   §11 LISTS / ROWS / CHIPS
   ========================================================= */
.list {
  display: flex;
  flex-direction: column;
}
.list > .row + .row { border-top: 1px solid var(--line); }

.row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: var(--tap);
  padding: 15px 18px;
  background: transparent;
  color: inherit;
  border-bottom: 1px solid var(--line);
  transition: background var(--transition), border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
a.row, .row[onclick], .row--click { cursor: pointer; }
a.row:hover, .row[onclick]:hover, .row--click:hover {
  background: var(--surface-3);
  border-color: var(--line-2);
  box-shadow: inset 3px 0 0 var(--accent);
}
.row__main { flex: 1 1 auto; min-width: 0; }
.row__title {
  font-weight: 600;
  font-size: .98rem;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
  font-size: .85rem;
  line-height: 1.45;
  color: var(--muted);
}
.row__right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  flex: none;
  text-align: right;
}
.row__amt {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* Filter chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--body);
  font-weight: 600;
  font-size: .86rem;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.chip:hover { border-color: var(--line-2); color: var(--ink); }
.chip--active {
  background: var(--accent-50);
  border-color: rgba(249, 168, 38, .45);
  color: var(--accent);
  box-shadow: 0 0 0 1px rgba(249, 168, 38, .25), 0 4px 14px -6px rgba(249, 168, 38, .5);
}
.chip--active:hover { color: var(--accent); border-color: rgba(249, 168, 38, .55); }

/* =========================================================
   §11 TABLES
   ========================================================= */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
}
.table th, .table td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
  color: var(--body);
}
.table thead th {
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, var(--surface-2), var(--bg-2));
  font-family: var(--font-head);
  font-weight: 600;
  font-size: .76rem;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 var(--line);
}
.table tbody tr + tr td { border-top: 1px solid var(--line); }
.table tbody tr:hover td { background: var(--surface-2); }
.table td.right, .table th.right { text-align: right; }
.table .money, .table .num, .table .amt { text-align: right; }
.table--compact th, .table--compact td { padding: 8px 12px; }

/* =========================================================
   §11 FORMS
   ========================================================= */
.form {
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.form__row { display: flex; flex-direction: column; gap: 22px; }
.form__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px 22px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.field__label {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: .85rem;
  color: var(--ink);
}
.field__label .req { color: var(--danger); margin-left: 2px; }
.field__control { position: relative; }
.field__hint {
  font-size: .8rem;
  color: var(--muted);
}
.field__error {
  font-size: .8rem;
  font-weight: 600;
  color: var(--danger);
}

.input, .select, .textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  font-size: .96rem;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  appearance: none;
  -webkit-appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-2);
  box-shadow: var(--ring);
}
/* Native date picker should render dark */
input[type="date"].input,
input[type="date"] { color-scheme: dark; }
.textarea {
  min-height: 110px;
  line-height: 1.5;
  resize: vertical;
}
.select {
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237d8ba2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
  cursor: pointer;
}
.select option { background: var(--surface-2); color: var(--ink); }
/* invalid state mirrors field__error */
.input.is-invalid, .select.is-invalid, .textarea.is-invalid {
  border-color: var(--danger);
  background: rgba(251, 113, 133, .08);
}
.input.is-invalid:focus, .select.is-invalid:focus, .textarea.is-invalid:focus {
  box-shadow: 0 0 0 3px rgba(251, 113, 133, .25);
}

/* Checkbox */
.checkbox {
  width: 20px; height: 20px;
  flex: none;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Prefix / suffix wraps (e.g. $ / %) */
.input-wrap {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.input-wrap:focus-within {
  border-color: var(--accent);
  background: var(--surface-2);
  box-shadow: var(--ring);
}
.input-wrap .input {
  border: 0;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
}
.input-wrap .input:focus { box-shadow: none; }
.input-prefix, .input-suffix {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  background: var(--surface-3);
  color: var(--muted);
  font-weight: 600;
  font-size: .92rem;
  white-space: nowrap;
}
.input-prefix { border-right: 1px solid var(--line); }
.input-suffix { border-left: 1px solid var(--line); }
.input-wrap.is-invalid {
  border-color: var(--danger);
  background: rgba(251, 113, 133, .08);
}

/* Inline field (checkbox + label on one line) */
.field--inline {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}
.field--inline .field__label { font-weight: 500; font-family: var(--font-body); }
.field--inline.field { min-height: var(--tap); }

/* =========================================================
   §11 MODAL
   ========================================================= */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  /* The root layer is click-through; only an actual backdrop (added when a modal
     opens) captures pointer events. Without this, the fixed full-screen root
     intercepts every click once it exists, and the whole app appears frozen. */
  pointer-events: none;
}
.modal-root:empty { display: none; }
.modal__backdrop {
  position: fixed;
  inset: 0;
  pointer-events: auto;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  background: rgba(4, 7, 12, .66);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: modal-fade var(--transition);
}
.modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 540px;
  max-height: 92vh;
  max-height: 92dvh;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  color: var(--body);
  animation: modal-rise .26s cubic-bezier(.2, .8, .2, 1);
}
.modal--wide { max-width: 820px; }
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.modal__title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.12rem;
  color: var(--ink);
}
.modal__close {
  display: grid;
  place-items: center;
  width: var(--tap); height: var(--tap);
  flex: none;
  margin: -8px -6px -8px 0;
  border-radius: 50%;
  color: var(--muted);
  transition: background var(--transition), color var(--transition);
}
.modal__close:hover { background: var(--surface-2); color: var(--ink); }
.modal__close .ic { width: 22px; height: 22px; }
.modal__body {
  padding: 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
}
.modal__foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 18px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  background: var(--bg-2);
  flex: none;
}

@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-rise { from { transform: translateY(24px); opacity: .4; } to { transform: translateY(0); opacity: 1; } }

/* =========================================================
   §11 TOAST
   ========================================================= */
.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: min(92vw, 460px);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  color: var(--ink);
  font-weight: 500;
  font-size: .92rem;
  box-shadow: var(--shadow);
  pointer-events: auto;
  animation: toast-in .26s cubic-bezier(.2, .8, .2, 1);
}
.toast .ic { width: 18px; height: 18px; flex: none; }
.toast--success { border-left: 3px solid var(--good); }
.toast--success .ic { color: var(--good); }
.toast--error { border-left: 3px solid var(--danger); }
.toast--error .ic { color: var(--danger); }
@keyframes toast-in { from { transform: translateY(14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* =========================================================
   §11 EMPTY / AVATAR / MISC
   ========================================================= */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 40px 22px;
  background: var(--surface);
  border: 1px dashed var(--line-2);
  border-radius: var(--radius);
}
.empty__icon {
  display: grid;
  place-items: center;
  width: 60px; height: 60px;
  margin-bottom: 4px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
}
.empty__icon .ic { width: 30px; height: 30px; }
.empty__title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.12rem;
  color: var(--ink);
}
.empty__sub {
  max-width: 360px;
  color: var(--muted);
  font-size: .94rem;
}
.empty .btn { margin-top: 8px; }

.avatar {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  flex: none;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--font-head);
  font-weight: 700;
  font-size: .9rem;
  letter-spacing: .01em;
  text-transform: uppercase;
}
.avatar--gc {
  background: var(--retainage-50);
  color: var(--retainage);
}

/* Kicker (eyebrow-style label) */
.kicker {
  display: inline-block;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: .74rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
}

/* Pill (small neutral label / count) */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--body);
  font-weight: 600;
  font-size: .76rem;
  white-space: nowrap;
  border: 1px solid var(--line);
}

/* Progress bar (billed / contract) */
.progress {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.progress__bar {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #fbb43f, #f59412);
  box-shadow: 0 0 12px rgba(249, 168, 38, .45), inset 0 1px 0 rgba(255, 255, 255, .35);
  transition: width var(--transition), background var(--transition);
}
/* Fully collected — nothing owed — the bar fills and turns green. */
.progress--complete .progress__bar {
  background: linear-gradient(90deg, #34d399, #10b981);
  box-shadow: 0 0 12px rgba(16, 185, 129, .5), inset 0 1px 0 rgba(255, 255, 255, .3);
}

/* =========================================================
   §11 ALERT STRIP
   ========================================================= */
.alert-strip {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.alert-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 17px 19px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--muted);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
}
.alert-item:hover { box-shadow: var(--shadow); transform: translateY(-1px); border-color: var(--line-2); }
.alert-item__sev {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  flex: none;
  border-radius: 10px;
  background: var(--danger-50);
  color: var(--danger);
}
.alert-item__sev .ic { width: 19px; height: 19px; }
.alert-item .row__main { min-width: 0; }
/* severity coloring (driven by a modifier on alert-item) */
.alert-item--high   { border-left-color: var(--danger); }
.alert-item--high   .alert-item__sev { background: var(--danger-50); color: var(--danger); }
.alert-item--medium { border-left-color: var(--warn); }
.alert-item--medium .alert-item__sev { background: var(--warn-50); color: var(--warn); }
.alert-item--low    { border-left-color: var(--brand); }
.alert-item--low    .alert-item__sev { background: var(--brand-50); color: var(--brand); }

/* =========================================================
   §11 HELPERS
   ========================================================= */
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.truncate {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.right { text-align: right; margin-left: auto; }
.spread {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.stack { display: flex; flex-direction: column; gap: 15px; }
.flex {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.grid { display: grid; gap: 14px; }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }

/* Generic prose for letter bodies / disclaimers */
.prose { line-height: 1.6; color: var(--body); }
.prose p { margin-bottom: 10px; }

/* =========================================================
   RESPONSIVE — sidebar >= 860px, tabbar < 860px
   ========================================================= */
@media (min-width: 860px) {
  .app__sidebar { display: flex; }
  .topbar__brand { display: none; }      /* brand lives in the sidebar on desktop */
  .tabbar { display: none; }
  .app__main { padding-bottom: 0; }
  .toast-wrap { bottom: 24px; }
  .topbar {
    justify-content: center;
    min-height: 64px;
  }
  .topbar__actions { margin-left: 0; }
  /* Horizontal gutter comes from .view; only adjust vertical room here. */
  .container { padding-bottom: 40px; }
  /* Desktop only: the larger sidebar + content column share one fixed row, so trim
     the page gutter slightly. This reclaims the width the wider sidebar takes — content
     never regresses vs. before, and uses more of the screen as it grows. Mobile (<860px)
     keeps its original 18px floor untouched, so the topbar/content edges stay aligned. */
  .view { padding-inline: clamp(18px, 1.9vw, 32px); }

  /* Centered modal on desktop */
  .modal__backdrop { align-items: center; padding: 24px; }
  .modal { border-radius: var(--radius-lg); }
}

/* Roomy multi-column grids only where width allows */
@media (max-width: 600px) {
  .grid--2, .grid--3 { grid-template-columns: 1fr; }
  .form__grid { grid-template-columns: 1fr; }
  .hero-split { grid-template-columns: 1fr; }
  .view__header { flex-direction: column; align-items: stretch; }
  .view__actions .btn { flex: 1 1 auto; }
}

/* Very narrow phones (~380px) */
@media (max-width: 400px) {
  body { font-size: 15px; }
  .container { padding-bottom: 24px; }
  .hero-total { padding: 22px 18px; }
}

/* =========================================================
   ACCESSIBILITY / MOTION
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .btn:hover, .row--click:hover, a.row:hover, .row[onclick]:hover,
  .alert-item:hover, .btn--primary:hover, .btn--accent:hover, .btn--danger:hover,
  .card--interactive:hover {
    transform: none;
  }
}

/* Print — clean letters/print windows */
@media print {
  .app__sidebar, .topbar, .tabbar, .toast-wrap, .modal-root { display: none !important; }
  body { background: #fff; color: #000; background-image: none; }
  .app__main { padding: 0; }
}

/* =========================================================
   LIGHT THEME  (opt-in via <html data-theme="light">; dark is the default)
   Flips tokens to a light palette and overrides the handful of rules that
   hard-code dark surfaces/text. The hero stays a dark "spotlight" card in both
   themes (its rgba-white internals are correct on dark).
   ========================================================= */
:root[data-theme="light"] {
  --bg:           #f4f7fb;
  --bg-2:         #eaf0f7;
  --surface:      #ffffff;
  --surface-2:    #f1f5fa;
  --surface-3:    #e6edf6;
  --line:         #e4e9f1;
  --line-2:       #d3dce8;
  --ink:          #0f1b2d;
  --body:         #44546b;
  --muted:        #6b7a90;
  --accent:       #f59e0b;
  --accent-600:   #d97706;
  --accent-50:    rgba(245, 158, 11, .12);
  --good:         #16a34a;
  --good-50:      rgba(22, 163, 74, .10);
  --warn:         #d97706;
  --warn-50:      rgba(217, 119, 6, .10);
  --danger:       #dc2626;
  --danger-50:    rgba(220, 38, 38, .09);
  --retainage:    #0d9488;
  --retainage-50: rgba(13, 148, 136, .10);
  --brand:        #15395c;
  --brand-600:    #15395c;
  --brand-50:     rgba(21, 57, 92, .08);
  --shadow-sm:    0 1px 2px rgba(15, 27, 45, .06);
  --shadow:       0 12px 30px rgba(15, 27, 45, .10);
  --shadow-lg:    0 30px 70px rgba(15, 27, 45, .18);
  --glow-accent:  0 8px 22px rgba(245, 158, 11, .26);
  --ring:         0 0 0 3px rgba(245, 158, 11, .30);
  --ring-accent:  0 0 0 3px rgba(245, 158, 11, .30);
}

[data-theme="light"] body {
  background-color: var(--bg);
  background-image:
    radial-gradient(1100px 520px at 12% -8%, rgba(245, 158, 11, .05), transparent 60%),
    radial-gradient(900px 520px at 100% 0%, rgba(21, 57, 92, .04), transparent 55%);
}

/* Chrome (hard-coded dark in the base) -> light */
[data-theme="light"] .app__sidebar { background: linear-gradient(180deg, #f8fafd, #eef3f9); }
[data-theme="light"] .app__sidebar .brand__name { color: var(--ink); }
[data-theme="light"] .app__sidebar-foot a { color: var(--brand-600); }
[data-theme="light"] .topbar { background: rgba(255, 255, 255, .78); }
[data-theme="light"] .tabbar { background: rgba(255, 255, 255, .95); }

/* Badge text: the dark theme's bright hues are too light on white -> darken */
[data-theme="light"] .badge--active,
[data-theme="light"] .badge--paid,
[data-theme="light"] .badge--good     { color: #15803d; }
[data-theme="light"] .badge--complete,
[data-theme="light"] .badge--sent,
[data-theme="light"] .badge--low       { color: #1d4ed8; }
[data-theme="light"] .badge--pending,
[data-theme="light"] .badge--unpaid,
[data-theme="light"] .badge--medium,
[data-theme="light"] .badge--ok        { color: #b45309; }
[data-theme="light"] .badge--disputed,
[data-theme="light"] .badge--overdue,
[data-theme="light"] .badge--high,
[data-theme="light"] .badge--poor      { color: #b91c1c; }
[data-theme="light"] .badge--released  { color: #0f766e; }

/* Native date picker + text selection render light */
[data-theme="light"] input[type="date"].input,
[data-theme="light"] input[type="date"] { color-scheme: light; }
[data-theme="light"] ::selection { background: rgba(245, 158, 11, .25); color: #1c1304; }

/* Hero "Total owed" card inverts to light too (it was a fixed dark spotlight). */
[data-theme="light"] .hero-total {
  color: var(--ink);
  background:
    radial-gradient(620px 320px at 88% -20%, rgba(245, 158, 11, .14), transparent 60%),
    linear-gradient(150deg, #ffffff 0%, #eef3fb 62%);
  border-color: var(--line-2);
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, .9),
    0 0 60px -30px rgba(245, 158, 11, .32);
}
[data-theme="light"] .hero-total__label { color: var(--muted); }
[data-theme="light"] .hero-total__value {
  background: none;
  -webkit-text-fill-color: var(--ink);
  color: var(--ink);
  filter: drop-shadow(0 2px 12px rgba(245, 158, 11, .18));
}
[data-theme="light"] .hero-split .stat {
  background: var(--surface-2);
  border-color: var(--line);
  backdrop-filter: none;
}
[data-theme="light"] .hero-split .stat__label { color: var(--muted); }
[data-theme="light"] .hero-split .stat__sub { color: var(--muted); }
[data-theme="light"] .hero-split .stat__icon { background: var(--surface-3); color: var(--muted); }
[data-theme="light"] .hero-split .stat__value { color: var(--ink); }
[data-theme="light"] .hero-split .stat--good .stat__value { color: var(--good); }
[data-theme="light"] .hero-split .stat--retainage .stat__value { color: var(--retainage); }
