/* ============================================================
   CERES — Portfolio dashboard
   Design system: dual theme (dark default), sunset-salmon accent
   Type: Sora (display) · IBM Plex Sans (body) · IBM Plex Mono (numbers)
   ============================================================ */

:root {
  --accent: #e08d86;
  --accent-strong: #d47a72;
  --accent-soft: rgba(224, 141, 134, 0.14);
  --accent-glow: rgba(224, 141, 134, 0.35);
  --font-display: "Sora", sans-serif;
  --font-body: "IBM Plex Sans", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-width: 248px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0d10;
  --bg-elev: #101318;
  --card: #14171d;
  --card-hover: #191d24;
  --border: #232831;
  --border-strong: #2f3540;
  --text: #eef1f4;
  --muted: #8b93a1;
  --positive: #35d07f;
  --negative: #ff5d6c;
  --chart-bg: #101318;
  --chart-grid: rgba(238, 241, 244, 0.45);
  --input-bg: #0e1116;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f4f6;
  --bg-elev: #ffffff;
  --card: #ffffff;
  --card-hover: #faf7f6;
  --border: #e5e7eb;
  --border-strong: #d3d6db;
  --text: #171a1f;
  --muted: #6b7280;
  --positive: #0c9d5e;
  --negative: #dc3d4c;
  --chart-bg: #ffffff;
  --chart-grid: rgba(23, 26, 31, 0.35);
  --input-bg: #f6f7f8;
  --shadow: 0 6px 22px rgba(23, 26, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
}

h1, h2, h3 {
  font-family: var(--font-display);
  margin: 0;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input, select, textarea {
  font-family: inherit;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent-glow);
  border-color: var(--accent);
}

.positive { color: var(--positive); }
.negative { color: var(--negative); }
.subtle { color: var(--muted); }
small { color: var(--muted); }

a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============ Shell layout ============ */

.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
  gap: 14px;
  z-index: 40;
  overflow: hidden; /* rigid, non-scrolling side menu */
  transition: transform 0.28s ease;
}

body.sidebar-collapsed .sidebar {
  transform: translateX(calc(-1 * var(--sidebar-width)));
}

.main-column {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-width: 0;
  transition: margin-left 0.28s ease;
  display: flex;
  flex-direction: column;
}

body.sidebar-collapsed .main-column {
  margin-left: 0;
}

.sidebar-logo {
  /* Mirrors the topbar's height (12px pad + 36px controls + 12px pad + 1px
     border = 61px) so the divider under the logo aligns with the line under
     the page title, and the wordmark sits on that row's midline. */
  margin-top: -12px;
  height: 61px;
  display: grid;
  place-items: center;
  padding: 0 2px;
  border-bottom: 1px solid var(--border);
}

/* logo.png is pre-cropped to the wordmark (627x181) — no scale/clip tricks. */
.brand-logo-img, .brand-logo { width: 128px; height: auto; display: block; }

/* Create/Manage row pinned at the top, fenced by thin lines like the logo. */
.nav-manage-row {
  padding: 2px 0 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.nav-portfolio-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.active-portfolio {
  display: block; /* sits on its own line under "My Portfolio" */
  margin-top: 2px;
  text-transform: none;
  letter-spacing: normal;
  font-style: italic;
  font-weight: 600;
  color: var(--accent-strong);
}
.active-portfolio:empty { display: none; }

.portfolio-dropdown-toggle {
  border: none;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  margin-right: 6px;
  transition: transform 0.2s ease, color 0.15s ease;
}
.portfolio-dropdown-toggle svg { width: 15px; height: 15px; }
.portfolio-dropdown-toggle:hover { color: var(--accent); }
.portfolio-dropdown-toggle[aria-expanded="true"] { transform: rotate(180deg); color: var(--accent); }

.portfolio-dropdown { display: flex; flex-direction: column; gap: 2px; margin: 2px 8px 4px; }
.portfolio-dropdown[hidden] { display: none; }
.portfolio-dropdown button {
  text-align: left;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-style: italic;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.portfolio-dropdown button:hover { background: var(--accent-soft); color: var(--accent-strong); }
.portfolio-dropdown button.active { color: var(--accent); }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  overflow: hidden; /* no scrollbar — menu is hard-fixed */
}

.nav-section-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin: 14px 8px 6px;
}

.sidebar-nav .tab {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-nav .tab svg {
  width: 17px;
  height: 17px;
  flex: none;
}

.sidebar-nav .tab:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.sidebar-nav .tab.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 8px 2px;
  border-top: 1px solid var(--border);
  font-weight: 600;
  text-transform: capitalize;
}

.sidebar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
}

/* ============ Top bar ============ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar h1 {
  font-size: 19px;
  font-weight: 700;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.icon-button svg { width: 18px; height: 18px; }

.icon-button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.status-chip {
  font-size: 11.5px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}

.status-chip:empty { display: none; }
.status-chip[data-status="open"] { color: var(--positive); border-color: var(--positive); }
.status-chip[data-status="live"] { color: var(--positive); border-color: var(--positive); }

/* Plain dynamic price-freshness text (no chip border). */
.price-status { font-size: 11.5px; font-family: var(--font-mono); color: var(--muted); white-space: nowrap; }
.price-status[data-status="live"] { color: var(--positive); }

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.segment {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 7px 13px;
  font-size: 12.5px;
  font-weight: 600;
}

.segment.active {
  background: var(--accent);
  color: #111;
}

.fx-control {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 600;
}

.fx-control input { width: 76px; padding: 6px 8px; font-family: var(--font-mono); }

#apiErrorBanner {
  margin: 12px 22px 0;
  padding: 10px 14px;
  color: var(--negative);
  border: 1px solid var(--negative);
  border-radius: var(--radius-sm);
  background: rgba(255, 93, 108, 0.08);
  font-size: 13px;
}

/* ============ Pages ============ */

.pages {
  padding: 20px 22px 40px;
  display: block;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: page-in 0.25s ease; }

@keyframes page-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-heading h2 { font-size: 15.5px; font-weight: 700; }

.eyebrow {
  margin: 0 0 2px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
}

.panel-subtitle { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }

/* ============ Dashboard ============ */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 44px 18px 20px; /* title pinned at top; body centers on the midline */
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 5px;
  min-height: 132px;
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), transparent 70%);
  opacity: 0.85;
}

.stat-label {
  position: absolute;
  top: 15px;
  left: 0;
  right: 0;
  font-size: 15px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  transform: translateY(-7px); /* sit slightly above the midline, nearer the title */
}

/* Pinned to the card bottom so it doesn't push the main value off the shared
   midline — all four $ amounts align across the row. */
.stat-card .stat-sub {
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  font-size: 12px;
  font-family: var(--font-mono);
}
.stat-sub .pnl-badge { margin-left: 6px; }

/* My Progress ring card */
/* Ring left of the midline, "of $target" to its right — one horizontal row. */
.progress-card { cursor: pointer; flex-direction: row; gap: 16px; padding-bottom: 20px; }
.progress-card .stat-sub,
.progress-card .progress-ring-wrap { transform: translateY(-7px); } /* match the neighbors' above-midline lift */
.progress-card .stat-sub {
  position: static; /* opt out of the pinned-bottom rule */
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap; /* one line — no ugly wrap */
}
.progress-card:hover { border-color: var(--accent); }
.progress-ring-wrap { position: relative; width: 92px; height: 92px; }
.progress-ring { width: 92px; height: 92px; transform: none; }
.progress-ring-track { fill: none; stroke: var(--border-strong); stroke-width: 9; }
.progress-ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 9;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease;
}
.progress-ring-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

/* Target editor dialog */
.target-progress { margin: 4px 0 2px; }
.target-progress-track {
  height: 10px;
  border-radius: 999px;
  background: var(--border-strong);
  overflow: hidden;
}
.target-progress-track span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-strong), var(--accent));
  transition: width 0.35s ease;
}
.target-progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 8px;
}
.target-progress-meta strong { font-family: var(--font-display); font-size: 18px; }
.target-progress-meta .subtle { font-family: var(--font-mono); font-size: 12px; }

.franklin-quote {
  margin: 16px 0 4px;
  padding: 12px 14px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
  color: var(--text);
  font-size: 14px;
}
.franklin-quote cite { display: block; margin-top: 6px; font-style: normal; font-size: 12px; color: var(--muted); }

.dash-main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(300px, 1fr);
  gap: 16px;
  margin-bottom: 18px;
  align-items: start;
  --dash-box-h: 384px; /* shared height: chart = best = worst = allocation = news */
}

.chart-panel { margin-bottom: 0; display: flex; flex-direction: column; height: var(--dash-box-h); }
.chart-canvas-wrap { position: relative; flex: 1; min-height: 0; }
.chart-panel canvas { width: 100%; height: 100%; border-radius: var(--radius-sm); }
/* ============ Earnings Calendar ============ */

.cal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 12px;
}
.cal-header strong { font-family: var(--font-display); font-size: 16px; min-width: 170px; text-align: center; }

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 6px;
}
.cal-weekdays span {
  text-align: center;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.cal-day {
  min-height: 86px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}
.cal-day.dim { background: transparent; border-style: dashed; opacity: 0.35; }
.cal-day.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-day-num { font-size: 11px; font-weight: 600; color: var(--muted); }

.cal-chip {
  border: none;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  cursor: pointer;
}
.cal-chip:hover { background: var(--accent); color: #111; }
.cal-more { font-size: 10px; color: var(--muted); }

.earnings-list-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.estimate-link {
  border: none;
  background: transparent;
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
  text-decoration: underline dotted;
  cursor: pointer;
  padding: 2px 4px;
}
.estimate-link:hover { color: var(--accent); }
.estimate-link.muted { color: var(--muted); }

.estimates-dialog { max-width: 760px; }
.estimates-table td, .estimates-table th { font-size: 12.5px; }

.dividend-log-scroll { max-height: 430px; overflow-y: auto; }
.dividend-log-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.chart-empty-note[hidden] { display: none; }
.chart-empty-note {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 0 24px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  pointer-events: none;
}

/* Snapshot readout under the title: balance + P/L on one line, date beneath. */
.chart-snapshot { margin-top: 6px; display: flex; flex-direction: column; gap: 1px; }
.chart-snapshot-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.chart-snapshot-balance {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.chart-snapshot-pnl { font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; }
.chart-snapshot-date { font-size: 11.5px; color: var(--muted); font-family: var(--font-mono); }

.range-tabs, .period-tabs {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
}

.range-tabs button, .period-tabs button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 11.5px;
  font-weight: 600;
}

.range-tabs button:hover, .period-tabs button:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.range-tabs button.active, .period-tabs button.active {
  background: var(--accent);
  color: #111;
}

.dash-left {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.dash-left .panel { margin-bottom: 0; }

/* Allocation + news sit in one row, each the shared box height. */
.dash-under-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 16px;
}

.dash-under-grid > .panel { height: var(--dash-box-h); display: flex; flex-direction: column; margin-bottom: 0; }
.dash-under-grid #insightsFeed { flex: 1; max-height: none; overflow-y: auto; min-height: 0; }
/* Keep the allocation box near the Worst Performers height — shrink the donut
   display (canvas stays 240 internally so it renders crisp). */
.dash-under-grid #allocationChart { width: 158px; height: 158px; }
/* Fill the panel below the heading and center donut + legend on its midline. */
.dash-under-grid .allocation-layout { gap: 20px; flex: 1; align-items: center; justify-content: center; }

.performer-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.performer-box { margin-bottom: 0; height: var(--dash-box-h); display: flex; flex-direction: column; }
.performer-box .period-tabs { margin-bottom: 10px; }

.performer-list { display: flex; flex-direction: column; gap: 8px; flex: 1; }

.performer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
}

.performer-row .performer-rank {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--accent);
  width: 18px;
}

.performer-row .performer-symbol { font-weight: 600; flex: 1; }
.performer-row .performer-value { font-family: var(--font-mono); font-size: 13px; font-weight: 600; }

.mini-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.mini-toggle button {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 600;
}

.mini-toggle button.active { background: var(--accent); color: #111; }

.ticker-tape-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 18px;
  background: var(--card);
}

/* Decorative tape: no hover interaction, so it never pauses. */
.ticker-tape-section tv-ticker-tape { pointer-events: none; }
/* Hide any symbol TradingView can't serve ("only available on TradingView"). */
tv-error-boundary[has-error] { display: none !important; }

.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 16px;
  margin-bottom: 2px;
}

.overview-grid .panel { margin-bottom: 16px; }

.allocation-layout {
  display: flex;
  align-items: center;
  justify-content: center; /* donut + legend centered within the box */
  gap: 26px;
  flex-wrap: wrap;
}

.allocation-list { display: flex; flex-direction: column; gap: 11px; flex: 0 0 auto; }

.allocation-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14.5px;
}

.allocation-row .dot, .allocation-row .swatch { width: 13px; height: 13px; border-radius: 4px; flex: none; }
.allocation-row > div { flex: none; width: 120px; } /* fixed so % sits close, not far right */
.allocation-row > div > strong { font-family: var(--font-display); font-size: 14.5px; }
.allocation-row .subtle { font-size: 12.5px; }
.allocation-row > strong:last-child { font-family: var(--font-mono); font-weight: 600; font-size: 14.5px; }

#insightsFeed { max-height: 320px; overflow-y: auto; }

/* ============ Tables (Holdings / Scenario) ============ */

.holdings-header h2 { font-size: 16px; margin-bottom: 6px; }

.holdings-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.holdings-toolbar-right { display: flex; gap: 9px; flex-wrap: wrap; }
.holdings-search { min-width: 230px; }

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: center; /* titles always centered over their column */
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  padding: 9px 10px;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

tbody td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  text-align: center; /* entries align centered under their title */
}

tbody tr:hover { background: var(--card-hover); }

.quantity-cell, .price-column, .current-value-cell, .pl-cell { font-family: var(--font-mono); }

.asset-cell-content { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 130px; }
.asset-name { font-size: 11.5px; color: var(--muted); }

.ticker-tag-clickable {
  border: none;
  background: transparent;
  color: var(--text);
  padding: 0;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
}

.ticker-tag-clickable:hover { outline: 2px solid var(--accent-glow); }
.ticker-fallback { display: none; font-weight: 700; }
tv-ticker-tag:not(:defined) + .ticker-fallback { display: inline; }

.asset-class-badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  border-radius: 999px;
  padding: 3px 10px;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  white-space: nowrap;
}

.asset-class-stocks { color: #7fb2ff; border-color: rgba(127, 178, 255, 0.4); }
.asset-class-etf { color: #8fd3ff; border-color: rgba(143, 211, 255, 0.4); }
.asset-class-crypto { color: #b3a4f5; border-color: rgba(179, 164, 245, 0.4); }
.asset-class-commodities { color: #6fd0d8; border-color: rgba(111, 208, 216, 0.4); }
.asset-class-cash { color: var(--positive); border-color: rgba(53, 208, 127, 0.4); }

html[data-theme="light"] .asset-class-stocks { color: #2563c4; }
html[data-theme="light"] .asset-class-etf { color: #1d7fb8; }
html[data-theme="light"] .asset-class-crypto { color: #6a53c9; }
html[data-theme="light"] .asset-class-commodities { color: #0f8a94; }

/* Centered stack: white price under the PRICE title, longer change-line
   centered beneath it so it fans out evenly to both sides. */
.price-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; white-space: nowrap; }
.price-cell .price-main { font-weight: 600; }

.session-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-family: var(--font-mono);
}

.session-arrow { font-size: 13px; line-height: 1; }

.after-hours { display: inline-flex; align-items: center; color: var(--muted); }
.after-hours svg { width: 13px; height: 13px; }

.moon-icon { width: 12px; height: 12px; vertical-align: -1px; }
.price-status .moon-icon { margin-right: 4px; }

.current-value-percent, .pl-percent { font-size: 11px; color: var(--muted); }
.pl-cell.positive .pl-percent { color: var(--positive); }
.pl-cell.negative .pl-percent { color: var(--negative); }

.diagonal-actions { display: flex; gap: 6px; justify-content: center; }

.action-icon-button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
}

.action-icon-button svg { width: 15px; height: 15px; }
.action-icon-button:hover { color: var(--accent); border-color: var(--accent); }
.delete-action:hover { color: var(--negative); border-color: var(--negative); }

.column-header-stacked small { display: block; text-transform: none; letter-spacing: 0; }

/* ============ Buttons ============ */

.add-holding-button, .primary-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #111;
  font-weight: 600;
  font-size: 13px;
  padding: 9px 15px;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.add-holding-button:hover, .primary-button:hover {
  background: var(--accent-strong);
  box-shadow: 0 4px 14px var(--accent-glow);
}

.add-holding-icon { font-weight: 700; }

.ghost-button {
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 7px 13px;
  font-size: 12.5px;
  font-weight: 600;
}

.ghost-button:hover { border-color: var(--accent); color: var(--accent); }

/* ============ Scenario ============ */

.scenario-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.scenario-summary > div {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.scenario-summary span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
.scenario-summary strong { font-family: var(--font-display); font-size: 19px; font-variant-numeric: tabular-nums; }

.scenario-context-line { padding: 8px 2px; font-size: 12.5px; color: var(--muted); }
.scenario-context-line strong { color: var(--text); }

.scenario-percent, .scenario-price {
  width: 86px;
  font-family: var(--font-mono);
}

/* Merged scenario input cell: % on top, price beneath, linked two ways. */
.scenario-inputs { display: flex; flex-direction: column; gap: 5px; align-items: center; }
.scenario-inputs input { width: 96px; text-align: center; }

.metric-badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  border-radius: 999px;
  padding: 2px 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.pnl-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  padding: 2px 8px;
  background: var(--accent-soft);
}

/* ============ Transactions ============ */

.activity-list { display: flex; flex-direction: column; gap: 9px; }

.activity-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
}

/* Default/empty messages: centered on the box midline, slightly larger. */
.empty-state {
  color: var(--muted);
  padding: 22px;
  text-align: center;
  font-size: 14.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 120px;
  height: 100%;
}

/* ============ Watchlist ============ */

.watch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.watch-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  padding: 13px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.pill {
  align-self: flex-start;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-radius: 999px;
  padding: 2px 9px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.watchlist-market-tabs { display: inline-flex; gap: 4px; margin-bottom: 12px; }

.watchlist-market-tabs button {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
}

.watchlist-market-tabs button.active { background: var(--accent); border-color: var(--accent); color: #111; }

.watchlist-market-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.watchlist-market-grid > * {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

/* ============ Macro ============ */

.macro-outlook-page { display: flex; flex-direction: column; gap: 16px; }

.macro-widget-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.macro-widget-card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.macro-widget-card-header h3 { font-size: 13.5px; font-weight: 700; }

.macro-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  padding: 14px 16px;
}

.macro-stat-grid > div { font-family: var(--font-mono); font-size: 13px; }
.macro-stat-grid strong { font-size: 16px; font-family: var(--font-display); }

.macro-top-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

/* Calendar card and the stacked forex column should match heights exactly:
   calendar body 524 + header ~45 = 569; stacked = 2*(header45 + body234) + gap16 = 574. */
.economic-calendar-card { display: flex; flex-direction: column; }

.macro-stacked-widgets { display: flex; flex-direction: column; gap: 16px; }
.macro-stacked-widgets .macro-widget-card { display: flex; flex-direction: column; flex: 1; }

.macro-widget-body { height: 524px; }
.compact-widget-body { height: auto; flex: 1; min-height: 234px; }
.heatmap-widget-body { height: 480px; }
.crypto-widget-body { height: 540px; }

/* Widgets fill their card body — no fixed-width negative space. */
.macro-widget-body .tradingview-widget-container,
.macro-widget-body .tradingview-widget-container > div,
.macro-widget-body .tradingview-widget-container iframe {
  width: 100% !important;
  height: 100% !important;
}

.macro-heatmap-grid {
  display: grid;
  grid-template-columns: 1fr 1fr; /* two equal heatmaps filling the full row */
  gap: 16px;
}

/* Crypto screener gets the full row so all its columns are visible. */
.macro-heatmap-grid .crypto-market-card { grid-column: 1 / -1; }
.crypto-widget-body { height: 620px; }

/* ============ Forum ============ */

.forum-new-topic {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 16px;
  background: var(--accent-soft);
}

.forum-topics { display: flex; flex-direction: column; gap: 12px; }

.forum-topic {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  overflow: hidden;
}

.forum-topic > summary {
  list-style: none;
  cursor: pointer;
  padding: 13px 16px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.forum-topic > summary::-webkit-details-marker { display: none; }
.forum-topic > summary:hover { background: var(--accent-soft); }
.forum-topic[open] > summary { border-bottom: 1px solid var(--border); }

.forum-topic-title { font-weight: 700; font-family: var(--font-display); font-size: 14px; }
.forum-topic-meta { font-size: 11.5px; color: var(--muted); white-space: nowrap; }

.forum-thread { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }

.forum-message {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  padding: 11px 13px 8px;
}

.forum-message-text { white-space: pre-wrap; word-break: break-word; }

.forum-message-meta {
  display: block;
  text-align: right;
  font-size: 11px;
  color: var(--muted);
  margin-top: 7px;
  font-family: var(--font-mono);
}

.forum-message-meta .forum-author { color: var(--accent-strong); font-weight: 600; }

.forum-reply-form { display: flex; gap: 8px; margin-top: 4px; }
.forum-reply-form textarea { flex: 1; resize: vertical; min-height: 40px; }

/* ============ Social / Manage shells ============ */

.tab-sub { padding-left: 30px !important; font-size: 12.5px !important; }
.tab-sub svg { width: 14px !important; height: 14px !important; }

.nav-badge[hidden] { display: none; }
.nav-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.shell-note {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
  max-width: 720px;
  line-height: 1.6;
}

.mono { font-family: var(--font-mono); color: var(--accent-strong); }

.shell-list { display: flex; flex-direction: column; gap: 10px; }

.shell-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
}

.shell-row strong { display: block; }
.shell-row .subtle { font-size: 12px; }

.shell-notif { cursor: default; }
.shell-invite-key { display: flex; gap: 8px; }
.shell-invite-key input { width: 130px; text-transform: uppercase; }

.shell-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 460px;
  margin-top: 16px;
}

.shell-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.shell-actions { display: flex; gap: 9px; }

.shell-split { display: grid; grid-template-columns: minmax(0, 240px) minmax(0, 1fr); gap: 14px; min-height: 260px; }
.shell-dm-list { display: flex; flex-direction: column; gap: 6px; }
.shell-dm {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.shell-dm.active { border-color: var(--accent); }
.shell-dm .subtle { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shell-dm-thread {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  display: grid;
  place-items: center;
}

.shell-access-controls { display: flex; align-items: center; gap: 12px; }
.shell-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }

/* Disabled shell inputs read as "coming soon", not broken. */
.shell-form input:disabled,
.shell-form button:disabled,
.shell-invite-key input:disabled,
.shell-invite-key button:disabled,
.shell-access-controls select:disabled,
.add-holding-button:disabled { opacity: 0.55; cursor: not-allowed; }

/* ============ Dividends Tracker ============ */

.dividend-summary {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.dividend-summary > div {
  flex: 1;
  min-width: 150px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.dividend-summary small { text-transform: uppercase; letter-spacing: 0.08em; font-size: 10.5px; }
.dividend-summary strong { font-family: var(--font-display); font-size: 20px; }

.piggy-panel { text-align: center; }
.piggy-bank {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 18px 0 6px;
}
.piggy-icon { width: 72px; height: 72px; color: var(--accent); }
.piggy-bank strong { display: block; font-family: var(--font-display); font-size: 34px; font-weight: 700; }
.piggy-bank .subtle { font-size: 12.5px; }
.piggy-quote { max-width: 440px; margin: 10px auto 0; text-align: left; }

/* ============ Dialogs ============ */

dialog {
  border: none;
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  padding: 0;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
  max-width: 520px;
  width: calc(100vw - 40px);
}

dialog::backdrop { background: rgba(8, 10, 13, 0.62); backdrop-filter: blur(3px); }

.dialog-card { padding: 20px; }

.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.dialog-heading h2 { font-size: 16px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-grid label, .full-label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.full-label { margin-top: 12px; display: flex; }

.total-cost-hint { min-height: 14px; font-size: 11.5px; font-family: var(--font-mono); color: var(--accent-strong); }
#priceInput[readonly] { opacity: 0.75; cursor: default; background: var(--bg-elev); }

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 18px;
}

/* ============ Stock detail modal ============ */

.stock-detail-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 13, 0.66);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 60;
}

.stock-detail-modal {
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  width: min(960px, calc(100vw - 40px));
  max-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}

.stock-detail-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.stock-detail-modal-title { font-size: 16px; }

.stock-detail-modal-close {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius-sm);
  width: 30px;
  height: 30px;
}

.stock-detail-modal-close:hover { color: var(--negative); border-color: var(--negative); }

.stock-detail-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 16px;
  flex-wrap: nowrap; /* single row — scrolls horizontally if it ever overflows */
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
}

.stock-detail-tab { white-space: nowrap; flex: none; }

.stock-detail-tab {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 11.5px;
  font-weight: 600;
}

.stock-detail-tab.active { background: var(--accent); border-color: var(--accent); color: #111; }

.stock-detail-modal-body { overflow: auto; padding: 14px 16px; flex: 1; display: flex; }
.stock-detail-widget-shell { height: 580px; width: 100%; }
.stock-overview-tab-content { display: flex; flex-direction: column; gap: 12px; height: 100%; }
.stock-overview-info-shell { flex: none; height: 190px; }
.stock-overview-chart-shell { flex: 1; min-height: 0; }

/* TradingView embeds fill their shells — no letterboxing inside the modal. */
.stock-detail-widget-shell .tradingview-widget-container,
.stock-detail-widget-shell .tradingview-widget-container > div,
.stock-detail-widget-shell .tradingview-widget-container iframe {
  width: 100% !important;
  height: 100% !important;
}

/* ============ Scrollbars & misc ============ */

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 1080px) {
  .dash-main-grid { grid-template-columns: 1fr; }
  .macro-top-grid { grid-template-columns: 1fr; }
  .macro-heatmap-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .sidebar { transform: translateX(calc(-1 * var(--sidebar-width))); }
  body.sidebar-open-mobile .sidebar { transform: none; }
  .main-column { margin-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
}

/* Cloud sync indicator (topbar) */
#syncDot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  align-self: center;
  background: var(--muted, #8b93a1);
  opacity: 0.55;
}
#syncDot[data-status="ok"] { background: #4caf82; opacity: 0.8; }
#syncDot[data-status="pending"] { background: #e0b34c; opacity: 1; }
#syncDot[data-status="error"] { background: #ff5d6c; opacity: 1; }

/* Transaction dialog validation note */
.dialog-note { font-size: 12.5px; color: var(--muted, #8b93a1); margin: 4px 0 0; }
#transactionError { margin: 6px 0 0; }

/* Watchlist view toolbar (Widgets | List + sort controls) */
.watchlist-view-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.watchlist-list-controls { display: flex; gap: 10px; }
.watchlist-list-controls[hidden] { display: none; }
.watchlist-market-grid[hidden] { display: none; }
#watchlistListWrap[hidden] { display: none; }

/* Earnings calendar chips carry a small TradingView logo tag */
.cal-chip { display: flex; align-items: center; gap: 4px; width: 100%; overflow: hidden; }
.cal-chip tv-ticker-tag { pointer-events: none; max-width: 100%; }
.cal-chip .ticker-fallback { font-size: 10.5px; font-weight: 700; }
.cal-chip:has(tv-ticker-tag:defined) .ticker-fallback { display: none; }

/* Estimates dialog: the clicked fiscal period is highlighted */
.estimates-table tr.selected-period { background: var(--accent-soft); }
.estimates-table tr.selected-period td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
