/* Market Signal — design system istituzionale (fonti, colori, componenti base, shell desktop).
   Usato da ogni pagina cosi' il prodotto si legge come un unico terminale, non moduli scollegati.

   Redesign professionale (Fase 2): l'ambra era il colore del TESTO di base (--text-primary), non
   un accento - ora --text-primary e' un neutro caldo, l'ambra (--accent) resta riservata a
   selezione/CTA/indicatori prioritari come richiesto. Font UI leggibile (Inter) per corpo e
   titoli, monospazio (JetBrains Mono, invariato) riservato a ticker/codici/numeri/dati tecnici. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  color-scheme: dark;
  --page:           #0a0a0b;
  --surface-1:      #131316;
  --surface-2:      #1b1b1f;
  --surface-3:      #242429;
  --text-primary:   #e9e7e2;
  --text-secondary: #a6a49f;
  --text-muted:     #706e6a;
  --gridline:       #2a2a2e;
  --baseline:       #45454a;
  --border:         #303035;
  --pos:            #3ecf8e;
  --pos-tint:       rgba(62,207,142,0.12);
  --pos-glow:       rgba(62,207,142,0);
  --neg:            #ef5350;
  --neg-tint:       rgba(239,83,80,0.12);
  --neg-glow:       rgba(239,83,80,0);
  --neutral:        #c6c4bf;
  --neutral-tint:   rgba(198,196,191,0.10);
  --accent:         #ffb000;
  --accent-tint:    rgba(255,176,0,0.12);
  --accent-2:       #6fa3d8;
  --accent-3:       #ffb000;
  --ai-accent:      #a685e2;
  --ai-accent-tint: rgba(166,133,226,0.14);
  --font-display:   'Inter', -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono:      'JetBrains Mono', ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --sidebar-w:      212px;
  --sidebar-w-collapsed: 56px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--page); }
html, body { height: 100%; }
body {
  margin: 0; color: var(--text-primary);
  font-family: var(--font-display);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
}

.shell { max-width: 720px; margin-inline: auto; padding: 14px 14px 32px; }

@media (min-width: 1024px) {
  body.with-sidebar .shell { max-width: 1400px; margin-inline: 0 0 0 auto; padding: 18px 28px 40px; margin-left: var(--sidebar-w); }
  body.with-sidebar.sidebar-collapsed .shell { margin-left: var(--sidebar-w-collapsed); }
}

/* back link, styled like a topbar action so it matches index.html's buttons */
.btn-back {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-muted); text-decoration: none; font-size: 0.78rem;
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 6px 0 12px; transition: color .1s ease;
}
.btn-back:hover { color: var(--accent); }

.btn {
  background: var(--page); color: var(--accent); border: 1px solid var(--accent); border-radius: 2px;
  padding: 7px 12px; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.05em;
  cursor: pointer; font-family: inherit; display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none;
  transition: background .1s ease, color .1s ease;
}
.btn:hover { background: var(--accent); color: #000; }
.btn:active { background: var(--accent-2); border-color: var(--accent-2); }

.input {
  width: 100%; background: var(--page); color: var(--text-primary); border: 1px solid var(--border);
  border-radius: 2px; padding: 10px 12px; font-size: 0.9rem; font-family: inherit;
}
.input:focus { outline: none; border-color: var(--accent); }

.card {
  background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 2px; padding: 14px;
  margin-bottom: 12px;
}
.card-title {
  font-size: 0.7rem; color: var(--accent-2); text-transform: uppercase; letter-spacing: 0.1em;
  font-weight: 700;
  margin: -14px -14px 12px; padding: 7px 14px;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
/* Learning Center: link "?" accanto a un titolo di card verso la voce di glossario corrispondente
   (glossary.py) - stile discreto, non deve competere visivamente col titolo stesso. */
.glossary-info-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--text-muted);
  color: var(--text-muted); font-size: 0.62rem; font-weight: 700; text-decoration: none;
  text-transform: none; letter-spacing: normal; margin-left: 5px; vertical-align: middle;
}
.glossary-info-link:hover { border-color: var(--accent-2); color: var(--accent-2); }

h1 { font-size: 1.15rem; margin: 0 0 4px; font-weight: 700; letter-spacing: 0.01em; color: var(--text-primary); }

table { width: 100%; border-collapse: collapse; background: var(--surface-1); border: 1px solid var(--border); }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--gridline); font-size: 0.82rem; vertical-align: middle; }
th { color: var(--accent-2); font-weight: 700; font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.06em; background: var(--surface-2); }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.disclaimer, .disclaimer-box {
  font-size: 0.74rem; color: var(--text-muted); line-height: 1.6; margin-top: 18px;
  padding: 12px 14px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 2px;
}

/* ==========================================================================
   Componenti condivisi tra le pagine con nav/bottom-nav (Home, Discover,
   Companies, Markets, Alerts, Learning) — spostati qui da index.html perche'
   la Fase 1 di Market Signal 2.0 rompe l'unico index.html monolitico in piu'
   pagine reali che condividono tutti questi componenti: un solo punto di
   verita' invece di N copie della stessa regola.
   ========================================================================== */

body.with-bottom-nav { padding-bottom: 84px; }

/* Footer legale globale (Fase 1 Autonomous Research Desk): sempre nel flusso normale del
   documento (mai fixed, a differenza di .bottom-nav) - su desktop resta l'ultima riga della
   pagina, su mobile scorre sopra alla bottom-nav fissa senza esserne mai coperto. */
.research-disclaimer-footer {
  display: block; margin: 20px 0 4px; padding: 12px 14px 0; border-top: 1px solid var(--border);
  font-size: 0.68rem; line-height: 1.5; color: var(--text-muted);
}
.research-disclaimer-footer a { color: var(--text-muted); text-decoration: underline; white-space: nowrap; margin-left: 6px; }
.research-disclaimer-footer a:hover { color: var(--accent); }
/* _bottom_nav.html (che include questo footer) e' incluso DOPO la chiusura di .shell in ogni
   pagina, quindi non eredita l'offset desktop di .shell per la sidebar fissa - senza questa
   regola il testo finirebbe visivamente sotto la sidebar invece che nell'area di contenuto. */
@media (min-width: 1024px) {
  body.with-sidebar .research-disclaimer-footer { max-width: 1400px; margin-left: var(--sidebar-w); padding: 12px 28px 0; }
  body.with-sidebar.sidebar-collapsed .research-disclaimer-footer { margin-left: var(--sidebar-w-collapsed); }
}

/* topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 0 -14px 16px; padding: 10px 14px; position: sticky; top: 0; z-index: 30;
  background: var(--page); border-bottom: 1px solid var(--border);
}
.topbar h1 {
  font-size: 1.05rem; margin: 0; letter-spacing: 0.03em; font-weight: 700; color: var(--text-primary);
  text-transform: uppercase;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
/* Fase Beta 2 (lancio Beta pubblica gratuita): badge discreto, mai un elemento che compete
   visivamente col wordmark - stesso trattamento "pill" gia' usato altrove (topbar-status-pill). */
.beta-badge {
  font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 2px 8px; border-radius: 20px; border: 1px solid var(--accent);
  color: var(--accent); background: var(--accent-tint); text-decoration: none; white-space: nowrap;
}
.beta-badge:hover { border-color: var(--accent-2); color: var(--accent-2); }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex-shrink: 0; }
.topbar-wordmark { white-space: nowrap; }
.user-email-pill { font-size: 0.72rem; color: var(--text-muted); }
.user-email-pill strong { color: var(--text-secondary); font-weight: 600; }

/* barra di ricerca globale (Fase 7 redesign) */
.topbar-search {
  display: flex; align-items: center; gap: 8px; flex: 1 1 auto; max-width: 480px;
  margin: 0 16px; padding: 7px 12px; background: var(--surface-1); border: 1px solid var(--border);
  color: var(--text-muted);
}
.topbar-search:focus-within { border-color: var(--accent); color: var(--accent); }
.topbar-search svg { width: 15px; height: 15px; flex-shrink: 0; }
.topbar-search input {
  flex: 1; background: none; border: none; color: var(--text-primary); font-family: inherit;
  font-size: 0.82rem; min-width: 0;
}
.topbar-search input:focus { outline: none; }
.topbar-search input::placeholder { color: var(--text-muted); }
@media (max-width: 900px) { .topbar-search { display: none; } }

/* LIVE, alert/messaggi, avatar (Fase 7 redesign) */
.topbar-status-pill { display: flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--pos); }
.live-pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--pos); animation: pulse-dot 1.2s step-start infinite; }
.topbar-live-label { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.06em; color: var(--pos); }
.topbar-icon-btn {
  position: relative; display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border: 1px solid var(--border); color: var(--text-secondary); flex-shrink: 0;
}
.topbar-icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.topbar-icon-btn svg { width: 16px; height: 16px; }
.topbar-badge {
  position: absolute; top: -6px; right: -6px; min-width: 16px; height: 16px; padding: 0 3px;
  background: var(--neg); color: #fff; font-size: 0.6rem; font-weight: 700; line-height: 16px;
  text-align: center; border-radius: 8px; font-family: var(--font-mono);
}
.topbar-avatar { display: flex; align-items: center; gap: 8px; text-decoration: none; padding: 3px 8px 3px 3px; border: 1px solid var(--border); flex-shrink: 0; }
.topbar-avatar:hover { border-color: var(--accent); }
.topbar-avatar-mark {
  width: 26px; height: 26px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  background: var(--accent-tint); color: var(--accent); font-size: 0.7rem; font-weight: 700; font-family: var(--font-mono);
}
.topbar-avatar-meta { display: flex; flex-direction: column; line-height: 1.25; max-width: 140px; }
.topbar-avatar-meta .n { font-size: 0.74rem; color: var(--text-primary); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-avatar-meta .r { font-size: 0.64rem; color: var(--text-muted); }
@media (max-width: 640px) { .topbar-avatar-meta { display: none; } }
.btn-ghost {
  font-size: 0.76rem; color: var(--text-muted); background: none; border: 1px solid var(--border);
  padding: 6px 10px; text-decoration: none; display: inline-flex; align-items: center; cursor: pointer;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* Selettore lingua: bottoni custom "IT"/"EN" + dropdown per le altre lingue europee, entrambi
   guidati via JS sopra il motore di Google Translate (nascosto - vedi .visually-hidden). Stile
   completamente nostro cosi' il widget si integra con l'estetica del sito invece di mostrare
   il dropdown grezzo di Google. */
.lang-switcher { display: flex; align-items: center; gap: 0; border: 1px solid var(--border); }
.translate-icon { font-size: 0.78rem; line-height: 1; padding: 0 8px 0 10px; opacity: 0.75; }
.lang-btn {
  font-family: var(--font-mono); font-size: 0.7rem; font-weight: 600; letter-spacing: 0.03em;
  color: var(--text-muted); background: none; border: none; border-left: 1px solid var(--border);
  padding: 6px 9px; cursor: pointer; transition: color 0.15s, background 0.15s;
}
.lang-btn:first-of-type { border-left: none; }
.lang-btn:hover { color: var(--text-primary); background: rgba(255,176,0,0.08); }
.lang-btn.active { color: #000; background: var(--accent); }
.lang-more {
  font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-muted); background: var(--page);
  border: none; border-left: 1px solid var(--border); padding: 6px 6px; cursor: pointer;
}
.lang-more:hover { color: var(--text-primary); }
.visually-hidden {
  position: absolute !important; width: 1px !important; height: 1px !important;
  padding: 0 !important; margin: -1px !important; overflow: hidden !important;
  clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important;
}
/* Google inietta una banda in cima alla pagina (e un fumetto informativo dopo il primo cambio
   lingua) quando la traduzione e' attiva; li nascondiamo perche' i bottoni IT/EN nella topbar
   coprono gia' quel controllo. Le classi generate da Google sono offuscate/variabili, ma tutti
   questi elementi hanno in comune "skiptranslate" (usata anche per marcare contenuto da NON
   tradurre, quindi il selettore resta mirato ai soli iframe). */
iframe.skiptranslate, iframe[id$=".container"], iframe[id$=".theme"], #goog-gt-tt { display: none !important; visibility: hidden !important; }
body { top: 0 !important; }
html { margin-top: 0 !important; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 0; flex-shrink: 0; position: relative;
  display: flex; align-items: center; justify-content: center;
  background: var(--page);
  border: 1px solid var(--accent);
}
.brand-mark svg { width: 16px; height: 16px; color: var(--accent); }
.brand-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--pos);
  animation: pulse-dot 1.2s step-start infinite;
  position: absolute; top: -3px; right: -3px;
}
@keyframes pulse-dot { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0.15; } }
.update-pill { font-size: 0.7rem; color: var(--text-muted); }
.btn svg { width: 14px; height: 14px; }

/* KPI row */
.kpi-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-bottom: 14px; }
@media (min-width: 560px) { .kpi-row { grid-template-columns: repeat(4, 1fr); } }
.kpi-tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: 2px; padding: 10px 12px; }
.kpi-label { font-size: 0.64rem; color: var(--accent-2); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 5px; font-weight: 700; }
.kpi-value { font-size: 1.4rem; font-weight: 700; line-height: 1.1; font-family: var(--font-mono); letter-spacing: -0.01em; color: var(--text-primary); }
.kpi-sub { font-size: 0.7rem; color: var(--text-muted); margin-top: 3px; }

.subscriber-trend { display: flex; align-items: flex-end; gap: 4px; height: 56px; margin: 14px 0 4px; }
.trend-bar-wrap { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.trend-bar { width: 100%; background: var(--accent-2); min-height: 2px; }
.subscriber-table { width: 100%; font-size: 0.8rem; margin-top: 10px; border-collapse: collapse; }
.subscriber-table th {
  text-align: left; color: var(--text-muted); font-weight: 600; font-size: 0.64rem;
  text-transform: uppercase; letter-spacing: 0.04em; padding-bottom: 6px;
}
.subscriber-table td { padding: 6px 0; border-top: 1px solid var(--gridline); color: var(--text-secondary); }
.subscriber-table td:last-child { text-align: right; }

/* hero row: gauge + donuts */
.hero-row { display: grid; grid-template-columns: 1fr; gap: 6px; margin-bottom: 14px; }
@media (min-width: 640px) { .hero-row { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px) { .hero-row { grid-template-columns: repeat(4, 1fr); } }

.gauge-wrap { display: flex; align-items: center; gap: 14px; }
.gauge-center-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.gauge-svg-box { position: relative; width: 100px; height: 100px; flex-shrink: 0; }
.gauge-score { font-size: 1.25rem; font-weight: 700; font-family: var(--font-mono); }
.gauge-key { font-size: 0.66rem; color: var(--text-muted); }
.gauge-meta { font-size: 0.8rem; color: var(--text-secondary); }
.gauge-meta strong { color: var(--text-primary); }

.donut-wrap { display: flex; align-items: center; gap: 14px; }
.donut-svg-box { position: relative; width: 88px; height: 88px; flex-shrink: 0; }
.donut-total { font-size: 1rem; font-weight: 700; font-family: var(--font-mono); }
.donut-total-label { font-size: 0.6rem; color: var(--text-muted); }
.donut-legend { display: flex; flex-direction: column; gap: 5px; font-size: 0.76rem; }
.donut-legend-row { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); }
.legend-dot { width: 8px; height: 8px; border-radius: 0; flex-shrink: 0; }

/* heatmap */
.heatmap { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-bottom: 14px; }
@media (min-width: 560px) { .heatmap { grid-template-columns: repeat(4, 1fr); } }
.heat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 0; padding: 9px 11px;
  border-left: 3px solid var(--tile-color, var(--neutral));
  cursor: pointer;
  text-decoration: none; color: inherit; display: block;
}
.heat-tile:hover { background: var(--surface-2); border-color: var(--tile-color, var(--border)); }
.heat-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 2px; }
.heat-code { font-size: 0.8rem; font-weight: 700; color: var(--text-secondary); }
.heat-score { font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.heat-bias { font-size: 0.63rem; color: var(--text-muted); margin-bottom: 6px; }
.heat-tile svg { display: block; width: 100%; height: 22px; }

/* section header + explain */
.section-head { margin: 18px 0 4px; display: flex; align-items: center; gap: 8px; }
h2 {
  font-size: 0.92rem; margin: 0; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text-primary);
  display: flex; align-items: center; gap: 8px;
}
h2::before { content: ""; width: 4px; height: 14px; flex-shrink: 0; background: var(--accent-2); }
.section-explain { font-size: 0.78rem; color: var(--text-secondary); margin: 6px 0 12px; line-height: 1.55; }

/* tables */
tr.row-clickable { cursor: pointer; }
tr.row-clickable:hover { background: var(--surface-2); }

.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.num.pos { color: var(--pos); }
.num.neg { color: var(--neg); }
.num.neutral { color: var(--text-secondary); }

.bias-tag { display: inline-block; padding: 2px 8px; border-radius: 0; font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; border: 1px solid transparent; }
.bias-tag.pos { background: var(--pos-tint); color: var(--pos); border-color: var(--pos); }
.bias-tag.neg { background: var(--neg-tint); color: var(--neg); border-color: var(--neg); }
.bias-tag.neutral { background: var(--neutral-tint); color: var(--text-secondary); border-color: var(--border); }

.meter-cell { min-width: 130px; }
.meter-track { position: relative; height: 4px; background: var(--gridline); border-radius: 0; margin-bottom: 4px; }
.meter-center { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--baseline); }
.meter-fill { position: absolute; top: 0; bottom: 0; border-radius: 0; }
.meter-fill.pos { background: var(--pos); }
.meter-fill.neg { background: var(--neg); }
.meter-fill.neutral { background: var(--neutral); }

.row-spark { width: 70px; height: 22px; display: block; }
.glow-line { filter: none; }

.funds-line { font-size: 0.74rem; color: var(--text-secondary); }
.funds-line .buy::before { content: "\25B2 "; color: var(--pos); }
.funds-line .sell::before { content: "\25BC "; color: var(--neg); }
.funds-line div { margin-bottom: 2px; }

.opp-list { display: flex; flex-direction: column; gap: 8px; }
.opp-card { padding: 12px 14px; }
.opp-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.opp-label { font-size: 0.88rem; font-weight: 600; }
.opp-score { font-size: 1.02rem; font-weight: 700; color: var(--pos); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.opp-score-max { font-size: 0.68rem; font-weight: 500; color: var(--text-muted); }
.opp-meter { margin-bottom: 8px; }
.opp-reasons { margin: 0; padding-left: 18px; font-size: 0.76rem; color: var(--text-secondary); }
.opp-reasons li { margin-bottom: 2px; }
.opp-card, .radar-card { display: block; text-decoration: none; color: inherit; }
.radar-card:hover { border-color: var(--accent); }
.radar-card-unresolved { cursor: default; opacity: 0.7; }
.radar-card-unresolved:hover { border-color: var(--border); }
.radar-note { font-size: 0.7rem; color: var(--text-muted); margin-top: 4px; font-style: italic; }

.feature-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.feature-card {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 11px 14px; text-decoration: none; color: inherit;
}
.feature-card:hover { border-color: var(--accent); }
.feature-main { min-width: 0; }
.feature-label { font-size: 0.86rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feature-desc { font-size: 0.74rem; color: var(--text-secondary); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feature-class { font-size: 0.66rem; color: var(--text-muted); margin-top: 2px; }
.feature-score-box { text-align: right; flex-shrink: 0; }
.feature-score-box .num { font-size: 1.05rem; }
.feature-score-box .delta { font-size: 0.66rem; color: var(--text-muted); }

.subnav { display: flex; gap: 4px; margin-bottom: 14px; overflow-x: auto; padding-bottom: 2px; }
.subnav-btn {
  background: var(--page); color: var(--text-secondary); border: 1px solid var(--border);
  border-radius: 0; padding: 6px 14px; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em;
  cursor: pointer; font-family: inherit;
  white-space: nowrap; flex-shrink: 0;
}
.subnav-btn.active { background: var(--accent); color: #000; border-color: var(--accent); }
.subview { display: none; }
.subview.active { display: block; }

.cb-list, .alert-list { list-style: none; padding: 0; margin: 0; }
.cb-item, .alert-item { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--gridline); }
.cb-item:last-child, .alert-item:last-child { border-bottom: none; }
.cb-item a { color: var(--text-primary); text-decoration: none; font-size: 0.83rem; }
.cb-item a:hover { text-decoration: underline; }
.cb-meta, .alert-meta { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }
.alert-item .label { font-size: 0.83rem; }
.alert-when { margin-left: auto; font-size: 0.7rem; color: var(--text-muted); white-space: nowrap; }
.empty-state { font-size: 0.8rem; color: var(--text-muted); padding: 10px 0; }

.two-col { display: grid; grid-template-columns: 1fr; gap: 6px; margin-bottom: 14px; }
@media (min-width: 640px) { .two-col { grid-template-columns: 1fr 1fr; } }

.settings-form { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.settings-label { font-size: 0.76rem; color: var(--text-secondary); display: flex; flex-direction: column; gap: 4px; }
.settings-input {
  background: var(--page); color: var(--text-primary); border: 1px solid var(--border); border-radius: 2px;
  padding: 8px 10px; font-size: 0.86rem; font-family: inherit;
}
.settings-form .btn { align-self: flex-start; }
.settings-hint { font-size: 0.7rem; color: var(--text-muted); margin: 8px 0 0; }
.settings-hint a { color: var(--accent-2); }
.fund-list { list-style: none; padding: 0; margin: 0 0 6px; }
.fund-row {
  display: flex; align-items: center; justify-content: space-between; padding: 8px 0;
  border-bottom: 1px solid var(--gridline); font-size: 0.83rem;
}
.fund-row:last-child { border-bottom: none; }
.btn-icon {
  background: none; border: 1px solid var(--neg); color: var(--neg); border-radius: 0; width: 24px; height: 24px;
  cursor: pointer; font-size: 0.9rem; line-height: 1; font-family: inherit;
}
.btn-icon:hover { background: var(--neg); color: #000; }
.info-block { font-size: 0.83rem; color: var(--text-secondary); line-height: 1.6; }
.info-block h3 { font-size: 0.83rem; color: var(--text-primary); margin: 16px 0 6px; text-transform: uppercase; letter-spacing: 0.03em; }
.info-block ul { margin: 4px 0; padding-left: 18px; }

/* detail sheet (pannello "chi/perche'/quando") */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.8);
  z-index: 50; display: none; align-items: flex-end; justify-content: center;
}
.sheet-backdrop.open { display: flex; }
.sheet {
  width: 100%; max-width: 640px; max-height: 82vh; overflow-y: auto;
  background: var(--page);
  border: 1px solid var(--accent); border-bottom: none;
  border-radius: 0; padding: 18px 18px calc(20px + env(safe-area-inset-bottom));
}
.sheet-handle { width: 36px; height: 3px; border-radius: 0; background: var(--gridline); margin: 0 auto 14px; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 4px; }
.sheet-title { font-size: 1.02rem; font-weight: 700; }
.sheet-close {
  background: var(--page); border: 1px solid var(--border); color: var(--text-secondary);
  width: 28px; height: 28px; border-radius: 0; cursor: pointer; font-size: 1rem; line-height: 1;
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
}
.sheet-close:hover { color: var(--accent); border-color: var(--accent); }
.sheet-score-row { display: flex; align-items: baseline; gap: 10px; margin: 6px 0 16px; }
.sheet-score { font-size: 2.1rem; font-weight: 700; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.sheet-score.pos { color: var(--pos); } .sheet-score.neg { color: var(--neg); } .sheet-score.neutral { color: var(--text-secondary); }
.sheet-section { margin-bottom: 14px; }
.sheet-label {
  font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent-2);
  display: flex; align-items: center; gap: 6px; margin-bottom: 5px; font-weight: 700;
}
.sheet-text { font-size: 0.86rem; line-height: 1.6; color: var(--text-secondary); }
.sheet-meta-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-top: 4px; }
.sheet-meta-cell { background: var(--surface-1); border: 1px solid var(--border); border-radius: 0; padding: 8px 10px; }
.sheet-meta-cell .v { font-size: 0.9rem; font-weight: 700; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.sheet-meta-cell .l { font-size: 0.63rem; color: var(--text-muted); margin-top: 1px; }
body.sheet-locked { overflow: hidden; }

/* bottom nav */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  background: var(--page);
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-around; padding: 5px 2px calc(5px + env(safe-area-inset-bottom));
}
@media (min-width: 1024px) { body.with-sidebar .bottom-nav { display: none; } }
.nav-btn {
  background: none; border: none; color: var(--text-muted); font-family: var(--font-display); font-size: 0.6rem;
  text-transform: uppercase; letter-spacing: 0.01em;
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 7px 1px; cursor: pointer; border-radius: 0;
  flex: 1; min-width: 0; text-decoration: none; white-space: nowrap;
}
.nav-btn svg { width: 20px; height: 20px; }
.nav-btn.active { color: var(--accent); }
.nav-btn-ai.active { color: var(--ai-accent); }

/* menu "Altro" (Fase 8 - mobile companion): bottom sheet che rispecchia la sidebar desktop */
.mobile-menu-sheet { padding-bottom: env(safe-area-inset-bottom); }
.mobile-menu-nav { display: flex; flex-direction: column; gap: 1px; }
.mobile-menu-nav .sidebar-link { font-size: 0.88rem; padding: 11px 9px; }
.mobile-menu-nav .sidebar-link svg { width: 17px; height: 17px; }
.mobile-menu-nav .sidebar-group-label:first-child { padding-top: 4px; }
.mobile-menu-foot { border-top: 1px solid var(--border); margin-top: 10px; padding-top: 8px; }
.mobile-menu-foot .sidebar-link { font-size: 0.88rem; padding: 11px 9px; }
.mobile-menu-foot .sidebar-status-pill { padding: 8px 9px; }

@media (max-width: 480px) {
  table.wide-cols th:nth-child(4), table.wide-cols td:nth-child(4) { display: none; }
}

/* ==========================================================================
   Sidebar desktop (Fase 2 - shell professionale). Nascosta sotto i 1024px:
   sotto quella soglia resta la bottom-nav esistente (companion mobile), sopra
   prende il suo posto e la bottom-nav si nasconde (vedi regola su .bottom-nav).
   ========================================================================== */
.sidebar {
  display: none;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 40; width: var(--sidebar-w);
  background: var(--surface-1); border-right: 1px solid var(--border);
  flex-direction: column; overflow-y: auto; overflow-x: hidden;
  transition: width 0.15s ease;
}
@media (min-width: 1024px) { body.with-sidebar .sidebar { display: flex; } }
body.with-sidebar.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }

.sidebar-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 14px 12px; border-bottom: 1px solid var(--border); }
.sidebar-brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--text-primary); min-width: 0; }
.sidebar-brand-label { font-size: 0.82rem; font-weight: 700; letter-spacing: 0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.sidebar-collapsed .sidebar-brand-label,
body.sidebar-collapsed .sidebar-link span,
body.sidebar-collapsed .sidebar-group-label,
body.sidebar-collapsed .sidebar-status-label { display: none; }
.sidebar-collapse-btn {
  background: none; border: 1px solid var(--border); color: var(--text-muted); border-radius: 2px;
  width: 22px; height: 22px; flex-shrink: 0; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.sidebar-collapse-btn:hover { color: var(--accent); border-color: var(--accent); }
.sidebar-collapse-btn svg { width: 13px; height: 13px; transition: transform 0.15s ease; }
body.sidebar-collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }

.sidebar-nav { display: flex; flex-direction: column; gap: 1px; padding: 8px; flex: 1; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 9px; border-radius: 2px;
  color: var(--text-secondary); text-decoration: none; font-size: 0.8rem; font-weight: 500;
  white-space: nowrap; overflow: hidden;
}
.sidebar-link svg { width: 15px; height: 15px; flex-shrink: 0; }
.sidebar-link span { overflow: hidden; text-overflow: ellipsis; }
.sidebar-link:hover { background: var(--surface-2); color: var(--text-primary); }
.sidebar-link.active { background: var(--accent-tint); color: var(--accent); font-weight: 600; }
.sidebar-link-ai { color: var(--ai-accent); }
.sidebar-link-ai:hover { background: var(--ai-accent-tint); color: var(--ai-accent); }
.sidebar-link-ai.active { background: var(--ai-accent-tint); color: var(--ai-accent); }
.sidebar-group-label {
  font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted);
  font-weight: 700; padding: 14px 9px 4px; white-space: nowrap; overflow: hidden;
}
.sidebar-group-label:first-child { padding-top: 4px; }
.sidebar-foot form { margin: 0; }

.sidebar-foot { padding: 10px; border-top: 1px solid var(--border); }
.sidebar-status-pill { display: flex; align-items: center; gap: 7px; text-decoration: none; padding: 4px 2px; }
.sidebar-status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: var(--text-muted); }
.sidebar-status-dot.status-healthy { background: var(--pos); }
.sidebar-status-dot.status-partial, .sidebar-status-dot.status-delayed { background: var(--accent); }
.sidebar-status-dot.status-degraded, .sidebar-status-dot.status-offline { background: var(--neg); }
.sidebar-status-label { font-size: 0.68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* topbar: sul desktop il bordo/negative-margin del topbar deve seguire il nuovo padding di .shell */
@media (min-width: 1024px) {
  body.with-sidebar .topbar { margin: 0 -28px 16px; padding: 10px 28px; }
}

/* pill "ultimo aggiornamento" / stato provider nella topbar - solo il pallino sotto i 720px,
   la topbar mobile e' gia' densa (lingua, CTA, admin) e questa non e' la sua priorita' li'
   (lo stato e' comunque sempre raggiungibile da Capital Flow al tap). */
.topbar-status-pill { display: flex; align-items: center; gap: 6px; font-size: 0.7rem; color: var(--text-muted); white-space: nowrap; }
.topbar-status-pill .sidebar-status-dot { width: 6px; height: 6px; }
@media (max-width: 720px) { .topbar-status-pill span:last-child { display: none; } }

/* ==========================================================================
   Drawer laterale generico (Fase 2 - shell professionale). Infrastruttura
   condivisa: nessuna pagina lo popola ancora, le fasi successive collegano
   le proprie righe di tabella a MarketSignalDrawer.open()/openUrl().
   ========================================================================== */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65); z-index: 55;
  display: none; justify-content: flex-end;
}
.drawer-backdrop.open { display: flex; }
.drawer {
  width: 100%; max-width: 480px; height: 100%; overflow-y: auto;
  background: var(--surface-1); border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.drawer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0;
  background: var(--surface-1); z-index: 1;
}
.drawer-title { font-size: 0.92rem; font-weight: 700; color: var(--text-primary); }
.drawer-close {
  background: none; border: 1px solid var(--border); color: var(--text-secondary);
  width: 26px; height: 26px; border-radius: 2px; cursor: pointer; font-size: 1.1rem; line-height: 1;
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
}
.drawer-close:hover { color: var(--accent); border-color: var(--accent); }
.drawer-body { padding: 16px; font-size: 0.84rem; color: var(--text-secondary); line-height: 1.6; }
.drawer-loading { color: var(--text-muted); font-size: 0.82rem; padding: 20px 0; text-align: center; }
@media (max-width: 640px) { .drawer { max-width: 100%; } }

/* Onboarding (Fase Beta 2): contenuto renderizzato dentro il drawer generico sopra, stessa
   tipografia/spaziatura del resto del drawer, solo la progress label e le azioni sono proprie. */
.onboarding-progress { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 10px; }
.onboarding-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

/* ============ LIVE NEWS TAPE (Fase News 2) ============
   Scorrimento guidato da JS (requestAnimationFrame + scrollLeft), non da una keyframe animation
   CSS: un marquee CSS puro presume una larghezza di contenuto fissa (di solito duplicando il
   contenuto e traslando del -50%) - fragile con elementi che arrivano in continuazione via SSE.
   JS puo' mettere in pausa/riprendere/cambiare velocita' istantaneamente senza ricalcolare nulla. */
.news-tape {
  display: flex; align-items: stretch; border-bottom: 1px solid var(--border);
  background: var(--surface-1); font-family: var(--font-mono); font-size: 0.78rem;
  margin: -6px -14px 16px; /* stesso escamotage del .topbar: esce dal padding di .shell per apparire a piena larghezza */
}
.news-tape-label {
  display: flex; align-items: center; gap: 6px; padding: 0 10px; flex-shrink: 0;
  background: var(--surface-2); border-right: 1px solid var(--border);
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent); white-space: nowrap;
}
.news-tape-status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--neutral); flex-shrink: 0; }
.news-tape-status-dot.status-connecting { background: var(--accent); animation: live-pulse 1.2s ease-in-out infinite; }
.news-tape-status-dot.status-near-real-time { background: var(--pos); animation: live-pulse 1.6s ease-in-out infinite; }
.news-tape-status-dot.status-offline { background: var(--neg); }
@media (prefers-reduced-motion: reduce) { .news-tape-status-dot { animation: none !important; } }

.news-tape-viewport { flex: 1; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.news-tape-viewport::-webkit-scrollbar { display: none; }
.news-tape-track { display: flex; gap: 26px; padding: 0 16px; width: max-content; }

.news-tape-item {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 0; white-space: nowrap;
  color: var(--text-secondary); cursor: pointer; border: none; background: none; font: inherit;
}
.news-tape-item:hover, .news-tape-item:focus-visible { color: var(--text-primary); }
.news-tape-item:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }
.news-tape-badge {
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
  padding: 1px 6px; border-radius: 2px; flex-shrink: 0;
}
.news-tape-badge.importance-relevant { background: var(--accent-tint); color: var(--accent); }
.news-tape-badge.importance-informational { background: var(--neutral-tint); color: var(--neutral); }
.news-tape-region { color: var(--accent-2); flex-shrink: 0; }
.news-tape-time, .news-tape-age { color: var(--text-muted); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.news-tape-source { color: var(--text-muted); flex-shrink: 0; }

.news-tape-controls, .news-tape-filters {
  display: flex; align-items: center; gap: 4px; padding: 0 8px; flex-shrink: 0; border-left: 1px solid var(--border);
}
.news-tape-btn {
  background: none; border: 1px solid var(--border); color: var(--text-secondary);
  min-width: 24px; height: 24px; padding: 0 5px; border-radius: 2px; cursor: pointer; font-size: 0.68rem;
  display: flex; align-items: center; justify-content: center; font-family: var(--font-mono);
}
.news-tape-btn:hover { color: var(--accent); border-color: var(--accent); }
.news-tape-btn[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--accent-tint); }
.news-tape-filter-select {
  background: var(--page); border: 1px solid var(--border); color: var(--text-secondary);
  font-size: 0.66rem; font-family: inherit; padding: 3px 4px; border-radius: 2px; max-width: 90px;
}
.news-tape-empty { padding: 7px 16px; font-size: 0.76rem; color: var(--text-muted); white-space: nowrap; }
.news-tape.hidden { display: none; }

.news-drawer-section { margin-bottom: 16px; }
.news-drawer-section h4 {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent-2);
  margin-bottom: 6px;
}
.news-drawer-meta-row { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.76rem; color: var(--text-muted); }
.news-drawer-limitation {
  font-size: 0.76rem; color: var(--text-muted); border: 1px solid var(--border); border-radius: 2px;
  padding: 8px 10px; background: var(--surface-2);
}

@media (max-width: 900px) {
  .news-tape-filters { display: none; }
}
