:root {
  --bg: #f3f4f6; --card: #fff; --ink: #111827; --muted: #6b7280; --line: #e5e7eb;
  --brand: #0f2a44; --green: #15803d; --amber: #b45309; --blue: #1d4ed8; --red: #b91c1c;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); line-height: 1.4; }
header { background: var(--brand); color: #fff; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
header h1 { font-size: 18px; margin: 0; }
main { max-width: 900px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border-radius: 14px; padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.muted { color: var(--muted); font-size: 14px; }
.big { font-size: 28px; font-weight: 700; }
.clock { font-size: 44px; font-weight: 700; letter-spacing: 1px; font-variant-numeric: tabular-nums; }
button, .btn { font: inherit; border: 0; border-radius: 12px; padding: 12px 16px; cursor: pointer; background: var(--brand); color: #fff; font-weight: 600; text-decoration: none; display: inline-block; text-align: center; }
button:disabled { opacity: .5; cursor: default; }
button.ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); }
button.small { padding: 6px 10px; font-size: 14px; border-radius: 8px; }
button.danger { background: var(--red); }
.actions { display: grid; gap: 12px; }
.act { font-size: 22px; padding: 22px; border-radius: 16px; width: 100%; }
.act.entrata { background: var(--green); }
.act.pausa_inizio { background: var(--amber); }
.act.pausa_fine { background: var(--blue); }
.act.uscita { background: var(--red); }
.msg { padding: 12px 14px; border-radius: 10px; margin-bottom: 12px; font-weight: 600; }
.msg.ok { background: #dcfce7; color: #14532d; }
.msg.err { background: #fee2e2; color: #7f1d1d; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.dentro { background: #dcfce7; color: #14532d; }
.badge.pausa { background: #fef3c7; color: #78350f; }
.badge.fuori { background: #e5e7eb; color: #374151; }
.badge.warn { background: #fee2e2; color: #7f1d1d; }
label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
input, select { font: inherit; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1 1 140px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.tabs button { background: transparent; color: var(--muted); padding: 8px 12px; white-space: nowrap; }
.tabs button.on { background: var(--brand); color: #fff; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.off td { color: #9ca3af; }
tr.sun td { background: #fafafa; }
tr.bad td { background: #fef2f2; }
td { font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }
.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.totals div { background: var(--bg); border-radius: 10px; padding: 10px; }
.totals b { display: block; font-size: 20px; }
.hidden { display: none !important; }
dialog { border: 0; border-radius: 14px; padding: 18px; width: min(460px, 94vw); }
dialog::backdrop { background: rgba(0,0,0,.4); }
.qr { display: block; margin: 10px auto; width: 240px; height: 240px; }
.copy { word-break: break-all; font-size: 13px; background: var(--bg); padding: 8px; border-radius: 8px; }
