/* Adadò Manutenzioni: palette e caratteri di Live Feedback, tema chiaro
   ad alto contrasto perché si usa in strada, sotto il sole.
   Regole: testo mai sotto 16px, tasti alti almeno 58px, una sola azione
   principale per schermo, colore solo per urgenza e stato. */

@font-face { font-family: Archivo; src: url('./archivo-latin.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: Instrument; src: url('./instrument-serif-latin.woff2') format('woff2'); font-display: swap; }

:root {
  color-scheme: light;
  --bg: #f1eee6;
  --surface: #fbf9f3;
  --white: #ffffff;
  --ink: #172e34;
  --muted: #4f666b;
  --line: #ddd8cc;
  --accent: #b2471a;
  --good: #1b6850;
  --good-soft: #e3efe9;
  --bad: #a83329;
  --warm: #8a5f12;
  --orange: #c2410c;
  --azure: #1d6fa5;
  --info: #1f5b7a;
  --radius: 18px;
  --tap: 58px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Archivo, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 17px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); min-height: 100%; }
body { overscroll-behavior-y: contain; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.serif { font-family: Instrument, Georgia, serif; font-weight: 400; }

.screen {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(var(--safe-top) + 18px) 16px calc(var(--safe-bottom) + 24px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- testata ---------- */
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 4px 4px 2px; }
.head h1 { font-family: Instrument, serif; font-weight: 400; font-size: 40px; line-height: 1; margin: 0; }
.head .who { font-size: 16px; color: var(--muted); font-weight: 600; margin-top: 4px; }
.back {
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 16px 0 10px;
  border-radius: 14px; background: var(--surface); font-weight: 800; font-size: 17px; align-self: flex-start;
}
.back svg { width: 22px; height: 22px; }

/* ---------- tab e filtri ---------- */
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tab {
  min-height: 52px; border-radius: 14px; background: var(--surface); color: var(--muted);
  font-weight: 800; font-size: 18px;
}
.tab[aria-selected="true"] { background: var(--ink); color: var(--white); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filters::-webkit-scrollbar { display: none; }
.filter {
  flex: none; min-height: 46px; padding: 0 14px; border-radius: 999px; background: var(--surface);
  font-weight: 800; font-size: 16px; color: var(--muted); border: 2px solid transparent; white-space: nowrap;
}
.filter[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); background: var(--white); }
.filter .n { margin-left: 6px; }

/* ---------- card guasto ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.card {
  display: block; width: 100%; text-align: left; background: var(--surface); border-radius: var(--radius);
  padding: 14px 16px 15px 24px; --stripe: var(--info);
  box-shadow: inset 9px 0 0 var(--stripe), 0 1px 2px rgba(23,46,52,.06);
}
.card:active { transform: scale(.99); }
.card.p-urgentissima { --stripe: var(--bad); }
.card.p-urgente { --stripe: var(--orange); }
.card.p-da_fare { --stripe: var(--azure); }
.card.closed { --stripe: var(--good); }
.pr { font-size: 16px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; }
.pr.p-urgentissima { color: var(--bad); }
.pr.p-urgente { color: var(--orange); }
.pr.p-da_fare { color: var(--azure); }
.pr.closed { color: var(--good); }
.card .ti { font-size: 21px; font-weight: 800; line-height: 1.2; margin-top: 3px; }
.card .wh { font-size: 16px; color: var(--muted); font-weight: 600; margin-top: 5px; }

.empty, .error {
  background: var(--surface); border-radius: var(--radius); padding: 22px 18px; font-size: 18px;
  font-weight: 700; text-align: center; color: var(--muted);
}
.error { color: var(--bad); }
.stamp { text-align: center; font-size: 16px; color: var(--muted); font-weight: 600; padding: 6px 0; }

/* ---------- pagina guasto ---------- */
.probhead { background: var(--surface); border-radius: 22px; padding: 18px 18px 20px; }
.probhead .ti { font-family: Instrument, serif; font-size: 38px; line-height: 1.05; margin-top: 6px; }
.probhead .wh { font-size: 17px; font-weight: 700; color: var(--muted); margin-top: 10px; }
.probhead .wh b { color: var(--ink); }
.facts { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }

.big {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  min-height: var(--tap); border-radius: 16px; font-weight: 800; font-size: 19px; text-align: center; padding: 8px 14px;
}
.big svg { width: 24px; height: 24px; flex: none; }
a.big { text-decoration: none; }
.flag { font-size: 26px; line-height: 1; }
.b-pri { background: var(--accent); color: var(--white); }
.b-good { background: var(--good); color: var(--white); }
.b-ink { background: var(--ink); color: var(--white); }
.b-sec { background: var(--surface); color: var(--ink); border: 2px solid var(--line); }
.b-bad { background: var(--surface); color: var(--bad); border: 2px solid var(--bad); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions { display: flex; flex-direction: column; gap: 10px; }
.note { background: var(--good-soft); color: var(--good); border-radius: 16px; padding: 14px 16px; font-weight: 800; font-size: 17px; }

/* ---------- popup dal basso ---------- */
.dim { position: fixed; inset: 0; background: rgba(23,46,52,.55); z-index: 20; animation: fade .18s ease-out; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-width: 560px; margin: 0 auto;
  background: var(--surface); border-radius: 26px 26px 0 0; padding: 12px 18px calc(var(--safe-bottom) + 20px);
  display: flex; flex-direction: column; gap: 14px; max-height: 88dvh; overflow-y: auto;
  animation: rise .24s cubic-bezier(.22,.61,.36,1);
}
.sheet .grab { width: 54px; height: 6px; border-radius: 9px; background: var(--line); margin: 0 auto 2px; }
.sheet h2 { font-family: Instrument, serif; font-weight: 400; font-size: 32px; line-height: 1.05; margin: 0; }
.sheet p { margin: 0; font-size: 18px; line-height: 1.45; }
.info { background: var(--white); border-radius: 16px; padding: 13px 15px; font-size: 17px; line-height: 1.4; }
.info b { font-weight: 800; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- accesso ---------- */
.login { justify-content: center; gap: 16px; }
.logo { font-family: Instrument, serif; font-size: 52px; line-height: .95; margin-bottom: 10px; }
.logo em { color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 17px; font-weight: 800; }
.field input {
  min-height: var(--tap); border-radius: 16px; border: 2px solid var(--line); background: var(--white);
  font: inherit; font-size: 20px; padding: 0 16px; color: var(--ink);
}
.field input:focus { border-color: var(--ink); outline: none; }
.hint { font-size: 16px; color: var(--muted); font-weight: 600; text-align: center; }
.form-error { color: var(--bad); font-weight: 800; font-size: 17px; text-align: center; min-height: 24px; }

.spinner { width: 34px; height: 34px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--ink); animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) { *:not(.blink) { animation: none !important; } }
[hidden] { display: none !important; }

/* ---------- card di stato ---------- */
/* Quattro card quadrate due per due: a meta' larghezza "Urgentissime" sta a 18px. */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile {
  aspect-ratio: 1 / 1; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start;
  padding: 14px 12px 14px 14px; border-radius: 22px; color: var(--white); text-align: left; min-width: 0;
  border: 3px solid transparent; transition: opacity .15s ease, transform .15s ease;
  box-shadow: 0 2px 6px rgba(23,46,52,.12);
}
.tile:active { transform: scale(.97); }
.tile-n { font-family: Instrument, serif; font-size: 64px; line-height: .9; }
.tile-l { font-weight: 800; font-size: clamp(16px, 4.8vw, 20px); line-height: 1.1; }
.t-urgentissima { background: var(--bad); }
.t-urgente { background: var(--orange); }
.t-da_fare { background: var(--azure); }
.t-risolte { background: var(--good); }
.tiles.filtering .tile[aria-pressed="false"] { opacity: .38; }
.tile[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--white) inset; }
.card .ti { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
/* Storico: tre card, la terza a tutta larghezza per non lasciare un buco. */
#filters:not(.filtering) > .tile:nth-child(3):last-child { grid-column: 1 / -1; aspect-ratio: auto; min-height: 120px; }

/* ---------- lampeggio, lavorazione, impostazioni ---------- */
.tile.blink { animation: blink 1.4s ease-in-out infinite; }
.tiles.filtering .tile.blink { animation: none; }
@keyframes blink { 0%, 100% { filter: none; } 50% { filter: brightness(1.28) saturate(1.1); } }
.working { margin-top: 8px; display: inline-block; background: var(--ink); color: var(--white); border-radius: 10px; padding: 5px 10px; font-weight: 800; font-size: 16px; }
.head { align-items: flex-start; }
.gear { flex: none; width: 52px; height: 52px; border-radius: 16px; background: var(--surface); display: grid; place-items: center; margin-top: 2px; }
.gear svg { width: 28px; height: 28px; }
.panel { background: var(--surface); border-radius: 22px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.panel-t { font-family: Instrument, serif; font-weight: 400; font-size: 30px; margin: 0; }
.panel-h { margin: 4px 0 0; font-weight: 800; font-size: 18px; }
.push-state { background: var(--white); border-radius: 16px; padding: 13px 15px; display: flex; flex-direction: column; gap: 4px; font-size: 17px; }
.push-state span { color: var(--muted); font-weight: 600; font-size: 16px; }
.push-state.on b { color: var(--good); }
.toggles { display: flex; flex-direction: column; gap: 8px; }
.toggle { display: flex; align-items: center; justify-content: space-between; min-height: 62px; padding: 0 16px; border-radius: 16px; color: var(--white); font-weight: 800; font-size: 19px; }
.toggle[aria-checked="false"] { filter: saturate(.25); opacity: .7; }
.switch { width: 60px; height: 34px; border-radius: 999px; background: rgba(255,255,255,.35); position: relative; flex: none; }
.switch span { position: absolute; top: 4px; left: 4px; width: 26px; height: 26px; border-radius: 50%; background: var(--white); transition: transform .18s ease; }
.toggle[aria-checked="true"] .switch { background: rgba(255,255,255,.55); }
.toggle[aria-checked="true"] .switch span { transform: translateX(26px); }
