/* ============================================================
   Scholarly Investing — Brand Design System
   Colors: Gold #C9A84C · Silver #A8B2BC · White · Charcoal #0C0D16
   ============================================================ */

:root {
  /* ── Education palette (default — gold accent) ───────────────── */
  --si-gold:        #C9A84C;
  --si-gold-light:  #E5C96A;
  --si-gold-dark:   #9A7E2A;
  --si-silver:      #A8B2BC;
  --si-silver-light:#C8D0D8;
  --si-dark:        #0C0D16;
  --si-dark-2:      #131421;
  --si-dark-3:      #1C1D2E;
  --si-border:      #2A2B40;
  --si-border-light:#353650;
  /* ── Planning palette (teal accent — used on /review/, /distributor/,
        and on planning-flavored nudges that route to the AMFI MFD service).
        Visually signals the boundary between "education content" and
        "personalised planning conversation". ─────────────────── */
  --si-planner:     #2E8B8B;
  --si-planner-light:#4FB0B0;
  --si-planner-dark:#1F6B6B;
  --font-display:   'Cormorant Garamond', Georgia, serif;
  --font-body:      'DM Sans', system-ui, sans-serif;
  --font-mono:      'JetBrains Mono', 'Fira Mono', monospace;
}

/* --- Brand wordmark in the global navbar ------------------ */
/* Rotating logo + gold-italic shimmer on "Investing" — applied to every
   page so the publication-style header is uniform across the site.
   prefers-reduced-motion disables both animations. */
.si-brand-logo {
  height: 36px;
  width: auto;
  display: block;
  animation: si-logo-orbit 30s linear infinite;
  transform-origin: 50% 50%;
}
@keyframes si-logo-orbit {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.si-brand-wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  font-family: var(--font-display, 'Cormorant Garamond', Georgia, serif);
  line-height: 1;
}
.si-brand-wordmark .si-brand-scholarly {
  font-variant: small-caps;
  letter-spacing: 0.08em;
  font-size: 1rem;
  text-transform: uppercase;
  color: inherit;
}
.si-brand-wordmark .si-brand-investing {
  font-style: italic;
  font-weight: 500;
  font-size: 1.2rem;
  letter-spacing: 0;
  background: linear-gradient(
    100deg,
    var(--si-gold-dark) 0%,
    var(--si-gold-dark) 35%,
    var(--si-gold-light) 50%,
    var(--si-gold-dark) 65%,
    var(--si-gold-dark) 100%
  );
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: si-brand-shimmer 6s ease-in-out infinite;
}
@keyframes si-brand-shimmer {
  0%   { background-position: 200% 50%; }
  100% { background-position: -50% 50%; }
}
@media (prefers-reduced-motion: reduce) {
  .si-brand-logo { animation: none; }
  .si-brand-wordmark .si-brand-investing { animation: none; background-position: 50% 50%; }
}

/* --- Planner-mode pages ------------------------------------ */
/* Apply via <body class="planner-mode"> on /review/ and /distributor/.
   Top-bar accent, headings, and buttons swap from gold → teal. */
body.planner-mode h1,
body.planner-mode h2,
body.planner-mode .planner-accent { color: var(--si-planner); }
body.planner-mode a:not(.btn):not(.nav-link):not(.si-footer-link) { color: var(--si-planner); }
body.planner-mode .btn-si-gold {
  background: var(--si-planner);
  color: #fff;
}
body.planner-mode .btn-si-gold:hover {
  background: var(--si-planner-light);
  color: #fff;
}
body.planner-mode::before {
  /* Subtle top bar to mark the boundary cross. */
  content: "";
  display: block;
  height: 3px;
  background: linear-gradient(90deg, var(--si-planner-dark), var(--si-planner), var(--si-planner-light));
}

/* --- Global ------------------------------------------------- */
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  /* Light is default; dark mode overrides below in body.bg-dark */
  background-color: #FAF8F5 !important;
  color: #1A1814;
}

/* Dark mode */
body.bg-dark {
  background-color: var(--si-dark) !important;
  color: #F0EEE8;
}

/* Mono font for financial figures */
.si-num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: -0.02em;
}

/* --- Logo spinner (loading animation) ---------------------- */
@keyframes si-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.si-spinner {
  animation: si-spin 1.2s linear infinite;
  display: inline-block;
}

/* --- Brand logotype ---------------------------------------- */
.si-brand {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  line-height: 1.15;
  color: #F0EEE8;  /* light text on dark navbar */
}
.si-brand .si-sub {
  font-size: 0.58rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.55;
  display: block;
}

/* --- Navbar (frosted glass) --------------------------------- */
.si-navbar {
  background: rgba(12, 13, 22, 0.92) !important;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(201,168,76,0.14) !important;
  position: sticky;
  top: 0;
  z-index: 1030;
  min-height: 54px;
}

/* ── Journey step nav links ─────────────────────────────── */
.si-nav-steps {
  row-gap: 0.35rem;
}

.si-nav-step {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.28rem 0.7rem;
  border-radius: 6px;
  text-decoration: none;
  color: var(--si-silver);
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid transparent;
  transition: color 0.18s, background 0.18s, border-color 0.18s;
  line-height: 1.4;
  white-space: nowrap;
}
.si-nav-step:hover {
  color: var(--si-gold-light);
  background: rgba(201,168,76,0.07);
  border-color: rgba(201,168,76,0.18);
  text-decoration: none;
}
.si-nav-step.active-page {
  color: var(--si-gold);
  background: rgba(201,168,76,0.1);
  border-color: rgba(201,168,76,0.3);
}

.si-step-num {
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--si-gold);
  opacity: 0.5;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  flex-shrink: 0;
}
.si-nav-step.active-page .si-step-num { opacity: 1; }
.si-nav-step:hover .si-step-num { opacity: 0.85; }

.si-step-icon {
  font-size: 0.82rem;
  flex-shrink: 0;
}
.si-step-label {
  letter-spacing: 0.01em;
}

/* Inline glossary auto-link — module reader and Q&A pages. */
.glossary-term {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted var(--si-gold);
  cursor: help;
  transition: color 0.15s, border-bottom-style 0.15s;
}
.glossary-term:hover {
  color: var(--si-gold);
  border-bottom-style: solid;
  text-decoration: none;
}
body.bg-light .glossary-term { border-bottom-color: var(--si-gold-dark); }
body.bg-light .glossary-term:hover { color: var(--si-gold-dark); }

.si-step-hint {
  font-size: 0.62rem;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--si-gold);
  font-weight: 600;
  opacity: 0.75;
  margin-left: 0.4rem;
  padding: 1px 6px;
  border: 1px solid rgba(201,168,76,0.4);
  border-radius: 999px;
}
.si-nav-step:hover .si-step-hint { opacity: 1; }
.si-nav-step.active-page .si-step-hint { display: none; }

.si-step-arrow {
  color: var(--si-border-light);
  font-size: 0.78rem;
  line-height: 1;
  opacity: 0.6;
  padding: 0 0.05rem;
  user-select: none;
}

/* Secondary nav links (Benchmarks, My Portfolio) */
.si-nav-sep {
  display: inline-block;
  width: 1px;
  height: 18px;
  background: var(--si-border);
  margin: 0 0.4rem;
  vertical-align: middle;
  opacity: 0.6;
}
.si-nav-secondary {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.6rem;
  border-radius: 6px;
  text-decoration: none;
  color: var(--si-silver);
  font-size: 0.76rem;
  opacity: 0.75;
  border: 1px solid transparent;
  transition: color 0.18s, background 0.18s, opacity 0.18s;
  white-space: nowrap;
}
.si-nav-secondary:hover {
  color: var(--si-silver-light);
  background: rgba(255,255,255,0.04);
  opacity: 1;
  text-decoration: none;
}
.si-nav-secondary.active-page {
  color: var(--si-gold);
  opacity: 1;
}

/* --- Sitewide footer --------------------------------------- */
.si-footer {
  border-top: 1px solid var(--si-border);
  background: var(--si-dark);
  margin-top: 3rem;
}
.si-footer-link {
  color: var(--si-silver);
  text-decoration: none;
  opacity: 0.75;
  transition: color 0.15s, opacity 0.15s;
}
.si-footer-link:hover {
  color: var(--si-gold-light);
  opacity: 1;
  text-decoration: none;
}

/* Legacy nav-link kept for any remaining uses */
.nav-link {
  transition: color 0.15s;
}
.nav-link:hover {
  color: var(--si-gold-light) !important;
}
.nav-link.active-page {
  color: var(--si-gold) !important;
  border-bottom: 2px solid var(--si-gold);
  padding-bottom: 2px;
}

/* --- Gold accent elements ---------------------------------- */
.btn-si-gold {
  background: var(--si-gold);
  color: #000;
  font-weight: 600;
  border: none;
}
.btn-si-gold:hover {
  background: var(--si-gold-light);
  color: #000;
}
.text-si-gold { color: var(--si-gold); }
.text-si-silver { color: var(--si-silver); }
.border-si-gold { border-color: var(--si-gold) !important; }

/* --- DataTables dark theme overrides ----------------------- */
/* Bloomberg-style: bottom-border only, generous row height */
table.dataTable {
  border-collapse: collapse !important;
}
table.dataTable thead th,
table.dataTable thead td {
  border-bottom: 2px solid var(--si-gold) !important;
  border-top: none !important;
  border-left: none !important;
  border-right: none !important;
  white-space: nowrap;
  font-family: var(--font-body);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
  color: var(--si-silver);
  background-color: var(--si-dark-2);
  padding: 0.65rem 0.75rem !important;
}
table.dataTable tbody td {
  border-top: none !important;
  border-left: none !important;
  border-right: none !important;
  border-bottom: 1px solid var(--si-border) !important;
  padding: 0.6rem 0.75rem !important;
  vertical-align: middle;
}

table.dataTable.table-dark tbody tr:hover td {
  background-color: var(--si-dark-3) !important;
}

table.dataTable.table-dark > tbody > tr.selected > td {
  background-color: rgba(201,168,76,0.12) !important;
}

div.dataTables_wrapper div.dataTables_filter input {
  background-color: var(--si-dark-2);
  border: 1px solid var(--si-border);
  color: #F0EEE8;
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
}

div.dataTables_wrapper div.dataTables_length select {
  background-color: var(--si-dark-2);
  border: 1px solid var(--si-border);
  color: #F0EEE8;
  border-radius: 4px;
}

div.dataTables_wrapper div.dataTables_info {
  color: var(--si-silver);
  font-size: 0.75rem;
}

div.dataTables_wrapper div.dataTables_paginate .paginate_button {
  color: var(--si-silver) !important;
}

div.dataTables_wrapper div.dataTables_paginate .paginate_button.current,
div.dataTables_wrapper div.dataTables_paginate .paginate_button.current:hover {
  background: rgba(201,168,76,0.15) !important;
  border-color: var(--si-gold) !important;
  color: var(--si-gold) !important;
}

/* --- Metric Cards ------------------------------------------ */
.metric-card {
  background: var(--si-dark-2);
  border: none;
  border-radius: 8px;
  padding: 0.875rem 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.35), 0 4px 14px rgba(0,0,0,0.2);
  transition: box-shadow 0.2s, transform 0.2s;
}

.metric-card:hover {
  box-shadow: 0 2px 6px rgba(0,0,0,0.4), 0 8px 28px rgba(201,168,76,0.1);
  transform: translateY(-1px);
}

.metric-value {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.2;
  margin-top: 0.25rem;
}

.metric-label {
  font-size: 0.7rem;
  color: var(--si-silver);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* --- Chart containers -------------------------------------- */
.chart-container {
  position: relative;
  min-height: 240px;
}

/* --- Table dark overrides ---------------------------------- */
/* Bloomberg-style: bottom-border only */
.table-dark {
  --bs-table-bg: var(--si-dark-2);
  --bs-table-border-color: transparent;
}

.table-dark th {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--si-silver);
  border-top: none;
  border-left: none;
  border-right: none;
  border-bottom: 2px solid var(--si-gold) !important;
  padding: 0.65rem 0.75rem;
}

.table-dark td {
  border-top: none;
  border-left: none;
  border-right: none;
  border-bottom: 1px solid var(--si-border) !important;
  vertical-align: middle;
  white-space: nowrap;
  padding: 0.6rem 0.75rem;
}

/* Fix: text-muted on dark backgrounds */
.table-dark .text-muted,
.bg-dark .text-muted {
  color: var(--si-silver) !important;
}

/* --- Color utilities --------------------------------------- */
.text-positive { color: #3D8B37; }
.text-negative { color: #C0392B; }

/* --- Cards ------------------------------------------------- */
.card {
  background-color: var(--si-dark-2) !important;
  border: none !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.25);
}

.card-header {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--si-silver);
  background-color: var(--si-dark-3) !important;
  border-bottom: 1px solid var(--si-border) !important;
  border-top: none !important;
  border-left: none !important;
  border-right: none !important;
}

/* --- Home page hero --------------------------------------- */
.si-hero {
  background:
    radial-gradient(ellipse at 72% 45%, rgba(201,168,76,0.07) 0%, transparent 55%),
    radial-gradient(ellipse at 15% 75%, rgba(40,40,120,0.25) 0%, transparent 55%),
    radial-gradient(ellipse at 50% 10%, rgba(20,20,60,0.4) 0%, transparent 60%),
    linear-gradient(160deg, #06070f 0%, #0c0d18 45%, #10112a 100%);
  border-bottom: 1px solid rgba(201,168,76,0.10);
  position: relative;
  overflow: hidden;
  min-height: 88vh;
  display: flex;
  align-items: center;
}
.si-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 80% 20%, rgba(201,168,76,0.04) 0%, transparent 40%),
    radial-gradient(circle at 10% 90%, rgba(60,60,160,0.08) 0%, transparent 40%);
  pointer-events: none;
  animation: hero-breathe 8s ease-in-out infinite;
}
@keyframes hero-breathe {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

/* --- Orbital animation system ----------------------------- */
@keyframes orbit-cw  { to { transform: rotate(360deg);  } }
@keyframes orbit-ccw { to { transform: rotate(-360deg); } }
@keyframes orb-pulse {
  0%, 100% { opacity: 0.8; transform: translate(-50%,-50%) scale(1);   box-shadow: 0 0 32px rgba(201,168,76,0.35), 0 0 80px rgba(201,168,76,0.08); }
  50%       { opacity: 1;   transform: translate(-50%,-50%) scale(1.06); box-shadow: 0 0 48px rgba(201,168,76,0.55), 0 0 100px rgba(201,168,76,0.14); }
}
@keyframes float-in {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: translateY(0);    }
}

.si-orbital-wrap {
  position: relative;
  width: 320px; height: 320px;
  margin: 0 auto;
  flex-shrink: 0;
}
.si-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(201,168,76,0.18);
  top: 50%; left: 50%;
}
.si-ring-1 {
  width: 310px; height: 310px;
  margin-top: -155px; margin-left: -155px;
  animation: orbit-cw 26s linear infinite;
  border-color: rgba(201,168,76,0.13);
}
.si-ring-2 {
  width: 210px; height: 210px;
  margin-top: -105px; margin-left: -105px;
  animation: orbit-ccw 18s linear infinite;
  border-color: rgba(201,168,76,0.22);
}
.si-ring-3 {
  width: 120px; height: 120px;
  margin-top: -60px; margin-left: -60px;
  animation: orbit-cw 11s linear infinite;
  border-color: rgba(201,168,76,0.32);
}
.si-dot {
  position: absolute;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--si-gold);
  box-shadow: 0 0 10px var(--si-gold), 0 0 20px rgba(201,168,76,0.5);
}
.si-dot-top    { top: -4px;  left: 50%; transform: translateX(-50%); }
.si-dot-bottom { bottom: -4px; left: 50%; transform: translateX(-50%); }
.si-dot-right  { right: -4px; top: 50%; transform: translateY(-50%); }
.si-orb-center {
  position: absolute;
  width: 72px; height: 72px;
  top: 50%; left: 50%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201,168,76,0.28), rgba(201,168,76,0.04) 70%, transparent);
  animation: orb-pulse 4s ease-in-out infinite;
  display: flex; align-items: center; justify-content: center;
}
.si-hero-copy {
  animation: float-in 0.9s ease both;
}
.si-hero-copy .hero-eyebrow {
  animation: float-in 0.9s 0.1s ease both;
  opacity: 0;
}
.si-hero-copy h1 {
  animation: float-in 0.9s 0.2s ease both;
  opacity: 0;
}
.si-hero-copy .hero-sub {
  animation: float-in 0.9s 0.35s ease both;
  opacity: 0;
}
.si-hero-copy .hero-ctas {
  animation: float-in 0.9s 0.5s ease both;
  opacity: 0;
}

.si-section-card {
  background: rgba(19, 20, 33, 0.7);
  border: 1px solid var(--si-border);
  border-radius: 12px;
  transition: border-color 0.25s, transform 0.2s, box-shadow 0.25s;
  backdrop-filter: blur(4px);
}
.si-section-card:hover {
  border-color: rgba(201,168,76,0.5);
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(201,168,76,0.07), 0 0 0 1px rgba(201,168,76,0.12);
}

.si-section-title {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--si-gold);
  margin-bottom: 0.5rem;
}

/* Gold divider line */
.si-divider {
  border: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--si-gold), transparent);
  margin: 2rem 0;
  opacity: 0.4;
}

/* --- Fund highlight rows ----------------------------------- */
.fund-highlight-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--si-border);
  font-size: 0.82rem;
}
.fund-highlight-row:last-child { border-bottom: none; }
.fund-highlight-row .fund-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 0.75rem;
  color: #E8E4DC;
}
.fund-highlight-row .fund-val {
  font-weight: 600;
  min-width: 60px;
  text-align: right;
}

/* --- Stub / locked section --------------------------------- */
.si-stub {
  background: var(--si-dark-2);
  border: 1px dashed var(--si-border-light);
  border-radius: 12px;
}

/* --- Download buttons -------------------------------------- */
.btn-outline-secondary {
  font-size: 0.75rem;
}

/* --- Theme toggle button ----------------------------------- */
#theme-toggle {
  font-size: 1rem;
  line-height: 1;
  padding: 0.25rem 0.5rem;
}

/* --- Range/period buttons ---------------------------------- */
.range-btn {
  font-size: 0.78rem;
  padding: 3px 10px;
  color: var(--si-silver);
  border-color: var(--si-border-light);
}
.range-btn.active, .period-btn.active {
  background: var(--si-gold);
  border-color: var(--si-gold);
  color: #000;
  font-weight: 600;
}

/* --- Portfolio builder specifics --------------------------- */
.builder-sidebar { border-right: 1px solid var(--si-border) !important; }
.bm-weight-input { border-color: var(--si-border) !important; }
.cat-label { color: var(--si-silver) !important; font-size: 0.68rem; }
.stat-chip  { color: var(--si-silver); }

/* --- Skeleton loaders -------------------------------------- */
@keyframes si-shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position:  600px 0; }
}
.si-skeleton {
  border-radius: 4px;
  background: linear-gradient(90deg, var(--si-dark-3) 25%, var(--si-border) 50%, var(--si-dark-3) 75%);
  background-size: 600px 100%;
  animation: si-shimmer 1.4s infinite;
  display: inline-block;
}
.si-skeleton-line {
  height: 0.8em;
  width: 100%;
  margin-bottom: 0.5rem;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--si-dark-3) 25%, var(--si-border) 50%, var(--si-dark-3) 75%);
  background-size: 600px 100%;
  animation: si-shimmer 1.4s infinite;
}
.si-skeleton-line.w-75 { width: 75%; }
.si-skeleton-line.w-50 { width: 50%; }

/* --- Counter animation ------------------------------------- */
/* JS adds .si-counted to trigger; .si-counter-val shows animated value */
.si-counter-val {
  display: inline-block;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums lining-nums;
}

/* ============================================================
   LIGHT MODE OVERRIDES
   ============================================================ */

body.bg-light {
  background-color: #F5F3EE !important;
  color: #1A1814 !important;
  --si-silver: #6A6050;
  --si-silver-light: #5A4A30;
}

body.bg-light .si-navbar {
  background: rgba(254,252,248,0.96) !important;
  border-bottom-color: #E0D8C8 !important;
}
body.bg-light .si-brand { color: #1A1814; }

body.bg-light .si-nav-step {
  color: #5A5040;
}
body.bg-light .si-nav-step:hover {
  color: var(--si-gold-dark);
  background: rgba(154,126,42,0.07);
  border-color: rgba(154,126,42,0.2);
}
body.bg-light .si-nav-step.active-page {
  color: var(--si-gold-dark);
  background: rgba(154,126,42,0.1);
  border-color: rgba(154,126,42,0.3);
}
body.bg-light .si-step-num { color: var(--si-gold-dark); }
body.bg-light .si-step-arrow { color: #B0A898; }
body.bg-light .si-nav-sep { background: #D0C8B8; }
body.bg-light .si-nav-secondary { color: #7A7060; }
body.bg-light .si-nav-secondary:hover { color: #4A4030; background: rgba(0,0,0,0.04); }
body.bg-light .si-nav-secondary.active-page { color: var(--si-gold-dark); }
body.bg-light .si-footer { border-top-color: #E0D8C8; background: #F5F0E8; }
body.bg-light .si-footer-link { color: #7A7060; }
body.bg-light .si-footer-link:hover { color: var(--si-gold-dark); }

body.bg-light .nav-link.active-page {
  color: var(--si-gold-dark) !important;
  border-bottom-color: var(--si-gold-dark) !important;
}

body.bg-light .card {
  background-color: #FEFCF8 !important;
  border: none !important;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.06);
}

body.bg-light .card-header {
  background-color: #F5F0E6 !important;
  border-bottom: 1px solid #E0D8C8 !important;
  color: #6A6050 !important;
}

body.bg-light .metric-card {
  background: #FEFCF8 !important;
  border: none !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07), 0 4px 14px rgba(0,0,0,0.05);
}
body.bg-light .metric-label { color: #6A6050 !important; }
body.bg-light .metric-value { color: #1A1814 !important; }

/* Skeleton in light mode */
body.bg-light .si-skeleton,
body.bg-light .si-skeleton-line {
  background: linear-gradient(90deg, #EDE8DE 25%, #E0D8C8 50%, #EDE8DE 75%);
  background-size: 600px 100%;
  animation: si-shimmer 1.4s infinite;
}

body.bg-light .table-dark {
  --bs-table-bg: #FEFCF8;
  --bs-table-striped-bg: #F5F0E6;
  --bs-table-hover-bg: #EDE6D6;
  --bs-table-border-color: transparent;
  --bs-table-color: #1A1814;
  color: #1A1814 !important;
}
body.bg-light .table-dark th {
  color: #6A6050 !important;
  border-top: none !important;
  border-left: none !important;
  border-right: none !important;
  border-bottom: 2px solid var(--si-gold) !important;
  background-color: #F5F0E6 !important;
}
body.bg-light .table-dark td {
  border-top: none !important;
  border-left: none !important;
  border-right: none !important;
  border-bottom: 1px solid #E0D8C8 !important;
  color: #1A1814 !important;
}

body.bg-light table.dataTable thead th,
body.bg-light table.dataTable thead td {
  background-color: #F5F0E6 !important;
  color: #6A6050 !important;
  border-bottom: 2px solid var(--si-gold) !important;
  border-top: none !important;
  border-left: none !important;
  border-right: none !important;
}
body.bg-light table.dataTable tbody td {
  border-top: none !important;
  border-left: none !important;
  border-right: none !important;
  border-bottom: 1px solid #E0D8C8 !important;
}
body.bg-light table.dataTable.table-dark tbody tr:hover td {
  background-color: #EDE6D6 !important;
}

body.bg-light div.dataTables_wrapper div.dataTables_filter input,
body.bg-light div.dataTables_wrapper div.dataTables_length select {
  background-color: #fff;
  border-color: #D0C8B8;
  color: #1A1814;
}
body.bg-light div.dataTables_wrapper div.dataTables_info { color: #6A6050; }
body.bg-light div.dataTables_wrapper div.dataTables_paginate .paginate_button { color: #3A3420 !important; }
body.bg-light div.dataTables_wrapper div.dataTables_paginate .paginate_button.current {
  background: #F5EDDA !important;
  border-color: var(--si-gold) !important;
  color: var(--si-gold-dark) !important;
}

body.bg-light .text-muted { color: #6A6050 !important; }
body.bg-light .text-secondary { color: #6A6050 !important; }
body.bg-light a.text-light { color: #1A1814 !important; }
body.bg-light .btn-outline-secondary { color: #6A6050; border-color: #A8A090; }
body.bg-light .range-btn { color: #6A6050; border-color: #A8A090; }
body.bg-light .range-btn.active, body.bg-light .period-btn.active {
  background: var(--si-gold);
  border-color: var(--si-gold);
  color: #000;
}
body.bg-light .si-hero {
  background: linear-gradient(135deg, #F5F0E0 0%, #EEE8D5 100%) !important;
}
body.bg-light .si-ring { border-color: rgba(154,126,42,0.18); }
body.bg-light .si-ring-2 { border-color: rgba(154,126,42,0.28); }
body.bg-light .si-ring-3 { border-color: rgba(154,126,42,0.38); }
body.bg-light .si-section-card { background: rgba(254,252,248,0.9); border-color: #E0D8C8; backdrop-filter: none; }
body.bg-light .si-section-card { background: #FEFCF8; border-color: #E0D8C8; }
body.bg-light .si-section-card:hover { border-color: var(--si-gold); }
body.bg-light .fund-highlight-row { border-bottom-color: #E0D8C8; }
body.bg-light .fund-highlight-row .fund-name { color: #1A1814; }
body.bg-light .si-stub { border-color: #D0C8B8; }
body.bg-light .builder-sidebar { border-color: #E0D8C8 !important; }
body.bg-light .bm-row { border-color: rgba(0,0,0,0.07) !important; }
body.bg-light .bm-weight-input { border-color: #D0C8B8 !important; color: #1A1814 !important; }

/* ============================================================
   Financial Planner — SI Dark Theme Integration
   ============================================================ */

/* ── Tool cards on home ─────────────────────────────────── */
.fp-tool-card {
  background: var(--si-dark-3);
  border: 1px solid var(--si-border);
  border-radius: 12px;
  padding: 1.25rem;
  border-top-width: 3px;
  transition: border-color 0.2s, transform 0.15s;
}
.fp-tool-card:hover { transform: translateY(-2px); border-color: var(--si-gold) !important; }
.fp-tool-icon { font-size: 2rem; margin-bottom: 0.6rem; }
.fp-tool-title { font-size: 1rem; font-weight: 600; color: #E8E4DC; margin-bottom: 0.4rem; }
.fp-tool-desc { font-size: 0.82rem; color: var(--si-silver); margin-bottom: 0.75rem; }
.fp-tool-badge { font-size: 0.72rem; font-weight: 600; border-radius: 20px; padding: 2px 10px; display: inline-block; }

/* ── Section card (generic container) ─────────────────── */
.fp-section-card {
  background: var(--si-dark-3);
  border: 1px solid var(--si-border);
  border-radius: 10px;
  padding: 1.25rem;
}

/* ── Conversational prompt cards ──────────────────────── */
.fp-convo-card {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  background: var(--si-dark-3);
  border: 1px solid var(--si-border-light);
  border-radius: 12px;
  padding: 1.25rem 1.4rem;
  transition: border-color 0.2s, background 0.15s, box-shadow 0.2s;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}
.fp-convo-card:hover {
  border-color: var(--si-gold);
  background: rgba(201,168,76,0.05);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.fp-convo-num {
  flex-shrink: 0;
  width: 2.25rem; height: 2.25rem;
  border-radius: 50%;
  border: 1.5px solid var(--si-gold-dark);
  background: rgba(201,168,76,0.1);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.82rem; font-weight: 700; color: var(--si-gold);
}
.fp-convo-body { flex: 1; min-width: 0; }
.fp-convo-q { font-size: 1.0rem; font-weight: 600; color: #F0EEE8; margin-bottom: 0.25rem; }
.fp-convo-sub { font-size: 0.82rem; color: var(--si-silver); line-height: 1.4; }
.fp-convo-arrow { font-size: 0.9rem; color: var(--si-border-light); margin-left: auto; flex-shrink: 0; padding-left: 0.5rem; }
.fp-convo-card:hover .fp-convo-arrow { color: var(--si-gold); }

/* ── Chat chips ────────────────────────────────────────── */
.fp-chat-chip {
  background: var(--si-dark-3);
  border: 1px solid var(--si-border);
  border-radius: 20px;
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  color: var(--si-silver);
  text-align: center;
  transition: all 0.2s;
}
.fp-chat-chip:hover { border-color: var(--si-gold); color: var(--si-gold); }

/* ── Concepts list ─────────────────────────────────────── */
.fp-concept-title { font-size: 0.82rem; font-weight: 600; margin-bottom: 0.5rem; }
.fp-concept-list { font-size: 0.78rem; color: var(--si-silver); padding-left: 1.1rem; margin-bottom: 0; }
.fp-concept-list li { margin-bottom: 0.2rem; }

/* ── Form sections ──────────────────────────────────────── */
.fp-form-section { margin-bottom: 1.25rem; }
.fp-form-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--si-gold);
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--si-border);
}
.fp-section-card .form-control,
.fp-section-card .form-select {
  background-color: var(--si-dark-2);
  border-color: var(--si-border-light);
  color: #E8E4DC;
}
.fp-section-card .form-control:focus,
.fp-section-card .form-select:focus {
  background-color: var(--si-dark-2);
  border-color: var(--si-gold);
  color: #E8E4DC;
  box-shadow: 0 0 0 2px rgba(201,168,76,0.15);
}
.fp-section-card .form-label { font-size: 0.82rem; color: var(--si-silver); margin-bottom: 0.3rem; }
.fp-section-card .form-check-label { font-size: 0.85rem; color: var(--si-silver); }
.fp-section-card .form-check-input { border-color: var(--si-border-light); background-color: var(--si-dark-2); }
.fp-section-card .form-check-input:checked { background-color: var(--si-gold); border-color: var(--si-gold); }

/* ── Metric highlights ──────────────────────────────────── */
.fp-metric-highlight {
  background: var(--si-dark-3);
  border: 1px solid var(--si-border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
}
.fp-metric-highlight.fp-metric-good  { border-color: rgba(39,174,96,0.4);  background: rgba(39,174,96,0.05); }
.fp-metric-highlight.fp-metric-warning { border-color: rgba(230,126,34,0.4); background: rgba(230,126,34,0.05); }
.fp-metric-highlight.fp-metric-danger { border-color: rgba(231,76,60,0.4);  background: rgba(231,76,60,0.05); }
.fp-metric-label { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--si-silver); margin-bottom: 0.3rem; }
.fp-metric-value { font-size: 1.6rem; font-weight: 700; color: #E8E4DC; line-height: 1.15; }
.fp-metric-note  { font-size: 0.78rem; color: var(--si-silver); margin-top: 0.35rem; }

/* ── Ratio cards ────────────────────────────────────────── */
.fp-ratio-card {
  background: var(--si-dark-3);
  border: 1px solid var(--si-border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
}
.fp-ratio-card.fp-ratio-good    { border-left: 3px solid #27ae60; }
.fp-ratio-card.fp-ratio-warning { border-left: 3px solid #e67e22; }
.fp-ratio-card.fp-ratio-danger  { border-left: 3px solid #e74c3c; }
.fp-ratio-label      { font-size: 0.78rem; color: var(--si-silver); font-weight: 500; }
.fp-ratio-value      { font-size: 1.1rem; font-weight: 700; color: #E8E4DC; }
.fp-ratio-assessment { font-size: 0.78rem; color: var(--si-silver); margin-top: 0.3rem; }
.fp-ratio-benchmark  { font-size: 0.7rem;  color: #6c7a87; margin-top: 0.2rem; }

/* ── Alert boxes ────────────────────────────────────────── */
.fp-alert-good    { border-left: 3px solid #27ae60 !important; background: rgba(39,174,96,0.06) !important; }
.fp-alert-warning { border-left: 3px solid #e67e22 !important; background: rgba(230,126,34,0.06) !important; }
.fp-alert-danger  { border-left: 3px solid #e74c3c !important; background: rgba(231,76,60,0.06) !important; }

/* ── Nav tabs / pills ───────────────────────────────────── */
.fp-nav-tabs { border-bottom: 1px solid var(--si-border); }
.fp-nav-tabs .nav-link { color: var(--si-silver); border: none; border-radius: 0; padding-bottom: 0.6rem; font-size: 0.88rem; }
.fp-nav-tabs .nav-link:hover { color: var(--si-gold); background: transparent; }
.fp-nav-tabs .nav-link.active { color: var(--si-gold); border-bottom: 2px solid var(--si-gold); background: transparent; font-weight: 600; }

.fp-pills .nav-link { color: var(--si-silver); background: var(--si-dark-3); border: 1px solid var(--si-border); border-radius: 20px; font-size: 0.85rem; margin-right: 0.5rem; }
.fp-pills .nav-link.active { background: rgba(201,168,76,0.15); color: var(--si-gold); border-color: var(--si-gold); }

/* ── Allocation badge ───────────────────────────────────── */
.fp-alloc-badge {
  background: rgba(201,168,76,0.15);
  color: var(--si-gold);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.7rem;
  border-radius: 20px;
}

/* ── Chat interface ─────────────────────────────────────── */
.fp-chat-wrapper {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 8rem);
  border: 1px solid var(--si-border);
  border-radius: 12px;
  overflow: hidden;
}
.fp-chat-header {
  background: var(--si-dark-3);
  border-bottom: 1px solid var(--si-border);
  padding: 1rem 1.25rem 0.85rem;
  flex-shrink: 0;
}
.fp-chat-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(201,168,76,0.15);
  color: var(--si-gold);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.95rem;
}
.fp-chat-avatar-sm {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: rgba(201,168,76,0.12);
  color: var(--si-gold);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem;
  flex-shrink: 0;
}
.fp-chat-progress { height: 3px; background: var(--si-border); border-radius: 2px; overflow: hidden; }
.fp-chat-progress-bar { height: 100%; background: var(--si-gold); border-radius: 2px; transition: width 0.4s ease; width: 0%; }

.fp-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  background: var(--si-dark-2);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  scroll-behavior: smooth;
}
.fp-chat-input-area {
  background: var(--si-dark-3);
  border-top: 1px solid var(--si-border);
  padding: 0.85rem 1.25rem;
  flex-shrink: 0;
}
.fp-chat-input-field {
  background: var(--si-dark-2) !important;
  border-color: var(--si-border-light) !important;
  color: #E8E4DC !important;
}
.fp-chat-input-field:focus {
  border-color: var(--si-gold) !important;
  box-shadow: 0 0 0 2px rgba(201,168,76,0.15) !important;
}

/* Chat bubbles */
.fp-bw-bot  { display: flex; align-items: flex-end; gap: 0.5rem; }
.fp-bw-user { display: flex; justify-content: flex-end; }

.fp-bubble {
  max-width: 72%;
  padding: 0.6rem 0.9rem;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.55;
  word-break: break-word;
}
.fp-bubble-bot     { background: var(--si-dark-3); border: 1px solid var(--si-border); border-bottom-left-radius: 4px; color: #E8E4DC; }
.fp-bubble-hint    { background: rgba(201,168,76,0.07); border: 1px solid rgba(201,168,76,0.2); border-bottom-left-radius: 4px; color: var(--si-silver); font-style: italic; font-size: 0.83rem; }
.fp-bubble-result  { background: linear-gradient(135deg, rgba(201,168,76,0.2) 0%, rgba(201,168,76,0.08) 100%); border: 1px solid rgba(201,168,76,0.3); border-bottom-left-radius: 4px; color: #E8E4DC; max-width: 82%; }
.fp-bubble-good    { background: var(--si-dark-3); border: 1px solid var(--si-border); border-left: 3px solid #27ae60; border-bottom-left-radius: 4px; color: #E8E4DC; }
.fp-bubble-warning { background: var(--si-dark-3); border: 1px solid var(--si-border); border-left: 3px solid #e67e22; border-bottom-left-radius: 4px; color: #E8E4DC; }
.fp-bubble-danger  { background: var(--si-dark-3); border: 1px solid var(--si-border); border-left: 3px solid #e74c3c; border-bottom-left-radius: 4px; color: #E8E4DC; }
.fp-bubble-tip     { background: rgba(14,165,233,0.07); border: 1px solid rgba(14,165,233,0.2); border-left: 3px solid #0ea5e9; border-bottom-left-radius: 4px; color: var(--si-silver); font-size: 0.85rem; }
.fp-bubble-info    { background: rgba(168,178,188,0.05); border: 1px solid var(--si-border); border-bottom-left-radius: 4px; color: var(--si-silver); }
.fp-bubble-user    { background: rgba(201,168,76,0.15); border: 1px solid rgba(201,168,76,0.25); border-bottom-right-radius: 4px; color: #E8E4DC; }

.fp-typing-dots { display: flex; gap: 5px; align-items: center; padding: 2px 4px; }
.fp-typing-dots span { width: 6px; height: 6px; background: var(--si-silver); border-radius: 50%; animation: fptdot 1.2s infinite ease-in-out; }
.fp-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.fp-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes fptdot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%           { transform: translateY(-6px); opacity: 1; }
}

/* Light mode overrides */
body.bg-light .fp-tool-card      { background: #fff; border-color: #E0D8C8; }
body.bg-light .fp-section-card   { background: #fff; border-color: #E0D8C8; }
body.bg-light .fp-chat-header    { background: #fff; border-color: #E0D8C8; }
body.bg-light .fp-chat-messages  { background: #F5F2ED; }
body.bg-light .fp-chat-input-area { background: #fff; border-color: #E0D8C8; }
body.bg-light .fp-bubble-bot     { background: #fff; border-color: #E0D8C8; color: #1A1814; }
body.bg-light .fp-bubble-user    { background: rgba(201,168,76,0.12); color: #1A1814; }
body.bg-light .fp-metric-highlight { background: #fff; border-color: #E0D8C8; }
body.bg-light .fp-metric-value   { color: #1A1814; }
body.bg-light .fp-ratio-card     { background: #fff; border-color: #E0D8C8; }
body.bg-light .fp-chat-wrapper   { border-color: #E0D8C8; }
body.bg-light .fp-tool-title     { color: #1A1814; }
body.bg-light .fp-section-card .form-control,
body.bg-light .fp-section-card .form-select { background: #fff; border-color: #D0C8B8; color: #1A1814; }
body.bg-light .fp-chat-chip      { background: #fff; border-color: #E0D8C8; color: #5A5045; }
body.bg-light .fp-convo-card     { background: #fff; border-color: #D8D0C0; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
body.bg-light .fp-convo-q        { color: #1A1814; }
body.bg-light .fp-convo-num      { border-color: var(--si-gold-dark); background: rgba(201,168,76,0.08); }

/* ── Signup nudge bar ─────────────────────────────────── */
.fp-nudge-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 1040;
  background: var(--si-dark-2);
  border-top: 1px solid var(--si-border-light);
  padding: 0.75rem 1.25rem;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s;
  opacity: 0;
}
.fp-nudge-bar.fp-nudge-visible  { transform: translateY(0); opacity: 1; }
.fp-nudge-bar.fp-nudge-hiding   { transform: translateY(100%); opacity: 0; }
.fp-nudge-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}
.fp-nudge-icon { color: var(--si-gold); font-size: 1.1rem; flex-shrink: 0; }
.fp-nudge-text { flex: 1; font-size: 0.875rem; color: var(--si-silver-light); min-width: 200px; line-height: 1.4; }
.fp-nudge-text strong { color: #F0EEE8; }
.fp-nudge-btn  { white-space: nowrap; flex-shrink: 0; }
.fp-nudge-dismiss {
  background: none; border: none; padding: 0.25rem 0.4rem;
  color: var(--si-silver); font-size: 1rem; cursor: pointer;
  flex-shrink: 0; line-height: 1;
  transition: color 0.15s;
}
.fp-nudge-dismiss:hover { color: #F0EEE8; }
body.bg-light .fp-nudge-bar  { background: #fff; border-top-color: #D8D0C0; }
body.bg-light .fp-nudge-text { color: #4A4035; }
body.bg-light .fp-nudge-text strong { color: #1A1814; }
