/* ============================================================
   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); }

/* Notifications bell */
.notif-bell { position: relative; }
.notif-dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--negative);
}
.notif-dot[hidden] { display: none; }
.shell-notif.unread { box-shadow: inset 3px 0 0 var(--accent); }

/* DM thread */
.shell-dm { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; border: none; background: transparent; color: var(--text); text-align: left; padding: 10px 12px; border-radius: var(--radius-sm); }
.shell-dm:hover, .shell-dm.active { background: var(--accent-soft); }
.shell-dm-thread-wrap { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.shell-dm-thread { max-height: 420px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 10px; }
.dm-thread-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.dm-bubble { max-width: 72%; padding: 8px 12px; border-radius: 12px; background: var(--bg-elev); border: 1px solid var(--border); }
.dm-bubble.mine { align-self: flex-end; background: var(--accent-soft); border-color: transparent; }
.dm-bubble small { display: block; color: var(--muted); font-size: 10.5px; margin-top: 2px; }
.dm-composer { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }
.dm-composer[hidden] { display: none; }
.dm-composer input { flex: 1; }
.dm-new { margin-bottom: 12px; }

/* Standard: explanation notes always span the full box width */
.shell-note { max-width: none; width: 100%; }
.panel-subtitle { max-width: none; }

/* Bell badge — Apple-style count, overflowing the icon's top-right corner */
.notif-badge {
  position: absolute;
  top: -4px;
  right: -5px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--negative);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.notif-badge[hidden] { display: none; }

/* Avatars (default: colored circle with the handle's first letter) */
.user-avatar {
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #111;
  font-weight: 700;
  font-family: var(--font-display);
  object-fit: cover;
  flex: none;
}

/* My Profile */
.profile-layout { display: flex; gap: 28px; align-items: flex-start; }
.profile-avatar-wrap { position: relative; width: 120px; height: 120px; cursor: pointer; flex: none; }
.profile-avatar {
  width: 120px; height: 120px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 44px; font-weight: 700; font-family: var(--font-display); color: #111;
  background: var(--accent); overflow: hidden;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-avatar-overlay {
  position: absolute; inset: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.35); backdrop-filter: blur(1.5px);
  color: #fff; opacity: 0.85; transition: opacity 0.15s ease;
}
.profile-avatar-wrap:hover .profile-avatar-overlay { opacity: 1; }
.profile-avatar-overlay svg { width: 30px; height: 30px; }
.profile-fields { display: flex; flex-direction: column; gap: 12px; flex: 1; max-width: 420px; }
.profile-fields label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.password-row { display: flex; gap: 6px; align-items: center; }
.password-row input { flex: 1; }

/* Inbox: symmetric two-pane layout with framed panes */
.dm-new { margin-bottom: 14px; }
.shell-split { display: grid; grid-template-columns: 280px 1fr; gap: 14px; align-items: stretch; }
.shell-dm-list {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev);
  padding: 8px; display: flex; flex-direction: column; gap: 4px; min-height: 380px; max-height: 480px; overflow-y: auto;
}
.shell-dm-thread-wrap { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); display: flex; flex-direction: column; min-height: 380px; max-height: 480px; }
.shell-dm { display: flex; flex-direction: row; align-items: center; gap: 10px; }
.dm-list-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.dm-list-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.dm-preview { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shell-dm-thread { flex: 1; }

/* Pending invites are clickable rows */
button.shell-invite { width: 100%; text-align: left; border: 1px solid var(--border); background: var(--bg-elev); border-radius: var(--radius-sm); display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; }
button.shell-invite:hover { border-color: var(--accent); }

/* Dividend Target & Piggy Bank */
.piggy-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: center; }
.piggy-left { display: flex; flex-direction: column; gap: 14px; }
.piggy-right { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.piggy-target-input { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); width: min(240px, 100%); }
.piggy-ring-wrap { position: relative; width: 150px; height: 150px; }
.piggy-ring { width: 150px; height: 150px; }
.piggy-ring-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.piggy-ring-label strong { font-size: 21px; font-family: var(--font-display); }
#piggyRingProgress { transition: stroke-dashoffset 0.4s ease; }

/* Symbol/name selection highlight */
.input-selected { background: rgba(140, 148, 160, 0.18) !important; }
html[data-theme="light"] .input-selected { background: #e8eaee !important; }

/* Current price hint under Purchase Price */
.current-price-hint { font-size: 11.5px; color: var(--muted); min-height: 14px; }

/* Dividend Piggy Bank: ring left, piggy+quote right, aligned midlines */
.piggy-layout { grid-template-columns: auto 1fr; gap: 40px; justify-content: start; }
.piggy-ring-side { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.piggy-ring-wrap, .piggy-ring { width: 180px; height: 180px; }
.piggy-ring-label strong { font-size: 24px; }
.piggy-ring-label .subtle { font-size: 13px; }
.piggy-target-input { width: 180px; font-size: 12px; text-align: center; }
.piggy-target-input input { text-align: center; padding: 6px 8px; font-size: 13px; }
.piggy-bank-side { display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.piggy-bank { display: flex; align-items: center; gap: 16px; }
.piggy-icon { width: 64px; height: 64px; color: var(--accent); flex: none; }
.piggy-amount { display: flex; flex-direction: column; }
.piggy-amount strong { font-size: 26px; font-family: var(--font-display); line-height: 1.2; }
.piggy-amount .subtle { font-size: 13px; }
.piggy-quote { margin: 0; font-size: 13.5px; }

/* Scenario toolbar: reset button top-aligned with the title block */
#scenario .panel-heading.toolbar { align-items: flex-start; }

/* Holdings toolbar: search flush with the panel title edge */
.holdings-toolbar-left { padding-left: 0; }
.holdings-toolbar-left input { margin-left: 0; }
#holdingsInterval[hidden] { display: none; }

/* Buy-with-cash checkbox */
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); grid-column: 1 / -1; }
.checkbox-label input { width: auto; }
.tx-buy-cash[hidden] { display: none; }

/* Cash card is clickable */
#cashTotal { cursor: pointer; }
.wide-dialog { min-width: min(620px, 92vw); }

/* Topbar: prices left, controls right; live FX under the currency toggle */
.price-status { margin-left: 4px; }
.currency-block { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.fx-readout { font-size: 10.5px; color: var(--muted); font-family: var(--font-mono); }

/* Toolbars: buttons top-aligned with the title/description block (standard) */
.panel-heading.toolbar { align-items: flex-start; }

/* Dialog symmetry: uniform vertical rhythm; full-row inputs centered */
.form-grid { row-gap: 14px; }
.form-grid label[hidden] { display: none; }
.form-grid .full-label { grid-column: 1 / -1; align-items: center; text-align: center; }
.form-grid .full-label input { width: min(320px, 100%); margin: 0 auto; text-align: center; }

/* Watchlist view toggle: icon pair on the right */
.watchlist-view-toolbar { justify-content: flex-end; gap: 10px; }
.view-icons { display: flex; gap: 4px; }
.view-icons button { display: grid; place-items: center; width: 32px; height: 30px; padding: 0; border: 1px solid var(--border); background: var(--bg-elev); border-radius: 7px; color: var(--muted); }
.view-icons button svg { width: 16px; height: 16px; }
.view-icons button.active { background: var(--accent); border-color: var(--accent); color: #111; }

/* Cash history: full table visible, vertical scroll only */
#cashHistoryDialog .dialog-card { min-width: min(680px, 94vw); }
#cashHistoryBody { overflow-x: hidden; overflow-y: auto; max-height: 60vh; }
#cashHistoryBody table { width: 100%; }

/* Profile: no blur; pen sits below the letter; equal-width fields; eye inside box */
.profile-layout { align-items: center; }
.profile-avatar-pen {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 10px;
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.45); color: #fff;
}
.profile-avatar-pen svg { width: 14px; height: 14px; }
.profile-avatar { align-items: flex-start; padding-top: 26px; }
.profile-avatar img { border-radius: 50%; }
.profile-fields { max-width: 460px; }
.profile-fields input { width: 100%; }
.password-row { position: relative; }
.password-row input { padding-right: 38px; }
.password-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; }
.password-eye svg { width: 16px; height: 16px; }

/* Forward-income breakdown link */
.forward-income-link { background: none; border: none; padding: 0; cursor: pointer; }
.forward-income-link strong { text-decoration: underline dotted; text-underline-offset: 3px; }

/* Uniform dialog rhythm even with helper hints and odd box counts: hints
   float in the row gap instead of stretching their row. */
.form-grid label { position: relative; }
.form-grid { row-gap: 20px; }
.current-price-hint { position: absolute; top: calc(100% + 3px); left: 2px; margin: 0; white-space: nowrap; }
.form-grid .full-label { margin-top: 0; }


/* Full-row dialog boxes: block centered, label + input text left-aligned */
.form-grid .full-label { align-items: flex-start; text-align: left; width: min(320px, 100%); margin: 0 auto; }
.form-grid .full-label input { text-align: left; width: 100%; }
/* Free-floating notes under the last dialog row stay centered */
#watchAlertNote, #transactionSellNote { text-align: center; }

/* Collapsible nav groups */
.nav-collapsible { cursor: pointer; user-select: none; display: flex; align-items: center; gap: 6px; }
.nav-caret { width: 13px; height: 13px; transition: transform 0.2s ease; flex: none; }
.nav-collapsible.collapsed .nav-caret { transform: rotate(-90deg); }
.nav-group.nav-collapsed { display: none; }
.coming-soon { font-size: 15.5px; min-height: 220px; }


/* Topbar: currency toggle on the icon row, live FX floating beneath */
.topbar-controls { align-items: center; }
.currency-block { position: relative; }
.fx-readout { position: absolute; top: calc(100% + 1px); left: 50%; transform: translateX(-50%); white-space: nowrap; }

/* Sidebar: collapse carets right-aligned across all three sections */
.nav-portfolio-header { align-items: center; }
.nav-section-row, .nav-portfolio-header { display: flex; justify-content: space-between; align-items: center; }
.nav-section-label { display: flex; align-items: center; gap: 4px; flex: 1; }
.nav-collapse-btn { border: none; background: transparent; color: var(--muted); width: 22px; height: 22px; display: grid; place-items: center; border-radius: 5px; margin-right: 6px; }
.nav-collapse-btn:hover { color: var(--accent); }
.nav-section-row .nav-collapse-btn, .nav-portfolio-header .nav-collapse-btn { margin-left: auto; }
.nav-collapse-btn .nav-caret { transition: transform 0.2s ease; }
.nav-group.nav-collapsed + * {}
.nav-collapse-btn.collapsed .nav-caret { transform: rotate(-90deg); }

/* Watchlist header: toggle + add button aligned with the title block */
.watchlist-header-actions { display: flex; align-items: center; gap: 10px; }
.watchlist-market-summary { margin-top: 4px; }
.watchlist-view-toolbar:empty { display: none; }

/* Mentions */
.mention { color: var(--accent); font-weight: 600; }
.mention-suggest {
  position: absolute; z-index: 20; left: 8px; bottom: 100%;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; min-width: 160px; overflow: hidden;
}
.mention-suggest button { border: none; background: transparent; color: var(--text); text-align: left; padding: 8px 12px; }
.mention-suggest button:hover { background: var(--accent-soft); color: var(--accent-strong); }

/* DM recipient chips + send row */
.dm-new-row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.dm-recipients-label { flex: 1; min-width: 260px; display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.dm-recipients { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 5px 8px; }
.dm-recipients input { border: none; background: transparent; flex: 1; min-width: 120px; padding: 4px; }
.dm-recipients input:focus { outline: none; }
.dm-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--accent); color: #111; font-weight: 600; font-size: 12.5px; border-radius: 999px; padding: 3px 10px; }
.dm-chip button { border: none; background: transparent; color: #111; font-size: 14px; padding: 0; line-height: 1; }
#dmSendBtn:disabled { opacity: 0.45; cursor: not-allowed; }


/* Sidebar sections collapse smoothly, content below pulls up */
.nav-group { overflow: hidden; max-height: 420px; transition: max-height 0.28s ease, opacity 0.2s ease; opacity: 1; }
.nav-group.nav-collapsed { display: block; max-height: 0; opacity: 0; }

/* Watchlist header: toggle + button share one midline */
.watchlist-header-actions { align-items: center; }
.view-icons button { height: 36px; width: 36px; }

/* Earnings calendar empty message: centered, capped */
#calGrid .empty-state, #earningsList .empty-state { grid-column: 1 / -1; min-height: 96px; max-width: 520px; margin: 0 auto; }

/* Dividend Piggy Bank: ring/bank on top, target + quote beneath */
.piggy-layout {
  grid-template-columns: 280px 1fr;
  grid-template-areas: "ring bank" "target quote";
  gap: 20px 40px;
  align-items: center;
  padding-left: 48px; /* gentle indent from the box edge */
}
.piggy-ring-side { grid-area: ring; }
.piggy-bank-side { grid-area: bank; }
.piggy-target-input {
  grid-area: target;
  width: auto;
  white-space: nowrap;
  align-items: center;
  text-align: center;
}
.piggy-target-input input { width: 200px; margin: 0 auto; }
.piggy-quote { grid-area: quote; width: 100%; margin: 0; }
.franklin-quote cite { display: block; text-align: right; }

/* Piggy bank icon: hero-sized, $ midline matched to the amount text */
.piggy-bank { gap: 22px; }
.piggy-icon { width: 108px; height: 108px; margin-top: -6px; }
.piggy-amount strong { font-size: 40px; }
.piggy-amount .subtle { font-size: 15px; }

/* DM group checkbox sits beside Send DM */
.dm-group-check { flex: none; max-width: 340px; }
.dm-group-check small { font-weight: 400; }

/* Transaction log: compact rows, description left / date right on one midline */
.activity-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
}
.activity-item strong { margin: 0; }
.activity-item .subtle { white-space: nowrap; }

/* View-icon pair: strip legacy tab-pill chrome so it centers with the button */
.watchlist-market-tabs.view-icons { padding: 0; background: transparent; border: none; gap: 6px; align-items: center; }
.view-icons button { height: 35px; width: 35px; margin: 0; }
.watchlist-market-tabs.view-icons { margin-bottom: 0; align-self: center; }

/* News headlines are bold */
.news-title { font-weight: 700; }

/* Topbar: slimmer icons/toggle so the FX readout clears the border line */
.topbar .icon-button { width: 30px; height: 30px; }
.topbar .icon-button svg { width: 15px; height: 15px; }
.segmented .segment { padding: 4px 10px; font-size: 12px; }
.fx-readout { font-size: 9.5px; top: calc(100% + 0px); }
#sidebarToggle { width: 30px; height: 30px; }

/* Sidebar collapse: headings hug each other and their sub-items — no dead gaps */
.nav-section-label { margin: 10px 8px 4px; }
.nav-group { margin: 0; }
.nav-group.nav-collapsed { margin: 0; }
.nav-portfolio-header + .portfolio-dropdown[hidden] + .nav-group { margin-top: 0; }

/* JS-driven collapse: neutralize the old CSS trick; folded groups take no space */
.nav-group { max-height: none; transition: none; opacity: 1; }
.nav-group.nav-collapsed { display: block; max-height: none; opacity: 1; margin: 0; }
.nav-group.nav-folded { display: none; }
/* Headings hug their groups and each other when folded */
.nav-section-label { margin: 8px 8px 3px; }
.nav-manage-row { margin-bottom: 2px; }

/* ===== Icon rail: collapsing the sidebar leaves a slim icon-only strip ===== */
body.sidebar-collapsed .sidebar {
  transform: none;
  width: 64px;
  padding: 12px 8px;
}
body.sidebar-collapsed .main-column { margin-left: 64px; }
body.sidebar-collapsed .sidebar-logo { display: none; }
body.sidebar-collapsed .nav-manage-row .tab span,
body.sidebar-collapsed .sidebar-nav .tab span,
body.sidebar-collapsed .nav-section-label,
body.sidebar-collapsed .nav-collapse-btn,
body.sidebar-collapsed .portfolio-dropdown,
body.sidebar-collapsed .active-portfolio,
body.sidebar-collapsed #sidebarUsername { display: none; }
body.sidebar-collapsed .nav-portfolio-header, body.sidebar-collapsed .nav-section-row { justify-content: center; min-height: 8px; }
body.sidebar-collapsed .sidebar-nav .tab { justify-content: center; padding: 10px 0; }
body.sidebar-collapsed .sidebar-nav .tab svg { width: 19px; height: 19px; }
body.sidebar-collapsed .nav-group.nav-folded { display: block; } /* icons stay reachable on the rail */
body.sidebar-collapsed .sidebar-user { justify-content: center; padding: 12px 0 2px; }

/* My Profile: balanced layout — avatar midline on the Email row, compact fields,
   save button pinned bottom-right */
.profile-layout { justify-content: center; gap: 64px; align-items: center; }
.profile-avatar-wrap { margin-top: -40px; }
.profile-fields { max-width: 320px; width: 320px; }
.profile-fields .shell-actions { justify-content: flex-end; margin-top: 10px; }

/* Collapsed sections: titles stack immediately, flush to the top */
.nav-section-label { margin: 6px 8px 2px; }
.nav-portfolio-header, .nav-section-row { min-height: 30px; }
.nav-manage-row { padding: 0 0 8px; }

/* Section titles must never stretch vertically in the sidebar column */
.nav-section-label { flex: 0 0 auto; }
.nav-portfolio-header .nav-section-label { flex: 1; } /* fills its horizontal row only */
.nav-section-row { min-height: 0; }

/* Stat cards: shorter, all components scaled together */
.stat-card { min-height: 106px; padding: 14px 16px; }
.stat-label { font-size: 12.5px; top: 12px; }
.stat-value { font-size: 22px; transform: translateY(-4px); }
.stat-card .stat-sub { bottom: 12px; font-size: 11.5px; }

/* My Progress: just the ring + percentage, centered */
.progress-card { justify-content: center; }
.progress-card .progress-ring-wrap { transform: translateY(9px); }
.progress-ring-wrap, .progress-ring { width: 74px; height: 74px; }
.progress-ring-label { font-size: 14px; }


/* Stat cards: content nudged down so the ring clears its title */
.stat-value { transform: translateY(1px); }
.progress-card .progress-ring-wrap { transform: translateY(12px); }
.stat-card .stat-sub { bottom: 9px; }

/* Topbar bottom line aligns with the line under the logo (61px) */
.topbar { min-height: 61px; }

/* Fillers: consistent placement across the dashboard's lower boxes */
.allocation-layout .empty-state, #allocationList .empty-state {
  min-height: 0; height: auto; flex: none; padding: 26px 12px; align-items: flex-start;
}
#bestPerformer .empty-state, #worstPerformer .empty-state {
  min-height: 0; height: auto; flex: none; padding: 26px 12px; align-items: flex-start;
}

/* Chart empty note wraps onto two lines */
.chart-empty-note { max-width: 320px; margin: 0 auto; text-align: center; }

/* Sidebar handle shows exactly as the user chose it */
.sidebar-user { text-transform: none; }

/* DM add-recipient (+) button inside the recipients box */
.dm-add-btn {
  width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--bg-elev); color: var(--muted); font-size: 15px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; padding: 0; flex: none;
}
.dm-add-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Fillers (correct targets): consistent top placement across dashboard boxes */
#bestPerformersBox .empty-state, #worstPerformersBox .empty-state {
  min-height: 0; height: auto; flex: none; padding: 26px 12px 0; align-items: flex-start; justify-content: center;
}
.allocation-layout { align-items: flex-start; }
.allocation-layout .empty-state { padding: 26px 12px 0; }
#insightsFeed .empty-state { min-height: 0; height: auto; flex: none; padding: 26px 12px 0; align-items: flex-start; }
#allocationChart[hidden] { display: none; }
.allocation-layout .empty-state { width: 100%; }
.dash-under-grid .allocation-layout { align-items: flex-start; justify-content: flex-start; }

/* Group checkbox: hidden until 2+ recipients ([hidden] beats display:flex) */
.dm-group-check[hidden] { display: none !important; }
/* One row: input | Send DM | checkbox+note */
.dm-new-row { flex-wrap: nowrap; align-items: center; }
.dm-recipients-label { flex: 1 1 auto; min-width: 220px; }
.dm-group-check { max-width: 380px; line-height: 1.3; }
.dm-group-check small { display: inline; }

/* Compose dialog */
.compose-recipients { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.compose-recipients-title { font-size: 12px; font-weight: 600; color: var(--muted); }
#composeRecipientsList { display: flex; flex-wrap: wrap; gap: 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--input-bg); padding: 8px; min-height: 38px; }
.compose-field { width: 100% !important; }
.compose-field input, .compose-field textarea { width: 100% !important; text-align: left !important; }
.dm-bubble div { white-space: pre-line; }

/* Stat values: equidistant between title and bottom border */
.stat-value { transform: translateY(5px); }
.dm-new-row { align-items: flex-end; }
.dm-group-check { margin-bottom: 7px; }
#dmSendBtn { margin-bottom: 0; }

/* Fillers, final rule: every dashboard filler sits on the MIDLINE of its box */
#insightsFeed .empty-state,
.dash-under-grid .allocation-layout .empty-state,
#bestPerformersBox .empty-state,
#worstPerformersBox .empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 16px;
  min-height: 0;
  height: 100%;
  flex: 1;
}
#insightsFeed:has(.empty-state) { height: 100%; display: flex; flex-direction: column; }
.dash-under-grid .allocation-layout { align-items: stretch; justify-content: center; }
#bestPerformersBox .performer-list:has(.empty-state),
#worstPerformersBox .performer-list:has(.empty-state) { display: flex; flex: 1; min-height: 170px; }

/* Chart empty note: dead center over the sample curve, two lines */
.chart-empty-note {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 320px;
  max-width: 85%;
  margin: 0;
  text-align: center;
}
#allocationList:has(> .empty-state) { display: flex; flex: 1; height: 100%; align-items: stretch; }
.dash-under-grid .allocation-layout:has(.empty-state) { height: 100%; }
#allocationList .empty-state, #insightsFeed .empty-state {
  align-items: center; justify-content: center; height: 100%; flex: 1; padding: 0 16px; min-height: 0;
}
/* Performer fillers wrap onto two lines ("... your / best performers.") */
#bestPerformersBox .empty-state, #worstPerformersBox .empty-state {
  max-width: 240px;
  margin: 0 auto;
  padding: 0;
}
/* Performer fillers: fixed offset under their toggles so both boxes match the
   body-text height of the boxes to their left */
#bestPerformersBox .empty-state, #worstPerformersBox .empty-state {
  align-items: flex-start; height: auto; flex: none; padding: 74px 0 0;
}
#bestPerformersBox .performer-list:has(.empty-state),
#worstPerformersBox .performer-list:has(.empty-state) { align-items: flex-start; }
#bestPerformersBox .empty-state { padding-top: 152px; }
#worstPerformersBox .empty-state { padding-top: 134px; }
#bestPerformersBox .empty-state { padding-top: 191px; }
#worstPerformersBox .empty-state { padding-top: 164px; }
/* Absolute placement: filler text lines up with the left-column body text */
#bestPerformersBox, #worstPerformersBox { position: relative; }
#bestPerformersBox .empty-state, #worstPerformersBox .empty-state {
  position: absolute; left: 50%; transform: translateX(-50%);
  padding: 0; margin: 0; height: auto; width: 240px;
}
#bestPerformersBox .empty-state { top: 208px; }
#worstPerformersBox .empty-state { top: 190px; }

/* Manage page: rename pen + delete trash, aligned like Holdings actions */
.manage-row { align-items: center; }
.manage-name { display: flex; align-items: center; gap: 8px; }
.manage-actions { display: flex; align-items: center; gap: 10px; }

/* Tolstoy quote: full row width, single centered line, credit bottom-right */
.piggy-quote {
  grid-column: 1 / -1;
  width: 100%;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
  padding-bottom: 26px;
}
.piggy-quote cite { position: absolute; right: 14px; bottom: 6px; }

/* Dividends Calendar: air between the subtitle and the summary boxes */
#dividendCalendar { margin-top: 16px; }
#dividendCalendar .dividend-summary div { align-items: flex-start; text-align: left; }
#dividendCalendar .dividend-summary strong, #dividendCalendar .forward-income-link { text-align: left; align-self: flex-start; }
/* Piggy quote: back to its own bottom-right cell (next to the target input),
   stretched to the end of the box, text centered, credit bottom-right */
.piggy-quote {
  grid-column: auto;
  grid-area: quote;
  width: 100%;
  white-space: normal;
  overflow: visible;
  text-align: center;
  position: relative;
  padding: 14px 18px 26px;
}
.piggy-quote cite { position: absolute; right: 14px; bottom: 6px; }
.piggy-quote { margin: 0; }
.piggy-layout .piggy-quote { width: 100% !important; justify-self: stretch !important; max-width: none !important; box-sizing: border-box; }


/* FX readout: nudged right with a live/offline dot */
.fx-readout { transform: translateX(calc(-50% + 6px)); display: inline-flex; align-items: center; gap: 4px; }
.fx-live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--negative); flex: none; }
.fx-live-dot[data-live="1"] { background: var(--positive); }

/* Chart range dropdown (top-right of the Portfolio Performance box) */
.chart-range-select { font-size: 12px; padding: 5px 8px; }

/* P/L header select */
#plIntervalSelect { font-size: 10.5px; padding: 2px 4px; margin-top: 2px; }


/* FX readout: tucked back under the toggle */
.fx-readout { transform: translateX(-50%); }

/* Chat bubbles: incoming LEFT (elevated grey), sent RIGHT (salmon tint);
   one message per row, long messages get their own scrollbar */
.dm-bubble { display: block; }
.dm-bubble.theirs { align-self: flex-start; background: var(--bg-elev); border: 1px solid var(--border); }
.dm-bubble.mine { align-self: flex-end; background: var(--accent-soft); border-color: transparent; }
.dm-bubble > div { max-height: 130px; overflow-y: auto; }
.dm-unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--negative); flex: none; align-self: center; }

/* Transaction type ribbons (top-left corner) */
.activity-item { position: relative; overflow: hidden; }
.activity-item::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 34px; height: 34px;
  clip-path: polygon(0 0, 100% 0, 0 100%);
  opacity: 0.9;
}
.activity-item.tx-buy::before { background: var(--positive); }
.activity-item.tx-sell::before { background: var(--negative); }
.activity-item.tx-deposit::before { background: #5b8def; }
.activity-item.tx-withdrawal::before { background: #e0b34c; }
.activity-item.tx-dividend::before { background: #a98ed6; }
.activity-item strong { margin-left: 26px; }


/* Circle-plus icon: black disc, salmon plus — the standard for Add buttons */
.circle-plus-icon { width: 17px; height: 17px; flex: none; }
.add-holding-icon { background: #111; color: var(--accent); }

/* Read-only shared portfolios: row edit/delete actions vanish too */
body.portfolio-readonly .diagonal-actions { display: none !important; }
body.portfolio-readonly .actions-ghost-column button { display: none !important; }

/* Active portfolio name: small italic salmon subtext under MY PORTFOLIO */
.nav-portfolio-header .nav-section-label { white-space: nowrap; }
.active-portfolio {
  display: block;
  margin: 0 8px 2px;
  font-size: 11px;
  font-style: italic;
  font-weight: 600;
  color: var(--accent-strong);
}
.active-portfolio:empty { display: none; }

/* Collapse carets: identical right offset on all three section rows */
.nav-portfolio-header .nav-collapse-btn, .nav-section-row .nav-collapse-btn { margin-right: 6px; }
.nav-section-row { padding-right: 0; }

/* Group chat: sender handle before timestamp */
.dm-sender { color: var(--accent-strong); font-weight: 600; }
.dm-members-more { border: none; background: transparent; color: var(--muted); cursor: pointer; font-weight: 700; }
.dm-members-more:hover { color: var(--accent); }
/* Carets: rows' buttons shifted right 8px to match MY PORTFOLIO's caret */
.nav-section-row .nav-collapse-btn { margin-right: -2px; }


/* Bubble footer: sender bottom-left (groups), timestamp bottom-right */
.dm-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; margin-top: 3px; }
.dm-meta .dm-time { margin-left: auto; }


/* Chat banner: pinned at the top of the scrolling log, clearly separated */
.dm-thread-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  margin: -10px -10px 6px;
  padding: 12px 14px;
}

/* Privacy Settings: save row bottom-right */
.privacy-save-row { display: flex; justify-content: flex-end; align-items: center; gap: 14px; margin-top: 16px; }
.privacy-save-row .shell-note { width: auto; margin: 0; }

/* My Profile: Save Changes pinned to the box's bottom-right corner */
#profile .panel { position: relative; padding-bottom: 70px; }
.profile-fields .shell-actions { position: absolute; right: 24px; bottom: 18px; margin: 0; }

/* Chat banner: SOLID salmon bar, edge-to-edge, fixed; messages pass behind */
.dm-thread-header {
  position: sticky;
  top: -10px; /* cancels the thread's inner padding so the bar hugs the box top */
  z-index: 8;
  background: var(--accent) !important;
  color: #111;
  border-bottom: 1px solid var(--border);
  margin: -10px -10px 8px;
  padding: 11px 14px;
}
.dm-thread-header > strong { color: #111; }
.dm-thread-header .ghost-button { border-color: rgba(0, 0, 0, 0.4); color: #111; background: transparent; }
.dm-thread-header .ghost-button:hover { background: rgba(0, 0, 0, 0.12); }

/* Add buttons: the + always sits in a PERFECT black circle */
.add-holding-icon {
  width: 16px;
  height: 16px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
  flex: none;
}

/* Watchlist header: compact controls, tops aligned with the description line */
.watchlist-header-actions { align-self: flex-start; margin-top: 26px; }
.watchlist-header-actions .add-holding-button { padding: 5px 12px; font-size: 12.5px; height: 30px; }
.watchlist-header-actions .view-icons button { height: 30px; width: 30px; }
.dm-thread-header { align-self: stretch; }
.shell-dm-thread { align-items: stretch; }
.shell-dm-thread .empty-state { align-self: center; }


/* Avatar editor: circular stage, draggable image */
.avatar-editor-stage {
  width: 240px;
  height: 240px;
  border-radius: 50%;
  overflow: hidden;
  margin: 0 auto 14px;
  position: relative;
  background: #000;
  cursor: grab;
  touch-action: none;
}
.avatar-editor-stage:active { cursor: grabbing; }
#avatarEditorImg {
  position: absolute;
  left: 50%;
  top: 50%;
  min-width: 100%;
  min-height: 100%;
  transform: translate(-50%, -50%);
  user-select: none;
  pointer-events: none;
}
.avatar-editor-controls { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.avatar-editor-controls label { display: flex; align-items: center; gap: 10px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.avatar-editor-controls input[type="range"] { flex: 1; }
.avatar-reset-btn { margin-top: 8px; font-size: 12px; }
.avatar-reset-btn[hidden] { display: none; }

/* Default avatars: themed border, white letter with black outline */
.avatar-default, .profile-avatar.avatar-default { border: 2px solid #fff; }
html[data-theme="light"] .avatar-default, html[data-theme="light"] .profile-avatar.avatar-default { border-color: #111; }
.avatar-letter {
  color: #fff;
  text-shadow: -1px -1px 0 #111, 1px -1px 0 #111, -1px 1px 0 #111, 1px 1px 0 #111;
}
.profile-avatar { align-items: center; padding-top: 0; }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.user-avatar img, img.user-avatar { border-radius: 50%; object-fit: cover; }

/* Chat bubbles: timestamp pinned to the bubble's right edge */
.dm-bubble small.dm-meta { display: flex !important; width: 100%; justify-content: space-between !important; }
.dm-meta .dm-time { margin-left: auto; text-align: right; }

/* Watchlist add button: tighter label */
.watchlist-header-actions .add-holding-button { font-size: 12px; white-space: nowrap; }
.watchlist-header-actions .add-holding-button span:last-child { font-size: 12px; }


/* Status indicator states */
#priceStatus[data-status="afterhours"] { color: var(--accent); }
#priceStatus[data-status="afterhours"] .moon-icon { color: var(--accent); }
#priceStatus[data-status="offline"] { color: var(--negative); }

/* Avatar column: preview on top, actions stacked beneath */
.avatar-side-actions { display: flex; flex-direction: column; gap: 8px; align-items: center; margin-top: -28px; }
.choose-file-box {
  border: 1px dashed var(--border-strong);
  background: var(--input-bg);
  color: var(--muted);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 12px;
  cursor: pointer;
}
.choose-file-box:hover { border-color: var(--accent); color: var(--accent); }
.profile-layout { flex-wrap: wrap; }
.sidebar-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.sidebar-avatar { overflow: hidden; }


/* Pen badge: centered directly UNDER the avatar circle */
.avatar-side-actions .profile-avatar-pen {
  position: static;
  transform: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-top: 2px;
}
.avatar-side-actions .profile-avatar-pen:hover { border-color: var(--accent); color: var(--accent); }
.avatar-side-actions .profile-avatar-pen svg { width: 15px; height: 15px; }
.profile-avatar-wrap { cursor: default; }
.avatar-side-actions { margin-top: 6px; }

/* Sidebar avatar: bigger, crisp */
.sidebar-avatar { width: 44px; height: 44px; font-size: 17px; }

/* Offline second line */
#priceStatus { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 1px; line-height: 1.25; }
.last-ping { font-size: 11px; display: inline-flex; align-items: center; gap: 5px; }
.ping-warn-btn { border: none; background: transparent; color: var(--negative); padding: 0; cursor: pointer; display: inline-flex; }
.avatar-column { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.avatar-column .profile-avatar-wrap { margin-top: 0; }

/* Zero-portfolio state: the switcher offers creation instead of a list */
.create-portfolio-link {
  text-align: left;
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 12.5px;
  font-style: italic;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.create-portfolio-link:hover { background: var(--accent-soft); }

/* Add Holding: breathing room between the Current Price hint and Total Amount */
#holdingForm .full-label { margin: 14px auto 0; }


/* Pager: showing a-b of X with back/forward arrows */
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.pager-arrows { display: flex; gap: 6px; }
.pager-arrows button {
  width: 30px; height: 28px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--bg-elev); color: var(--text);
  font-size: 16px; line-height: 1; display: grid; place-items: center;
}
.pager-arrows button:disabled { opacity: 0.35; cursor: default; }
.pager-arrows button:not(:disabled):hover { border-color: var(--accent); color: var(--accent); }
.tx-toolbar-actions { display: flex; align-items: center; gap: 10px; }


/* Transaction rows: date + edit/delete cluster on the right */
.activity-right { display: inline-flex; align-items: center; gap: 8px; }
.activity-right .action-icon-button { width: 26px; height: 26px; }
.tx-auto-tag { font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; opacity: 0.7; }
body.portfolio-readonly .activity-right .action-icon-button { display: none !important; }
.watch-actions { white-space: nowrap; }
.watch-actions .action-icon-button { width: 26px; height: 26px; }
