/* =========================================================================
   ConCap Client Dashboard — refreshed stylesheet
   Design language borrowed from homepage.html: flat surfaces, 1px borders,
   compact type, CSS-variable theming, sidebar + tab-panel shell.
   Accent is ConCap teal so the brand still reads.
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

/* ── Tokens ────────────────────────────────────────────────────────────── */
:root {
  --bg:          #f6f8fa;
  --surface:     #ffffff;
  --surface2:    #f0f2f5;
  --surface3:    #e7eaee;
  --border:      #d8dee4;
  --border-soft: #e8ecf0;
  --text:        #1f2328;
  --text2:       #656d76;
  --text3:       #8c959f;

  --accent:      #00787d;
  --accent-rgb:  0, 120, 125;
  --accent-hi:   #009999;
  --accent-soft: rgba(0, 152, 153, 0.10);
  --accent-line: rgba(0, 152, 153, 0.35);

  --green:  #1a7f37;
  --red:    #cf222e;
  --yellow: #9a6700;
  --purple: #8250df;
  --blue:   #0969da;
  --orange: #bc4c00;

  --shadow-sm: 0 1px 2px rgba(27, 31, 36, 0.06);
  --shadow-md: 0 4px 16px rgba(27, 31, 36, 0.08);
  --shadow-lg: 0 16px 48px rgba(27, 31, 36, 0.18);

  --radius:    10px;
  --radius-sm: 7px;
  --sidebar-w: 244px;
  --sidebar-w-collapsed: 56px;
  --topbar-h:  56px;
}

html.dark {
  --bg:          #0d1117;
  --surface:     #161b22;
  --surface2:    #21262d;
  --surface3:    #2b313a;
  --border:      #30363d;
  --border-soft: #262c34;
  --text:        #e6edf3;
  --text2:       #9aa4b0;
  --text3:       #767f8a;

  --accent:      #2dd4bf;
  --accent-rgb:  45, 212, 191;
  --accent-hi:   #5eead4;
  --accent-soft: rgba(45, 212, 191, 0.12);
  --accent-line: rgba(45, 212, 191, 0.40);

  --green:  #3fb950;
  --red:    #f85149;
  --yellow: #d29922;
  --purple: #a371f7;
  --blue:   #58a6ff;
  --orange: #f0883e;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.6);
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
ul, ol { list-style: none; }
a { text-decoration: none; color: inherit; }

html { color-scheme: light; }
html.dark { color-scheme: dark; }

body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  display: flex;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent-soft); }

/* ── Custom background layer ────────────────────────────────────────────────
   Fixed behind the whole app. Hidden until a gradient/image is chosen; a solid
   colour goes straight to --bg instead and never needs this. */
#app-bg { display: none; }
html.has-custom-bg #app-bg {
  display: block;
  position: fixed; inset: 0; z-index: -1;
  overflow: hidden; pointer-events: none;
}
/* Body's own fill would sit over a z-index:-1 layer, so drop it while a custom
   background is showing; the sidebar/cards keep their own opaque surfaces. */
html.has-custom-bg body { background: transparent; }
#app-bg-media {
  position: absolute;
  /* oversized so blur() doesn't bleed transparent edges into view */
  inset: -40px;
  background-position: center; background-size: cover; background-repeat: no-repeat;
  /* Matte shown when the image is zoomed out below cover — themed, so a
     letterboxed background reads as intentional rather than a gap. */
  background-color: var(--bg);
}
#app-bg::after {   /* dim scrim — sits over the (blurred) media, itself unblurred */
  content: ''; position: absolute; inset: 0;
  background: var(--app-bg-scrim, transparent);
}

/* Text that floats directly on the wallpaper (page headings, section labels)
   gets a halo in the theme's backdrop colour — a light glow in light mode, a
   dark one in dark mode — so it stays legible over any colour or image. The
   card content needs none of this; it sits on opaque surfaces. */
:root      { --bg-halo: rgba(255, 255, 255, 0.85); }
html.dark  { --bg-halo: rgba(0, 0, 0, 0.85); }
html.bg-active .page-header h1,
html.bg-active .page-header small,
html.bg-active .section-label,
html.bg-active #podcast-header {
  text-shadow: 0 0 2px var(--bg-halo), 0 0 10px var(--bg-halo), 0 1px 2px var(--bg-halo);
}

/* Scrollbars — thin and quiet, like homepage */
* { scrollbar-width: thin; scrollbar-color: var(--surface3) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text3); background-clip: padding-box; }
.no-scrollbar::-webkit-scrollbar { display: none; }

/* =========================================================================
   SIDEBAR
   ========================================================================= */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease, min-width 0.2s ease, transform 0.25s ease;
  z-index: 40;
}
.sidebar.collapsed {
  width: var(--sidebar-w-collapsed);
  min-width: var(--sidebar-w-collapsed);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  /* Logo centres across the full header; the toggle floats over it on the left
     (absolute) so it doesn't shove the logo off-centre. */
  justify-content: center;
  position: relative;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  /* Exactly the topbar's height, not a minimum — the 34px logo plus the old
     14/12 padding pushed this to 60px, so its bottom rule sat 4px below the
     topbar's and the seam between them visibly stepped. */
  height: var(--topbar-h);
}
.sidebar-toggle {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text2);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--surface2); color: var(--text); }

.brand-mark {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  white-space: nowrap;
}
/* logo.png is white artwork on transparency (verified: pure greyscale, zero
   chroma), so it disappears against the light sidebar. Inverting maps white to
   near-black and carries the antialiased grey edges down with it, which keeps
   the mark crisp — unlike brightness(0), which would crush those edge pixels
   flat. Dark mode wants the artwork exactly as authored, so no filter there. */
.brand-logo {
  height: 34px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  display: block;
  filter: invert(1);
}
html.dark .brand-logo { filter: none; }

/* Periodic shimmer — a warm gold glint sweeps across the mark (the logo PNG
   masks it to the artwork, so the light rides the actual shape, C and all).
   Gold reads on both the inverted-dark logo and the white dark-mode logo, and
   nods to the "reaching financial freedom" spirit. */
.brand-logo-wrap { position: relative; display: inline-flex; }
.brand-logo-wrap::after {
  content: '';
  position: absolute; inset: 0;
  pointer-events: none;
  -webkit-mask: url('https://www.concapadvisory.com/dashboard/img/logo.png') center / contain no-repeat;
          mask: url('https://www.concapadvisory.com/dashboard/img/logo.png') center / contain no-repeat;
  /* Wide, bright warm band so the glint clearly reads even at the sidebar's
     small size. Painted directly (not screen-blended) so it shows on both the
     inverted-dark light-mode logo and the white dark-mode logo. */
  background-image: linear-gradient(105deg,
    transparent 30%,
    rgba(255, 226, 165, 0.18) 42%,
    rgba(255, 242, 212, 0.65) 50%,
    rgba(255, 226, 165, 0.18) 58%,
    transparent 70%);
  background-repeat: no-repeat;
  background-size: 260% 100%;
  background-position: -60% 0;
  animation: brand-shimmer 9s ease-in-out infinite;   /* slow & occasional */
}
@keyframes brand-shimmer {
  0%   { background-position: -60% 0; }   /* parked off the left … */
  15%  { background-position: 160% 0; }   /* … a slow ~1.3s glide … */
  100% { background-position: 160% 0; }   /* … then a long rest before the next */
}
@keyframes brand-glow { 0%, 100% { opacity: 0; } 50% { opacity: 1; } }
/* Reduced motion: no lateral sliding — a gentle gold glow that breathes in and
   out, so the mark still feels alive without movement that could unsettle. */
@media (prefers-reduced-motion: reduce) {
  .brand-logo-wrap::after {
    background: radial-gradient(120% 150% at 50% 50%, rgba(255, 240, 205, 0.5), transparent 66%);
    animation: brand-glow 9s ease-in-out infinite;
  }
}
.brand-wordmark {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.brand-wordmark sup { font-size: 8px; color: var(--text3); }
.sidebar.collapsed .brand-mark { display: none; }
/* Logo is hidden when collapsed, so centre the lone hamburger in the narrow bar. */
.sidebar.collapsed .sidebar-toggle { left: 50%; transform: translate(-50%, -50%); }

/* Client identity block — the avatar is the one personal touch in the
   chrome, so it gets real estate rather than being a 34px afterthought. */
.sidebar-user {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  padding: 20px 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  text-align: center;
}
.sidebar-user #avatarImageURL {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 2px var(--accent-line), var(--shadow-sm);
  transition: width 0.2s, height 0.2s;
}
.sidebar-user #avatarImageURL img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sidebar-user #avatarImageURL i { font-size: 58px; line-height: 1; }

/* A slow teal highlight orbits the avatar's ring — the same "quietly alive"
   idea as the logo shimmer. The wrapper exists because the avatar clips its own
   overflow (to round the photo), which would otherwise cut the ring off. */
.avatar-ring { position: relative; display: inline-flex; border-radius: 50%; flex-shrink: 0; }
.avatar-ring #avatarImageURL { position: relative; z-index: 1; }
.avatar-ring::before {
  content: '';
  position: absolute; inset: -4px;
  border-radius: 50%;
  z-index: 0;
  pointer-events: none;
  background: conic-gradient(from 0deg,
    transparent 0deg, transparent 250deg,
    var(--accent-hi) 320deg,
    transparent 360deg);
  animation: avatar-ring 30s linear infinite;
}
@keyframes avatar-ring { to { transform: rotate(1turn); } }
/* Reduced motion: no spin — a soft teal ring that gently breathes instead. */
@keyframes avatar-ring-glow { 0%, 100% { opacity: 0.2; } 50% { opacity: 0.75; } }
@media (prefers-reduced-motion: reduce) {
  .avatar-ring::before {
    background: radial-gradient(farthest-side, transparent calc(100% - 5px), var(--accent-hi) calc(100% - 5px));
    animation: avatar-ring-glow 9s ease-in-out infinite;
  }
}
.sidebar-user .user-meta { overflow: hidden; white-space: nowrap; }
.sidebar-user h3 { font-size: 14px; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; }
.sidebar-user span { font-size: 11px; color: var(--text3); }
.sidebar.collapsed .sidebar-user { padding: 12px 0; }
.sidebar.collapsed .sidebar-user #avatarImageURL { width: 34px; height: 34px; box-shadow: none; }
.sidebar.collapsed .sidebar-user #avatarImageURL i { font-size: 20px; }
.sidebar.collapsed .sidebar-user .user-meta { display: none; }

/* Nav */
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 0; }
.menu-head {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text3);
  padding: 10px 18px 4px;
}
.sidebar.collapsed .menu-head { text-align: center; padding: 10px 0 4px; font-size: 0; }
.sidebar.collapsed .menu-head::after { content: '···'; font-size: 11px; letter-spacing: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 1px 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  border-left: 2px solid transparent;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  border-left-color: var(--accent);
}
.nav-icon { width: 18px; text-align: center; font-size: 14px; flex-shrink: 0; }
.nav-label { overflow: hidden; text-overflow: ellipsis; }
.nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  border-radius: 20px;
  padding: 0 6px;
  line-height: 16px;
}
html.dark .nav-badge { color: #06231f; }
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-badge { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 8px 0; margin: 1px 6px; }

/* Sidebar external links reuse .nav-item but render as anchors */
.nav-icon img { width: 16px; height: 16px; object-fit: contain; display: block; margin: 0 auto; }
a.nav-item .nav-icon i { font-size: 13px; }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 8px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.side-btn {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
}
.side-btn:hover { background: var(--surface2); color: var(--text); }
.side-btn .nav-icon { font-size: 14px; }
.sidebar.collapsed .side-btn { justify-content: center; }
.sidebar.collapsed .side-btn .side-label { display: none; }

/* Mobile scrim */
.sidebar-scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 35;
}
body.nav-open .sidebar-scrim { display: block; }

/* =========================================================================
   MAIN SHELL
   ========================================================================= */
.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#header-bar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 20;
}
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text2);
  font-size: 16px;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
}
.menu-toggle:hover { background: var(--surface2); color: var(--text); }

.topbar-title {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-sub {
  font-size: 11.5px;
  color: var(--text3);
  white-space: nowrap;
}
.topbar-spacer { flex: 1; }
.header-actions { display: flex; align-items: center; gap: 8px; }

main {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 64px;
  scroll-behavior: smooth;
}

.tab-panel { display: none; max-width: 1360px; }
.tab-panel.active { display: block; animation: panel-in 0.22s ease; }
@keyframes panel-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* =========================================================================
   PAGE HEADERS / SECTION FURNITURE
   ========================================================================= */
.page-header { margin-bottom: 16px; }
.page-header h1 {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--text);
}
.page-header small {
  display: block;
  margin-top: 6px;
  max-width: 78ch;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text2);
}
.page-header-top-spacer { height: 8px; }
#key-stats:empty { display: none; }

.section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text3);
  margin: 28px 0 10px;
}
.rule { height: 1px; background: var(--border); border: 0; margin: 28px 0; }

.pill-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  border-radius: 20px;
  padding: 2px 9px;
  vertical-align: middle;
  background: var(--surface2);
  color: var(--text2);
  border: 1px solid var(--border);
}
.pill-tag.beta { background: rgba(210, 153, 34, 0.12); color: var(--yellow); border-color: rgba(210, 153, 34, 0.35); }

/* =========================================================================
   CARDS
   ========================================================================= */
.card-asset-chart,
.card-single,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.card-asset-chart:hover,
.card-single:hover { border-color: var(--accent-line); }

.card-single { height: 100%; display: flex; flex-direction: column; }

.card-flex,
.card-flex-pie-chart,
.card-flex-speedometer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
/* flex:1 rather than height:100% so the .card-why footer band can sit
   below it without overflowing the card. */
.card-flex { flex: 1 1 auto; min-height: 0; width: 100%; }
.card-flex-pie-chart,
.card-flex-speedometer { flex-direction: column; align-items: stretch; height: 100%; }

/* "Why this matters" band pinned to the bottom of each key-stat card.
   Negative margins take it edge-to-edge past the card's own padding. */
.card-why {
  margin: 16px -18px -18px;
  padding: 12px 18px 14px;
  background: var(--surface2);
  border-top: 1px solid var(--border-soft);
  border-radius: 0 0 var(--radius) var(--radius);
  font-size: 10.5px;
  line-height: 1.8;
  color: var(--text2);
}
.card-why b {
  display: block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 3px;
}
.card-why-watch {
  display: block;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--border);
  color: var(--text3);
}
.card-why-watch > span {
  display: block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 2px;
}

.card-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.card-info h2 { font-size: inherit; font-weight: inherit; margin: 6px 0 8px; }

.card-head span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text);
}
.card-head small {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text3);
}

/* scripts.js injects this <select> and hard-codes light inline styles on it,
   so these need !important to win in dark mode. */
.growth-since { margin-top: 7px; }
#myDropdown {
  padding: 3px 8px !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  background-color: var(--surface2) !important;
  color: var(--text) !important;
  font-family: inherit !important;
  font-size: 11.5px !important;
  cursor: pointer;
}
#myDropdown option { background-color: var(--surface) !important; color: var(--text) !important; }

.card-main-info {
  display: block;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* Small descriptive text under the number */
.card-info small,
#hoverText small {
  font-size: 11px;
  line-height: 1.6;
  color: var(--text2);
}

.card-chart {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  /* Bare icon — no box behind it. */
}
.card-chart i,
.card-chart.success i { font-size: 26px; color: var(--accent); }
.card-chart.danger i  { color: var(--red); }
.card-chart.yellow i  { color: var(--yellow); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }

/* Reserves inline control */
.input-row-reserves,
input.input-row-reserves {
  width: 110px;
  margin: 8px 8px 0 0;
  padding: 6px 9px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  outline: none;
}
.input-row-reserves:focus { border-color: var(--accent); }

/* =========================================================================
   BUTTONS
   ========================================================================= */
.cool-button,
.cool-button-reserves,
.toggle-chart,
.btn {
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  line-height: 1.4;
}
.cool-button:hover,
.cool-button-reserves:hover,
.toggle-chart:hover,
.btn:hover { border-color: var(--accent); color: var(--accent); }
.cool-button:active { transform: translateY(1px); }
.cool-button:disabled { opacity: 0.5; cursor: default; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
html.dark .btn-primary { color: #06231f; }
.btn-primary:hover { opacity: 0.88; color: #fff; border-color: var(--accent); }
html.dark .btn-primary:hover { color: #06231f; }

.btn-ghost { background: transparent; }
.btn-sm { font-size: 11.5px; padding: 5px 11px; }

/* Header buttons */
.header-actions button { white-space: nowrap; }
.header-actions button i { margin-right: 5px; }

/* select styled as a button */
select.cool-button {
  appearance: none;
  padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 15px) center, calc(100% - 10px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

/* Quarterly / Yearly toggle */
.toggle-buttons { display: inline-flex; gap: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.toggle-chart { border: none; border-radius: 0; background: transparent; }
.toggle-chart + .toggle-chart { border-left: 1px solid var(--border); }
.toggle-chart.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.toggle-chart:focus { outline: none; }

/* =========================================================================
   FORM CONTROLS
   ========================================================================= */
input, textarea, select {
  font-family: inherit;
  color: var(--text);
}
input[type=number], input[type=text], input[type=email], input[type=search], textarea, select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
input[type=range] { accent-color: var(--accent); }
label { font-size: 12.5px; color: var(--text2); }

.input-row { margin-bottom: 12px; }
.input-row label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 5px; line-height: 1.5; }
.input-row input { width: 100%; }
.input-row i { color: var(--text3); margin-left: 4px; }

/* =========================================================================
   CHART CARDS — "What If" hamburger + panels
   ========================================================================= */
.module { position: relative; }

#hamburgerMenuClientChart,
#hamburgerMenuMonteCarlo {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 5px 11px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  cursor: pointer;
  user-select: none;
}
#hamburgerMenuClientChart:hover,
#hamburgerMenuMonteCarlo:hover { border-color: var(--accent); color: var(--accent); }

#inputPanelClientChart,
#inputPanelMonteCarlo {
  position: absolute;
  top: 46px;
  left: 14px;
  z-index: 7;
  width: 330px;
  max-width: calc(100vw - 60px);
  max-height: 70vh;
  overflow-y: auto;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
#inputPanelClientChart input,
#inputPanelMonteCarlo input { width: 100%; }
.hidden { display: none !important; }
.visible { display: block; }

.chart-container-net-worth,
.chart-container-pie-chart { position: relative; width: 100%; }
.net-worth-chart, canvas.net-worth-chart { width: 100% !important; height: auto !important; }

#summaryNetWorth,
#summaryMonteCarlo {
  margin-top: 14px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text2);
}
#summaryNetWorth b, #summaryMonteCarlo b { color: var(--text); }

#customLegendMonteCarlo { flex-wrap: wrap; gap: 10px; margin-top: 10px; font-size: 12px !important; color: var(--text2); }

.montecarlojoke { font-size: 12px; color: var(--text3); font-style: italic; margin-top: 8px; }

/* Pie / gauge */
.card-flex-pie-chart .card-info { height: 100%; }
.pie-chart-container-asset-allocation {
  position: relative;
  width: 100%;
  max-width: 280px;
  margin: 18px auto 0;
  flex: 1;
  display: flex;
  align-items: center;
}
.pie-chart-container-asset-allocation canvas { width: 100% !important; height: auto !important; }

/* Percent To Goal fills its card rather than sitting as a small dial */
#speedometer .card-flex-speedometer { display: flex; flex-direction: column; height: 100%; }
#speedometer .card-info { flex: 1; display: flex; flex-direction: column; }
.analytics-card { margin-top: 10px; flex: 1; display: flex; align-items: center; justify-content: center; }
#gaugeWrapper, .gauge-wrapper { position: relative; text-align: center; width: 100%; }
#gauge, .speedometerChart { display: block; width: 100%; max-width: 440px; height: auto; margin: 0 auto; }
/* The needle is drawn on the canvas' horizontal centreline, close to its
   bottom edge — so the readout sits below the canvas rather than being
   pulled up into it, which is what made the two collide. */
.gauge-label {
  font-size: 38px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.gauge-note:empty { display: none; }
.gauge-note {
  margin-top: 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--green);
}
.analytics-note { font-size: 11.5px; color: var(--text2); }
.analytics-note h3 { font-size: 12px; font-weight: 500; color: var(--text2); }
.analytics-chart small { font-size: 11px; color: var(--text3); }
.analytics-head { font-size: 12px; font-weight: 600; }
.analytics-head i { color: var(--text3); }

/* updateAssetMixChart() in scripts.js writes this legend with hard-coded
   light colours inline; override only the text and the bar track so the
   category swatches keep their own colour. */
#assetMixLegend > div > div:nth-child(2) { color: var(--text2) !important; }
#assetMixLegend > div > div:nth-child(3) { color: var(--text) !important; }
#assetMixLegend > div > div:nth-child(4) { background: var(--surface3) !important; }

/* =========================================================================
   CARD CAROUSELS
   ========================================================================= */
.card-carousel { position: relative; overflow: hidden; flex: 1; height: 100%; min-height: 340px; border-radius: var(--radius); }

/* Long legal text was setting the height of the whole card row — tuck it
   behind a disclosure so the metrics stay the focus. */
.fine-print { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-soft); }
.fine-print summary {
  font-size: 10.5px; color: var(--text3); cursor: pointer; list-style: none;
  display: flex; align-items: center; gap: 5px;
}
.fine-print summary::-webkit-details-marker { display: none; }
.fine-print summary::after { content: '▾'; margin-left: auto; transition: transform 0.2s; }
.fine-print[open] summary::after { transform: rotate(180deg); }
.fine-print summary:hover { color: var(--text2); }
.fine-print p { font-size: 10px; color: var(--text3); line-height: 1.65; margin-top: 8px; }
.card-carousel-track { display: flex; align-items: stretch; height: 100%; transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1); }
.card-carousel-track .card-single { min-width: 100%; width: 100%; height: 100% !important; }
.card-carousel-track #speedometer { min-width: 100%; width: 100%; height: 100%; }
.card-carousel-track #speedometer .card-single { min-width: 100% !important; width: 100% !important; }

.card-carousel-nav { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 10px 0 2px; }
.card-carousel-nav button,
.slideshow-nav button {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  font-size: 14px;
  line-height: 1.3;
  color: var(--text2);
  cursor: pointer;
  font-family: inherit;
}
.card-carousel-nav button:hover,
.slideshow-nav button:hover { border-color: var(--accent); color: var(--accent); }
.card-carousel-nav button:disabled,
.slideshow-nav button:disabled { opacity: 0.35; cursor: default; }

.card-carousel-dots, .slideshow-dots { display: flex; gap: 6px; }
.card-carousel-dot, .slideshow-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--surface3); cursor: pointer; transition: background 0.2s, transform 0.2s;
}
.card-carousel-dot.active, .slideshow-dot.active { background: var(--accent); transform: scale(1.25); }
.card-carousel-label { font-size: 11px; color: var(--text3); text-align: center; margin-top: 4px; }

#trivia-corner-card-tour { height: 100% !important; }

/* =========================================================================
   FINANCIAL CALCULATORS
   ========================================================================= */
.fpc-calc { margin-bottom: 16px; }

/* Calculator search bar */
.fpc-search-wrap {
  position: relative;
  margin-bottom: 14px;
}
.fpc-search-wrap i {
  position: absolute;
  left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--text2); font-size: 13px; pointer-events: none;
}
.fpc-search-wrap input {
  width: 100%;
  padding: 10px 14px 10px 36px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit; font-size: 13.5px;
  outline: none;
}
.fpc-search-wrap input:focus { border-color: var(--accent); }
.fpc-search-wrap input::placeholder { color: var(--text3); }
.fpc-tab-empty {
  font-size: 12.5px; color: var(--text2);
  padding: 4px 2px 12px;
}

/* Segmented mode toggle (retirement calculator) */
.fpc-seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-wrap: wrap;
}
.fpc-seg-btn {
  background: none; border: none;
  padding: 8px 15px;
  font-family: inherit; font-size: 12.5px; font-weight: 500;
  color: var(--text2); cursor: pointer;
  border-left: 1px solid var(--border);
}
.fpc-seg-btn:first-child { border-left: none; }
.fpc-seg-btn:hover { color: var(--text); }
.fpc-seg-btn.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* Small disclaimer under a calculator */
.fpc-note {
  margin-top: 14px;
  font-size: 11px; line-height: 1.65;
  color: var(--text3);
  max-width: 80ch;
}

.fpc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}
.fpc-grid label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 11.5px; font-weight: 600; color: var(--text2);
}
.fpc-grid input, .fpc-grid select {
  padding: 8px 11px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit; font-size: 13px; font-weight: 400;
  outline: none;
}
.fpc-grid input:focus, .fpc-grid select:focus { border-color: var(--accent); }

.fpc-result {
  margin-top: 18px;
  padding: 15px 17px;
  background: var(--surface2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.75;
}
.fpc-result .fpc-headline { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; color: var(--text); margin-bottom: 3px; }
.fpc-result .fpc-sub { color: var(--text2); font-size: 11.5px; line-height: 1.7; }

.fpc-chart-wrap { position: relative; height: 240px; margin-top: 18px; }

.fpc-debt-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr auto;
  gap: 10px; align-items: center; margin-bottom: 8px;
}
.fpc-debt-row input {
  padding: 7px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text); font-family: inherit; font-size: 12.5px; outline: none;
}
.fpc-debt-row input:focus { border-color: var(--accent); }
.fpc-debt-row button { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 14px; padding: 4px 6px; }
.fpc-debt-row button:hover { color: var(--red); }

@media (max-width: 640px) {
  .fpc-debt-row { grid-template-columns: 1fr 1fr auto; }
  .fpc-debt-row input:first-child { grid-column: 1 / -1; }
}

/* Advisor "viewing as client" banner (set by advisor.html) */
#advisor-banner {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  z-index: 100000; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: center;
  background: #f59e0b; color: #3a2600;
  padding: 8px 16px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  box-shadow: 0 6px 22px rgba(0,0,0,.28); max-width: 92vw;
}
#advisor-banner a { color: #3a2600; text-decoration: underline; cursor: pointer; font-weight: 700; }
#advisor-banner a:hover { color: #000; }

/* Financial Projection — income/expense line-item editor */
.proj-table-head,
.proj-row {
  display: grid;
  grid-template-columns: 112px 1.4fr 1fr 84px 74px 40px 28px;
  gap: 10px;
  align-items: center;
}
.proj-table-head span:nth-child(6) { text-align: center; }
.proj-tax-cell { display: flex; align-items: center; justify-content: center; margin: 0; cursor: pointer; }
.proj-tax-cell input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }
.proj-tax-label { display: none; }
.proj-table-head {
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text3); padding: 0 2px 8px; border-bottom: 1px solid var(--border-soft);
}
.proj-row { margin-top: 8px; }
.proj-row input,
.proj-row select {
  padding: 7px 9px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text); font-family: inherit; font-size: 12.5px; outline: none;
  min-width: 0;
}
.proj-row input:focus, .proj-row select:focus { border-color: var(--accent); }
.proj-remove { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 14px; padding: 4px; }
.proj-remove:hover { color: var(--red); }

/* Collapsible year-by-year detail table */
.proj-table-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 4px 2px;
  background: none; border: none; cursor: pointer;
  font-family: inherit; font-size: 13.5px; font-weight: 600; color: var(--text);
}
.proj-table-toggle:hover { color: var(--accent); }
.proj-table-toggle .fa-chevron-down { font-size: 12px; color: var(--text2); transition: transform 0.2s ease; }
.proj-table-actions {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 14px 0 10px;
}
.proj-year-scroll { max-height: 360px; overflow: auto; border: 1px solid var(--border-soft); border-radius: var(--radius); }
#proj-year-table { margin: 0; }
#proj-year-table th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface2);
  text-align: right; white-space: nowrap;
}
#proj-year-table th:first-child, #proj-year-table td:first-child { text-align: left; }
#proj-year-table td { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

@media (max-width: 720px) {
  .proj-table-head { display: none; }
  .proj-row {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 12px; margin-top: 12px;
    border: 1px solid var(--border-soft); border-radius: var(--radius);
  }
  .proj-row input:nth-child(2) { grid-column: 1 / -1; }   /* label spans full width */
  .proj-tax-cell { grid-column: 1 / -1; justify-content: flex-start; gap: 8px; font-size: 12.5px; color: var(--text2); }
  .proj-tax-label { display: inline; }                    /* show "Taxable" text on mobile */
  .proj-remove { grid-column: 2; justify-self: end; }
}

/* =========================================================================
   TABLES
   ========================================================================= */
.tab-panel table,
#net-worth-table-output table,
#client-log-tableContainer table,
table.data-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 12.5px;
  background: var(--surface);
}
.tab-panel table th,
#net-worth-table-output table th,
#client-log-tableContainer table th,
table.data-table th {
  text-align: left;
  padding: 9px 12px !important;
  font-size: 10px !important;
  font-weight: 700 !important;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text3) !important;
  background: var(--surface2);
  border: none !important;
  border-bottom: 1px solid var(--border) !important;
  white-space: nowrap;
}
/* Sortable Date column header in the Client Log */
#client-log-tableContainer table th.log-sort-header { cursor: pointer; user-select: none; }
#client-log-tableContainer table th.log-sort-header:hover { color: var(--accent) !important; }
#client-log-tableContainer table th .log-sort-arrow { font-size: 9px; margin-left: 4px; opacity: 0.75; }
.tab-panel table td,
#net-worth-table-output table td,
#client-log-tableContainer table td,
table.data-table td {
  padding: 9px 12px !important;
  border: none !important;
  border-bottom: 1px solid var(--border-soft) !important;
  color: var(--text2);
  vertical-align: top;
}
.tab-panel table tr:last-child td { border-bottom: none !important; }
.tab-panel table tbody tr:hover td,
#net-worth-table-output table tr:hover td,
#client-log-tableContainer table tr:hover td {
  background: var(--accent-soft) !important;
  color: var(--text) !important;
  font-weight: 400 !important;
}
.tab-panel table td strong { color: var(--text); font-weight: 600; }

#net-worth-data-table { margin-top: 22px; }
#net-worth-data-table h2 { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
#net-worth-data-table p { font-size: 12px; color: var(--text2); max-width: 78ch; }
#net-worth-table-output { max-height: 420px; overflow: auto; margin-top: 10px; border-radius: var(--radius); }

#resultsTableContainerMonteCarlo { border-radius: var(--radius); }
.success-row-monte-carlo td { color: var(--green) !important; }
.failure-row-monte-carlo td { color: var(--red) !important; }

.bold { font-weight: 600; color: var(--text); }

/* Editable-quarter table inside the What-If sheet */
#notesSection { margin-top: 18px; }
#notesSection table { margin-top: 10px; }
#notesSection input { width: 100%; }

/* =========================================================================
   IN-PANEL CHART TABS (Net Worth / Retirement / Trivia)
   ========================================================================= */
.chart-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  padding: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.chart-tab {
  flex: 1;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 7px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text2);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.chart-tab:hover { color: var(--text); background: var(--surface); }
.chart-tab.active {
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.chart-tab-panel { display: none; }
.chart-tab-panel.active { display: block; animation: panel-in 0.2s ease; }
.chart-tab-description {
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text2);
  max-width: 84ch;
  margin: 0 0 16px;
}

/* Read-only cell in the Net Worth edit table (ConCap-managed investments) */
.notes-readonly {
  color: var(--text3);
  background: var(--surface2);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

/* =========================================================================
   ANNOUNCEMENTS
   ========================================================================= */
#announcements-container { max-height: none !important; overflow: visible !important; }
.announcement-row {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border-soft);
}
.announcement-row:first-child { padding-top: 0; }
.announcement-row:last-child { border-bottom: none; padding-bottom: 0; }
.ann-icon {
  width: 32px; height: 32px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0;
  background: var(--surface2); color: var(--text2);
}
.type-update .ann-icon { background: var(--accent-soft); color: var(--accent); }
.type-event  .ann-icon { background: rgba(130, 80, 223, 0.12); color: var(--purple); }
.type-tip    .ann-icon { background: rgba(210, 153, 34, 0.14); color: var(--yellow); }
.type-alert  .ann-icon { background: rgba(207, 34, 46, 0.12); color: var(--red); }
.ann-title { font-size: 13px; font-weight: 600; color: var(--text); }
.ann-body  { font-size: 12px; color: var(--text2); margin-top: 3px; line-height: 1.6; max-width: 76ch; }
.ann-date  { font-size: 11px; color: var(--text3); white-space: nowrap; margin-left: auto; padding-left: 12px; }

/* =========================================================================
   PODCAST
   ========================================================================= */
.podcast-search-bar { display: flex; gap: 10px; margin-bottom: 12px; }
.podcast-search-bar input { flex: 1; }

.podcast-category-filters { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }
.category-chip {
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  font-size: 11.5px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.category-chip:hover { border-color: var(--accent); color: var(--accent); }
.category-chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

.podcast-list-scroll { max-height: 340px; overflow-y: auto; padding-right: 4px; }

.podcast-row {
  border-radius: var(--radius-sm);
  background: var(--surface2) !important;
  border: 1px solid transparent !important;
  transition: border-color 0.15s;
  overflow: hidden;
}
.podcast-row:hover { border-color: var(--accent-line) !important; }
.podcast-row.is-playing,
.podcast-row[data-playing="1"] {
  background: var(--accent-soft) !important;
  border-color: var(--accent) !important;
}
/* A freshly published (isNew) update gets a green ring that pulses to draw
   the eye. Uses box-shadow so it layers over the existing border. */
.podcast-row.is-new {
  border: 2px solid var(--green) !important;
  animation: podcastNewPulse 2s ease-in-out infinite;
}
@keyframes podcastNewPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(26, 127, 55, 0.45); }
  50%      { box-shadow: 0 0 0 5px rgba(26, 127, 55, 0); }
}
html.dark .podcast-row.is-new {
  animation-name: podcastNewPulseDark;
}
@keyframes podcastNewPulseDark {
  0%, 100% { box-shadow: 0 0 0 0 rgba(63, 185, 80, 0.5); }
  50%      { box-shadow: 0 0 0 5px rgba(63, 185, 80, 0); }
}
/* While it's the row that's playing, the accent selection wins — no need to
   also pulse for attention. */
.podcast-row.is-new.is-playing,
.podcast-row.is-new[data-playing="1"] {
  border-color: var(--accent) !important;
  animation: none;
  box-shadow: none;
}
/* Respect users who ask for less motion: keep the green ring, drop the pulse. */
@media (prefers-reduced-motion: reduce) {
  .podcast-row.is-new { animation: none; box-shadow: 0 0 0 2px rgba(26, 127, 55, 0.35); }
  html.dark .podcast-row.is-new { box-shadow: 0 0 0 2px rgba(63, 185, 80, 0.4); }
}
.podcast-row-head {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px;
  cursor: pointer;
}
/* The player docks in here when the row is the one playing. */
.podcast-row-body { padding: 2px 13px 13px; }
.podcast-row-body[hidden] { display: none; }
.podcast-row-body audio { width: 100%; margin-top: 2px; }
html.dark .podcast-row-body audio { filter: invert(0.9) hue-rotate(180deg); }
.podcast-row p { color: var(--text); }
.podcast-row .row-play-icon { color: var(--text2) !important; }
.podcast-episode-category {
  display: inline-block;
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 2px 7px; border-radius: 20px; margin-bottom: 4px;
}
.podcast-no-results { font-size: 12.5px; color: var(--text3); padding: 16px 0; text-align: center; display: none; }

.audio-wave { display: inline-flex; align-items: flex-end; gap: 2px; width: 20px; height: 20px; flex-shrink: 0; }
.audio-wave span {
  display: block; width: 3px; border-radius: 2px;
  background: var(--accent);
  animation: wave-bar 0.9s ease-in-out infinite;
  transform-origin: bottom;
}
.audio-wave span:nth-child(1) { height: 6px;  animation-delay: 0s; }
.audio-wave span:nth-child(2) { height: 14px; animation-delay: 0.15s; }
.audio-wave span:nth-child(3) { height: 10px; animation-delay: 0.3s; }
.audio-wave span:nth-child(4) { height: 18px; animation-delay: 0.1s; }
.audio-wave.paused span { animation-play-state: paused; }
@keyframes wave-bar { 0%, 100% { transform: scaleY(0.4); } 50% { transform: scaleY(1); } }

#podcast-footer {
  display: none; margin-top: 12px; padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--text2); line-height: 1.7;
}

/* Slideshow */
/* Slides are viewed full-screen in a new tab, so the row carries just one
   prominent call-to-action button rather than an inline carousel. Hidden
   until an episode is opened. */
#podcast-slideshow { display: none; margin-top: 16px; }
.episode-slides-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%;
  padding: 15px 18px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-family: inherit; font-size: 14.5px; font-weight: 700; letter-spacing: 0.2px;
  cursor: pointer;
  /* Gentle breathing glow so the button draws the eye and invites a click. */
  animation: episode-slides-pulse 2.4s ease-in-out infinite;
  transition: transform 0.15s ease, filter 0.15s ease;
}
html.dark .episode-slides-btn { color: #06231f; }
.episode-slides-btn i { font-size: 15px; }
.episode-slides-btn:hover {
  transform: translateY(-1px) scale(1.01);
  filter: brightness(1.05);
}
.episode-slides-btn:active { transform: translateY(0) scale(0.995); }

@keyframes episode-slides-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb, 0,120,125), 0.45); }
  50%      { box-shadow: 0 0 0 10px rgba(var(--accent-rgb, 0,120,125), 0); }
}

/* Respect users who prefer reduced motion — keep it static but still styled. */
@media (prefers-reduced-motion: reduce) {
  .episode-slides-btn { animation: none; }
}

/* On phones the Market Updates card can get tall — the episode list plus a long
   per-episode footer push the "view episode slides" button off-screen. Shorten
   the list, cap a long footer with its own scroll, and tighten spacing so the
   button stays reachable. (The list and footer still scroll internally.) */
@media (max-width: 640px) {
  .podcast-list-scroll { max-height: 208px; }
  #podcast-footer { max-height: 96px; overflow-y: auto; margin-top: 10px; }
  #podcast-slideshow { margin-top: 12px; }
  .episode-slides-btn { padding: 13px 16px; }
}

/* =========================================================================
   MARKET OVERVIEW
   ========================================================================= */
.market-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 16px;
  align-items: start;
}
#market-overview-tv {
  height: 640px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  padding: 6px;
}
#market-overview-tv .tradingview-widget-container,
#market-overview-tv .tradingview-widget-container__widget { height: 100%; }
.tradingview-widget-copyright { font-size: 8px; color: var(--text3); text-align: center; }

#market-overview-commentary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  max-height: 640px;
  overflow-y: auto;
}
#marketCommentaryTitle { padding-bottom: 14px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
#marketCommentaryTitle h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
#marketCommentaryTitle small { font-size: 11px; color: var(--text3); }
#marketCommentary { max-width: 78ch; }
#marketCommentary p { text-align: left; font-size: 13px; line-height: 1.75; color: var(--text2); margin-top: 10px; }
#marketCommentary p b { color: var(--text); font-weight: 600; }
#marketCommentary .commentary-h {
  font-size: 14px; font-weight: 600; color: var(--text);
  margin-top: 26px; padding-top: 6px;
}
#marketCommentary .commentary-h:first-of-type { margin-top: 8px; }
.market-commentary { opacity: 0; transform: translateY(14px); transition: opacity 0.9s ease, transform 0.9s ease; }
.market-commentary.visible { opacity: 1; transform: none; }
.commentary-legal { margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--border); }
.commentary-legal p { font-size: 9.5px !important; color: var(--text3) !important; line-height: 1.7 !important; }

/* =========================================================================
   TRIVIA
   ========================================================================= */
.trivia-question-container { color: var(--text); min-height: 260px; }
.trivia-question { font-size: 15px; font-weight: 500; line-height: 1.6; margin-bottom: 16px; max-width: 76ch; }
.trivia-choices { display: flex; flex-direction: column; gap: 8px; max-width: 620px; }
.trivia-choices li {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  font-size: 13px;
  color: var(--text2);
  transition: border-color 0.3s, color 0.3s, background 0.3s;
}
.trivia-choices li.bold {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.trivia-empty-note { font-size: 12px; color: var(--text3); margin-top: 12px; font-style: italic; }

/* ── Financial Literacy Quiz ───────────────────────────────────────────── */
.fq-intro { font-size: 13px; color: var(--text2); line-height: 1.7; margin-bottom: 18px; max-width: 70ch; }
.fq-len-row { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.fq-len-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text3); }
.fq-len-opts { display: flex; gap: 8px; }
.fq-len-opt {
  padding: 6px 14px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--surface2);
  color: var(--text2); font-family: inherit; font-size: 12.5px; cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.fq-len-opt:hover { border-color: var(--accent-line); }
.fq-len-opt.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.fq-start-row { display: flex; align-items: center; gap: 16px; }
.fq-best { font-size: 12px; color: var(--text3); margin-right: auto; }
.fq-best b { color: var(--text); font-weight: 600; }

.fq-start-btn, .fq-next-btn {
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 10px 20px;
  font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: opacity 0.15s;
}
html.dark .fq-start-btn, html.dark .fq-next-btn { color: #06231f; }
.fq-start-btn:hover, .fq-next-btn:hover { opacity: 0.9; }
.fq-quit-btn {
  background: var(--surface2); color: var(--text2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 16px; font-family: inherit; font-size: 13px; cursor: pointer;
}
.fq-quit-btn:hover { color: var(--text); border-color: var(--accent-line); }

.fq-quiz-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.fq-quiz-top-right { display: flex; align-items: center; gap: 10px; }
.fq-restart-btn {
  background: none; border: none; padding: 2px 4px;
  color: var(--text3); font-family: inherit; font-size: 11.5px; cursor: pointer;
  transition: color 0.12s;
}
.fq-restart-btn:hover { color: var(--accent); }
.fq-counter { font-size: 11.5px; color: var(--text3); font-weight: 500; }
.fq-cat-tag {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 3px 9px; border-radius: 20px; background: var(--accent-soft); color: var(--accent);
}
.fq-progress { height: 4px; background: var(--surface3); border-radius: 4px; overflow: hidden; margin-bottom: 18px; }
.fq-progress-fill { height: 100%; background: var(--accent); width: 0; transition: width 0.3s ease; }
.fq-question { font-size: 15px; font-weight: 600; color: var(--text); line-height: 1.5; margin-bottom: 16px; max-width: 72ch; }
.fq-options { display: flex; flex-direction: column; gap: 8px; max-width: 640px; }
.fq-option {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface2); color: var(--text); font-family: inherit; font-size: 13px;
  cursor: pointer; transition: border-color 0.12s, background 0.12s;
}
.fq-option:hover:not(:disabled) { border-color: var(--accent-line); }
.fq-option:disabled { cursor: default; }
.fq-opt-letter {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface3); color: var(--text2); font-size: 11px; font-weight: 700;
}
.fq-option.correct { border-color: var(--green); background: rgba(26, 127, 55, 0.10); }
.fq-option.correct .fq-opt-letter { background: var(--green); color: #fff; }
.fq-option.wrong { border-color: var(--red); background: rgba(207, 34, 46, 0.08); }
.fq-option.wrong .fq-opt-letter { background: var(--red); color: #fff; }

.fq-feedback {
  display: none; margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-sm);
  border-left: 3px solid var(--border); background: var(--surface2);
  font-size: 12.5px; line-height: 1.7; color: var(--text2); max-width: 640px;
}
.fq-feedback.show { display: block; }
.fq-feedback.correct { border-left-color: var(--green); }
.fq-feedback.incorrect { border-left-color: var(--red); }
.fq-verdict { display: block; font-weight: 700; margin-bottom: 3px; color: var(--text); }
.fq-feedback.correct .fq-verdict { color: var(--green); }
.fq-feedback.incorrect .fq-verdict { color: var(--red); }
.fq-next-row { display: flex; align-items: center; gap: 10px; margin-top: 18px; }

.fq-result-score { font-size: 46px; font-weight: 700; line-height: 1; color: var(--accent); }
.fq-result-sub { font-size: 13px; font-weight: 600; color: var(--text2); margin-top: 6px; }
.fq-result-msg { font-size: 13px; color: var(--text2); line-height: 1.7; margin-top: 12px; max-width: 62ch; }

/* =========================================================================
   CLIENT LOG
   ========================================================================= */
.collapsible-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.toggle-button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 14px 18px;
  background: var(--surface2);
  border: none;
  border-bottom: 1px solid var(--border);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.toggle-button small { font-weight: 400; font-size: 11px; color: var(--text3); }
.toggle-button i { margin-left: auto; color: var(--text3); transition: transform 0.25s; }
.collapsible-container .content { max-height: 0; overflow: hidden; transition: max-height 0.35s ease; }
.collapsible-container .content.expanded { max-height: 720px; }
.toggle-button.open i { transform: rotate(180deg); }
#client-log-tableContainer { padding: 16px 18px; max-height: 620px; overflow: auto; }
#client-log-tableContainer table td:nth-child(1) { white-space: nowrap; color: var(--text); font-weight: 500; width: 1%; }
#client-log-tableContainer table td:nth-child(2) { white-space: nowrap; width: 1%; }
#client-log-tableContainer table td:nth-child(3) { line-height: 1.7; }
tr.log-hidden { display: none; }

.log-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.log-toolbar input { flex: 1; min-width: 200px; }
.log-count { font-size: 11.5px; color: var(--text3); white-space: nowrap; }

/* =========================================================================
   LINKS TAB
   ========================================================================= */
.link-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.link-tile {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s, transform 0.15s;
  cursor: pointer;
  color: inherit;
  text-align: left;
  font-family: inherit;
  width: 100%;
}
.link-tile:hover { border-color: var(--accent); transform: translateY(-1px); }
.link-tile-icon {
  width: 36px; height: 36px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
  font-size: 15px; flex-shrink: 0;
}
.link-tile-icon img { width: 18px; height: 18px; object-fit: contain; }
.link-tile-title { font-size: 13px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 6px; }
.link-tile-title .ext { font-size: 10px; color: var(--text3); }
.link-tile-desc { font-size: 11.5px; color: var(--text2); line-height: 1.6; margin-top: 3px; }

/* =========================================================================
   LEGAL DISCLOSURE (own tab)
   ========================================================================= */
/* A reading surface, so the type gets more room than it had crammed into the
   old footer bar — measure capped for line length, not for card width. */
.legal-body {
  max-width: 86ch;
  padding: 22px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text2);
}
.legal-body p { font-size: 12.5px; line-height: 1.85; margin: 0 0 14px; }
.legal-body p:last-child { margin-bottom: 0; }
.legal-body b { color: var(--text); font-weight: 600; }
.legal-body a { color: var(--accent); }
.legal-body a:hover { text-decoration: underline; }
.legal-copyright {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
  color: var(--text3);
  font-size: 11.5px;
}

/* =========================================================================
   TOUR
   ========================================================================= */
#tour-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 999; pointer-events: none; display: none;
}
.tour-highlight {
  position: relative;
  z-index: 1000;
  outline: 2px solid var(--accent-hi);
  outline-offset: 3px;
  border-radius: var(--radius);
  box-shadow: 0 0 0 6px var(--accent-soft), var(--shadow-lg);
  transition: outline-color 0.3s, box-shadow 0.3s;
}
.card-single.tour-highlight { background: var(--surface) !important; z-index: 1001 !important; }

#tour-intro { display: none; }
.tour-intro-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.65); z-index: 1200; }
.tour-intro-box {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 1201;
  width: 620px; max-width: 92vw; max-height: 84vh; overflow-y: auto;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 14px;
  padding: 30px 34px; box-shadow: var(--shadow-lg);
}
.tour-intro-box h2 { font-size: 19px; font-weight: 600; margin-bottom: 16px; letter-spacing: -0.01em; }
.tour-intro-box p { font-size: 13px; line-height: 1.75; color: var(--text2); }
.tour-intro-box button {
  margin-top: 8px; padding: 9px 20px;
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
html.dark .tour-intro-box button { color: #06231f; }
.tour-intro-box button:hover { opacity: 0.88; }

.tour-message-box {
  display: none;
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%);
  z-index: 1001;
  width: 640px; max-width: 92vw; max-height: 44vh; overflow-y: auto;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 20px 24px; box-shadow: var(--shadow-lg);
  font-size: 13px; line-height: 1.75;
}
.tour-message-box a { color: var(--accent); text-decoration: underline; }
.tour-controls {
  display: none;
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: 1002;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 40px;
  padding: 7px 9px;
  box-shadow: var(--shadow-lg);
}
.tour-controls button {
  padding: 6px 16px; border-radius: 30px;
  border: 1px solid var(--border); background: var(--surface2);
  font-family: inherit; font-size: 12.5px; color: var(--text); cursor: pointer;
}
.tour-controls button:hover { border-color: var(--accent); color: var(--accent); }

/* =========================================================================
   FEEDBACK
   ========================================================================= */
/* Bottom-right: the old layout had no sidebar to collide with, and the right
   gutter is the only spot that never sits on top of content. */
#feedback-button-tour { position: fixed; right: 20px; bottom: 20px; z-index: 60; }
#feedbackBtn {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 15px;
  border-radius: 40px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  font-family: inherit; font-size: 11.5px; line-height: 1.35; white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  opacity: 0.8;
  transition: opacity 0.2s, border-color 0.2s, color 0.2s;
}
#feedbackBtn:hover { opacity: 1; border-color: var(--accent); color: var(--accent); }

#feedbackModal { display: none; position: fixed; inset: 0; z-index: 1300; background: rgba(0, 0, 0, 0.55); }
#feedbackModal .modal-content {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 520px; max-width: 92vw;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 14px;
  padding: 26px 28px; box-shadow: var(--shadow-lg);
}
#feedbackModal h3 { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
#feedbackModal p { font-size: 12px; color: var(--text3); }
.feedback, input.feedback, textarea.feedback {
  width: 100%; margin-top: 5px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 11px;
  font-family: inherit; font-size: 13px; color: var(--text); outline: none;
}
textarea.feedback { min-height: 120px; resize: vertical; }
.modal-buttons { display: flex; gap: 8px; margin-top: 12px; }
.close-btn { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 16px; }
.close-btn:hover { color: var(--text); }
.send-btn { background: var(--accent); color: #fff; border: none; }

/* =========================================================================
   AUTH / SESSION OVERLAYS
   ========================================================================= */
#overlayToken { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.8); z-index: 1400; }
#tokenDialog {
  display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 1401; width: 460px; max-width: 92vw;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 14px;
  padding: 26px 28px; box-shadow: var(--shadow-lg);
  font-size: 14px; line-height: 1.7;
}
#tokenDialog a { color: var(--accent); }
#tokenDialog a:hover { text-decoration: underline; }
#inactivityLogOutMessage {
  display: none; position: fixed; top: 18px; right: 18px; z-index: 1402;
  background: var(--red); color: #fff;
  padding: 12px 20px; border-radius: var(--radius);
  font-size: 13px; box-shadow: var(--shadow-md);
}

/* =========================================================================
   MISC
   ========================================================================= */
.orientation-warning {
  display: none;
  background: var(--accent-soft);
  border: 2px solid var(--accent-line);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 14px;
  text-align: center;
  letter-spacing: 0.01em;
}

.tooltip { position: relative; display: inline-block; }
.tooltiptext {
  visibility: hidden; opacity: 0;
  position: absolute; bottom: 130%; left: 50%; transform: translateX(-50%);
  z-index: 50; width: 220px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 11px; font-size: 11.5px; line-height: 1.6;
  box-shadow: var(--shadow-md);
  transition: opacity 0.15s;
}
.tooltip:hover .tooltiptext { visibility: visible; opacity: 1; }

span.indicator { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 6px; }

/* noUiSlider theming */
#rangeSlider { margin: 34px 12px 12px; }
.noUi-target { background: var(--surface3); border: none; box-shadow: none; height: 4px; border-radius: 3px; }
.noUi-connect { background: var(--accent) !important; }
.noUi-handle {
  width: 15px !important; height: 15px !important;
  right: -7px !important; top: -6px !important;
  border-radius: 50% !important;
  background: var(--surface) !important;
  border: 2px solid var(--accent) !important;
  box-shadow: var(--shadow-sm) !important;
  cursor: grab;
}
.noUi-handle::before, .noUi-handle::after { display: none !important; }
.noUi-tooltip {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  font-size: 10.5px !important;
  padding: 2px 7px !important;
  border-radius: 5px !important;
  box-shadow: var(--shadow-sm);
}

/* =========================================================================
   COMMAND PALETTE  (⌘K / Ctrl+K)
   ========================================================================= */
/* ── Background picker ────────────────────────────────────────────────────── */
.bg-overlay {
  display: none; position: fixed; inset: 0; z-index: 1500;
  background: rgba(0, 0, 0, 0.5);
  align-items: flex-start; justify-content: center; padding-top: 10vh;
}
.bg-overlay.open { display: flex; }
.bg-box {
  width: 440px; max-width: 94vw; max-height: 80vh;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-lg);
}
.bg-box-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  font-size: 13.5px; font-weight: 600; color: var(--text);
}
.bg-box-header i { color: var(--accent); margin-right: 4px; }
.bg-box-header button {
  background: none; border: none; color: var(--text3); font-size: 15px;
  cursor: pointer; line-height: 1; padding: 2px 4px;
}
.bg-box-header button:hover { color: var(--text); }
.bg-box-body { padding: 14px 16px 18px; overflow-y: auto; }
.bg-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text3); margin: 14px 0 8px;
}
.bg-section-label:first-child { margin-top: 0; }
.bg-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.bg-swatch {
  width: 40px; height: 40px; flex-shrink: 0;
  border-radius: 8px; border: 1px solid var(--border);
  background-size: cover; background-position: center;
  cursor: pointer; padding: 0; position: relative;
  transition: transform 0.12s, box-shadow 0.12s;
}
.bg-swatch:hover { transform: translateY(-1px); }
.bg-swatch.selected {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
}
.bg-swatch-theme {
  display: flex; align-items: center; justify-content: center;
  width: auto; min-width: 40px; padding: 0 12px;
  font-family: inherit; font-size: 11px; font-weight: 600;
  color: var(--text2); background: var(--surface2);
}
.bg-swatch-wrap { position: relative; display: inline-flex; }
.bg-swatch-x {
  position: absolute; top: -6px; right: -6px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--red); color: #fff; border: 2px solid var(--surface);
  font-size: 9px; line-height: 1; cursor: pointer; padding: 0;
  display: none; align-items: center; justify-content: center;
}
.bg-swatch-wrap:hover .bg-swatch-x { display: flex; }
.bg-add-row { display: flex; gap: 8px; margin-bottom: 10px; }
.bg-add-row input {
  flex: 1; min-width: 0; padding: 8px 12px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-family: inherit; font-size: 12.5px; outline: none;
}
.bg-add-row input:focus { border-color: var(--accent); }
.bg-add-btn {
  flex-shrink: 0; padding: 8px 14px;
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer;
}
html.dark .bg-add-btn { color: #06231f; }
.bg-add-btn:hover { opacity: 0.9; }
.bg-empty-msg { font-size: 11.5px; color: var(--text3); padding: 2px 0; }
.bg-slider-row {
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border-soft);
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px 10px;
}
.bg-slider-row label { font-size: 12px; font-weight: 500; color: var(--text); }
.bg-slider-row label span { color: var(--accent); font-weight: 600; }
.bg-slider-row input[type=range] { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); cursor: pointer; }
.bg-slider-hint { grid-column: 1 / -1; font-size: 10.5px; color: var(--text3); }
.bg-slider-hint a { color: var(--accent); }
.bg-slider-hint a:hover { text-decoration: underline; }

.palette-overlay {
  display: none; position: fixed; inset: 0; z-index: 1500;
  background: rgba(0, 0, 0, 0.5);
  align-items: flex-start; justify-content: center; padding-top: 16vh;
}
.palette-overlay.open { display: flex; }
.palette-box {
  width: 400px; max-width: 92vw;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-lg);
}
.palette-box input {
  width: 100%; padding: 14px 16px;
  background: transparent; border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  font-size: 14px; color: var(--text); outline: none;
}
.palette-list { max-height: 300px; overflow-y: auto; padding: 6px; }
.palette-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text2); cursor: pointer;
  border-left: 2px solid transparent;
}
.palette-item:hover { background: var(--surface2); color: var(--text); }
.palette-item.selected { background: var(--accent-soft); color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.palette-hint { font-size: 10.5px; color: var(--text3); text-align: center; padding: 8px; border-top: 1px solid var(--border); }

/* =========================================================================
   RESPONSIVE
   ========================================================================= */
@media (max-width: 1100px) {
  .market-grid { grid-template-columns: 1fr; }
  #market-overview-tv { height: 480px; }
  #market-overview-commentary { max-height: none; }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    overflow-y: auto; -webkit-overflow-scrolling: touch;
  }
  body.nav-open .sidebar { transform: none; }
  /* On mobile the drawer scrolls as one piece, so the footer buttons
     (Dark mode / Background / Jump to) flow with the nav list instead of
     being pinned to the bottom edge. */
  .sidebar-nav { flex: 0 0 auto; overflow: visible; }
  .menu-toggle { display: inline-flex; }
  #feedback-button-tour { right: 12px; bottom: 12px; }
  main { padding: 18px 16px calc(96px + env(safe-area-inset-bottom)); }
  #header-bar { padding: 0 14px; }
  .topbar-sub { display: none; }
  .chart-tabs { flex-direction: column; }
  .chart-tab { min-height: 34px; }
  .card-carousel-track .card-single { padding: 16px; }
}

@media (max-width: 640px) {
  .header-actions .btn-label { display: none; }
  .header-actions button i { margin-right: 0; }
  .page-header h1 { font-size: 18px; }
  .card-main-info { font-size: 26px; }
  .legal-body { padding: 16px 16px; }
}

/* Landscape nudge for phones only */
@media (max-width: 820px) and (orientation: portrait) {
  .orientation-warning { display: block; }
}

/* =========================================================================
   PRINT / html2canvas capture helper
   ========================================================================= */
body.capturing .tab-panel,
body.capturing .chart-tab-panel { display: block !important; }
