/* BTCPerformance, shared styles */
:root {
  --bg: #0a0e16;
  --surface: #121826;
  --surface-2: #171f30;
  --border: #232d42;
  --border-strong: #2f3b55;
  --text: #e8edf6;
  --text-2: #b4bfd2;
  --muted: #8491a8;
  --brand: #f7931a;           /* logo + UI accent only, not a data color */
  --brand-ink: #1a1206;
  --series-1: #d97706;        /* price, portfolio value */
  --series-2: #3b82f6;        /* 200D SMA, amount invested */
  --up: #3fb950;
  --down: #f85149;
  --grid: rgba(148, 163, 184, 0.10);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 10px 30px -18px rgba(0, 0, 0, 0.7);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 85% -120px, rgba(247, 147, 26, 0.08), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: #9cc2ff; text-decoration: none; }
a:hover { text-decoration: underline; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.up { color: var(--up); }
.down { color: var(--down); }
.muted { color: var(--muted); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* ---- Header ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(10, 14, 22, 0.82);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .wrap { display: flex; align-items: center; gap: 24px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brand); color: var(--brand-ink);
  font-weight: 800; font-size: 17px; transform: rotate(-12deg);
}
.brand b { color: var(--brand); font-weight: 700; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a { color: var(--text-2); padding: 6px 10px; border-radius: 8px; font-size: 14px; }
.nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.live {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--muted); white-space: nowrap;
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--up); box-shadow: 0 0 0 0 rgba(63, 185, 80, 0.6); animation: pulse 2s infinite; }
.live.stale .live-dot { background: var(--muted); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(63,185,80,.55); } 70% { box-shadow: 0 0 0 8px rgba(63,185,80,0); } 100% { box-shadow: 0 0 0 0 rgba(63,185,80,0); } }

/* ---- Hero ---- */
.hero { padding: 36px 0 12px; display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: end; }
.eyebrow { color: var(--brand); font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; margin: 0 0 8px; }
.hero h1 { margin: 0; font-size: 15px; font-weight: 500; color: var(--text-2); }
.hero-price { font-size: clamp(38px, 6vw, 56px); font-weight: 700; line-height: 1.05; margin: 6px 0 4px; letter-spacing: -0.02em; }
.hero-change { font-size: 16px; font-weight: 600; }
.hero-change .muted { font-weight: 400; }
.hero-note { text-align: right; font-size: 13px; color: var(--muted); max-width: 320px; }

/* ---- KPI tiles ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 20px 0 8px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); min-width: 0;
}
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 500; display: flex; justify-content: space-between; gap: 8px; }
.kpi-value { font-size: 22px; font-weight: 600; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.pill.up { color: var(--up); border-color: rgba(63,185,80,.35); background: rgba(63,185,80,.08); }
.pill.down { color: var(--down); border-color: rgba(248,81,73,.35); background: rgba(248,81,73,.08); }

/* ---- Cards / sections ---- */
section.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); margin: 20px 0; padding: 20px;
}
.card-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 20px; margin-bottom: 14px; }
.card-head h2 { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -0.01em; }
.card-head p { margin: 3px 0 0; color: var(--muted); font-size: 13.5px; max-width: 640px; }
.subhead { font-size: 13px; font-weight: 600; color: var(--text-2); margin: 18px 0 6px; display: flex; justify-content: space-between; gap: 12px; }

/* ---- Controls ---- */
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.seg {
  display: inline-flex; background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 3px; gap: 2px;
}
.seg button {
  appearance: none; border: 0; background: transparent; color: var(--text-2);
  font: 600 12.5px var(--font); padding: 6px 11px; border-radius: 7px; cursor: pointer; min-width: 40px;
}
.seg button:hover { color: var(--text); background: var(--surface-2); }
.seg button[aria-pressed='true'] { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong); }
.toggle { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2); cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--brand); width: 15px; height: 15px; margin: 0; }
.toggle.disabled { opacity: 0.45; cursor: not-allowed; }

.btn {
  appearance: none; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  font: 600 13px var(--font); padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer;
}
.btn:hover { border-color: #3d4b69; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }

/* ---- Charts ---- */
.chart-box { position: relative; width: 100%; }
.chart-box.h-lg { height: 360px; }
.chart-box.h-md { height: 280px; }
.chart-box.h-sm { height: 170px; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.swatch.dash { background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px) !important; height: 2px; }
.range-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.range-stats div { font-size: 12px; color: var(--muted); min-width: 0; }
.range-stats strong { display: block; font-size: 15px; color: var(--text); font-weight: 600; margin-top: 2px; }

/* ---- DCA ---- */
.dca { display: grid; grid-template-columns: 300px 1fr; gap: 22px; }
.form-grid { display: grid; gap: 12px; align-content: start; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.field input, .field select {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 9px 11px; font: 500 14px var(--font); color-scheme: dark;
}
.field input:focus, .field select:focus, .btn:focus-visible, .seg button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.input-prefix { position: relative; }
.input-prefix span { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; }
.input-prefix input { padding-left: 24px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.presets button {
  appearance: none; border: 1px solid var(--border); background: transparent; color: var(--text-2);
  font: 500 12px var(--font); padding: 4px 9px; border-radius: 999px; cursor: pointer;
}
.presets button:hover { color: var(--text); border-color: var(--border-strong); }
.dca-results { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; min-width: 0; }
.stat .k { font-size: 11.5px; color: var(--muted); }
.stat .v { font-size: 18px; font-weight: 600; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .s { font-size: 11.5px; color: var(--muted); }
.dca-summary { font-size: 14px; color: var(--text-2); margin: 0 0 12px; }
.dca-summary strong { color: var(--text); }

/* ---- Heatmap ---- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-sm); }
table.heat { border-collapse: separate; border-spacing: 2px; width: 100%; min-width: 760px; font-size: 12.5px; }
table.heat th { color: var(--muted); font-weight: 600; font-size: 11.5px; padding: 6px 4px; text-align: center; }
table.heat th.year { text-align: left; padding-left: 8px; color: var(--text-2); }
table.heat td {
  text-align: center; padding: 7px 4px; border-radius: 5px; color: var(--text);
  font-family: var(--mono); font-variant-numeric: tabular-nums; cursor: default;
}
table.heat td.empty { color: transparent; background: transparent; }
table.heat td.total { font-weight: 700; box-shadow: inset 0 0 0 1px var(--border-strong); }
table.heat tfoot td { color: var(--text-2); font-weight: 600; background: var(--surface-2); }
.heat-legend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.heat-legend .bar { width: 160px; height: 8px; border-radius: 4px; }

/* ---- Explainers / FAQ ---- */
.faq { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.faq article { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; }
.faq h3 { margin: 0 0 6px; font-size: 14.5px; }
.faq p { margin: 0; color: var(--text-2); font-size: 13.5px; }

/* ---- Tooltip (heatmap) ---- */
.tip {
  position: fixed; z-index: 50; pointer-events: none; background: #0b1020; border: 1px solid var(--border-strong);
  color: var(--text); font-size: 12.5px; padding: 7px 10px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.45);
  opacity: 0; transition: opacity .08s;
}

/* ---- Footer ---- */
footer.site { border-top: 1px solid var(--border); margin-top: 36px; padding: 26px 0 40px; color: var(--muted); font-size: 13px; }
footer.site .wrap { display: flex; flex-wrap: wrap; gap: 12px 28px; justify-content: space-between; }
footer.site p { margin: 0; max-width: 640px; }
footer.site nav { display: flex; gap: 18px; }

/* ---- Simple pages (contact, 404) ---- */
.page { max-width: 640px; margin: 48px auto; padding: 0 20px; }
.page h1 { font-size: 28px; margin: 0 0 8px; letter-spacing: -0.02em; }
.page p.lead { color: var(--text-2); margin: 0 0 22px; }
.page form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; display: grid; gap: 14px; box-shadow: var(--shadow); }
.page textarea { width: 100%; min-height: 140px; resize: vertical; background: var(--bg); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 10px 11px; font: 500 14px var(--font); }
.page textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.form-note { font-size: 12.5px; color: var(--muted); }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .dca { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; }
  .hero-note { text-align: left; }
  .nav { display: none; }
  .topbar .live { margin-left: auto; }
}
@media (max-width: 600px) {
  .wrap { padding: 0 16px; }
  section.card { padding: 16px; margin: 14px 0; }
  .chart-box.h-lg { height: 280px; }
  .chart-box.h-md { height: 230px; }
  .range-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi-value { font-size: 19px; }
  .seg button { padding: 6px 8px; min-width: 34px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .live-dot { animation: none; }
}
