/* Rateqora — design system "Market Signal" (provvisorio).
   Token unici: sostituendo questi valori si cambia l'identità senza toccare i componenti. */
:root {
  --graphite: #171918;
  --graphite-2: #222522;
  --graphite-3: #2E322E;
  --graphite-line: #393D39;
  --paper: #F7F6F2;
  --surface: #FFFFFF;
  --surface-2: #FBFAF7;
  --line: #E3E2DC;
  --line-strong: #CFCEC6;
  --ink: #171918;
  --ink-2: #4A4E49;
  --muted: #6F736D;
  --neutral: #A9ACA6;
  --signal: #F26A30;
  --signal-ink: #C24A16;
  --signal-soft: #FDEDE4;
  --pos: #2F7D4F;
  --pos-soft: #E6F2EA;
  --warn: #9A6B00;
  --warn-soft: #FBF1D9;
  --info-soft: #ECEEEA;
  --focus: 0 0 0 3px rgba(242, 106, 48, .35);
  --radius: 6px;
  --radius-sm: 4px;
  --font-display: "Space Grotesk", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sidebar-w: 236px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 14px/1.5 var(--font-ui); -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 26px; line-height: 1.2; }
h2 { font-size: 17px; }
h3 { font-size: 14px; font-family: var(--font-ui); font-weight: 600; letter-spacing: 0; }
p { margin: 0; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }
.num, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  background: var(--graphite); color: #DAD9D3; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; padding: 20px 14px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; text-decoration: none; color: #fff; }
.brand img { width: 26px; height: 26px; }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 17px; letter-spacing: .16em; }
.brand-sub { display: block; font-size: 9.5px; letter-spacing: .22em; color: var(--neutral); margin-top: 1px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius);
  text-decoration: none; color: #C9C8C1; font-weight: 500; position: relative;
}
.nav a svg { width: 17px; height: 17px; flex: none; stroke: currentColor; }
.nav a:hover { background: var(--graphite-2); color: #fff; }
.nav a[aria-current="page"] { background: var(--graphite-2); color: #fff; }
.nav a[aria-current="page"]::before {
  content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; background: var(--signal); border-radius: 0 2px 2px 0;
}
.nav .count { margin-left: auto; font: 500 11px var(--font-mono); background: var(--graphite-3); color: #fff; padding: 1px 6px; border-radius: 10px; }
.nav .count.hot { background: var(--signal); }
.sidebar-sep { height: 1px; background: var(--graphite-line); margin: 14px 6px; }
.sidebar-foot { margin-top: auto; padding: 0 8px; display: grid; gap: 14px; }
.by { font-size: 10.5px; letter-spacing: .2em; color: var(--neutral); }
.by b { color: #fff; font-weight: 600; }
/* "by THE SELLA" con il logo di The Sella e il link a thesella.com (04.11.2026) */
.by-sella { display: inline-flex; align-items: center; gap: 7px; color: inherit; text-decoration: none; }
.by-sella img { display: block; height: 32px; width: auto; }
.by .by-sella img { height: 28px; }
.small .by-sella img { height: 24px; }
.by-sella:hover { opacity: .8; }
.by-sella:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }

.lang-switch { display: inline-flex; border: 1px solid var(--graphite-line); border-radius: var(--radius); overflow: hidden; }
.lang-switch button {
  background: transparent; border: 0; color: #C9C8C1; padding: 5px 10px; cursor: pointer; font-size: 12px; font-weight: 600; letter-spacing: .06em;
}
.lang-switch button[aria-pressed="true"] { background: var(--paper); color: var(--graphite); }
.lang-switch.light { border-color: var(--line-strong); }
.lang-switch.light button { color: var(--ink-2); }
.lang-switch.light button[aria-pressed="true"] { background: var(--graphite); color: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 14px 28px; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.topbar .menu-btn { display: none; }
.selector { display: flex; flex-direction: column; gap: 2px; }
.selector label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.selector select {
  appearance: none; background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236F736D' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 6px 30px 6px 10px; min-width: 150px; max-width: 280px; cursor: pointer;
}
.selector select:hover { border-color: var(--neutral); }
.topbar-meta { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; letter-spacing: .06em;
  padding: 3px 8px; border-radius: var(--radius-sm); white-space: nowrap; text-transform: uppercase;
}
.badge.demo { background: var(--signal-soft); color: var(--signal-ink); border: 1px solid #F6C3AA; }
.badge.neutral { background: var(--info-soft); color: var(--ink-2); }
.badge.pos { background: var(--pos-soft); color: var(--pos); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.signal { background: var(--signal); color: #fff; }
.asof { font-size: 12px; color: var(--muted); }
.asof .mono { color: var(--ink-2); }

.content { padding: 24px 28px 48px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; max-width: 1360px; width: 100%; }
.content > *, .grid > * { min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head .eyebrow { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--signal-ink); font-weight: 600; margin-bottom: 6px; }
.page-head .lead { color: var(--ink-2); margin-top: 6px; max-width: 760px; }

.notice {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--radius);
  border: 1px solid #F6C3AA; background: var(--signal-soft); color: #6B2C10; font-size: 13px;
}
.notice.info { border-color: var(--line); background: var(--surface); color: var(--ink-2); }
.notice.warn { border-color: #EBD49A; background: var(--warn-soft); color: #5E4300; }
.notice svg { flex: none; width: 16px; height: 16px; margin-top: 2px; }
.notice-trial { display: inline-block; font-weight: 500; }
.notice-trial a { color: var(--signal-ink); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Cards & grids ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head p { color: var(--muted); font-size: 12px; margin-top: 2px; }
.card-body { padding: 16px 18px; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.two { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
.halves { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; min-height: 124px; }
.kpi .k-label { font-size: 12px; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi .k-value { font-family: var(--font-mono); font-size: 28px; font-weight: 500; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi .k-value.text { font-family: var(--font-display); font-size: 19px; font-weight: 600; letter-spacing: -.01em; line-height: 1.25; }
.kpi .k-sub { font-size: 12px; color: var(--ink-2); margin-top: auto; }
.kpi.accent { border-top: 3px solid var(--signal); }
.up, .down { color: var(--ink); }   /* sopra o sotto il mercato non è "giusto" o "sbagliato" */
.flat { color: var(--ink-2); }

/* ---------- Position chart ---------- */
.position { padding: 8px 18px 18px; }
.position svg { width: 100%; height: auto; display: block; overflow: visible; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--ink-2); padding: 0 18px 14px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600;
  padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0;
}
table.data th button { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
table.data th button:focus-visible { box-shadow: var(--focus); }
table.data th[aria-sort="ascending"] button::after { content: "↑"; color: var(--signal-ink); }
table.data th[aria-sort="descending"] button::after { content: "↓"; color: var(--signal-ink); }
table.data td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
table.data th { font-family: var(--font-ui); }
table.data td.num, table.data th.num { text-align: right; }
table.data tr.excluded td { color: var(--muted); background: #FCFCFA; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: #FAF8F3; }
table.data tr.selected td { background: #FFF6F1; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot.in { background: var(--pos); }
.dot.out { background: var(--neutral); }
.dot.rep { background: var(--signal); }
.reason { display: block; font-size: 12px; color: var(--ink-2); white-space: normal; min-width: 180px; max-width: 260px; }
td.wrap { white-space: normal; min-width: 130px; }
.rep-tag { display: block; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--signal-ink); font-weight: 600; margin-top: 2px; }
.cond-unknown { color: var(--muted); font-style: italic; }

/* ---------- Controls ---------- */
.tabs { display: inline-flex; gap: 2px; background: var(--info-soft); padding: 3px; border-radius: var(--radius); }
.tabs button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: var(--radius-sm); cursor: pointer; font-weight: 500; color: var(--ink-2);
}
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.field input, .field select {
  border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 7px 10px; background: var(--surface); min-width: 120px;
}
.field select {
  appearance: none; padding-right: 30px; cursor: pointer;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236F736D' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 10px center;
}
.field input:hover, .field select:hover { border-color: var(--neutral); }
.field input[aria-invalid="true"] { border-color: var(--signal); background: var(--signal-soft); }
.field .hint { font-size: 11.5px; color: var(--muted); }
.field .err { font-size: 11.5px; color: var(--signal-ink); }
.input-affix { display: flex; align-items: stretch; }
.input-affix input { border-radius: var(--radius) 0 0 var(--radius); min-width: 0; width: 100%; font-family: var(--font-mono); }
.input-affix span { border: 1px solid var(--line-strong); border-left: 0; padding: 7px 10px; background: var(--surface-2); border-radius: 0 var(--radius) var(--radius) 0; color: var(--muted); font-size: 12px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  padding: 7px 14px; border-radius: var(--radius); cursor: pointer; font-weight: 500; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--neutral); background: var(--surface-2); }
.btn.primary { background: var(--signal); border-color: var(--signal); color: #fff; }
.btn.primary:hover { background: #E35D24; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--signal-ink); padding-left: 0; padding-right: 0; }
.btn svg { width: 15px; height: 15px; stroke: currentColor; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line-strong); background: var(--surface); padding: 5px 12px; border-radius: 999px; cursor: pointer; font-size: 12.5px; font-weight: 500;
}
.chip[aria-pressed="true"] { background: var(--graphite); color: #fff; border-color: var(--graphite); }
.chip .num { margin-left: 6px; opacity: .8; }

/* ---------- Stats blocks ---------- */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stats > div { padding: 14px 18px; }
.stats > div + div { border-left: 1px solid var(--line); }
.stat-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin-bottom: 10px; }
dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; font-size: 13px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
dl.kv dd.text { font-family: var(--font-ui); }

/* ---------- Observations ---------- */
.obs-list { display: grid; }
.obs { display: grid; grid-template-columns: 4px 1fr auto; gap: 0 16px; padding: 14px 18px; border-bottom: 1px solid var(--line); align-items: start; }
.obs:last-child { border-bottom: 0; }
.obs .bar { align-self: stretch; border-radius: 2px; background: var(--neutral); }
.obs.actionable .bar { background: var(--signal); }
.obs.insufficient_evidence .bar { background: #D9B44A; }
.obs .o-title { font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.obs .o-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.obs .o-body { color: var(--ink-2); margin-top: 6px; font-size: 13px; max-width: 760px; }
.obs .o-side { text-align: right; display: grid; gap: 8px; justify-items: end; }
.obs .o-figure { font-family: var(--font-mono); font-size: 20px; font-variant-numeric: tabular-nums; }

/* ---------- Simulator ---------- */
.sim { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); }
.sim-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.sim-form .full { grid-column: 1 / -1; }
.radio-row { display: flex; gap: 6px; flex-wrap: wrap; }
.radio-row label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; text-transform: none; letter-spacing: 0; color: var(--ink); font-weight: 400; border: 1px solid var(--line-strong); padding: 6px 10px; border-radius: var(--radius); cursor: pointer; }
.radio-row input { accent-color: var(--signal); margin: 0; min-width: 0; padding: 0; border: 0; }
table.breakdown { width: 100%; border-collapse: collapse; font-size: 13px; }
table.breakdown th { text-align: right; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 6px 0 8px; font-weight: 600; }
table.breakdown th:first-child { text-align: left; }
table.breakdown td { padding: 8px 0; border-bottom: 1px solid var(--line); }
table.breakdown td + td { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
table.breakdown tr.total td { font-weight: 600; border-bottom: 0; border-top: 2px solid var(--ink); font-size: 15px; }
table.breakdown tr.minus td:first-child::before { content: "− "; color: var(--muted); }

/* ---------- States ---------- */
.state { padding: 36px 18px; text-align: center; color: var(--muted); display: grid; gap: 8px; justify-items: center; }
.state strong { color: var(--ink); font-family: var(--font-display); font-size: 16px; }
.skeleton { background: linear-gradient(90deg, #EEEDE8 25%, #F6F5F1 50%, #EEEDE8 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--radius-sm); height: 14px; }
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } * { transition: none !important; } }
.fade-in { animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }

.meter { height: 6px; background: var(--info-soft); border-radius: 3px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--graphite); }
.reliability { display: grid; gap: 12px; }
.rel-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; font-size: 13px; }
.rel-row .meter { grid-column: 1 / -1; }
.source-line { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; padding: 6px 0; border-top: 1px dashed var(--line); }

.footer-note { font-size: 12px; color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two, .sim { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(84vw, 300px); z-index: 30; transform: translateX(-100%);
    transition: transform .2s ease; height: 100%;
  }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(23, 25, 24, .45); }
  .topbar { padding: 10px 16px; }
  .topbar .menu-btn { display: inline-flex; }
  .selector select { min-width: 0; max-width: 100%; }
  .selector { flex: 1 1 140px; }
  .topbar-meta { margin-left: 0; width: 100%; justify-content: space-between; }
  .content { padding: 16px 16px 40px; }
  .halves, .stats { grid-template-columns: 1fr; }
  .stats > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .sim-form { grid-template-columns: 1fr; }
  h1 { font-size: 22px; }
  .obs { grid-template-columns: 4px 1fr; }
  .obs .o-side { grid-column: 2; justify-items: start; text-align: left; margin-top: 10px; }
}
@media (max-width: 520px) {
  .kpis { grid-template-columns: 1fr; }
  .kpi { min-height: 0; }
}

/* Contesto ufficiale (DATI REALI, D-57): separato a colpo d'occhio dai dati simulati */
.card.official { border-left: 3px solid var(--pos); margin-top: 16px; }
.card.official h2 .badge { margin-left: 8px; vertical-align: middle; }
.official-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; padding: 0 20px 8px; }
.official-series .k-sub { margin-top: 4px; }
.official-notes p + p { margin-top: 4px; }

