/* ═══════════════════════════════════════════════════════════════════════════
   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);
}

/* ── 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;
}

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;
  padding: 0.45rem 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: rgba(58,106,114,0.1); color: var(--teal); }
#status-bar.building    { background: rgba(200,169,110,0.15); color: #8a6a2e; }
#status-bar.stale       { background: rgba(179,74,74,0.1); color: var(--red-soft); }
#status-bar.error       { background: rgba(179,74,74,0.1); 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;
  padding-top: 2.5rem;
}
.screen.active { display: flex; flex-direction: column; }

/* ── 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: 2.5rem;
  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;
}

/* Each orbit group rotates around the SVG centre. transform-box: view-box
   makes the 50% origin map to the centre of the viewBox (40,40). */
.quafi-mark .qm-orbit {
  transform-origin: 50% 50%;
  transform-box: view-box;
  will-change: transform;
}
.quafi-mark .qm-orbit-1 { animation: qm-spin-cw  9s linear infinite; }
.quafi-mark .qm-orbit-2 { animation: qm-spin-ccw 14s linear infinite; }
.quafi-mark .qm-orbit-3 { animation: qm-spin-cw 22s linear infinite; }

@keyframes qm-spin-cw  { from { transform: rotate(0deg);   } to { transform: rotate(360deg);  } }
@keyframes qm-spin-ccw { from { transform: rotate(0deg);   } to { transform: rotate(-360deg); } }

/* Respect users who prefer reduced motion — keep electrons static */
@media (prefers-reduced-motion: reduce) {
  .quafi-mark .qm-orbit { animation: none; }
}
.nav-actions { display: flex; 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);
}

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

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

.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-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;
}
.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;
}

/* 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%;
}

/* ── ══════════════════ OUTPUT SCREEN ══════════════════ ── */
.output-body {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 2rem 5rem;
  flex: 1;
}

.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;
  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: 720px) {
  #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: 1.4rem;
  left: 1.6rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--dark2);
  text-decoration: none;
  transition: color 200ms;
}
.auth-back:hover { color: var(--teal); }

.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;
}

.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: not-allowed;
  letter-spacing: 0.01em;
  opacity: 0.78;
}
.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;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: white;
  border: 1px solid var(--marble2);
  color: var(--dark2);
  cursor: pointer;
  transition: color 200ms, transform 600ms;
  padding: 0;
}
.user-badge .ub-cog:hover { color: var(--teal); transform: rotate(60deg); }

/* User badge dropdown menu */
.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: white;
  border: 1px solid var(--marble2);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.10);
  padding: 0.4rem;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: all 180ms;
}
.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); }
.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.6rem 1.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.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; }
