/* Archivo (variabile: peso e larghezza), licenza OFL, ospitato qui: nessuna chiamata a servizi esterni */
@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url("fonts/archivo-latin-wdth-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url("fonts/archivo-latin-ext-wdth-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bench: #2c6296;
  --bench-hi: #3a74ab;
  --bench-line: #4f85ba;
  --bg: #f1f4f8;
  --panel: #ffffff;
  --ink: #1c2733;
  --muted: #5a6877;
  --line: #dbe2ea;
  --field: #b3bfcc;
  --signal: #2f67a8;
  --signal-hi: #265589;
  --signal-ink: #ffffff;
  --link: #2a5f9e;
  --ok: #0e5a2e;
  --ok-bg: #d9f3e3;
  --err: #7a1f1f;
  --err-bg: #fbe0e0;
  --radius: 4px;
  font-family: "Archivo", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Colori degli stati: usati da badge, fascia della home e legenda */
.st-accettato         { --st: #4c6fbf; --st-bg: #e4eafa; --st-fg: #25396e; }
.st-in_diagnosi       { --st: #c58a00; --st-bg: #fdf0c9; --st-fg: #6b4a00; }
.st-attesa_preventivo { --st: #d9622b; --st-bg: #fde4d6; --st-fg: #7a2f0c; }
.st-attesa_ricambi    { --st: #8456c8; --st-bg: #eee4fa; --st-fg: #44267a; }
.st-in_lavorazione    { --st: #0f8b96; --st-bg: #d9f0f2; --st-fg: #0a4d54; }
.st-pronto            { --st: #1e9a52; --st-bg: #d9f3e3; --st-fg: #0e5a2e; }
.st-consegnato        { --st: #8a9593; --st-bg: #e6e9e8; --st-fg: #424d4b; }
.st-preventivo_approvato { --st: #5a9a2a; --st-bg: #e6f3d6; --st-fg: #34581a; }
.st-preventivo_rifiutato { --st: #c2557a; --st-bg: #fbe3ec; --st-fg: #7a2347; }
.st-collaudo             { --st: #2f80b7; --st-bg: #dbe9f7; --st-fg: #1d4570; }
.st-non_riparabile       { --st: #c43d3d; --st-bg: #fbe0e0; --st-fg: #7a1f1f; }
.st-rientro_garanzia     { --st: #8a6a45; --st-bg: #efe4d8; --st-fg: #4a3622; }
.st-riparazione_garanzia { --st: #b8449a; --st-bg: #f8e1f1; --st-fg: #6b1f58; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  font-stretch: 100%;
  font-variant-numeric: tabular-nums;
}
a { color: var(--link); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

h1, h2, h3 { margin: 0; font-stretch: 82%; letter-spacing: -.005em; line-height: 1.15; }
h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 700; margin-bottom: 14px; }
.muted { color: var(--muted); }
.sub { margin: 4px 0 0; color: var(--muted); }
.content > h1 { margin-bottom: 20px; }

/* Struttura: menu laterale + contenuto */
body.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: 0; align-self: start; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 18px;
  padding: 20px 14px 16px; background: linear-gradient(180deg, #2f6aa3 0%, #2a5d92 55%, #234f7e 100%); color: #e3eefa;
}
.rail a { color: inherit; text-decoration: none; }
.rail :focus-visible { outline-color: #fff; }
.brand {
  display: flex; align-items: center; gap: 10px; padding: 2px 6px;
  color: #fff; font-size: 20px; font-weight: 700; font-stretch: 80%; line-height: 1.15;
}
.brand svg { width: 34px; height: 34px; flex: none; }
.rail .btn { width: 100%; color: var(--signal-ink); }
.rail-search { position: relative; margin: 0; }
.rail-search svg { position: absolute; left: 11px; top: 10px; width: 18px; height: 18px; fill: none; stroke: #bcd3ea; stroke-width: 2; stroke-linecap: round; }
.rail-search input[type=search] {
  height: 38px; padding: 0 10px 0 36px;
  background: var(--bench-hi); border-color: var(--bench-line); color: #fff;
}
.rail-search input[type=search]::placeholder { color: #bcd3ea; }
.rail-search input[type=search]:hover { border-color: #7fa8d0; }
.rail-search input[type=search]:focus { border-color: #fff; outline: 2px solid rgba(255, 255, 255, .35); }
.menu { display: flex; flex-direction: column; gap: 2px; }
.menu a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px;
  border-left: 3px solid transparent; border-radius: var(--radius); font-weight: 550;
}
.menu a:hover { background: var(--bench-hi); }
.menu a[aria-current=page] { background: var(--bench-hi); border-left-color: #f4b400; color: #fff; }
.menu svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.who {
  margin-top: auto; padding: 12px 6px 0; border-top: 1px solid var(--bench-line);
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  font-size: 13.5px; color: #cfe0f2;
}
.who a { text-decoration: underline; text-underline-offset: 3px; }
.content { width: 100%; max-width: 1120px; padding: 28px 36px 56px; }

.head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 20px; margin-bottom: 20px; }
.row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 20px; margin-bottom: 20px; }
.head-main { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; min-width: 0; }
.title-block { min-width: 0; }
.head-actions, .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions { margin-top: 18px; }

/* Cartellino con il numero della riparazione */
.ticket {
  position: relative; flex: none; display: inline-block;
  padding: 11px 16px 11px 34px;
  background: var(--signal); color: var(--signal-ink);
  font-size: 26px; font-weight: 800; font-stretch: 75%; line-height: 1; letter-spacing: .02em;
  clip-path: polygon(16px 0, 100% 0, 100% 100%, 16px 100%, 0 50%);
}
.ticket::before {
  content: ""; position: absolute; left: 14px; top: 50%;
  width: 9px; height: 9px; margin-top: -4.5px; border-radius: 50%; background: var(--hole, var(--bg));
}

/* Avanzamento della riparazione in 5 fasi */
.track { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 0 0 22px; padding: 0; list-style: none; }
.track li { padding-top: 10px; border-top: 5px solid #cfd7d4; font-size: 13.5px; color: var(--muted); }
.track li.done { border-top-color: var(--bench); color: var(--ink); }
.track li.now { border-top-color: var(--signal); color: var(--ink); font-weight: 700; }
.track.void li { border-top-color: #e6bcbc; }

/* Pannelli */
.card { margin-bottom: 20px; padding: 20px 22px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2 { margin: 0; padding: 16px 16px 12px; }

/* Home: fascia con le riparazioni aperte per stato */
.pipeline { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 24px; }
.stage {
  display: block; padding: 12px 14px;
  background: var(--panel); border: 1px solid var(--line); border-top: 4px solid var(--st); border-radius: var(--radius);
  color: var(--ink); text-decoration: none;
}
.stage:hover { background: var(--st-bg); }
.stage b { display: block; font-size: 40px; font-weight: 800; font-stretch: 72%; line-height: 1; }
.stage span { display: block; margin-top: 6px; font-size: 13.5px; line-height: 1.3; color: var(--muted); }
.stage.zero b { color: #9aa7a4; }

/* Tabelle */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 16px; text-align: left; vertical-align: middle; }
thead th { background: #f6f8f7; border-bottom: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
tbody td { border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f7faf9; }
.right { text-align: right; }
.id { color: var(--ink); font-size: 17px; font-weight: 800; font-stretch: 78%; text-decoration: none; }
.id:hover { text-decoration: underline; }
td .line2 { display: block; font-size: 13px; color: var(--muted); }
.empty { margin: 0; padding: 22px 20px; color: var(--muted); }
.empty a { font-weight: 600; }

.badge {
  display: inline-flex; align-items: center; gap: 7px; padding: 3px 11px 3px 9px;
  border-radius: 999px; background: var(--st-bg, #e6e9e8); color: var(--st-fg, #424d4b);
  font-size: 13px; font-weight: 600; line-height: 1.4; white-space: nowrap;
}
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--st, #8a9593); }

/* Moduli */
form.stack label { display: block; margin: 0 0 5px; font-size: 14px; font-weight: 600; }
form.stack input:not([type=hidden]), form.stack select, form.stack textarea { margin-bottom: 14px; }
form.stack .actions { margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=search], select, textarea {
  width: 100%; height: 42px; padding: 8px 11px;
  border: 1px solid var(--field); border-radius: var(--radius);
  background: #fff; color: var(--ink); font: inherit; font-stretch: 100%;
}
textarea { height: auto; min-height: 96px; line-height: 1.45; resize: vertical; }
select {
  appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23566664' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
input:hover, select:hover, textarea:hover { border-color: #8a9996; }
input:focus, select:focus, textarea:focus { border-color: var(--link); outline: 3px solid rgba(10, 102, 112, .25); outline-offset: 0; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filters input[type=search] { flex: 1 1 260px; max-width: 380px; }
.filters select { flex: 0 1 240px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 18px;
  border: 1px solid var(--signal-hi); border-radius: var(--radius);
  background: var(--signal); color: var(--signal-ink);
  font: inherit; font-weight: 650; text-decoration: none; cursor: pointer;
  transition: background-color .12s, border-color .12s;
}
.btn:hover { background: var(--signal-hi); text-decoration: none; }
.btn:focus-visible { outline-color: var(--ink); }
.rail .btn:focus-visible { outline-color: #fff; }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.btn.sec { background: #fff; border-color: var(--field); color: var(--ink); }
.btn.sec:hover { background: #f1f4f3; border-color: #8a9996; }
.btn.danger { background: #fff; border-color: #c43d3d; color: #9b2c2c; }
.btn.danger:hover { background: var(--err-bg); }
.btn.wa { background: #128c4a; border-color: #0e7a40; color: #fff; }
.btn.wa:hover { background: #0e7a40; }

.flash { margin-bottom: 18px; padding: 11px 14px; border-left: 4px solid; border-radius: var(--radius); font-weight: 500; }
.flash.ok { background: var(--ok-bg); border-color: #1e9a52; color: var(--ok); }
.flash.err { background: var(--err-bg); border-color: #c43d3d; color: var(--err); }

/* Dettagli e cronologia */
dl.info { display: grid; grid-template-columns: 170px minmax(0, 1fr); margin: 0; }
dl.info dt, dl.info dd { margin: 0; padding: 10px 0; border-bottom: 1px solid var(--line); }
dl.info dt { color: var(--muted); }
dl.info dd { overflow-wrap: anywhere; white-space: pre-wrap; }
dl.info dt:last-of-type, dl.info dd:last-of-type { border-bottom: 0; }

.timeline { position: relative; margin: 0; padding: 0 0 0 24px; list-style: none; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
.timeline li { position: relative; padding: 0 0 18px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: -24px; top: 5px; width: 12px; height: 12px;
  border: 2px solid var(--field); border-radius: 50%; background: var(--panel);
}
.timeline li.ev-stato::before { border-color: var(--bench); background: var(--bench); }
.timeline .meta { font-size: 13px; color: var(--muted); }
.timeline .txt { margin-top: 2px; white-space: pre-wrap; }

/* Accesso e primo avvio */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 24px; background: var(--bench); }
.auth-wrap { width: 100%; max-width: 380px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; color: #fff; font-size: 26px; font-weight: 700; font-stretch: 80%; line-height: 1.1; }
.auth-brand svg { width: 34px; height: 34px; flex: none; }
.login-box { margin: 0; padding: 24px; }
.login-box h1 { margin-bottom: 14px; font-size: 24px; }

@media (max-width: 860px) {
  body.app { display: block; }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 12px 14px; }
  .brand { flex: 1 1 auto; font-size: 18px; }
  .rail .btn { order: 1; width: auto; }
  .who { order: 2; margin: 0; padding: 0; border: 0; gap: 12px; }
  .menu { order: 4; flex: 1 1 100%; flex-direction: row; overflow-x: auto; }
  .menu a { white-space: nowrap; }
  .rail-search { order: 5; flex: 1 1 100%; }
  .content { padding: 20px 14px 40px; }
}
@media (max-width: 720px) {
  .cols { grid-template-columns: 1fr; }
  table.stack-sm thead { display: none; }
  table.stack-sm tbody tr { display: block; padding: 10px 14px; border-bottom: 1px solid var(--line); }
  table.stack-sm tbody tr:last-child { border-bottom: 0; }
  table.stack-sm td { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 4px 0; border: 0; text-align: right; }
  table.stack-sm td::before { content: attr(data-label); flex: none; font-size: 13px; color: var(--muted); text-align: left; }
  table.stack-sm tbody tr:hover td { background: none; }
  h1 { font-size: 24px; }
  .ticket { font-size: 22px; }
}
@media (max-width: 560px) {
  .pipeline { grid-template-columns: 1fr 1fr; gap: 8px; }
  .track li { font-size: 12.5px; }
  dl.info { grid-template-columns: 1fr; }
  dl.info dt { padding-bottom: 0; border-bottom: 0; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Ricerca cliente, avvisi, tracking pubblico */
[hidden] { display: none !important; }
.card .ticket { --hole: var(--panel); }
.hint { margin: -6px 0 14px; font-size: 13.5px; color: var(--muted); }
.btn.mini { min-height: 30px; padding: 0 11px; font-size: 13px; }

.picker { margin-bottom: 14px; }
.picker-box { position: relative; }
form.stack .picker-box input[type=search] { margin-bottom: 0; }
.picker-list {
  position: absolute; z-index: 20; top: 100%; left: 0; right: 0; max-height: 300px; overflow: auto;
  margin: 4px 0 0; padding: 4px; list-style: none;
  background: #fff; border: 1px solid var(--field); border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(18, 39, 42, .14);
}
.picker-list li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 10px; border-radius: 3px; cursor: pointer; }
.picker-list li:hover, .picker-list li[aria-selected=true] { background: #e4f0ef; }
.picker-list li.vuoto { color: var(--muted); cursor: default; }
.picker-list li.vuoto:hover { background: none; }
.picker-list small { flex: none; color: var(--muted); }
.picker-scelto { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 12px; background: #f3f8f7; border: 1px solid var(--field); border-radius: var(--radius); }
.picker-nome { font-weight: 700; }

fieldset.nuovo-cliente, fieldset.gruppo-campi { min-width: 0; margin: 0 0 14px; padding: 14px 16px 2px; border: 1px dashed var(--field); border-radius: var(--radius); }
fieldset.nuovo-cliente legend, fieldset.gruppo-campi legend { padding: 0 6px; font-size: 16px; font-weight: 700; font-stretch: 82%; }

.avviso { margin: 0 0 14px; padding: 12px 14px; background: #fdf0c9; border-left: 4px solid #c58a00; border-radius: var(--radius); color: #4d3500; }
.avviso-titolo { margin: 0 0 6px; font-weight: 700; }
.avviso ul { margin: 0 0 10px; padding: 0; list-style: none; }
.avviso li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; padding: 6px 0; }
.avviso small { color: #6b4a00; }

body.auth.pub { place-items: start center; }
.auth-wrap.wide { max-width: 600px; }
.auth-wrap.wide .card { margin-bottom: 16px; }
.auth-wrap.wide .flash { margin-bottom: 16px; }
.pub-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 16px; }
.pub-desc { margin: 12px 0 18px; font-size: 16px; }

/* Riquadri colorati della home (stesso stile a gradiente del gestionale di riferimento) */
.stage { border: 0; color: #fff; background: linear-gradient(135deg, var(--st), var(--st-fg)); box-shadow: 0 2px 6px rgba(20, 40, 70, .15); }
.stage:hover { background: linear-gradient(135deg, var(--st-fg), var(--st-fg)); }
.stage span { color: rgba(255, 255, 255, .92); }
.stage.zero { background: linear-gradient(135deg, #c3ccd6, #aeb9c5); box-shadow: none; }
.stage.zero b, .stage.zero span { color: #fff; }
.brand svg { filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .2)); }
.card { border-radius: 10px; }
.stage.zero { background: #e3e9f0; }
.stage.zero b, .stage.zero span { color: #5a6877; }
.rail .btn { background: #fff; color: #234f7e; border-color: #fff; }
.rail .btn:hover { background: #e8f0f9; }
.rail .btn:focus-visible { outline-color: #fff; }

/* Pattern di sblocco */
.pattern { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 6px; }
.pattern svg { width: 120px; height: 120px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; flex: none; user-select: none; }
.pattern.ro svg { width: 90px; height: 90px; }

/* ===== Grafica moderna e responsive ===== */
:root { --radius: 10px; --shadow: 0 1px 2px rgba(25, 50, 90, .06), 0 8px 24px rgba(25, 50, 90, .08); }
body { background: radial-gradient(1200px 500px at 85% -10%, #dfeafa 0%, transparent 60%), var(--bg); background-attachment: fixed; }
.card { border: 0; border-radius: 16px; box-shadow: var(--shadow); }
.btn { border-radius: 10px; font-weight: 650; transition: transform .12s ease, box-shadow .12s ease, background .12s ease; box-shadow: 0 2px 6px rgba(47, 103, 168, .25); }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
input[type=text], input[type=search], input[type=email], input[type=password], input[type=tel], select, textarea { border-radius: 10px; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(47, 103, 168, .25); border-color: var(--signal); }
.stage { border-radius: 14px; transition: transform .15s ease, box-shadow .15s ease; }
.stage:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(25, 50, 90, .2); }
.brand span { letter-spacing: .01em; }
.menu a { border-radius: 10px; }
.rail { box-shadow: 4px 0 24px rgba(20, 50, 90, .18); }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.auth-brand small { color: #cfe0f2; font-size: 14px; font-weight: 500; letter-spacing: .04em; }
body.auth { background: radial-gradient(900px 500px at 20% 0%, #3b78b4 0%, transparent 60%), linear-gradient(160deg, #2c6296, #1d4670); }
.pub-info { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.pub-info h2 { margin-bottom: 8px; }
.pub-info p { margin: 0 0 8px; }
.orari { list-style: none; margin: 0 0 8px; padding: 0; }
.orari li { padding: 5px 0; border-bottom: 1px dotted var(--line); }

/* Telefono e tablet: il menu diventa una barra in basso, come in un'app */
@media (max-width: 860px) {
  body.app { padding-bottom: 76px; }
  .rail { box-shadow: 0 2px 14px rgba(20, 50, 90, .2); }
  .menu {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; order: 0; flex: none;
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0; overflow: visible;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, #2f6aa3, #234f7e); box-shadow: 0 -4px 18px rgba(20, 50, 90, .25);
  }
  .menu a { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 11.5px; border-left: 0; border-radius: 10px; text-align: center; justify-content: center; }
  .menu a[aria-current=page] { background: rgba(255, 255, 255, .18); }
  .menu svg { width: 22px; height: 22px; }
  .rail-search { order: 5; }
}
@media (max-width: 560px) {
  .content { padding: 16px 12px 32px; }
  .card { border-radius: 14px; }
  .head, .row { gap: 10px; }
  .head-actions .btn, .actions .btn { flex: 1 1 auto; text-align: center; }
  .auth-wrap.wide { width: 100%; }
}
@media print { .menu, .rail { display: none !important; } body.app { padding: 0; } }

/* Schede della sezione Impostazioni */
.subnav { display: flex; gap: 6px; margin: -4px 0 18px; padding: 4px; background: #e3e9f0; border-radius: 12px; width: fit-content; max-width: 100%; overflow-x: auto; }
.subnav a { padding: 8px 16px; border-radius: 9px; color: var(--muted); font-weight: 600; text-decoration: none; white-space: nowrap; }
.subnav a:hover { color: var(--ink); }
.subnav a[aria-current=page] { background: #fff; color: var(--link); box-shadow: 0 1px 4px rgba(25, 50, 90, .15); }
td select { min-width: 150px; }

/* Menu a tendina */
.menu .grp { margin: 0; }
.menu summary {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; cursor: pointer; list-style: none;
  border-left: 3px solid transparent; border-radius: 10px; font-weight: 550; user-select: none;
}
.menu summary::-webkit-details-marker { display: none; }
.menu summary:hover { background: var(--bench-hi); }
.menu summary span { flex: 1; }
.menu summary svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.menu summary .chev { width: 16px; height: 16px; transition: transform .2s ease; }
.menu details[open] > summary .chev { transform: rotate(180deg); }
.menu details[open] > summary { background: rgba(255, 255, 255, .1); }
.menu .dd { display: flex; flex-direction: column; margin: 4px 0 6px; padding: 4px; background: rgba(10, 35, 70, .28); border-radius: 10px; }
.menu .dd a { padding: 8px 10px 8px 14px; border-left: 0; border-radius: 8px; font-weight: 500; font-size: 14.5px; }
.menu .dd a[aria-current=page] { background: rgba(255, 255, 255, .2); color: #fff; }
.menu .dd a:hover { background: rgba(255, 255, 255, .12); }

@media (max-width: 860px) {
  .menu .grp { position: static; }
  .menu summary { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 11.5px; text-align: center; justify-content: center; border-left: 0; }
  .menu summary .chev { display: none; }
  .menu summary span { flex: none; }
  .menu details[open] > summary { background: rgba(255, 255, 255, .18); }
  .menu .dd {
    position: fixed; left: 8px; right: 8px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 30; margin: 0;
    padding: 8px; background: #1f4a78; border-radius: 14px; box-shadow: 0 8px 28px rgba(10, 30, 60, .4);
  }
  .menu .dd a { flex-direction: row; font-size: 15px; padding: 12px 14px; text-align: left; justify-content: flex-start; }
}
.menu .dd { max-height: 60vh; overflow-y: auto; }
.menu .dd a.stato::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--st, #fff); margin-right: 9px; flex: none; }
.menu .dd a { display: flex; align-items: center; }
.st-aperte { --st: #f4b400; }
.menu .dd a.senza-pallino { padding-left: 14px; }

/* Preventivi e permute */
.st-pv-aperto { --st: #c58a00; --st-bg: #fdf0c9; --st-fg: #6b4a00; }
.st-pv-convertito { --st: #1e9a52; --st-bg: #d9f3e3; --st-fg: #0e5a2e; }
.st-pv-rifiutato { --st: #c43d3d; --st-bg: #fbe0e0; --st-fg: #7a1f1f; }
.menu .dd a.piu::before { content: "+"; width: 8px; margin-right: 9px; flex: none; text-align: center; font-weight: 800; font-size: 17px; line-height: 1; }
.beni { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.beni th { text-align: left; font-size: 13px; padding: 4px 6px; }
.beni td { padding: 3px 4px; vertical-align: top; }
.beni input { margin: 0 !important; }
.beni .nr { width: 28px; text-align: center; padding-top: 12px; color: var(--muted); }
.beni .col-p { width: 110px; }
.beni .col-s { width: 32%; }
.radio-riga { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 14px; }
.radio-riga label { display: inline-flex !important; align-items: center; gap: 6px; margin: 0 !important; font-weight: 500 !important; }
.radio-riga input { width: auto; margin: 0 !important; }
@media (max-width: 700px) {
  .beni thead { display: none; }
  .beni tr { display: block; border: 1px solid var(--line, #d9e0e8); border-radius: 10px; padding: 8px; margin-bottom: 8px; }
  .beni td { display: block; padding: 3px 0; }
  .beni .nr { width: auto; text-align: left; padding: 0; font-weight: 700; }
  .beni .col-p, .beni .col-s { width: auto; }
}

/* ===== Tema blu e giallo (stile gestionale di riferimento) ===== */
:root {
  --bench: #2f6aa3; --bench-hi: rgba(255, 255, 255, .12); --bench-line: rgba(255, 255, 255, .25);
  --bg: #f3f5f9; --panel: #fff; --ink: #1f2937; --muted: #5d6b7e; --line: #e3e8ef; --field: #c3cddb;
  --signal: #2f6fe4; --signal-hi: #2a63cf; --link: #2a63cf; --radius: 10px; --gold: #f6c445;
  --shadow: 0 2px 10px rgba(30, 50, 90, .08);
}
body { background: var(--bg); background-attachment: scroll; }
h1 { font-stretch: 100%; font-weight: 800; font-size: 30px; letter-spacing: -.01em; }
h2 { font-stretch: 100%; }
.content { max-width: none; padding: 26px 32px 56px; }
body.app { grid-template-columns: 250px minmax(0, 1fr); grid-template-rows: auto 1fr; }
.rail { grid-row: 1 / span 2; background: linear-gradient(180deg, #2f6aa3 0%, #2a5d92 60%, #244f7f 100%); box-shadow: none; color: #eaf2fb; }
.rail .who { display: none; }
.brand { padding: 4px 2px 0; display: block; }
.brand svg { width: 100%; max-width: 214px; height: auto; filter: none; display: block; }
.rail .btn, .rail .btn:focus-visible { background: var(--gold); color: #3a2a00; border: 0; box-shadow: none; }
.rail .btn:hover { background: #f2b92a; }
.rail .btns { display: flex; flex-direction: column; gap: 8px; }
.rail-search input[type=search] { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .25); }
.rail-search input[type=search]::placeholder, .rail-search svg { color: #d3e3f5; stroke: #d3e3f5; }
.menu summary:hover, .menu .dd a:hover { background: rgba(255, 255, 255, .1); }
.menu details[open] > summary { background: rgba(255, 255, 255, .14); }
.menu .dd { background: rgba(0, 0, 0, .12); }
.menu .dd a[aria-current=page] { background: rgba(255, 255, 255, .22); box-shadow: none; color: #fff; }
.topbar { grid-column: 2; display: flex; align-items: center; gap: 14px; height: 64px; padding: 0 24px; background: #fff; box-shadow: 0 2px 8px rgba(30, 50, 90, .08); position: sticky; top: 0; z-index: 10; }
.topbar .toggle { width: 38px; height: 38px; display: grid; place-items: center; border: 0; border-radius: 8px; background: none; cursor: pointer; color: #2f6fe4; }
.topbar .toggle:hover { background: #eef3fd; }
.topbar .toggle svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.topbar .tt { font-size: 22px; font-weight: 800; color: #1f2937; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; }
.topbar .tt svg { width: 26px; height: 26px; }
.topbar .utente { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--muted); font-weight: 600; }
.topbar .av { width: 38px; height: 38px; border-radius: 50%; background: #2f6fe4; color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.topbar .utente a { font-size: 13px; }
.content { grid-column: 2; }
body.app.rail-chiusa { grid-template-columns: 0 minmax(0, 1fr); }
body.app.rail-chiusa .rail { display: none; }
.btn { background: var(--signal); border-color: var(--signal-hi); box-shadow: 0 2px 6px rgba(47, 111, 228, .25); }
.btn:hover { background: var(--signal-hi); }
.btn.sec { background: #fff; border-color: var(--field); color: var(--ink); box-shadow: none; }
.btn.sec:hover { background: #f1f4f9; border-color: #9aa8bd; }
.btn.danger { background: #fff; border-color: #e07a7a; color: #9b2c2c; box-shadow: none; }
.btn.wa { background: #128c4a; border-color: #0e7a40; }
.head > a.btn:not(.sec), .head > .head-actions > a.btn:not(.sec):first-child { background: var(--gold); border-color: #e6b230; color: #3a2a00; box-shadow: none; }
.head > a.btn:not(.sec):hover, .head > .head-actions > a.btn:not(.sec):first-child:hover { background: #f2b92a; }
a { color: var(--link); }
.card { border: 0; border-radius: 12px; box-shadow: var(--shadow); }
.filters { background: #fff; padding: 12px; border-radius: 12px; box-shadow: var(--shadow); }
thead th { background: #eceff4; color: #2b3445; text-transform: uppercase; letter-spacing: .04em; font-size: 12.5px; font-weight: 700; }
tbody tr:hover td { background: #f6f9fe; }
.id { color: #1f2937; font-stretch: 100%; font-size: 16px; font-weight: 800; }
.ticket { background: #2f6fe4; }
.track li.done { border-top-color: #2f6aa3; }
.track li.now { border-top-color: #2f6fe4; }
.timeline li.ev-stato::before { border-color: #2f6fe4; background: #2f6fe4; }
.stage { border-radius: 12px; box-shadow: 0 4px 14px rgba(30, 50, 90, .18); }
.stage b { font-stretch: 100%; font-weight: 800; font-size: 36px; }
input:focus, select:focus, textarea:focus { border-color: #2f6fe4; outline: 3px solid rgba(47, 111, 228, .22); }
body.auth { background: radial-gradient(900px 500px at 20% 0%, #3b78b4 0%, transparent 60%), linear-gradient(160deg, #2f6aa3, #214a78); }
.auth-brand svg { width: 230px; max-width: 100%; height: auto; filter: none; }
.auth-brand { gap: 10px; }
.subnav a[aria-current=page] { color: #2a63cf; }
@media (max-width: 860px) {
  body.app { display: block; }
  .topbar { display: none; }
  .brand { flex: 1 1 auto; }
  .brand svg { max-width: 160px; }
  .rail { box-shadow: 0 2px 14px rgba(20, 50, 90, .25); }
  .rail .who { display: flex; }
  .rail .btns { flex-direction: row; order: 1; }
  .rail .btns .btn { width: auto; padding: 0 12px; font-size: 14px; }
  .menu { background: linear-gradient(180deg, #2f6aa3, #234f7e); box-shadow: 0 -4px 18px rgba(20, 50, 90, .3); }
  .menu .dd { background: #2a5d92; }
  .content { padding: 20px 14px 40px; }
  h1 { font-size: 24px; }
}
.brand > span, .auth-brand > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.auth-brand small { margin-top: 2px; }

/* Cassa (POS) */
.pos-grid { display: grid; grid-template-columns: minmax(300px, 420px) 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .pos-grid { grid-template-columns: 1fr; } }
.pos-display { background: #0f2a44; color: #fff; border-radius: 12px; padding: 12px 16px; text-align: right; }
.pos-display small { display: block; opacity: .7; font-size: 12px; }
.pos-display strong { font-size: 36px; font-variant-numeric: tabular-nums; }
.pos-tasti { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pos-tasti button { font-size: 26px; font-weight: 700; padding: 16px 0; border-radius: 12px; border: 1px solid #cbd5e0; background: #fff; color: #1a202c; cursor: pointer; touch-action: manipulation; }
.pos-tasti button:active { background: #e8eff7; }
.pos-tasti .pos-c { background: #fdecea; color: #b91c1c; }
.pos-scelte { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.pos-scelte label { margin: 0 !important; }
.pos-scelte input { position: absolute; opacity: 0; }
.pos-scelte span { display: inline-block; padding: 12px 20px; border: 2px solid #cbd5e0; border-radius: 10px; font-weight: 700; cursor: pointer; }
.pos-scelte input:checked + span { border-color: #2f6aa3; background: #2f6aa3; color: #fff; }
.pos-scelte input:focus-visible + span { outline: 3px solid #f6c445; }
.pos-ok { font-size: 20px; padding: 16px; width: 100%; }
.linklike { background: none; border: 0; color: #b91c1c; cursor: pointer; padding: 0; font: inherit; text-decoration: underline; }
.pos-tasti .pos-c { grid-column: 1 / -1; padding: 10px 0; font-size: 20px; }

/* Paginazione */
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; margin: 14px 0; font-size: 14px; }
.btn.off { opacity: .4; pointer-events: none; }

/* Allegati (documenti di identità) */
ul.allegati { list-style: none; margin: 0 0 14px; padding: 0; }
ul.allegati li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 0; border-bottom: 1px solid var(--line, #e5e7eb); }
ul.allegati li > a:first-child { font-weight: 600; word-break: break-all; }
ul.allegati li small { flex: 1 1 200px; }
form.inline { display: inline; margin: 0; }
