/* ═══════════════════════════════════════════════════════════════
   NZF Dashboard — Brand-Compliant Stylesheet
   Colours, typography and components sourced directly from
   the NZF Figma brand guide.
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Bree+Serif&family=Cambay:ital,wght@0,400;0,700;1,400;1,700&display=swap');

/* ── Design Tokens ────────────────────────────────────────────── */
:root {
  /* Primary — exact NZF brand red */
  --color-primary:        #EE3524;
  --color-primary-dark:   #B51E10;
  --color-primary-bg:     #FFF6F5;

  /* Alternative palette */
  --color-yellow:         #FDB913;
  --color-yellow-bg:      #FFF9EB;
  --color-blue:           #0081C6;
  --color-blue-bg:        #EBF6FF;
  --color-green:          #49A942;
  --color-green-bg:       #ECFFEB;

  /* Neutral */
  --color-black:          #231F1F;
  --color-grey:           #4C6060;
  --color-mid-grey:       #9F9393;
  --color-light-grey:     #CFCFC9;
  --color-bg:             #F5F4F4;
  --color-white:          #FFFFFF;

  /* Feedback */
  --color-success:        #49A942;
  --color-success-bg:     #ECFFEB;
  --color-warning:        #FDB913;
  --color-warning-bg:     #FFF9EB;
  --color-alert:          #FF5C00;
  --color-alert-bg:       #FFF6F5;

  /* Semantic aliases */
  --bg:                   var(--color-bg);
  --surface:              var(--color-white);
  --surface-2:            #F5F4F4;
  --border:               var(--color-light-grey);
  --border-subtle:        #E8E6E6;
  --text-primary:         var(--color-black);
  --text-secondary:       var(--color-grey);
  --text-muted:           var(--color-mid-grey);

  /* Layout */
  --nav-width:            248px;
  --radius:               6px;
  --radius-lg:            10px;
  --shadow-sm:            0 1px 3px rgba(35,31,31,0.08);
  --shadow-md:            0 4px 16px rgba(35,31,31,0.10);
  --shadow-lg:            0 8px 32px rgba(35,31,31,0.14);
  --transition:           0.18s ease;
}

/* ── Reset ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }

body {
  font-family: 'Cambay', sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
}

/* ── Typography scale ─────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Bree Serif', serif;
  font-weight: 400;
  line-height: 1.2;
  color: var(--text-primary);
}

/* ── Layout ───────────────────────────────────────────────────── */
.layout {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  width: var(--nav-width);
  background: var(--color-black);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 18px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo-link {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-decoration: none;
}

.sidebar-logo-card {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-white);
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.sidebar-logo-card img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 44px;
  object-fit: contain;
}

.sidebar-tagline {
  font-family: 'Cambay', sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  color: rgba(255,255,255,0.7);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  text-align: center;
}

/* ── Month tabs + month panel (shared component) ──────────────── */
.month-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.month-tab {
  padding: 4px 12px;
  font-family: 'Cambay', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 4px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all .1s;
}
.month-tab:hover  { background: var(--surface); border-color: var(--border-subtle); }
.month-tab.active { background: #1F3864; color: #fff; }

.month-panel {
  border: 1px solid var(--border-subtle);
  border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
  margin-bottom: 20px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-section-label {
  font-family: 'Cambay', sans-serif;
  color: var(--color-mid-grey);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 16px 20px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  font-family: 'Cambay', sans-serif;
  font-size: 0.875rem;
  border-left: 3px solid transparent;
  transition: all var(--transition);
}

.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: var(--color-white);
  border-left-color: rgba(238,53,38,0.4);
}

.nav-item.active {
  background: rgba(238,53,38,0.12);
  color: var(--color-white);
  border-left-color: var(--color-primary);
}

.nav-item svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  opacity: 0.8;
}

.nav-item.active svg,
.nav-item:hover svg { opacity: 1; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

/* ── Auth badges ──────────────────────────────────────────────── */
#user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,0.72);
  font-family: 'Cambay', sans-serif;
  font-size: 0.8rem;
  min-width: 0;
}

.user-avatar {
  width: 34px; height: 34px;
  background: var(--color-primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--color-white);
  font-family: 'Cambay', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  line-height: 1.25;
}

.user-info .user-name {
  color: rgba(255,255,255,0.95);
  font-weight: 600;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-info .user-email {
  color: rgba(255,255,255,0.5);
  font-size: 0.7rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.signout-btn {
  flex-shrink: 0;
  width: 30px; height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: rgba(255,255,255,0.55);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.signout-btn svg {
  width: 15px;
  height: 15px;
}
.signout-btn:hover {
  background: rgba(255,255,255,0.06);
  color: var(--color-white);
  border-color: rgba(255,255,255,0.25);
}
.signout-btn:focus-visible {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.15);
}

.auth-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(253,185,19,0.15);
  color: var(--color-warning);
  font-family: 'Cambay', sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 20px;
}

.auth-status-badge::before {
  content: '';
  width: 5px; height: 5px;
  background: var(--color-warning);
  border-radius: 50%;
}

/* ── Main content ─────────────────────────────────────────────── */
.main {
  margin-left: var(--nav-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Top bar ──────────────────────────────────────────────────── */
.topbar {
  background: var(--color-white);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 28px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-yellow) 50%, var(--color-blue) 100%);
  opacity: 0.3;
}

.draft-disclaimer {
  background: #fff8e1;
  border-bottom: 2px solid #f0d060;
  padding: 9px 28px;
  font-family: 'Cambay', sans-serif;
  font-size: 0.8rem;
  color: #7a5c00;
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  box-sizing: border-box;
  flex-shrink: 0;
}
.draft-disclaimer a {
  color: #7a5c00;
  font-weight: 700;
  text-decoration: underline;
}
.draft-disclaimer a:hover {
  color: var(--color-primary);
}

.topbar-title {
  font-family: 'Bree Serif', serif;
  font-size: 1rem;
  color: var(--text-primary);
  font-weight: 400;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 20px;
  font-family: 'Cambay', sans-serif;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.last-updated {
  display: flex;
  align-items: center;
  gap: 6px;
}

.last-updated::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--color-success);
  border-radius: 50%;
}

/* ── Page content ─────────────────────────────────────────────── */
.page-content {
  padding: 28px;
  flex: 1;
}

.page-header {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}

.page-header-left h1 {
  font-family: 'Bree Serif', serif;
  font-size: 1.75rem;
  font-weight: 400;
  color: var(--text-primary);
  line-height: 1.2;
}

.page-header-left p {
  font-family: 'Cambay', sans-serif;
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 4px;
  max-width: 880px;
  line-height: 1.55;
}

/* Tagline beneath the H1 — a beat between title and prose. Uses the
   primary brand colour for emphasis without competing with the H1. */
.page-header-left .page-header-tagline {
  font-family: 'Bree Serif', serif;
  font-size: 1.0625rem;
  color: var(--color-primary);
  margin-top: 8px;
  font-style: italic;
}
.page-header-left .page-header-tagline + p {
  margin-top: 12px;
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  border-radius: var(--radius);
  font-family: 'Cambay', sans-serif;
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-white);
  border-color: var(--color-primary);
}
.btn-primary:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
}

.btn-secondary {
  background: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.btn-secondary:hover {
  background: var(--color-primary-bg);
}

.btn:disabled,
.btn-disabled {
  background: var(--color-light-grey);
  color: var(--color-mid-grey);
  border-color: var(--color-light-grey);
  cursor: not-allowed;
}

/* ── KPI Cards ────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
  position: relative;
  overflow: hidden;
}

.kpi-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--kpi-color, var(--color-primary));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.kpi-card.accent-red    { --kpi-color: var(--color-primary); }
.kpi-card.accent-yellow { --kpi-color: var(--color-yellow);  }
.kpi-card.accent-blue   { --kpi-color: var(--color-blue);    }
.kpi-card.accent-green  { --kpi-color: var(--color-green);   }

.kpi-label {
  font-family: 'Cambay', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.kpi-value {
  font-family: 'Bree Serif', serif;
  font-size: 1.9rem;
  color: var(--text-primary);
  line-height: 1.1;
  font-weight: 400;
}

.kpi-change {
  font-family: 'Cambay', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 3px;
}
.kpi-change.up   { color: var(--color-success); }
.kpi-change.down { color: var(--color-primary);  }
.kpi-change.flat { color: var(--text-muted);     }

/* ── Chart Cards ──────────────────────────────────────────────── */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
}

.chart-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}

.chart-card-title {
  font-family: 'Bree Serif', serif;
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-primary);
}

.chart-card-subtitle {
  font-family: 'Cambay', sans-serif;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.chart-container {
  position: relative;
  height: 260px;
}

/* ── Dashboard nav cards (home page) ──────────────────────────── */
.section-label {
  font-family: 'Cambay', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 12px;
  margin-top: 8px;
}

.dashboard-card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px;
  cursor: pointer;
  text-decoration: none;
  display: block;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.dashboard-card::after {
  content: '→';
  position: absolute;
  right: 20px; bottom: 20px;
  font-size: 1.1rem;
  color: var(--color-light-grey);
  transition: all var(--transition);
}

.dashboard-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--card-color, var(--color-primary));
}

.dashboard-card:hover::after {
  color: var(--card-color, var(--color-primary));
  right: 16px;
}

.dashboard-card-section {
  font-family: 'Cambay', sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--card-color, var(--color-primary));
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.dashboard-card-section::before {
  content: '';
  width: 3px; height: 12px;
  background: var(--card-color, var(--color-primary));
  border-radius: 2px;
}

.dashboard-card-title {
  font-family: 'Bree Serif', serif;
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.dashboard-card-desc {
  font-family: 'Cambay', sans-serif;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ── Per-tile data-status block ───────────────────────────────────
   Inline source-date / refreshed / records summary that replaces the
   old separate Data Refresh Status table. Populated by JS in
   /dashboards/index.html. Subtle by default; the tile's own
   .is-stale / .is-failed states draw the user's eye when relevant. */
.dashboard-card-status {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-subtle);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  font-family: 'Cambay', sans-serif;
  font-size: 0.74rem;
  line-height: 1.4;
  min-height: 36px; /* prevents layout shift while JS populates */
}
.dashboard-card-status:empty { border-top: none; padding-top: 0; min-height: 0; }
.dashboard-card-status .status-row {
  display: contents; /* let the row's children sit directly in the parent grid */
}
.dashboard-card-status .status-label {
  color: var(--color-mid-grey);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.66rem;
  font-weight: 700;
  align-self: center;
}
.dashboard-card-status .status-value {
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.78rem;
}
.dashboard-card-status .status-row-empty .status-value {
  color: var(--color-alert);
  font-weight: 700;
}
.dashboard-card-status .status-empty {
  color: var(--color-mid-grey);
}

/* Stale + Failed badges — sit top-right; hidden by default; activated by
   the .is-stale / .is-failed classes JS adds to the card. */
.dashboard-card-stale-badge,
.dashboard-card-failed-badge {
  display: none;
  position: absolute;
  top: 14px;
  right: 14px;
  font-family: 'Cambay', sans-serif;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 10px;
  border-radius: 999px;
  pointer-events: none;
}
.dashboard-card-stale-badge {
  background: var(--color-warning);
  color: var(--color-black);
}
.dashboard-card-failed-badge {
  background: var(--color-alert);
  color: var(--color-white);
}
.dashboard-card.is-stale .dashboard-card-stale-badge { display: inline-block; }
.dashboard-card.is-failed .dashboard-card-failed-badge { display: inline-block; }

/* Stale tile visual — soft warning border + tinted background. Loud
   enough to notice, not loud enough to override the brand palette. */
.dashboard-card.is-stale {
  border-color: var(--color-warning);
  background:
    linear-gradient(180deg, var(--color-warning-bg) 0%, var(--surface) 70%);
}
.dashboard-card.is-stale:hover { border-color: var(--color-warning); }

/* Failed tile — alert (orange) border, muted body. */
.dashboard-card.is-failed {
  border-color: var(--color-alert);
  background: var(--color-alert-bg);
}
.dashboard-card.is-failed:hover { border-color: var(--color-alert); }

/* Inline badge variant — used in the homepage note paragraph. Sits in
   the text flow instead of absolute-positioned over a card corner. */
.dashboard-card-stale-badge.inline,
.dashboard-card-failed-badge.inline {
  display: inline-block;
  position: static;
  vertical-align: baseline;
  margin: 0 2px;
}

/* Draft badge — sits top-LEFT (never collides with the top-right stale
   or failed badges). Always-on for tiles flagged data-draft="true" via
   markup; signals 'work in progress, not yet finalised'. Uses a darker
   muted-blue tone to read as informational rather than alarming. */
.dashboard-card-draft-badge {
  display: none;
  position: absolute;
  top: 14px;
  left: 14px;
  font-family: 'Cambay', sans-serif;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 10px;
  border-radius: 999px;
  pointer-events: none;
  background: var(--color-blue);
  color: var(--color-white);
}
.dashboard-card[data-draft="true"] .dashboard-card-draft-badge {
  display: inline-block;
}
/* Bump card title right so the badge doesn't sit on top of the section
   label. The .dashboard-card-section starts at the card's normal padding,
   so we just nudge it down a couple of pixels to clear the badge baseline. */
.dashboard-card[data-draft="true"] .dashboard-card-section {
  margin-top: 14px;
}

/* Homepage explanatory note above the dashboard grid. */
.homepage-note {
  font-family: 'Cambay', sans-serif;
  font-size: 0.82rem;
  color: var(--text-secondary);
  background: var(--color-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  margin-bottom: 28px;
  line-height: 1.55;
}
.homepage-note strong {
  color: var(--text-primary);
  font-weight: 700;
}

/* Shared card-grid container — extracted from the per-section inline
   styles for consistency. */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

/* ── Tables ───────────────────────────────────────────────────── */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.table-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.table-card-title {
  font-family: 'Bree Serif', serif;
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-primary);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Cambay', sans-serif;
  font-size: 0.85rem;
}

thead th {
  background: var(--surface-2);
  padding: 10px 16px;
  text-align: left;
  font-family: 'Cambay', sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border-subtle);
}

tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover      { background: var(--color-primary-bg); }
tbody td            { padding: 11px 16px; color: var(--text-primary); }

/* ── Badges ───────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 20px;
  font-family: 'Cambay', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-warning { background: var(--color-warning-bg); color: #7A5700;              }
.badge-alert   { background: var(--color-alert-bg);   color: var(--color-alert);   }
.badge-primary { background: var(--color-primary-bg); color: var(--color-primary); }
.badge-blue    { background: var(--color-blue-bg);    color: var(--color-blue);    }
.badge-grey    { background: var(--surface-2);        color: var(--text-muted);    }

/* ── Loading ──────────────────────────────────────────────────── */
.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px;
  color: var(--text-muted);
  font-family: 'Cambay', sans-serif;
  font-size: 0.875rem;
}

.spinner {
  width: 30px; height: 30px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar      { transform: translateX(-100%); }
  .main         { margin-left: 0; }
  .chart-grid   { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
  .page-header  { flex-direction: column; align-items: flex-start; gap: 12px; }
}

/* ════════════════════════════════════════════════════════════════════
   TABLE FILTER COMPONENT — column-level filters (table-filter.js)
   ════════════════════════════════════════════════════════════════════ */

/* Filter row sits directly under the header row */
.tf-filter-row th.tf-filter-cell {
  background: var(--surface-2, #F8F7F7);
  border-bottom: 2px solid var(--border-subtle);
  padding: 4px 8px;
  vertical-align: top;
}

/* Individual filter inputs — shared base */
.tf-input {
  width: 100%;
  box-sizing: border-box;
  height: 26px;
  padding: 0 7px;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  font-family: 'Cambay', sans-serif;
  font-size: 0.72rem;
  color: var(--text-primary);
  background: var(--surface);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
/* Strip appearance only for text/number/date inputs — NOT selects */
input.tf-input {
  appearance: none;
  -webkit-appearance: none;
}
.tf-input:focus {
  border-color: var(--color-blue, #0081C6);
  box-shadow: 0 0 0 2px rgba(0,129,198,0.12);
}
input.tf-input:not(:placeholder-shown) {
  border-color: var(--color-primary, #EE3526);
  background: rgba(238,53,38,0.03);
}
/* ── Custom dropdown (replaces native <select> for cross-browser reliability) ─── */
.tf-dd {
  position: relative;
  width: 100%;
}
.tf-dd-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 26px;
  padding: 0 7px;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  background: var(--surface);
  font-family: 'Cambay', sans-serif;
  font-size: 0.72rem;
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  transition: border-color 0.12s, color 0.12s;
  box-sizing: border-box;
}
.tf-dd-btn:focus {
  outline: none;
  border-color: var(--color-blue, #0081C6);
  box-shadow: 0 0 0 2px rgba(0,129,198,0.12);
}
.tf-dd-btn.tf-dd-active {
  border-color: var(--color-primary, #EE3526);
  color: var(--color-primary, #EE3526);
}
.tf-dd-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.tf-dd-arrow { flex-shrink: 0; margin-left: 4px; opacity: 0.45; }
.tf-dd-menu {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  min-width: 100%;
  max-height: 200px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 9999;
  padding: 4px 0;
}
.tf-dd-menu.tf-dd-open { display: block; }
.tf-dd-option {
  padding: 6px 12px;
  font-family: 'Cambay', sans-serif;
  font-size: 0.75rem;
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.08s;
}
.tf-dd-option:hover    { background: var(--color-primary-bg, #FFF6F5); }
.tf-dd-option.tf-dd-selected {
  color: var(--color-primary, #EE3526);
  font-weight: 700;
  background: rgba(238,53,38,0.04);
}

/* Range pairs (amount / date) — two small inputs side by side */
.tf-range-pair {
  display: flex;
  gap: 3px;
}
.tf-range-pair .tf-input {
  flex: 1;
  min-width: 0;
  padding: 0 4px;
  font-size: 0.68rem;
}
.tf-date-input {
  padding: 0 3px !important;
}

/* Column header active state — turns red when filter applied */
thead tr:first-child th.tf-col-active {
  color: var(--color-primary, #EE3526) !important;
  position: relative;
}
thead tr:first-child th.tf-col-active::after {
  content: ' ▼';
  font-size: 0.6rem;
  color: var(--color-primary, #EE3526);
  vertical-align: middle;
}

/* Clear all filters button */
.tf-clear-btn {
  display: none;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--color-primary, #EE3526);
  background: rgba(238,53,38,0.06);
  color: var(--color-primary, #EE3526);
  font-family: 'Cambay', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s;
  white-space: nowrap;
}
.tf-clear-btn:hover {
  background: rgba(238,53,38,0.12);
}
