/* Meridian — wealth dashboard
   Palette strategy: committed. Deep plum carries the hero band (~40% of the
   first viewport); below it, true off-white surfaces with plum-tinted neutrals.
   Type: Fraunces (display) · Inter (UI) · Spline Sans Mono (figures). */

:root {
  /* color */
  --plum-900: oklch(0.24 0.08 315);
  --plum-800: oklch(0.30 0.10 315);
  --plum-700: oklch(0.38 0.12 315);
  --plum-100: oklch(0.90 0.04 315);
  --plum-50:  oklch(0.96 0.015 315);
  --bg:       oklch(0.97 0.005 315);
  --surface:  oklch(0.995 0.002 315);
  --ink:      oklch(0.22 0.015 315);
  --ink-soft: oklch(0.42 0.02 315);
  --line:     oklch(0.89 0.01 315);
  --pos:      oklch(0.50 0.11 155);
  --pos-on-dark: oklch(0.84 0.14 155);
  --neg:      oklch(0.50 0.16 25);
  --focus:    oklch(0.55 0.18 315);

  /* type */
  --font-display: "Fraunces", Georgia, serif;
  --font-ui: "Inter", system-ui, sans-serif;
  --font-num: "Spline Sans Mono", ui-monospace, monospace;

  /* shape & space */
  --radius-s: 8px;
  --radius-m: 14px;
  --radius-l: 22px;
  --gutter: clamp(1rem, 3vw, 2.5rem);

  /* z scale */
  --z-sticky: 10;
  --z-tooltip: 30;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { text-wrap: balance; margin: 0; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

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

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.8rem var(--gutter);
  background: var(--plum-900);
  color: oklch(0.97 0.01 315);
}

.topbar__brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.3rem;
  color: inherit;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.topbar__nav {
  display: flex;
  gap: 0.25rem;
  margin-inline-start: 1rem;
}

.topbar__link {
  color: oklch(0.85 0.03 315);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  transition: background-color 160ms ease-out, color 160ms ease-out;
}

.topbar__link:hover { background: oklch(0.32 0.09 315); color: oklch(0.98 0.005 315); }

.topbar__link--active {
  background: oklch(0.36 0.10 315);
  color: oklch(0.98 0.005 315);
}

.topbar__market {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: oklch(0.88 0.03 315);
}

.topbar__market-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--pos-on-dark);
}

.topbar__avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid oklch(0.45 0.08 315);
  background: var(--plum-700);
  color: oklch(0.97 0.01 315);
  font: 600 0.8rem var(--font-ui);
  cursor: pointer;
  transition: background-color 160ms ease-out;
}

.topbar__avatar:hover { background: oklch(0.44 0.12 315); }

/* ---------- hero band ---------- */

.hero {
  background: linear-gradient(180deg, var(--plum-900) 0%, var(--plum-800) 100%);
  color: oklch(0.96 0.01 315);
  padding: clamp(2rem, 5vw, 4rem) var(--gutter) clamp(2.5rem, 5vw, 4rem);
}

.hero__inner {
  max-width: 1180px;
  margin-inline: auto;
  display: grid;
  grid-template-columns: minmax(300px, 5fr) minmax(0, 7fr);
  gap: clamp(1.5rem, 4vw, 3.5rem);
  align-items: start;
}

.hero__date {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: oklch(0.82 0.04 315);
}

.hero__title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2rem, 4.5vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -0.015em;
}

.hero__summary {
  margin: 1rem 0 0;
  max-width: 42ch;
  font-size: 1.02rem;
  color: oklch(0.88 0.025 315);
}

.hero__gain { color: var(--pos-on-dark); font-weight: 600; }

.hero__worth { margin-top: 2rem; }

.hero__worth-label {
  display: block;
  font-size: 0.85rem;
  color: oklch(0.8 0.04 315);
  margin-bottom: 0.3rem;
}

.hero__figure {
  display: block;
  font-family: var(--font-num);
  font-weight: 600;
  font-size: clamp(2.1rem, 4.5vw, 3.1rem);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.delta {
  font-family: var(--font-num);
  font-size: 0.9rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.delta--up { color: var(--pos); }
.delta--down { color: var(--neg); }
.delta--onbrand.delta--up { color: var(--pos-on-dark); }

.hero__facts {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem 2.25rem;
  margin: 1.75rem 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid oklch(0.38 0.08 315);
}

.hero__fact dt {
  font-size: 0.8rem;
  color: oklch(0.8 0.04 315);
}

.hero__fact dd {
  margin: 0.15rem 0 0;
  font-family: var(--font-num);
  font-size: 1.05rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* hero chart card */

.hero__chart-wrap {
  background: oklch(0.20 0.06 315 / 0.55);
  border: 1px solid oklch(0.42 0.08 315);
  border-radius: var(--radius-l);
  padding: 1.25rem 1.25rem 1rem;
  min-width: 0;
}

.hero__chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.hero__chart-title {
  font-size: 1rem;
  font-weight: 600;
  color: oklch(0.93 0.02 315);
}

.range { display: flex; gap: 2px; background: oklch(0.30 0.07 315); border-radius: 999px; padding: 3px; }

.range__btn {
  border: 0;
  background: transparent;
  color: oklch(0.85 0.03 315);
  font: 500 0.8rem var(--font-ui);
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 160ms ease-out, color 160ms ease-out;
}

.range__btn:hover { color: oklch(0.98 0.005 315); }

.range__btn--active {
  background: oklch(0.95 0.01 315);
  color: var(--plum-900);
}

.hero__chart {
  position: relative;
  margin-top: 1rem;
  height: clamp(220px, 30vw, 320px);
}

.hero__chart svg { width: 100%; height: 100%; display: block; }

.chart-tip {
  position: absolute;
  z-index: var(--z-tooltip);
  pointer-events: none;
  background: oklch(0.985 0.005 315);
  color: var(--ink);
  border-radius: var(--radius-s);
  padding: 0.45rem 0.65rem;
  box-shadow: 0 6px 24px oklch(0.1 0.04 315 / 0.45);
  transform: translate(-50%, calc(-100% - 14px));
  white-space: nowrap;
}

.chart-tip__date { display: block; font-size: 0.72rem; color: var(--ink-soft); }

.chart-tip__value {
  display: block;
  font-family: var(--font-num);
  font-weight: 600;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.hero__chart-foot {
  margin: 0.9rem 0 0;
  font-size: 0.85rem;
  color: oklch(0.82 0.04 315);
}

/* ---------- board ---------- */

.board {
  max-width: 1180px;
  margin-inline: auto;
  padding: clamp(1.5rem, 4vw, 3rem) var(--gutter);
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: clamp(1rem, 2vw, 1.5rem);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: clamp(1.1rem, 2.5vw, 1.6rem);
  min-width: 0;
}

.panel--alloc { grid-column: span 5; }
.panel--cash { grid-column: span 7; }
.panel--holdings { grid-column: span 8; }
.panel--goals { grid-column: span 4; }

.panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
}

.panel__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
}

.panel__note { font-size: 0.82rem; color: var(--ink-soft); }

/* buttons */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font: 500 0.9rem var(--font-ui);
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
  cursor: pointer;
  transition: background-color 160ms ease-out, border-color 160ms ease-out;
}

.btn svg { width: 16px; height: 16px; }

.btn--ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

.btn--ghost:hover { border-color: var(--plum-700); background: var(--plum-50); }

.btn--solid {
  background: var(--plum-800);
  border: 1px solid var(--plum-800);
  color: oklch(0.97 0.01 315);
}

.btn--solid:hover { background: var(--plum-700); }

/* allocation */

.alloc {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 3vw, 2rem);
  flex-wrap: wrap;
}

.alloc__donut-wrap {
  position: relative;
  width: 168px;
  height: 168px;
  flex-shrink: 0;
}

.alloc__donut-wrap svg { width: 100%; height: 100%; display: block; }

.alloc__center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  pointer-events: none;
}

.alloc__center-num {
  font-family: var(--font-num);
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1;
}

.alloc__center-label { font-size: 0.72rem; color: var(--ink-soft); }

.alloc__legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
  flex: 1;
  min-width: 180px;
}

.alloc__row {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
}

.alloc__dot { width: 12px; height: 12px; border-radius: 4px; }

.alloc__pct {
  font-family: var(--font-num);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.alloc__action {
  margin-top: 1.25rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.alloc__action p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
  max-width: 30ch;
}

/* cash flow */

.cash__chart-wrap { height: 220px; }
.cash__chart-wrap svg { width: 100%; height: 100%; display: block; }

.cash__keys {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-top: 0.9rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
  flex-wrap: wrap;
}

.cash__key { display: inline-flex; align-items: center; gap: 0.45rem; }

.cash__swatch { width: 11px; height: 11px; border-radius: 3px; }
.cash__swatch--in { background: var(--plum-700); }
.cash__swatch--out { background: var(--plum-100); }

.cash__net {
  margin-inline-start: auto;
  font-family: var(--font-num);
  font-weight: 600;
  color: var(--pos);
  font-variant-numeric: tabular-nums;
}

/* holdings table */

.holdings__scroll { overflow-x: auto; }

.holdings {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  min-width: 540px;
}

.holdings th {
  text-align: left;
  font-weight: 500;
  font-size: 0.78rem;
  color: var(--ink-soft);
  padding: 0 0.6rem 0.6rem;
  border-bottom: 1px solid var(--line);
}

.holdings td {
  padding: 0.7rem 0.6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.holdings tbody tr:last-child td { border-bottom: 0; }

.holdings tbody tr { transition: background-color 120ms ease-out; }
.holdings tbody tr:hover { background: var(--plum-50); }

.holdings__num { text-align: right; }

td.holdings__num {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
}

.holdings__name { font-weight: 500; }

.holdings__ticker {
  display: block;
  font-size: 0.76rem;
  color: var(--ink-soft);
  font-family: var(--font-num);
}

.holdings__spark-col { width: 110px; text-align: right; }

.holdings__spark { width: 96px; height: 28px; display: inline-block; vertical-align: middle; }

/* goals */

.goals {
  list-style: none;
  margin: 0 0 1.25rem;
  padding: 0;
  display: grid;
  gap: 1.1rem;
}

.goal__top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
}

.goal__name { font-weight: 500; font-size: 0.95rem; }

.goal__pct {
  font-family: var(--font-num);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.goal__bar {
  margin-top: 0.45rem;
  height: 8px;
  border-radius: 999px;
  background: var(--plum-50);
  overflow: hidden;
}

.goal__fill {
  height: 100%;
  border-radius: inherit;
  background: var(--plum-700);
  transition: width 600ms cubic-bezier(0.22, 1, 0.36, 1);
}

.goal--ahead .goal__fill { background: var(--pos); }

.goal__meta {
  margin: 0.4rem 0 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

/* footer */

.foot {
  max-width: 1180px;
  margin-inline: auto;
  padding: 1.5rem var(--gutter) 2.5rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
  flex-wrap: wrap;
}

.foot p { margin: 0; }

.foot__brand { font-family: var(--font-display); font-weight: 600; color: var(--ink); }

/* chart svg internals (classes used by js/charts.js) */

.perf-grid-line { stroke: oklch(0.42 0.07 315 / 0.5); stroke-width: 1; stroke-dasharray: 2 5; }
.perf-axis-label {
  fill: oklch(0.78 0.04 315);
  font: 500 11px var(--font-num);
}
.perf-area { fill: url(#perfFill); }
.perf-line { fill: none; stroke: oklch(0.88 0.07 315); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.perf-cursor-line { stroke: oklch(0.9 0.03 315 / 0.7); stroke-width: 1; }
.perf-cursor-dot { fill: oklch(0.97 0.01 315); stroke: var(--plum-800); stroke-width: 2.5; }

.cash-bar-in { fill: var(--plum-700); }
.cash-bar-out { fill: var(--plum-100); }
.cash-axis-label { fill: var(--ink-soft); font: 500 11px var(--font-num); }
.cash-zero-line { stroke: var(--line); stroke-width: 1; }

.spark-line { fill: none; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.spark-line--up { stroke: var(--pos); }
.spark-line--down { stroke: var(--neg); }

/* ---------- responsive ---------- */

@media (max-width: 940px) {
  .panel--alloc, .panel--cash, .panel--holdings, .panel--goals { grid-column: span 12; }
  .hero__inner { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .topbar { gap: 0.75rem; }
  .topbar__nav { display: none; }
  .topbar__market span:last-child { display: none; }
  .hero__facts { gap: 1rem 1.5rem; }
  .alloc { justify-content: center; }
  .cash__net { margin-inline-start: 0; width: 100%; }
}

/* ---------- motion preferences ---------- */

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