/* ═══════════════════════════════════════════════════════════════════════════
   QUAFI — Design System
   Font: Neue Haas Grotesk / Helvetica Now / system-ui
   Palette: marble #f2f2ee · teal #3a6a72 · gold #c8a96e · dark #3a3a42
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Tokens ──────────────────────────────────────────────────────────────── */
:root {
  --teal:        #3a6a72;
  --teal-light:  #4d8d98;
  --teal-pale:   #d4e6e9;
  --green:       #4a7a6a;
  --dark1:       #3a3a42;
  --dark2:       #5a5a62;
  --marble:      #f2f2ee;
  --marble2:     #e8e8e4;
  --marble3:     #dcdcd8;
  --gold:        #c8a96e;
  --gold-light:  #e8d4b0;
  --white:       #ffffff;
  --red-soft:    #b34a4a;
  --green-soft:  #3a7a5a;

  --ff:          'HelveticaNeue', 'Helvetica Neue', 'Helvetica', -apple-system,
                 BlinkMacSystemFont, 'Arial', sans-serif;
  --radius:      12px;
  --radius-lg:   20px;
  --shadow-sm:   0 2px 8px rgba(58,106,114,0.08);
  --shadow-md:   0 4px 20px rgba(58,106,114,0.12);
  --shadow-lg:   0 8px 40px rgba(58,106,114,0.16);
  --transition:  220ms cubic-bezier(0.4, 0, 0.2, 1);

  /* ── Mobile-system tokens (consumed by quafi-mobile.css only) ─────────────
     Defined here so any new desktop component can also reach for them, but
     no desktop rule currently uses these — they don't change PC rendering. */

  /* Standardized 3-breakpoint system. See docs/handoff-mobile-experience.md */
  --bp-mobile:   640px;   /* ≤ 640px: phone (portrait + small landscape) */
  --bp-tablet:  1024px;   /* 641–1024px: large phone landscape + tablet portrait */
  --bp-desktop: 1025px;   /* ≥ 1025px: tablet landscape + laptop + desktop (UNCHANGED) */

  /* Mobile type scale */
  --fs-mobile-display: 1.95rem;
  --fs-mobile-h1:      1.55rem;
  --fs-mobile-h2:      1.25rem;
  --fs-mobile-h3:      1.05rem;
  --fs-mobile-body:    0.95rem;
  --fs-mobile-small:   0.82rem;
  --fs-mobile-tiny:    0.72rem;

  /* Mobile spacing — 8-px grid */
  --sp-1: 0.5rem;
  --sp-2: 0.75rem;
  --sp-3: 1rem;
  --sp-4: 1.25rem;
  --sp-5: 1.75rem;
  --sp-6: 2.5rem;

  /* Mobile safe-area insets (iOS notch / home indicator) */
  --safe-top:    env(safe-area-inset-top,    0px);
  --safe-bot:    env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left,   0px);
  --safe-right:  env(safe-area-inset-right,  0px);

  /* Min tap target — Apple HIG / Material baseline */
  --tap: 44px;

  /* Motion tokens (mobile-scope only — desktop uses the legacy --transition) */
  --m-fast:    180ms;
  --m-medium:  280ms;
  --m-slow:    400ms;
  --m-loop:   2400ms;
  --m-ease:    cubic-bezier(.2, .9, .25, 1);
  --m-ease-io: ease-in-out;
}

/* Reduced-motion override: every loop / transition collapses to 0ms. The
   media-query target is the user system preference, not viewport size, so
   it applies on desktop and mobile alike — but the values it overrides
   are ONLY referenced from quafi-mobile.css, so desktop behavior is
   unchanged. */
@media (prefers-reduced-motion: reduce) {
  :root { --m-fast: 0ms; --m-medium: 0ms; --m-slow: 0ms; --m-loop: 0ms; }
}

/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  /* Pin the text scale at 100% so iOS Safari does NOT auto-boost type when
     the device rotates to landscape. Without this, the bottom disclaimer
     (and other dense paragraphs) render at 2× – 3× the intended size on
     iPhone landscape because Safari's "Text Boost" heuristic kicks in.
     The 100% value preserves the CSS-author-specified sizes verbatim on
     every browser; no effect on desktop. */
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--ff);
  background: var(--marble);
  color: var(--dark1);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Status bar ───────────────────────────────────────────────────────────── */
#status-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: 30px;
  padding: 0 1.5rem;
  font-size: 0.78rem;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  transition: var(--transition);
}
#status-bar.ready       { background: #e0e4e2; color: var(--teal); }
#status-bar.building    { background: #ece7db; color: #8a6a2e; }
#status-bar.stale       { background: #ece1de; color: var(--red-soft); }
#status-bar.error       { background: #ece1de; color: var(--red-soft); }
#status-bar.hidden      { display: none; }
.status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.status-dot.pulse { animation: pulse 1.8s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* ── Screen system ─────────────────────────────────────────────────────────── */
.screen {
  display: none;
  min-height: 100vh;
}
.screen.active { display: flex; flex-direction: column; }

/* Push content below fixed status bar — applied to navbar directly */
.nav-bar { margin-top: 30px; align-self: stretch; }

/* ── Language toggle (React NavBar) ──────────────────────────────────────── */
.lang-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 28px;
  padding: 0 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--marble2);
  background: transparent;
  color: var(--dark2);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: border-color 150ms, color 150ms;
  flex-shrink: 0;
}
.lang-toggle:hover { border-color: var(--teal); color: var(--teal); }

/* ── Currency labels + transparency disclaimer (native-currency display) ──── */
.cur-tag {
  display: inline-block;
  margin-left: 0.5em;
  padding: 0.08em 0.5em;
  border-radius: 999px;
  background: var(--marble2);
  color: var(--dark2);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  vertical-align: middle;
}
.cur-note {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--dark2);
  letter-spacing: 0.03em;
}
.currency-disclaimer {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  margin: 1.4rem 0 0.4rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--marble2);
  border-left: 3px solid var(--gold);
  border-radius: 8px;
  background: var(--marble);
}
.currency-disclaimer.compact { margin-top: 1rem; padding: 0.7rem 0.9rem; }
.currency-disclaimer .currency-disclaimer-icon {
  color: var(--gold);
  font-size: 1rem;
  line-height: 1.4;
  flex-shrink: 0;
}
.currency-disclaimer p {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--dark2);
}

/* ── Navigation bar (all screens except home) ─────────────────────────────── */
.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 3rem;
  border-bottom: 1px solid var(--marble2);
  background: var(--white);
  position: sticky;
  top: 30px;
  z-index: 100;
}
.nav-brand {
  display: inline-flex;
  align-items: center;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  letter-spacing: -0.01em;
  color: var(--teal);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
/* ── QUAFI brand signature: animated Bohr-atom mark ────────────────────────
   Three concentric "orbit" tracks + a nucleus + 4 electrons per orbit.
   Electron groups rotate alternately CW / CCW / CW around the SVG center.
   The wordmark "QUAFI" sits next to the mark — the mark is signature only. */
.quafi-mark {
  display: inline-block;
  flex-shrink: 0;
  color: var(--teal);
  vertical-align: middle;
  overflow: visible;
}
.quafi-mark-lg { width: 76px;  height: 76px;  margin-bottom: 0.9rem; }
.quafi-mark-sm { width: 32px;  height: 32px;  margin-right: 0.45rem; }

/* Concentric tracks — outer is the brand frame, inner two are subtler orbits */
.quafi-mark .qm-track {
  fill: none;
  stroke: currentColor;
}
.quafi-mark .qm-track-3 { stroke-width: 1.6; opacity: 1;    }
.quafi-mark .qm-track-2 { stroke-width: 0.8; opacity: 0.45; }
.quafi-mark .qm-track-1 { stroke-width: 0.7; opacity: 0.40; }

/* Nucleus + electrons — solid filled circles in the brand colour */
.quafi-mark .qm-core,
.quafi-mark .qm-orbit circle {
  fill: currentColor;
  stroke: none;
}

/* Orbits rotate around the SVG centre (40, 40). Historically this was a CSS
   animation with transform-origin: 50% 50% + transform-box: view-box, but
   that combination is unreliable on Chromium/Windows — the orbits sit still
   while macOS browsers render them fine. We now drive rotation from JS by
   setting the SVG `transform` attribute (rotate(angle, cx, cy) — SVG 1.1
   syntax, works in every browser, no transform-box involved).
   See `animateQuafiMark()` in js/app.js. */
.nav-actions { display: flex; align-items: center; gap: 0.75rem; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.4rem;
  font-family: var(--ff);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--teal);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(58,106,114,0.3);
}
.btn-primary:hover { background: var(--teal-light); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: var(--white);
  color: var(--dark1);
  border: 1.5px solid var(--marble3);
}
.btn-secondary:hover { border-color: var(--teal); color: var(--teal); background: var(--teal-pale); }

.btn-ghost {
  background: transparent;
  color: var(--dark2);
  padding: 0.5rem 1rem;
}
.btn-ghost:hover { color: var(--teal); background: var(--teal-pale); }

.btn-sm { padding: 0.45rem 1rem; font-size: 0.83rem; }
.btn-lg { padding: 0.85rem 2rem; font-size: 1rem; }
.btn-xl {
  padding: 1.1rem 2.5rem;
  font-size: 1.05rem;
  font-weight: 700;
  border-radius: var(--radius-lg);
}

/* Toggle-group buttons */
.toggle-group {
  display: inline-flex;
  background: var(--marble2);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
}
.toggle-group .toggle-btn {
  background: transparent;
  color: var(--dark2);
  border: none;
  border-radius: calc(var(--radius) - 3px);
  padding: 0.5rem 1.1rem;
  font-family: var(--ff);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}
.toggle-group .toggle-btn.active {
  background: var(--white);
  color: var(--teal);
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

/* Stacked toggle: small range hint under the main label
   (used for the Time horizon selector) */
.toggle-group-stacked .toggle-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.15;
  padding: 0.45rem 1.1rem 0.5rem;
}
.toggle-btn .toggle-sub {
  display: block;
  margin-top: 2px;
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--dark2);
  opacity: 0.55;
  letter-spacing: 0.02em;
}
.toggle-btn.active .toggle-sub {
  opacity: 0.7;
  color: var(--dark2);
  font-weight: 500;
}

/* ── ══════════════════ HOME SCREEN ══════════════════ ── */
#screen-home {
  align-items: center;
  justify-content: center;
}

.home-container {
  max-width: 800px;
  width: 100%;
  text-align: center;
  padding: 3rem 2rem;
}

.home-logo {
  margin-bottom: 3.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--teal);
}
.home-logo .wordmark {
  display: block;
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--dark1);
  line-height: 1;
}
.home-logo .tagline {
  display: block;
  font-size: 0.92rem;
  color: var(--dark2);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 0.5rem;
  font-weight: 500;
}

.home-intro {
  max-width: 640px;
  margin: -1.5rem auto 2.75rem;
  text-align: center;
}
.home-intro .intro-eyebrow {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--teal);
  background: var(--teal-pale);
  padding: 0.32rem 0.85rem;
  border-radius: 999px;
  margin-bottom: 1.25rem;
}
.home-intro p {
  font-size: 0.94rem;
  color: var(--dark2);
  line-height: 1.65;
  margin: 0 0 0.85rem;
}
.home-intro p:last-child { margin-bottom: 0; }
.home-intro p em {
  font-style: normal;
  color: var(--dark1);
  font-weight: 600;
}
.home-intro .intro-highlight {
  margin-top: 1.1rem;
  padding: 1rem 1.15rem;
  background: var(--marble);
  border-left: 3px solid var(--teal);
  border-radius: 8px;
  text-align: left;
  font-size: 0.92rem;
}
.home-intro .intro-highlight strong {
  color: var(--dark1);
  font-weight: 700;
}
.home-intro .intro-leadin {
  margin-top: 1.4rem;
  font-size: 0.85rem;
  color: var(--dark2);
  opacity: 0.75;
  letter-spacing: 0.02em;
}

.home-question {
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--dark1);
  line-height: 1.2;
  margin-bottom: 3rem;
}
.home-question em,
.home-question .hl {
  font-style: normal;
  color: var(--teal);
}

.home-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  max-width: 680px;
  margin: 0 auto;
}

.home-card {
  background: var(--white);
  border: 2px solid var(--marble2);
  border-radius: var(--radius-lg);
  padding: 2.2rem 1.8rem 2rem;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  position: relative;
  overflow: hidden;
}
.home-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--teal);
  transform: scaleX(0);
  transition: var(--transition);
  transform-origin: left;
}
.home-card:hover {
  border-color: var(--teal);
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}
.home-card:hover::before { transform: scaleX(1); }
.home-card.gold-accent::before { background: var(--gold); }
.home-card.gold-accent:hover { border-color: var(--gold); }

.card-icon {
  width: 44px; height: 44px;
  background: var(--teal-pale);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--teal);
  font-size: 1.3rem;
}
.home-card.gold-accent .card-icon {
  background: var(--gold-light);
  color: #8a6030;
}
.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--dark1);
  line-height: 1.25;
}
.card-desc {
  font-size: 0.88rem;
  color: var(--dark2);
  line-height: 1.55;
}
.card-arrow {
  margin-top: auto;
  font-size: 1.1rem;
  color: var(--teal);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.home-card.gold-accent .card-arrow { color: var(--gold); }

.home-footer {
  margin-top: 4rem;
  font-size: 0.78rem;
  color: var(--dark2);
  opacity: 0.6;
  letter-spacing: 0.05em;
}

/* ── ══════════════════ SELECTOR SCREEN ══════════════════ ── */
.screen-body {
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem 2rem 4rem;
  flex: 1;
}

.screen-title {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--dark1);
  margin-bottom: 0.4rem;
}
.screen-subtitle {
  font-size: 0.95rem;
  color: var(--dark2);
  margin-bottom: 2.5rem;
  line-height: 1.5;
}

/* Form sections */
.form-section {
  background: var(--white);
  border: 1px solid var(--marble2);
  border-radius: var(--radius-lg);
  padding: 1.75rem 2rem;
  margin-bottom: 1.25rem;
}
.form-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 1.2rem;
}
.form-row {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}
/* Modifier: force label/hint and the control to stack vertically,
   regardless of available width. Used on the Time-horizon row so the
   toggle bar never jumps between right-of-text and below-text as the
   hint string length changes. */
.form-row.form-row-stacked {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.85rem;
}
.form-label {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--dark1);
  min-width: 160px;
}
.form-hint {
  font-size: 0.8rem;
  color: var(--dark2);
  margin-top: 0.35rem;
}

/* Number input */
.num-input-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.num-input-group button {
  width: 32px; height: 32px;
  border: 1.5px solid var(--marble3);
  background: var(--white);
  border-radius: 8px;
  font-size: 1rem;
  color: var(--dark1);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.num-input-group button:hover { border-color: var(--teal); color: var(--teal); }
.num-input-group input {
  width: 56px;
  text-align: center;
  border: 1.5px solid var(--marble3);
  border-radius: 8px;
  padding: 0.35rem;
  font-family: var(--ff);
  font-size: 1rem;
  font-weight: 600;
  color: var(--dark1);
  background: var(--white);
  outline: none;
}
.num-input-group input:focus { border-color: var(--teal); }
/* Hide native browser spinner buttons — we use the custom ± controls */
.num-input-group input[type="number"]::-webkit-outer-spin-button,
.num-input-group input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.num-input-group input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ── Glossary "Learn more" hints (InfoHint.jsx) ──────────────────────────────
   A subtle "?" beside a financial label that opens a small branded card with a
   plain-language definition + example. See docs/glossary-info-hints-action-plan.md */
.info-hint-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}
/* Keeps an asset-type chip and its hint on the same baseline inside .chip-group */
.chip-with-hint {
  display: inline-flex;
  align-items: center;
}
.info-hint {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;                 /* never grow/shrink inside a flex label */
  align-self: center;         /* never stretch to the row height */
  box-sizing: border-box;
  aspect-ratio: 1 / 1;
  width: 16px;
  height: 16px;
  min-width: 16px;
  min-height: 16px;           /* beats the universal mobile --tap floor */
  margin-left: 6px;
  padding: 0;
  border: 1.2px solid #b9cdd0;
  border-radius: 50%;
  background: transparent;
  color: #9fb4b8;
  font-family: var(--ff);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  cursor: help;
  outline: none;
  transition: background 0.12s, color 0.12s, border-color 0.12s, box-shadow 0.12s;
}
/* Enlarge the touch/click target to ~36px without growing the visual. */
.info-hint::before {
  content: '';
  position: absolute;
  inset: -10px;
}
.info-hint:hover,
.info-hint:focus-visible,
.info-hint.is-open {
  background: var(--teal);
  border-color: var(--teal);
  color: var(--white);
}
.info-hint:focus-visible { box-shadow: 0 0 0 3px var(--teal-pale); }

/* Pill variant of the hint trigger — a labelled "? How to read" chip used under
   chart titles. Opens the same branded glossary popover/modal as the "?" icon. */
.info-hint-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.22rem 0.62rem 0.22rem 0.42rem;
  border: 1px solid var(--marble3);
  border-radius: 999px;
  background: var(--marble);
  color: var(--dark2);
  font-family: var(--ff);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1;
  cursor: pointer;
  outline: none;
  transition: background 0.14s, color 0.14s, border-color 0.14s, box-shadow 0.14s;
}
.info-hint-pill:hover,
.info-hint-pill:focus-visible,
.info-hint-pill.is-open {
  background: var(--teal-pale);
  border-color: var(--teal);
  color: var(--teal);
}
.info-hint-pill:focus-visible { box-shadow: 0 0 0 3px var(--teal-pale); }
.info-hint-pill-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 15px;
  height: 15px;
  border: 1.2px solid currentColor;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
}
.info-hint-pill-label { line-height: 1; }

/* Roomier, scrollable card for the multi-paragraph "How to read" content. */
.glossary-pop.is-howto { max-width: min(360px, 88vw); max-height: 60vh; overflow-y: auto; }
.glossary-pop.is-modal.is-howto { max-height: 82vh; overflow-y: auto; }

/* The how-to pill sits just under a chart's title + subtitle. */
.chart-howto-row { margin-top: 0.5rem; }
/* The how-to card, portalled to <body>, sits above other UI. */
.glossary-pop.is-fixed { right: auto; bottom: auto; z-index: 120; }

.glossary-pop {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 60;
  width: max-content;
  max-width: min(300px, 80vw);
  text-align: left;
  /* The hint sits inside labels that may be uppercased (e.g. .metric-label);
     text-transform / letter-spacing inherit, so reset them — the card reads in
     normal sentence case (only the eyebrow re-applies uppercase). */
  text-transform: none;
  letter-spacing: normal;
  background: var(--white);
  border: 0.5px solid var(--marble3);
  border-top: 3px solid var(--teal);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: default;
  white-space: normal;
  animation: glosspop-in 0.12s ease-out;
}
.glossary-pop.align-right { left: auto; right: 0; }
@keyframes glosspop-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .glossary-pop { animation: none; }
}
.glossary-pop-eyebrow {
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
}
.glossary-pop-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--teal);
}
.glossary-pop-def {
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--dark2);
}
.glossary-pop-ex {
  font-size: 0.76rem;
  line-height: 1.5;
  color: #2f5860;
  background: var(--teal-pale);
  border-radius: 8px;
  padding: 7px 9px;
  margin-top: 2px;
}
.glossary-pop-ex-label { font-weight: 600; }

/* Mobile presentation: a centered modal over a blurred backdrop (rendered via a
   portal to <body> only on ≤640px — see InfoHint.jsx). Avoids the off-screen
   anchored popover entirely and gives the card room to breathe. */
.glossary-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(58, 106, 114, 0.30);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: glossoverlay-in 0.14s ease-out;
}
.glossary-pop.is-modal {
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  width: 100%;
  max-width: 380px;
  padding: 18px 18px 16px;
  gap: 8px;
  box-shadow: var(--shadow-lg);
  animation: glossmodal-in 0.16s ease-out;
}
.glossary-pop.is-modal .glossary-pop-title { font-size: 1.05rem; }
.glossary-pop.is-modal .glossary-pop-def { font-size: 0.9rem; line-height: 1.6; }
.glossary-pop.is-modal .glossary-pop-ex { font-size: 0.85rem; padding: 9px 11px; }
.glossary-pop-close {
  position: absolute;
  top: 8px;
  right: 9px;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--dark2);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.glossary-pop-close:hover { background: var(--marble2); color: var(--dark1); }
@keyframes glossoverlay-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes glossmodal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .glossary-overlay, .glossary-pop.is-modal { animation: none; }
}

/* ── Sector → Industry picker (SectorIndustryPicker.jsx) ─────────────────────
   A calm summary row that expands to a searchable, two-level grouped picker.
   Replaces the truncated wall of sector pills. */
.sip-control { width: 100%; }
.sip-status { font-size: 0.85rem; color: var(--dark2); }
.sip { width: 100%; }

.sip-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 0.7rem 0.9rem;
  background: var(--white);
  border: 1.5px solid var(--marble3);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--ff);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.sip-summary:hover { border-color: var(--teal-light); }
.sip-summary:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--teal-pale); }
.sip-summary.open { border-color: var(--teal); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.sip-summary-text { font-size: 0.9rem; font-weight: 500; color: var(--dark1); text-align: left; }
.sip-summary-chevron { width: 18px; height: 18px; color: var(--dark2); flex: none; transition: transform 0.18s; }
.sip-summary.open .sip-summary-chevron { transform: rotate(180deg); }

.sip-panel {
  border: 1.5px solid var(--teal);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--white);
  overflow: hidden;
}
.sip-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 0.5px solid var(--marble3);
}
.sip-search {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
}
.sip-search svg {
  position: absolute;
  left: 10px;
  width: 15px;
  height: 15px;
  color: var(--dark2);
  pointer-events: none;
}
.sip-search input {
  width: 100%;
  padding: 0.5rem 1.9rem 0.5rem 2rem;
  font-family: var(--ff);
  font-size: 0.85rem;
  color: var(--dark1);
  background: var(--marble);
  border: 1px solid var(--marble3);
  border-radius: 8px;
  outline: none;
}
.sip-search input:focus { border-color: var(--teal-light); background: var(--white); }
.sip-search-clear {
  position: absolute;
  right: 7px;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--dark2);
  font-size: 11px;
  cursor: pointer;
}
.sip-search-clear:hover { background: var(--marble2); }
.sip-bulk { display: flex; align-items: center; gap: 8px; flex: none; }
.sip-bulk button {
  background: none;
  border: none;
  padding: 2px 2px;
  font-family: var(--ff);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--teal);
  cursor: pointer;
}
.sip-bulk button:hover { text-decoration: underline; }
.sip-bulk-sep { color: var(--marble3); }

.sip-list { max-height: 340px; overflow-y: auto; padding: 4px 0; }
.sip-empty { padding: 18px 14px; text-align: center; font-size: 0.85rem; color: var(--dark2); }

.sip-group { border-bottom: 0.5px solid var(--marble); }
.sip-group:last-child { border-bottom: none; }
.sip-row { display: flex; align-items: stretch; }
.sip-check {
  flex: none;
  align-self: center;
  width: 20px;
  height: 20px;
  margin: 0 8px 0 12px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  border: 1.5px solid #b9cdd0;
  border-radius: 6px;
  background: var(--white);
  color: var(--white);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.sip-check.all, .sip-check.some { background: var(--teal); border-color: var(--teal); }
.sip-check svg { width: 14px; height: 14px; }
.sip-check:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--teal-pale); }
.sip-row-main {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 0.62rem 12px 0.62rem 0;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--ff);
  text-align: left;
}
.sip-row-main:hover .sip-sector-name { color: var(--teal); }
.sip-sector-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--dark1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sip-count { flex: none; font-size: 0.72rem; color: var(--dark2); font-variant-numeric: tabular-nums; }
.sip-row-chevron { flex: none; width: 16px; height: 16px; color: var(--dark2); transition: transform 0.16s; }
.sip-row-chevron.open { transform: rotate(180deg); }

.sip-industries {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 14px;
  padding: 2px 14px 12px 40px;
}
.sip-ind {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 0.8rem;
  color: var(--dark2);
  cursor: pointer;
  min-width: 0;
}
.sip-ind input {
  flex: none;
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--teal);
  cursor: pointer;
}
.sip-ind span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Sector chips: grow to fill row whitespace so the grid feels balanced.
   Asset-type chips (only 4 entries) stay content-sized via the default rule. */
#industry-chips .chip {
  flex: 1 1 auto;
  justify-content: center;
  text-align: center;
  max-width: 240px;
}

/* Pill-button chip — toggle state lives entirely in `.selected` class */
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.42rem 1rem;
  border: 1.5px solid var(--teal);
  border-radius: 100px;
  font-family: var(--ff);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.005em;
  color: var(--white);
  background: var(--teal);
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
  white-space: nowrap;
  outline: none;
}
.chip:hover { filter: brightness(1.05); }
.chip:focus-visible { box-shadow: 0 0 0 3px var(--teal-pale); }

.chip:not(.selected) {
  background: transparent;
  color: var(--dark2);
  border-color: var(--marble3);
  font-weight: 500;
}
.chip:not(.selected):hover {
  border-color: var(--teal);
  color: var(--teal);
  filter: none;
}

/* ── "Coming soon" chips: rendered like an unselected chip but inert ──── */
.chip.chip-soon,
.chip.chip-soon:hover,
.chip.chip-soon:focus {
  background: transparent !important;
  color: var(--dark2) !important;
  border-color: var(--marble3) !important;
  font-weight: 500 !important;
  cursor: not-allowed !important;
  filter: none !important;
  box-shadow: none !important;
  opacity: 0.85;
  position: relative;
  padding-right: 2.6rem;            /* room for the SOON tag */
}
.chip.chip-soon[disabled] { pointer-events: auto; }   /* keep tooltip on hover */

.chip-soon-tag {
  position: absolute;
  right: 0.35rem;
  bottom: 0.2rem;
  background: var(--gold);
  color: var(--white);
  font-size: 0.5rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  padding: 0.1rem 0.36rem;
  border-radius: 100px;
  line-height: 1;
  text-transform: uppercase;
  pointer-events: none;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

/* Run button row */
.run-row {
  display: flex;
  justify-content: center;
  padding: 2rem 0;
}

/* ── ══════════════════ KNOWN PORTFOLIO SCREEN ══════════════════ ── */

/* Ticker search */
.search-container {
  position: relative;
  margin-bottom: 1rem;
}
.search-input {
  width: 100%;
  padding: 0.85rem 1.1rem 0.85rem 2.8rem;
  font-family: var(--ff);
  font-size: 0.95rem;
  color: var(--dark1);
  background: var(--white);
  border: 1.5px solid var(--marble3);
  border-radius: var(--radius);
  outline: none;
  transition: var(--transition);
}
.search-input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-pale); }
.search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--dark2);
  font-size: 0.95rem;
  pointer-events: none;
}
.search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--white);
  border: 1px solid var(--marble3);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  max-height: 320px;
  overflow-y: auto;
  display: none;
}
.search-dropdown.open { display: block; }
.search-result-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid var(--marble);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--marble); }
.search-result-item .ticker-tag {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--white);
  background: var(--teal);
  padding: 0.2rem 0.5rem;
  border-radius: 5px;
  min-width: 64px;
  text-align: center;
  flex-shrink: 0;
}
.search-result-item .ticker-name {
  font-size: 0.9rem;
  color: var(--dark1);
  font-weight: 500;
}
.search-result-item .ticker-meta {
  font-size: 0.78rem;
  color: var(--dark2);
  margin-left: auto;
}

/* Selected ticker list */
.ticker-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0.6rem;
  background: var(--marble);
  border-radius: var(--radius);
  border: 1.5px dashed var(--marble3);
  transition: border-color var(--transition);
}
.ticker-list.has-items { border-style: solid; border-color: var(--marble3); }
.ticker-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--white);
  border: 1px solid var(--marble3);
  border-radius: 100px;
  padding: 0.3rem 0.4rem 0.3rem 0.8rem;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--dark1);
}
.ticker-pill button {
  width: 20px; height: 20px;
  background: var(--marble2);
  border: none;
  border-radius: 50%;
  color: var(--dark2);
  cursor: pointer;
  font-size: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}
.ticker-pill button:hover { background: var(--red-soft); color: var(--white); }
.ticker-list-empty {
  font-size: 0.85rem;
  color: var(--dark2);
  opacity: 0.6;
  margin: auto;
  padding: 0.25rem;
}

/* ── ══════════════════ LOADING SCREEN ══════════════════ ── */
#screen-loading {
  align-items: center;
  justify-content: center;
}
.loading-container {
  text-align: center;
  max-width: 420px;
}
.loading-spinner {
  width: 60px; height: 60px;
  border: 4px solid var(--teal-pale);
  border-top-color: var(--teal);
  border-radius: 50%;
  margin: 0 auto 2rem;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--dark1);
  margin-bottom: 0.6rem;
}
.loading-subtitle {
  font-size: 0.9rem;
  color: var(--dark2);
  line-height: 1.55;
}
.loading-progress {
  margin-top: 2rem;
  height: 4px;
  background: var(--marble2);
  border-radius: 2px;
  overflow: hidden;
}
.loading-progress-bar {
  height: 100%;
  background: var(--teal);
  border-radius: 2px;
  transition: width 0.5s ease;
  width: 0%;
}

/* ── ══════════ QUAFI ATOM LOADER (3D gyroscopic brand mark) ══════════ ──
   The Bohr-atom mark tumbling in R³. Three orbitals each rotate a full turn
   about their own diagonal axis (all ~24–30° off the viewer line → gentle,
   "balanced" precession, never fully edge-on). They share one period and HOLD
   at 0° once per cycle, where every orbital is face-on and every electron is on
   its cardinal point — that frame reveals the clean 2D QUAFI logo. Electrons
   revolve along each ring (alternating direction) and re-sync at the reveal.
   Transforms-only (GPU-composited). See QuafiLoader.jsx. */
.quafi-loader {
  --qa-size: 72px;
  --qa-cycle: 4s;
  --qa-delay: calc(var(--qa-cycle) * -0.3);  /* start mid-tumble, not on the hold */
  --r1: calc(var(--qa-size) * 0.1625);   /* orbital radii: 13 / 24 / 35 in the */
  --r2: calc(var(--qa-size) * 0.300);    /* canonical 80-unit BRAND_MARK space  */
  --r3: calc(var(--qa-size) * 0.4375);
  --qa-e: calc(var(--qa-size) * 0.052);  /* electron dot  */
  --qa-nuc: calc(var(--qa-size) * 0.066);/* nucleus dot   */
  position: relative;
  width: var(--qa-size);
  height: var(--qa-size);
  flex-shrink: 0;
  overflow: visible;                     /* tilted rings extend past the box */
  display: inline-flex;
  vertical-align: middle;
  perspective: calc(var(--qa-size) * 8);
}
.quafi-loader .qa-stage {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}
.quafi-loader .qa-orbital {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform-origin: 50% 50%;
  will-change: transform;
}
.quafi-loader .qa-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: calc(2 * var(--r));
  height: calc(2 * var(--r));
  margin: calc(-1 * var(--r)) 0 0 calc(-1 * var(--r));
  border: var(--bw) solid var(--col);
  border-radius: 50%;
  opacity: var(--ring-op);
  box-sizing: border-box;
}
.quafi-loader .qa-carrier {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform-origin: 50% 50%;
  will-change: transform;
}
.quafi-loader .qa-electron {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--qa-e);
  height: var(--qa-e);
  background: var(--col);
  border-radius: 50%;
  transform: translate(-50%, -50%) rotate(var(--a)) translateY(calc(-1 * var(--r)));
}
.quafi-loader .qa-nucleus {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--qa-nuc);
  height: var(--qa-nuc);
  margin: calc(-0.5 * var(--qa-nuc)) 0 0 calc(-0.5 * var(--qa-nuc));
  background: var(--teal);
  border-radius: 50%;
  box-shadow: 0 0 calc(var(--qa-size) * 0.08) rgba(58, 106, 114, 0.45);
}

/* Per-orbital geometry/colour — inner two teal (subtle), outer gold (frame). */
.quafi-loader .qa-o1 { --r: var(--r1); --col: var(--teal); --ring-op: 0.42; --bw: max(1px, calc(var(--qa-size) * 0.009)); }
.quafi-loader .qa-o2 { --r: var(--r2); --col: var(--teal); --ring-op: 0.50; --bw: max(1px, calc(var(--qa-size) * 0.011)); }
.quafi-loader .qa-o3 { --r: var(--r3); --col: var(--gold); --ring-op: 1.00; --bw: max(1px, calc(var(--qa-size) * 0.020)); }

/* Tumbles — independent diagonal axes, shared period + a 0–8% hold (the reveal
   pause). ease-in-out decelerates into the reveal and accelerates out of it. */
.quafi-loader .qa-o1 { animation: qa-tumble-1 var(--qa-cycle) ease-in-out infinite; }
.quafi-loader .qa-o2 { animation: qa-tumble-2 var(--qa-cycle) ease-in-out infinite; }
.quafi-loader .qa-o3 { animation: qa-tumble-3 var(--qa-cycle) ease-in-out infinite; }
.quafi-loader .qa-o1 .qa-carrier { animation: qa-spin-cw  var(--qa-cycle) ease-in-out infinite; }
.quafi-loader .qa-o2 .qa-carrier { animation: qa-spin-ccw var(--qa-cycle) ease-in-out infinite; }
.quafi-loader .qa-o3 .qa-carrier { animation: qa-spin-cw  var(--qa-cycle) ease-in-out infinite; }
.quafi-loader .qa-nucleus { animation: qa-nucleus-pulse var(--qa-cycle) ease-in-out infinite; }

/* Start every loader ~30% into the cycle (mid-tumble) instead of on the face-on
   hold, so the motion reads instantly even when the optimization run is short.
   The shared negative delay keeps all parts in sync; the logo reveal still
   happens once per cycle, just not frozen at mount. Declared AFTER the shorthand
   above (which would otherwise reset the delay). */
.quafi-loader .qa-orbital,
.quafi-loader .qa-carrier,
.quafi-loader .qa-nucleus { animation-delay: var(--qa-delay); }

@keyframes qa-tumble-1 {
  0%, 8% { transform: rotate3d(0.401, 0.071, 0.914, 0deg); }
  100%   { transform: rotate3d(0.401, 0.071, 0.914, 360deg); }
}
@keyframes qa-tumble-2 {
  0%, 8% { transform: rotate3d(-0.383, 0.321, 0.866, 0deg); }
  100%   { transform: rotate3d(-0.383, 0.321, 0.866, 360deg); }
}
@keyframes qa-tumble-3 {
  0%, 8% { transform: rotate3d(-0.155, -0.427, 0.891, 0deg); }
  100%   { transform: rotate3d(-0.155, -0.427, 0.891, 360deg); }
}
@keyframes qa-spin-cw  { 0%, 8% { transform: rotateZ(0deg); } 100% { transform: rotateZ(360deg); } }
@keyframes qa-spin-ccw { 0%, 8% { transform: rotateZ(0deg); } 100% { transform: rotateZ(-360deg); } }
@keyframes qa-nucleus-pulse {
  0%, 8%, 100% { transform: scale(1); opacity: 1; }
  54%          { transform: scale(1.16); opacity: 0.8; }
}

/* Hero variant (full-screen loading moments) — larger on desktop, calmer on
   mobile. Other call-sites pass an explicit `size` prop. */
.quafi-loader--hero { --qa-size: 88px; margin: 0 auto 1.7rem; }
@media (max-width: 1024px) {
  .quafi-loader--hero { --qa-size: 72px; margin-bottom: 1.4rem; }
}

/* Accessibility — respect reduced-motion: freeze at the face-on pose (the clean
   2D logo) with only a slow opacity breathe. */
@media (prefers-reduced-motion: reduce) {
  .quafi-loader .qa-orbital,
  .quafi-loader .qa-o1 .qa-carrier,
  .quafi-loader .qa-o2 .qa-carrier,
  .quafi-loader .qa-o3 .qa-carrier,
  .quafi-loader .qa-nucleus {
    animation: none;
    transform: none;
  }
  .quafi-loader { animation: qa-breathe 2.6s ease-in-out infinite; }
}
@keyframes qa-breathe { 0%, 100% { opacity: 1; } 50% { opacity: 0.62; } }

/* ── ══════════════════ OUTPUT SCREEN ══════════════════ ── */
.output-body {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 2rem 5rem;
  flex: 1;
  /* As a flex item the default min-width:auto refuses to shrink below the
     content's intrinsic size, so on a narrow viewport the body balloons to
     its 1100px max-width and drags every child to desktop width (horizontal
     scroll on mobile). min-width:0 lets it collapse to the viewport. */
  min-width: 0;
}

.output-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.output-title { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.03em; }
.output-subtitle { font-size: 0.88rem; color: var(--dark2); margin-top: 0.3rem; }
.profile-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.75rem;
  background: var(--teal-pale);
  color: var(--teal);
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Metrics cards row */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
  margin-bottom: 1.75rem;
}
@media (max-width: 900px) { .metrics-row { grid-template-columns: repeat(3,1fr); } }
@media (max-width: 600px) { .metrics-row { grid-template-columns: repeat(2,1fr); } }

.metric-card {
  background: var(--white);
  border: 1px solid var(--marble2);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.metric-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dark2);
}
.metric-value {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--dark1);
  line-height: 1.1;
}
.metric-value.positive { color: var(--green-soft); }
.metric-value.negative { color: var(--red-soft); }
.metric-sub {
  font-size: 0.77rem;
  color: var(--dark2);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.metric-sub .spy-val { font-weight: 600; }

/* ── Mandatory FX exposure banner (under the title, gold-bordered) ────── */
.fx-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  background: linear-gradient(90deg, rgba(200,169,110,0.14) 0%, rgba(200,169,110,0.04) 100%);
  border: 1px solid rgba(200,169,110,0.45);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  margin-bottom: 1.4rem;
  font-size: 0.85rem;
  color: var(--dark1);
  line-height: 1.5;
}
.fx-banner-icon {
  color: #8a6030;
  font-size: 1.05rem;
  flex-shrink: 0;
  line-height: 1.2;
}
.fx-banner-body strong { color: #6a4a18; font-weight: 700; }

/* ── Insight pills row (auto-generated callouts under the title) ──────── */
.insight-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.4rem;
}
.insight-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.36rem 0.8rem;
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.005em;
  background: var(--white);
  border: 1px solid var(--marble3);
  color: var(--dark1);
}
.insight-pill .ip-icon {
  font-size: 0.78rem;
  line-height: 1;
}
.insight-pill.positive {
  background: rgba(58,122,90,0.10);
  border-color: rgba(58,122,90,0.35);
  color: var(--green-soft);
}
.insight-pill.negative {
  background: rgba(179,74,74,0.08);
  border-color: rgba(179,74,74,0.30);
  color: var(--red-soft);
}
.insight-pill.warning {
  background: rgba(200,169,110,0.14);
  border-color: rgba(200,169,110,0.45);
  color: #8a6030;
}
.insight-pill.neutral {
  background: var(--marble);
  border-color: var(--marble3);
  color: var(--dark2);
}

/* Currency-exposure row */
.fx-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1.1rem;
  background: var(--white);
  border: 1px solid var(--marble2);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
  color: var(--dark1);
}
.fx-row .fx-icon { color: var(--gold); display: flex; }
.fx-row .fx-label { font-weight: 600; color: var(--dark2); }
.fx-row .fx-pill {
  display: inline-block;
  background: var(--marble);
  border-radius: 100px;
  padding: 0.18rem 0.7rem;
  margin: 0 0.2rem;
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--dark1);
}
.fx-row .fx-pill.ars { background: rgba(200,169,110,0.18); color: #8a6030; }
.fx-row .fx-pill.usd { background: rgba(58,106,114,0.12); color: var(--teal); }
.fx-row .fx-note {
  font-size: 0.78rem;
  color: var(--dark2);
  font-style: italic;
  margin-left: auto;
}

/* Toast notifications (success / warning / error) */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.85rem 1.4rem;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: 0 4px 22px rgba(0,0,0,0.18);
  z-index: 9999;
  max-width: 520px;
  text-align: center;
  line-height: 1.45;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--dark1);
  color: var(--white);
  transition: opacity 0.4s, transform 0.4s;
}
.toast.warning  { background: #8a6a2e; }
.toast.error    { background: var(--red-soft); }
.toast.success  { background: var(--green-soft); }
.toast.fade-out { opacity: 0; transform: translateX(-50%) translateY(8px); }

/* Chart section */
.chart-section {
  background: var(--white);
  border: 1px solid var(--marble2);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.75rem;
}
.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.chart-title { font-size: 1rem; font-weight: 700; color: var(--dark1); }
.chart-subtitle { font-size: 0.8rem; color: var(--dark2); margin-top: 0.1rem; }

.chart-window-group {
  display: flex;
  align-items: center;
  gap: 4px;
}
.chart-win-btn {
  padding: 0.35rem 0.75rem;
  font-family: var(--ff);
  font-size: 0.8rem;
  font-weight: 600;
  background: transparent;
  border: 1px solid var(--marble3);
  border-radius: 8px;
  color: var(--dark2);
  cursor: pointer;
  transition: var(--transition);
}
.chart-win-btn:hover { border-color: var(--teal); color: var(--teal); }
.chart-win-btn.active {
  background: var(--teal);
  border-color: var(--teal);
  color: var(--white);
}
.chart-win-btn.partial {
  border-style: dashed;
  color: var(--gold);
  border-color: var(--gold);
}
.chart-win-btn.partial.active {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--white);
}
.chart-win-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.chart-legend {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--dark2);
}
.legend-dot {
  width: 10px; height: 3px;
  border-radius: 2px;
}

.chart-wrapper {
  position: relative;
  height: 280px;
}

/* Allocation table */
.table-section {
  background: var(--white);
  border: 1px solid var(--marble2);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.75rem;
  border-bottom: 1px solid var(--marble2);
}
.table-title { font-size: 1rem; font-weight: 700; color: var(--dark1); }

table {
  width: 100%;
  border-collapse: collapse;
}
thead th {
  padding: 0.85rem 1.75rem;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dark2);
  background: var(--marble);
  border-bottom: 1px solid var(--marble2);
}
thead th:last-child { text-align: right; }
tbody td {
  padding: 1rem 1.75rem;
  font-size: 0.9rem;
  color: var(--dark1);
  border-bottom: 1px solid var(--marble);
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--marble); }

.ticker-cell {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.ticker-symbol {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--teal);
  letter-spacing: 0.01em;
}
.ticker-segment {
  font-size: 0.73rem;
  color: var(--dark2);
  font-weight: 500;
}
.ticker-desc {
  font-size: 0.83rem;
  color: var(--dark2);
  line-height: 1.45;
  max-width: 400px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}
.weight-cell {
  text-align: right;
}
.weight-bar-container {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.7rem;
}
.weight-bar {
  height: 6px;
  background: var(--teal);
  border-radius: 3px;
  min-width: 4px;
  max-width: 120px;
  opacity: 0.8;
}
.weight-pct {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--dark1);
  min-width: 48px;
  text-align: right;
}

/* Entropy bar */
.entropy-bar-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}
.entropy-track {
  flex: 1;
  height: 4px;
  background: var(--marble2);
  border-radius: 2px;
  overflow: hidden;
}
.entropy-fill {
  height: 100%;
  background: var(--teal);
  border-radius: 2px;
}

/* ── Utilities ─────────────────────────────────────────────────────────────── */
.text-teal   { color: var(--teal); }
.text-gold   { color: var(--gold); }
.text-muted  { color: var(--dark2); }
.fw-700      { font-weight: 700; }
.mt-1        { margin-top: 0.5rem; }
.mt-2        { margin-top: 1rem; }
.flex        { display: flex; }
.flex-between{ justify-content: space-between; }
.align-center{ align-items: center; }
.gap-1       { gap: 0.5rem; }
.gap-2       { gap: 1rem; }

/* Persistent legal disclaimer footer (visible across every screen) */
#disclaimer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 99;
  padding: 0.55rem 1.5rem 0.6rem;
  background: rgba(242, 242, 238, 0.92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--marble2);
  text-align: center;
  font-size: 0.71rem;
  line-height: 1.5;
  color: var(--dark2);
  letter-spacing: 0.005em;
}
#disclaimer strong {
  color: var(--teal);
  font-weight: 700;
  letter-spacing: 0.02em;
}
#disclaimer .d-sep {
  margin: 0 0.35rem;
  opacity: 0.45;
}

/* Reserve viewport space for the disclaimer so it never overlaps content */
body { padding-bottom: 56px; }
@media (max-width: 1024px) {
  #disclaimer { font-size: 0.65rem; padding: 0.45rem 0.9rem 0.5rem; line-height: 1.4; }
  #disclaimer .d-sep { display: none; }
  body { padding-bottom: 90px; }
}

/* ──────────────────────────────────────────────────────────────────────────
   REPORT MODE — applied either via the `body.printing` class (PDF download
   triggered by Generate Report) or via the native print dialog. The
   beforeprint/afterprint listeners in app.js add/remove `printing` so a
   single block of styles drives both output paths.
   ────────────────────────────────────────────────────────────────────────── */

.print-only { display: none; }

@media print {
  @page {
    size: A4 portrait;
    margin: 11mm 12mm 14mm;
  }
}

body.printing #status-bar,
body.printing #disclaimer,
body.printing .nav-bar,
body.printing .nav-actions,
body.printing .chart-window-group,
body.printing #screen-home,
body.printing #screen-selector,
body.printing #screen-portfolio,
body.printing #screen-loading,
body.printing .toast {
  display: none !important;
}

body.printing #screen-output {
  display: flex !important;
  padding-top: 0 !important;
  margin: 0 !important;
  min-height: 0 !important;
}
body.printing .output-body {
  max-width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
}
body.printing .output-body > *:first-child {
  margin-top: 0 !important;
}

body.printing .print-only { display: block !important; }

body.printing,
body.printing html {
  background: #fff !important;
  color: #1f1f25 !important;
  margin: 0 !important;
  padding: 0 !important;
  font-size: 9.5pt;
  line-height: 1.4;
}

body.printing *,
body.printing *::before,
body.printing *::after {
  -webkit-print-color-adjust: exact !important;
  print-color-adjust: exact !important;
  box-shadow: none !important;
  text-shadow: none !important;
}

/* ── Report header (clean wordmark + left-aligned meta) ─────────────────── */
body.printing .print-header {
  display: flex !important;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12mm;
  border-bottom: 1.4pt solid var(--teal);
  padding: 0 0 4mm !important;
  margin: 0 0 6mm !important;
  page-break-after: avoid;
  break-after: avoid;
}
body.printing .print-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1mm;
}
body.printing .print-brandname {
  font-size: 22pt;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1;
  color: var(--dark1);
}
body.printing .print-brandtag {
  font-size: 7.5pt;
  color: var(--teal);
  margin-top: 1mm;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 700;
}
body.printing .print-meta {
  font-size: 8pt;
  color: var(--dark2);
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  gap: 0.5mm;
}
body.printing .print-meta-line {
  display: flex;
  align-items: baseline;
  gap: 4mm;
  white-space: nowrap;
}
body.printing .print-meta-line strong {
  flex: 0 0 auto;
  width: 22mm;
  color: var(--teal);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 6.8pt;
  text-align: left;
}
body.printing .print-meta-line span,
body.printing .print-meta-line em {
  font-style: normal;
  color: var(--dark1);
  font-weight: 500;
}

/* ── Output content ─────────────────────────────────────────────────────── */
body.printing .output-header { display: block !important; margin-bottom: 4mm; }
body.printing .output-title {
  font-size: 13pt !important;
  margin-bottom: 1.5mm !important;
  color: var(--dark1) !important;
  page-break-after: avoid;
}
body.printing .output-subtitle,
body.printing #profile-badges { display: none !important; }

/* ── Print-only Executive Summary block ─────────────────────────────────── */
body.printing .print-exec-summary {
  background: linear-gradient(90deg, rgba(58,106,114,0.06) 0%, rgba(58,106,114,0.02) 100%);
  border-left: 2pt solid var(--teal);
  padding: 3mm 4mm !important;
  margin: 0 0 4mm !important;
  page-break-inside: avoid;
  break-inside: avoid;
}
body.printing .print-exec-label {
  font-size: 6.5pt;
  font-weight: 700;
  color: var(--teal);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 1.2mm;
}
body.printing .print-exec-summary p {
  font-size: 8.5pt;
  line-height: 1.5;
  color: var(--dark1);
  margin: 0;
}
body.printing .print-exec-summary p strong {
  color: var(--teal);
  font-weight: 700;
}

/* ── FX banner in print ─────────────────────────────────────────────────── */
body.printing .fx-banner {
  background: rgba(200,169,110,0.10) !important;
  border: 0.5pt solid #c8a96e !important;
  border-left: 1.8pt solid #c8a96e !important;
  border-radius: 1mm !important;
  padding: 2mm 3mm !important;
  margin-bottom: 3.5mm !important;
  font-size: 7.8pt !important;
  page-break-inside: avoid;
}
body.printing .fx-banner-icon {
  color: #8a6030 !important;
  font-size: 8.5pt !important;
}
body.printing .fx-banner-body strong { color: #6a4a18 !important; }

/* ── Insight pills in print ─────────────────────────────────────────────── */
body.printing .insight-pills {
  margin-bottom: 4mm !important;
  gap: 1.5mm !important;
  page-break-inside: avoid;
}
body.printing .insight-pill {
  font-size: 7pt !important;
  padding: 1mm 2.5mm !important;
  border-width: 0.5pt !important;
}

/* ── Methodology block ─────────────────────────────────────────────────── */
body.printing .print-methodology {
  margin-top: 4mm;
  padding: 3mm 4mm;
  background: var(--marble) !important;
  border-radius: 1.5mm !important;
  page-break-inside: avoid;
  break-inside: avoid;
}
body.printing .print-methodology-title {
  font-size: 7.5pt;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 1.5mm;
}
body.printing .print-methodology p {
  font-size: 7.5pt;
  line-height: 1.55;
  color: var(--dark2);
  margin: 0;
  text-align: justify;
}

/* ── "What this report is NOT" panel ────────────────────────────────────── */
body.printing .print-not-panel {
  margin-top: 3mm;
  padding: 3mm 4mm;
  border: 0.5pt solid var(--marble3);
  border-radius: 1.5mm;
  page-break-inside: avoid;
}
body.printing .print-not-title {
  font-size: 7.5pt;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--red-soft);
  margin-bottom: 1.8mm;
}
body.printing .print-not-panel ol {
  margin: 0;
  padding-left: 4mm;
  font-size: 7pt;
  line-height: 1.55;
  color: var(--dark2);
}
body.printing .print-not-panel li { margin-bottom: 0.5mm; }

/* ── Report ID footer (vector page-numbers come from jsPDF) ─────────────── */
body.printing .print-report-id {
  margin-top: 2.5mm;
  font-size: 6.2pt;
  color: var(--dark2);
  text-align: right;
  letter-spacing: 0.06em;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
}

body.printing .fx-row {
  page-break-inside: avoid;
  border: 0.5pt solid var(--marble3) !important;
  border-left: 2pt solid var(--gold) !important;
  margin-bottom: 4mm !important;
  padding: 2mm 3mm !important;
  font-size: 8pt !important;
}
body.printing .fx-row .fx-pill {
  background: #f4f0e6 !important;
  border: 0.4pt solid #ddd !important;
  font-size: 7.5pt !important;
  padding: 0.5mm 2mm !important;
}
body.printing .fx-row .fx-pill.ars { background: #f0e3c8 !important; color: #6e4f1e !important; }
body.printing .fx-row .fx-pill.usd { background: #d4e6e9 !important; color: var(--teal) !important; }

body.printing .metrics-row {
  grid-template-columns: repeat(5, 1fr) !important;
  gap: 2mm !important;
  margin-bottom: 5mm !important;
  page-break-inside: avoid;
  break-inside: avoid;
}
body.printing .metric-card {
  background: #fff !important;
  border: 0.5pt solid #ccc !important;
  padding: 2.2mm 2.8mm !important;
  border-radius: 1.5mm !important;
  gap: 0.8mm !important;
}
body.printing .metric-label {
  font-size: 6pt !important;
  letter-spacing: 0.1em !important;
  color: var(--dark2) !important;
}
body.printing .metric-value {
  font-size: 11.5pt !important;
  font-weight: 800 !important;
  color: var(--dark1) !important;
}
body.printing .metric-value.positive { color: var(--green-soft) !important; }
body.printing .metric-value.negative { color: var(--red-soft) !important; }
body.printing .metric-sub { font-size: 6.5pt !important; color: var(--dark2) !important; }
body.printing .entropy-track { height: 1.2mm !important; background: var(--marble2) !important; }
body.printing .entropy-fill  { background: var(--teal) !important; }

body.printing .chart-section {
  page-break-inside: avoid;
  break-inside: avoid;
  border: 0.5pt solid #ccc !important;
  margin-bottom: 5mm !important;
  padding: 4mm 4mm 3mm !important;
  border-radius: 2mm !important;
}
body.printing .chart-header { margin-bottom: 2.5mm !important; }
body.printing .chart-title    { font-size: 10pt !important; }
body.printing .chart-subtitle { font-size: 7pt !important; }
body.printing .chart-legend   { font-size: 7.5pt !important; gap: 4mm !important; margin-bottom: 1.5mm !important; }
body.printing .chart-wrapper  { height: 62mm !important; }

/* ── Print-only allocation bar chart ───────────────────────────────────── */
body.printing .print-alloc-section {
  page-break-inside: avoid;
  break-inside: avoid;
  border: 0.5pt solid #ccc !important;
  border-radius: 2mm !important;
  padding: 4mm 5mm 4mm !important;
  margin-bottom: 5mm;
  background: #fff;
}
body.printing .print-alloc-header {
  margin-bottom: 2.5mm;
  page-break-after: avoid;
}
body.printing .print-alloc-title {
  font-size: 10pt;
  font-weight: 800;
  color: var(--dark1);
  letter-spacing: -0.01em;
}
body.printing .print-alloc-subtitle {
  font-size: 7pt;
  color: var(--dark2);
  margin-top: 0.5mm;
}
body.printing .print-alloc-chart-wrap {
  position: relative;
  width: 100%;
  /* Dynamically scaled by JS based on holding count */
  height: 70mm;
}
body.printing .print-alloc-chart-wrap canvas {
  width: 100% !important;
  max-width: 100% !important;
  height: 100% !important;
}

/* ── Allocation table ───────────────────────────────────────────────────── */
/* Chunked-table wrapper used when a long table is split into per-page units */
body.printing .print-table-chunks {
  display: block;
}
body.printing .print-table-chunk {
  page-break-inside: avoid !important;
  break-inside: avoid !important;
  margin-bottom: 5mm;
}
body.printing .print-table-chunk + .print-table-chunk {
  page-break-before: always !important;
  break-before: page !important;
  margin-top: 0;
}

body.printing .table-section {
  border: 0.5pt solid #ccc !important;
  border-radius: 2mm !important;
  margin-bottom: 5mm;
  overflow: visible !important;
  page-break-inside: auto;          /* let the chunker decide */
}
body.printing .table-header-row {
  padding: 2.5mm 4mm !important;
  border-bottom: 0.5pt solid #ddd !important;
  page-break-after: avoid;
}
body.printing .table-title { font-size: 10pt !important; }

/* Repeat <thead> at top of every page when the table spans multiple pages */
body.printing .table-section table {
  width: 100% !important;
  border-collapse: collapse !important;
}
body.printing thead {
  display: table-header-group !important;
}
body.printing tfoot {
  display: table-footer-group !important;
}
body.printing thead th {
  background: var(--marble) !important;
  font-size: 6.5pt !important;
  padding: 1.8mm 4mm !important;
  color: var(--dark2) !important;
  border-bottom: 0.5pt solid #ccc !important;
}
body.printing tbody td {
  font-size: 8pt !important;
  padding: 2.5mm 4mm !important;
  border-bottom: 0.3pt solid #eee !important;
  vertical-align: top;
}
body.printing tbody tr {
  page-break-inside: avoid !important;
  break-inside: avoid !important;
}
body.printing .ticker-symbol { font-size: 9pt !important; }
body.printing .ticker-segment { font-size: 6.5pt !important; }
/* Full descriptions in the report — override on-screen line clamp.
   Use explicit values (`none`, `horizontal`) instead of `unset`, which is
   unreliable for vendor-prefixed line-clamp across browsers. */
body.printing .ticker-desc {
  font-size: 7.5pt !important;
  max-width: none !important;
  display: block !important;
  -webkit-line-clamp: none !important;
  -webkit-box-orient: horizontal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  white-space: normal !important;
  line-height: 1.4 !important;
  word-break: normal !important;
  hyphens: none !important;
}
body.printing .weight-bar  { background: var(--teal) !important; max-width: 22mm !important; }
body.printing .weight-pct  { font-size: 8.5pt !important; }

body.printing .print-disclaimer {
  margin-top: 6mm;
  page-break-inside: avoid;
  break-inside: avoid;
}
body.printing .print-disclaimer-inner {
  border-top: 0.6pt solid var(--teal);
  padding-top: 3.5mm;
}
body.printing .print-disclaimer-title {
  font-size: 7.5pt;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 1.5mm;
}
body.printing .print-disclaimer p {
  font-size: 7pt;
  line-height: 1.55;
  color: var(--dark2);
  text-align: justify;
  margin: 0;
}
body.printing .print-disclaimer strong { color: var(--dark1); }

/* ──────────────────────────────────────────────────────────────────────────
   ASSET DETAIL SCREEN ("More Info" page)
   ────────────────────────────────────────────────────────────────────────── */

/* Magnifying-glass info button shown in every allocation-table row */
.info-cell { text-align: center; padding: 0.6rem 0.5rem !important; }

.info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--marble);
  border: 1px solid var(--marble3);
  color: var(--teal);
  cursor: pointer;
  transition: var(--transition);
  padding: 0;
}
.info-btn:hover {
  background: var(--teal);
  border-color: var(--teal);
  color: var(--white);
  transform: scale(1.06);
  box-shadow: 0 2px 8px rgba(58,106,114,0.25);
}
.info-btn:active { transform: scale(0.97); }

/* ── Asset detail body ──────────────────────────────────────────────────── */
.asset-body {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 2rem 5rem;
  width: 100%;
}

/* Loading state */
.asset-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  min-height: 50vh;
  color: var(--dark2);
  font-size: 0.92rem;
}

/* Hero header — name + ticker + badges */
.asset-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1.5rem;
  border-bottom: 1px solid var(--marble2);
  padding-bottom: 1.5rem;
  margin-bottom: 1.75rem;
}
.asset-hero-left { flex: 1 1 auto; min-width: 0; }
.asset-name {
  font-size: 1.95rem;
  font-weight: 800;
  color: var(--dark1);
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin-bottom: 0.65rem;
}
.asset-hero-meta {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}
.asset-ticker {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--teal);
  background: var(--teal-pale);
  padding: 0.22rem 0.7rem;
  border-radius: 6px;
  letter-spacing: 0.04em;
}
.asset-tags {
  display: inline-flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.asset-tags .tag {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--dark2);
  background: var(--marble);
  border: 1px solid var(--marble2);
  padding: 0.3rem 0.7rem;
  border-radius: 100px;
  letter-spacing: 0.01em;
}
.asset-tags .tag.gold {
  background: rgba(200,169,110,0.14);
  border-color: rgba(200,169,110,0.45);
  color: #8a6030;
  font-weight: 600;
}

.asset-hero-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
}
.asset-price {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--dark1);
  line-height: 1;
}
.asset-price-change {
  font-size: 0.85rem;
  font-weight: 600;
}
.asset-price-change.positive { color: var(--green-soft); }
.asset-price-change.negative { color: var(--red-soft); }
.asset-price-label {
  font-size: 0.7rem;
  color: var(--dark2);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 0.25rem;
}

/* Generic card container for sections */
.asset-card {
  background: var(--white);
  border: 1px solid var(--marble2);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.6rem;
  margin-bottom: 1.5rem;
}
.asset-card .card-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 0.7rem;
}
.asset-card .card-h {
  font-size: 1rem;
  font-weight: 700;
  color: var(--dark1);
  letter-spacing: -0.005em;
}
.asset-card .card-sub {
  font-size: 0.78rem;
  color: var(--dark2);
  margin-top: 0.2rem;
}

.asset-description {
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--dark1);
}

/* Chart card */
.asset-chart-card .card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.1rem;
}
.window-selector {
  display: inline-flex;
  gap: 3px;
  background: var(--marble);
  padding: 3px;
  border-radius: 8px;
}
.window-selector button {
  background: transparent;
  border: none;
  padding: 0.38rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--dark2);
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.04em;
  transition: var(--transition);
}
.window-selector button:hover { color: var(--teal); }
.window-selector button.active {
  background: var(--white);
  color: var(--teal);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.window-selector button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  color: var(--dark2);
}
.window-selector button:disabled:hover { color: var(--dark2); }

.asset-chart-wrapper {
  position: relative;
  height: 320px;
  width: 100%;
}

/* KPI grid — wider tiles than the portfolio KPI row */
.asset-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}
.kpi-tile {
  background: var(--white);
  border: 1px solid var(--marble2);
  border-radius: 10px;
  padding: 0.95rem 1.1rem;
}
.kpi-tile .kpi-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--dark2);
  text-transform: uppercase;
  margin-bottom: 0.3rem;
}
.kpi-tile .kpi-value {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--dark1);
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.kpi-tile .kpi-value.positive { color: var(--green-soft); }
.kpi-tile .kpi-value.negative { color: var(--red-soft); }
.kpi-tile .kpi-sub {
  font-size: 0.7rem;
  color: var(--dark2);
  margin-top: 0.25rem;
}

/* News card */
.asset-news-card .card-sub { margin-bottom: 1rem; }
.asset-news-list {
  display: flex;
  flex-direction: column;
}
.news-item {
  display: block;
  padding: 0.95rem 0;
  border-bottom: 1px solid var(--marble);
  text-decoration: none;
  color: var(--dark1);
  transition: var(--transition);
  border-radius: 0;
}
.news-item:last-child { border-bottom: none; }
.news-item:hover {
  background: var(--marble);
  margin: 0 -0.6rem;
  padding-left: 0.6rem;
  padding-right: 0.6rem;
  border-radius: 6px;
}
.news-title {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.45;
  margin-bottom: 0.4rem;
  color: var(--dark1);
}
.news-meta {
  display: flex;
  gap: 0.7rem;
  font-size: 0.74rem;
  align-items: center;
}
.news-publisher {
  font-weight: 700;
  color: var(--teal);
  letter-spacing: 0.02em;
}
.news-date { color: var(--dark2); }
.news-empty {
  padding: 1.5rem 0.5rem;
  text-align: center;
  color: var(--dark2);
  font-size: 0.85rem;
  font-style: italic;
}

@media (max-width: 760px) {
  .asset-hero { flex-direction: column; align-items: stretch; }
  .asset-hero-right { align-items: flex-start; }
  .asset-kpis { grid-template-columns: repeat(2, 1fr); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   AUTH / USER / PLANS / SETTINGS / MODALS
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Auth shell ────────────────────────────────────────────────────────── */
#screen-auth { align-items: stretch; justify-content: stretch; }
.auth-shell {
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  background: linear-gradient(160deg, var(--marble) 0%, #ecede7 100%);
  position: relative;
}
.auth-back {
  position: absolute;
  top: 45px;
  left: 1.6rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--dark1);
  text-decoration: none;
  transition: color 200ms;
}
.auth-back:hover { color: var(--teal); }
.auth-back svg { width: 16px; height: 16px; }

.auth-card {
  width: 100%;
  max-width: 540px;
  background: white;
  border: 1px solid var(--marble2);
  border-radius: var(--radius-lg);
  padding: 2.4rem 2.4rem 2rem;
  box-shadow: 0 10px 50px rgba(58, 106, 114, 0.08);
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.7rem;
  padding-bottom: 1.4rem;
  border-bottom: 1px solid var(--marble2);
  color: var(--teal);
}
.auth-brand .quafi-mark-lg { width: 56px; height: 56px; margin: 0; }
.auth-word {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--dark1);
  line-height: 1;
}
.auth-tag {
  font-size: 0.78rem;
  color: var(--teal);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  margin-top: 0.4rem;
}

.auth-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--marble2);
  margin-bottom: 1.5rem;
}
.auth-tab {
  flex: 1;
  padding: 0.65rem 0;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--dark2);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: color 200ms, border-color 200ms;
}
.auth-tab:hover { color: var(--teal); }
.auth-tab.active { color: var(--teal); border-bottom-color: var(--teal); }

.auth-pane { display: none; flex-direction: column; gap: 0.8rem; }
.auth-pane.active { display: flex; }

.auth-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}
@media (max-width: 520px) {
  .auth-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 1.8rem 1.4rem; }
}

.auth-field { display: flex; flex-direction: column; gap: 0.35rem; }
.auth-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dark2);
}
.auth-optional {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0.02em;
  color: var(--dark2);
  opacity: 0.7;
}
.auth-field input,
.auth-field textarea {
  width: 100%;
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--dark1);
  background: var(--marble);
  border: 1.5px solid var(--marble2);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  transition: border-color 200ms, background 200ms;
  outline: none;
}
.auth-field textarea { resize: vertical; min-height: 100px; }
.auth-field input:focus,
.auth-field textarea:focus {
  border-color: var(--teal);
  background: white;
  box-shadow: 0 0 0 3px var(--teal-pale);
}
.auth-field input:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Password show/hide toggle (PasswordInput.jsx) */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 2.6rem; }
.pw-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--dark2);
  opacity: 0.65;
  cursor: pointer;
  transition: opacity 200ms, color 200ms;
}
.pw-toggle:hover { opacity: 1; color: var(--teal); }
.pw-toggle:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
  opacity: 1;
}

.auth-check {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  font-size: 0.84rem;
  color: var(--dark2);
  margin: 0.4rem 0 0.2rem;
  line-height: 1.5;
}
.auth-check input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--teal);
  margin-top: 2px;
  flex-shrink: 0;
}
.auth-check a { color: var(--teal); }

.auth-error {
  font-size: 0.82rem;
  color: var(--red-soft);
  background: rgba(179,74,74,0.08);
  border: 1px solid rgba(179,74,74,0.25);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  display: none;
}
.auth-error.show { display: block; }

.auth-foot {
  font-size: 0.85rem;
  color: var(--dark2);
  text-align: center;
  margin-top: 0.6rem;
}
.auth-foot a { color: var(--teal); font-weight: 600; }

.full-w { width: 100%; justify-content: center; }

/* OAuth row (placeholder) */
.oauth-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin-bottom: 0.6rem;
}
@media (max-width: 520px) { .oauth-row { grid-template-columns: 1fr; } }
.oauth-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.6rem 0.8rem;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--dark1);
  background: white;
  border: 1.5px solid var(--marble2);
  border-radius: 10px;
  cursor: pointer;
  letter-spacing: 0.01em;
  opacity: 1;
  transition: background 0.15s ease, border-color 0.15s ease,
              box-shadow 0.15s ease, transform 0.05s ease;
}
.oauth-btn:hover {
  background: var(--marble1, #f6f5f1);
  border-color: var(--dark2);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.oauth-btn:active {
  transform: translateY(1px);
}
.oauth-btn:focus-visible {
  outline: 2px solid var(--accent, #2f6f74);
  outline-offset: 2px;
}
/* Disabled state — applies until JS removes the `disabled` attribute after
   Google Identity Services finishes loading and we have a Client ID. */
.oauth-btn[disabled],
.oauth-btn:disabled {
  cursor: not-allowed;
  opacity: 0.78;
  background: white;
  border-color: var(--marble2);
  box-shadow: none;
}
.oauth-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: 700;
  font-family: 'SF Mono', Menlo, monospace;
  flex-shrink: 0;
}
.oauth-logo.google { background: #fff; border: 1.5px solid #ddd; color: #4285f4; }
.oauth-logo.apple { background: #000; color: #fff; }
.oauth-soon {
  position: absolute;
  top: 6px; right: 8px;
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: white;
  background: var(--gold);
  padding: 1px 5px;
  border-radius: 100px;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.74rem;
  color: var(--dark2);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0.6rem 0;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--marble2);
}

/* ── User badge (persistent header element) ─────────────────────────────── */
.user-badge {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem 0.6rem 0.35rem 0.85rem;
  background: var(--marble);
  border: 1px solid var(--marble2);
  border-radius: 100px;
  font-size: 0.84rem;
  color: var(--dark1);
}
.user-badge .ub-greeting { font-weight: 500; color: var(--dark1); }
.user-badge .ub-name { font-weight: 700; color: var(--teal); }
.user-badge .ub-admin {
  display: inline-block;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: white;
  background: var(--gold);
  padding: 2px 6px;
  border-radius: 100px;
  margin-left: 0.25rem;
}
.user-badge .ub-cog {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* 70% of user-badge height. Badge height ≈ 34px → cog ≈ 24px */
  width: 24px; height: 24px;
  border-radius: 50%;
  background: white;
  border: 1px solid var(--marble2);
  color: var(--dark2);
  cursor: pointer;
  transition: color 200ms, transform 600ms;
  padding: 0;
  flex-shrink: 0;
}
.user-badge .ub-cog:hover { color: var(--teal); transform: rotate(60deg); }

/* User badge dropdown menu */
.user-menu {
  position: fixed;
  top: auto;
  right: 1.5rem;
  min-width: 200px;
  background: white;
  border: 1px solid var(--marble2);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.12);
  padding: 0.4rem;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 180ms, visibility 180ms, transform 180ms;
  margin-top: 4px;
}
.user-badge.menu-open .user-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.user-badge { position: relative; }
.user-menu a, .user-menu button {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.7rem;
  font-family: inherit;
  font-size: 0.86rem;
  color: var(--dark1);
  background: transparent;
  border: none;
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.user-menu a:hover, .user-menu button:hover { background: var(--marble); color: var(--teal); }
/* The free Academy: a quietly branded entry (mini QUAFI atom), always available. */
.user-menu a.user-menu-academy { color: var(--teal); display: flex; align-items: center; gap: 0.5rem; }
.user-menu-academy-icon { flex: none; }
.user-menu-divider { height: 1px; background: var(--marble2); margin: 0.3rem 0; }
.user-menu-usage {
  padding: 0.35rem 0.7rem;
  font-size: 0.72rem;
  color: var(--dark2);
  border-bottom: 1px solid var(--marble2);
  margin-bottom: 0.25rem;
}
.user-menu-usage strong { color: var(--dark1); }

/* ── Plans grid ────────────────────────────────────────────────────────── */
.plans-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}
.plan-tile {
  background: white;
  border: 1px solid var(--marble2);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  position: relative;
}
.plan-tile.current {
  border: 2px solid var(--teal);
  background: linear-gradient(180deg, white 0%, var(--teal-pale) 100%);
}
.plan-tile.current::before {
  content: 'CURRENT PLAN';
  position: absolute;
  top: -10px;
  left: 1.4rem;
  background: var(--teal);
  color: white;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  padding: 0.25rem 0.6rem;
  border-radius: 100px;
}
.plan-tile h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--dark1);
  margin: 0;
}
.plan-tile .price {
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
  margin: 0.2rem 0 0.4rem;
}
.plan-tile .price .amount {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--dark1);
}
.plan-tile .price .period { font-size: 0.82rem; color: var(--dark2); }
.plan-tile ul {
  list-style: none;
  padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 0.45rem;
}
.plan-tile li {
  font-size: 0.84rem;
  color: var(--dark1);
  padding-left: 1.2rem;
  position: relative;
  line-height: 1.45;
}
.plan-tile li::before {
  content: '✓'; position: absolute; left: 0; top: 0;
  color: var(--teal); font-weight: 800;
}
.plan-tile .plan-discount {
  font-size: 0.7rem; font-weight: 600;
  letter-spacing: 0.04em; color: var(--gold);
  text-transform: uppercase;
}
.plan-tile .plan-cta { margin-top: auto; padding-top: 0.5rem; }
.plan-tile .plan-cta button { width: 100%; justify-content: center; }
@media (max-width: 980px) { .plans-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 580px) { .plans-grid { grid-template-columns: 1fr; } }

/* ── Settings ──────────────────────────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 1.5rem;
  margin-top: 1.5rem;
}
.settings-card {
  background: white;
  border: 1px solid var(--marble2);
  border-radius: var(--radius-lg);
  padding: 1.8rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.settings-card form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.settings-card .card-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 0.3rem;
}
.settings-divider { border: 0; height: 1px; background: var(--marble2); margin: 0.6rem 0; }
.muted { color: var(--dark2); }
.muted.small { font-size: 0.82rem; }

#sub-summary {
  background: var(--marble);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.4rem;
  font-size: 0.86rem;
  line-height: 1.55;
}
#sub-summary strong { color: var(--teal); }
@media (max-width: 880px) { .settings-grid { grid-template-columns: 1fr; } }

/* ── Modals ────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(20, 20, 25, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
}
.modal {
  background: white;
  border-radius: var(--radius-lg);
  width: 100%; max-width: 540px;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  padding: 2rem 2rem 1.7rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.20);
  animation: modal-in 220ms ease-out;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.2rem;
}
.modal-eyebrow {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal);
}
.modal-h {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--dark1);
  margin-top: 0.3rem;
}
.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--marble);
  border: none;
  font-size: 0.9rem;
  color: var(--dark2);
  cursor: pointer;
  transition: var(--transition);
}
.modal-close:hover { background: var(--red-soft); color: white; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* Contact CTA in home screen */
.home-footer a {
  color: var(--teal);
  text-decoration: none;
  font-weight: 600;
}
.home-footer a:hover { text-decoration: underline; }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .nav-bar { padding: 1rem 1.5rem; }
  .home-cards { grid-template-columns: 1fr; }
  .home-question { font-size: 1.6rem; }
  .screen-body { padding: 1.5rem 1.25rem 3rem; }
  .output-body { padding: 1.5rem 1.25rem 3rem; }
  .form-row { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .metrics-row { grid-template-columns: repeat(2,1fr); }
  thead th, tbody td { padding-left: 1rem; padding-right: 1rem; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Feedback widget — floating button + modal
   Goals: visible enough to invite use, subdued enough to never compete with
   the primary flow. Anchored bottom-right; modal centered with backdrop.
   ═══════════════════════════════════════════════════════════════════════════ */

#feedback-fab {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 980;                          /* above content, below loading overlays */
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.05rem 0.65rem 0.9rem;
  border: 1px solid rgba(58,106,114,0.18);
  border-radius: 999px;
  background: var(--white);
  color: var(--teal);
  font-family: var(--ff);
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform var(--transition), box-shadow var(--transition),
              background var(--transition), color var(--transition);
}
#feedback-fab:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
  background: var(--teal);
  color: var(--white);
}
#feedback-fab:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}
#feedback-fab svg { flex: 0 0 auto; }

/* Hide on auth screen (sign-in / register) — prevents distraction at the gate */
body.feedback-hide #feedback-fab { display: none; }

/* Mobile: collapse to icon-only circle */
@media (max-width: 640px) {
  #feedback-fab {
    right: 1rem;
    bottom: 1rem;
    padding: 0.65rem;
    border-radius: 50%;
  }
  #feedback-fab span { display: none; }
}

/* ── Modal ─────────────────────────────────────────────────────────────── */
.feedback-modal {
  position: fixed;
  inset: 0;
  z-index: 1080;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.feedback-modal[aria-hidden="false"] { display: flex; }

.feedback-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(58,58,66,0.42);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: feedbackFadeIn 180ms ease-out;
}

.feedback-panel {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  background: var(--marble);
  border: 1px solid var(--marble3);
  border-radius: var(--radius-lg);
  padding: 1.75rem 1.75rem 1.5rem;
  box-shadow: 0 24px 64px rgba(58,58,66,0.22);
  animation: feedbackPop 220ms cubic-bezier(0.2, 0.9, 0.3, 1.1);
}

@keyframes feedbackFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes feedbackPop {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.feedback-close {
  position: absolute;
  top: 0.65rem;
  right: 0.85rem;
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  font-size: 1.75rem;
  line-height: 1;
  color: var(--dark2);
  cursor: pointer;
  border-radius: 50%;
  transition: background var(--transition), color var(--transition);
}
.feedback-close:hover { background: var(--marble2); color: var(--dark1); }

.feedback-header { margin-bottom: 1.1rem; padding-right: 1.5rem; }
.feedback-header h2 {
  font-family: var(--ff);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--dark1);
  letter-spacing: -0.01em;
  margin-bottom: 0.35rem;
}
.feedback-sub {
  font-size: 0.875rem;
  color: var(--dark2);
  line-height: 1.45;
}

.feedback-form { display: flex; flex-direction: column; gap: 0.95rem; }

.feedback-row { display: flex; flex-direction: column; gap: 0.35rem; }
.feedback-row label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--dark1);
  letter-spacing: 0.005em;
}
.feedback-optional {
  font-weight: 400;
  color: var(--dark2);
  font-size: 0.78rem;
}

.feedback-row input,
.feedback-row select,
.feedback-row textarea {
  font-family: var(--ff);
  font-size: 0.92rem;
  color: var(--dark1);
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--marble3);
  border-radius: var(--radius);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}
.feedback-row textarea {
  resize: vertical;
  min-height: 96px;
  line-height: 1.45;
}
.feedback-row input:focus,
.feedback-row select:focus,
.feedback-row textarea:focus {
  outline: 0;
  border-color: var(--teal-light);
  box-shadow: 0 0 0 3px rgba(77,141,152,0.16);
}

.feedback-hint {
  font-size: 0.74rem;
  color: var(--dark2);
  margin-top: 0.1rem;
}
.feedback-counter { text-align: right; font-variant-numeric: tabular-nums; }

.feedback-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.35rem;
}

.feedback-btn-primary,
.feedback-btn-secondary {
  font-family: var(--ff);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.65rem 1.2rem;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition), transform var(--transition);
}
.feedback-btn-primary {
  background: var(--teal);
  color: var(--white);
}
.feedback-btn-primary:hover:not(:disabled) {
  background: #2f5860;
  transform: translateY(-1px);
}
.feedback-btn-primary:disabled {
  opacity: 0.55;
  cursor: progress;
}
.feedback-btn-secondary {
  background: transparent;
  color: var(--dark2);
  border-color: var(--marble3);
}
.feedback-btn-secondary:hover { background: var(--marble2); color: var(--dark1); }

.feedback-error {
  min-height: 1.1rem;
  margin-top: 0.1rem;
  font-size: 0.82rem;
  color: var(--red-soft);
}

/* Success state */
.feedback-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0.5rem 0.5rem 0.25rem;
  gap: 0.65rem;
}
.feedback-success svg { color: var(--green-soft); }
.feedback-success h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--dark1);
  margin-bottom: 0.1rem;
}
.feedback-success p {
  font-size: 0.88rem;
  color: var(--dark2);
  max-width: 320px;
  line-height: 1.45;
  margin-bottom: 0.5rem;
}
.feedback-success .feedback-btn-primary { min-width: 130px; }

/* Mobile tweaks */
@media (max-width: 640px) {
  .feedback-panel { padding: 1.35rem 1.25rem 1.25rem; border-radius: 16px; }
  .feedback-header h2 { font-size: 1.1rem; }
  .feedback-actions { flex-direction: column-reverse; }
  .feedback-actions button { width: 100%; }
}

/* Print: never show */
@media print { #feedback-fab, .feedback-modal { display: none !important; } }

/* ═══════════════════════════════════════════════════════════════════════════
   Terms & Conditions modal — larger reading surface than the feedback one,
   with a fixed header (title + close) and scrollable body so users can read
   without losing the close affordance.
   ═══════════════════════════════════════════════════════════════════════════ */
.terms-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.terms-modal[aria-hidden="false"] { display: flex; }

.terms-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(58,58,66,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: feedbackFadeIn 180ms ease-out;
}

.terms-panel {
  position: relative;
  width: 100%;
  max-width: 760px;
  max-height: calc(100vh - 2.5rem);
  display: flex;
  flex-direction: column;
  background: var(--marble);
  border: 1px solid var(--marble3);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(58,58,66,0.28);
  animation: feedbackPop 220ms cubic-bezier(0.2, 0.9, 0.3, 1.1);
  overflow: hidden;
}

.terms-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem 0.85rem;
  border-bottom: 1px solid var(--marble3);
  background: var(--marble);
}
.terms-header h2 {
  font-family: var(--ff);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--dark1);
  letter-spacing: -0.01em;
}
.terms-close {
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  font-size: 1.8rem;
  line-height: 1;
  color: var(--dark2);
  cursor: pointer;
  border-radius: 50%;
  transition: background var(--transition), color var(--transition);
}
.terms-close:hover { background: var(--marble2); color: var(--dark1); }

.terms-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--marble3);
  font-size: 0.82rem;
  color: var(--dark2);
  background: var(--marble2);
}
.terms-meta strong { color: var(--dark1); font-weight: 500; }

.terms-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1.75rem;
  font-size: 0.91rem;
  line-height: 1.6;
  color: var(--dark1);
}
.terms-body p { margin-bottom: 0.85rem; }
.terms-body h3 {
  font-family: var(--ff);
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--teal);
  margin-top: 1.5rem;
  margin-bottom: 0.6rem;
  letter-spacing: -0.005em;
}
.terms-body h3:first-of-type { margin-top: 0.5rem; }

.terms-lede { font-size: 0.95rem; color: var(--dark1); }

.terms-callout {
  background: var(--white);
  border-left: 3px solid var(--gold);
  padding: 0.75rem 1rem;
  margin: 0.85rem 0 1.1rem;
  font-size: 0.88rem;
  color: var(--dark1);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.terms-callout-strong {
  background: var(--teal-pale);
  border-left: 3px solid var(--teal);
  padding: 0.7rem 1rem;
  margin: 0.5rem 0 1rem;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--teal);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.terms-acknowledgment {
  margin-top: 1.5rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  background: rgba(200,169,110,0.07);
  font-size: 0.92rem;
  color: var(--dark1);
}

.terms-copyright {
  text-align: center;
  font-size: 0.78rem;
  color: var(--dark2);
  margin-top: 1.5rem;
}

.terms-footer {
  display: flex;
  justify-content: flex-end;
  padding: 0.85rem 1.5rem;
  border-top: 1px solid var(--marble3);
  background: var(--marble);
}

/* Mobile */
@media (max-width: 640px) {
  .terms-panel { max-height: calc(100vh - 1rem); }
  .terms-header { padding: 1rem 1.1rem 0.7rem; }
  .terms-header h2 { font-size: 1.05rem; }
  .terms-meta { padding: 0.6rem 1.1rem; flex-direction: column; gap: 0.25rem; }
  .terms-body { padding: 1.1rem 1.1rem; font-size: 0.88rem; }
  .terms-footer { padding: 0.7rem 1.1rem; }
}


/* ═══════════════════════════════════════════════════════════════════════════
   Feedback widget fixes
   - Move the floating button above the QUAFI disclaimer footer
   - Repair [hidden] specificity so the success card stays hidden until submit
   ═══════════════════════════════════════════════════════════════════════════ */

/* Bump the FAB up so it no longer overlaps #disclaimer */
#feedback-fab { bottom: 5.5rem; }
@media (max-width: 640px) { #feedback-fab { bottom: 5rem; } }

/* The [hidden] HTML attribute is normally equivalent to display:none, but our
   .feedback-success { display: flex; ... } rule overrode it due to class
   specificity. This re-asserts [hidden] semantics for the success card. */
.feedback-success[hidden] { display: none; }

/* ═════════════════════════════════════════════════════════════════════════════
   PASSWORD RESET — modals (forgot + reset)
   Same backdrop/panel pattern as the Terms modal, sized for a compact form.
   ═════════════════════════════════════════════════════════════════════════════ */

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.auth-modal[aria-hidden="false"] { display: flex; }

.auth-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(58,58,66,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: feedbackFadeIn 180ms ease-out;
}

.auth-modal-panel {
  position: relative;
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  background: var(--marble);
  border: 1px solid var(--marble3);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(58,58,66,0.28);
  animation: feedbackPop 220ms cubic-bezier(0.2, 0.9, 0.3, 1.1);
  overflow: hidden;
}

.auth-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem 0.85rem;
  border-bottom: 1px solid var(--marble3);
}
.auth-modal-header h2 {
  font-family: var(--ff);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--dark1);
  letter-spacing: -0.01em;
}
.auth-modal-close {
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  font-size: 1.8rem;
  line-height: 1;
  color: var(--dark2);
  cursor: pointer;
  border-radius: 50%;
  transition: background var(--transition), color var(--transition);
}
.auth-modal-close:hover { background: var(--marble2); color: var(--dark1); }

.auth-modal-body { padding: 1.25rem 1.5rem 1.5rem; }
.auth-modal-lede {
  margin: 0 0 1.1rem 0;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--dark2);
}

/* "Forgot password?" link inside the login Password label — small, right-aligned. */
.auth-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.auth-forgot-link {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--teal);
  text-decoration: none;
  letter-spacing: 0;
}
.auth-forgot-link:hover { text-decoration: underline; }

/* Helper text under the new-password field. */
.auth-hint {
  margin: -0.4rem 0 0.9rem 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--dark2);
  opacity: 0.85;
}

/* Inline success card inside the forgot-password modal. */
.auth-success {
  margin: 0 0 1rem 0;
  padding: 0.85rem 1rem;
  background: #ecf3f1;
  border: 1px solid #c8dcd6;
  border-radius: 10px;
  font-size: 0.92rem;
  line-height: 1.5;
  color: #265c52;
}
.auth-success[hidden] { display: none; }

/* The .auth-error element exists in the modals as a div with [hidden] until
   a real error happens. The base .auth-error rule expects always-visible
   styling, so we add the [hidden] override here too. */
#forgot-error[hidden],
#reset-error[hidden] { display: none; }

/* ═══════════════════════════════════════════════════════════════════════════
   Language toggle FAB
   Sits bottom-left so it doesn't collide with the feedback FAB (bottom-right).
   ═══════════════════════════════════════════════════════════════════════════ */

.lang-fab {
  position: fixed;
  left: 1.5rem;
  bottom: 5.5rem;               /* mirrors feedback-fab elevation */
  z-index: 980;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.8rem;
  height: 2.8rem;
  border: 1px solid rgba(58,106,114,0.22);
  border-radius: 50%;
  background: var(--white);
  color: var(--teal);
  font-family: var(--ff);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition),
              background var(--transition), color var(--transition);
}
.lang-fab:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  background: var(--teal);
  color: var(--white);
}
.lang-fab:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

@media (max-width: 640px) {
  .lang-fab { left: 1rem; bottom: 5rem; }
}

@media print { .lang-fab { display: none !important; } }

/* ═══════════════════════════════════════════════════════════════════════════
   "Descripción en inglés" badge (Phase 4a)
   Shown above asset description text when a non-English language is active.
   Hidden in English sessions (asset.desc_lang_tag = "" in en.json).
   ═══════════════════════════════════════════════════════════════════════════ */

.desc-lang-tag {
  display: inline-block;
  margin-bottom: 0.55rem;
  padding: 0.18em 0.6em;
  border: 1px solid rgba(58,106,114,0.25);
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dark2);
  opacity: 0.75;
}

/* Hide entirely when empty (EN catalog has "" for this key) */
.desc-lang-tag:empty { display: none; }

/* ── Chart carousel (output screen: timeline + treemap + heatmap) ─────── */
.chart-carousel {
  position: relative;
  margin: 0 0 1.75rem;
}
.carousel-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  gap: 1.5rem;
  scrollbar-width: none;
}
.carousel-track::-webkit-scrollbar { display: none; }

.chart-slide {
  flex: 0 0 100%;
  scroll-snap-align: start;
  background: var(--white);
  border: 1px solid var(--marble2);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.75rem;
  /* Each slide is a complete chart-section visually. */
  display: flex;
  flex-direction: column;
}
/* The timeline has no disclaimer, so let its chart grow to consume the
   slide height set by the taller treemap/heatmap slides — no dead space. */
.chart-slide[data-slide-key="timeline"] .chart-wrapper {
  flex: 1 1 auto;
  min-height: 280px;
}

.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--white);
  border: 1px solid var(--marble2);
  color: var(--teal);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.carousel-arrow:hover {
  background: var(--teal);
  color: var(--white);
  transform: translateY(-50%) scale(1.05);
}
.carousel-arrow:disabled { opacity: 0.35; cursor: default; transform: translateY(-50%); }
.carousel-prev { left: -1.4rem; }
.carousel-next { right: -1.4rem; }

.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 0.9rem;
}
.carousel-dots button {
  appearance: none;
  width: 28px; height: 28px;
  background: transparent; border: 0; padding: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.carousel-dots button::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--marble3, var(--marble2));
  transition: var(--transition);
}
.carousel-dots button.active::before {
  background: var(--teal);
  transform: scale(1.3);
}

.chart-disclaimer {
  margin-top: 1rem;
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--dark2);
  text-align: center;
  opacity: 0.85;
}

/* Small ghost button (heatmap "See all" reset) */
.btn-ghost-sm {
  appearance: none;
  background: transparent;
  border: 1px solid var(--marble2);
  color: var(--teal);
  font-family: var(--ff);
  font-weight: 600;
  font-size: 0.78rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  transition: var(--transition);
}
.btn-ghost-sm:hover { background: var(--teal); color: var(--white); border-color: var(--teal); }

/* ── Treemap ──────────────────────────────────────────────────────────── */
.treemap-wrapper {
  width: 100%;
  height: 410px;
  position: relative;
}
.treemap-tile { transform-origin: center; }
@media (hover: hover) and (pointer: fine) {
  .treemap-tile:hover {
    transform: scale(1.03);
    filter: brightness(1.06);
  }
}
.treemap-tile:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ── Correlation heatmap ──────────────────────────────────────────────── */
.heatmap-wrapper {
  width: 100%;
  height: 410px;
  position: relative;
}
.heatmap-root { font-family: var(--ff); position: relative; }

.hm-cells { box-shadow: inset 0 0 0 1px var(--marble2); }
.hm-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 240ms cubic-bezier(.2,.9,.25,1);
  cursor: default;
}
.hm-cell-val {
  font-weight: 700;
  letter-spacing: -0.01em;
  pointer-events: none;
}

.hm-label {
  appearance: none;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  color: var(--dark1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
  white-space: nowrap;
  position: relative;
  transition: opacity 240ms cubic-bezier(.2,.9,.25,1), color 200ms;
}
.hm-row { justify-content: flex-end; padding-right: 0.5rem; }
.hm-col { justify-content: center; }
.hm-col.rotated {
  transform: rotate(-45deg);
  transform-origin: center bottom;
  white-space: nowrap;
}
/* Fully-vertical (90°) header labels — used on mobile so every column shows
   its ticker even when columns are narrow. overflow:visible lets the text
   extend along the (taller) header band instead of being clipped to the
   narrow column width before the transform is applied. */
.hm-col.rotated.vertical {
  transform: rotate(-90deg);
  transform-origin: center center;
  overflow: visible;
  white-space: nowrap;
  /* Grid items default to min-width:auto, so each label refuses to shrink
     below its horizontal text width (~79px) and overflows its 1fr track,
     dragging every column off-centre and pushing the last few past the
     matrix edge. min-width:0 lets the button collapse to its track; the
     nowrap text then overflows visibly and, once rotated, sits centred and
     vertical over its own column. */
  min-width: 0;
}
.hm-label:hover, .hm-label.hm-active { color: var(--teal); }

.hm-callout {
  position: fixed;
  z-index: 9999;
  display: none;
  pointer-events: none;
  background: var(--dark1);
  color: white;
  padding: 0.55rem 0.8rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  letter-spacing: 0.005em;
  white-space: nowrap;
}
.hm-callout-val {
  display: inline-block;
  margin-left: 0.6rem;
  padding: 0.1rem 0.4rem;
  background: var(--teal);
  border-radius: 4px;
  font-weight: 800;
}

.hm-disabled,
.hm-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem 1.5rem;
  background: var(--marble);
  border-radius: 12px;
  color: var(--dark2);
}
.hm-disabled-icon {
  color: var(--gold);
  margin-bottom: 0.85rem;
  opacity: 0.85;
}
.hm-disabled-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--dark1);
  margin-bottom: 0.5rem;
  letter-spacing: -0.005em;
}
.hm-disabled-body {
  font-size: 0.86rem;
  line-height: 1.55;
  max-width: 48ch;
  color: var(--dark2);
}

/* Reduced-motion: kill the smooth scroll and tile hover-scale */
@media (prefers-reduced-motion: reduce) {
  .carousel-track { scroll-behavior: auto; }
  .treemap-tile:hover { transform: none; filter: none; }
  .carousel-arrow:hover { transform: translateY(-50%); }
}

/* ── QUAFI Academy ───────────────────────────────────────────────────────────
   The free learning module: course home, lesson player + quiz, diploma. */
.aca-eyebrow {
  font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--gold); font-weight: 600; margin-bottom: 0.5rem;
}
.aca-hero { margin-bottom: 2rem; }
.aca-badges { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.9rem 0 0; }
.aca-badge {
  font-size: 0.78rem; font-weight: 500; color: var(--teal);
  background: var(--teal-pale); border-radius: 100px; padding: 0.3rem 0.8rem;
}
.aca-badge-free { background: var(--gold-light); color: #7a5e2e; }
.aca-progress-row { display: flex; align-items: center; gap: 0.8rem; margin-top: 1.2rem; max-width: 560px; }
.aca-progress-track { flex: 1 1 auto; height: 8px; background: var(--marble2); border-radius: 100px; overflow: hidden; }
.aca-progress-fill { height: 100%; background: var(--teal); border-radius: 100px; transition: width 0.4s; }
.aca-progress-label { font-size: 0.82rem; color: var(--dark2); white-space: nowrap; }
.aca-cta-row { margin-top: 1.3rem; }
.aca-status { color: var(--dark2); font-size: 0.9rem; padding: 0.5rem 0; }

.aca-module { margin-bottom: 1.6rem; }
.aca-module-head { display: flex; align-items: flex-start; gap: 0.9rem; margin-bottom: 0.7rem; }
.aca-module-num {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  background: var(--teal); color: var(--white); font-weight: 600; font-size: 0.95rem;
  display: inline-flex; align-items: center; justify-content: center;
}
.aca-module-title { font-size: 1.05rem; font-weight: 600; color: var(--dark1); }
.aca-module-summary { font-size: 0.85rem; color: var(--dark2); margin-top: 2px; max-width: 720px; }

.aca-lessons { display: flex; flex-direction: column; gap: 0.5rem; padding-left: 2.9rem; }
.aca-lesson {
  display: flex; align-items: center; gap: 0.9rem; width: 100%; text-align: left;
  padding: 0.85rem 1rem; background: var(--white); border: 1px solid var(--marble3);
  border-radius: var(--radius); cursor: pointer; font-family: var(--ff);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.aca-lesson:hover:not(:disabled) { border-color: var(--teal-light); box-shadow: var(--shadow-sm); }
.aca-lesson.is-locked { opacity: 0.6; cursor: not-allowed; background: var(--marble); }
.aca-lesson.is-done { border-color: var(--teal-pale); }
.aca-lesson-mark {
  flex: none; width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--marble3);
  display: inline-flex; align-items: center; justify-content: center; font-size: 0.8rem; color: var(--dark2);
}
.aca-lesson-mark.done { background: var(--teal); border-color: var(--teal); color: var(--white); }
.aca-lesson-text { flex: 1 1 auto; min-width: 0; }
.aca-lesson-title { display: block; font-size: 0.95rem; font-weight: 500; color: var(--dark1); }
.aca-lesson-obj { display: block; font-size: 0.8rem; color: var(--dark2); margin-top: 1px; }
.aca-lesson-meta { flex: none; font-size: 0.78rem; color: var(--dark2); }
.aca-disclaimer { font-size: 0.78rem; color: var(--dark2); margin-top: 2rem; font-style: italic; }

/* Lesson player */
.aca-lesson-body { max-width: 820px; }
.aca-video {
  margin: 1.2rem 0; border-radius: var(--radius-lg); overflow: hidden;
  background: var(--dark1); aspect-ratio: 16 / 9;
}
.aca-video video { width: 100%; height: 100%; display: block; }
.aca-video-soon {
  width: 100%; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0.5rem; color: var(--white);
  background: linear-gradient(0deg, var(--teal), var(--teal-light));
}
.aca-video-soon-icon {
  width: 64px; height: 64px; border-radius: 50%; background: rgba(255,255,255,0.18);
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.6rem; padding-left: 4px;
}
.aca-video-soon-sub { font-size: 0.82rem; opacity: 0.85; max-width: 420px; text-align: center; }

/* Lesson player controls: speed chips + captions toggle */
.aca-video-tools {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.7rem;
  margin: -0.5rem 0 1.2rem;
}
.aca-vt-group { display: inline-flex; align-items: center; gap: 0.3rem; flex-wrap: wrap; }
.aca-vt-label {
  font-size: 0.72rem; font-weight: 600; color: var(--dark1); opacity: 0.6;
  text-transform: uppercase; letter-spacing: 0.05em; margin-right: 0.2rem;
}
.aca-vt-chip {
  border: 1px solid var(--marble3); background: var(--white); color: var(--dark1);
  font-size: 0.8rem; font-weight: 500; padding: 0.26rem 0.55rem; border-radius: 999px;
  cursor: pointer; font-variant-numeric: tabular-nums;
  transition: background .15s, color .15s, border-color .15s;
}
.aca-vt-chip:hover { border-color: var(--teal); }
.aca-vt-chip.active { background: var(--teal); border-color: var(--teal); color: var(--white); }
.aca-vt-cc {
  display: inline-flex; align-items: center; gap: 0.4rem; margin-left: auto;
  border: 1px solid var(--marble3); background: var(--white); color: var(--dark1);
  font-size: 0.8rem; font-weight: 500; padding: 0.26rem 0.6rem; border-radius: 999px;
  cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.aca-vt-cc:hover { border-color: var(--teal); }
.aca-vt-cc.active { background: var(--teal); border-color: var(--teal); color: var(--white); }
.aca-vt-cc-icon {
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.02em;
  border: 1.5px solid currentColor; border-radius: 3px; padding: 0 3px; line-height: 1.3;
}

.aca-card { background: var(--white); border: 1px solid var(--marble3); border-radius: var(--radius-lg); padding: 1.5rem 1.7rem; }
.aca-read .md-h { font-size: 1rem; font-weight: 600; color: var(--teal); margin: 1.2rem 0 0.5rem; }
.aca-read .md-p { font-size: 0.95rem; line-height: 1.7; color: var(--dark1); margin: 0 0 0.9rem; }
.aca-read .md-ul { margin: 0 0 0.9rem; padding-left: 1.2rem; }
.aca-read .md-ul li { font-size: 0.95rem; line-height: 1.6; color: var(--dark1); margin-bottom: 0.35rem; }

/* Quiz */
.aca-quiz { margin-top: 1.8rem; }
.aca-quiz-title { font-size: 1.2rem; font-weight: 600; color: var(--dark1); margin: 0 0 0.3rem; }
.aca-quiz-sub { font-size: 0.85rem; color: var(--dark2); margin: 0 0 1.2rem; }
.aca-q { margin-bottom: 1.4rem; }
.aca-q-text { font-size: 1rem; font-weight: 500; color: var(--dark1); margin-bottom: 0.7rem; }
.aca-q-options { display: flex; flex-direction: column; gap: 0.5rem; }
.aca-opt {
  display: flex; align-items: center; gap: 0.7rem; width: 100%; text-align: left;
  padding: 0.7rem 0.9rem; background: var(--white); border: 1.5px solid var(--marble3);
  border-radius: var(--radius); cursor: pointer; font-family: var(--ff); font-size: 0.9rem; color: var(--dark1);
  transition: border-color 0.12s, background 0.12s;
}
.aca-opt:hover:not(:disabled) { border-color: var(--teal-light); }
.aca-opt-dot { flex: none; width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--marble3); }
.aca-opt.chosen { border-color: var(--teal); }
.aca-opt.chosen .aca-opt-dot { border-color: var(--teal); background: var(--teal); box-shadow: inset 0 0 0 3px var(--white); }
.aca-opt.correct { border-color: var(--green-soft); background: #eaf5ef; }
.aca-opt.correct .aca-opt-dot { border-color: var(--green-soft); background: var(--green-soft); }
.aca-opt.wrong { border-color: var(--red-soft); background: #f7ecec; }
.aca-opt.wrong .aca-opt-dot { border-color: var(--red-soft); background: var(--red-soft); }
.aca-q-explain { font-size: 0.85rem; color: var(--dark2); margin-top: 0.5rem; padding-left: 0.2rem; }
.aca-submit { margin-top: 0.5rem; }
.aca-result {
  margin-top: 1.4rem; padding: 1.1rem 1.3rem; border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.aca-result.pass { background: #eaf5ef; border: 1px solid var(--green-soft); }
.aca-result.fail { background: #f7ecec; border: 1px solid var(--red-soft); }
.aca-result-score { font-size: 1.05rem; font-weight: 600; color: var(--dark1); }
.aca-done-note { margin-top: 1rem; font-size: 0.85rem; color: var(--green-soft); }

/* Diploma */
.aca-cert-locked, .aca-cert-actions { margin-top: 1.2rem; }
.aca-cert-actions { display: flex; gap: 0.7rem; flex-wrap: wrap; }
.aca-diploma {
  position: relative; max-width: 720px; margin: 1.5rem auto; text-align: center;
  background: var(--white); border: 1px solid var(--marble3); border-top: 5px solid var(--teal);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 2.6rem 2rem 2rem;
}
.aca-diploma-mark { display: flex; justify-content: center; margin-bottom: 0.8rem; }
.aca-diploma-eyebrow { font-size: 0.8rem; letter-spacing: 0.2em; color: var(--gold); font-weight: 600; }
.aca-diploma-cap { font-size: 0.9rem; color: var(--dark2); margin-top: 1.1rem; }
.aca-diploma-name { font-size: 2rem; font-weight: 600; color: var(--teal); margin: 0.3rem 0; }
.aca-diploma-course { font-size: 1.3rem; font-weight: 600; color: var(--dark1); margin-top: 0.2rem; }
.aca-diploma-foot { display: flex; justify-content: space-between; margin-top: 2rem; font-size: 0.82rem; color: var(--dark2); }
.aca-diploma-note { font-size: 0.72rem; color: var(--dark2); margin-top: 1rem; font-style: italic; }
