:root {
  --sfondo: #f3f5f8; --carta: #ffffff; --testo: #17202b; --tenue: #5d6876; --bordo: #d8dee6;
  --accento: #0b5cad; --accento-chiaro: #e3eefa; --accento-testo: #ffffff; --errore: #b3261e;
  --ok: #1d7a46; --ok-chiaro: #e3f4ea; --attesa: #8a5a00; --attesa-chiaro: #fff3dc; --raggio: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --sfondo: #0f1318; --carta: #181e26; --testo: #e7ebf0; --tenue: #9aa6b4; --bordo: #2b333d;
    --accento: #5ea2ff; --accento-chiaro: #1a2c44; --accento-testo: #08111e; --errore: #ff8a80;
    --ok: #5fd08f; --ok-chiaro: #14301f; --attesa: #f0b44c; --attesa-chiaro: #33270f; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --sfondo: #0f1318; --carta: #181e26; --testo: #e7ebf0; --tenue: #9aa6b4; --bordo: #2b333d;
  --accento: #5ea2ff; --accento-chiaro: #1a2c44; --accento-testo: #08111e; --errore: #ff8a80;
  --ok: #5fd08f; --ok-chiaro: #14301f; --attesa: #f0b44c; --attesa-chiaro: #33270f; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--sfondo); color: var(--testo); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
[hidden] { display: none !important; }
a { color: var(--accento); }
h1 { font-size: 1.4rem; margin: 0 0 .4rem; }
h2 { font-size: 1.05rem; margin: 1.4rem 0 .6rem; display: flex; align-items: center; gap: .5rem; }
.tenue { color: var(--tenue); }
.piccolo { font-size: .85rem; }
.errore { color: var(--errore); min-height: 1.2em; }

input, button, textarea { font: inherit; }
input {
  width: 100%; padding: .65rem .8rem; border: 1px solid var(--bordo); border-radius: 10px;
  background: var(--carta); color: var(--testo);
}
label { display: block; margin: .7rem 0; }
label input { margin-top: .3rem; }
button {
  padding: .6rem 1.1rem; border: 0; border-radius: 10px; background: var(--accento); color: var(--accento-testo);
  cursor: pointer; font-weight: 600;
}
button.secondario { background: transparent; color: var(--testo); border: 1px solid var(--bordo); }
button.grande { width: 100%; padding: .85rem; font-size: 1.05rem; margin-top: 1.4rem; }
button:disabled { opacity: .55; cursor: default; }
button:focus-visible, input:focus-visible, .chip:focus-visible { outline: 2px solid var(--accento); outline-offset: 2px; }

.marchio { display: flex; align-items: center; gap: .5rem; font-weight: 800; font-size: 1.25rem; color: var(--accento); }
.logo {
  width: 28px; height: 28px; border-radius: 7px; background: var(--accento); position: relative; flex: none;
}
.logo::before { content: ""; position: absolute; left: 6px; top: 6px; width: 11px; height: 11px; border: 3px solid var(--accento-testo); border-radius: 50%; }
.logo::after { content: ""; position: absolute; left: 18px; top: 18px; width: 7px; height: 3px; background: var(--accento-testo); transform: rotate(45deg); border-radius: 2px; }

.centrato { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.scheda { background: var(--carta); border: 1px solid var(--bordo); border-radius: var(--raggio); padding: 1.4rem; }
.stretta { width: 100%; max-width: 400px; }
.stretta button { width: 100%; margin-top: .6rem; }

.barra {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: .8rem;
  padding: .6rem 16px; background: var(--carta); border-bottom: 1px solid var(--bordo);
}
.barra #chi { margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pagina { max-width: 860px; margin: 0 auto; padding: 20px 16px 32px; display: grid; gap: 1.6rem; }
.piede { text-align: center; padding: 0 16px 24px; }

.passo {
  display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: var(--accento); color: var(--accento-testo); font-size: .85rem;
}
.cerca-box { position: relative; }
.suggerimenti {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 4; max-height: 320px; overflow-y: auto;
  background: var(--carta); border: 1px solid var(--bordo); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
}
.suggerimenti button {
  display: block; width: 100%; text-align: left; background: transparent; color: var(--testo); font-weight: 400;
  border-radius: 0; padding: .55rem .8rem; border-bottom: 1px solid var(--bordo);
}
.suggerimenti button:hover, .suggerimenti button.attivo { background: var(--accento-chiaro); }
.suggerimenti .sotto { display: block; font-size: .8rem; color: var(--tenue); }
.scelta { margin: .6rem 0 0; font-weight: 600; }
.scelta button { margin-left: .4rem; padding: .1rem .5rem; font-size: .8rem; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .6rem 0; }
.chip {
  display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .7rem; border-radius: 999px;
  border: 1px solid var(--accento); background: var(--accento-chiaro); color: var(--testo); font-size: .9rem; font-weight: 500;
}
.chip.spenta { background: transparent; border-color: var(--bordo); color: var(--tenue); text-decoration: line-through; }
.chip .x { font-weight: 700; opacity: .7; }
.aggiungi { display: flex; gap: .5rem; }
.aggiungi button { flex: none; }

.intestazione { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .6rem; }
.piccolo-btn { padding: .35rem .8rem; font-size: .85rem; }
.elenco { display: grid; gap: .8rem; }
.richiesta { background: var(--carta); border: 1px solid var(--bordo); border-radius: var(--raggio); padding: 1rem 1.1rem; }
.richiesta .testa { display: flex; justify-content: space-between; gap: .8rem; align-items: flex-start; flex-wrap: wrap; }
.richiesta h3 { margin: 0; font-size: 1rem; }
.stato { padding: .15rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap;
  background: var(--accento-chiaro); color: var(--accento); }
.stato.ok { background: var(--ok-chiaro); color: var(--ok); }
.stato.attesa { background: var(--attesa-chiaro); color: var(--attesa); }
.stato.errore { background: transparent; border: 1px solid var(--errore); color: var(--errore); }
.stato.chiusa { background: transparent; border: 1px solid var(--bordo); color: var(--tenue); }
.numeri { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; margin: .8rem 0; }
.numero { background: var(--sfondo); border-radius: 10px; padding: .55rem .75rem; }
.numero b { display: block; font-size: 1.25rem; }
.numero.prezzo b { color: var(--accento); }
.azioni { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.attesa-box { background: var(--attesa-chiaro); border-radius: 10px; padding: .7rem .9rem; margin-top: .6rem; white-space: pre-line; }
.rotella { display: inline-block; width: .9rem; height: .9rem; border: 2px solid var(--bordo); border-top-color: var(--accento);
  border-radius: 50%; animation: gira 1s linear infinite; vertical-align: -2px; margin-right: .4rem; }
@keyframes gira { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .rotella { animation: none; } }
.vuoto { text-align: center; padding: 1.4rem; }

dialog { border: 1px solid var(--bordo); border-radius: var(--raggio); background: var(--carta); color: var(--testo); max-width: 440px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.riga { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }

.avviso {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 9; background: var(--testo); color: var(--sfondo);
  padding: .6rem 1rem; border-radius: 10px; max-width: calc(100% - 32px);
}
.avviso.errore { background: var(--errore); color: #fff; }

@media (max-width: 560px) {
  .scheda { padding: 1.1rem; }
  .aggiungi { flex-direction: column; }
}
