/* =====================================================================
   Magazzino CRI Cesena

   Impostazione visiva: il linguaggio dei magazzini di soccorso —
   marcature stencil sulle casse, liste di carico, etichette di
   attrezzatura. I codici articolo sono l'elemento tipografico portante
   perche' sono cio' che l'operatore legge, cerca e detta via radio.
   Tutto il resto sta zitto.

   Vincoli d'uso: telefono in mano, magazzino, spesso con i guanti.
   Bersagli tattili ampi, contrasti alti, niente decorazione.
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;450;500;600&display=swap');

:root {
  --inchiostro:  #16202b;
  --carta:       #f1f2ef;
  --pannello:    #ffffff;
  --riga:        #d3d7d1;
  --riga-tenue:  #e6e8e4;
  --attenuato:   #5f6b74;

  --operativo:   #126e4a;
  --attenzione:  #a65b00;
  --allarme:     #c8102e;

  --sans: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', monospace;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;

  --barra-alta: 56px;
  --barra-bassa: 60px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--carta);
  color: var(--inchiostro);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

body {
  padding-bottom: calc(var(--barra-bassa) + env(safe-area-inset-bottom));
}

:focus-visible {
  outline: 2px solid var(--inchiostro);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ---------------------------------------------------------------- */
/*  Intestazione                                                     */
/* ---------------------------------------------------------------- */

.testata {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--barra-alta);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-4);
  background: var(--inchiostro);
  color: var(--carta);
}

.testata h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.testata .ente {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: #9fb0bd;
  letter-spacing: .04em;
}

.testata button {
  background: none;
  border: 1px solid #3b4956;
  color: var(--carta);
  border-radius: 3px;
  padding: 6px 10px;
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
  min-height: 34px;
}

.indietro {
  background: none;
  border: none;
  color: var(--carta);
  font-size: 22px;
  line-height: 1;
  padding: var(--sp-2);
  margin-left: calc(var(--sp-2) * -1);
  cursor: pointer;
}

/* ---------------------------------------------------------------- */
/*  Contenuto                                                        */
/* ---------------------------------------------------------------- */

main { display: block; }

.sezione {
  padding: var(--sp-4);
  max-width: 720px;
  margin: 0 auto;
}

.sezione-piena {
  max-width: 720px;
  margin: 0 auto;
}

h2 {
  font-size: 15px;
  font-weight: 600;
  margin: var(--sp-5) var(--sp-4) var(--sp-2);
  color: var(--attenuato);
}

h2:first-child { margin-top: var(--sp-4); }

/* ---------------------------------------------------------------- */
/*  Righe di elenco: la "riga di manifesto"                          */
/* ---------------------------------------------------------------- */

.elenco {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--pannello);
  border-top: 1px solid var(--riga);
  border-bottom: 1px solid var(--riga);
}

.voce {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--riga-tenue);
  border-left: 3px solid transparent;
  min-height: 60px;
  cursor: pointer;
  background: none;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
}

.voce:last-child { border-bottom: none; }
.voce:active { background: var(--carta); }

.voce.stato-ok      { border-left-color: var(--operativo); }
.voce.stato-scarso  { border-left-color: var(--attenzione); }
.voce.stato-critico { border-left-color: var(--allarme); }

.codice {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .01em;
  color: var(--inchiostro);
  white-space: nowrap;
  flex-shrink: 0;
  width: 88px;
}

.codice .suffisso { color: var(--attenuato); font-weight: 400; }

.corpo { flex: 1; min-width: 0; }

.corpo .titolo {
  font-weight: 450;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.corpo .sotto {
  font-size: 12.5px;
  color: var(--attenuato);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quantita {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  text-align: right;
  flex-shrink: 0;
  white-space: nowrap;
}

.quantita .totale {
  font-weight: 400;
  font-size: 12px;
  color: var(--attenuato);
}

.quantita .um {
  display: block;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 400;
  color: var(--attenuato);
}

/* ---------------------------------------------------------------- */
/*  Modulo                                                           */
/* ---------------------------------------------------------------- */

.campo { margin-bottom: var(--sp-4); }

.campo > label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: var(--sp-1);
  color: var(--attenuato);
}

.campo .aiuto {
  font-size: 12.5px;
  color: var(--attenuato);
  margin-top: var(--sp-1);
  line-height: 1.35;
}

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="search"],
select, textarea {
  width: 100%;
  padding: 11px var(--sp-3);
  border: 1px solid var(--riga);
  border-radius: 3px;
  background: var(--pannello);
  font-family: var(--sans);
  font-size: 16px;   /* sotto i 16px iOS ingrandisce la pagina al focus */
  color: var(--inchiostro);
  min-height: 44px;
}

input:disabled, select:disabled { background: var(--riga-tenue); color: var(--attenuato); }

textarea { min-height: 76px; resize: vertical; }

.scelta {
  display: flex;
  gap: var(--sp-2);
}

.scelta input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }

.scelta label {
  flex: 1;
  border: 1px solid var(--riga);
  border-radius: 3px;
  padding: var(--sp-3);
  cursor: pointer;
  background: var(--pannello);
  font-size: 14px;
  line-height: 1.3;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.scelta label .nota {
  font-size: 12px;
  color: var(--attenuato);
  margin-top: 2px;
}

.scelta input:checked + label {
  border-color: var(--inchiostro);
  box-shadow: inset 0 0 0 1px var(--inchiostro);
}

.scelta input:focus-visible + label { outline: 2px solid var(--inchiostro); outline-offset: 2px; }

.interruttore {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-top: 1px solid var(--riga-tenue);
  cursor: pointer;
}

.interruttore input { width: 22px; height: 22px; margin: 2px 0 0; flex-shrink: 0; accent-color: var(--inchiostro); }
.interruttore .testo { font-size: 14.5px; }
.interruttore .testo .nota { display: block; font-size: 12.5px; color: var(--attenuato); margin-top: 2px; }

/* ---------------------------------------------------------------- */
/*  Pulsanti                                                         */
/* ---------------------------------------------------------------- */

.pulsante {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  width: 100%;
  min-height: 48px;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--inchiostro);
  border-radius: 3px;
  background: var(--inchiostro);
  color: var(--carta);
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

.pulsante:disabled { opacity: .45; cursor: not-allowed; }
.pulsante.secondario { background: var(--pannello); color: var(--inchiostro); }
.pulsante.pericolo { background: var(--pannello); border-color: var(--allarme); color: var(--allarme); }
.pulsante.compatto { width: auto; min-height: 40px; font-size: 14px; padding: var(--sp-2) var(--sp-3); }

.azioni { display: flex; gap: var(--sp-2); margin-top: var(--sp-5); }

/* ---------------------------------------------------------------- */
/*  Ricerca e filtri                                                 */
/* ---------------------------------------------------------------- */

.filtri {
  position: sticky;
  top: var(--barra-alta);
  z-index: 10;
  background: var(--carta);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--riga);
  display: flex;
  gap: var(--sp-2);
}

.filtri input[type="search"] { flex: 2; }
.filtri select { flex: 1; min-width: 96px; }

/* ---------------------------------------------------------------- */
/*  Riquadro dati                                                    */
/* ---------------------------------------------------------------- */

.riquadro {
  background: var(--pannello);
  border-top: 1px solid var(--riga);
  border-bottom: 1px solid var(--riga);
  padding: var(--sp-4);
}

.dati { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); }

.dato .etichetta { font-size: 12px; color: var(--attenuato); }
.dato .valore { font-family: var(--mono); font-size: 24px; font-weight: 600; line-height: 1.1; }
.dato .valore.piccolo { font-size: 15px; font-weight: 500; }

.riga-dato {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--riga-tenue);
  font-size: 14.5px;
}

.riga-dato:last-child { border-bottom: none; }
.riga-dato dt { color: var(--attenuato); }
.riga-dato dd { margin: 0; text-align: right; }

dl { margin: 0; }

/* ---------------------------------------------------------------- */
/*  Stati                                                            */
/* ---------------------------------------------------------------- */

.marchio {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 2px;
  border: 1px solid currentColor;
}

.marchio.ok      { color: var(--operativo); }
.marchio.avviso  { color: var(--attenzione); }
.marchio.grave   { color: var(--allarme); }
.marchio.neutro  { color: var(--attenuato); }

.vuoto {
  padding: var(--sp-6) var(--sp-4);
  text-align: center;
  color: var(--attenuato);
}

.vuoto p { margin: 0 0 var(--sp-4); font-size: 14.5px; }

.caricamento {
  padding: var(--sp-6);
  text-align: center;
  color: var(--attenuato);
  font-size: 14px;
}

/* ---------------------------------------------------------------- */
/*  Navigazione                                                      */
/* ---------------------------------------------------------------- */

.navigazione {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  background: var(--pannello);
  border-top: 1px solid var(--riga);
  padding-bottom: env(safe-area-inset-bottom);
}

.navigazione a {
  flex: 1;
  height: var(--barra-bassa);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--attenuato);
  font-size: 11.5px;
  border-top: 2px solid transparent;
  margin-top: -1px;
}

.navigazione a.attivo { color: var(--inchiostro); border-top-color: var(--inchiostro); font-weight: 500; }
.navigazione svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.6; }

/* ---------------------------------------------------------------- */
/*  Avvisi                                                           */
/* ---------------------------------------------------------------- */

.avviso {
  position: fixed;
  left: var(--sp-4);
  right: var(--sp-4);
  bottom: calc(var(--barra-bassa) + var(--sp-4) + env(safe-area-inset-bottom));
  z-index: 40;
  padding: var(--sp-3) var(--sp-4);
  border-radius: 3px;
  background: var(--inchiostro);
  color: var(--carta);
  font-size: 14.5px;
  max-width: 690px;
  margin: 0 auto;
}

.avviso.errore { background: var(--allarme); }
.avviso.riuscito { background: var(--operativo); }

/* ---------------------------------------------------------------- */
/*  Accesso                                                          */
/* ---------------------------------------------------------------- */

.accesso {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--sp-5);
  max-width: 420px;
  margin: 0 auto;
}

.accesso .marca { margin-bottom: var(--sp-6); }

.accesso .marca .nome {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.accesso .marca .ente {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--attenuato);
  letter-spacing: .06em;
  margin-top: var(--sp-2);
}

.errore-modulo {
  background: #fdecef;
  border-left: 3px solid var(--allarme);
  color: #8c1023;
  padding: var(--sp-3);
  font-size: 14px;
  margin-bottom: var(--sp-4);
  border-radius: 0 3px 3px 0;
}

/* ---------------------------------------------------------------- */

.righe-matricole { display: flex; flex-direction: column; gap: var(--sp-2); }

.riga-matricola { display: flex; align-items: center; gap: var(--sp-3); }

.riga-matricola .n {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--attenuato);
  width: 26px;
  flex-shrink: 0;
  text-align: right;
}
