/* Price Hunter — inchiostro blu, cartellino giallo, IBM Plex Sans */

@font-face { font-family: "Plex"; src: url("fonts/plex-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex"; src: url("fonts/plex-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex"; src: url("fonts/plex-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Plex"; src: url("fonts/plex-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --ink: #1F2A44;          /* testo e azioni principali */
  --ink-2: #4A5672;        /* testo secondario */
  --muted: #7A849A;
  --bg: #F3F5F7;
  --surface: #FFFFFF;
  --sunken: #EDF0F4;
  --line: #E1E5EB;
  --line-strong: #CDD3DD;
  --tag: #F5C518;          /* cartellino: solo obiettivi raggiunti */
  --tag-soft: #FFF6D1;
  --tag-ink: #5A4500;
  --bad: #C2410C;
  --bad-soft: #FDEDE4;
  --warn: #9A6200;
  --accent: var(--ink);
  --good: #B38A00;         /* punti sotto obiettivo nel grafico */
  --focus: #3D6BE0;
  --radius-s: 6px;
  --radius: 10px;
  --shadow: 0 1px 0 rgba(31, 42, 68, .04), 0 1px 3px rgba(31, 42, 68, .06);
  --side: 232px;
  font-family: "Plex", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #E4E8F0; --ink-2: #AEB7C8; --muted: #8590A5;
    --bg: #11151C; --surface: #181D26; --sunken: #141922; --line: #262D3A; --line-strong: #353E4E;
    --tag-soft: #2B2410; --tag-ink: #F5D66A; --bad: #FF8A5C; --bad-soft: #3A1F14; --warn: #F2B84B;
    --accent: #9DB4F0; --good: #F5C518; --focus: #7C9CF0;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
body { margin: 0; }
a { color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; line-height: 1.2; }
h2 { font-size: 1rem; }
p { margin: 0; }
.num, .price { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.ic { width: 18px; height: 18px; flex: none; }
.ic-sm { width: 14px; height: 14px; }

/* ---------- struttura ---------- */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh;
  background: linear-gradient(to right, var(--surface) calc(var(--side) - 1px), var(--line) calc(var(--side) - 1px), var(--line) var(--side), transparent var(--side)); }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 1.5rem;
  padding: 1.25rem 1rem; background: var(--surface); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.05rem; text-decoration: none; padding: 0 .5rem; }
.brand-tag {
  width: 22px; height: 16px; background: var(--tag); position: relative;
  clip-path: polygon(0 0, 72% 0, 100% 50%, 72% 100%, 0 100%);
  border-radius: 3px 0 0 3px;
}
.brand-tag::after { content: ""; position: absolute; left: 5px; top: 5.5px; width: 5px; height: 5px; border-radius: 50%; background: var(--surface); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: .65rem; padding: .55rem .6rem; border-radius: var(--radius-s);
  color: var(--ink-2); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--sunken); color: var(--ink); }
.nav a.on { background: var(--sunken); color: var(--ink); box-shadow: inset 3px 0 0 var(--ink); }

.worker { margin-top: auto; padding: .85rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--sunken); }
.worker-line { display: flex; align-items: center; gap: .5rem; font-weight: 500; font-size: .9rem; }
.worker-detail { color: var(--muted); font-size: .8rem; margin-top: .15rem; overflow-wrap: anywhere; }
.worker-detail:empty { display: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); flex: none; }
.worker.busy .dot { background: var(--tag); box-shadow: 0 0 0 0 rgba(245, 197, 24, .6); animation: pulse 1.6s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(245, 197, 24, 0); } 100% { box-shadow: 0 0 0 0 rgba(245, 197, 24, 0); } }
.worker form { margin-top: .6rem; }
.stop { width: 100%; justify-content: center; }

.main { padding: 2rem 2.5rem 4rem; max-width: 1240px; width: 100%; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1.5rem; margin-bottom: 1.75rem; flex-wrap: wrap; }
.lede { color: var(--ink-2); margin-top: .4rem; max-width: 70ch; overflow-wrap: anywhere; }
.lede-hit { color: var(--tag-ink); background: var(--tag-soft); padding: 0 .3rem; border-radius: 4px; font-weight: 600; }
.back { display: inline-flex; align-items: center; gap: .3rem; color: var(--muted); text-decoration: none; font-size: .9rem; margin-bottom: .6rem; }
.back::before { content: "‹"; font-size: 1.2rem; line-height: 1; }
.back:hover { color: var(--ink); }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }

/* ---------- pulsanti ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .45rem; font: inherit; font-weight: 500; font-size: .92rem;
  padding: .55rem .9rem; border-radius: var(--radius-s); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { border-color: var(--ink-2); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.btn-primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--sunken); border-color: transparent; color: var(--ink); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--sunken); color: var(--ink); border-color: transparent; }
.btn-danger { color: var(--bad); }
.btn-danger:hover { border-color: var(--bad); background: var(--bad-soft); }
.btn-icon { padding: .45rem; }
.btn-sm { padding: .35rem .65rem; font-size: .85rem; }
.stop { color: var(--bad); border: 1px solid var(--line-strong); background: var(--surface); }

/* ---------- elementi comuni ---------- */
.chip { display: inline-block; font-size: .75rem; font-weight: 500; padding: .05rem .45rem; border-radius: 4px; background: var(--sunken); color: var(--ink-2); border: 1px solid var(--line); }
.chip-bad { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.4rem; margin-bottom: 1.25rem; box-shadow: var(--shadow); }
.panel-flush { padding: 0; }
.panel-flush .panel-head { padding: 1.1rem 1.4rem .4rem; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: .8rem; }
.panel-head h2 { display: flex; align-items: center; gap: .5rem; }
.panel-note { color: var(--muted); font-size: .85rem; }
.panel-empty { padding: 1rem 1.4rem 1.4rem; color: var(--muted); }
.panel-empty a, .empty a, .lede a { color: var(--ink); }

/* prezzo e cartellino */
.price { font-weight: 600; font-size: 1.15rem; }
.price-sm { font-weight: 500; font-size: 1rem; color: var(--ink-2); }
.price-xl { font-size: 2.6rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.pricetag {
  position: relative; display: inline-flex; align-items: center; gap: .45rem;
  background: var(--tag); color: #2A2100; font-weight: 700; font-variant-numeric: tabular-nums;
  padding: .2rem .8rem .2rem .55rem; border-radius: 4px 0 0 4px;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%);
  padding-right: 1.1rem; font-size: 1.1rem;
}
.pricetag-hole { width: 6px; height: 6px; border-radius: 50%; background: var(--surface); flex: none; }

/* barra "mirino" */
.track { position: relative; height: 8px; border-radius: 4px; background: var(--sunken); border: 1px solid var(--line); min-width: 120px; }
.track-zone { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px 0 0 4px; background: var(--tag-soft); }
.track-target { position: absolute; top: -5px; bottom: -5px; width: 2px; margin-left: -1px; background: var(--ink); border-radius: 1px; }
.track-best { position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--surface); border: 2.5px solid var(--ink-2); }
.track.hit .track-best { background: var(--tag); border-color: var(--ink); }
.track-big { height: 12px; border-radius: 6px; }
.track-big .track-target { top: -7px; bottom: -7px; width: 3px; }
.track-big .track-best { width: 18px; height: 18px; margin: -9px 0 0 -9px; border-width: 3px; }
.gap { font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.gap-hit { color: var(--tag-ink); font-weight: 600; }

/* ---------- elenco prodotti ---------- */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list-head, .row { display: grid; grid-template-columns: minmax(220px, 2.2fr) 150px 170px 110px minmax(170px, 1.3fr); gap: 1.25rem; align-items: center; padding: .9rem 1.4rem; }
.list-head { padding-block: .6rem; font-size: .8rem; color: var(--muted); border-bottom: 1px solid var(--line); background: var(--sunken); }
.list-head .num { text-align: right; }
.row { text-decoration: none; border-bottom: 1px solid var(--line); transition: background .12s; }
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--sunken); }
.row.is-off { opacity: .55; }
.row-name { display: flex; align-items: center; gap: .85rem; min-width: 0; }
.row-name-text { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.thumb { width: 48px; height: 48px; flex: none; border-radius: 8px; object-fit: contain; background: #fff; border: 1px solid var(--line); padding: 3px; }
.thumb-empty { background: var(--sunken); padding: 0; position: relative; }
.thumb-empty::after { content: ""; position: absolute; inset: 15px 13px; background: var(--line-strong); clip-path: polygon(0 0, 70% 0, 100% 50%, 70% 100%, 0 100%); border-radius: 2px 0 0 2px; }
.best-price { font-variant-numeric: tabular-nums; }
.name { font-weight: 600; font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { color: var(--muted); font-size: .82rem; display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.row-price { display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; }
.row-price .meta { justify-content: flex-end; text-align: right; }
.row-target { text-align: right; }
.row-gauge { display: flex; flex-direction: column; gap: .45rem; }
.spark { display: block; overflow: visible; }
.spark path { fill: none; stroke: var(--ink-2); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { fill: var(--ink); }
.spark.hit circle { fill: var(--tag); stroke: var(--ink); stroke-width: 1.2; }
.spark-empty { color: var(--muted); font-size: .8rem; }

.empty { text-align: left; max-width: 620px; padding: 2.5rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.empty h2 { font-size: 1.3rem; margin: 1rem 0 .5rem; }
.empty p { color: var(--ink-2); margin-bottom: .75rem; }
.empty .btn { margin-top: .5rem; }
.empty-tag { width: 54px; height: 38px; background: var(--tag); clip-path: polygon(0 0, 72% 0, 100% 50%, 72% 100%, 0 100%); border-radius: 6px 0 0 6px; position: relative; }
.empty-tag::after { content: ""; position: absolute; left: 11px; top: 14px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); }

/* ---------- pagina prodotto ---------- */
.hero { display: grid; grid-template-columns: minmax(240px, 1fr) 2fr; gap: 2.5rem; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.6rem 1.8rem; margin-bottom: 1.25rem; box-shadow: var(--shadow); }
.hero.has-image { grid-template-columns: 168px minmax(220px, 1fr) 2fr; }
.hero-image { width: 168px; height: 168px; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; cursor: zoom-in; display: grid; place-items: center; }
.hero-image:hover { border-color: var(--ink-2); }
.hero-image img { max-width: 100%; max-height: 100%; object-fit: contain; }
.dd-sub { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; }
.lightbox { border: 0; padding: 0; background: #fff; border-radius: var(--radius); max-width: min(92vw, 1000px); max-height: 90vh; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.lightbox::backdrop { background: rgba(17, 21, 28, .72); }
.lightbox img { display: block; max-width: min(92vw, 1000px); max-height: 90vh; object-fit: contain; padding: 1.5rem; }
.lightbox-close { position: absolute; top: .6rem; right: .6rem; background: rgba(255,255,255,.9); color: #1F2A44; }
.import-thumb { float: right; width: 72px; height: 72px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 4px; margin-left: 1rem; }
.hero.is-hit { border-color: var(--tag); box-shadow: inset 0 0 0 1px var(--tag), var(--shadow); }
.hero-price { display: flex; flex-direction: column; align-items: flex-start; gap: .45rem; }
.hero-price .pricetag { font-size: 2.1rem; padding: .3rem 1.8rem .3rem .8rem; clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 50%, calc(100% - 18px) 100%, 0 100%); }
.hero-price .pricetag-hole { width: 10px; height: 10px; }
.hero-label { color: var(--muted); font-size: .85rem; }
.hero-shop { display: inline-flex; align-items: center; gap: .3rem; color: var(--ink-2); font-weight: 500; text-decoration: none; }
.hero-shop:hover { color: var(--ink); text-decoration: underline; }
.hero-gauge { display: flex; flex-direction: column; gap: .8rem; }
.hero-scale { font-size: .92rem; color: var(--ink-2); }
.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin: .4rem 0 0; padding-top: 1rem; border-top: 1px solid var(--line); }
.facts dt { color: var(--muted); font-size: .8rem; }
.facts dd { margin: .15rem 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }

canvas { width: 100%; height: 240px; display: block; }

table { width: 100%; border-collapse: collapse; }
.table-wrap { overflow-x: auto; }
th { text-align: left; font-size: .8rem; font-weight: 500; color: var(--muted); padding: .55rem .8rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th:first-child, td:first-child { padding-left: 1.4rem; }
th:last-child, td:last-child { padding-right: 1.4rem; }
th.num, td.num { text-align: right; white-space: nowrap; }
.offers tr.is-hit td { background: var(--tag-soft); }
.offers tr.is-hit td:first-child { box-shadow: inset 4px 0 0 var(--tag); }
.offers tr.is-off td { opacity: .55; }
.shop { display: flex; gap: .75rem; align-items: flex-start; min-width: 260px; }
.avatar { width: 30px; height: 30px; border-radius: 7px; flex: none; display: grid; place-items: center; font-weight: 700; font-size: .85rem;
  color: hsl(var(--h) 45% 28%); background: hsl(var(--h) 55% 90%); }
@media (prefers-color-scheme: dark) { .avatar { color: hsl(var(--h) 70% 82%); background: hsl(var(--h) 30% 22%); } }
.shop-text { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.shop-name { font-weight: 600; text-decoration: none; }
.shop-name:hover { text-decoration: underline; }
.shop-title { color: var(--ink-2); font-size: .85rem; max-width: 46ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; color: var(--muted); }
.note-promo { color: var(--tag-ink); font-weight: 600; }
.note-warn { color: var(--warn); }
.total { font-size: 1.05rem; }
.total-hit { color: var(--tag-ink); }
.was { display: block; font-size: .8rem; color: var(--muted); }
.estimate { color: var(--warn); border-bottom: 1px dotted currentColor; cursor: help; }
.when { white-space: nowrap; font-size: .85rem; color: var(--ink-2); }
.via { display: block; color: var(--muted); font-size: .78rem; }
.row-actions { white-space: nowrap; }
.row-actions form { display: flex; gap: .1rem; justify-content: flex-end; }
.runs td { font-size: .9rem; }
.status { font-size: .8rem; font-weight: 500; padding: .1rem .5rem; border-radius: 4px; }
.status-ok { background: var(--sunken); color: var(--ink-2); }
.status-bad { background: var(--bad-soft); color: var(--bad); cursor: help; }
.status-run { background: var(--tag-soft); color: var(--tag-ink); }
.skipped { color: var(--bad); }
.engines { display: flex; gap: .75rem; align-items: baseline; flex-wrap: wrap; padding: .9rem 1.4rem 1.1rem; border-top: 1px solid var(--line); font-size: .85rem; }
.engines-label { color: var(--muted); }
.engine-list { display: flex; flex-wrap: wrap; gap: .4rem; }
.engine { padding: .1rem .5rem; border-radius: 4px; background: var(--sunken); color: var(--ink-2); }
.engine b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.engine-down { background: var(--bad-soft); color: var(--bad); }
.engine-down b { color: var(--bad); font-weight: 500; }

/* intestazioni ordinabili */
.sort { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; display: inline-flex; align-items: center; gap: .3rem; }
.sort:hover { color: var(--ink); }
.sort::after { content: ""; width: 0; height: 0; border: 4px solid transparent; border-top-color: currentColor; margin-top: 4px; opacity: .25; }
[aria-sort="ascending"] .sort, [aria-sort="descending"] .sort { color: var(--ink); font-weight: 600; }
[aria-sort="ascending"] .sort::after { border-top-color: transparent; border-bottom-color: currentColor; margin: 0 0 4px; opacity: 1; }
[aria-sort="descending"] .sort::after { opacity: 1; }
th.num .sort, .list-head .num .sort { flex-direction: row; }

/* ---------- moduli ---------- */
.form-wrap { max-width: 760px; }
.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1.15rem; }
.field label { font-weight: 500; font-size: .92rem; }
.field small { color: var(--muted); font-size: .82rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
input, textarea {
  font: inherit; padding: .55rem .7rem; border: 1px solid var(--line-strong); border-radius: var(--radius-s);
  background: var(--surface); color: var(--ink); width: 100%;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, textarea:focus { outline: 0; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent); }
.field-num input { max-width: 180px; font-variant-numeric: tabular-nums; }
.input-affix { display: flex; align-items: stretch; max-width: 220px; }
.input-affix input { border-radius: var(--radius-s) 0 0 var(--radius-s); font-variant-numeric: tabular-nums; font-weight: 600; }
.input-affix span { display: grid; place-items: center; padding: 0 .75rem; border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 var(--radius-s) var(--radius-s) 0; background: var(--sunken); color: var(--ink-2); }
.hints { display: flex; gap: .35rem; flex-wrap: wrap; }
.hints:empty { display: none; }
.hints .mini { font: inherit; font-size: .8rem; padding: .15rem .5rem; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); color: var(--ink-2); cursor: pointer; font-variant-numeric: tabular-nums; }
.hints .mini:hover { border-color: var(--ink); color: var(--ink); }
.switches { display: flex; flex-direction: column; gap: .6rem; margin: .4rem 0 1.2rem; }
.switch { display: inline-flex; align-items: center; gap: .65rem; cursor: pointer; font-weight: 500; font-size: .92rem; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui { width: 36px; height: 20px; border-radius: 10px; background: var(--line-strong); position: relative; flex: none; transition: background .15s; }
.switch-ui::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch input:checked + .switch-ui { background: var(--ink); }
.switch input:checked + .switch-ui::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--focus); outline-offset: 2px; }
.form-actions { display: flex; gap: .5rem; padding-top: 1.1rem; border-top: 1px solid var(--line); }
.import { background: var(--sunken); box-shadow: none; }
.import .panel-head { margin-bottom: .2rem; }
.import .panel-note { margin-bottom: .8rem; }
.import-row { display: flex; gap: .5rem; }
.test-result { font-size: .88rem; margin-top: .7rem; }
.test-result:empty { display: none; }
.test-result.ok { color: var(--ink); }
.test-result.ok::first-line { font-weight: 500; }
.test-result.ko { color: var(--bad); }

.settings { max-width: 1040px; }
.setting-group { display: grid; grid-template-columns: 280px 1fr; gap: 2rem; padding: 1.75rem 0; border-top: 1px solid var(--line); }
.setting-group:first-child { border-top: 0; padding-top: 0; }
.setting-intro h2 { font-size: 1.05rem; margin-bottom: .35rem; }
.setting-intro p { color: var(--ink-2); font-size: .9rem; }
.test-buttons { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .9rem; }
.setting-fields { margin: 0; }
.setting-fields .field:last-child { margin-bottom: 0; }
.field-switch { gap: .25rem; }
.field-switch small { padding-left: calc(36px + .65rem); }
.savebar { position: sticky; bottom: 0; padding: .9rem 0; margin-top: .5rem; background: var(--bg); border-top: 1px solid var(--line); display: flex; justify-content: flex-end; z-index: 2; }

/* ---------- log ---------- */
.log { background: #141922; color: #CDD5E3; padding: 1.1rem 1.25rem; border-radius: var(--radius); font: 13px/1.6 ui-monospace, "SF Mono", Menlo, Consolas, monospace; height: calc(100vh - 220px); min-height: 360px; overflow: auto; white-space: pre-wrap; word-break: break-word; margin: 0; border: 1px solid var(--line); }

/* ---------- notifiche ---------- */
.toasts { position: fixed; right: 1.5rem; bottom: 1.5rem; display: flex; flex-direction: column; gap: .5rem; z-index: 20; }
.toast { background: var(--ink); color: var(--surface); padding: .7rem 1rem; border-radius: var(--radius-s); box-shadow: 0 6px 20px rgba(0,0,0,.18); max-width: 380px; font-size: .92rem; animation: toast-in .18s ease-out; }
.toast.error { background: var(--bad); color: #fff; }
.toast.hide { opacity: 0; transform: translateY(6px); transition: opacity .25s, transform .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- schermi stretti ---------- */
@media (max-width: 1100px) {
  .list-head { display: none; }
  .row { grid-template-columns: 1fr auto; grid-template-areas: "name price" "gauge gauge"; gap: .6rem 1rem; }
  .row-name { grid-area: name; } .row-price { grid-area: price; } .row-gauge { grid-area: gauge; }
  .row-spark, .row-target { display: none; }
  .hero, .hero.has-image { grid-template-columns: 1fr; gap: 1.5rem; }
  .hero.has-image { grid-template-columns: 120px 1fr; }
  .hero.has-image .hero-gauge { grid-column: 1 / -1; }
  .hero-image { width: 120px; height: 120px; }
  .setting-group { grid-template-columns: 1fr; gap: 1rem; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); background: none; }
  .side { position: sticky; top: 0; z-index: 10; height: auto; flex-direction: row; align-items: center; gap: .75rem; padding: .6rem .9rem; border-right: 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
  .brand span:last-child { display: none; }
  .nav { flex-direction: row; }
  .nav a { padding: .45rem .55rem; font-size: .88rem; }
  .nav a.on { box-shadow: inset 0 -2px 0 var(--ink); }
  .nav a .ic { display: none; }
  .worker { margin: 0 0 0 auto; padding: .3rem .5rem; display: flex; align-items: center; gap: .5rem; background: transparent; border: 0; }
  .worker-detail { display: none; }
  .worker form { margin: 0; } .stop { width: auto; }
  .main { padding: 1.25rem 1rem 3rem; }
  h1 { font-size: 1.45rem; }
  .field-row { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr 1fr; }
  .price-xl { font-size: 2.1rem; }
  .hero { padding: 1.2rem; }
  .hero-price .pricetag { font-size: 1.7rem; }
  .import-row { flex-direction: column; }
  .toasts { left: 1rem; right: 1rem; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- voli ---------- */
select { font: inherit; padding: .55rem .7rem; border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); width: 100%; }
.field-num select { max-width: 260px; }
.iata { text-transform: uppercase; font-weight: 600; letter-spacing: .04em; max-width: 160px; }
.field[hidden] { display: none; }
.more { margin: .4rem 0 1rem; border-top: 1px solid var(--line); padding-top: .9rem; }
.more summary { cursor: pointer; font-weight: 500; color: var(--ink-2); margin-bottom: .9rem; }
.thumb-route { display: grid; place-items: center; background: var(--sunken); color: var(--ink-2); padding: 0; }
.thumb-route .ic { width: 22px; height: 22px; transform: rotate(45deg); }
.name-sub, .h1-sub { font-weight: 400; color: var(--muted); }
.h1-sub { font-size: 1.1rem; }
.flight-best { display: flex; gap: .75rem; align-items: center; }
.flight-best > div { display: flex; flex-direction: column; gap: .1rem; }
.flight-best .muted { font-size: .9rem; }
.flights sup { color: var(--bad); font-size: .7rem; margin-left: 1px; }

/* ---------- accesso ---------- */
.auth-body { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: max(1.25rem, env(safe-area-inset-top)) 1rem max(1.25rem, env(safe-area-inset-bottom)); }
.auth { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 1.25rem; }
.auth-brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.1rem; justify-content: center; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1.75rem 1.5rem; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 1.4rem; margin-bottom: .5rem; }
.auth-lede { color: var(--ink-2); margin-bottom: 1.25rem; }
.auth-card .form { margin-top: 1rem; }
.auth-or { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .85rem; margin: 1.1rem 0 .2rem; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-below { display: flex; justify-content: center; }
.btn-block { width: 100%; justify-content: center; padding: .7rem 1rem; }
.otp { font-size: 1.35rem; letter-spacing: .25em; font-variant-numeric: tabular-nums; text-align: center; font-weight: 600; }
.choice { display: grid; gap: .75rem; }
.choice-item { display: flex; flex-direction: column; gap: .25rem; text-align: left; font: inherit; color: var(--ink); text-decoration: none; padding: 1rem 1.1rem; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); cursor: pointer; }
.choice-item span { color: var(--ink-2); font-size: .9rem; }
.choice-item:hover { border-color: var(--ink); }
.choice-item.is-disabled { opacity: .55; cursor: default; }
.steps { padding-left: 1.2rem; color: var(--ink-2); margin: 0 0 1rem; }
.steps li { margin-bottom: .3rem; }
.qr { display: grid; place-items: center; padding: .5rem; background: #fff; border-radius: var(--radius); border: 1px solid var(--line); width: max-content; margin: 0 auto 1rem; }
.qr img { display: block; width: 270px; max-width: 100%; height: auto; image-rendering: pixelated; }
.secret { text-align: center; overflow-wrap: anywhere; }
.secret code, .codes code { font: 600 .95rem/1.4 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .05em; }
.codes { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.codes li { background: var(--sunken); border-radius: var(--radius-s); padding: .45rem .6rem; text-align: center; }
.devices { list-style: none; padding: 0; margin: .9rem 0 0; display: flex; flex-direction: column; gap: .5rem; }
.devices li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .6rem .75rem; background: var(--sunken); border-radius: var(--radius-s); }
.devices li > span { display: flex; flex-direction: column; min-width: 0; }
.devices .muted { font-size: .82rem; }
.devices form { margin: 0; }
.small-note { font-size: .88rem; margin-top: .7rem; }
.side-user { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .2rem .25rem 0 .6rem; margin: 0; }
.side-user-name { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- telefono: app con barra in basso ---------- */
@media (max-width: 760px) {
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .side { position: fixed; top: auto; bottom: 0; left: 0; right: 0; z-index: 30; height: auto; flex-direction: row; align-items: stretch;
    padding: .3rem .4rem calc(.3rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); border-bottom: 0; gap: 0;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
  .brand, .side-user { display: none; }
  .nav { flex: 1; flex-direction: row; justify-content: space-around; }
  .nav a { flex: 1; flex-direction: column; gap: .15rem; font-size: .7rem; padding: .35rem .2rem; justify-content: center; text-align: center; border-radius: 10px; }
  .nav a .ic { display: block; width: 22px; height: 22px; }
  .nav a.on { box-shadow: none; background: var(--sunken); }
  .worker { position: fixed; left: .75rem; right: .75rem; bottom: calc(70px + env(safe-area-inset-bottom)); margin: 0; padding: .5rem .75rem; display: none;
    background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.12); align-items: center; gap: .6rem; }
  .worker.busy { display: flex; }
  .worker-detail { display: block; flex: 1; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .worker form { margin: 0; }
  .main { padding: max(1rem, env(safe-area-inset-top)) 1rem 1.5rem; }
  .page-head { margin-bottom: 1.1rem; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn-primary { flex: 1; justify-content: center; }
  .btn { min-height: 42px; }
  input, select, textarea { font-size: 16px; }          /* niente zoom automatico su iPhone */
  .toasts { bottom: calc(76px + env(safe-area-inset-bottom)); }

  /* tabelle → schede */
  .offers thead, .runs thead { display: none; }
  .offers, .offers tbody, .runs, .runs tbody { display: block; }
  .offers tr { display: grid; grid-template-columns: 1fr auto; gap: .2rem .75rem; padding: .85rem 1rem; border-bottom: 1px solid var(--line); }
  .offers td { display: block; padding: 0; border: 0; background: transparent !important; box-shadow: none !important; }
  .offers tr.is-hit { background: var(--tag-soft); box-shadow: inset 4px 0 0 var(--tag); }
  .offers td:first-child { grid-column: 1 / -1; padding: 0; }
  .offers td.num { text-align: left; font-size: .9rem; color: var(--ink-2); }
  .offers td.num:has(.total) { grid-column: 2; grid-row: 2 / span 3; text-align: right; align-self: center; }
  .offers td.when { font-size: .82rem; }
  .offers td.row-actions { grid-column: 1 / -1; }
  .offers td.row-actions form { justify-content: flex-start; }
  .shop { min-width: 0; }
  .shop-title { max-width: 100%; }
  .runs tr { display: grid; grid-template-columns: 1fr auto; gap: .1rem .75rem; padding: .7rem 1rem; border-bottom: 1px solid var(--line); }
  .runs td { padding: 0; border: 0; font-size: .85rem; }
  .runs td:first-child { font-weight: 500; }
  .runs td.num { text-align: left; color: var(--muted); }
  .runs td:last-child { grid-column: 2; grid-row: 1; }
  .sortbar { display: flex; }
  .offers td[data-label]::before, .runs td[data-label]::before { content: attr(data-label) " "; color: var(--muted); font-size: .78rem; }
  .runs td[data-label] { display: inline; margin-right: .6rem; }
  .runs tr { display: block; }
  .runs td:first-child { display: block; }
  .runs td:last-child { display: block; margin-top: .3rem; }
}
.sortbar { display: none; gap: .5rem; align-items: center; padding: .4rem 1rem .8rem; font-size: .85rem; color: var(--muted); }
.sortbar select { width: auto; padding: .35rem .5rem; font-size: 16px; }
.list .sortbar { border-bottom: 1px solid var(--line); padding-top: .8rem; }

.auth-errors { background: var(--bad-soft); color: var(--bad); border-radius: var(--radius-s); padding: .7rem .9rem; margin: .2rem 0 1rem; font-size: .92rem; }
.auth-errors p + p { margin-top: .3rem; }
.toast { display: flex; align-items: flex-start; gap: .75rem; }
.toast-close { margin-left: auto; background: none; border: 0; color: inherit; font: inherit; cursor: pointer; opacity: .8; padding: 0 .1rem; }
.totp-actions { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: center; margin-bottom: .8rem; }
@media (min-width: 761px) and (hover: hover) { .totp-actions .btn-primary { display: none; } }   /* sul computer serve il QR */
