/* ================================================================
   Canopy Design System
   Warm charcoal + earth tones, EXIF-inspired glassmorphism
   Dark mode default, light mode via [data-theme="light"]
   ================================================================ */

/* ---- DESIGN TOKENS ---- */
:root {
  /* Backgrounds */
  --bg-base: #0e0e0c;
  --bg-surface: #121210;
  --bg-elevated: #141412;
  --bg-hover: rgba(255, 248, 230, 0.05);
  --bg-active: rgba(255, 248, 230, 0.06);

  /* Borders */
  --border-subtle: #1e1e1a;
  --border-default: rgba(255, 248, 230, 0.06);
  --border-hover: rgba(255, 248, 230, 0.1);

  /* Text */
  --text-primary: #e8e4dc;
  --text-secondary: #706b63;
  --text-tertiary: #5a5650;
  --text-muted: #3a3830;

  /* Glass */
  --glass-bg: rgba(255, 248, 230, 0.03);
  --glass-blur: blur(20px);
  --glass-border: rgba(255, 248, 230, 0.06);

  /* Status */
  --status-positive: #5a9a6e;
  --status-warning: #c4973b;
  --status-negative: #b85c4a;
  --status-info: #6b8cae;
  --status-positive-bg: rgba(90, 154, 110, 0.1);
  --status-warning-bg: rgba(196, 151, 59, 0.1);
  --status-negative-bg: rgba(184, 92, 74, 0.1);
  --status-info-bg: rgba(107, 140, 174, 0.1);

  /* Chart palette */
  --chart-1: #5a9a6e;
  --chart-2: #c4973b;
  --chart-3: #6b8cae;
  --chart-4: #b85c4a;
  --chart-5: #8a7e72;
  --chart-bg: rgba(232, 228, 220, 0.08);

  /* Coaching */
  --coaching-bg: rgba(90, 154, 110, 0.06);
  --coaching-border: rgba(90, 154, 110, 0.12);

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', SFMono-Regular, ui-monospace, Menlo, monospace;

  /* Type scale */
  --text-xs: 9px;
  --text-sm: 11px;
  --text-base: 13px;
  --text-md: 15px;
  --text-lg: 18px;
  --text-xl: 28px;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 20px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.3s ease;
}

/* ---- LIGHT MODE ---- */
[data-theme="light"] {
  --bg-base: #faf9f6;
  --bg-surface: #ffffff;
  --bg-elevated: #f5f4f1;
  --bg-hover: rgba(0, 0, 0, 0.03);
  --bg-active: rgba(0, 0, 0, 0.05);

  --border-subtle: #e8e4dc;
  --border-default: rgba(0, 0, 0, 0.06);
  --border-hover: rgba(0, 0, 0, 0.1);

  --text-primary: #1a1a18;
  --text-secondary: #706b63;
  --text-tertiary: #908880;
  --text-muted: #c4bfb8;

  --glass-bg: rgba(0, 0, 0, 0.02);
  --glass-border: rgba(0, 0, 0, 0.06);

  --chart-bg: rgba(0, 0, 0, 0.06);
}

/* ================================================================
   RESET + BASE
   ================================================================ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: var(--font-mono);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }

/* Dollar amounts and large numeric values stay in sans-serif */
.sans, .currency, .scenario-val, .kpi-value {
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
}

/* ================================================================
   LAYOUT SHELL
   ================================================================ */

/* ---- APP ---- */
.app { display: flex; height: 100vh; }

/* ---- SIDEBAR ---- */
.sidebar {
  width: 220px;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-subtle);
  display: flex; flex-direction: column; flex-shrink: 0;
  overflow-y: auto;
  transition: width 0.25s ease;
  z-index: 100;
}
.sidebar.collapsed { width: 60px; }
.sidebar.collapsed .sidebar-logo-text { display: none; }
.sidebar.collapsed .sidebar-section { opacity: 0; height: 0; padding: 0; overflow: hidden; }
.sidebar.collapsed .sidebar-item span { display: none; }
.sidebar.collapsed .sidebar-item { justify-content: center; padding: 9px 0; }
.sidebar.collapsed .sidebar-item .sidebar-dot { margin: 0; }
.sidebar.collapsed .sidebar-footer-text { display: none; }

.sidebar-logo {
  padding: 20px 20px 24px;
  font-size: 21px; font-weight: 700;
  display: flex; align-items: center; gap: var(--space-sm);
  white-space: nowrap; overflow: hidden;
}
.sidebar-logo .sidebar-logo-icon { color: var(--status-positive); flex-shrink: 0; }
.sidebar-logo .sidebar-logo-text { color: var(--status-positive); }
.sidebar.collapsed .sidebar-logo { justify-content: center; padding: 20px 0 24px; }

.sidebar-section {
  padding: 14px 20px 6px;
  font-size: var(--text-xs); font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--text-tertiary);
  transition: opacity var(--transition-base), height var(--transition-base), padding var(--transition-base);
}

.sidebar-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px;
  font-size: var(--text-base);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
  user-select: none;
  border-left: 3px solid transparent;
  white-space: nowrap; overflow: hidden;
}
.sidebar-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-item.active {
  background: var(--bg-active);
  color: var(--text-primary);
  border-left-color: var(--status-positive);
}

.sidebar-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.6; transition: opacity var(--transition-fast), color var(--transition-fast); }
.sidebar-item:hover .sidebar-icon { opacity: 0.9; }
.sidebar-item.active .sidebar-icon { opacity: 1; }
/* Tinted sidebar icons — each section gets its own accent */
.sidebar-icon.ic-green { color: var(--status-positive); }
.sidebar-icon.ic-gold { color: var(--status-warning); }
.sidebar-icon.ic-red { color: var(--status-negative); }
.sidebar-icon.ic-blue { color: var(--status-info); }
.sidebar-icon.ic-muted { color: var(--text-tertiary); }

/* Legacy dot classes (kept for backward compat) */
.sidebar-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.dot-green { background: var(--status-positive); }
.dot-yellow { background: var(--status-warning); }
.dot-red { background: var(--status-negative); }
.dot-gray { background: var(--text-tertiary); }

.sidebar-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-sm) 20px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  overflow: hidden;
}
.sidebar-footer .sync-dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--status-positive); margin-right: 6px;
}
.sidebar-footer .sync-line { color: var(--status-positive); margin-top: 2px; }

/* ---- TOPBAR ---- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--space-lg) var(--space-2xl);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  background: var(--bg-elevated);
}
.topbar-left { display: flex; align-items: center; gap: var(--space-lg); }
.topbar h1 { font-family: var(--font-mono); font-size: var(--text-lg); font-weight: 600; color: var(--text-primary); letter-spacing: 0.3px; }
.topbar h1 .subtitle { font-family: var(--font-sans); color: var(--text-secondary); font-weight: 400; font-size: var(--text-md); letter-spacing: normal; }
.topbar-right { display: flex; align-items: center; gap: var(--space-lg); }
.topbar-company { font-size: var(--text-base); color: var(--text-secondary); }
.topbar-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--border-subtle);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-base); color: var(--text-secondary); cursor: pointer;
}

/* ---- MAIN + CONTENT ---- */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.content { flex: 1; overflow-y: auto; padding: var(--space-xl) var(--space-2xl) 40px; }

/* ---- HAMBURGER ---- */
.hamburger {
  display: none; background: none; border: none; cursor: pointer;
  padding: var(--space-xs); color: var(--text-secondary);
}
.hamburger svg { display: block; }

/* ---- BACK BUTTON ---- */
.back-btn {
  display: none; align-items: center; gap: 6px;
  padding: 6px var(--space-md);
  font-size: var(--text-base); font-weight: 600;
  color: var(--text-secondary);
  background: none;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}
.back-btn:hover { color: var(--text-primary); border-color: var(--border-hover); }
.back-btn.visible { display: flex; }

/* ---- SIDEBAR OVERLAY (mobile) ---- */
.sidebar-overlay {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5); z-index: 90;
}
.sidebar-overlay.visible { display: block; }

/* ================================================================
   COMPONENTS
   ================================================================ */

/* ---- GLASS CARD ---- */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color var(--transition-fast);
}
.glass-card:hover { border-color: var(--border-hover); }

/* ---- KPI CARDS ---- */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-lg); margin-bottom: 20px; }
.kpi-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: border-color var(--transition-fast);
}
.kpi-card:hover { border-color: var(--border-hover); }
.kpi-label {
  font-size: var(--text-xs); font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}
.kpi-value {
  font-size: var(--text-xl); font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.kpi-value .unit { font-size: 14px; color: var(--text-secondary); font-weight: 400; }
.kpi-target { font-size: var(--text-sm); color: var(--text-secondary); margin-top: 2px; }
.kpi-delta { font-size: var(--text-sm); font-weight: 600; margin-top: var(--space-xs); }
.kpi-bar { height: 5px; background: var(--border-subtle); border-radius: 3px; margin: 10px 0 6px; position: relative; }
.kpi-bar-fill { height: 100%; border-radius: 3px; width: 0; transition: width 1.2s cubic-bezier(0.4, 0, 0.2, 1); }
.kpi-bar-target { position: absolute; top: -3px; width: 2px; height: 11px; background: var(--text-primary); border-radius: 1px; }
.kpi-coaching { font-size: var(--text-sm); color: var(--text-secondary); line-height: 1.4; }

/* ---- DATA CARD (EXIF-style key-value) ---- */
.data-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.data-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-default);
}
.data-row:last-child { border-bottom: none; }
.data-key {
  font-size: var(--text-xs); font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-secondary);
}
.data-value {
  font-size: var(--text-base);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* ---- CHART CARD ---- */
.chart-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.chart-header { margin-bottom: var(--space-lg); }
.chart-title {
  font-size: var(--text-xs); font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-secondary);
}

/* ---- COACHING STRIP ---- */
.coaching-strip {
  background: var(--coaching-bg);
  border: 1px solid var(--coaching-border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 20px;
  display: flex; align-items: flex-start; gap: 14px;
}
.coaching-strip .tag {
  font-size: var(--text-xs); font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--status-positive);
  background: var(--status-positive-bg);
  padding: 3px var(--space-sm); border-radius: 4px;
  white-space: nowrap; flex-shrink: 0;
}
.coaching-strip p { font-size: var(--text-base); color: var(--text-primary); line-height: 1.5; }
.coaching-strip a { color: var(--status-warning); text-decoration: none; font-weight: 600; }

/* ---- PANEL ---- */
.panel {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.panel-title {
  font-size: var(--text-xs); font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 3px;
}
.panel-subtitle { font-size: var(--text-sm); color: var(--text-secondary); margin-bottom: 14px; }

/* ---- GRID LAYOUTS ---- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-lg); margin-bottom: 20px; }
.grid-top { display: grid; grid-template-columns: 300px 1fr; gap: var(--space-lg); margin-bottom: 20px; }

/* ---- TABLES ---- */
th {
  font-size: var(--text-xs); font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.5px; text-transform: uppercase;
  color: var(--text-secondary);
  text-align: left;
  padding: var(--space-sm) var(--space-md) var(--space-sm) 0;
  border-bottom: 1px solid var(--border-subtle);
}
td {
  font-size: var(--text-base);
  padding: var(--space-md) var(--space-md) var(--space-md) 0;
  border-bottom: 1px solid var(--border-default);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
tbody tr { transition: background var(--transition-fast); }
tbody tr:hover { background: var(--bg-hover); }
.neg { color: var(--status-negative); }
.pos { color: var(--status-positive); }
.warn { color: var(--status-warning); }

/* ---- MARGIN TEST TABLE ---- */
.mt-table { width: 100%; border-collapse: collapse; }
.mt-table th { text-align: right; padding: 5px 0; }
.mt-table th:first-child { text-align: left; }
.mt-table td { font-size: 12px; padding: 6px 0; text-align: right; }
.mt-table td:first-child { text-align: left; color: var(--text-secondary); }
.mt-table .total td { border-top: 1px solid var(--text-tertiary); font-weight: 600; color: var(--text-primary); }
.mt-table .gm td { font-weight: 700; font-size: var(--text-base); }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  font-size: 12px; font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  transition: border-color var(--transition-fast), color var(--transition-fast);
}
.btn:hover { border-color: var(--border-hover); color: var(--text-primary); }
.btn-primary {
  background: var(--status-positive);
  color: var(--bg-base);
  border-color: var(--status-positive);
  font-weight: 700;
}
.btn-primary:hover { opacity: 0.9; }

.quick-actions {
  display: flex; gap: var(--space-sm);
  padding: var(--space-md) var(--space-2xl);
  border-bottom: 1px solid var(--border-default);
  flex-shrink: 0;
  background: var(--bg-base);
}
.quick-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  font-size: 12px; font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  transition: border-color var(--transition-fast), color var(--transition-fast);
  min-height: 44px;
}
.quick-btn:hover { border-color: var(--status-positive); color: var(--status-positive); }
.quick-btn .icon { font-size: 14px; }
.quick-btn.primary {
  background: var(--status-positive);
  color: var(--bg-base);
  border-color: var(--status-positive);
  font-weight: 700;
}
.quick-btn.primary:hover { opacity: 0.9; }

/* ---- SCENARIO CARDS ---- */
.scenario {
  background: var(--bg-hover);
  border-radius: var(--radius-md);
  padding: 14px;
  border: 1px solid var(--border-default);
}
.scenario.good { border-color: var(--coaching-border); }
.scenario-label {
  font-size: var(--text-xs); font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}
.scenario-val { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.scenario-sub { font-size: 12px; color: var(--text-secondary); }
.scenario-delta { font-size: var(--text-sm); font-weight: 600; margin-top: var(--space-xs); }

/* ---- TOAST ---- */
.toast {
  position: fixed; bottom: var(--space-xl); right: var(--space-xl); z-index: 9999;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-md) 20px;
  font-size: var(--text-base); color: var(--text-primary);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  transform: translateY(100px); opacity: 0;
  transition: transform var(--transition-slow), opacity var(--transition-slow);
}
.toast.visible { transform: translateY(0); opacity: 1; }

/* ---- COMING SOON ---- */
.coming-soon {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 400px; text-align: center;
  padding: 40px;
}
.coming-soon-icon {
  width: 64px; height: 64px; border-radius: var(--radius-lg);
  background: var(--status-positive-bg);
  border: 1px solid var(--coaching-border);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-xl); margin-bottom: 20px;
}
.coming-soon h2 { font-family: var(--font-mono); font-size: var(--text-lg); font-weight: 600; color: var(--text-primary); margin-bottom: var(--space-sm); letter-spacing: 0.5px; }
.coming-soon p { font-size: 14px; color: var(--text-secondary); max-width: 440px; line-height: 1.6; }

/* ---- SECTION TITLE ---- */
.section-title {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
  margin-top: var(--space-xl);
}
.section-title:first-child { margin-top: 0; }

/* ---- COACHING QUOTE ---- */
.coaching-quote {
  padding: var(--space-lg) 20px;
  border-radius: var(--radius-md);
  background: var(--coaching-bg);
  border: 1px solid var(--coaching-border);
  border-left: 4px solid var(--status-positive);
  text-align: left;
  max-width: 480px;
}
.coaching-quote .tag {
  font-size: var(--text-xs); font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--status-positive);
  margin-bottom: var(--space-sm);
}
.coaching-quote p { font-size: var(--text-base); color: var(--text-primary); line-height: 1.5; }

/* ---- CORRECTION / DIAGNOSIS BOXES ---- */
.correction-box,
.diagnosis-box {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  color: var(--text-primary);
  line-height: 1.5;
  margin-bottom: var(--space-md);
}
.correction-box {
  background: var(--status-negative-bg);
  border-left: 3px solid var(--status-negative);
}
.diagnosis-box {
  background: var(--status-info-bg);
  border-left: 3px solid var(--status-info);
}

/* ---- THEME TOGGLE ---- */
.theme-toggle {
  display: flex; align-items: center; gap: var(--space-sm);
  padding: 9px 20px;
  font-size: var(--text-base);
  color: var(--text-secondary);
  cursor: pointer;
  background: none; border: none;
  transition: color var(--transition-fast);
  width: 100%;
  text-align: left;
}
.theme-toggle:hover { color: var(--text-primary); }

/* ---- VIEW MANAGEMENT ---- */
.view { display: none; }
.view.active { display: block; }
.view-iframe {
  display: none; width: 100%; height: 100%; border: none;
}
.view-iframe.active { display: block; }

/* ---- HEADER LAYOUTS ---- */
.proposals-header,
.jobs-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
}
.proposals-header h2,
.jobs-header h2 {
  font-family: var(--font-mono);
  font-size: var(--text-lg); font-weight: 600; color: var(--text-primary);
  letter-spacing: 0.5px;
}

/* Full-width tables inside panels need cell padding for alignment */
.panel > table th:first-child,
.panel > table td:first-child { padding-left: 20px; }
.panel > table th:last-child,
.panel > table td:last-child { padding-right: 20px; }

/* ---- DATE BADGE ---- */
.date-badge {
  display: inline-block;
  font-size: var(--text-xs); font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  background: var(--bg-hover);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  padding: 2px 10px;
}

/* ---- BADGES ---- */
.badge,
.status-badge {
  display: inline-block;
  padding: 2px var(--space-sm);
  border-radius: 4px;
  font-size: var(--text-xs); font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.badge-accepted { background: var(--status-positive-bg); color: var(--status-positive); }
.badge-sent { background: var(--status-info-bg); color: var(--status-info); }
.badge-expired { background: var(--status-negative-bg); color: var(--status-negative); }
.badge-draft { background: var(--bg-hover); color: var(--text-secondary); }
.badge-active { background: var(--status-positive-bg); color: var(--status-positive); }
.badge-complete,
.badge-completed { background: var(--bg-hover); color: var(--text-secondary); }
.badge-pending,
.badge-viewed { background: var(--status-warning-bg); color: var(--status-warning); }
.badge-declined,
.badge-on_hold { background: var(--status-negative-bg); color: var(--status-negative); }
.badge-in_progress { background: var(--status-info-bg); color: var(--status-info); }

/* ---- PIPELINE SUMMARY ---- */
.pipeline-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-lg);
  margin-bottom: 20px;
}
.pipeline-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: border-color var(--transition-fast);
}
.pipeline-card:hover { border-color: var(--border-hover); }
.pipeline-card-label {
  font-size: var(--text-xs); font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}
.pipeline-card-value {
  font-size: var(--text-xl); font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.pipeline-card-sub {
  font-size: var(--text-sm); color: var(--text-secondary);
  margin-top: 2px;
}

/* ---- FILTER TABS ---- */
.filter-tabs {
  display: flex; gap: 4px; align-items: center;
  margin-bottom: 20px;
}
.filter-tab {
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  letter-spacing: 0.5px; text-transform: uppercase;
  padding: 5px 12px; border-radius: var(--radius-pill);
  border: 1px solid var(--border-default); background: transparent;
  color: var(--text-tertiary); cursor: pointer;
  transition: all var(--transition-fast);
}
.filter-tab:hover { color: var(--text-secondary); border-color: var(--border-hover); }
.filter-tab.active {
  background: var(--status-positive-bg); color: var(--status-positive);
  border-color: var(--coaching-border);
}

/* ---- SORT SELECT ---- */
.sort-controls {
  display: flex; align-items: center; gap: 8px; margin-left: auto;
}
.sort-controls label {
  font-size: var(--text-xs); font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.5px; text-transform: uppercase;
  color: var(--text-tertiary);
}
.sort-select {
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  letter-spacing: 0.5px;
  padding: 4px 10px; border-radius: var(--radius-pill);
  border: 1px solid var(--border-default); background: var(--bg-elevated);
  color: var(--text-secondary); cursor: pointer;
  transition: all var(--transition-fast);
  -webkit-appearance: none; appearance: none;
}
.sort-select:hover { border-color: var(--border-hover); color: var(--text-primary); }

/* ---- PROPOSAL CARDS ---- */
.proposal-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: var(--space-lg);
}
.proposal-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  display: flex; flex-direction: column; gap: 12px;
  position: relative;
}
.proposal-card:hover { border-color: var(--border-hover); box-shadow: 0 4px 24px rgba(0,0,0,0.15); }

/* EXIF-style hover detail card (charliedeets inspired) — fixed bottom-right */
.proposal-hover-detail {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 380px;
  max-height: 70vh;
  background: rgba(20, 20, 18, 0.92);
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  border: 1px solid rgba(255, 248, 230, 0.08);
  border-radius: 16px;
  padding: 24px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  overflow-y: auto;
  z-index: 500;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 248, 230, 0.04);
}
.proposal-card:hover .proposal-hover-detail {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
[data-theme="light"] .proposal-hover-detail {
  background: rgba(250, 249, 246, 0.96);
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.06);
}
@media (max-width: 768px) {
  .proposal-hover-detail { display: none; }
}
.proposal-card-top {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
}
.proposal-card-property {
  font-size: var(--text-md); font-weight: 700;
  color: var(--text-primary); line-height: 1.3;
}
.proposal-card-amount {
  font-size: var(--text-lg); font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap; flex-shrink: 0;
}
.proposal-card-meta {
  display: flex; flex-wrap: wrap; gap: 8px 16px;
  font-size: var(--text-sm); color: var(--text-secondary);
}
.proposal-card-meta span { display: flex; align-items: center; gap: 4px; }
.proposal-card-contact {
  font-size: var(--text-sm); color: var(--text-secondary);
}
.proposal-card-actions {
  display: flex; gap: 8px; margin-top: auto; padding-top: 4px;
}
.proposal-card-actions .card-action-btn {
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  letter-spacing: 0.5px; text-transform: uppercase;
  padding: 6px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-default); background: var(--bg-elevated);
  color: var(--text-secondary); cursor: pointer;
  transition: all var(--transition-fast);
}
.proposal-card-actions .card-action-btn:hover {
  border-color: var(--status-positive); color: var(--status-positive);
}
.proposal-card-actions .card-action-btn.primary {
  background: var(--status-positive); color: var(--bg-base);
  border-color: var(--status-positive); font-weight: 700;
}
.proposal-card-actions .card-action-btn.primary:hover { opacity: 0.9; }

/* ---- JOB CARDS ---- */
.job-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: var(--space-lg);
}
.job-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  cursor: pointer;
  display: flex; flex-direction: column; gap: 10px;
}
.job-card:hover { border-color: var(--border-hover); box-shadow: 0 4px 24px rgba(0,0,0,0.15); }
.job-card-top {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
}
.job-card-number {
  font-size: var(--text-xs); font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
  color: var(--status-positive);
}
.job-card-property {
  font-size: var(--text-md); font-weight: 700;
  color: var(--text-primary); line-height: 1.3;
}
.job-card-amount {
  font-size: var(--text-lg); font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap; flex-shrink: 0;
}
.job-card-meta {
  display: flex; flex-wrap: wrap; gap: 8px 16px;
  font-size: var(--text-sm); color: var(--text-secondary);
}
.job-card-meta span { display: flex; align-items: center; gap: 4px; }
.job-card-margin-indicator {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--text-sm); font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.job-card-margin-indicator.green { color: var(--status-positive); background: var(--status-positive-bg); }
.job-card-margin-indicator.amber { color: var(--status-warning); background: var(--status-warning-bg); }
.job-card-margin-indicator.red { color: var(--status-negative); background: var(--status-negative-bg); }

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center; padding: 60px 20px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
}
.empty-state-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.6; }
.empty-state-title {
  font-size: var(--text-md); font-weight: 600;
  color: var(--text-primary); margin-bottom: 6px;
}
.empty-state-text {
  font-size: var(--text-base); color: var(--text-secondary);
  margin-bottom: 20px; line-height: 1.5;
}

/* ---- RESPONSIVE: PIPELINE + CARDS ---- */
@media (max-width: 768px) {
  .pipeline-summary { grid-template-columns: repeat(2, 1fr); }
  .proposal-cards, .job-cards { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .pipeline-summary { grid-template-columns: 1fr; }
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ---- SELECTION ---- */
::selection { background: rgba(90, 154, 110, 0.3); color: var(--text-primary); }

/* ---- SPLIT-FLAP / VESTABOARD LOGO ANIMATION ---- */
.split-flap {
  display: inline-flex;
  gap: 0;
  font-family: var(--font-mono);
  font-weight: 700;
}
.split-flap .flap-char {
  display: inline-block;
  transition: transform 0.05s ease;
}
/* Tile variant — each char gets a background tile like a real board */
.split-flap.flap-tiles .flap-char {
  background: rgba(255, 248, 230, 0.04);
  border: 1px solid rgba(255, 248, 230, 0.06);
  border-radius: 3px;
  padding: 2px 4px;
  margin: 0 1px;
  line-height: 1;
}
[data-theme="light"] .split-flap.flap-tiles .flap-char {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
}

/* ---- NOISE TEXTURE OVERLAY ---- */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
}

/* ---- STAGGERED ENTRY ANIMATION ---- */
@keyframes staggerIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); filter: blur(4px); }
  to   { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}
.stagger-in {
  animation: staggerIn 500ms cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
  animation-delay: calc(60ms * var(--stagger, 0));
}
/* Utility classes for common stagger positions */
.stagger-1 { --stagger: 1; }
.stagger-2 { --stagger: 2; }
.stagger-3 { --stagger: 3; }
.stagger-4 { --stagger: 4; }
.stagger-5 { --stagger: 5; }
.stagger-6 { --stagger: 6; }

/* KPI cards auto-stagger */
.kpi-row > :nth-child(1) { --stagger: 0; }
.kpi-row > :nth-child(2) { --stagger: 1; }
.kpi-row > :nth-child(3) { --stagger: 2; }
.kpi-row > :nth-child(4) { --stagger: 3; }
.kpi-row > .kpi-card { animation: staggerIn 500ms cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
  animation-delay: calc(60ms * var(--stagger, 0)); }

/* Panels and grid children auto-stagger */
.grid-2 > :nth-child(1) { --stagger: 0; }
.grid-2 > :nth-child(2) { --stagger: 1; }
.grid-2 > .panel, .grid-2 > .chart-card { animation: staggerIn 500ms cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
  animation-delay: calc(80ms * var(--stagger, 0)); }

/* ---- DRILLABLE ROW HOVER ACCENT ---- */
.drillable {
  cursor: pointer;
  position: relative;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.drillable::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--status-positive), transparent);
  opacity: 0;
  transition: opacity 0.2s ease;
  border-radius: 2px;
}
.drillable:hover { background: var(--bg-hover); }
.drillable:hover::before { opacity: 1; }

/* ---- SLIDE-OVER PANEL (drill-down) ---- */
.drill-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.drill-overlay.open { opacity: 1; pointer-events: auto; }

.drill-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 420px; max-width: 90vw;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border-subtle);
  z-index: 201;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex; flex-direction: column;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.4);
}
/* Entrance: 250ms. Exit: 150ms (faster out than in) */
.drill-overlay.open .drill-panel { transform: translateX(0); }
.drill-overlay:not(.open) .drill-panel { transition-duration: 0.15s; }

.drill-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-shrink: 0;
}
.drill-breadcrumb {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}
.drill-header h3 { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.drill-close {
  background: none; border: none;
  color: var(--text-tertiary);
  font-size: 20px; cursor: pointer;
  padding: 4px 8px; border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}
.drill-close:hover { color: var(--text-primary); background: var(--bg-hover); }

.drill-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.drill-section-label {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
  margin-top: 20px;
}
.drill-section-label:first-child { margin-top: 0; }

.drill-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-default);
  font-size: 12px;
}
.drill-row-key { color: var(--text-secondary); }
.drill-row-value { color: var(--text-primary); font-weight: 600; font-family: var(--font-sans); font-variant-numeric: tabular-nums; }
.drill-row-value.positive { color: var(--status-positive); }
.drill-row-value.negative { color: var(--status-negative); }
.drill-row-value.warning { color: var(--status-warning); }

.drill-row.highlight {
  background: var(--coaching-bg);
  border: 1px solid var(--coaching-border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin: 4px 0;
}

.drill-coaching {
  background: var(--coaching-bg);
  border: 1px solid var(--coaching-border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-top: 16px;
}
.drill-coaching .tag {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--status-positive);
  background: var(--status-positive-bg);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  display: inline-block;
  margin-bottom: 8px;
}
.drill-coaching p { font-size: 12px; line-height: 1.6; color: var(--text-secondary); }
.drill-coaching strong { color: var(--text-primary); }

.drill-action {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-top: 8px;
}
.drill-action:first-child { margin-top: 16px; }
.drill-action:hover { background: var(--bg-hover); border-color: var(--border-hover); }
.drill-action-icon { font-size: 14px; width: 20px; text-align: center; }
.drill-action-text { flex: 1; }
.drill-action-arrow { color: var(--text-muted); font-size: 14px; }

.drill-compare {
  margin-top: 12px;
  background: var(--glass-bg);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.drill-compare-label {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.drill-bar-container {
  height: 6px;
  background: var(--border-subtle);
  border-radius: 3px;
  position: relative;
  margin-bottom: 6px;
}
.drill-bar-fill {
  height: 100%;
  border-radius: 3px;
  position: absolute;
  left: 0; top: 0;
}
.drill-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
}

.drill-table {
  width: 100%;
  font-size: 11px;
  border-collapse: collapse;
  margin-top: 8px;
}
.drill-table th {
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 6px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.drill-table td {
  padding: 6px 0;
  border-bottom: 1px solid var(--border-default);
  color: var(--text-secondary);
}
.drill-table td:last-child {
  text-align: right;
  color: var(--text-primary);
  font-weight: 600;
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
}

/* ---- REDUCED MOTION ---- */
@media (prefers-reduced-motion: reduce) {
  .stagger-in,
  .kpi-row > .kpi-card,
  .grid-2 > .panel,
  .grid-2 > .chart-card { animation: none; }
  .drill-panel { transition-duration: 0.01s; }
  .drill-overlay { transition-duration: 0.01s; }
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 900px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-top { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: -220px; top: 0; bottom: 0;
    transition: left var(--transition-slow);
    z-index: 100;
  }
  .sidebar.open { left: 0; }
  .hamburger { display: flex; }
  .content { padding: var(--space-lg); }
  .quick-actions { padding: var(--space-md) var(--space-lg); }
  .topbar { padding: var(--space-md) var(--space-lg); }
  .kpi-row { grid-template-columns: 1fr; }
}
