:root {
  color-scheme: dark;
  --bg: #0b1626;
  --panel: #132339;
  --line: #30455f;
  --text: #f7f9ff;
  --muted: #a9bad0;
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(ellipse at 70% 0%, #172b45 0%, transparent 52%), var(--bg); }
main { width: min(100%, 520px); margin: 0 auto; padding: calc(env(safe-area-inset-top) + 18px) clamp(12px, 3.8vw, 20px) calc(env(safe-area-inset-bottom) + 24px); }
header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 18px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(20px, 5.2vw, 25px); letter-spacing: -.045em; font-weight: 850; line-height: 1.1; }
.subtitle { margin-top: 6px; border-left: 3px solid #bc71ec; padding-left: 7px; color: #bed0e5; text-transform: uppercase; font-size: 11px; font-weight: 740; letter-spacing: .085em; }
#today { max-width: 90px; text-align: right; color: #b6c8dd; font-size: 12px; }
button { font: inherit; font-weight: 650; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible, #recent-title:focus-visible { outline: 3px solid white; outline-offset: 3px; }
button:active:enabled { filter: brightness(1.14); }
button:disabled { opacity: .43; cursor: default; }
[hidden] { display: none !important; }
.counters, .correction-buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(5px, 1.6vw, 9px); }
.coppie { --tone: #fa80ce; --base: #322036; }
.singoli { --tone: #45d5f7; --base: #113345; }
.singole { --tone: #8af3ae; --base: #15382e; }
.tile { display: grid; gap: 6px; padding: 12px clamp(4px, 1.2vw, 8px) 7px; text-align: center; border: 1px solid var(--tone); border-radius: 14px; background: linear-gradient(160deg, var(--base), #101e2d); }
.tile h2 { font-size: clamp(12px, 3.25vw, 16px); font-weight: 780; letter-spacing: .05em; text-transform: uppercase; color: var(--tone); }
output { font-variant-numeric: tabular-nums; }
.tile output { font-weight: 750; font-size: clamp(33px, 9vw, 47px); letter-spacing: -.04em; line-height: 1.1; }
.tile button, .correction-buttons button { min-width: 0; padding: 8px 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; line-height: 1.05; border-radius: 12px; }
.tile button { min-height: 96px; border: 0; background: var(--tone); color: #0a1623; font-size: clamp(13px, 3.65vw, 18px); font-weight: 800; text-transform: uppercase; }
.tile button b { font-size: clamp(38px, 11vw, 52px); font-weight: 850; }
.tile p { align-self: center; color: var(--muted); font-size: 11px; }
.tile p output { color: var(--tone); font-size: 14px; margin-left: 2px; }
.total, .camera-head, .camera-title { display: flex; align-items: center; }
.total, .camera-head { justify-content: space-between; }
.total { padding: 13px 15px; margin: 11px 0; background: var(--panel); border: 1px solid var(--line); border-radius: 13px; }
.total span { font-weight: 740; font-size: 11px; letter-spacing: .09em; text-transform: uppercase; }
.total output { font-weight: 770; font-size: 26px; line-height: 1; }
.scan { width: 100%; padding: 16px 8px; min-height: 68px; border: 1px solid #ffce68; border-radius: 14px; background: linear-gradient(120deg, #ffc857, #ffaa34); color: #25190b; display: flex; justify-content: center; align-items: center; gap: 10px; text-transform: uppercase; font-size: clamp(15px, 4vw, 18px); font-weight: 800; }
.scan-icon { border: 2px dashed currentColor; border-radius: 4px; display: grid; place-items: center; width: 23px; height: 23px; font: bold 18px/1 monospace; }
#status, .camera-hint { color: #becde0; font-size: 13px; }
#status:not(:empty) { padding: 10px 0; text-align: center; }
#recent { margin: 8px 0 0; padding: 0; list-style: none; background: #102034; border: 1px solid var(--line); border-radius: 13px; max-height: 134px; overflow-y: auto; }
#recent li { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 9px 13px; }
#recent li + li { border-top: 1px solid #273951; }
#recent .entry { display: flex; align-items: baseline; flex-wrap: wrap; column-gap: 8px; font-size: 14px; }
#recent small, #recent .empty { color: var(--muted); font-size: 12px; }
#recent .movement { color: var(--tone); font-weight: 740; }
.corrections { margin-top: 24px; }
.corrections h2 { margin-bottom: 10px; font-size: 20px; letter-spacing: -.025em; }
.correction-buttons button { min-height: 86px; background: #102033; border: 2px solid var(--tone); font-size: 15px; }
.correction-buttons b { font-size: 33px; font-weight: 790; }
.actions { margin-top: 20px; display: grid; gap: 10px; }
.actions button, #recent-title, #close-camera, #review { background: #192b40; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 14px; min-height: 44px; }
#recent-title { cursor: pointer; touch-action: manipulation; font-weight: 650; line-height: 26px; }
.actions button { display: flex; align-items: center; gap: 12px; text-align: left; }
.actions svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#camera { background: #101f32; border: 1px solid #3c516a; border-radius: 15px; overflow: hidden; }
.camera-head { min-height: 54px; padding: 4px 8px 4px 14px; gap: 8px; }
.camera-title { gap: 8px; }
.camera-title h2 { font-size: 17px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #ffc857; }
#close-camera { padding: 6px 12px; }
#reader { width: 100%; min-height: 160px; background: #060c14; overflow: hidden; }
#reader video { display: block; }
.camera-hint { padding: 12px 14px; min-height: 44px; }

#camera.closing { position: absolute; visibility: hidden; pointer-events: none; }

#connecting { color: var(--muted); font-size: 13px; margin-top: 8px; }
.session-row { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 12px; font-size: 12px; color: var(--muted); }
#sync { color: #a4e7bc; text-align: right; }
#sync[data-stale] { color: #ffd482; }
#review { width: 100%; margin: 0 0 12px; }
footer { margin-top: 20px; text-align: center; color: var(--muted); font-size: 12px; }
