/* ═══════════════════════════════════════════════════════
   TradeDesk — Design Tokens & Global Styles
   ═══════════════════════════════════════════════════════ */
:root {
  /* Layout */
  --bg: #0a0b0f;
  --panel: #101219;
  --card: #161923;
  --border: #1f2334;
  --border-hi: #2c3049;
  --grid: #171b2a;

  /* Text hierarchy */
  --text: #d0d4e2;
  --text-bright: #e8ebf4;
  --text-dim: #8a90ab;
  --text-muted: #5c6180;
  --text-faint: #6b7194;
  --text-soft: #b8bdd4;

  /* Accent palette */
  --green: #26d97f;
  --green-dim: rgba(38, 217, 127, .12);
  --red: #f0506e;
  --red-dim: rgba(240, 80, 110, .12);
  --blue: #4da6ff;
  --blue-dim: rgba(77, 166, 255, .12);
  --blue-hover: #3d96f0;
  --amber: #ffb833;
  --amber-dim: rgba(255, 184, 51, .12);
  --purple: #a78bfa;
  --purple-dim: rgba(167, 139, 250, .12);

  /* Extended opacity variants (theme-aware) */
  --green-subtle: rgba(38, 217, 127, .06);
  --green-med: rgba(38, 217, 127, .15);
  --green-strong: rgba(38, 217, 127, .18);
  --red-subtle: rgba(240, 80, 110, .06);
  --red-med: rgba(240, 80, 110, .15);
  --red-strong: rgba(240, 80, 110, .18);
  --blue-med: rgba(77, 166, 255, .15);
  --blue-strong: rgba(77, 166, 255, .22);
  --blue-focus: rgba(77, 166, 255, .3);
  --amber-light: rgba(255, 184, 51, .12);
  --purple-med: rgba(167, 139, 250, .15);

  /* Chart / tooltip (theme-aware) */
  --label-bg: rgba(19, 23, 34, .85);
  --chart-tooltip-bg: rgba(16, 18, 25, .96);
  --chart-tooltip-border: rgba(77, 166, 255, .25);

  /* Chrome */
  --toolbar-active: #1e2136;
  --toolbar-w: 52px;
  --topbar-h: 46px;
  --rsb-strip-w: 52px;
  --rsb-panel-w: 400px;

  /* ── Component Design Tokens ── */

  /* Border radius scale (use ONLY these 3) */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  /* Overlay / modal backdrop */
  --overlay-bg: rgba(0, 0, 0, .65);
  --overlay-blur: 4px;
  --overlay-shadow: 0 16px 48px rgba(0, 0, 0, .55);

  /* Transition */
  --ease: .15s ease;

  /* Hover layers */
  --hover-subtle: rgba(255, 255, 255, .05);
  --hover-medium: rgba(255, 255, 255, .08);

  /* Scrollbar (theme-aware) */
  --scrollbar-thumb: rgba(255, 255, 255, .35);
  --scrollbar-thumb-hover: rgba(255, 255, 255, .5);

  /* Surface layers — theme-aware opacity overlays
     On dark: white alpha. On light: black alpha (inverted via preset). */
  --surface-veil:            rgba(255, 255, 255, .02);
  --surface-raised:          rgba(255, 255, 255, .06);
  --surface-border:          rgba(255, 255, 255, .08);
  --surface-border-hi:       rgba(255, 255, 255, .12);
  --surface-border-strong:   rgba(255, 255, 255, .18);
  --divider-soft:            rgba(255, 255, 255, .04);

  /* Shadows (theme-aware) */
  --shadow-soft:    rgba(0, 0, 0, .15);
  --shadow-strong:  rgba(0, 0, 0, .35);

  /* Pill-tab active state (white pill) */
  --pill-active-bg: #fff;
  --pill-active-color: #111;

  /* Font stacks (Outfit = UI, JetBrains = data) */
  --font-ui: 'Outfit', sans-serif;
  --font-data: 'JetBrains Mono', monospace;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
/* ═══════════════════════════════════════════════════════
   Scrollbar & Responsive
   ═══════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

/* ═══════════════════════════════════════════════════════
   Light theme — body shadow under cards/panels
   ═══════════════════════════════════════════════════════ */
:root[data-theme="light"] body {
  color: var(--text);
}

/* ═══════════════════════════════════════════════════════
   Toast / avvisi transitori (notify.js) — es. rate limit
   ═══════════════════════════════════════════════════════ */
#appToastContainer {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 100000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.app-toast {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  line-height: 1.35;
  color: #fff;
  background: rgba(22, 22, 28, .97);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: var(--radius-md);
  box-shadow: var(--overlay-shadow);
  padding: 13px 20px;
  max-width: min(90vw, 460px);
  text-align: center;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity var(--ease), transform var(--ease);
  pointer-events: auto;
}
.app-toast--show { opacity: 1; transform: translateY(0); }
.app-toast--warn  { border-color: rgba(240, 185, 60, .55); }
.app-toast--error { border-color: rgba(240, 90, 90, .55); }

/* ─────────────────────────────────────────────────────────────────────
   Data Health — avvisi delisting / dati mancanti (js/data-health.js)
   Finestra di avviso (modale) + badge chart + overlay failed + banner pannelli
   ───────────────────────────────────────────────────────────────────── */

/* Finestra di avviso (modale) */
.dh-modal-overlay {
  position: fixed; inset: 0; z-index: 4000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6, 7, 11, .62);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .2s ease;
  padding: 20px;
}
.dh-modal-overlay--show { opacity: 1; }
.dh-modal {
  position: relative;
  width: min(92vw, 460px);
  background: var(--panel, #101219);
  border: 1px solid var(--border-hi, #2c3049);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .55);
  padding: 26px 26px 22px;
  text-align: center;
  transform: translateY(10px) scale(.98);
  transition: transform .22s cubic-bezier(.2, .8, .2, 1);
}
.dh-modal-overlay--show .dh-modal { transform: translateY(0) scale(1); }
.dh-modal--warn  { border-top: 3px solid #f0b93c; }
.dh-modal--error { border-top: 3px solid var(--red, #f0506e); }
.dh-modal-close {
  position: absolute; top: 10px; right: 12px;
  background: none; border: none; cursor: pointer;
  font-size: 26px; line-height: 1; color: var(--text-muted, #5c6180);
  transition: color .15s;
}
.dh-modal-close:hover { color: var(--text-bright, #e8ebf4); }
.dh-modal-icon {
  width: 54px; height: 54px; margin: 4px auto 14px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
}
.dh-modal--warn  .dh-modal-icon { background: rgba(240, 185, 60, .14); color: #f0b93c; }
.dh-modal--error .dh-modal-icon { background: var(--red-med, rgba(240, 80, 110, .15)); color: var(--red, #f0506e); }
.dh-modal-icon svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.dh-modal-title {
  margin: 0 0 10px; font-family: var(--font-ui);
  font-size: 1.25rem; font-weight: 700; color: var(--text-bright, #e8ebf4);
}
.dh-modal-body { font-size: .96rem; line-height: 1.55; color: var(--text, #d0d4e2); }
.dh-modal-body p { margin: 0 0 10px; }
.dh-modal-body b { color: var(--text-bright, #e8ebf4); font-weight: 600; }
.dh-modal-note {
  margin-top: 14px !important; padding-top: 12px;
  border-top: 1px solid var(--border, #1f2334);
  font-size: .88rem; color: var(--text-dim, #8a90ab);
}
.dh-modal-actions { margin-top: 20px; }
.dh-modal-ok {
  font-family: var(--font-ui); font-size: .95rem; font-weight: 600;
  color: #0a0b0f; background: var(--text-bright, #e8ebf4);
  border: none; border-radius: 9px; padding: 11px 26px; cursor: pointer;
  transition: filter .15s, transform .1s;
}
.dh-modal-ok:hover { filter: brightness(1.08); }
.dh-modal-ok:active { transform: scale(.97); }

/* Badge persistente sulla chart (dati vecchi / stale) */
.dh-chart-badge {
  position: absolute; top: 10px; right: 64px; z-index: 40;
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-ui); font-size: .78rem; font-weight: 600;
  color: #f0b93c;
  background: rgba(20, 16, 6, .92);
  border: 1px solid rgba(240, 185, 60, .55);
  border-radius: 7px; padding: 5px 10px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
  transition: background .15s, transform .1s;
}
.dh-chart-badge:hover { background: rgba(40, 32, 10, .96); }
.dh-chart-badge:active { transform: scale(.96); }
.dh-chart-badge svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* Overlay sulla chart (failed / nessun dato) */
.dh-chart-overlay {
  position: absolute; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 9, 13, .72);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  padding: 24px; text-align: center;
}
.dh-overlay-card { max-width: 440px; }
.dh-overlay-icon {
  width: 60px; height: 60px; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--red-med, rgba(240, 80, 110, .15)); color: var(--red, #f0506e);
}
.dh-overlay-icon svg { width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.dh-overlay-title { font-family: var(--font-ui); font-size: 1.35rem; font-weight: 700; color: var(--text-bright, #e8ebf4); margin-bottom: 10px; }
.dh-overlay-title b { color: var(--red, #f0506e); }
.dh-overlay-sub { font-size: .96rem; line-height: 1.6; color: var(--text-dim, #8a90ab); margin-bottom: 20px; }
.dh-overlay-sub b { color: var(--text, #d0d4e2); font-weight: 600; }
.dh-overlay-btn {
  font-family: var(--font-ui); font-size: .95rem; font-weight: 600;
  color: #0a0b0f; background: var(--text-bright, #e8ebf4);
  border: none; border-radius: 9px; padding: 11px 24px; cursor: pointer;
  transition: filter .15s, transform .1s;
}
.dh-overlay-btn:hover { filter: brightness(1.08); }
.dh-overlay-btn:active { transform: scale(.97); }

/* Banner inline nei pannelli di analisi */
.dh-panel-banner {
  display: flex; align-items: flex-start; gap: 10px;
  font-family: var(--font-ui); font-size: .88rem; line-height: 1.5;
  color: #f0d79a;
  background: rgba(240, 185, 60, .1);
  border: 1px solid rgba(240, 185, 60, .38);
  border-radius: 9px; padding: 11px 14px; margin: 0 0 14px;
}
.dh-panel-banner b { color: #f5c452; font-weight: 700; }
.dh-panel-banner svg { flex: 0 0 auto; width: 18px; height: 18px; margin-top: 1px; fill: none; stroke: #f0b93c; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
/* Variante flottante per i modali a colonne */
.dh-panel-banner--float {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  z-index: 50; width: auto; max-width: min(90vw, 680px); margin: 0;
  background: rgba(30, 24, 6, .97);
  box-shadow: 0 6px 22px rgba(0, 0, 0, .5);
}

/* Tema chiaro */
:root[data-theme="light"] .dh-modal { background: #fff; border-color: #e2e5ee; }
:root[data-theme="light"] .dh-chart-badge { background: rgba(255, 250, 240, .96); color: #b8860b; }
:root[data-theme="light"] .dh-chart-overlay { background: rgba(245, 246, 250, .8); }

/* ─────────────────────────────────────────────────────────────────────
   Teaser prosa gated (guest/free) — riusabile da tutti i report.
   Il 1° paragrafo è reale; sotto, SOLO filler fittizio inviato dal server
   (i paragrafi veri non vengono serializzati → non-scavalcabile). Il blur a
   gradiente fa sfumare il filler, con CTA lucchetto "Abbonati" → /pricing.
   ───────────────────────────────────────────────────────────────────── */
.rpt-teaser { position: relative; margin-top: 4px; overflow: hidden; min-height: 132px; }
.rpt-teaser-fade {
  filter: blur(3.5px); -webkit-filter: blur(3.5px);
  user-select: none; pointer-events: none;
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 0%, rgba(0,0,0,.85) 28%, rgba(0,0,0,0) 92%);
          mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 0%, rgba(0,0,0,.85) 28%, rgba(0,0,0,0) 92%);
}
.rpt-teaser-fade p { margin: .55em 0; color: var(--text-muted); line-height: 1.55; }
.rpt-teaser-cta {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 2;
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  padding: 10px 18px; border-radius: 10px;
  background: #4da3ff; color: #fff !important; font-weight: 700; font-size: .92rem;
  text-decoration: none; box-shadow: 0 8px 24px rgba(77,163,255,.4); transition: background .15s ease;
}
.rpt-teaser-cta:hover { background: #6fb8ff; }
.rpt-teaser-ico { font-size: 1.05em; line-height: 1; }

/* ─────────────────────────────────────────────────────────────────────
   Report LOCKED (guest/free) — l'intero corpo analitico è premium: i capitoli
   gated NON renderizzano dati reali (vedi drawdown-report.js wsRenderReportLocked).
   Qui sotto solo uno SCHELETRO decorativo sfocato (finte card chart, nessun
   numero reale) con overlay e CTA al pricing. Riusabile da tutti i report.
   ───────────────────────────────────────────────────────────────────── */
.rpt-locked { position: relative; margin-top: 22px; min-height: 560px; }
.rpt-locked-blur {
  filter: blur(7px); -webkit-filter: blur(7px);
  opacity: .42; pointer-events: none; user-select: none;
}
.rpt-sk-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 18px 18px 16px; margin-bottom: 18px;
}
.rpt-sk-title {
  width: 42%; height: 14px; border-radius: 6px; margin-bottom: 20px;
  background: rgba(255,255,255,.13);
}
.rpt-sk-chart { display: flex; align-items: flex-end; gap: 6px; height: 190px; }
.rpt-sk-bar {
  flex: 1 1 0; min-width: 4px; border-radius: 4px 4px 0 0;
  background: linear-gradient(to top, rgba(77,163,255,.45), rgba(77,163,255,.12));
}
.rpt-sk-lines { margin: 4px 2px 0; }
.rpt-sk-lines span { display: block; height: 11px; border-radius: 6px; margin: 9px 0; background: rgba(255,255,255,.08); }
.rpt-sk-lines span:nth-child(1) { width: 92%; }
.rpt-sk-lines span:nth-child(2) { width: 78%; }
.rpt-sk-lines span:nth-child(3) { width: 85%; }
.rpt-sk-lines span:nth-child(4) { width: 64%; }
.rpt-locked-cta {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; text-align: center; padding: 30px 24px;
  background: linear-gradient(to bottom, rgba(10,11,15,0) 0%, rgba(10,11,15,.72) 26%, rgba(10,11,15,.86) 100%);
}
.rpt-locked-ico { font-size: 2.4rem; line-height: 1; filter: drop-shadow(0 4px 16px rgba(0,0,0,.5)); }
.rpt-locked-h { font-size: 1.32rem; font-weight: 800; color: var(--text-bright, #e8ebf4); }
.rpt-locked-sub { max-width: 520px; font-size: .96rem; line-height: 1.55; color: var(--text-dim, #8a90ab); }
.rpt-locked-btn {
  margin-top: 6px; display: inline-flex; align-items: center; gap: 9px; white-space: nowrap;
  padding: 13px 24px; border-radius: 12px;
  background: #4da3ff; color: #fff !important; font-weight: 700; font-size: 1rem;
  text-decoration: none; box-shadow: 0 10px 30px rgba(77,163,255,.42); transition: background .15s ease;
}
.rpt-locked-btn:hover { background: #6fb8ff; }
.ws-nav-locked { opacity: .7; }
.ws-nav-locked .ws-nav-num { font-size: .9em; }
