/*
 * BudgetData.net v2 — Design System
 * Built from brand-guide.md + budgetdata-tokens.css (March 2026)
 * ─────────────────────────────────────────────────────────────────────────────
 * Single source of truth. Every page imports this file.
 * Font: DM Sans 400 + 600 only.
 * Import: https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;600&display=swap
 */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;600&display=swap');


/* ══════════════════════════════════════════════════════════════════════════
   DESIGN TOKENS
   ══════════════════════════════════════════════════════════════════════════ */
:root {
  /* ── Color ramps ── */
  --green-50:   #F2F8F1;
  --green-100:  #DDF0D8;
  --green-200:  #A8D89E;
  --green-400:  #5BAD53;
  --green-600:  #3A7A32;
  --green-800:  #2D5A27;
  --green-900:  #1C3818;

  --orange-50:  #FEF2E6;
  --orange-100: #FDEBD8;
  --orange-200: #F9C58A;
  --orange-400: #E88528;
  --orange-600: #C96A18;
  --orange-800: #8A420C;
  --orange-900: #5C2B07;

  --neutral-50:  #F8F8F7;
  --neutral-100: #EDEDE9;
  --neutral-200: #D4D4CE;
  --neutral-400: #9B9B94;
  --neutral-600: #636360;
  --neutral-800: #3C3C3A;
  --neutral-900: #1A1A18;

  /* ── Semantic ── */
  --color-primary:        #3A7A32;
  --color-primary-dark:   #2D5A27;
  --color-primary-light:  #DDF0D8;
  --color-accent:         #C96A18;
  --color-accent-dark:    #8A420C;
  --color-accent-light:   #FDEBD8;
  --color-surface:        #F8F8F7;
  --color-surface-raised: #ffffff;
  --color-border:         #D4D4CE;
  --color-border-subtle:  #EDEDE9;
  --color-text-base:      #1A1A18;
  --color-text-muted:     #3C3C3A;
  --color-text-hint:      #636360;

  /* ── Typography ── */
  --font-sans: 'DM Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'Menlo', 'Consolas', monospace;
  --font-weight-regular: 400;
  --font-weight-bold:    600;

  /* ── Spacing ── */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;

  /* ── Radius ── */
  --radius-sm:   5px;
  --radius-md:   7px;
  --radius-lg:   10px;
  --radius-pill: 50px;

  /* ── Borders ── */
  --border-default: 0.5px solid #D4D4CE;
  --border-subtle:  0.5px solid #EDEDE9;

  /* ── Transitions ── */
  --transition-fast:   0.12s ease;
  --transition-normal: 0.2s ease;
  --transition-pill:   0.22s cubic-bezier(0.4, 0, 0.2, 1);

  /* ── Sidebar ── */
  --sidebar-bg:        #1C3818;
  --sidebar-width:     240px;
  --sidebar-divider:   rgba(255,255,255,0.08);
  --nav-active-bg:     #F8F8F7;

  /* ── Shadows ── */
  --shadow-sm:  0 1px 3px rgba(28,56,24,0.06);
  --shadow-md:  0 2px 8px rgba(28,56,24,0.08);
  --shadow-lg:  0 4px 20px rgba(28,56,24,0.10);

  /* ── Layout ── */
  --content-max-width: 1140px;
}


/* ══════════════════════════════════════════════════════════════════════════
   BASE RESET
   ══════════════════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--color-text-base);
  background: var(--color-surface);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-accent); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--color-accent-dark); }
img, svg { display: block; max-width: 100%; }
button { font-family: var(--font-sans); cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: var(--font-sans); font-size: 14px; }


/* ══════════════════════════════════════════════════════════════════════════
   TYPOGRAPHY
   ══════════════════════════════════════════════════════════════════════════ */
.text-display {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--color-text-base);
}
.text-heading {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-text-base);
}
.text-subheading {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text-base);
}
.text-body {
  font-size: 15px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--color-text-muted);
}
.text-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--color-text-hint);
}
.text-data {
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--color-primary);
}
.text-muted    { color: var(--color-text-muted); }
.text-hint     { color: var(--color-text-hint); }
.text-accent   { color: var(--color-accent); }
.text-green    { color: var(--color-primary); }
.text-positive { color: var(--color-primary); }
.text-negative { color: var(--color-accent); }


/* ══════════════════════════════════════════════════════════════════════════
   APP SHELL
   ══════════════════════════════════════════════════════════════════════════ */
.app-shell { display: flex; min-height: 100vh; flex-direction: column; max-width: 100%; overflow-x: clip; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  padding: 20px 0 16px;
  flex-shrink: 0;
}

/* Logo */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px 14px;
  margin-bottom: 8px;
  border-bottom: 0.5px solid var(--sidebar-divider);
}
.sidebar-logo-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  overflow: visible;
}
.sidebar-logo-text {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1;
}
.sidebar-logo-text .wm-budget { color: #A8D89E; font-weight: 600; }
.sidebar-logo-text .wm-data   { color: rgba(255,255,255,0.45); font-weight: 400; }
.sidebar-logo-text .wm-dot    { color: #C96A18; font-weight: 600; }
.sidebar-logo-text .wm-net    { color: rgba(255,255,255,0.3); font-weight: 400; }

/* Nav lists */
.nav-list   { display: flex; flex-direction: column; gap: 1px; flex: 1; overflow: visible; padding: 4px 0; }
.nav-bottom { border-top: 0.5px solid var(--sidebar-divider); padding-top: 6px; margin-top: 4px; }
.nav-divider{ border: none; border-top: 0.5px solid var(--sidebar-divider); margin: 8px 0; }

/* ── Plain nav item ── */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px 9px 14px;
  font-size: 15px;
  font-weight: 400;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  position: relative;
  transition: color var(--transition-normal);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}
.nav-item svg.nav-icon {
  width: 14px; height: 14px;
  flex-shrink: 0;
  opacity: 0.55;
  transition: opacity var(--transition-normal);
}
.nav-item:hover { color: rgba(255,255,255,0.95); }
.nav-item:hover svg.nav-icon { opacity: 0.85; }

/* Active plain item — white cutout */
.nav-item.active {
  color: #1A1A18;
  background: var(--nav-active-bg);
  font-weight: 600;
  border-radius: 16px 0 0 16px;
  margin-left: 6px;
  position: relative;
  overflow: visible;
  z-index: 10;
  box-shadow: -2px 0 0 0 rgba(255,255,255,0.08);
}
.nav-item.active::before,
.nav-item.active::after {
  z-index: 11;
}
/* Ensure other nav items don't cover the active item's pseudo-elements */
.nav-item:not(.active) {
  position: relative;
  z-index: 1;
}
.nav-group {
  position: relative;
  z-index: 1;
}
.nav-group.open {
  z-index: 10;
}
.nav-group.open .nav-group-cap::after,
.nav-group.open .nav-group-header::before {
  z-index: 11;
}
.nav-item.active svg.nav-icon { opacity: 1; color: var(--color-primary); }
.nav-item.active::before,
.nav-item.active::after { display: none; }

/* ── Nav group (parent + children share one white block) ── */
.nav-group { position: relative; }

.nav-group-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px 9px 14px;
  font-size: 15px;
  font-weight: 400;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  position: relative;
  transition: color var(--transition-normal);
  white-space: nowrap;
  user-select: none;
}
.nav-group-item svg.nav-icon { width: 14px; height: 14px; flex-shrink: 0; opacity: 0.55; transition: opacity var(--transition-normal); }
.nav-group-item .nav-chevron {
  width: 12px; height: 12px;
  margin-left: auto; flex-shrink: 0;
  opacity: 0.35;
  transition: transform var(--transition-normal), opacity var(--transition-normal);
}
.nav-group-item:hover { color: rgba(255,255,255,0.95); }
.nav-group-item:hover svg.nav-icon { opacity: 0.85; }

/* ── Open group — one seamless white block ──
   The header, sub-items, and cap share the same bg.
   Corner cutouts use box-shadow to fake the curved join
   between the dark sidebar and the white block. */
.nav-group.open .nav-group-header {
  background: var(--nav-active-bg);
  margin: 1px 8px 0;
  border-radius: 8px 8px 0 0;
}
.nav-group.open .nav-group-header::before { display: none; }
.nav-group.open .nav-group-item { color: #1A1A18; font-weight: 600; }
.nav-group.open .nav-group-item svg.nav-icon { opacity: 1; color: var(--color-primary); }
.nav-group.open .nav-group-item .nav-chevron { opacity: 1; color: var(--color-primary); transform: rotate(180deg); }

/* Sub-items */
.nav-subs { overflow: hidden; max-height: 0; transition: max-height 0.25s ease; }
.nav-group.open .nav-subs {
  max-height: 200px;
  background: var(--nav-active-bg);
  margin: 0 8px;
  padding-bottom: 4px;
}

.nav-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 18px 6px 34px;
  font-size: 12px;
  font-weight: 400;
  color: #9B9B94;
  cursor: pointer;
  position: relative;
  transition: color var(--transition-fast);
}
.nav-sub::before { content: ''; position: absolute; left: 22px; top: 0; bottom: 0; width: 1px; background: #D4D4CE; }
.nav-sub-dot { width: 4px; height: 4px; border-radius: 50%; background: #D4D4CE; flex-shrink: 0; transition: background var(--transition-fast); }
.nav-sub:hover { color: var(--color-primary); }
.nav-sub:hover .nav-sub-dot { background: var(--color-primary); }
.nav-sub.active { color: var(--color-primary); font-weight: 600; }
.nav-sub.active .nav-sub-dot { background: var(--color-accent); }

/* Bottom cap — closes the white block with a rounded corner */
.nav-group-cap { display: none; }
.nav-group.open .nav-group-cap {
  display: block;
  height: 8px;
  background: var(--nav-active-bg);
  margin: 0 8px 1px;
  border-radius: 0 0 8px 8px;
}
.nav-group.open .nav-group-cap::after { display: none; }

/* Orange accent dot */
.nav-accent-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--color-accent);
  margin-left: auto;
  flex-shrink: 0;
  display: none;
}
.nav-item.active .nav-accent-dot { display: block; }

/* ── Main content ── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  width: calc(100% - var(--sidebar-width));
  padding: 36px 64px 64px 56px;
  box-sizing: border-box;
  min-height: 100vh;
}

/* Inner content constrained to max-width, centered */
.main-content > * {
  max-width: 1040px;
}

/* Disclaimer and breadcrumb span full width */
.main-content > .disclaimer-bar,
.main-content > .breadcrumb {
  max-width: none;
  margin-left: -56px;
  margin-right: -64px;
  width: calc(100% + 120px);
}

/* Footer sits outside main, full width */
.site-footer {
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
}
@media(max-width: 768px) {
  .site-footer { margin-left: 0; width: 100%; }
}

.page-header   { margin-bottom: var(--space-6); }
.page-title    { font-size: 32px; font-weight: 600; color: var(--color-text-base); letter-spacing: -0.02em; line-height: 1.2; }
.page-subtitle { font-size: 15px; color: var(--color-text-muted); margin-top: 4px; }


/* ══════════════════════════════════════════════════════════════════════════
   CARDS — top accent border
   ══════════════════════════════════════════════════════════════════════════ */
.card {
  background: var(--color-surface-raised);
  border: var(--border-default);
  border-top: 3px solid var(--color-primary);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
}
.card--accent { border-top-color: var(--color-accent); }
.card--subtle { border-top-color: var(--neutral-200); }
.card--none   { border-top-width: 0.5px; }

.card-surface {
  background: var(--color-surface);
  border: none;
  border-radius: var(--radius-lg);
  padding: 16px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-base);
  margin-bottom: 12px;
}
.card-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--color-text-hint);
  margin-bottom: 12px;
}
.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}


/* ══════════════════════════════════════════════════════════════════════════
   STAT CARDS
   ══════════════════════════════════════════════════════════════════════════ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.stat-card {
  background: var(--color-surface-raised);
  border: var(--border-default);
  border-top: 3px solid var(--color-primary);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}
.stat-card--accent { border-top-color: var(--color-accent); }
.stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--color-text-hint);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 24px;
  color: var(--color-primary);
  line-height: 1;
  letter-spacing: -0.01em;
}
.stat-change {
  font-size: 12px;
  margin-top: 4px;
  color: var(--color-text-hint);
}
.stat-change.up   { color: var(--color-accent); }
.stat-change.down { color: var(--color-primary); }


/* ══════════════════════════════════════════════════════════════════════════
   BAR ROWS
   ══════════════════════════════════════════════════════════════════════════ */
.bar-row { display: flex; align-items: center; gap: 12px; padding: 5px 0; }
.bar-row-name  { font-size: 13px; color: var(--color-text-muted); min-width: 140px; flex-shrink: 0; }
.bar-track     { flex: 1; height: 6px; background: var(--neutral-100); border-radius: var(--radius-pill); overflow: hidden; }
.bar-fill      { height: 100%; border-radius: var(--radius-pill); background: var(--color-primary); transition: width 0.6s cubic-bezier(0.25,1,0.5,1); }
.bar-fill--accent { background: var(--color-accent); }
.bar-fill--muted  { background: var(--neutral-200); }
.bar-row-value { font-family: var(--font-mono); font-size: 13px; color: var(--color-text-muted); min-width: 64px; text-align: right; flex-shrink: 0; }


/* ══════════════════════════════════════════════════════════════════════════
   TABLES
   ══════════════════════════════════════════════════════════════════════════ */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--color-text-hint); text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border);
}
.data-table td {
  padding: 10px 12px;
  color: var(--color-text-base);
  border-bottom: 0.5px solid var(--color-border-subtle);
}
.data-table th.r, .data-table td.r { text-align: right; }
.data-table tr:last-child td       { border-bottom: none; }
.data-table tr:hover td            { background: var(--green-50); }
.data-table .row-total td          { font-weight: 600; border-top: 1px solid var(--color-border); }
.data-table td.mono                { font-family: var(--font-mono); }


/* ══════════════════════════════════════════════════════════════════════════
   BUTTONS
   All use !important to prevent host-page stylesheet interference.
   Hover uses filter:brightness so it works regardless of color overrides.
   ══════════════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: var(--radius-md);
  cursor: pointer;
  letter-spacing: 0.01em;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  transition: filter var(--transition-normal), transform var(--transition-fast);
}
.btn:hover  { filter: brightness(0.88); }
.btn:active { transform: scale(0.97); filter: brightness(0.82); }

.btn-primary   { background-color: #3A7A32 !important; color: #ffffff !important; border: 1.5px solid #3A7A32 !important; }
.btn-secondary { background-color: #DDF0D8 !important; color: #2D5A27 !important; border: 1.5px solid #A8D89E !important; }
.btn-accent    { background-color: #C96A18 !important; color: #ffffff !important; border: 1.5px solid #C96A18 !important; }
.btn-ghost     { background-color: #EDEDE9 !important; color: #3C3C3A !important; border: 1.5px solid #D4D4CE !important; }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 11px 24px; font-size: 15px; }


/* ══════════════════════════════════════════════════════════════════════════
   SEGMENTED PILL SELECTOR
   JS required — call initPill(id) on load, sp(id, idx) on click.
   Uses double-rAF to ensure layout is complete before measuring.
   ══════════════════════════════════════════════════════════════════════════ */
.pill-selector {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-pill);
  padding: 3px;
  position: relative;
}
.pill-selector--green  { background-color: #F2F8F1; border: 0.5px solid #A8D89E; }
.pill-selector--orange { background-color: #FEF2E6; border: 0.5px solid #F9C58A; }

.pill-track {
  position: absolute;
  top: 3px;
  height: calc(100% - 6px);
  border-radius: var(--radius-pill);
  z-index: 0;
  pointer-events: none;
}
.pill-selector--green  .pill-track { background-color: #3A7A32; }
.pill-selector--orange .pill-track { background-color: #C96A18; }

.pill-option {
  position: relative;
  z-index: 1;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: color var(--transition-normal);
}
.pill-selector--green  .pill-option        { color: #3A7A32; }
.pill-selector--green  .pill-option.active { color: #ffffff; }
.pill-selector--orange .pill-option        { color: #8A420C; }
.pill-selector--orange .pill-option.active { color: #ffffff; }


/* ══════════════════════════════════════════════════════════════════════════
   BADGES
   ══════════════════════════════════════════════════════════════════════════ */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.02em;
}
.badge--approved { background: #DDF0D8; color: #2D5A27; }
.badge--proposed { background: #FDEBD8; color: #8A420C; }
.badge--draft    { background: #EDEDE9; color: #636360; border: 0.5px solid #D4D4CE; }
.badge--neutral  { background: #EDEDE9; color: #636360; }
.badge--green    { background: #DDF0D8; color: #2D5A27; }
.badge--orange   { background: #FDEBD8; color: #8A420C; }


/* ══════════════════════════════════════════════════════════════════════════
   TOOLTIP  (ℹ)
   ══════════════════════════════════════════════════════════════════════════ */
.tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px; height: 15px;
  border-radius: 50%;
  background-color: #3A7A32;
  color: #ffffff;
  font-size: 9px;
  font-weight: 600;
  cursor: help;
  flex-shrink: 0;
  user-select: none;
  vertical-align: middle;
  margin-left: 4px;
  position: relative;
  transition: background var(--transition-fast);
}
.tip:hover { background-color: #2D5A27; }
.tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1A1A18;
  color: #F8F8F7;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  padding: 8px 12px;
  border-radius: 8px;
  width: 240px;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s 0.08s;
  z-index: 500;
  text-transform: none;
  letter-spacing: 0;
}
.tip:hover::after, .tip:focus::after { opacity: 1; }
.tip.tip-left::after { left: auto; right: 0; transform: none; }


/* ══════════════════════════════════════════════════════════════════════════
   NOTICE / DISCLAIMER BOXES
   ══════════════════════════════════════════════════════════════════════════ */
.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.55;
}
.notice svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 1px; }
.notice--green   { background: #DDF0D8; border: 0.5px solid #A8D89E; color: #2D5A27; }
.notice--orange  { background: #FDEBD8; border: 0.5px solid #F9C58A; color: #8A420C; }
.notice--neutral { background: #EDEDE9; border: 0.5px solid #D4D4CE; color: #636360; }
.notice--blue    { background: #E8F0FD; border: 0.5px solid #A8C0F0; color: #1A3A6B; }
.notice--blue a  { color: #1A3A6B; font-weight: 600; text-decoration: underline; }
.notice--blue a:hover { text-decoration: none; }


/* ══════════════════════════════════════════════════════════════════════════
   FORM ELEMENTS
   ══════════════════════════════════════════════════════════════════════════ */
.form-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--color-text-hint);
  margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
  display: block;
  width: 100%;
  background: var(--color-surface-raised);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0 12px;
  height: 38px;
  font-size: 14px;
  color: var(--color-text-base);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}
.form-textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 80px; }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px #DDF0D8;
}
.form-group { margin-bottom: 20px; }


/* ══════════════════════════════════════════════════════════════════════════
   LAYOUT UTILITIES
   ══════════════════════════════════════════════════════════════════════════ */
.flex            { display: flex; }
.flex-col        { flex-direction: column; }
.items-center    { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.gap-6  { gap: 24px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; }

.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mt-8 { margin-top: 32px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }

.text-right  { text-align: right; }
.text-center { text-align: center; }

.divider { border: none; border-top: 0.5px solid var(--color-border-subtle); margin: 24px 0; }


/* ══════════════════════════════════════════════════════════════════════════
   LOGO ANIMATION
   transform-box:fill-box is required — makes transform-origin relative
   to the element itself, not the SVG viewport.
   ══════════════════════════════════════════════════════════════════════════ */
.logo-bar {
  transform-box: fill-box;
  transform-origin: bottom center;
  animation: logo-bar-rise 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.logo-bar:nth-child(1) { animation-delay: 0.00s; }
.logo-bar:nth-child(2) { animation-delay: 0.10s; }
.logo-bar:nth-child(3) { animation-delay: 0.20s; }
.logo-bar:nth-child(4) { animation-delay: 0.05s; }

@keyframes logo-bar-rise {
  from { transform: scaleY(0); opacity: 0; }
  to   { transform: scaleY(1); opacity: 1; }
}

.logo-line {
  stroke-dasharray: 70;
  stroke-dashoffset: 70;
  animation: logo-line-draw 0.45s ease both;
  animation-delay: 0.45s;
}
@keyframes logo-line-draw {
  to { stroke-dashoffset: 0; }
}

.logo-dot {
  transform-box: fill-box;
  transform-origin: center center;
  animation: logo-dot-pop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.logo-dot:nth-child(1) { animation-delay: 0.60s; }
.logo-dot:nth-child(2) { animation-delay: 0.67s; }
.logo-dot:nth-child(3) { animation-delay: 0.74s; }
.logo-dot:nth-child(4) { animation-delay: 0.81s; }

@keyframes logo-dot-pop {
  from { transform: scale(0); }
  to   { transform: scale(1); }
}

.logo-wordmark {
  opacity: 0;
  animation: logo-fade-in 0.35s ease both;
  animation-delay: 0.55s;
}
@keyframes logo-fade-in {
  to { opacity: 1; }
}


/* ══════════════════════════════════════════════════════════════════════════
   PILL SELECTOR JS HELPER
   Include once per page:

   function initPill(id) {
     requestAnimationFrame(function(){
       requestAnimationFrame(function(){
         var c = document.getElementById(id);
         var t = document.getElementById(id+'-track');
         var a = c && c.querySelector('.pill-option.active');
         if(a && t){ t.style.left=a.offsetLeft+'px'; t.style.width=a.offsetWidth+'px'; }
       });
     });
   }
   function selectPill(id, idx) {
     var c = document.getElementById(id);
     var t = document.getElementById(id+'-track');
     var opts = c.querySelectorAll('.pill-option');
     opts.forEach(function(o,i){ o.classList.toggle('active', i===idx); });
     var a = opts[idx];
     t.style.transition = 'left 0.22s cubic-bezier(0.4,0,0.2,1), width 0.22s cubic-bezier(0.4,0,0.2,1)';
     t.style.left  = a.offsetLeft+'px';
     t.style.width = a.offsetWidth+'px';
   }
   ══════════════════════════════════════════════════════════════════════════ */


/* ══════════════════════════════════════════════════════════════════════════
   ACCESSIBILITY
   ══════════════════════════════════════════════════════════════════════════ */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: 3px;
}
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border-width: 0;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}


/* ══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Sidebar — slide off screen, open on toggle */
  .sidebar {
    transform: translateX(-200px);
    transition: transform 0.25s ease;
    z-index: 200;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  /* Main content — full width, tighter padding */
  .main-content {
    margin-left: 0;
    width: 100%;
    padding: 56px 20px 24px;
    max-width: 100%;
  }

  /* Inner content fills full width on mobile */
  .main-content > * {
    max-width: 100%;
  }

  /* Fix full-bleed elements on mobile */
  .main-content > .disclaimer-bar,
  .main-content > .breadcrumb {
    margin-left: -20px;
    margin-right: -20px;
    width: calc(100% + 40px);
  }

  /* Grids collapse to single column */
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

  /* Stat grid: 2 columns on mobile */
  .stat-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }

  /* Stat cards — tighter on mobile */
  .stat-card { padding: 12px; min-width: 0; overflow: hidden; }
  .stat-value { font-size: clamp(1.1rem, 3.5vw, 1.5rem); white-space: nowrap; }
  .stat-label { font-size: 0.7rem; }
  /* Allow stat-change text to wrap rather than truncate with ellipsis */
  .stat-change { white-space: normal; overflow: visible; }

  /* Suppress CSS ::after tooltip on mobile — JS touch handler provides positioning */
  .tip::after, .tip:hover::after, .tip:focus::after { display: none; }

  /* Page title smaller */
  .page-title { font-size: 24px; }

  /* Cards tighter padding */
  .card { padding: 14px 16px; }

  /* Bar rows — label wraps, don't force min-width */
  .bar-row { flex-wrap: wrap; gap: 8px; }
  .bar-row-name { min-width: 0; width: 100%; }

  /* Data table — allow horizontal scroll */
  .data-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table { min-width: 480px; }

  /* Buttons full width in forms */
  .btn-block-mobile { width: 100%; justify-content: center; }

  /* Pill selector — smaller text */
  .pill-option { font-size: 12px; padding: 5px 12px; }
}

@media (max-width: 480px) {
  /* Keep 2-column stat grid even on small phones */
  .stat-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }

  .page-title { font-size: 22px; }

  .main-content { padding: 52px 16px 16px; }

  /* Card header stack vertically */
  .ov-card-hdr { flex-direction: column; gap: 8px; }
}
