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

:root {
  --bg:         #09090b;
  --bg-raised:  #18181b;
  --bg-hover:   #1f1f23;
  --border:     #27272a;
  --border-sub: #1e1e22;
  --text:       #f4f4f5;
  --text-2:     #a1a1aa;
  --text-3:     #71717a;
  --text-4:     #52525b;
  --accent:     #10b981;
  --accent-dim: rgba(16,185,129,0.12);
  --accent-2:   #34d399;
  --warn:       #f59e0b;
  --warn-dim:   rgba(245,158,11,0.10);
  --danger:     #ef4444;
  --blue:       #38bdf8;
  --blue-dim:   rgba(56,189,248,0.10);
  --radius:     16px;
  --radius-sm:  10px;
  --ease:       cubic-bezier(0.16, 1, 0.3, 1);
  --font:       'Outfit', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --mono:       'JetBrains Mono', ui-monospace, monospace;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ─── Sidebar (desktop) ─────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 200px;
  background: var(--bg);
  border-right: 1px solid var(--border-sub);
  display: flex;
  flex-direction: column;
  padding: 2rem 0 1.5rem;
  z-index: 100;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0 1.25rem;
  margin-bottom: 2.5rem;
}

.logo {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 0.9rem;
  color: var(--bg);
}

.logo-text {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.5px;
}

.nav-links { list-style: none; }

.nav-link {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.55rem 1.25rem;
  color: var(--text-3);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: color 0.25s var(--ease), background 0.25s var(--ease);
  border-left: 2px solid transparent;
  position: relative;
}

.nav-link svg { width: 17px; height: 17px; flex-shrink: 0; }

.nav-link:hover { color: var(--text-2); background: var(--bg-raised); }

.nav-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-dim);
}

/* ─── Mobile Bottom Nav ──────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-raised);
  border-top: 1px solid var(--border-sub);
  z-index: 200;
  padding: 0.35rem 0 env(safe-area-inset-bottom, 0.35rem);
}

.bottom-nav-inner {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  max-width: 480px;
  margin: 0 auto;
}

.bottom-nav-link {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 0.45rem 0;
  color: var(--text-4);
  text-decoration: none;
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.2px;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-link svg { width: 20px; height: 20px; }

.bottom-nav-link.active { color: var(--accent); }

/* ─── Main ───────────────────────────────────────────────── */
.main-content {
  margin-left: 200px;
  padding: 2.5rem 3rem;
  max-width: 1400px;
}

.section { display: none; animation: fadeUp 0.4s var(--ease); }
.section.active { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Section header ─────────────────────────────────────── */
.section-header { margin-bottom: 2.5rem; }

.section-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.75px;
  line-height: 1.15;
}

.subtitle {
  color: var(--text-3);
  margin-top: 0.4rem;
  font-size: 0.9rem;
  font-weight: 400;
}

/* ─── Stats (asymmetric 2fr 1fr 1fr layout) ──────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 1px;
  background: var(--border-sub);
  border: 1px solid var(--border-sub);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 2.5rem;
}

.stat-card {
  background: var(--bg-raised);
  padding: 1.5rem;
  transition: background 0.3s var(--ease);
}

.stat-card:hover { background: var(--bg-hover); }

.stat-card.featured {
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.stat-value {
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.5px;
}

.stat-card.featured .stat-value {
  font-size: 2.75rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-sub {
  font-size: 0.72rem;
  color: var(--text-4);
  margin-top: 0.25rem;
}

/* ─── Chart containers ───────────────────────────────────── */
.chart-row {
  display: grid;
  gap: 1px;
  background: var(--border-sub);
  border: 1px solid var(--border-sub);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.chart-row.two { grid-template-columns: 3fr 2fr; }
.chart-row.one { grid-template-columns: 1fr; }

.chart-container {
  background: var(--bg-raised);
  padding: 1.5rem;
}

.chart-container h3 {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.3px;
  margin-bottom: 1rem;
  text-transform: uppercase;
}

/* ─── Assumptions strip ──────────────────────────────────── */
.assumptions-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border-sub);
  border: 1px solid var(--border-sub);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 1.5rem;
}

.assumption-item {
  background: var(--bg-raised);
  padding: 1rem 1.25rem;
  display: flex; gap: 0.75rem; align-items: flex-start;
}

.assumption-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: grid; place-items: center;
  flex-shrink: 0;
}

.assumption-icon svg { width: 16px; height: 16px; }

.assumption-icon.house  { background: var(--blue-dim); color: var(--blue); }
.assumption-icon.chart  { background: var(--warn-dim); color: var(--warn); }
.assumption-icon.person { background: var(--accent-dim); color: var(--accent); }
.assumption-icon.bank   { background: rgba(239,68,68,0.10); color: var(--danger); }

.assumption-item strong {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.1rem;
}

.assumption-item p {
  font-size: 0.72rem;
  color: var(--text-3);
  line-height: 1.45;
}

/* ─── Simulator ──────────────────────────────────────────── */
.simulator-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.controls-panel {
  background: var(--bg-raised);
  border: 1px solid var(--border-sub);
  border-radius: var(--radius);
  padding: 1.25rem;
  position: sticky;
  top: 1.5rem;
}

.controls-panel h3 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.control-group { margin-bottom: 1.1rem; }

.control-group > label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.45rem;
}

.slider-row { display: flex; align-items: center; gap: 0.65rem; }

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s var(--ease);
}

input[type="range"]::-webkit-slider-thumb:active {
  transform: scale(1.2);
}

.slider-value {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--accent);
  min-width: 42px;
  text-align: right;
}

/* Toggle */
.toggle-row { display: flex; align-items: center; gap: 0.75rem; }

.toggle {
  position: relative;
  width: 40px; height: 22px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute; cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 11px;
  transition: background 0.3s var(--ease);
}

.toggle-slider::before {
  content: "";
  position: absolute;
  height: 16px; width: 16px;
  left: 3px; bottom: 3px;
  background: var(--text);
  border-radius: 50%;
  transition: transform 0.3s var(--ease);
}

.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

#jump-label { font-size: 0.8rem; color: var(--text-3); }

.reset-btn {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.2s var(--ease);
  margin-top: 0.5rem;
}

.reset-btn:hover { border-color: var(--accent); color: var(--accent); }
.reset-btn:active { transform: scale(0.98); }

/* Simulator results */
.simulator-charts { display: flex; flex-direction: column; gap: 1.25rem; }

.result-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border-sub);
  border: 1px solid var(--border-sub);
  border-radius: var(--radius);
  overflow: hidden;
}

.result-card {
  background: var(--bg-raised);
  padding: 1rem 1.25rem;
  text-align: center;
}

.result-card.highlight { background: var(--accent-dim); }

.result-label {
  font-size: 0.65rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.result-value {
  font-family: var(--mono);
  font-size: 1.25rem;
  font-weight: 600;
}

.result-sub {
  font-size: 0.65rem;
  color: var(--text-4);
  margin-top: 0.15rem;
}

/* ─── Income phases (2×2 zig-zag, not 3-col) ─────────────── */
.income-phases {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border-sub);
  border: 1px solid var(--border-sub);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 2rem;
}

.phase-card { background: var(--bg-raised); overflow: hidden; }

.phase-header { padding: 1rem 1.25rem 0.75rem; }

.phase-1 .phase-tag { color: var(--accent); }
.phase-2 .phase-tag { color: var(--blue); }
.phase-3 .phase-tag { color: var(--warn); }
.phase-4 .phase-tag { color: var(--danger); }

.phase-tag {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 700;
}

.phase-header h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-top: 0.25rem;
  letter-spacing: -0.3px;
}

.phase-body { padding: 0 1.25rem 1.25rem; }

.phase-metric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0;
  font-size: 0.8rem;
}

.phase-metric span { color: var(--text-3); }

.phase-metric strong {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 0.78rem;
}

.phase-actions {
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.phase-actions p {
  font-size: 0.75rem;
  color: var(--text-3);
  padding: 0.15rem 0 0.15rem 1rem;
  position: relative;
}

.phase-actions p::before {
  content: "";
  position: absolute; left: 0; top: 0.55rem;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--text-4);
}

/* ─── Timeline ───────────────────────────────────────────── */
.timeline { position: relative; padding-left: 2rem; }

.timeline::before {
  content: "";
  position: absolute; left: 5px; top: 8px; bottom: 8px;
  width: 1px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  margin-bottom: 1.5rem;
  animation: fadeUp 0.4s var(--ease) both;
}

.timeline-item:nth-child(1) { animation-delay: 0.05s; }
.timeline-item:nth-child(2) { animation-delay: 0.10s; }
.timeline-item:nth-child(3) { animation-delay: 0.15s; }
.timeline-item:nth-child(4) { animation-delay: 0.20s; }
.timeline-item:nth-child(5) { animation-delay: 0.25s; }
.timeline-item:nth-child(6) { animation-delay: 0.30s; }
.timeline-item:nth-child(7) { animation-delay: 0.35s; }

.timeline-dot {
  position: absolute; left: -2rem; top: 1rem;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--border);
  z-index: 1;
}

.timeline-dot.current { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.timeline-dot.decision { background: var(--warn); }
.timeline-dot.milestone { background: var(--accent-2); }

.timeline-content {
  background: var(--bg-raised);
  border: 1px solid var(--border-sub);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  transition: border-color 0.25s var(--ease);
}

.timeline-content:hover { border-color: var(--border); }

.timeline-date {
  font-size: 0.72rem; color: var(--text-3);
  margin-bottom: 0.25rem; font-weight: 500;
}

.timeline-title {
  font-size: 0.95rem; font-weight: 600;
  margin-bottom: 0.25rem; letter-spacing: -0.3px;
}

.timeline-desc { font-size: 0.82rem; color: var(--text-3); line-height: 1.5; }

/* ─── Insight grid ───────────────────────────────────────── */
.insight-box {
  border: 1px solid var(--border-sub);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 1.5rem;
}

.insight-box h3 {
  font-size: 0.85rem; font-weight: 600;
  padding: 1.25rem 1.25rem 0;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px; background: var(--border-sub);
  margin-top: 1rem;
}

.insight-item {
  background: var(--bg-raised);
  text-align: center;
  padding: 1.25rem 1rem;
}

.insight-number {
  font-family: var(--mono);
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.4rem;
}

.insight-text { font-size: 0.72rem; color: var(--text-3); line-height: 1.5; }

/* ─── Action items ───────────────────────────────────────── */
.action-phase {
  border: 1px solid var(--border-sub);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1rem;
}

.action-phase h2 {
  font-size: 1rem; font-weight: 600;
  padding: 1rem 1.25rem;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border-sub);
  letter-spacing: -0.3px;
}

.action-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border-sub);
}

.action-column {
  background: var(--bg-raised);
  padding: 1rem 1.25rem;
}

.action-column h4 {
  font-size: 0.72rem; font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.65rem;
}

.action-item {
  display: flex; align-items: flex-start; gap: 0.55rem;
  padding: 0.35rem 0;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-2);
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.action-item input[type="checkbox"] {
  margin-top: 3px;
  accent-color: var(--accent);
  cursor: pointer;
  width: 15px; height: 15px;
  flex-shrink: 0;
}

.action-item:has(input:checked) span {
  text-decoration: line-through;
  color: var(--text-4);
}

/* ─── Simulator controls collapse (mobile) ───────────────── */
.controls-toggle {
  display: none;
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-raised);
  border: 1px solid var(--border-sub);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  margin-bottom: 1rem;
  transition: border-color 0.2s;
}

.controls-toggle:active { border-color: var(--accent); }

.controls-toggle svg {
  width: 16px; height: 16px;
  vertical-align: middle;
  margin-right: 0.5rem;
  transition: transform 0.3s var(--ease);
}

.controls-toggle.open svg { transform: rotate(180deg); }

/* ─── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ─── MOBILE (<768px) ────────────────────────────────────── */
@media (max-width: 767px) {
  .sidebar { display: none; }
  .bottom-nav { display: block; }
  .main-content {
    margin-left: 0;
    padding: 1.25rem 1rem 5rem;
  }

  .section-header h1 { font-size: 1.35rem; }

  /* Stats → stack */
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .stat-card.featured {
    grid-row: auto;
  }
  .stat-card.featured .stat-value { font-size: 2rem; }

  /* Charts → single col */
  .chart-row.two { grid-template-columns: 1fr; }

  /* Assumptions → 2-col then 1-col */
  .assumptions-strip { grid-template-columns: 1fr 1fr; }

  /* Simulator → stack */
  .simulator-layout { grid-template-columns: 1fr; }
  .controls-panel {
    position: static;
    max-height: none;
  }
  .controls-toggle { display: flex; align-items: center; }
  .controls-panel.collapsed .control-group,
  .controls-panel.collapsed .reset-btn,
  .controls-panel.collapsed h3 { display: none; }

  /* Results */
  .result-cards { grid-template-columns: 1fr 1fr; }

  /* Phases → single col */
  .income-phases { grid-template-columns: 1fr; }

  /* Insights → 2-col */
  .insight-grid { grid-template-columns: 1fr 1fr; }

  /* Actions → single col */
  .action-columns { grid-template-columns: 1fr; }

  /* Larger touch targets */
  input[type="range"]::-webkit-slider-thumb { width: 22px; height: 22px; }
  .action-item { padding: 0.5rem 0; font-size: 0.88rem; }
  .action-item input[type="checkbox"] { width: 18px; height: 18px; }

  /* Timeline tighter */
  .timeline { padding-left: 1.5rem; }
  .timeline-dot { left: -1.5rem; }
}

@media (max-width: 420px) {
  .assumptions-strip { grid-template-columns: 1fr; }
  .result-cards { grid-template-columns: 1fr; }
  .insight-grid { grid-template-columns: 1fr; }
}

/* ─── Tablet (768-1024) ──────────────────────────────────── */
@media (min-width: 768px) and (max-width: 1024px) {
  .sidebar { width: 180px; }
  .main-content { margin-left: 180px; padding: 2rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card.featured { grid-row: auto; grid-column: 1 / -1; }
  .insight-grid { grid-template-columns: repeat(2, 1fr); }
}
