/* ------------------------------------------------------------------
   Design tokens (validated data-viz palette — see palette.md)
   Dark theme only, by design — this site doesn't offer a light mode.
   ------------------------------------------------------------------ */
:root {
  color-scheme: dark;
  --surface-1:      #17181a;
  --surface-2:      #1e1f22;
  --page-plane:     #08090a;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;
  --gridline:       #2c2c2a;
  --baseline:       #383835;
  --border:         rgba(255,255,255,0.10);
  --success:        #0ca30c;
  --critical:       #e66767;

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-card: 0 1px 2px rgba(0,0,0,0.24), 0 1px 12px rgba(0,0,0,0.28);
}

/* ------------------------------------------------------------------
   Reset & base
   ------------------------------------------------------------------ */
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--page-plane);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; }
button { font-family: inherit; }
a { color: inherit; }

.tabular { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------
   Shell layout
   ------------------------------------------------------------------ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 20px;
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--series-1), var(--series-3));
  flex-shrink: 0;
}
.brand-name { font-weight: 700; font-size: 15.5px; letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: var(--text-muted); margin-top: -2px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.nav-link:hover { background: var(--border); color: var(--text-primary); }
.nav-link.active { background: var(--series-1); color: #fff; }
.nav-link .ic { width: 18px; text-align: center; font-size: 15px; }

/* A thin rule between nav groups (core pages / Watchlist+News / Import) —
   keeps the sidebar feeling organized instead of one flat list. The one
   right before Import also carries all the sidebar's free vertical space
   (margin-top: auto), which is what actually pins Import to the very
   bottom, just above the footer — Import itself stays in normal flow. */
.nav-divider { height: 1px; background: var(--border); margin: 10px 8px; flex-shrink: 0; }
.nav-divider-push { margin-top: auto; }

.sidebar-footer {
  padding: 10px;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.main {
  flex: 1;
  min-width: 0;
  padding: 28px 36px 60px;
  max-width: 1180px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 22px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; margin: 0; }
.page-sub { color: var(--text-secondary); font-size: 13.5px; margin-top: 4px; }

.demo-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: color-mix(in srgb, var(--series-4) 14%, var(--surface-1));
  border: 1px solid color-mix(in srgb, var(--series-4) 35%, transparent);
  color: var(--text-primary);
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  margin-bottom: 22px;
}
.demo-banner b { font-weight: 700; }

/* ------------------------------------------------------------------
   Cards / grid
   ------------------------------------------------------------------ */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: 2fr 1fr; }
@media (max-width: 980px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(1, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 10px;
}
.card-title { font-size: 13.5px; font-weight: 700; margin: 0; }
.card-title-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }

/* Stat tile */
.stat-tile .stat-label {
  font-size: 12px; color: var(--text-secondary); font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}
.stat-tile .stat-value {
  font-size: 25px; font-weight: 700; margin-top: 6px; letter-spacing: -0.01em;
}
.stat-tile .stat-delta {
  font-size: 12.5px; margin-top: 5px; font-weight: 600;
  display: flex; align-items: center; gap: 4px;
}
.delta-up { color: var(--success); }
.delta-down { color: var(--critical); }
.delta-neutral { color: var(--text-muted); }

/* ------------------------------------------------------------------
   Hero card (dashboard) — big value + minimal trend chart
   ------------------------------------------------------------------ */
.hero-card { display: flex; flex-direction: column; }
.hero-top {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; flex-wrap: wrap; margin-bottom: 4px;
}
.hero-label {
  font-size: 12.5px; color: var(--text-secondary); font-weight: 600;
}
.hero-value-row { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.hero-value {
  font-size: 38px; font-weight: 700; letter-spacing: -0.02em; color: var(--text-primary);
}
.hero-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700;
}
.hero-badge.delta-up { background: color-mix(in srgb, var(--success) 16%, transparent); }
.hero-badge.delta-down { background: color-mix(in srgb, var(--critical) 16%, transparent); }
.hero-asof { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.live-status { font-size: 11.5px; color: var(--text-muted); min-height: 14px; }
.hero-chart { margin-top: 14px; }
.hero-growth-row {
  display: flex; gap: 20px; margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--border);
}
.hero-growth-item { display: flex; flex-direction: column; gap: 2px; }
.hero-growth-label { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.hero-growth-value { font-size: 14px; font-weight: 700; }

/* Donut allocation card */
.donut-card { display: flex; flex-direction: column; }
.donut-tabs { display: flex; gap: 4px; background: var(--page-plane); border-radius: 999px; padding: 3px; }
.donut-tabs .tab-btn {
  border: none; background: transparent; color: var(--text-secondary);
  font-size: 11.5px; font-weight: 600; padding: 5px 11px; border-radius: 999px; cursor: pointer;
}
.donut-tabs .tab-btn.active { background: var(--surface-2); color: var(--text-primary); box-shadow: var(--shadow-card); }
.donut-wrap { display: flex; justify-content: center; margin: 6px 0 4px; }

/* ------------------------------------------------------------------
   Tables
   ------------------------------------------------------------------ */
.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.data-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--gridline);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.data-table th:hover { color: var(--text-primary); }
.data-table th.sorted::after { content: " " attr(data-arrow); }
.data-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--gridline);
  color: var(--text-primary);
  white-space: nowrap;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tbody tr:hover { background: var(--border); }

.sym-cell { display: flex; align-items: center; gap: 9px; }
.sym-badge {
  width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.sym-name { font-size: 11.5px; color: var(--text-muted); font-weight: 400; }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.pill-buy { background: color-mix(in srgb, var(--series-3) 16%, transparent); color: var(--series-3); }
.pill-sell { background: color-mix(in srgb, var(--series-8) 16%, transparent); color: var(--series-8); }
.pill-dividend { background: color-mix(in srgb, var(--series-4) 20%, transparent); color: var(--series-4); }
.pill-deposit { background: color-mix(in srgb, var(--series-1) 16%, transparent); color: var(--series-1); }

.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-secondary); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

.controls-row {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px;
}
.input, .select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  font-size: 13px;
}
.input:focus, .select:focus { outline: 2px solid var(--series-1); outline-offset: -1px; }
.chip-group { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.chip.active { background: var(--series-1); border-color: var(--series-1); color: #fff; }

.table-toggle {
  font-size: 11.5px;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  cursor: pointer;
}
.table-toggle:hover { background: var(--border); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.tooltip-layer { position: relative; }
.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  box-shadow: var(--shadow-card);
  z-index: 5;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.08s;
}
.chart-tooltip .tt-title { font-weight: 700; margin-bottom: 3px; }
.chart-tooltip .tt-row { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); }
.chart-tooltip .tt-swatch { width: 8px; height: 8px; border-radius: 2px; }

.insight-list { display: flex; flex-direction: column; gap: 10px; }
.insight-item { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; }
.insight-ic { font-size: 15px; margin-top: 1px; }
.insight-item b { font-weight: 700; }
.insight-sub { color: var(--text-secondary); font-size: 12px; }

.empty-state {
  text-align: center; padding: 30px 10px; color: var(--text-muted); font-size: 13px;
}

/* mobile nav */
.mobile-topbar { display: none; }
@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    position: static; height: auto; width: 100%; flex-direction: row;
    overflow-x: auto; padding: 10px 12px; align-items: center;
  }
  .brand { padding: 0 10px 0 0; }
  .sidebar-footer { display: none; }
  .nav-divider { display: none; }
  .nav-link { flex-shrink: 0; }
  .main { padding: 20px 16px 50px; }
}

/* ------------------------------------------------------------------
   Buttons
   ------------------------------------------------------------------ */
.btn {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  cursor: pointer;
}
.btn:hover { background: var(--border); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-primary {
  background: var(--series-1);
  border-color: var(--series-1);
  color: #fff;
}
.btn-primary:hover { background: var(--series-1); filter: brightness(1.06); }

/* ------------------------------------------------------------------
   Auth screen
   ------------------------------------------------------------------ */
.auth-wrap {
  min-height: calc(100vh - 120px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card { width: 100%; max-width: 380px; padding: 32px 28px; }
.auth-brand-mark {
  width: 36px; height: 36px; border-radius: 10px; margin: 0 auto 14px;
  background: linear-gradient(135deg, var(--series-1), var(--series-3));
}
.auth-title { font-size: 19px; font-weight: 700; text-align: center; margin: 0 0 4px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-field { display: flex; flex-direction: column; gap: 5px; }
.auth-field-label { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.auth-field .input { width: 100%; }
.auth-error {
  font-size: 12.5px; color: var(--critical);
  background: color-mix(in srgb, var(--critical) 10%, transparent);
  border-radius: var(--radius-sm); padding: 8px 10px;
}
.auth-info, .auth-error.auth-info {
  color: var(--success);
  background: color-mix(in srgb, var(--success) 10%, transparent);
  font-size: 12.5px; border-radius: var(--radius-sm); padding: 8px 10px;
}
.auth-demo-link {
  display: block; width: 100%; text-align: center; margin-top: 16px;
  background: none; border: none; color: var(--text-muted);
  font-size: 12px; cursor: pointer; text-decoration: underline;
}
.auth-user-email { font-size: 11px; color: var(--text-secondary); word-break: break-all; }

/* Holdings-review inputs inside the CSV import tables need to be compact. */
.data-table td .input { padding: 4px 8px; font-size: 12.5px; }

.btn-lg { padding: 12px 22px; font-size: 14.5px; border-radius: 10px; }

/* ------------------------------------------------------------------
   Landing page (signed-out visitors)
   ------------------------------------------------------------------ */
.landing-wrap { max-width: 980px; margin: 0 auto; padding: 70px 24px 60px; }
.landing-hero { text-align: center; margin-bottom: 48px; }
.landing-mark {
  width: 56px; height: 56px; border-radius: 15px; margin: 0 auto 22px;
  background: linear-gradient(135deg, var(--series-1), var(--series-3));
}
.landing-title { font-size: 40px; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 16px; }
.landing-sub {
  font-size: 16.5px; color: var(--text-secondary); max-width: 620px;
  margin: 0 auto; line-height: 1.6;
}
.landing-cta-row { display: flex; justify-content: center; gap: 12px; margin-top: 30px; flex-wrap: wrap; }
.landing-note { font-size: 12px; color: var(--text-muted); margin-top: 14px; }

.landing-shot-wrap {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: var(--shadow-card); margin-bottom: 56px;
}
.landing-shot { display: block; width: 100%; height: auto; }

.landing-features {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 56px;
}
.feature-card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 20px 18px;
}
.feature-ic {
  width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--series-1); font-size: 16px; margin-bottom: 12px;
}
.feature-card h3 { font-size: 14px; font-weight: 700; margin: 0 0 6px; }
.feature-card p { font-size: 12.5px; color: var(--text-secondary); line-height: 1.55; margin: 0; }

.landing-footer {
  border-top: 1px solid var(--border); padding-top: 22px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.landing-footer-links { display: flex; gap: 18px; }
.landing-footer-links a { font-size: 12.5px; color: var(--text-secondary); text-decoration: none; }
.landing-footer-links a:hover { text-decoration: underline; }
.landing-footer-note { font-size: 11.5px; color: var(--text-muted); }

@media (max-width: 860px) {
  .landing-features { grid-template-columns: repeat(2, 1fr); }
  .landing-title { font-size: 30px; }
}

/* ------------------------------------------------------------------
   Legal pages (Privacy / Terms)
   ------------------------------------------------------------------ */
.legal-wrap { max-width: 760px; margin: 0 auto; padding: 50px 24px 70px; }
.legal-wrap h1 { font-size: 28px; font-weight: 800; margin: 0 0 6px; }
.legal-wrap .legal-updated { font-size: 12px; color: var(--text-muted); margin-bottom: 32px; }
.legal-wrap h2 { font-size: 16px; font-weight: 700; margin: 30px 0 10px; }
.legal-wrap p, .legal-wrap li { font-size: 13.5px; color: var(--text-secondary); line-height: 1.7; }
.legal-wrap ul { padding-left: 20px; margin: 8px 0; }
.legal-wrap a { color: var(--series-1); }
.legal-back { display: inline-block; margin-bottom: 24px; font-size: 12.5px; color: var(--text-secondary); text-decoration: none; }
.legal-back:hover { text-decoration: underline; }

/* ------------------------------------------------------------------
   Manual transaction form (Import page)
   ------------------------------------------------------------------ */
.manual-tx-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-top: 6px;
}
@media (max-width: 720px) {
  .manual-tx-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ------------------------------------------------------------------
   Watchlist
   ------------------------------------------------------------------ */
.watchlist-add-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.watchlist-add-row .auth-field { min-width: 140px; }
.watch-badge {
  font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  background: var(--border); color: var(--text-secondary);
}
.watch-badge.hit { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.watch-remove { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 15px; padding: 2px 6px; }
.watch-remove:hover { color: var(--critical); }

/* ------------------------------------------------------------------
   News
   ------------------------------------------------------------------ */
.news-list { display: flex; flex-direction: column; }
.news-item {
  display: flex; gap: 12px; padding: 14px 4px; text-decoration: none; color: inherit;
  border-top: 1px solid var(--border);
}
.news-list .news-item:first-child { border-top: none; }
.news-item:hover .news-item-headline { color: var(--series-1); }
.news-item-badge { flex-shrink: 0; margin-top: 2px; }
.news-item-body { min-width: 0; }
.news-item-meta { font-size: 11px; color: var(--text-muted); font-weight: 700; margin-bottom: 4px; }
.news-item-symbol { color: var(--text-secondary); }
.news-item-headline { font-size: 14px; font-weight: 600; line-height: 1.4; margin-bottom: 4px; }
.news-item-summary {
  font-size: 12.5px; color: var(--text-secondary); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
