/* ---------------------------------------------------------------------------
   Ink Navy & Copper — a calm private-wealth palette. Tokens drive everything so
   both light and dark themes come from one source. Old token names (--text,
   --accent, --up, --down) are aliased to the new ones so existing components
   keep working.
   --------------------------------------------------------------------------- */
:root {
  /* Neutrals & brand — light */
  --bg: #eceef1;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #d8dde4;
  --ink: #16202b;
  --muted: #566373;
  --faint: #8792a0;
  --brand: #1f3a5f;      /* ink navy */
  --copper: #b06a3c;     /* warm accent */
  --gain: #1f8a6b;       /* semantic up (teal-green) */
  --loss: #cf5a4e;       /* semantic down (coral) */
  --btn-bg: #1f3a5f;
  --btn-fg: #ffffff;

  /* Asset-class hues (allocation bar, category dots) — light */
  --c-equity: #2f5f8c; --c-mf: #3a86a8; --c-us: #6a7fb0; --c-fixed: #b06a3c;
  --c-gold: #c79a52; --c-bank: #7a8794; --c-realty: #9c6a54; --c-alt: #8a6ea8;
  --c-forex: #4a9d9d; --c-crypto: #e0913a; --c-other: #8792a0;

  /* Aliases for legacy component CSS */
  --text: var(--ink);
  --accent: var(--brand);
  --up: var(--gain);
  --down: var(--loss);

  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --shadow: 0 1px 2px rgba(20, 28, 40, .05), 0 8px 24px rgba(20, 28, 40, .07);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1219; --surface: #141c26; --surface-2: #1a232f; --border: #26313f;
    --ink: #e8edf3; --muted: #93a1b2; --faint: #6b7889;
    --brand: #5b8fc9; --copper: #d0895a; --gain: #3fb890; --loss: #e07b6a;
    --btn-bg: #2f5f8c; --btn-fg: #ffffff;
    --c-equity: #5b8fc9; --c-mf: #5aa6c6; --c-us: #8a9dcb; --c-fixed: #d0895a;
    --c-gold: #dcb166; --c-bank: #93a1b2; --c-realty: #c08a6f; --c-alt: #b096cf;
    --c-forex: #5fb5b5; --c-crypto: #e8a556; --c-other: #93a1b2;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .38);
  }
}
/* Explicit toggle wins over the OS preference, in both directions. */
:root[data-theme="light"] {
  --bg: #eceef1; --surface: #ffffff; --surface-2: #f1f3f6; --border: #d8dde4;
  --ink: #16202b; --muted: #566373; --faint: #8792a0;
  --brand: #1f3a5f; --copper: #b06a3c; --gain: #1f8a6b; --loss: #cf5a4e;
  --btn-bg: #1f3a5f; --btn-fg: #ffffff;
  --c-equity: #2f5f8c; --c-mf: #3a86a8; --c-us: #6a7fb0; --c-fixed: #b06a3c;
  --c-gold: #c79a52; --c-bank: #7a8794; --c-realty: #9c6a54; --c-alt: #8a6ea8;
  --c-forex: #4a9d9d; --c-crypto: #e0913a; --c-other: #8792a0;
  --shadow: 0 1px 2px rgba(20, 28, 40, .05), 0 8px 24px rgba(20, 28, 40, .07);
}
:root[data-theme="dark"] {
  --bg: #0c1219; --surface: #141c26; --surface-2: #1a232f; --border: #26313f;
  --ink: #e8edf3; --muted: #93a1b2; --faint: #6b7889;
  --brand: #5b8fc9; --copper: #d0895a; --gain: #3fb890; --loss: #e07b6a;
  --btn-bg: #2f5f8c; --btn-fg: #ffffff;
  --c-equity: #5b8fc9; --c-mf: #5aa6c6; --c-us: #8a9dcb; --c-fixed: #d0895a;
  --c-gold: #dcb166; --c-bank: #93a1b2; --c-realty: #c08a6f; --c-alt: #b096cf;
  --c-other: #93a1b2;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .38);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 9px;
}
.brand .mark {
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--brand); color: #fff;
  font-family: -apple-system, sans-serif; font-size: 0.72rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.topbar nav { display: flex; gap: 20px; align-items: center; }
/* Theme toggle */
.theme-toggle {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
  border-radius: 999px; width: 32px; height: 32px; cursor: pointer; font-size: 0.95rem;
  line-height: 1; padding: 0;
}
.theme-toggle:hover { color: var(--text); }
.topbar nav a { color: var(--muted); text-decoration: none; }
.topbar nav a:hover { color: var(--text); }
/* The upload link is a .btn — keep its label white over the accent fill
   (this selector must out-specify `.topbar nav a` above). */
.topbar nav a.btn, .topbar nav a.btn:hover { color: #fff; }
.topbar .user-email { color: var(--muted); font-size: 0.85rem; }
.link-muted {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font: inherit; padding: 0;
}
.link-muted:hover { color: var(--text); text-decoration: underline; }

.auth-title { margin: 0 0 6px; font-family: var(--serif); font-weight: 600; font-size: 1.6rem; letter-spacing: -0.01em; }
.auth-sub { margin: 0 0 18px; font-size: 0.9rem; }
.card.narrow .auth-sub:last-child { margin: 16px 0 0; }

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 28px;
}
main.wide { max-width: 1120px; }

.btn {
  display: inline-block;
  background: var(--btn-bg);
  color: var(--btn-fg);
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.08); }
.btn-lg { padding: 12px 22px; font-size: 1rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 22px;
}
.card.narrow { max-width: 460px; margin: 40px auto; }
.card h2 { margin: 0 0 16px; font-size: 1rem; color: var(--muted); font-weight: 600; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; }
.card-head .link-danger { font-size: 0.85rem; }

.summary { margin-bottom: 22px; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-label { color: var(--muted); font-size: 0.85rem; }
.stat-value { font-family: var(--serif); font-size: 2.4rem; font-weight: 600; letter-spacing: -0.02em; }
.stat-change { font-size: 0.9rem; font-weight: 600; }
.stat-change.up { color: var(--up); }
.stat-change.down { color: var(--down); }

table.snapshots { width: 100%; border-collapse: collapse; }
table.snapshots th, table.snapshots td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}
table.snapshots th { color: var(--muted); font-weight: 600; }
table.snapshots .num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

.link-danger {
  background: none; border: none; color: var(--down);
  cursor: pointer; font: inherit; padding: 0;
}
.link-danger:hover { text-decoration: underline; }
form { display: inline; }

.card.narrow form { display: flex; flex-direction: column; gap: 16px; }
.card.narrow label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; color: var(--muted); }
.card.narrow input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font: inherit;
}

.alert {
  background: rgba(229, 72, 77, 0.1);
  border: 1px solid var(--down);
  color: #b42318;
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.upload-progress { margin-top: 18px; }
.up-bar {
  height: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.up-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.15s ease;
}
.up-status { margin: 8px 0 0; font-size: 0.85rem; color: var(--muted); }
/* Parsing phase: upload is done (bar full), server is working — pulse it. */
.upload-progress.parsing .up-fill { animation: up-pulse 1s ease-in-out infinite; }
@keyframes up-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.results { margin-top: 24px; border-top: 1px solid var(--border); padding-top: 20px; }
.results h2 { font-size: 1rem; color: var(--muted); font-weight: 600; margin: 0 0 12px; }
.result-list { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.result-list li {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.9rem;
}
.result-list li.ok { border-left: 3px solid var(--up); }
.result-list li.fail { border-left: 3px solid var(--down); }
.result-list .r-icon { font-weight: 700; line-height: 1.5; }
.result-list li.ok .r-icon { color: var(--up); }
.result-list li.fail .r-icon { color: var(--down); }
.result-list .r-body { display: flex; flex-direction: column; gap: 2px; }
.result-list .r-file { font-weight: 600; word-break: break-all; }
.result-list .r-msg { color: var(--muted); }

.empty { text-align: center; padding: 80px 20px; }
.empty h1 { font-family: var(--serif); font-weight: 600; font-size: 1.7rem; letter-spacing: -0.01em; }
.empty p { color: var(--muted); margin-bottom: 24px; }

/* Chart */
#chart { width: 100%; }
.chart-wrap { position: relative; }
.c-line { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.c-area { fill: rgba(79, 140, 255, 0.12); stroke: none; }
.c-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 1.5; }
.c-xlabel { fill: var(--muted); font-size: 11px; text-anchor: middle; }
.c-ylabel { fill: var(--muted); font-size: 11px; text-anchor: end; }
.c-guide { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.c-focus { fill: var(--accent); stroke: #fff; stroke-width: 2; }
.c-hit { cursor: crosshair; }

/* Hover tooltip — dark card with light text for high readability against the
   light chart. Positioned above the focused point; centered via transform. */
.c-tip {
  position: absolute;
  transform: translate(-50%, calc(-100% - 12px));
  background: #1a1d24;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.82rem;
  line-height: 1.35;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(15, 17, 21, 0.18);
  display: flex;
  flex-direction: column;
  z-index: 5;
}
.c-tip-date { color: #9aa1ad; font-size: 0.72rem; }
.c-tip-val { color: #ffffff; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Portfolio view */
.pf-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

/* Asset-class palette — one hue per class, reused by dots, bar segments and
   badges via the ac-<class> modifier. */
.ac-direct_equity { --ac: #2f6bff; }
.ac-mutual_fund   { --ac: #12a150; }
.ac-etf           { --ac: #0ea5b7; }
.ac-debt          { --ac: #f59e0b; }
.ac-govt_security { --ac: #8b6f47; }
.ac-gold          { --ac: #d4a017; }
.ac-silver        { --ac: #9ca3af; }
.ac-nps           { --ac: #7c3aed; }
.ac-ppf           { --ac: #6366f1; }
.ac-epf           { --ac: #4f46e5; }
.ac-private_equity{ --ac: #db2777; }
.ac-real_estate   { --ac: #b45309; }
.ac-cash          { --ac: #64748b; }
.ac-other         { --ac: #9aa1ad; }
[class*="ac-"]:not([style*="--ac"]) { --ac: #9aa1ad; }

.dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--ac, #9aa1ad);
  margin-right: 8px;
  vertical-align: middle;
  flex: none;
}

.alloc-bar {
  display: flex;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-2);
  margin-bottom: 16px;
}
.alloc-seg { background: var(--ac, #9aa1ad); min-width: 2px; }
.alloc-legend {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 20px;
}
.alloc-legend li { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.alloc-name { flex: 1; }
.alloc-val { font-variant-numeric: tabular-nums; font-weight: 600; }
.alloc-pct { font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }

/* Live-price indicators (Networth leaves) */
.stat-sub { font-size: 0.9rem; font-weight: 600; }
.stat-sub.up { color: var(--up); }
.stat-sub.down { color: var(--down); }
.chg { font-weight: 600; font-variant-numeric: tabular-nums; }
.chg.up { color: var(--up); }
.chg.down { color: var(--down); }
.chg.flat { color: var(--muted); }
.live-note { font-size: 0.78rem; margin: 12px 0 0; }

/* Manual holdings entry (Networth fixed-income / others leaves) */
.manual-section { margin-top: 8px; }
.manual-section.manual-sep { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--border); }
.manual-head { margin: 0 0 12px; font-size: 0.95rem; font-weight: 600; }
.manual-head .muted { font-weight: 400; }
.manual-table { margin-bottom: 16px; }
.manual-add {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}
@media (min-width: 620px) {
  .manual-add { grid-template-columns: repeat(4, 1fr); }
}
.manual-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.manual-field.col-2 { grid-column: span 2; }
.manual-field label {
  font-size: 0.75rem; font-weight: 600; color: var(--muted);
}
.manual-field label .opt { font-weight: 400; opacity: 0.65; }
.manual-field input,
.manual-field select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--text);
  font: inherit;
  height: 38px;
  /* Sit the control at the bottom of its cell so a label that wraps to two lines
     can't push its input out of line with the rest of the row. */
  margin-top: auto;
}
.manual-field input:focus,
.manual-field select:focus { outline: none; border-color: var(--accent); }
.manual-field input::placeholder { color: var(--muted); }
.manual-actions {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  border-top: 1px solid var(--border); padding-top: 14px;
}
.manual-hint { font-size: 0.8rem; }
.manual-actions .btn { margin-left: auto; }
.matures-in { display: block; font-size: 0.74rem; margin-top: 1px; }

.card.cta { text-align: center; padding: 32px 24px; }
.card.cta h2 { color: var(--text); font-size: 1.15rem; margin-bottom: 10px; }
.card.cta p { margin: 0 auto 8px; max-width: 520px; }
.card.cta .btn { margin-top: 14px; }

/* Button loading state (Refresh) */
.btn.is-loading { opacity: 0.8; cursor: progress; }
.btn.is-loading::before {
  content: "";
  display: inline-block;
  width: 12px; height: 12px;
  margin-right: 8px;
  vertical-align: -1px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

.acct-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.acct-badge {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.03em; padding: 2px 8px; border-radius: 6px;
  color: #fff; margin-right: 8px;
}
.kind-demat { background: #2f6bff; }
.kind-mutual_fund { background: #12a150; }
.kind-nps { background: #7c3aed; }
.acct-name { font-weight: 600; }
.acct-total { font-weight: 700; font-variant-numeric: tabular-nums; }

table.holdings { width: 100%; border-collapse: collapse; }
table.holdings th, table.holdings td {
  padding: 9px 8px; text-align: left;
  border-bottom: 1px solid var(--border); font-size: 0.9rem;
}
table.holdings th { color: var(--muted); font-weight: 600; }
table.holdings .num { text-align: right; font-variant-numeric: tabular-nums; }
table.holdings tbody tr:last-child td { border-bottom: none; }
.h-name { font-weight: 500; }
.h-isin { display: inline-block; margin-left: 8px; font-size: 0.78rem; font-variant-numeric: tabular-nums; }

/* --- "Where do you stand?" ------------------------------------------------ */
.stand-intro h1 { margin: 0 0 8px; font-family: var(--serif); font-weight: 600; font-size: 1.7rem; letter-spacing: -0.02em; }
.stand-intro > .muted { margin: 0; max-width: 640px; font-size: 0.92rem; }

.nw-control { margin-top: 20px; display: flex; flex-direction: column; gap: 16px; }
.nw-amount {
  display: flex; align-items: center; gap: 4px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 4px 6px 4px 14px; max-width: 340px;
}
.nw-currency { font-size: 1.3rem; font-weight: 600; color: var(--muted); }
#nw-input {
  flex: 1; min-width: 0; background: none; border: none;
  font: inherit; font-size: 1.5rem; font-weight: 700; padding: 6px 8px;
  color: var(--text); font-variant-numeric: tabular-nums;
}
#nw-input:focus { outline: none; }
#nw-unit {
  border: none; background: var(--surface); border-radius: 8px;
  padding: 8px 10px; font: inherit; font-weight: 600; color: var(--text); cursor: pointer;
}
#nw-slider { width: 100%; max-width: 520px; accent-color: var(--accent); }
.nw-presets { display: flex; flex-wrap: wrap; gap: 8px; }
.nw-presets button {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 0.85rem;
  font-weight: 600; color: var(--text); cursor: pointer;
}
.nw-presets button:hover { border-color: var(--accent); color: var(--accent); }
.nw-presets .preset-mine { background: var(--accent); color: #fff; border-color: var(--accent); }
.nw-presets .preset-mine:hover { color: #fff; filter: brightness(1.08); }

.stand-lead { font-size: 1.15rem; margin: 0 0 18px; }
.stand-lead strong { color: var(--accent); }

.country-rows { display: flex; flex-direction: column; gap: 2px; }
.crow {
  display: grid; grid-template-columns: 148px 1fr 190px;
  align-items: center; gap: 14px; width: 100%;
}
.crow-btn {
  background: none; border: 1px solid transparent; border-radius: 10px;
  padding: 10px 8px; font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.crow-btn:hover { background: var(--surface-2); }
.crow-btn.selected { border-color: var(--border); background: var(--surface-2); }

.crow-geo { display: flex; align-items: center; gap: 8px; min-width: 0; }
.crank { font-size: 0.72rem; font-weight: 700; color: var(--muted); width: 22px; flex: none; }
.crow.is-top .crank { color: var(--accent); }
.flag { font-size: 1.15rem; flex: none; }
.cname { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crow.is-top .cname::after { content: " \1F451"; }

.crow-track {
  position: relative; height: 24px;
  background: var(--surface-2); border-radius: 999px;
}
.track-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  background: linear-gradient(to right, #cfe0ff, var(--accent));
  border-radius: 999px; transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}
.track-marker {
  position: absolute; top: 50%; left: 0; width: 14px; height: 14px;
  margin-left: -7px; transform: translateY(-50%);
  background: #fff; border: 3px solid var(--accent); border-radius: 50%;
  box-shadow: 0 1px 3px rgba(15, 17, 21, 0.25);
  transition: left 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.crow-stat { text-align: right; display: flex; flex-direction: column; gap: 1px; }
.top-pct { font-weight: 700; font-size: 1.02rem; font-variant-numeric: tabular-nums; }
.crow.is-top .top-pct { color: var(--accent); }
.above { font-size: 0.82rem; font-weight: 600; color: var(--text); }
.one-in { font-size: 0.76rem; }

/* Shared log-percentile scale header, aligned to the track column. */
.scale-row { align-items: end; margin-bottom: 4px; padding: 0 8px; }
.scale-ticks { position: relative; height: 20px; background: none; }
.scale-ticks .tick {
  position: absolute; bottom: 0; transform: translateX(-50%);
  font-size: 0.68rem; color: var(--muted); text-align: center; white-space: nowrap;
}
.scale-ticks .tick i { display: block; width: 1px; height: 6px; background: var(--border); margin: 0 auto 2px; }
.scale-cap {
  font-size: 0.68rem; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.05em; align-self: end;
}
.scale-cap.right { text-align: right; }

.fun-fact {
  margin: 18px 0 0; padding: 12px 14px;
  background: rgba(47, 107, 255, 0.08); border: 1px solid rgba(47, 107, 255, 0.25);
  border-radius: 10px; font-size: 0.95rem;
}
.fun-fact strong { color: var(--accent); }
.stand-note { margin: 12px 0 0; font-size: 0.8rem; }

/* Wealth pyramid */
.pyramid-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.ptab {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 0.8rem;
  font-weight: 600; color: var(--muted); cursor: pointer;
}
.ptab:hover { color: var(--text); }
.ptab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.pyramid { display: flex; flex-direction: column; gap: 6px; }
.pyr-row { display: grid; grid-template-columns: 1fr 200px; align-items: center; gap: 16px; }
.pyr-bar {
  justify-self: center; box-sizing: border-box; min-height: 36px;
  display: flex; flex-direction: column; justify-content: center;
  padding: 5px 14px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-left: 4px solid color-mix(in srgb, var(--accent) calc(var(--shade, 0.3) * 100%), #cbd8f2);
  transition: width 0.4s ease;
}
.pyr-band { font-weight: 600; font-size: 0.9rem; }
.pyr-usd { font-size: 0.72rem; color: var(--muted); }
.pyr-user .pyr-bar {
  background: var(--accent); border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(47, 107, 255, 0.35);
}
.pyr-user .pyr-band { color: #fff; }
.pyr-user .pyr-usd { color: rgba(255, 255, 255, 0.85); }
.pyr-meta { display: flex; flex-direction: column; font-size: 0.82rem; }
.pyr-count { font-weight: 600; font-variant-numeric: tabular-nums; }
.pyr-share { font-size: 0.75rem; }
.pyr-you { color: var(--accent); font-weight: 700; font-size: 0.78rem; }
.pyr-split { font-size: 0.75rem; margin-top: 1px; font-variant-numeric: tabular-nums; }
.pyramid-note { margin: 16px 0 0; font-size: 0.8rem; }

@media (max-width: 640px) {
  .crow { grid-template-columns: 1fr; gap: 6px; }
  .crow-stat { text-align: left; flex-flow: row wrap; gap: 4px 12px; align-items: baseline; }
  .scale-row { display: none; }
  .pyr-row { grid-template-columns: 1fr; gap: 4px; }
  .pyr-bar { justify-self: start; }
  .pyr-meta { flex-direction: row; gap: 12px; padding-left: 2px; }
}

/* --- Net worth breakdown --------------------------------------------------- */
.nw-page-head { margin-bottom: 22px; }
.nw-page-head h1 { margin: 0 0 6px; font-family: var(--serif); font-weight: 600; font-size: 1.7rem; letter-spacing: -0.02em; }
.nw-page-head > .muted { margin: 0; max-width: 640px; font-size: 0.92rem; }

.nw-section .card-head { margin-bottom: 6px; }
.nw-subsection { margin-top: 18px; }
.nw-subsection:first-of-type { margin-top: 10px; }
.nw-subhead { margin: 0 0 10px; font-size: 0.95rem; font-weight: 600; }
.nw-subhead a { color: var(--text); text-decoration: none; }
.nw-subhead a:hover { color: var(--accent); }

.nw-leaf-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.nw-leaf {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); text-decoration: none; color: var(--text);
}
.nw-leaf:hover { border-color: var(--accent); }
.nw-leaf-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.nw-leaf-title { font-weight: 600; }
.nw-leaf-note { color: var(--muted); font-size: 0.82rem; }
.nw-leaf-arrow { color: var(--muted); flex: none; }

/* Category rows (nodes with children) read as "drill in", not a data leaf. */
.nw-leaf.nw-cat { border-left: 3px solid var(--accent); }
.nw-cat-count {
  flex: none; font-size: 0.72rem; font-weight: 600; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 2px 9px; white-space: nowrap;
}
.nw-cat .nw-leaf-arrow { color: var(--accent); font-size: 1.1rem; line-height: 1; }

/* Rolled-up value shown against a Networth head/leaf. */
.nw-val { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text); }
.nw-subhead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.nw-subhead .nw-val { font-size: 0.95rem; }
.nw-page-total { font-family: var(--serif); font-size: 2rem; font-weight: 600; letter-spacing: -0.02em; margin: 2px 0 6px; font-variant-numeric: tabular-nums; }
.nw-leaf:hover .nw-leaf-arrow { color: var(--accent); }
.nw-empty { margin: 6px 0 0; font-size: 0.88rem; }

.crumbs { font-size: 0.85rem; margin-bottom: 16px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumb-sep { margin: 0 8px; color: var(--border); }
.crumb-current { color: var(--text); font-weight: 600; }

.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }
.steps li { font-size: 0.92rem; line-height: 1.5; }
.steps a { color: var(--accent); text-decoration: none; }
.steps a:hover { text-decoration: underline; }
.nw-section + .card .card-head, .card .card-head .stat { align-items: flex-start; }

.nw-blank { text-align: center; padding: 48px 24px; }
.nw-blank-icon { font-size: 2rem; margin-bottom: 8px; }
.nw-blank h2 { margin: 0 0 6px; font-family: var(--serif); font-weight: 600; font-size: 1.2rem; color: var(--text); }
.nw-blank p { margin: 0 auto 16px; max-width: 420px; }

footer {
  text-align: center;
  padding: 24px;
  color: var(--muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--border);
}

/* ===========================================================================
   Dashboard (home) — hero net worth, allocation, tiles, live holdings
   =========================================================================== */
.dash { max-width: 1080px; }
.dash .num { font-variant-numeric: tabular-nums; }

.dash-hero { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 800px) { .dash-hero { grid-template-columns: 1fr; } }
.dash-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow);
}
.hero-main { padding: 30px 32px 26px; display: flex; flex-direction: column; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.7rem; font-weight: 700; color: var(--faint); }
.hero-nw { font-family: var(--serif); font-size: 3.9rem; line-height: 1; font-weight: 600; letter-spacing: -0.02em; margin: 12px 0 8px; }
@media (max-width: 800px) { .hero-nw { font-size: 2.9rem; } }
.hero-nw .rs { color: var(--faint); font-weight: 500; }
.hero-note { font-size: 0.85rem; color: var(--faint); }
.hero-split { display: flex; gap: 30px; margin-top: auto; padding-top: 24px; }
.hero-split .lab { font-size: 0.78rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.hero-split .swatch { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.hero-split .val { font-family: var(--serif); font-size: 1.45rem; margin-top: 3px; }
.hero-split .val.neg { color: var(--loss); }

.alloc-card { padding: 24px 26px; display: flex; flex-direction: column; }
.alloc-card h2 { margin: 0 0 16px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); font-weight: 700; }
.alloc-strip { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--surface-2); margin-bottom: 18px; }
.alloc-strip span { height: 100%; min-width: 2px; }
.alloc-legend { margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 9px 18px; }
.alloc-legend li { list-style: none; display: flex; align-items: center; gap: 9px; font-size: 0.85rem; }
.alloc-legend .swatch { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.alloc-legend .lname { color: var(--muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alloc-legend .lval { font-variant-numeric: tabular-nums; font-weight: 600; }

.dash-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 20px; }
@media (max-width: 800px) { .dash-tiles { grid-template-columns: 1fr 1fr; } }
.dash-tile { padding: 20px 22px; display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: var(--text); }
a.dash-tile:hover { border-color: var(--brand); }
.dash-tile .k { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.dash-tile .v { font-family: var(--serif); font-size: 1.7rem; letter-spacing: -0.01em; }
.dash-tile .v.neg { color: var(--loss); }
.dash-tile .sub { font-size: 0.78rem; color: var(--faint); margin-top: auto; }

/* Standing CTA tile */
.cta-tile {
  background: linear-gradient(150deg, var(--brand), color-mix(in srgb, var(--brand) 72%, #000));
  border: none; color: #fff; position: relative; overflow: hidden; gap: 6px;
}
.cta-tile h3 { margin: 0; font-family: var(--serif); font-size: 1.1rem; font-weight: 600; color: #fff; }
.cta-tile p { margin: 0; font-size: 0.79rem; color: rgba(255,255,255,0.82); line-height: 1.45; }
.cta-tile .go { margin-top: auto; font-size: 0.82rem; font-weight: 700; color: var(--copper); filter: brightness(1.3); display: inline-flex; align-items: center; gap: 6px; }
a.cta-tile:hover { filter: brightness(1.06); border: none; }
.cta-pyr { position: absolute; right: -6px; top: 18px; opacity: 0.26; }
.cta-pyr i { display: block; height: 5px; margin: 2px 0 2px auto; background: #fff; border-radius: 1px; }

/* Live holdings list */
.dash-holdings { padding: 6px 6px 10px; }
.dash-holdings .bh { display: flex; align-items: baseline; justify-content: space-between; padding: 14px 20px 6px; }
.dash-holdings .bh h2 { margin: 0; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); font-weight: 700; }
.dash-holdings .bh .hint { font-size: 0.78rem; color: var(--faint); }
.hrow { display: flex; align-items: center; gap: 14px; padding: 13px 20px; border-top: 1px solid var(--border); text-decoration: none; color: var(--text); }
.hrow:hover { background: var(--surface-2); }
.hrow .swatch { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.hrow .name { font-weight: 600; font-size: 0.95rem; }
.hrow .meta { color: var(--faint); font-size: 0.8rem; }
.hrow .amt { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }
.hrow .chev { color: var(--faint); }

.nw-overview-summary { margin-bottom: 22px; }

/* Expenses page */
.exp-hero { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 800px) { .exp-hero { grid-template-columns: 1fr; } }
.exp-burn { padding: 28px 30px; display: flex; flex-direction: column; }
.exp-fire { padding: 24px 28px; display: flex; gap: 30px; flex-wrap: wrap; }
.exp-stat { display: flex; flex-direction: column; gap: 4px; min-width: 160px; flex: 1; }
.exp-figure { font-family: var(--serif); font-size: 1.9rem; font-weight: 600; letter-spacing: -0.01em; margin-top: 4px; }
.exp-figure .exp-unit { font-size: 1rem; color: var(--faint); }
.fire-bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 8px 0 4px; }
.fire-bar span { display: block; height: 100%; background: var(--gain); border-radius: 999px; }
.exp-lead { max-width: 720px; font-size: 0.9rem; margin: 0 0 18px; }

/* Per-category expense sections */
.exp-cat { padding: 16px 20px 18px; margin-bottom: 14px; }
.exp-cat-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.exp-cat-head h3 { margin: 0; font-size: 1rem; font-weight: 600; }
.exp-cat-head .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.exp-cat-total { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.exp-cat-total .per { color: var(--faint); font-weight: 400; font-size: 0.82rem; }
.exp-cat-table { width: 100%; margin-bottom: 12px; }
.exp-cat-table td { padding: 8px 8px; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.exp-cat-table tr:last-child td { border-bottom: none; }
.exp-cat-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Compact inline add row per category */
.exp-add-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.exp-add-row input, .exp-add-row select {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; color: var(--text); font: inherit; height: 38px;
}
.exp-add-row input::placeholder { color: var(--faint); }
.exp-add-row .exp-name { flex: 1; min-width: 180px; }
.exp-add-row .exp-amt { width: 120px; }
.exp-add-row .exp-freq { width: 130px; }
.exp-add-row .exp-count { width: 70px; }
.exp-add-row .btn { height: 38px; }

.dash-empty { text-align: center; padding: 60px 24px; }
.dash-empty h1 { font-family: var(--serif); font-weight: 600; font-size: 1.6rem; margin: 0 0 8px; letter-spacing: -0.01em; }
.dash-empty p { color: var(--muted); margin: 0 auto 22px; max-width: 480px; }
/* Italic serif lead line — a little editorial flourish. */
.dash-empty p.dash-empty-lead {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.2rem;
  color: var(--text);
  margin-bottom: 10px;
}
/* Higher specificity than `.dash-empty p` so the top margin isn't overridden;
   wider + balanced so the secondary line doesn't leave a short orphan. */
.dash-empty p.dash-empty-alt {
  font-size: 0.9rem;
  margin-top: 26px;
  max-width: 600px;
  text-wrap: balance;
}
.dash-empty-alt a { color: var(--accent); text-decoration: none; }
.dash-empty-alt a:hover { text-decoration: underline; }
