/* ==========================================================================
   Finance Intelligence Console — Premium Dark Theme
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* --------------------------------------------------------------------------
   CSS Custom Properties — Dark Executive Theme
   -------------------------------------------------------------------------- */

:root {
  /* Background hierarchy */
  --bg: #0B1120;
  --bg-card: #131C2E;
  --bg-elevated: #182235;
  --bg-hover: #1A2540;
  --bg-surface: #0F1729;

  /* Primary palette */
  --primary: #3B82F6;
  --primary-light: #60A5FA;
  --primary-dim: #2563EB;
  --primary-glow: rgba(59, 130, 246, 0.12);

  /* Accent */
  --accent: #8B5CF6;
  --accent-glow: rgba(139, 92, 246, 0.12);

  /* Semantic */
  --success: #10B981;
  --success-soft: rgba(16, 185, 129, 0.12);
  --destructive: #EF4444;
  --destructive-soft: rgba(239, 68, 68, 0.12);
  --warning: #F59E0B;
  --warning-soft: rgba(245, 158, 11, 0.12);

  /* Text */
  --text: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --text-dim: #475569;

  /* Borders */
  --border: rgba(148, 163, 184, 0.08);
  --border-subtle: rgba(148, 163, 184, 0.04);
  --border-accent: rgba(59, 130, 246, 0.2);

  /* Layout */
  --sidebar-width: 220px;
  --sidebar-collapsed: 60px;
  --topbar-height: 56px;
  --bottombar-height: 52px;
  --card-radius: 12px;
  --transition-speed: 200ms;

  /* Shadows */
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-elevated: 0 4px 12px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-glow-blue: 0 0 20px rgba(59, 130, 246, 0.15), 0 0 4px rgba(59, 130, 246, 0.1);
  --shadow-glow-green: 0 0 20px rgba(16, 185, 129, 0.15);
  --shadow-glow-red: 0 0 20px rgba(239, 68, 68, 0.15);
}

/* --------------------------------------------------------------------------
   Reset & Base
   -------------------------------------------------------------------------- */

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 8px 0;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

p { margin: 0 0 8px 0; }

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--text-dim);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* --------------------------------------------------------------------------
   App Layout
   -------------------------------------------------------------------------- */

.app-layout {
  min-height: 100vh;
}

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow: hidden;
  transition: width var(--transition-speed) ease;
}

.sidebar-logo {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-size: 15px;
  font-weight: 700;
  color: var(--primary-light);
  letter-spacing: -0.02em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  gap: 2px;
}

.sidebar-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-align: left;
  width: 100%;
  border-left: 3px solid transparent;
  transition: all var(--transition-speed) ease;
  white-space: nowrap;
}

.sidebar-btn:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.sidebar-btn.active {
  color: var(--primary-light);
  border-left-color: var(--primary);
  background: var(--primary-glow);
  font-weight: 600;
}

.sidebar-btn .icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --------------------------------------------------------------------------
   Topbar
   -------------------------------------------------------------------------- */

.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 90;
  transition: left var(--transition-speed) ease;
}

.topbar-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 6px;
  color: var(--text);
}

.topbar-hamburger:hover {
  background: var(--bg-hover);
}

.topbar-company {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-right: auto;
  letter-spacing: -0.01em;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar select,
.topbar-select {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-speed) ease;
}

.topbar select:focus,
.topbar-select:focus {
  border-color: var(--primary);
  box-shadow: var(--shadow-glow-blue);
}

.data-freshness {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.freshness-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.freshness-dot.stale {
  background: var(--warning);
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.6);
}

/* --------------------------------------------------------------------------
   Period & Compare Controls
   -------------------------------------------------------------------------- */

.period-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.period-quick-btns {
  display: flex;
  gap: 2px;
}

.period-btn {
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition-speed);
  font-family: inherit;
  letter-spacing: 0.02em;
}

.period-btn:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
  border-color: rgba(148, 163, 184, 0.15);
}

.period-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: var(--shadow-glow-blue);
}

.compare-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.compare-label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
}

#compare-select {
  font-size: 12px;
  padding: 4px 8px;
}

/* --------------------------------------------------------------------------
   Main Content Area
   -------------------------------------------------------------------------- */

.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  margin-bottom: var(--bottombar-height);
  padding: 24px;
  max-width: 1440px;
  min-height: calc(100vh - var(--topbar-height) - var(--bottombar-height));
  transition: margin-left var(--transition-speed) ease;
}

/* --------------------------------------------------------------------------
   Bottom Bar — AI Input
   -------------------------------------------------------------------------- */

.bottom-bar {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--bottombar-height);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 10px;
  z-index: 50;
}

.ai-input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-elevated);
  outline: none;
  transition: all var(--transition-speed) ease;
}

.ai-input:focus {
  border-color: var(--primary);
  box-shadow: var(--shadow-glow-blue);
  background: var(--bg-hover);
}

.ai-input::placeholder {
  color: var(--text-dim);
}

.ai-send-btn {
  padding: 10px 18px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-speed) ease;
  letter-spacing: 0.02em;
}

.ai-send-btn:hover {
  background: var(--primary-light);
  box-shadow: var(--shadow-glow-blue);
}

/* --------------------------------------------------------------------------
   AI Response Panel
   -------------------------------------------------------------------------- */

.ai-response-panel {
  position: fixed;
  bottom: var(--bottombar-height);
  left: var(--sidebar-width);
  right: 0;
  max-height: 340px;
  overflow-y: auto;
  background: var(--bg-card);
  border-top: 1px solid var(--border-accent);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.4);
  padding: 20px 24px;
  transform: translateY(100%);
  transition: transform var(--transition-speed) ease;
  z-index: 45;
}

.ai-response-panel.visible {
  transform: translateY(0);
}

.ai-response-panel .ai-response-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.ai-response-panel .ai-response-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-light);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.ai-response-panel .ai-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  transition: all var(--transition-speed);
}

.ai-response-panel .ai-close-btn:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.ai-response-panel .ai-response-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   Tab Sections
   -------------------------------------------------------------------------- */

.tab-section {
  display: none;
}

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

/* --------------------------------------------------------------------------
   KPI Cards — Premium Hero Cards
   -------------------------------------------------------------------------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 20px;
  transition: all var(--transition-speed) ease;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  opacity: 0;
  transition: opacity var(--transition-speed);
}

.kpi-card:hover {
  border-color: rgba(59, 130, 246, 0.15);
  box-shadow: var(--shadow-glow-blue);
  transform: translateY(-1px);
}

.kpi-card:hover::before {
  opacity: 1;
}

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 36px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.kpi-variance {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}

.kpi-variance.positive {
  background: var(--success-soft);
  color: var(--success);
}

.kpi-variance.negative {
  background: var(--destructive-soft);
  color: var(--destructive);
}

.kpi-variance.neutral {
  background: var(--warning-soft);
  color: var(--warning);
}

.sparkline-container {
  position: relative;
  height: 44px;
  margin-top: 12px;
}

/* --------------------------------------------------------------------------
   Chart Containers — Hero Elements
   -------------------------------------------------------------------------- */

.chart-container {
  position: relative;
  width: 100%;
  height: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 20px 20px 32px;
  margin-bottom: 16px;
  transition: all var(--transition-speed) ease;
}

.chart-container:hover {
  border-color: rgba(148, 163, 184, 0.12);
}

.chart-container.chart-hero {
  height: 480px;
}

.chart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* --------------------------------------------------------------------------
   Cards — Generic Container
   -------------------------------------------------------------------------- */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 20px;
  margin-bottom: 16px;
  transition: all var(--transition-speed) ease;
}

.card:hover {
  border-color: rgba(148, 163, 184, 0.1);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.card-total, .card-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 400;
  font-family: 'JetBrains Mono', monospace;
}

/* --------------------------------------------------------------------------
   Data Tables — Secondary, Clean
   -------------------------------------------------------------------------- */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.data-table th:hover {
  color: var(--text-secondary);
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.data-table tr:hover td {
  background: var(--bg-hover);
}

.data-table .num {
  font-family: 'JetBrains Mono', monospace;
  text-align: right;
  font-size: 13px;
}

/* Total row */
.total-row {
  border-top: 1px solid rgba(148, 163, 184, 0.15);
}
.total-row td {
  padding-top: 14px;
  color: var(--text);
  font-weight: 600;
}

/* Collapsible table wrapper */
.table-collapsible {
  border-radius: var(--card-radius);
  overflow: hidden;
}

.table-collapsible summary {
  cursor: pointer;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: color var(--transition-speed);
}

.table-collapsible summary:hover {
  color: var(--text-secondary);
}

.table-collapsible summary::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform var(--transition-speed);
}

.table-collapsible[open] summary::before {
  transform: rotate(45deg);
}

.table-collapsible summary::-webkit-details-marker {
  display: none;
}

/* --------------------------------------------------------------------------
   Variance Badges
   -------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  font-family: 'JetBrains Mono', monospace;
}

.badge.positive {
  background: var(--success-soft);
  color: var(--success);
}

.badge.negative {
  background: var(--destructive-soft);
  color: var(--destructive);
}

.badge.neutral {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge.info {
  background: var(--primary-glow);
  color: var(--primary-light);
}

/* --------------------------------------------------------------------------
   Alert Cards
   -------------------------------------------------------------------------- */

.alert-card {
  padding: 14px 18px;
  border-left: 3px solid var(--border);
  border-radius: 8px;
  margin-bottom: 10px;
  font-size: 14px;
  background: var(--bg-elevated);
}

.alert-card.warning {
  border-left-color: var(--warning);
  background: var(--warning-soft);
}

.alert-card.danger {
  border-left-color: var(--destructive);
  background: var(--destructive-soft);
}

.alert-card.success {
  border-left-color: var(--success);
  background: var(--success-soft);
}

.alert-card .alert-title {
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

.alert-card .alert-body {
  color: var(--text-secondary);
  font-size: 13px;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-speed) ease;
  white-space: nowrap;
}

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

.btn-primary:hover {
  background: var(--primary-light);
  box-shadow: var(--shadow-glow-blue);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: rgba(148, 163, 184, 0.15);
  color: var(--text);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
  gap: 4px;
}

/* --------------------------------------------------------------------------
   Section Headers
   -------------------------------------------------------------------------- */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* --------------------------------------------------------------------------
   Narrative Inline Boxes
   -------------------------------------------------------------------------- */

.narrative-inline {
  border-left: 3px solid var(--primary);
}

.narrative-inline .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.narrative-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 24px;
  font-size: 14px;
  line-height: 1.8;
  min-height: 120px;
  color: var(--text-secondary);
}

.narrative-content h2 {
  font-size: 18px;
  margin-top: 16px;
}

.narrative-content h3 {
  font-size: 15px;
  margin-top: 12px;
}

.narrative-content ul {
  padding-left: 20px;
  margin: 8px 0;
}

.narrative-content li {
  margin-bottom: 4px;
}

.variance-explanation {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.variance-explanation:last-child { border-bottom: none; }
.variance-explanation strong {
  margin-right: 8px;
  color: var(--text);
}
.variance-explanation p {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}

/* Positive/Negative cell colors */
td.positive, span.positive { color: var(--success); font-weight: 600; }
td.negative, span.negative { color: var(--destructive); font-weight: 600; }

/* --------------------------------------------------------------------------
   Layout Grids
   -------------------------------------------------------------------------- */

.forecast-grid, .chart-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.chart-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.cash-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.cash-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

/* --------------------------------------------------------------------------
   Cash Tab Specifics
   -------------------------------------------------------------------------- */

.runway-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 20px;
}

.runway-value {
  font-size: 48px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: var(--text);
}

.runway-label {
  font-size: 14px;
  color: var(--text-muted);
}

.cash-warnings { margin-top: 12px; }

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.5;
}
.alert-danger {
  background: var(--destructive-soft);
  color: var(--destructive);
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.alert-warning {
  background: var(--warning-soft);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

/* --------------------------------------------------------------------------
   Goal Bars
   -------------------------------------------------------------------------- */

.goal-bar {
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 4px;
}

.goal-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--primary);
  transition: width var(--transition-speed) ease;
}

.goal-bar-fill.on-track { background: var(--success); }
.goal-bar-fill.at-risk { background: var(--warning); }
.goal-bar-fill.behind { background: var(--destructive); }

.goal-meta {
  font-size: 12px;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Health Dot
   -------------------------------------------------------------------------- */

.health-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.health-dot.green {
  background: var(--success);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.health-dot.yellow {
  background: var(--warning);
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.5);
}

.health-dot.red {
  background: var(--destructive);
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

/* --------------------------------------------------------------------------
   Loading States — Skeleton + Spinner
   -------------------------------------------------------------------------- */

@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-hover) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.8s ease-in-out infinite;
  border-radius: 6px;
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
}

.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 70%; }

.skeleton-value {
  height: 36px;
  width: 140px;
  margin-bottom: 6px;
}

.skeleton-badge {
  height: 22px;
  width: 70px;
  border-radius: 20px;
}

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

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner.large {
  width: 36px;
  height: 36px;
  border-width: 3px;
}

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  gap: 12px;
  color: var(--text-muted);
  font-size: 14px;
}

/* --------------------------------------------------------------------------
   Utility Classes
   -------------------------------------------------------------------------- */

.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--destructive); }
.text-warning { color: var(--warning); }
.text-mono { font-family: 'JetBrains Mono', monospace; }

.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.hidden { display: none !important; }

/* --------------------------------------------------------------------------
   Responsive — Tablet
   -------------------------------------------------------------------------- */

@media (max-width: 1024px) {
  .sidebar {
    width: var(--sidebar-collapsed);
  }

  .sidebar .tab-label { display: none; }
  .sidebar-logo span { display: none; }

  .sidebar-btn {
    justify-content: center;
    padding: 10px 0;
  }

  .topbar { left: var(--sidebar-collapsed); }
  .main-content { margin-left: var(--sidebar-collapsed); }
  .bottom-bar { left: var(--sidebar-collapsed); }
  .ai-response-panel { left: var(--sidebar-collapsed); }
}

/* --------------------------------------------------------------------------
   Responsive — Mobile
   -------------------------------------------------------------------------- */

@media (max-width: 768px) {
  .sidebar {
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform var(--transition-speed) ease;
  }

  .sidebar.open { transform: translateX(0); }

  .mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99;
  }

  .mobile-overlay.visible { display: block; }
  .topbar { left: 0; }
  .topbar-hamburger { display: flex; }
  .main-content { margin-left: 0; padding: 16px; }
  .bottom-bar { left: 0; }
  .ai-response-panel { left: 0; }

  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-card .kpi-value { font-size: 28px; }

  .forecast-grid,
  .chart-grid-2,
  .cash-charts {
    grid-template-columns: 1fr;
  }

  .topbar-controls { gap: 8px; }
  .topbar-company { font-size: 14px; }
  .data-freshness { display: none; }
}

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

/* --------------------------------------------------------------------------
   Accessibility — Reduced Motion
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --------------------------------------------------------------------------
   Accessibility — Focus Visible
   -------------------------------------------------------------------------- */

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Print
   -------------------------------------------------------------------------- */

@media print {
  .sidebar, .bottom-bar, .ai-response-panel, .topbar-controls {
    display: none !important;
  }
  .topbar { margin-left: 0; position: static; }
  .main-content { margin-left: 0; }
  body { background: white; color: black; }
  .tab-section { display: block !important; page-break-after: always; }
}
