/* TruksPlanner Operatori.
 * Regole di progetto (APP-OPERATORI.md, §7): bersagli >= 56px, testo >= 18px,
 * contrasto alto, un solo bottone evidente per schermata, nessun gesto nascosto.
 * Tema unico e chiaro: si legge sotto il sole, in cabina.
 */
:root {
  --blu: #0b3d75;
  --blu-scuro: #082c55;
  --blu-tenue: #e4edf8;
  --verde: #17703a;
  --rosso: #b3261e;
  --arancio: #9a4d00;
  --arancio-tenue: #fff1dd;
  --testo: #10151c;
  --testo-tenue: #46505d;
  --sfondo: #f1f3f6;
  --carta: #ffffff;
  --bordo: #b8c0cb;
  --raggio: 14px;
  --gutter: 16px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--sfondo);
  color: var(--testo);
  font: 18px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
.noscript { padding: var(--gutter); }

/* --- struttura ---------------------------------------------------------- */
.schermata {
  min-height: 100vh;
  min-height: 100dvh;
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
  padding-bottom: max(32px, env(safe-area-inset-bottom));
  max-width: 640px;
  margin: 0 auto;
}
.barra {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  margin: 0 calc(-1 * var(--gutter));
  padding: max(10px, env(safe-area-inset-top)) var(--gutter) 10px;
  background: var(--blu); color: #fff;
  min-height: 64px;
}
.barra-titolo { flex: 1; font-size: 20px; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barra-btn {
  min-height: 48px; min-width: 48px; padding: 0 14px;
  border: 2px solid rgba(255,255,255,.7); border-radius: 12px;
  background: transparent; color: #fff; font: inherit; font-weight: 600;
}
h1 { font-size: 26px; line-height: 1.2; margin: 18px 0 6px; }
h2 { font-size: 18px; margin: 22px 0 8px; color: var(--testo-tenue); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 8px 0; }
.tenue { color: var(--testo-tenue); }

/* --- bottoni ------------------------------------------------------------ */
.bottone {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 60px; padding: 12px 18px;
  border: 0; border-radius: var(--raggio);
  background: var(--blu); color: #fff;
  font: inherit; font-size: 20px; font-weight: 700; text-align: center; text-decoration: none;
}
.bottone:active { filter: brightness(.88); }
.bottone[disabled] { opacity: .5; }
.bottone-grande { min-height: 88px; font-size: 24px; letter-spacing: .02em; }
.bottone-verde { background: var(--verde); }
.bottone-rosso { background: var(--rosso); }
.bottone-neutro { background: var(--carta); color: var(--testo); border: 2px solid var(--bordo); }
.bottone-testo {
  background: none; border: 0; color: var(--blu); text-decoration: underline;
  min-height: 56px; font: inherit; font-weight: 600; width: 100%;
}
.pila > * + * { margin-top: 14px; }
:focus-visible { outline: 4px solid #ffb300; outline-offset: 2px; }

/* --- form --------------------------------------------------------------- */
.campo { margin: 16px 0; }
.campo label, .campo .etichetta { display: block; font-weight: 700; margin-bottom: 6px; }
.campo input[type=text], .campo input[type=password], .campo textarea {
  width: 100%; min-height: 60px; padding: 12px 14px;
  border: 2px solid var(--bordo); border-radius: 12px; background: #fff;
  font: inherit; font-size: 22px; color: var(--testo);
}
.campo textarea { min-height: 150px; font-size: 19px; resize: vertical; }
.campo input:focus, .campo textarea:focus { outline: 4px solid #ffb300; outline-offset: 0; border-color: var(--blu); }
.suggerimento { color: var(--testo-tenue); font-size: 16px; margin: 6px 0 0; }
.errore { color: var(--rosso); font-weight: 700; margin: 8px 0; }
.scelte { display: grid; gap: 10px; }
label.scelta {
  display: flex; align-items: center; gap: 14px; margin-bottom: 0; min-height: 64px; padding: 10px 16px;
  border: 2px solid var(--bordo); border-radius: 12px; background: #fff; font-weight: 700;
}
.scelta input { width: 26px; height: 26px; flex: none; margin: 0; }
.scelta span { line-height: 1.3; }
.scelta:has(input:checked) { border-color: var(--blu); background: var(--blu-tenue); }

/* --- schede intervento -------------------------------------------------- */
.tabs { display: flex; gap: 8px; margin: 14px 0; }
.tab {
  flex: 1; min-height: 56px; border: 2px solid var(--bordo); border-radius: 12px;
  background: #fff; color: var(--testo); font: inherit; font-weight: 700;
}
.tab[aria-selected=true] { background: var(--blu); border-color: var(--blu); color: #fff; }

.card {
  display: block; margin: 0 0 14px; padding: 0; overflow: hidden;
  background: var(--carta); border: 2px solid var(--bordo); border-radius: var(--raggio);
  color: inherit; text-decoration: none;
}
.card:active { filter: brightness(.95); }
.mezzo {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 10px 16px;
  background: var(--mz, #46505d); color: var(--mzt, #fff);
}
.mezzo strong { font-size: 24px; }
.mezzo span { font-size: 17px; font-weight: 600; }
.mezzo small { display: block; font-size: 14px; font-weight: 600; opacity: .9; }
.mezzo-nessuno { --mz: #dfe3e8; --mzt: #46505d; }
.corpo { padding: 12px 16px 14px; }
.ora { font-size: 26px; font-weight: 800; line-height: 1.1; }
.cliente { font-size: 20px; font-weight: 700; margin-top: 2px; }
.dove { color: var(--testo-tenue); margin-top: 2px; }
.stato { display: inline-block; margin-top: 10px; padding: 5px 12px; border-radius: 999px; font-size: 16px; font-weight: 800; background: var(--blu-tenue); color: var(--blu-scuro); }
.stato-in_corso { background: #dff3e5; color: var(--verde); }
.stato-terminato { background: var(--arancio-tenue); color: var(--arancio); }
.stato-inviato { background: #e8ebef; color: var(--testo-tenue); }
.stato-rimandato { background: #fde5e3; color: var(--rosso); }
.badge { display: inline-block; margin: 10px 0 0 6px; padding: 5px 12px; border-radius: 999px; font-size: 16px; font-weight: 800; background: #ffe7a3; color: #5a4300; }
.sezione-titolo { margin: 18px 2px 8px; font-size: 17px; font-weight: 800; color: var(--arancio); }
.vuoto { text-align: center; padding: 48px 12px; color: var(--testo-tenue); }

/* --- dettaglio ---------------------------------------------------------- */
.mezzo-grande { border-radius: var(--raggio); padding: 14px 18px; margin-top: 16px; }
.mezzo-grande strong { font-size: 30px; }
.riga { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid #d8dde4; }
.riga .k { flex: none; width: 96px; color: var(--testo-tenue); font-weight: 700; }
.riga .v { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.riga a { color: var(--blu); font-weight: 700; }
.note-ufficio { white-space: pre-wrap; background: #fffbe8; border: 2px solid #e6d27a; border-radius: 12px; padding: 12px 14px; }
.chip { display: inline-block; margin: 4px 6px 0 0; padding: 4px 12px; border-radius: 999px; background: #fde5e3; color: var(--rosso); font-weight: 800; font-size: 16px; }
.cronometro { text-align: center; font-size: 34px; font-weight: 800; margin: 18px 0 4px; font-variant-numeric: tabular-nums; }
.azioni { margin-top: 26px; }
.riquadro { border: 2px solid var(--bordo); border-radius: var(--raggio); background: var(--carta); padding: 14px 16px; margin-top: 18px; }

/* --- avvisi ------------------------------------------------------------- */
.avviso { margin: 12px 0 0; padding: 12px 14px; border-radius: 12px; font-weight: 700; }
.avviso-rete { background: #ffe7a3; color: #5a4300; }
.avviso-coda { background: var(--blu-tenue); color: var(--blu-scuro); display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.avviso-errore { background: #fde5e3; color: var(--rosso); border: 0; width: 100%; text-align: left; font: inherit; font-weight: 800; min-height: 56px; }
.avviso button { min-height: 44px; padding: 0 14px; border: 2px solid currentColor; border-radius: 10px; background: transparent; color: inherit; font: inherit; font-weight: 800; }

/* --- finestre e messaggi ------------------------------------------------ */
.velo {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(8, 20, 38, .6);
}
.finestra {
  width: 100%; max-width: 640px; max-height: 88vh; overflow: auto;
  background: #fff; border-radius: 20px 20px 0 0;
  padding: 22px max(var(--gutter), env(safe-area-inset-left)) max(22px, env(safe-area-inset-bottom));
}
.finestra h2 { margin: 0 0 8px; font-size: 24px; color: var(--testo); text-transform: none; letter-spacing: 0; }
.finestra .pila { margin-top: 18px; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: max(24px, env(safe-area-inset-bottom)); z-index: 30;
  max-width: calc(100% - 2 * var(--gutter)); padding: 14px 20px;
  background: #10151c; color: #fff; border-radius: 12px; font-weight: 700; text-align: center;
  /* Non deve mai intercettare i tocchi: puo' coprire un bottone per qualche secondo. */
  pointer-events: none;
}

/* --- accesso ------------------------------------------------------------ */
.accesso { padding-top: max(40px, env(safe-area-inset-top)); }
.accesso img { display: block; width: 88px; height: 88px; margin: 0 auto 8px; border-radius: 20px; }
.accesso h1 { text-align: center; }
