:root[data-theme="dark"] {
  --bg-base: #0B0F17;
  --bg-card: #131B2E;
  --bg-card-hover: #1C273E;
  --bg-input: #1A2438;
  
  --text-main: #F8FAFC;
  --text-muted: #CBD5E1;
  --text-subtle: #94A3B8;
  
  --border: rgba(255, 255, 255, 0.1);
  --border-hover: rgba(255, 255, 255, 0.22);
  --border-focus: #3B82F6;

  --gain: #10B981;
  --gain-bg: rgba(16, 185, 129, 0.18);
  --loss: #F43F5E;
  --loss-bg: rgba(244, 63, 94, 0.18);
  --dividend: #3B82F6;

  --tfsa: #10B981;
  --fhsa: #8B5CF6;
  --rrsp: #3B82F6;
  --nonreg: #F59E0B;

  --bar-deposit: rgba(255, 255, 255, 0.14);
  --bar-reinvest: rgba(16, 185, 129, 0.45);
  --bar-unrealized: #10B981;

  --warn: #F59E0B;
  --warn-bg: rgba(245, 158, 11, 0.16);
  --warn-border: rgba(245, 158, 11, 0.35);
}

:root[data-theme="light"] {
  --bg-base: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F1F5F9;
  --bg-input: #EDF2F7;
  
  --text-main: #0F172A;
  --text-muted: #334155;
  --text-subtle: #64748B;
  
  --border: #E2E8F0;
  --border-hover: #CBD5E1;
  --border-focus: #2563EB;

  --gain: #059669;
  --gain-bg: rgba(5, 150, 105, 0.12);
  --loss: #E11D48;
  --loss-bg: rgba(225, 29, 72, 0.12);
  --dividend: #2563EB;

  --tfsa: #059669;
  --fhsa: #7C3AED;
  --rrsp: #2563EB;
  --nonreg: #D97706;

  --bar-deposit: #E2E8F0;
  --bar-reinvest: rgba(5, 150, 105, 0.4);
  --bar-unrealized: #059669;

  --warn: #D97706;
  --warn-bg: rgba(217, 119, 6, 0.1);
  --warn-border: rgba(217, 119, 6, 0.3);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background-color: var(--bg-base);
  color: var(--text-main);
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}

.app {
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 24px;
}

/* PRIVACY MASKS */
.masked-value { display: none; }
body.privacy-mode .real-value { display: none; }
body.privacy-mode .masked-value { display: inline; }

/* Salary input is a live input (not a masked span), so privacy mode hides its
   value with a dot overlay (matching the $•••• placeholders used everywhere
   else) rather than swapping the input out of the DOM. The overlay sits on
   top with pointer-events:none so a click still passes through to focus the
   real input, which reveals the value while typing. */
.salary-input-wrap {
  position: relative;
}
body.privacy-mode #baseSalaryInput {
  color: transparent;
}
#baseSalaryInput:focus {
  color: var(--text-main) !important;
}
.salary-privacy-dots {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  padding: 7px 10px;
  font-family: 'Manrope', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  pointer-events: none;
}
body.privacy-mode .salary-privacy-dots {
  display: flex;
}
.salary-input-wrap:focus-within .salary-privacy-dots {
  display: none;
}

.privacy-eye-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  margin-left: 8px;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  color: var(--text-subtle);
  transition: color 0.2s ease;
}
.privacy-eye-btn:hover {
  color: var(--text-main);
}
.privacy-eye-btn svg {
  width: 20px;
  height: 20px;
}

/* HERO BANNER SECTION */
.app-banner {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 28px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-card-hover) 100%);
  box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 32px 40px;
  gap: 24px;
}

.app-banner::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #3B82F6, #10B981, #8B5CF6);
}

.banner-content {
  display: flex;
  align-items: center;
  gap: 24px;
  z-index: 2;
}

.banner-logo-wrap {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.25);
  border: 2px solid var(--border-focus);
  background: var(--bg-card);
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.banner-logo-wrap:hover {
  transform: scale(1.06);
}

.banner-logo-wrap img {
  width: 125%;
  height: 125%;
  object-fit: cover;
  transform: scale(1.15);
}

.banner-text-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.banner-title {
  font-family: 'Manrope', sans-serif;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 12px;
  line-height: 1.1;
}

.banner-subtitle {
  font-size: 13px;
  color: var(--text-subtle);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.banner-disclaimer {
  font-size: 12px;
  color: var(--warn);
  font-weight: 500;
  margin-top: 6px;
}

.banner-badge {
  font-size: 11px;
  font-weight: 800;
  background: linear-gradient(135deg, #3B82F6, #8B5CF6);
  color: #FFF;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
}

.header-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; z-index: 2; }

.profile-switcher {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.profile-btn {
  border: none;
  background: transparent;
  color: var(--text-subtle);
  font-family: 'Manrope', sans-serif;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.profile-btn:hover {
  color: var(--text-main);
}

.profile-btn.active {
  background: var(--bg-card);
  color: var(--border-focus);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.profile-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.profile-btn:disabled:hover {
  color: var(--text-subtle);
}

.theme-toggle-btn, .privacy-toggle-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Manrope', sans-serif;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.theme-toggle-btn:hover, .privacy-toggle-btn:hover { border-color: var(--border-hover); }

.update-time {
  font-size: 12px;
  color: var(--text-muted);
  font-family: -apple-system, BlinkMacSystemFont, "SF Mono", monospace;
  text-align: right;
}

/* HERO OVERVIEW — card with the sparkline as a transparent full-bleed background */
.hero {
  position: relative;
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 26px 32px 22px;
  margin-bottom: 24px;
}

.hero-spark-bg {
  position: absolute;
  inset: 0;
  opacity: 0.5;
  pointer-events: none;
}

:root[data-theme="light"] .hero-spark-bg { opacity: 0.35; }

.hero-top {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 20px;
}

.hero-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.total-value-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.total-value {
  font-family: 'Manrope', sans-serif;
  font-size: 46px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
  min-height: 50px;
  min-width: 280px;
  display: inline-block;
}

.hero-stats {
  font-size: 15px;
  color: var(--text-muted);
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
}

.hero-stats strong {
  font-family: -apple-system, BlinkMacSystemFont, "SF Mono", monospace;
  color: var(--text-main);
  font-size: 16px;
}

.hero-top-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  min-width: 220px;
}

.change-pill {
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--gain-bg);
  color: var(--gain);
  white-space: nowrap;
}

.change-pill.neg { background: var(--loss-bg); color: var(--loss); }

.range-selector {
  display: flex;
  gap: 2px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}

.range-btn {
  border: none;
  background: transparent;
  color: var(--text-subtle);
  font-family: 'Manrope', sans-serif;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.range-btn:hover { color: var(--text-main); }
.range-btn.active { background: var(--bg-card); color: var(--border-focus); }

.hero-spark-range {
  font-size: 11px;
  color: var(--text-subtle);
}

.hero-mix-row {
  position: relative;
  z-index: 2;
  margin-top: 24px;
}

.hero-mix-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  margin-bottom: 8px;
}

.hero-mix-bar {
  display: flex;
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--border);
  box-shadow: 0 0 0 1px var(--border);
}

.hero-mix-seg { height: 100%; }
.hero-mix-seg.tfsa { background: var(--tfsa); }
.hero-mix-seg.fhsa { background: var(--fhsa); }
.hero-mix-seg.rrsp { background: var(--rrsp); }
.hero-mix-seg.nonreg { background: var(--nonreg); }

.hero-mix-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 9px;
  font-size: 12px;
  color: var(--text-muted);
}

.hero-mix-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* KPI CARDS */
.account-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.flip-card {
  flex: 1 1 270px;
  max-width: 340px;
  min-width: 240px;
  perspective: 1400px;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 260px;
  transition: transform 0.5s ease;
  transform-style: preserve-3d;
  cursor: pointer;
}

.flip-card.flipped .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card .flip-face {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.flip-card .flip-face.front {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.flip-card .flip-face.back {
  position: absolute;
  inset: 0;
  transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
}

.flip-hint {
  font-size: 11px;
  color: var(--text-subtle);
  text-align: center;
  margin-top: auto;
  padding-top: 8px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.kpi-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}

.kpi-card.tfsa::before { background: var(--tfsa); }
.kpi-card.fhsa::before { background: var(--fhsa); }
.kpi-card.rrsp::before { background: var(--rrsp); }
.kpi-card.nonreg::before { background: var(--nonreg); }

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.acct-title {
  font-family: 'Manrope', sans-serif;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.kpi-val {
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 38px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--text-main);
  margin: 8px 0 4px 0;
  min-height: 42px;
  position: relative;
}

.kpi-caption {
  font-size: 13px;
  color: var(--text-subtle);
  font-weight: 500;
  margin-bottom: 12px;
}

.kpi-bar {
  display: flex;
  height: 7px;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.kpi-bar-seg.deposited { background: var(--bar-deposit); }
.kpi-bar-seg.reinvested { background: var(--bar-reinvest); }
.kpi-bar-seg.unrealized { background: var(--bar-unrealized); }
.kpi-bar-seg.unrealized.neg { background: var(--loss); }

.kpi-legend {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-subtle);
  margin-bottom: 12px;
}

.legend-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
}
.legend-dot.deposited { background: var(--bar-deposit); }
.legend-dot.reinvested { background: var(--bar-reinvest); }
.legend-dot.unrealized { background: var(--bar-unrealized); }

.kpi-detail {
  border-top: 1px dashed var(--border);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Mono", monospace;
  color: var(--text-muted);
}

.kpi-detail-row span:last-child { color: var(--text-main); font-weight: 600; }
.kpi-detail-row span.pos { color: var(--gain); }
.kpi-detail-row span.neg { color: var(--loss); }
.kpi-detail-row.muted { font-size: 11px; color: var(--text-subtle); }
.kpi-detail-row.muted span:last-child { font-weight: 500; color: var(--text-subtle); }

.tab-pills {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 3px;
  gap: 2px;
}

.tab-pill {
  border: none;
  background: transparent;
  color: var(--text-subtle);
  font-family: 'Manrope', sans-serif;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-pill:hover { color: var(--text-main); }
.tab-pill.active { background: var(--bg-card); color: var(--border-focus); }

.gauge-view {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.gauge-view.hidden { display: none; }

.section-heading {
  font-size: 11px;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 800;
  margin: 28px 0 12px 2px;
}

.zone3 {
  display: block;
}

.side-nav {
  display: flex;
  flex-direction: row;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
}

@media (max-width: 860px) {
  .side-nav { display: none; }
}

.side-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px 13px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  border: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.side-nav-item:hover { color: var(--text-main); }

.side-nav-item.active {
  border-bottom-color: var(--border-focus);
  color: var(--text-main);
  font-weight: 700;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-subtle);
  transition: color 0.15s ease;
}

.side-nav-item.active .nav-icon { color: var(--border-focus); }

.bottom-tab .nav-icon {
  width: 18px;
  height: 18px;
  color: var(--text-subtle);
}

.bottom-tab.active .nav-icon { color: var(--border-focus); }

.zone3-content { min-width: 0; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.bottom-tabs {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  justify-content: space-around;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
}

@media (max-width: 860px) {
  .bottom-tabs { display: flex; }
  .app { padding-bottom: 76px; }
}

.bottom-tab {
  border: none;
  background: transparent;
  color: var(--text-subtle);
  font-family: 'Manrope', sans-serif;
  font-size: 10.5px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  cursor: pointer;
  flex: 1;
}

.bottom-tab.active { color: var(--border-focus); }

/* GRID & CARDS */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  display: flex;
  flex-direction: column;
}

.card h3 {
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  font-size: 17px;
  margin: 0 0 16px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-main);
  flex-wrap: wrap;
  gap: 8px;
}

.card h3 small {
  font-family: 'Manrope', sans-serif;
  font-size: 11px;
  color: var(--text-subtle);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* HOLDINGS GAUGE LAYOUT */
.gauge-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex: 1;
  min-height: 220px;
}

.gauge-canvas-wrapper {
  position: relative;
  width: 55%;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gauge-center-label {
  position: absolute;
  bottom: 4px;
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
}

.gauge-center-value {
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.02em;
  color: var(--text-main);
  line-height: 1.15;
}

.gauge-center-caption {
  font-size: 10.5px;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  margin-top: 3px;
}

.gauge-legend-list {
  width: 45%;
  max-height: 210px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  padding-right: 4px;
}

.donut-chart-wrap {
  position: relative;
  flex: 1;
  min-height: 220px;
  display: flex;
  align-items: center;
  width: 100%;
}

.gauge-legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: -apple-system, BlinkMacSystemFont, "SF Mono", monospace;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
}

.gauge-legend-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--text-main);
}

.gauge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}

.gauge-pct {
  color: var(--text-muted);
  font-weight: 500;
}

.gauge-legend-extra.hidden { display: none; }

.gauge-legend-toggle {
  display: block;
  width: 100%;
  margin-top: 2px;
  padding: 6px;
  background: none;
  border: none;
  border-radius: 6px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Mono", monospace;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--border-focus);
  cursor: pointer;
  text-align: center;
}
.gauge-legend-toggle:hover { background: rgba(255, 255, 255, 0.04); }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

@media (max-width: 1200px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* TABLES & TYPOGRAPHY FIXES */
.table-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 12px;
}

.asset-count-pill {
  font-size: 12px;
  background: rgba(59, 130, 246, 0.15);
  color: #3B82F6;
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 700;
  font-family: -apple-system, BlinkMacSystemFont, "SF Mono", monospace;
}

.search-input {
  font-family: 'Manrope', sans-serif;
  font-size: 13px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text-main);
  width: 240px;
  outline: none;
  transition: border-color 0.15s ease;
}

.search-input:focus { border-color: var(--border-focus); }

.scroll {
  max-height: 520px;
  overflow-y: auto;
  overflow-x: auto;
  position: relative;
  -webkit-overflow-scrolling: touch;
}

.scroll::-webkit-scrollbar { width: 6px; height: 6px; }
.scroll::-webkit-scrollbar-track { background: transparent; }
.scroll::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 4px; }

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
  table-layout: auto;
  min-width: 650px;
}

th {
  font-weight: 700;
  color: var(--text-subtle);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 12px 16px;
  height: 44px;
  box-sizing: border-box;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 20;
  white-space: nowrap;
}

td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-family: -apple-system, BlinkMacSystemFont, "SF Mono", monospace;
  font-size: 14px;
  color: var(--text-main);
  white-space: nowrap;
}

.col-ticker { width: 28%; text-align: left; }
.col-qty    { width: 22%; text-align: right; }
.col-gain   { width: 50%; text-align: right; }
.col-action { width: 10%; text-align: right; }

/* Dedicated 5-column widths for the Tax-Loss Harvesting Opportunities table
   (Ticker/Account, Shares Held, Unrealized Loss, Est. Tax Saved, action) --
   the shared .col-ticker/.col-qty/.col-gain/.col-action classes above were
   designed for 3-column tables and don't sum to 100% across 5 columns. */
.col-harvest-ticker    { width: 26%; text-align: left; }
.col-harvest-qty       { width: 16%; text-align: right; }
.col-harvest-loss      { width: 24%; text-align: right; }
.col-harvest-taxsaved  { width: 24%; text-align: right; }
.col-harvest-action    { width: 10%; text-align: right; }

.col-date   { width: 14%; text-align: left; }
.col-acct   { width: 16%; text-align: left; }

.col-h-ticker { width: 22%; text-align: left; }
.col-h-num    { width: 13%; text-align: right; }

.col-acb-ticker { width: 34%; text-align: left; }
.col-acb-num    { width: 22%; text-align: right; }

.ticker-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.company-logo {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: contain;
  background: #FFFFFF;
  padding: 2px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.logo-placeholder {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(139, 92, 246, 0.2));
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 10px;
  color: #60A5FA;
  flex-shrink: 0;
}

.ticker-symbol {
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  color: var(--text-main);
  font-size: 15px;
  letter-spacing: 0.02em;
}

tr.ticker-row { cursor: pointer; transition: background 0.15s ease; }
tr.ticker-row:hover { background: var(--bg-card-hover); }

.chevron {
  display: inline-block;
  width: 12px;
  text-align: center;
  transition: transform 0.15s ease;
  color: var(--text-subtle);
  font-size: 11px;
  vertical-align: middle;
}
.chevron.open { transform: rotate(90deg); }

tr.detail-row > td {
  padding: 0 !important;
  background: var(--bg-card-hover);
  border-bottom: 1px solid var(--border);
}
tr.detail-row.hidden { display: none; }

.nested-detail-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: auto;
}

.nested-detail-table th {
  background: var(--bg-input);
  font-size: 11px;
  color: var(--text-subtle);
  padding: 10px 6px;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: sticky;
  top: 44px;
  z-index: 10;
}

.nested-detail-table td {
  font-size: 13px;
  padding: 10px 6px;
  border-bottom: 1px solid var(--border);
}

/* Marks a ticker rename/reorg row (e.g. PTK -> POET) in the ACB Audit Trail
   so the continuity point in a position's history stands out from ordinary
   buys/sells instead of blending in as just another row. */
.ledger-milestone-row td {
  background: color-mix(in srgb, var(--border-focus) 10%, transparent);
  font-weight: 600;
}

.acct-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
  vertical-align: middle;
}
.acct-dot.tfsa { background: var(--tfsa); }
.acct-dot.fhsa { background: var(--fhsa); }
.acct-dot.rrsp { background: var(--rrsp); }
.acct-dot.nonreg { background: var(--nonreg); }

.pos { color: var(--gain); font-weight: 600; }
.neg { color: var(--loss); font-weight: 600; }

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 700;
  font-family: -apple-system, BlinkMacSystemFont, "SF Mono", monospace;
}
.badge.pos { background: var(--gain-bg); color: var(--gain); }
.badge.neg { background: var(--loss-bg); color: var(--loss); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }

/* MOBILE ROW CARDS — tables become cards at <=860px (same breakpoint the
   app already switches to bottom-tab nav), instead of horizontal scroll. */
.row-card-list { display: none; flex-direction: column; gap: 10px; }

.row-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  /* No overflow:hidden here — an ancestor with any overflow other than
     visible becomes the containing block for a sticky descendant, and
     since this element itself never scrolls, that silently disables the
     sticky header below. Rounding is handled by matching corners on
     .row-card-head instead of by clipping. */
}

.row-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-card);
  border-radius: 12px;
}
.row-card.expandable .row-card-head { cursor: pointer; }

/* While a card is open, pin its head to the top of the screen as you
   scroll through a long detail list (e.g. VT with 20+ dividend
   payments), so it's always clear which card you're in — and it stays
   tappable to collapse back. */
.row-card.expandable.open .row-card-head {
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--border);
}

.row-card-left { display: flex; align-items: center; gap: 10px; min-width: 0; }

.row-card-title-group { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.row-card-title {
  font-family: 'Manrope', sans-serif;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-card-subtitle {
  font-size: 11px;
  color: var(--text-subtle);
  font-family: -apple-system, BlinkMacSystemFont, "SF Mono", monospace;
}

.row-card-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.row-card-value-group { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.row-card-value {
  font-family: -apple-system, BlinkMacSystemFont, "SF Mono", monospace;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main);
}
.row-card-value.pos { color: var(--gain); }
.row-card-value.neg { color: var(--loss); }

.row-card-chevron {
  font-size: 9px;
  color: var(--text-subtle);
  transition: transform 0.15s ease;
  display: inline-block;
}
.row-card.open .row-card-chevron { transform: rotate(90deg); }

.row-card-detail { display: none; padding: 0 14px 14px; border-top: 1px solid var(--border); }
.row-card.open .row-card-detail { display: block; padding-top: 12px; }

.row-card-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }

.detail-field { display: flex; flex-direction: column; gap: 2px; }
.detail-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-subtle);
  font-weight: 700;
}
.detail-val {
  font-family: -apple-system, BlinkMacSystemFont, "SF Mono", monospace;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
}
.detail-val.pos { color: var(--gain); }
.detail-val.neg { color: var(--loss); }

.row-card-acct-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.row-card-acct-row { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; }
.row-card-acct-row-left { display: flex; align-items: center; color: var(--text-muted); }
.row-card-acct-row-right {
  font-family: -apple-system, BlinkMacSystemFont, "SF Mono", monospace;
  color: var(--text-main);
  font-weight: 600;
}

.row-card-acct-header {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
  padding: 10px 0 6px;
}
.row-card-acct-header strong { font-family: 'Manrope', sans-serif; font-size: 13px; color: var(--text-main); }
.row-card-blended-note { font-size: 11px; color: var(--text-subtle); font-weight: 500; }

.row-card-nested-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 10px; }
.row-card-nested-scroll .nested-detail-table { min-width: 560px; }

.row-card-txn-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.row-card-txn:not(:first-child) {
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.row-card-txn-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.row-card-txn-head-left { display: flex; align-items: center; }
.row-card-txn-head-right {
  font-family: -apple-system, BlinkMacSystemFont, "SF Mono", monospace;
  font-weight: 700;
  color: var(--text-main);
}
.row-card-txn-head-right.pos { color: var(--gain); }
.row-card-txn-head-right.neg { color: var(--loss); }
.row-card-txn-grid { grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.row-card-txn-grid .detail-label { font-size: 9px; }
.row-card-txn-grid .detail-val { font-size: 11.5px; }

.row-card-footer { padding: 0 14px 14px; }
.row-card-footer .btn-harvest-sim { width: 100%; text-align: center; }

.row-card-empty { text-align: center; color: var(--text-subtle); padding: 24px; font-size: 13px; }

@media (max-width: 860px) {
  .scroll { display: none; }
  .row-card-list { display: flex; }
}

.stale-price-badge, .superficial-loss-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 700;
  vertical-align: middle;
  background: var(--warn-bg);
  color: var(--warn);
  cursor: help;
}

.tax-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: -apple-system, BlinkMacSystemFont, "SF Mono", monospace;
  font-size: 13.5px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
  color: var(--text-muted);
}

.tax-line span:last-child { color: var(--text-main); font-weight: 600; }

.tax-line.total {
  border-bottom: none;
  font-weight: 700;
  padding-top: 14px;
  font-size: 15px;
  color: var(--text-main);
}

.tax-section {
  margin-bottom: 4px;
}

.tax-section-label {
  font-size: 11px;
  color: var(--text-subtle);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 16px 0 6px 0;
}

.tax-section:first-of-type .tax-section-label { margin-top: 0; }

.tax-line.sub {
  font-size: 12px;
  color: var(--text-subtle);
  padding: 6px 0;
}
.tax-line.sub span:last-child { color: var(--text-subtle); font-weight: 500; }

.tax-warning-banner {
  background: var(--warn-bg);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.tax-warning-banner svg { flex-shrink: 0; margin-top: 1px; }

.tax-warning-banner p {
  font-size: 12px;
  color: var(--warn);
  margin: 0;
  line-height: 1.5;
  font-weight: 600;
}

/* SIMULATION INPUTS STRIP (Tax Liability card) */
.sim-inputs {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding: 14px 16px;
  background: var(--bg-input);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.sim-input-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1 1 140px;
  min-width: 130px;
}

.sim-input-group label {
  font-size: 10.5px;
  color: var(--text-subtle);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.sim-input-group input,
.sim-input-group select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-family: 'Manrope', sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 10px;
  border-radius: 6px;
  outline: none;
  width: 100%;
  height: 36px;
}

.sim-input-group input:focus,
.sim-input-group select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.sim-input-group input::-webkit-outer-spin-button,
.sim-input-group input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.fire-readonly-value {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-subtle);
  font-family: 'Manrope', sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 10px;
  border-radius: 6px;
  height: 36px;
  display: flex;
  align-items: center;
}

.fire-advanced-toggle {
  background: none;
  border: none;
  color: var(--border-focus);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  padding: 8px 0 0 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.fire-advanced-toggle:hover {
  text-decoration: underline;
}

.small-note {
  font-size: 11.5px;
  color: var(--text-subtle);
  margin-top: 2px;
}

.sim-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 6px;
}

@media (max-width: 640px) {
  .sim-compare { grid-template-columns: 1fr; }
}

.sim-compare-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}

.sim-compare-card.warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
}

.sim-compare-label {
  font-size: 11px;
  color: var(--text-subtle);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.sim-compare-card.warn .sim-compare-label { color: var(--warn); }

.sim-compare-val {
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 24px;
  font-weight: 800;
  color: var(--text-main);
}

.sim-compare-card.warn .sim-compare-val { color: var(--warn); }

.sim-delta-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 18px;
  background: var(--loss-bg);
  color: var(--loss);
  padding: 8px 14px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 13.5px;
}

.sim-delta-pill.pos { background: var(--gain-bg); color: var(--gain); }

/* NET POSITION HERO */
.net-position {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-input);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 18px;
  border-left: 4px solid var(--gain);
}

.net-position.neg { border-left-color: var(--loss); }

.net-position-label {
  font-size: 11px;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.net-position-value {
  font-size: 27px;
  font-weight: 800;
  margin-top: 4px;
  color: var(--gain);
}

.net-position-value.neg { color: var(--loss); }

.net-position-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* BRACKET BAR */
.bracket-box { margin-bottom: 18px; }

.bracket-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.bracket-bar {
  position: relative;
  height: 10px;
  border-radius: 6px;
  background: var(--bg-input);
  overflow: visible;
}

.bracket-seg { position: absolute; top: 0; height: 100%; }

.bracket-marker {
  position: absolute;
  top: -3px;
  width: 16px;
  height: 16px;
  background: var(--text-main);
  border: 3px solid var(--bg-card);
  border-radius: 50%;
  transform: translateX(-50%);
  box-shadow: 0 0 0 1px var(--border-hover);
}

/* COLLAPSIBLE FULL BREAKDOWN */
.tax-details {
  background: var(--bg-input);
  border-radius: 10px;
  padding: 12px 16px;
  border: 1px solid var(--border);
}

.tax-details summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
}

.tax-details-body { margin-top: 8px; }

select {
  font-family: 'Manrope', sans-serif;
  font-size: 13px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-input);
  color: var(--text-main);
}

.clear-btn {
  font-size: 12px;
  color: var(--text-subtle);
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  font-family: 'Manrope', sans-serif;
}

.clear-btn:hover { color: var(--text-muted); }

@media (max-width: 1200px) {
  .grid { grid-template-columns: 1fr; }
  .hero-top { flex-direction: column; align-items: flex-start; }
  .hero-top-right { width: 100%; align-items: flex-start; }
  .range-selector { align-self: flex-start; }
  .app-banner { flex-direction: column; align-items: flex-start; padding: 24px; }
}

@media (max-width: 768px) {
  .app {
    padding: 12px 10px 76px;
  }
  .app-banner {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    padding: 20px;
  }
  .banner-content {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .banner-logo-wrap {
    width: 60px;
    height: 60px;
  }
  .banner-title {
    font-size: 22px;
    justify-content: center;
  }
  .header-actions {
    justify-content: space-between;
    width: 100%;
  }
  .total-value {
    font-size: 34px;
    min-width: 190px;
  }
  .hero-top-right {
    align-items: stretch;
    width: 100%;
    min-width: 0;
  }
  .range-selector {
    justify-content: space-between;
  }
  .range-btn {
    padding: 4px 6px;
    font-size: 10px;
  }
  .kpi-val {
    font-size: 30px;
  }
  .card {
    padding: 14px;
  }
  .search-input {
    width: 100%;
  }
  .gauge-container {
    flex-direction: column;
    align-items: stretch;
  }
  .gauge-canvas-wrapper, .gauge-legend-list {
    width: 100%;
  }
  .gauge-canvas-wrapper {
    height: 180px;
  }
  .gauge-legend-list {
    max-height: none;
    overflow-y: visible;
  }
  .donut-chart-wrap {
    min-height: 160px;
  }
  .sim-inputs {
    flex-direction: column;
  }
  .net-position {
    padding: 14px 16px;
  }
  .net-position-value {
    font-size: 22px;
  }
  .card-header-flex {
    flex-wrap: wrap;
    gap: 12px;
  }
  .btn-export {
    white-space: nowrap;
  }
  
  table {
    font-size: 12.5px;
  }
  th, td {
    padding: 10px 12px;
  }
  .tax-line {
    font-size: 12.5px;
    flex-wrap: wrap;
    row-gap: 2px;
  }
  .tax-line span:last-child {
    width: 100%;
    text-align: left;
  }
}

/* =========================================================================
   TAX & ACB DASHBOARD (redesigned)
   ========================================================================= */

.tax-global-settings-card {
  margin-bottom: 24px;
}
.tax-global-settings-row, .fire-settings-row {
  display: flex;
  align-items: flex-end;
  gap: 20px;
  flex-wrap: wrap;
  width: fit-content;
  padding: 16px 20px;
  background: var(--bg-input);
  border-radius: 10px;
  border: 1px solid var(--border);
}
.tax-global-settings-row .sim-input-group,
.fire-settings-row .sim-input-group {
  flex: 0 0 auto;
}

.tax-dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 24px;
  align-items: start;
}

.tax-dashboard-main {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.btn-export {
  background: #1e293b;
  color: #fff;
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}
.btn-export:hover {
  background: #334155;
}

.btn-harvest-sim {
  background: transparent;
  color: var(--border-focus);
  border: 1px solid var(--border-focus);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-harvest-sim:hover {
  background: var(--bg-card-hover);
}

.tax-dashboard-header-card .card-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.tax-kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 20px 0;
}
.fire-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
  margin: 20px 0;
}
.fire-col-label { text-align: left; }
.fire-col-num { text-align: right; }

.fire-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-subtle);
}
.fire-chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.fire-legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.fire-legend-dash {
  width: 16px;
  height: 0;
  border-top: 2px dashed rgba(148, 163, 184, 0.9);
  border-radius: 0;
}

.fire-verdict-row {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-top: 20px;
}
.fire-gauge-wrap {
  position: relative;
  width: 120px;
  height: 120px;
  flex-shrink: 0;
}
.fire-verdict-callout {
  flex: 1;
  min-width: 240px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-radius: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
}
.fire-verdict-callout.tone-good { background: var(--gain-bg); border-color: rgba(16, 185, 129, 0.3); }
.fire-verdict-callout.tone-fair { background: var(--warn-bg); border-color: var(--warn-border); }
.fire-verdict-callout.tone-poor { background: var(--loss-bg); border-color: rgba(244, 63, 94, 0.3); }
.fire-verdict-icon {
  display: inline-flex;
  flex-shrink: 0;
}
.fire-verdict-callout p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-main);
}
.fire-verdict-callout strong { font-weight: 800; }

.mobile-tooltip-bubble {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.mobile-tooltip-bubble.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.tax-kpi-box {
  position: relative;
  background: var(--bg-input);
  border-radius: 10px;
  padding: 20px;
  border: 1px solid var(--border);
}
/* Every KPI box carries an explanatory `title` (native tooltip on hover,
   tap-to-show bubble on touch — see the mobile-tooltip-bubble handler).
   A bare div gives no hint that's there, so surface a small info glyph.
   Uses the [title] attribute selector rather than a class so it also
   picks up titles assigned dynamically after render (e.g. kpiBoxRefund).
   A mask-image (the same lucide-style info icon used elsewhere in the
   app) is used instead of a text glyph — a font's "i" doesn't sit
   optically centered in a circle at this size, an SVG shape does. */
.tax-kpi-box[title]::after {
  content: "";
  position: absolute;
  top: 10px;
  right: 10px;
  width: 14px;
  height: 14px;
  background-color: var(--text-subtle);
  opacity: 0.5;
  pointer-events: none;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='16' x2='12' y2='12'/%3E%3Cline x1='12' y1='8' x2='12.01' y2='8'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='16' x2='12' y2='12'/%3E%3Cline x1='12' y1='8' x2='12.01' y2='8'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}
.tax-kpi-box.green {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.2);
}
.tax-kpi-box.red {
  background: rgba(244, 63, 94, 0.05);
  border-color: rgba(244, 63, 94, 0.2);
}
.tax-kpi-box .kpi-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-subtle);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.tax-kpi-box .kpi-val-text {
  font-family: 'Manrope', sans-serif;
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.tax-context-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.tax-context-box {
  background: var(--bg-input);
  border-radius: 10px;
  padding: 20px;
  border: 1px solid var(--border);
}
.context-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-subtle);
  margin: 0 0 16px 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.context-list-item {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 12px;
  color: var(--text-muted);
}
.context-list-item:last-child {
  margin-bottom: 0;
}
.context-list-item span:last-child {
  font-weight: 700;
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "SF Mono", monospace;
}
/* Let pos/neg colors win over the default value color above */
.context-list-item span.pos:last-child { color: var(--gain); }
.context-list-item span.neg:last-child { color: var(--loss); }

/* Real monthly realized P&L bars (JS generated) */
.trend-bars {
  display: flex;
  height: 100%;
  align-items: flex-end;
  gap: 3px;
}
.trend-bar-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 4px;
}
.trend-bar {
  width: 100%;
  border-radius: 3px 3px 0 0;
  min-height: 3px;
}
.trend-bar.pos { background: var(--gain); }
.trend-bar.neg { background: var(--loss); }
.trend-bar.empty { background: var(--border); }
.trend-bar-stack {
  width: 100%;
  display: flex;
  flex-direction: column-reverse;
  border-radius: 3px 3px 0 0;
  overflow: hidden;
  min-height: 3px;
}
.trend-bar-actual { width: 100%; }
.trend-bar-actual.pos { background: var(--gain); }
.trend-bar-actual.empty { background: var(--border); }
.trend-bar-projected {
  width: 100%;
  min-height: 3px;
  background-color: var(--gain-bg);
  background-image: repeating-linear-gradient(45deg, var(--gain) 0, var(--gain) 3px, transparent 3px, transparent 7px);
}
.trend-bar-label {
  font-size: 9px;
  color: var(--text-subtle);
  font-weight: 600;
  text-transform: uppercase;
}
.trend-empty-note {
  width: 100%;
  align-self: center;
  text-align: center;
  color: var(--text-subtle);
  font-size: 12px;
}

/* Realized P&L bars: capital gain/loss (its own scale, diverging around
   zero) stacked above a compact dividends strip (its own, independent
   scale) per month, so a handful of dollars in dividends stays legible
   next to a five-figure capital gain instead of being crushed to a
   sliver on a shared axis. Distinct classes from .trend-bar* above,
   which the Dividends tab chart still uses. */
.pnl-legend {
  display: flex;
  gap: 14px;
  margin: -8px 0 14px;
  font-size: 11px;
  color: var(--text-subtle);
}
.pnl-legend span { display: inline-flex; align-items: center; gap: 5px; }
.pnl-legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.pnl-legend i.div { background: var(--dividend); }
.pnl-legend i.gain { background: var(--gain); }
.pnl-legend i.loss { background: var(--loss); }

.pnl-chart { display: flex; flex-direction: column; height: 100%; }
.pnl-bars-row {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: stretch;
  gap: 3px;
}
.pnl-bar-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}
.pnl-gain-cell { flex: 1; min-height: 0; position: relative; }
.pnl-zero-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
}
.pnl-seg {
  position: absolute;
  left: 0;
  right: 0;
  min-height: 2px;
}
.pnl-seg-gain.pos { background: var(--gain); border-radius: 3px 3px 0 0; }
.pnl-seg-gain.neg { background: var(--loss); border-radius: 0 0 3px 3px; }
.pnl-seg-empty { background: var(--border); height: 3px; border-radius: 3px; }
.pnl-div-cell {
  flex: 0 0 28px;
  position: relative;
  margin-top: 6px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}
.pnl-seg-div-mini {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--dividend);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
}
.pnl-seg-div-mini.empty { background: var(--border); height: 2px; border-radius: 2px; }
.pnl-bar-labels-row {
  flex: 0 0 auto;
  display: flex;
  gap: 3px;
  margin-top: 4px;
}
.pnl-bar-labels-row span {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 9px;
  color: var(--text-subtle);
  font-weight: 600;
  text-transform: uppercase;
}

.simulator-section {
  padding-bottom: 24px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.simulator-section.last {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}
.sim-sec-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 16px 0;
}

.tax-impact-list {
  margin: 4px 0 16px;
}

.stat-mini-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  text-align: center;
}
.stat-mini {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--bg-input);
  border-radius: 8px;
  padding: 8px 6px;
}
.stat-mini-label {
  font-size: 9.5px;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
}
.stat-mini-val {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "SF Mono", monospace;
}

/* Redesigned simulator card shell */
.sim-card {
  padding: 0;
  overflow: hidden;
}
.sim-card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-input);
}
.sim-card-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

/* Safari ignores plain -webkit-appearance:none on <input type=range> unless
   the track is *also* styled explicitly via ::-webkit-slider-runnable-track
   — otherwise it silently falls back to its own tiny native "compact"
   slider (the toggle-switch look). Styling the track directly fixes that. */
.sim-input-group .sim-slider {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  min-width: 0;
  flex: 1 1 auto;
  height: 20px;
  background: transparent;
  border: none;
  padding: 0;
  border-radius: 0;
  outline: none;
  cursor: pointer;
  margin: 0;
}
.sim-slider::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  background: var(--border-hover);
  border-radius: 4px;
}
.sim-slider::-moz-range-track {
  width: 100%;
  height: 6px;
  background: var(--border-hover);
  border-radius: 4px;
  border: none;
}
.sim-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -7px; /* (thumb height - track height) / 2, centers thumb on track */
  border-radius: 50%;
  background: var(--border-focus);
  border: 3px solid var(--bg-card);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.sim-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--border-focus);
  border: 3px solid var(--bg-card);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.sim-slider::-moz-range-progress {
  height: 6px;
  background: var(--border-focus);
  border-radius: 4px;
}
.sim-input-group .sim-num-input {
  width: 80px;
  text-align: center;
  flex-shrink: 0;
}

@media (max-width: 1024px) {
  .tax-dashboard-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .tax-kpi-row {
    grid-template-columns: 1fr;
  }
  .tax-context-row {
    grid-template-columns: 1fr;
  }
  .fire-kpi-row {
    grid-template-columns: 1fr;
  }
}

/* Between 1024-1400px the two-column tax layout is still active, but the
   380px What-If sidebar leaves the sells/ACB tables too narrow for their
   column count, forcing a horizontal scroll. Drop to single column earlier
   than the general 1024px breakpoint above so those tables get full width. */
@media (max-width: 1400px) {
  .tax-dashboard-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Ticker-picker modal: search-and-pick fallback when a symbol can't be
   auto-resolved to a price feed. */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal.hidden { display: none; }
.modal-content {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 24px;
  border-radius: 14px;
  max-width: 400px;
  width: 90%;
}
.modal-content h3 { margin-top: 0; }
.ticker-pick-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  margin-bottom: 6px;
  cursor: pointer;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-main);
}
.ticker-pick-option:hover { border-color: var(--border-hover); }
#tickerPickerCancel {
  margin-top: 8px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-main);
  cursor: pointer;
}

/* How to Export tab - numbered onboarding steps */
.guide-step {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}
.guide-step:first-of-type { border-top: none; }
.guide-step-num {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}
.guide-step-title {
  display: block;
  margin-bottom: 2px;
  color: var(--text-main);
}
.guide-step .small-note { margin: 0; }
.guide-checklist {
  margin: 0;
  padding-left: 20px;
  color: var(--text-subtle);
  font-size: 13px;
  line-height: 1.5;
}
.guide-checklist li { margin-bottom: 4px; }
.guide-checklist strong { color: var(--text-main); }