/* App operatori: pensata per una mano sola.
   - Tutto ciò che si tocca sta nella metà bassa dello schermo (zona del pollice).
   - Bersagli grandi (almeno 56px), testo grande, contrasto alto: si lavora in movimento, con luce variabile.
   - Un solo colore d'accento, il giallo segnaletica, usato solo per ciò che risponde al tocco. */

:root {
  --ink: #15202B;
  --paper: #F3F5F6;
  --card: #FFFFFF;
  --line: #CBD3D9;
  --muted: #55646F;
  --signal: #FFC20E;
  --signal-ink: #1D1600;
  --ok: #177A43;
  --bad: #B3261E;
  --radius: 16px;
  --gap: 12px;
  font-family: Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 18px;
  line-height: 1.3;
  color: var(--ink);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--paper);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 4px solid var(--ink); outline-offset: 2px; }

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}
.body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px 16px 0;
}

/* Barra in alto: poco più di una riga, solo informazioni e il blocco */
.bar {
  background: var(--ink);
  color: #fff;
  min-height: calc(64px + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 16px 0;
  display: flex;
  align-items: center;
  gap: 12px;
}
.bar .who { flex: 1; min-width: 0; }
.bar .name { font-size: 20px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .role { font-size: 14px; opacity: .8; }
.bar .title { flex: 1; font-size: 20px; font-weight: 700; }

.chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600;
  padding: 6px 12px; border-radius: 999px;
  background: rgba(255,255,255,.14);
}
.chip::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: #4ADE80; }
.chip.off { background: var(--signal); color: var(--signal-ink); }
.chip.off::before { background: var(--signal-ink); }

.lock {
  min-height: 48px; padding: 0 16px;
  border: 2px solid rgba(255,255,255,.7); border-radius: 12px;
  background: transparent; color: #fff; font-weight: 700;
}

/* Home: i quattro compiti, ancorati in basso */
.tiles {
  margin-top: auto;
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap);
}
.tile {
  min-height: 150px;
  display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start;
  padding: 16px; text-align: left;
  background: var(--card);
  border: 2px solid var(--ink); border-radius: var(--radius);
}
.tile svg { width: 44px; height: 44px; }
.tile span { font-size: 22px; font-weight: 700; line-height: 1.15; }
.tile:active { background: var(--signal); color: var(--signal-ink); }

/* Pagina di compito (segnaposto) */
.empty { margin: auto 0; }
.empty h2 { font-size: 26px; margin: 0 0 8px; }
.empty p { margin: 0; color: var(--muted); font-size: 18px; }
.primary {
  width: 100%; min-height: 72px; margin-top: var(--gap);
  border: 2px solid var(--ink); border-radius: var(--radius);
  background: var(--signal); color: var(--signal-ink);
  font-size: 22px; font-weight: 700;
}
.primary:active { background: var(--ink); color: #fff; }

/* PIN */
.pin-top { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 20px; }
.pin-top h1 { margin: 0; font-size: 28px; }
.dots { display: flex; gap: 14px; }
.dot { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--ink); background: transparent; }
.dot.on { background: var(--ink); }
.dots.bad .dot { border-color: var(--bad); }
.dots.bad .dot.on { background: var(--bad); }
.dots.bad { animation: shake .35s; }
.msg { min-height: 48px; margin: 0; font-size: 18px; font-weight: 600; color: var(--muted); max-width: 20em; }
.msg.bad { color: var(--bad); }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 0 16px; }
.key {
  min-height: 72px;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  font-size: 32px; font-weight: 600; font-variant-numeric: tabular-nums;
  display: flex; align-items: center; justify-content: center;
}
.key.aux { font-size: 17px; font-weight: 700; background: transparent; border-color: transparent; }
.key svg { width: 32px; height: 32px; }
.key:active { background: var(--signal); border-color: var(--ink); color: var(--signal-ink); }
.keypad[aria-busy="true"] .key { opacity: .45; pointer-events: none; }

@keyframes shake {
  20% { transform: translateX(-10px); } 40% { transform: translateX(10px); }
  60% { transform: translateX(-6px); } 80% { transform: translateX(6px); }
}
@media (prefers-reduced-motion: reduce) { .dots.bad { animation: none; } }
@media (max-height: 640px) { .key { min-height: 60px; font-size: 28px; } .tile { min-height: 120px; } }
