@font-face { font-family: "IBM Plex Sans"; src: url(plex-sans-400.3b646991d3.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url(plex-sans-500.0717336fb3.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url(plex-sans-600.8960851d69.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url(plex-mono-400.3c5a451f9e.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url(plex-mono-500.756026ff72.woff2) format("woff2"); font-weight: 500; font-display: swap; }

:root {
  color-scheme: dark;
  --bg: #0b0c0e;
  --surface: #121317;
  --surface-2: #1a1c21;
  --line: #24272e;
  --line-2: #363a43;
  --ink: #f1ede4;
  --ink-2: #bfbaaf;
  --ink-3: #979389;
  --gold: #d4af61;
  --gold-ink: #e7c77e;
  --on-gold: #15120a;
  --good: #57cf97;
  --bad: #f58a82;
  --warn: #e9b44c;
  --series-1: #4f8be8;
  --series-2: #b08a38;
  --warn-bg: #2a2110;
  --bad-bg: #2f1816;
  --info-bg: #182130;
  --shadow: none;
  --r: 3px;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f6f2e9;
    --surface: #fdfbf6;
    --surface-2: #efe9dc;
    --line: #ddd5c4;
    --line-2: #c5bca8;
    --ink: #15161a;
    --ink-2: #45433c;
    --ink-3: #66635a;
    --gold: #7f5d12;
    --gold-ink: #6d4f0e;
    --on-gold: #fff9ea;
    --good: #0f7b4e;
    --bad: #c23b33;
    --warn: #8f5a00;
    --series-1: #2f6fde;
    --series-2: #8e6a1b;
    --warn-bg: #f8edd5;
    --bad-bg: #fbe6e3;
    --info-bg: #e4edfb;
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f2e9;
  --surface: #fdfbf6;
  --surface-2: #efe9dc;
  --line: #ddd5c4;
  --line-2: #c5bca8;
  --ink: #15161a;
  --ink-2: #45433c;
  --ink-3: #66635a;
  --gold: #7f5d12;
  --gold-ink: #6d4f0e;
  --on-gold: #fff9ea;
  --good: #0f7b4e;
  --bad: #c23b33;
  --warn: #8f5a00;
  --series-1: #2f6fde;
  --series-2: #8e6a1b;
  --warn-bg: #f8edd5;
  --bad-bg: #fbe6e3;
  --info-bg: #e4edfb;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 76px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 var(--sans);
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
}
h1, h2, h3, p { margin: 0; }
h2 { font: 600 24px/1.25 var(--sans); letter-spacing: -.012em; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 30; }
.skip:focus { left: 16px; }
.lead { color: var(--ink-2); }
.mute { color: var(--ink-3); font-size: 13px; }
.num { font-family: var(--mono); font-size: .94em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--good); }
.neg { color: var(--bad); }

/* testata */
.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top-in {
  max-width: 1240px; margin: 0 auto; padding: 10px 24px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.word { font: 600 17px/1.1 var(--sans); letter-spacing: -.01em; color: var(--ink); }
.paper {
  font: 500 12px/1 var(--mono); letter-spacing: .6px; text-transform: uppercase; line-height: 1;
  color: var(--warn); border: 1px solid var(--warn); border-radius: var(--r); padding: 4px 9px;
}
.stamp { display: flex; align-items: center; gap: 7px; color: var(--ink-2); font-size: 13px; min-width: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.stamp[data-status="ok"] .dot { background: var(--good); }
.stamp[data-status="stale"] .dot, .stamp[data-status="partial"] .dot { background: var(--warn); }
.stamp[data-status="none"] .dot, .stamp[data-status="offline"] .dot { background: var(--bad); }
.stamp[data-status="stale"], .stamp[data-status="offline"] { color: var(--ink); font-weight: 600; }
.tools { display: flex; align-items: center; gap: 8px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.seg button {
  min-height: 38px; min-width: 42px; padding: 0 10px; border: 0; background: transparent; color: var(--ink-2); font-size: 13px; font-weight: 600;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); }
.icon { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: var(--r); background: transparent; color: var(--ink-2); }

/* avvisi */
.banners { max-width: 1240px; margin: 0 auto; padding: 0 24px; }
.banner { margin-top: 12px; padding: 11px 14px; border-radius: var(--r); border: 1px solid; font-size: 14px; }
.banner[data-level="warn"] { background: var(--warn-bg); border-color: var(--warn); }
.banner[data-level="bad"] { background: var(--bad-bg); border-color: var(--bad); }
.banner[data-level="info"] { background: var(--info-bg); border-color: var(--series-1); }

.page { max-width: 1240px; margin: 0 auto; padding: 20px 24px 40px; }
.block { margin-top: 40px; }
.block > h2 { margin-bottom: 4px; }
.block > .lead { margin-bottom: 4px; }
#paper .stats { margin-top: 12px; }
#paper h3 { margin: 24px 0 8px; font-size: 14px; }
#paper > .mute { margin-top: 16px; }
body.dim .page { opacity: .72; }

/* portafoglio */
.hero {
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 1px;
  background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow);
}
.hero-main, .hero-now { background: var(--surface); padding: 24px; min-width: 0; }
.hero-label { font: 500 12px/1.4 var(--mono); letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.hero-value { font: 400 46px/1.08 var(--mono); letter-spacing: -.04em; margin: 6px 0 2px; overflow-wrap: anywhere; }
.hero-delta { font: 500 15px/1.4 var(--mono); }
.hero-note { font-size: 13px; color: var(--warn); margin-top: 6px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 20px; }
.stat dt, .mini dt { font-size: 12px; color: var(--ink-3); }
.stat dd, .mini dd { margin: 2px 0 0; font-family: var(--mono); font-weight: 500; font-size: 14px; }
dl { margin: 0; }
.hero-now h2 { font-size: 21px; margin-bottom: 10px; }
.now { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.now li { display: grid; grid-template-columns: 10px 1fr; gap: 10px; color: var(--ink-2); font-size: 14.5px; }
.now li::before { content: ""; width: 7px; height: 7px; margin-top: 7px; border-radius: 2px; background: var(--ink-3); transform: rotate(45deg); }
.now li[data-kind="position"]::before { background: var(--gold); }
.now li[data-kind="position"] { color: var(--ink); }

/* tabelle */
.tbl-wrap { margin-top: 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow: hidden; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font: 500 12px/1.4 var(--mono); letter-spacing: .03em; color: var(--ink-3); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th.r, td.r { text-align: right; }
td.strong { font-weight: 600; }
.pill { display: inline-block; font: 500 12px/1.5 var(--mono); padding: 2px 8px; border-radius: var(--r); border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; }
.pill[data-side="1"], .pill[data-side="-1"] { color: var(--ink); border-color: var(--gold); }
.empty { margin-top: 12px; padding: 18px; border: 1px dashed var(--line); border-radius: var(--r); color: var(--ink-2); }

/* schede mercato */
.cards { margin-top: 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow);
  padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0;
}
.card[data-state="position"] { border-color: color-mix(in srgb, var(--gold) 55%, var(--line)); }
.card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.card-name { font: 600 21px/1.2 var(--sans); letter-spacing: -.01em; }
.card-sub { font-size: 12px; color: var(--ink-3); }
.card-price { text-align: right; }
.card-price b { display: block; font: 500 16px/1.3 var(--mono); }
.card-price span { font-size: 12px; color: var(--ink-3); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: var(--r); background: var(--surface-2); color: var(--ink-2); }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.chip[data-state="position"], .chip[data-state="signal"] { color: var(--ink); }
.chip[data-state="position"]::before, .chip[data-state="signal"]::before { background: var(--gold); }
.chip[data-state="blocked"]::before, .chip[data-state="no_data"]::before { background: var(--bad); }
.chip[data-state="closed"]::before { background: transparent; box-shadow: inset 0 0 0 2px var(--ink-3); }
.chip[data-alert] { background: var(--warn-bg); color: var(--ink); }
.chip[data-alert]::before { background: var(--warn); border-radius: 1px; transform: rotate(45deg); }
.part h3 { font: 500 12px/1.4 var(--mono); letter-spacing: .03em; color: var(--ink-3); margin-bottom: 3px; }
.part p { color: var(--ink); font-size: 14.5px; }
.part p + p { margin-top: 4px; }
.part .note { color: var(--ink-2); font-size: 13px; }
.minis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.mini dd { font-size: 14px; }
.mini dd small { display: block; font-size: 12px; color: var(--ink-3); font-weight: 400; }
.acct { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
details { border-top: 1px solid var(--line); padding-top: 4px; margin-top: auto; }
summary { cursor: pointer; font-size: 13px; color: var(--ink-2); min-height: 40px; display: flex; align-items: center; gap: 8px; }
summary::after { content: "+"; margin-left: auto; color: var(--ink-3); font-size: 18px; line-height: 1; }
details[open] summary::after { content: "−"; }
.rules { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 12px; }
.rule-head { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; font-weight: 600; }
.rule-head span { color: var(--ink-3); font-weight: 400; }
.rules p { font-size: 13px; color: var(--ink-2); }
.rules p[data-ok="true"] { color: var(--ink); }
.feed { font-size: 12px; color: var(--ink-3); overflow-wrap: anywhere; }

/* grafico */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 104px; touch-action: pan-y; }
.chart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.chart .ln.close { stroke: var(--series-1); }
.chart .ln.st { stroke: var(--series-2); stroke-dasharray: 5 4; }
.chart .ref { stroke-width: 1; stroke-dasharray: 2 3; vector-effect: non-scaling-stroke; }
.chart .ref.stop { stroke: var(--bad); }
.chart .ref.entry { stroke: var(--ink-3); }
.chart .cross { stroke: var(--ink-3); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-tip {
  position: absolute; top: 4px; pointer-events: none; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r);
  padding: 5px 8px; font-size: 12px; line-height: 1.4; white-space: nowrap; box-shadow: var(--shadow); z-index: 2;
}
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink-2); margin-top: 4px; }
.legend i { display: inline-block; width: 16px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 6px; }
.legend i.close { border-color: var(--series-1); }
.legend i.st { border-color: var(--series-2); border-top-style: dashed; }
.legend i.stop { border-color: var(--bad); border-top-style: dotted; }
.legend i.entry { border-color: var(--ink-3); border-top-style: dotted; }

/* diario */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; }
.filters label { font-size: 13px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 8px; }
select { min-height: 40px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 0 10px; }

/* piede */
.foot { border-top: 1px solid var(--line); }
.foot-in { max-width: 1240px; margin: 0 auto; padding: 18px 24px 28px; color: var(--ink-3); font-size: 13px; display: grid; gap: 4px; }
.foot-in strong { color: var(--ink-2); font-weight: 600; }
.noscript { padding: 16px; text-align: center; }

/* accesso */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 28px 24px; display: grid; gap: 10px; justify-items: start; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 24px; }
.auth-card form { width: 100%; display: grid; gap: 8px; margin: 8px 0 6px; }
.auth-card label { font-size: 13px; color: var(--ink-2); }
.auth-card input { min-height: 44px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); padding: 0 12px; }
.primary { min-height: 44px; border: 0; border-radius: var(--r); background: var(--gold); color: var(--bg); font-weight: 600; margin-top: 6px; }
.auth-err { color: var(--bad); font-size: 14px; }

@media (max-width: 900px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .col-opt { display: none; }
}
@media (max-width: 640px) {
  html { scroll-padding-top: 112px; }
  .top-in { padding: 8px 16px; gap: 6px 12px; }
  .stamp { flex: 1 1 0; margin-left: 0; }
  .word { font-size: 17px; }
  .banners { padding: 0 16px; }
  .page { padding: 14px 16px 32px; }
  .block { margin-top: 32px; }
  .hero-main, .hero-now { padding: 18px; }
  .hero-value { font-size: 36px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards { grid-template-columns: minmax(0, 1fr); }
  .foot-in { padding: 16px; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack thead { display: none; }
  table.stack tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack td { display: flex; justify-content: space-between; gap: 16px; padding: 3px 0; border: 0; text-align: right; }
  table.stack td::before { content: attr(data-label); color: var(--ink-3); font-size: 12px; text-align: left; flex: none; }
  th, td { padding-left: 10px; padding-right: 10px; }
}
@media (prefers-reduced-motion: no-preference) {
  .page { transition: opacity .2s; }
}
