body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
}

:root {
  --bg-canvas: #000000;
  --bg-surface: #1d2026;
  --bg-surface-elevated: #242831;
  --bg-surface-deep: #15181d;
  --bg-hover: #272c35;
  
  --border-default: #2c313a;
  --border-strong: #3d4452;
  --border-accent: #7b109a;

  --text-primary: #ffffff;
  --text-body: #d5d8de;
  --text-muted: #9aa1ad;
  --text-accent: #ce5dee;

  --accent-fill: #7b109a;
  --accent-hover: #6a0e87;
  --accent-active: #5a0c70;
  --accent-glow: rgba(123, 16, 154, 0.35);

  --success-fg: #4ade80;
  --success-bg: rgba(22, 163, 74, 0.18);
  --warning-fg: #facc15;
  --warning-bg: rgba(202, 138, 4, 0.18);
  --error-fg: #f87171;
  --error-bg: rgba(220, 38, 38, 0.18);
  --info-fg: #60a5fa;
  --info-bg: rgba(37, 99, 235, 0.18);

  --font-heading: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: "Open Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", ui-monospace, monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 2px 4px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.7);
  --shadow-accent: 0 0 15px var(--accent-glow);
}

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

html, body {
  height: 100%;
  background-color: var(--bg-canvas);
  color: var(--text-body);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--text-primary);
  font-weight: 700;
  letter-spacing: -0.02em;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-surface-deep);
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Eyebrow rule */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-accent);
  margin-bottom: 6px;
}

.eyebrow::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 3px;
  background-color: var(--accent-fill);
  border-radius: 2px;
}

/* Layout */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.app-sidebar {
  width: 260px;
  background-color: var(--bg-surface-deep);
  border-right: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  shrink: 0;
}

.app-header {
  height: 56px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  shrink: 0;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background-color: var(--bg-canvas);
}

/* Header & Brand */
.brand-title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px;
  border-bottom: 1px solid var(--border-default);
}

.brand-badge {
  background: linear-gradient(135deg, var(--accent-fill), #5a0c70);
  color: #ffffff;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-accent);
}

.brand-name {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* Navigation items */
.nav-group {
  padding: 12px 10px;
}

.nav-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 6px 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-body);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-bottom: 2px;
  border: 1px solid transparent;
}

.nav-item:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background-color: rgba(123, 16, 154, 0.2);
  color: var(--text-accent);
  border-color: rgba(206, 93, 238, 0.3);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

.nav-item.active svg {
  color: var(--text-accent);
}

/* Cards & Panels */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
  border-color: var(--border-strong);
}

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

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.card-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  outline: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-fill), #5a0c70);
  color: #ffffff;
  border-color: rgba(206, 93, 238, 0.4);
  box-shadow: var(--shadow-accent);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-hover), #4a0a5c);
  transform: translateY(-1px);
}

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

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

.btn-ghost {
  background: transparent;
  color: var(--text-body);
}

.btn-ghost:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

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

.btn-lg {
  padding: 10px 20px;
  font-size: 14px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
}

.badge-active {
  background-color: var(--success-bg);
  color: var(--success-fg);
  border: 1px solid rgba(74, 222, 128, 0.3);
}

.badge-draft {
  background-color: var(--warning-bg);
  color: var(--warning-fg);
  border: 1px solid rgba(250, 204, 21, 0.3);
}

.badge-accent {
  background-color: rgba(123, 16, 154, 0.25);
  color: var(--text-accent);
  border: 1px solid rgba(206, 93, 238, 0.3);
}

.badge-neutral {
  background-color: var(--bg-surface-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border-default);
}

/* Forms & Sliders */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.input-text, .select-input {
  width: 100%;
  padding: 8px 12px;
  background-color: var(--bg-surface-deep);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-text:focus, .select-input:focus {
  border-color: var(--text-accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.slider-input {
  width: 100%;
  accent-color: var(--text-accent);
  cursor: pointer;
}

.slider-val {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-accent);
  font-size: 13px;
}

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

.kpi-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  position: relative;
  overflow: hidden;
}

.kpi-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background-color: var(--accent-fill);
}

.kpi-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.kpi-value {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  margin: 4px 0;
  font-variant-numeric: tabular-nums;
}

.kpi-sub {
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Financial Tables */
.table-container {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
}

.fin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.fin-table th {
  background-color: var(--bg-surface-elevated);
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-default);
  white-space: nowrap;
}

.fin-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-default);
  color: var(--text-body);
  font-variant-numeric: tabular-nums;
}

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

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

.num-cell {
  text-align: right;
  font-family: var(--font-mono);
}

.highlight-row {
  background-color: rgba(123, 16, 154, 0.1);
  font-weight: 700;
}

.highlight-row td {
  color: var(--text-primary);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-content {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  max-width: 650px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: var(--shadow-lg);
}

/* Charts SVG Styling */
.chart-container {
  width: 100%;
  height: 320px;
  position: relative;
}

.chart-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.grid-line {
  stroke: var(--border-default);
  stroke-dasharray: 4 4;
  stroke-width: 1;
}

.axis-text {
  fill: var(--text-muted);
  font-size: 10px;
  font-family: var(--font-body);
}

/* Tooltip on SVG */
.chart-tooltip {
  position: absolute;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  box-shadow: var(--shadow-md);
  pointer-events: none;
  z-index: 10;
}

/* Tabs */
.tab-list {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-default);
  margin-bottom: 20px;
}

.tab-btn {
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.tab-btn.active {
  color: var(--text-accent);
  border-bottom-color: var(--accent-fill);
}

/* Sensitivity Heatmap */
.sensitivity-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.sensitivity-cell {
  padding: 10px;
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid var(--border-default);
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .app-shell {
    flex-direction: column;
  }
  .app-sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-default);
  }
  .brand-title {
    padding: 12px 16px;
  }
  .nav-group {
    display: flex;
    overflow-x: auto;
    padding: 6px 12px;
  }
  .nav-item {
    white-space: nowrap;
  }
}
