/* style.css — Classiko Dashboard v1.1 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ========================================
   DESIGN TOKENS
   ======================================== */
:root {
  --font-body: 'Inter', system-ui, sans-serif;
  --font-display: 'Inter', system-ui, sans-serif;

  /* Fluid type scale */
  --text-xs:   clamp(0.6875rem, 0.65rem + 0.2vw, 0.8125rem);
  --text-sm:   clamp(0.8125rem, 0.75rem + 0.3vw, 0.9375rem);
  --text-base: clamp(0.9375rem, 0.85rem + 0.4vw, 1.0625rem);
  --text-lg:   clamp(1.0625rem, 0.9rem + 0.7vw, 1.375rem);
  --text-xl:   clamp(1.375rem, 0.95rem + 1.2vw, 2rem);
  --text-2xl:  clamp(1.75rem, 1.1rem + 2vw, 3rem);
  --text-3xl:  clamp(2.25rem, 0.9rem + 3.5vw, 4.5rem);

  /* 4px spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* LIGHT MODE (default) */
:root, [data-theme="light"] {
  --color-bg:               #f7f6f2;
  --color-surface:          #ffffff;
  --color-surface-2:        #fbfbf9;
  --color-surface-offset:   #f0eeea;
  --color-surface-offset-2: #e8e6e1;
  --color-surface-dynamic:  #e2e0db;
  --color-divider:          #dcd9d5;
  --color-border:           #d4d1ca;

  --color-text:             #1a1a1a;
  --color-text-muted:       #6b6b6b;
  --color-text-faint:       #a3a3a3;
  --color-text-inverse:     #f9f8f4;

  --color-primary:          #01696f;
  --color-primary-hover:    #0c4e54;
  --color-primary-active:   #0f3638;
  --color-primary-light:    #e0f0f1;

  --color-success:          #16a34a;
  --color-success-light:    #dcfce7;
  --color-error:            #dc2626;
  --color-error-light:      #fef2f2;
  --color-warning:          #d97706;

  --color-blue:             #006494;
  --color-header-bg:        #1e2a32;
  --color-header-text:      #f0f0f0;
  --color-header-muted:     #8a9aa6;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);

  --chart-grid:             #e8e6e1;
  --chart-text:             #6b6b6b;
}

/* DARK MODE */
[data-theme="dark"] {
  --color-bg:               #111318;
  --color-surface:          #1a1c22;
  --color-surface-2:        #20222a;
  --color-surface-offset:   #16181e;
  --color-surface-offset-2: #24262e;
  --color-surface-dynamic:  #2a2c34;
  --color-divider:          #2a2c34;
  --color-border:           #343640;

  --color-text:             #e0e0e0;
  --color-text-muted:       #8a8a8a;
  --color-text-faint:       #555555;
  --color-text-inverse:     #1a1a1a;

  --color-primary:          #3eb8c0;
  --color-primary-hover:    #2da0a8;
  --color-primary-active:   #1a8890;
  --color-primary-light:    rgba(62, 184, 192, 0.12);

  --color-success:          #4ade80;
  --color-success-light:    rgba(74, 222, 128, 0.1);
  --color-error:            #f87171;
  --color-error-light:      rgba(248, 113, 113, 0.1);
  --color-warning:          #fbbf24;

  --color-blue:             #5591c7;
  --color-header-bg:        #13151a;
  --color-header-text:      #e0e0e0;
  --color-header-muted:     #6b7280;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);

  --chart-grid:             #2a2c34;
  --chart-text:             #8a8a8a;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg:               #111318;
    --color-surface:          #1a1c22;
    --color-surface-2:        #20222a;
    --color-surface-offset:   #16181e;
    --color-surface-offset-2: #24262e;
    --color-surface-dynamic:  #2a2c34;
    --color-divider:          #2a2c34;
    --color-border:           #343640;
    --color-text:             #e0e0e0;
    --color-text-muted:       #8a8a8a;
    --color-text-faint:       #555555;
    --color-text-inverse:     #1a1a1a;
    --color-primary:          #3eb8c0;
    --color-primary-hover:    #2da0a8;
    --color-primary-active:   #1a8890;
    --color-primary-light:    rgba(62, 184, 192, 0.12);
    --color-success:          #4ade80;
    --color-success-light:    rgba(74, 222, 128, 0.1);
    --color-error:            #f87171;
    --color-error-light:      rgba(248, 113, 113, 0.1);
    --color-warning:          #fbbf24;
    --color-blue:             #5591c7;
    --color-header-bg:        #13151a;
    --color-header-text:      #e0e0e0;
    --color-header-muted:     #6b7280;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
    --chart-grid:             #2a2c34;
    --chart-text:             #8a8a8a;
  }
}

/* ========================================
   PASSWORD GATE
   ======================================== */
.pw-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.pw-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.pw-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-10);
  max-width: 380px;
  width: 100%;
}

.pw-logo {
  color: var(--color-primary);
  width: 48px;
  height: 48px;
}

.pw-brand {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text);
}

.pw-subtitle {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.pw-form {
  display: flex;
  gap: var(--space-2);
  width: 100%;
}

.pw-input {
  flex: 1;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-text);
  outline: none;
  transition: border-color var(--transition-interactive);
}

.pw-input:focus {
  border-color: var(--color-primary);
}

.pw-input.shake {
  animation: pwShake 0.4s ease;
}

.pw-btn {
  padding: var(--space-3) var(--space-5);
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-interactive);
  white-space: nowrap;
}

.pw-btn:hover {
  background: var(--color-primary-hover);
}

.pw-error {
  font-size: var(--text-xs);
  color: var(--color-error);
  opacity: 0;
  transition: opacity 0.2s;
  height: 1.2em;
}

.pw-error.visible {
  opacity: 1;
}

@keyframes pwShake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-8px); }
  30% { transform: translateX(6px); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(3px); }
  75% { transform: translateX(-2px); }
}

/* ========================================
   GLOBAL / LAYOUT
   ======================================== */
html, body {
  height: 100%;
  overflow: hidden;
  margin: 0;
}

.dashboard {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* HEADER */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  background: var(--color-header-bg);
  color: var(--color-header-text);
  z-index: 100;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.logo svg {
  display: block;
  flex-shrink: 0;
}

.logo-text {
  font-size: var(--text-base);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-header-text);
}

.header-meta {
  font-size: var(--text-xs);
  color: var(--color-header-muted);
  margin-left: var(--space-2);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  color: var(--color-header-muted);
  transition: color var(--transition-interactive), background var(--transition-interactive);
}

.theme-toggle:hover {
  color: var(--color-header-text);
  background: rgba(255,255,255,0.08);
}

/* TAB NAV */
.tab-nav {
  display: flex;
  gap: 0;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-divider);
  padding: 0 var(--space-5);
  flex-shrink: 0;
}

.tab-btn {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  transition: color var(--transition-interactive), border-color var(--transition-interactive);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.tab-btn:hover {
  color: var(--color-text);
}

.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

/* MAIN CONTENT */
.main {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-5);
}

.tab-content {
  display: none;
  max-width: 1200px;
  margin: 0 auto;
}

.tab-content.active {
  display: block;
}

/* ========================================
   MONTH SELECTOR
   ======================================== */
.month-selector-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.month-selector-label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.period-status {
  margin: calc(-1 * var(--space-3)) 0 var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.period-status.is-stale {
  color: var(--color-warning);
}

.period-status.is-current {
  color: var(--color-success);
}

.month-select-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.month-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-8) var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  transition: border-color var(--transition-interactive), box-shadow var(--transition-interactive);
  font-variant-numeric: tabular-nums lining-nums;
  min-width: 130px;
}

.month-select:hover {
  border-color: var(--color-primary);
}

.month-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-light);
}

.month-select-chevron {
  position: absolute;
  right: var(--space-3);
  pointer-events: none;
  color: var(--color-text-muted);
}

/* ========================================
   KPI CARDS
   ======================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  overflow: visible;
}

.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  transition: box-shadow var(--transition-interactive);
  min-height: 160px;
  justify-content: flex-start;
  overflow: visible;
  position: relative;
  z-index: 1;
}

.kpi-card:hover {
  box-shadow: var(--shadow-md);
  z-index: 50;
}

.kpi-label {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Info Tooltips */
.info-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-surface-offset);
  color: var(--color-text-faint);
  font-size: 9px;
  font-weight: 700;
  cursor: help;
  flex-shrink: 0;
  transition: background 180ms ease, color 180ms ease;
  text-transform: none;
  letter-spacing: 0;
  line-height: 1;
  z-index: 60;
}
.info-tip:hover {
  background: var(--color-primary);
  color: #fff;
}
.info-tip .info-bubble {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  width: min(300px, calc(100vw - 48px));
  min-width: 260px;
  padding: 12px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px oklch(0 0 0 / 0.12);
  font-size: 11.5px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--color-text);
  text-align: left;
  white-space: normal;
  z-index: 99999;
  pointer-events: auto;
  opacity: 0;
  visibility: hidden;
  transition: opacity 150ms ease, visibility 150ms ease;
}
/* invisible bridge between ? and bubble so hover doesn't break */
.info-tip .info-bubble::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 0;
  width: 100%;
  height: 14px;
}
.info-tip .info-bubble::after {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: var(--color-border);
}
.info-tip:hover .info-bubble {
  opacity: 1;
  visibility: visible;
}

.kpi-card:has(.info-tip:hover),
.chart-card:has(.info-tip:hover) {
  z-index: 999;
}
.info-bubble strong {
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--color-divider);
  color: var(--color-primary);
  text-transform: none;
}
.info-bubble b {
  display: block;
  font-weight: 600;
  margin-top: 6px;
  color: var(--color-text);
}
.info-bubble em {
  display: block;
  font-style: italic;
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px solid var(--color-border);
  font-size: 10px;
  color: var(--color-text-muted);
}
.chart-title-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

.kpi-value {
  font-size: var(--text-xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--color-text);
  line-height: 1.1;
  transition: opacity 0.2s;
}

.kpi-sublabel {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 500;
  margin-top: 1px;
  margin-bottom: 2px;
}

.kpi-deltas {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: 500;
  font-variant-numeric: tabular-nums lining-nums;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
}

.kpi-delta.positive {
  color: var(--color-success);
  background: var(--color-success-light);
}

.kpi-delta.negative {
  color: var(--color-error);
  background: var(--color-error-light);
}

.kpi-delta.neutral {
  color: var(--color-text-muted);
  background: var(--color-surface-offset);
}

.kpi-sparkline {
  height: 32px;
  margin-top: var(--space-1);
}

.kpi-sparkline canvas {
  width: 100% !important;
  height: 32px !important;
}

/* ========================================
   CHART CONTAINERS
   ======================================== */
.chart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
  overflow: visible;
  position: relative;
  z-index: 1;
}

.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  gap: var(--space-4);
  flex-wrap: wrap;
  overflow: visible;
  position: relative;
  z-index: 10;
}

.chart-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}

.chart-subtitle {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.chart-container {
  position: relative;
  width: 100%;
  height: 280px;
}

.chart-container canvas {
  width: 100% !important;
  max-height: 100%;
}

/* ========================================
   RASMUS TOGGLE (pill style)
   ======================================== */
.rasmus-toggle-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.toggle-label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.pill-toggle {
  position: relative;
  display: inline-flex;
  cursor: pointer;
}

.pill-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.pill-toggle-track {
  width: 40px;
  height: 22px;
  background: var(--color-surface-offset-2);
  border-radius: 11px;
  position: relative;
  transition: background 0.2s;
  border: 1px solid var(--color-border);
}

.pill-toggle input:checked + .pill-toggle-track {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.pill-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.pill-toggle input:checked + .pill-toggle-track .pill-toggle-thumb {
  transform: translateX(18px);
}

.pill-toggle input:focus-visible + .pill-toggle-track {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ========================================
   SECTION HEADERS
   ======================================== */
.section-header {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 2px solid var(--color-primary);
  display: inline-block;
}

.section-divider {
  margin-top: var(--space-8);
  margin-bottom: var(--space-5);
}

/* ========================================
   TABLES
   ======================================== */
.data-table {
  width: 100%;
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums lining-nums;
}

.data-table th {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.6875rem;
  border-bottom: 2px solid var(--color-divider);
  white-space: nowrap;
}

.data-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-divider);
  color: var(--color-text);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums lining-nums;
}

.data-table .highlight {
  font-weight: 600;
  color: var(--color-primary);
}

/* ========================================
   RASMUS CARD
   ======================================== */
.rasmus-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
}

.rasmus-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.rasmus-badge {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.rasmus-layout {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: var(--space-5);
  align-items: center;
}

.rasmus-donut {
  position: relative;
  width: 160px;
  height: 160px;
}

.rasmus-donut canvas {
  width: 160px !important;
  height: 160px !important;
}

.rasmus-legend {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.rasmus-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
}

.rasmus-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.rasmus-legend-value {
  margin-left: auto;
  font-weight: 600;
  font-variant-numeric: tabular-nums lining-nums;
}

/* ========================================
   NOAH CARD
   ======================================== */
.noah-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.noah-badge {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--color-surface-offset);
  color: var(--color-text-muted);
}

/* ========================================
   MARKETING / PLACEHOLDER
   ======================================== */
.placeholder-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-5);
  text-align: center;
  margin-bottom: var(--space-5);
}

.placeholder-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-4);
  border-radius: var(--radius-full);
  background: var(--color-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
}

.placeholder-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.placeholder-text {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  max-width: 420px;
  margin: 0 auto;
}

.meta-spend-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
}

.funnel-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-6) 0;
}

.funnel-step {
  height: 32px;
  background: var(--color-primary-light);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  transition: opacity 0.3s;
}

/* Live funnel */
.funnel-live {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4) 0;
}
.funnel-loading {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  justify-content: center;
  padding: var(--space-8) 0;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.funnel-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.funnel-bar-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.funnel-bar-label {
  flex: 0 0 130px;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  text-align: right;
}
.funnel-bar-track {
  flex: 1;
  height: 28px;
  background: var(--color-surface-offset);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}
.funnel-bar-fill {
  height: 100%;
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 2px;
}
.funnel-bar-fill.stage-lost {
  background: var(--color-error);
  opacity: 0.6;
}
.funnel-bar-fill.stage-done {
  background: var(--color-success);
}
.funnel-bar-count {
  flex: 0 0 36px;
  font-size: var(--text-sm);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
}
.funnel-total {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-divider);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.funnel-total strong {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
}
.brevo-error {
  text-align: center;
  padding: var(--space-6) 0;
  font-size: var(--text-xs);
  color: var(--color-error);
}

/* Stage badges in deal table */
.stage-badge {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--color-primary-light);
  color: var(--color-primary);
}
.stage-badge.done {
  background: var(--color-success-light);
  color: var(--color-success);
}
.stage-badge.lost {
  background: var(--color-error-light);
  color: var(--color-error);
}

/* Marketing KPI grid */
.mkt-kpi-grid {
  margin-bottom: var(--space-5);
}
.mkt-kpi-grid .kpi-card {
  min-height: 120px;
}

.marketing-explainer {
  margin: 0 0 var(--space-4);
  padding: 14px 16px;
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-md);
  background: color-mix(in oklch, var(--color-primary-light) 35%, var(--color-surface));
  color: var(--color-text);
  font-size: var(--text-sm);
  line-height: 1.55;
}

.marketing-explainer strong {
  color: var(--color-primary);
}

.marketing-explainer a {
  display: inline-flex;
  margin-left: 8px;
  color: var(--color-primary);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.marketing-explainer-muted {
  border-left-color: var(--color-text-faint);
  background: color-mix(in oklch, var(--color-surface-alt) 72%, var(--color-surface));
}

.marketing-explainer-muted strong {
  color: var(--color-text);
}

/* ========================================
   MOBILE: BOTTOM TAB BAR
   ======================================== */
@media (max-width: 640px) {
  .tab-nav {
    display: none;
  }

  .mobile-tab-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-top: 1px solid var(--color-divider);
    z-index: 100;
    padding: var(--space-1) 0;
    padding-bottom: env(safe-area-inset-bottom, var(--space-1));
  }

  .mobile-tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--space-2) var(--space-1);
    font-size: 0.625rem;
    font-weight: 500;
    color: var(--color-text-muted);
    transition: color var(--transition-interactive);
    text-decoration: none;
  }

  .mobile-tab-btn.active {
    color: var(--color-primary);
  }

  .mobile-tab-btn svg {
    width: 20px;
    height: 20px;
  }

  .main {
    padding: var(--space-4);
    padding-bottom: calc(var(--space-16) + env(safe-area-inset-bottom, 0px));
  }

  .kpi-grid {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }

  .kpi-value {
    font-size: var(--text-lg);
  }

  .header-meta {
    display: none;
  }

  .rasmus-layout {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .rasmus-legend {
    width: 100%;
  }

  .chart-container {
    height: 220px;
  }

  .logo-text {
    font-size: var(--text-sm);
  }

  .noah-card {
    flex-direction: column;
    text-align: center;
  }

  .month-select {
    min-width: 110px;
    font-size: var(--text-xs);
  }

  .rasmus-toggle-wrap {
    margin-top: var(--space-2);
  }

  .chart-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }
}

@media (min-width: 641px) {
  .mobile-tab-bar {
    display: none;
  }
}

/* ========================================
   REVENUE OVERLAY CHART LEGEND
   ======================================== */
.chart-legend {
  display: flex;
  gap: var(--space-4);
  margin-top: var(--space-3);
  justify-content: center;
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.chart-legend-line {
  width: 16px;
  height: 3px;
  border-radius: 2px;
}

/* ========================================
   UTILITY
   ======================================== */
.tabular-nums {
  font-variant-numeric: tabular-nums lining-nums;
}

.text-success { color: var(--color-success); }
.text-error { color: var(--color-error); }
.text-muted { color: var(--color-text-muted); }
.text-primary { color: var(--color-primary); }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* Animate numbers */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.kpi-card {
  animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.kpi-card:nth-child(1) { animation-delay: 0ms; }
.kpi-card:nth-child(2) { animation-delay: 60ms; }
.kpi-card:nth-child(3) { animation-delay: 120ms; }
.kpi-card:nth-child(4) { animation-delay: 180ms; }
.kpi-card:nth-child(5) { animation-delay: 240ms; }
.kpi-card:nth-child(6) { animation-delay: 300ms; }
.kpi-card:nth-child(7) { animation-delay: 360ms; }
.kpi-card:nth-child(8) { animation-delay: 420ms; }
.kpi-card:nth-child(9) { animation-delay: 480ms; }

/* Grid helpers for economy tab */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
}

@media (max-width: 768px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* Status dot */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: var(--space-1);
}

.status-dot.green { background: var(--color-success); }
.status-dot.yellow { background: var(--color-warning); }
.status-dot.red { background: var(--color-error); }

/* Monthly delta pills inline */
.month-deltas {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-top: var(--space-3);
}

.month-delta-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 0.625rem;
  font-weight: 500;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-variant-numeric: tabular-nums lining-nums;
}

/* ========================================
   3-COLUMN KPI on wider screens
   ======================================== */
@media (min-width: 900px) {
  .kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ============================================ */
/* UPLOAD UI (Fase 3)                            */
/* ============================================ */
.upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-accent, #01696f);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}
.upload-btn:hover { background: #014e53; }
.upload-btn svg { display: block; }

.upload-modal {
  position: fixed; inset: 0; z-index: 1000;
  display: none;
  align-items: center; justify-content: center;
}
.upload-modal[aria-hidden="false"] { display: flex; }
.upload-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(20, 30, 40, 0.55);
  backdrop-filter: blur(4px);
}
.upload-modal-card {
  position: relative;
  background: var(--color-bg, #fff);
  color: var(--color-text, #1a2230);
  width: min(92vw, 980px);
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  border: 1px solid var(--color-divider, #e4e8ef);
}
.upload-modal-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 22px;
}
.upload-modal-head h2 {
  margin: 0; font-size: 22px; font-weight: 600;
}
.upload-sub {
  margin: 6px 0 0; font-size: 13px;
  color: var(--color-muted, #6b7280);
}
.upload-close {
  background: transparent; border: none;
  font-size: 28px; line-height: 1;
  color: var(--color-muted, #9ca3af);
  cursor: pointer; padding: 0 4px;
}
.upload-close:hover { color: var(--color-text, #1a2230); }

.upload-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
@media (max-width: 720px) {
  .upload-grid { grid-template-columns: 1fr; }
}
.drop-zone {
  border: 2px dashed var(--color-divider, #d1d8e0);
  border-radius: 10px;
  padding: 22px 16px;
  text-align: center;
  background: var(--color-card-bg, #f9fafb);
  transition: border-color 0.15s, background 0.15s;
}
.drop-zone.is-drag {
  border-color: var(--color-accent, #01696f);
  background: rgba(1,105,111,0.05);
}
.drop-zone.is-loaded { border-style: solid; border-color: var(--color-success, #16a34a); }
.drop-icon { font-size: 28px; margin-bottom: 6px; }
.drop-title { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.drop-hint {
  font-size: 11px; color: var(--color-muted, #6b7280);
  font-family: ui-monospace, monospace;
  margin-bottom: 12px;
}
.drop-pick {
  background: #fff; border: 1px solid var(--color-divider, #d1d8e0);
  border-radius: 6px; padding: 6px 14px;
  font-size: 13px; cursor: pointer;
  font-family: inherit;
}
.drop-pick:hover { border-color: var(--color-accent, #01696f); color: var(--color-accent, #01696f); }
.drop-status {
  font-size: 12px; margin-top: 10px; min-height: 16px;
  color: var(--color-muted, #6b7280);
}
.drop-status.ok { color: var(--color-success, #16a34a); }
.drop-status.err { color: var(--color-error, #dc2626); }

.upload-preview {
  margin-top: 24px;
  border-top: 1px solid var(--color-divider, #e4e8ef);
  padding-top: 20px;
}
.upload-preview h3 {
  margin: 0 0 12px; font-size: 16px; font-weight: 600;
}
.preview-block {
  margin-bottom: 14px;
  padding: 12px;
  background: var(--color-card-bg, #f9fafb);
  border-radius: 8px;
  border: 1px solid var(--color-divider, #e4e8ef);
}
.preview-block-head {
  display: flex; justify-content: space-between;
  font-size: 13px; margin-bottom: 8px;
}
.preview-block-head strong { font-size: 14px; }
.preview-block-head .pb-month {
  background: var(--color-accent, #01696f);
  color: #fff; padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 600;
}
.preview-table {
  width: 100%; border-collapse: collapse; font-size: 12px;
}
.preview-table th, .preview-table td {
  padding: 5px 8px; text-align: left;
  border-bottom: 1px solid var(--color-divider, #e4e8ef);
}
.preview-table th {
  font-weight: 600; color: var(--color-muted, #6b7280);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
}
.preview-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

.upload-actions {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 16px;
}
.btn-primary, .btn-secondary {
  border: none; border-radius: 8px;
  padding: 9px 18px; font-size: 14px; font-weight: 500;
  cursor: pointer; font-family: inherit;
}
.btn-primary {
  background: var(--color-accent, #01696f); color: #fff;
}
.btn-primary:hover { background: #014e53; }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-secondary {
  background: transparent;
  color: var(--color-text, #1a2230);
  border: 1px solid var(--color-divider, #d1d8e0);
}
.btn-secondary:hover { background: var(--color-card-bg, #f9fafb); }

.upload-result {
  margin-top: 14px; padding: 10px 14px;
  border-radius: 8px; font-size: 13px;
}
.upload-result.ok { background: rgba(22,163,74,0.1); color: #15803d; }
.upload-result.err { background: rgba(220,38,38,0.1); color: #b91c1c; }
