/* Stili del cruscotto: ripresi così come sono dall'artifact originale (prima parte),
   più le aggiunte per le parti nuove della web app (in fondo). */

:root {
  --bg: #f2f4f5; --surface: #ffffff; --surface2: #eceff1;
  --ink: #12181d; --ink2: #4a5660; --muted: #66727c;
  --line: #d9dfe3; --line2: #e7ebee;
  --accent: #1f5a8a; --accent-ink: #ffffff;
  --s1: #2a78d6; --s2: #898781;
  --adj-bg: #e8e5fb; --adj-ink: #3b2f98;
  --flag-bg: #fff0b8; --flag-ink: #5e4400;
  --good: #006300; --bad: #b02a2a; --good-bg: #e2f3e2; --bad-bg: #fae4e4;
  --c2: #eb6834; --c3: #1baf7a; --c4: #eda100; --c5: #e87ba4; --c6: #4a3aa7;
  --hero1: #e3eefb; --hero2: #f4f9ff; --hero-line: #b7d3f6; --hero-ink2: #3d5a78; --hero-trk: #c9dcf3;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1316; --surface: #171c20; --surface2: #1f262b;
    --ink: #eef2f4; --ink2: #b4bec6; --muted: #8e9aa3;
    --line: #2a3238; --line2: #232a2f;
    --accent: #6fb0e8; --accent-ink: #0d1a24;
    --s1: #3987e5; --s2: #898781;
    --adj-bg: #2b2760; --adj-ink: #c6bfff;
    --flag-bg: #4a3d0a; --flag-ink: #ffe08a;
    --good: #52d052; --bad: #ff8d8d; --good-bg: #12301a; --bad-bg: #3a1a1a;
    --c2: #d95926; --c3: #199e70; --c4: #c98500; --c5: #d55181; --c6: #9085e9;
    --hero1: #14283d; --hero2: #101c2a; --hero-line: #26486b; --hero-ink2: #a9c4de; --hero-trk: #23384d;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1316; --surface: #171c20; --surface2: #1f262b;
  --ink: #eef2f4; --ink2: #b4bec6; --muted: #8e9aa3;
  --line: #2a3238; --line2: #232a2f;
  --accent: #6fb0e8; --accent-ink: #0d1a24;
  --s1: #3987e5; --s2: #898781;
  --adj-bg: #2b2760; --adj-ink: #c6bfff;
  --flag-bg: #4a3d0a; --flag-ink: #ffe08a;
  --good: #52d052; --bad: #ff8d8d; --good-bg: #12301a; --bad-bg: #3a1a1a;
  --c2: #d95926; --c3: #199e70; --c4: #c98500; --c5: #d55181; --c6: #9085e9;
  --hero1: #14283d; --hero2: #101c2a; --hero-line: #26486b; --hero-ink2: #a9c4de; --hero-trk: #23384d;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14px; line-height: 1.45; padding-inline: 16px; padding-block: 20px 56px; }
.wrap { max-width: 1180px; margin-inline: auto; display: grid; gap: 16px; }
h1 { font-size: 22px; line-height: 1.2; font-weight: 600; margin: 0; letter-spacing: -0.01em; text-wrap: balance; }
h2 { font-size: 15px; font-weight: 600; margin: 0; }
.eyebrow { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 8px 16px; }
.head .src { color: var(--muted); font-size: 12px; text-align: right; }

.bar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; }
.ctl { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ctl > .lab { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.seg { display: inline-flex; background: var(--surface2); border-radius: 8px; padding: 2px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 5px 10px; border-radius: 6px; color: var(--ink2); font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.seg button.na { text-decoration: underline dotted var(--muted); text-underline-offset: 3px; }
select, input[type="text"], input[type="number"] { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; min-width: 0; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px 12px; font-weight: 500; }
.btn:hover { background: var(--surface2); }
.btn.pri { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.banner { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 14px; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; }
.banner .lbl { font-weight: 600; }
.banner.err { border-color: var(--flag-ink); background: var(--flag-bg); color: var(--flag-ink); }
.banner.err .lbl { color: inherit; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: grid; gap: 4px; min-width: 0; }
.kpi .v { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.kpi .b { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.pill { display: inline-flex; gap: 4px; align-items: center; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 2px 8px; width: fit-content; font-variant-numeric: tabular-nums; }
.pill.g { background: var(--good-bg); color: var(--good); }
.pill.r { background: var(--bad-bg); color: var(--bad); }
.pill.z { background: var(--surface2); color: var(--muted); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; padding: 9px 14px; font-weight: 500; color: var(--ink2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: grid; gap: 12px; min-width: 0; }
.card .ch { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--ink2); font-size: 12px; align-items: center; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 5px; }
.sw.adj { background: var(--adj-bg); box-shadow: inset 0 0 0 1px var(--adj-ink); }
.sw.flag { background: var(--flag-bg); box-shadow: inset 0 0 0 1px var(--flag-ink); }

.tw { overflow-x: auto; border: 1px solid var(--line2); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; min-width: 640px; }
th { text-align: right; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 500; padding: 8px 10px; background: var(--surface2); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
td { padding: 7px 10px; border-top: 1px solid var(--line2); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; vertical-align: top; }
td:first-child { white-space: normal; min-width: 240px; }
tr.ln td { font-weight: 600; background: var(--surface); }
tr.sub td { font-weight: 600; background: var(--surface2); }
tr.total td { font-weight: 700; background: var(--surface2); border-top: 2px solid var(--ink2); }
tr.voce td:first-child { padding-left: 28px; }
tr.conto td { color: var(--ink2); font-size: 13px; }
tr.conto td:first-child { padding-left: 46px; }
tr.ln.dir td:first-child { padding-left: 10px; }
tr.conto.l1 td:first-child { padding-left: 30px; }
.caret { display: inline-block; width: 14px; color: var(--muted); }
tr.x { cursor: pointer; }
tr.x:hover td { background: var(--surface2); }
.sub1 { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
td.adj { background: var(--adj-bg); color: var(--adj-ink); font-weight: 500; }
td.flag { background: var(--flag-bg); color: var(--flag-ink); font-weight: 600; }
.dg { color: var(--good); } .db { color: var(--bad); } .dz { color: var(--muted); }
.pct { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 8px; }
.empty { text-align: center; padding: 36px 16px; color: var(--ink2); display: grid; gap: 6px; }
.empty b { font-size: 16px; color: var(--ink); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; }
.chart { position: relative; min-width: 0; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .grid { stroke: var(--line2); stroke-width: 1; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .zero { stroke: var(--ink2); stroke-width: 1; }
#tip { position: fixed; z-index: 20; pointer-events: none; background: var(--ink); color: var(--bg); padding: 7px 10px; border-radius: 8px; font-size: 12px; line-height: 1.5; max-width: 260px; box-shadow: 0 4px 16px rgba(0,0,0,.25); font-variant-numeric: tabular-nums; }
#tip b { font-weight: 600; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; font-variant-numeric: tabular-nums; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; text-align: right; font-weight: 500; }
.stag { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.stag label { display: grid; gap: 2px; font-size: 11px; color: var(--muted); }
.stag input { width: 100%; }
.field { display: grid; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
td select, td input { width: 100%; min-width: 120px; font-size: 13px; }
td.ed { padding: 4px 6px; }
.toast { position: fixed; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; z-index: 30; font-size: 13px; }
details summary { cursor: pointer; color: var(--ink2); font-weight: 500; }
/* Pagina Indicatori */
.ind { display: grid; gap: 14px; }
.sec { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin-top: 6px; }
.sec h2 { font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.sec span { color: var(--muted); font-size: 12px; }
.stage { display: grid; grid-template-columns: minmax(0,1fr) minmax(300px,1.25fr) minmax(0,1fr); grid-template-areas: "l hero r" "l2 hero r2"; gap: 12px; align-items: stretch; }
.stage > .hero { grid-area: hero; }
.stage > .a1 { grid-area: l; } .stage > .a2 { grid-area: l2; } .stage > .a3 { grid-area: r; } .stage > .a4 { grid-area: r2; }
@media (max-width: 900px) { .stage { grid-template-columns: 1fr 1fr; grid-template-areas: "hero hero" "l r" "l2 r2"; } }
@media (max-width: 560px) { .stage { grid-template-columns: 1fr; grid-template-areas: "hero" "l" "r" "l2" "r2"; } }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: grid; gap: 8px; align-content: start; min-width: 0; }
.tile .big { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile .cap { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.hero { background: linear-gradient(160deg, var(--hero1), var(--hero2)); border: 1px solid var(--hero-line); border-radius: 22px; padding: 20px 18px 18px; display: grid; gap: 10px; justify-items: center; align-content: center; text-align: center; min-width: 0; }
.hero .eyebrow { color: var(--hero-ink2); }
.ringbox { position: relative; width: min(290px, 100%); aspect-ratio: 1; }
.ringbox svg { width: 100%; height: 100%; display: block; }
.ringbox .mid { position: absolute; inset: 0; display: grid; place-content: center; gap: 2px; text-align: center; }
.ringbox .mid .big { font-size: 38px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.ringbox .mid .pc { font-size: 15px; font-weight: 600; color: var(--hero-ink2); font-variant-numeric: tabular-nums; }
.hero .eq { display: flex; gap: 6px 14px; flex-wrap: wrap; justify-content: center; font-size: 13px; color: var(--hero-ink2); font-variant-numeric: tabular-nums; }
.trk { fill: none; stroke: var(--surface2); }
.hero .trk { stroke: var(--hero-trk); }
.arc { fill: none; stroke-linecap: round; }
.tick { stroke: var(--ink); stroke-width: 2.5; stroke-linecap: round; }
.bul { position: relative; height: 14px; background: var(--surface2); border-radius: 7px; }
.bul i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 7px; background: var(--s1); }
.bul b { position: absolute; top: -4px; bottom: -4px; width: 3px; margin-left: -1.5px; border-radius: 2px; background: var(--ink); }
.div { position: relative; height: 18px; background: var(--surface2); border-radius: 9px; }
.div .z { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--ink2); }
.div i { position: absolute; top: 3px; bottom: 3px; }
.div b { position: absolute; top: -4px; bottom: -4px; width: 3px; margin-left: -1.5px; border-radius: 2px; background: var(--ink); }
.pos { background: var(--s1); } .neg { background: var(--bad); }
.stack { display: flex; height: 40px; border-radius: 10px; overflow: hidden; gap: 2px; background: var(--surface2); }
.stack > div { min-width: 2px; display: grid; place-content: center; color: #fff; font-size: 11px; font-weight: 600; overflow: hidden; white-space: nowrap; }
.stack .mgn { background: repeating-linear-gradient(135deg, var(--good-bg) 0 6px, transparent 6px 12px); color: var(--good); box-shadow: inset 0 0 0 1.5px var(--good); }
.stack .loss { background: repeating-linear-gradient(135deg, var(--bad-bg) 0 6px, transparent 6px 12px); color: var(--bad); box-shadow: inset 0 0 0 1.5px var(--bad); }
.leg { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink2); font-variant-numeric: tabular-nums; }
.leg i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.meter .rowv { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.meter .big { font-size: 22px; }
.fin { display: grid; grid-template-columns: repeat(12, minmax(0,1fr)); gap: 12px; }
.fin > .tile, .fin > .callout { grid-column: span 4; } .fin > .w8 { grid-column: span 8; } .fin > .w12 { grid-column: span 12; }
@media (max-width: 900px) { .fin > .tile, .fin > .w8 { grid-column: span 8; } }
@media (max-width: 900px) { .fin > .callout { grid-column: span 12 !important; } }
@media (max-width: 560px) { .fin > .tile, .fin > .w8, .fin > .w12 { grid-column: span 12; } }
.spark { width: 100%; max-width: 320px; height: auto; display: block; overflow: visible; }
.spark path { fill: none; stroke: var(--s1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { fill: var(--s1); stroke: var(--surface); stroke-width: 2; }
.spark .zl { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 3; }
.duo { display: grid; gap: 6px; }
.duo .r { display: grid; grid-template-columns: 78px 1fr auto; gap: 8px; align-items: center; font-size: 12px; color: var(--ink2); font-variant-numeric: tabular-nums; }
.duo .tr { height: 12px; border-radius: 6px; background: var(--surface2); overflow: hidden; }
.duo .tr i { display: block; height: 100%; border-radius: 6px; }
.callout { background: var(--flag-bg); color: var(--flag-ink); border-radius: 14px; padding: 14px 16px; display: grid; gap: 6px; border: 1px solid var(--flag-ink); }
.callout .big { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.callout .two { display: flex; flex-wrap: wrap; gap: 6px 24px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; background: var(--surface2); border-radius: 999px; padding: 2px 9px; color: var(--ink2); font-variant-numeric: tabular-nums; }
@media (max-width: 700px) { .bar { position: static; } }
@media (max-width: 560px) { .kpi .v { font-size: 21px; } h1 { font-size: 19px; } .head .src { text-align: left; } }
@media (prefers-reduced-motion: no-preference) { .seg button, .tabs button { transition: background .12s, color .12s; } }

/* ---------- Aggiunte della web app ---------- */
/* I comandi a segmenti e le schede sono link invece che pulsanti: stesso aspetto. */
.seg a { padding: 5px 10px; border-radius: 6px; color: var(--ink2); font-weight: 500; text-decoration: none; }
.seg a[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.seg a.na { text-decoration: underline dotted var(--muted); text-underline-offset: 3px; }
.tabs a { padding: 9px 14px; font-weight: 500; color: var(--ink2); border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; }
.tabs a[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
a.btn { color: inherit; text-decoration: none; display: inline-block; }
a.btn.pri { color: var(--accent-ink); }
.empty a, a.link { color: var(--accent); }
.head .src { display: grid; gap: 4px; justify-items: end; }
.head .chi { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; justify-content: flex-end; }
.head .chi a { color: var(--accent); }
@media (max-width: 560px) { .head .src, .head .chi { justify-items: start; justify-content: flex-start; } }
.banner.ok { border-color: var(--good); background: var(--good-bg); color: var(--good); }
.accesso { max-width: 380px; margin-top: 8vh; }
.accesso input { width: 100%; }
tr[hidden] { display: none; }
.grid2 > .card { align-content: start; }
