:root { --page:#f1f4f2; --text:#1b2326; --accent:#0b51c2; --alu:#b7bdc0; --alu-d:#6f777b; --red:#bf3a2d; --amber:#f3b53f;
  --font:"Helvetica Neue", Arial, sans-serif; }
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--alu-d); font-family: var(--font); font-size: 18px; color: var(--text); }
body { display: flex; justify-content: center; }
#app { width: 100%; max-width: 420px; min-height: 100dvh; display: flex; }
#app.wide { max-width: 960px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* corpo di alluminio spazzolato: gradienti, righe orizzontali, due viti per lato, graffi sottili */
.body { position: relative; flex: 1; display: flex; flex-direction: column; gap: 14px; padding: 34px 22px 24px;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,.10) 0 1px, rgba(0,0,0,.05) 1px 2px, rgba(255,255,255,.03) 2px 4px),
    linear-gradient(180deg, #c6ccce 0%, var(--alu) 40%, #a9b0b3 100%);
  box-shadow: inset 0 0 0 2px rgba(111,119,123,.55), inset 0 2px 6px rgba(255,255,255,.5); }
.body::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background:
    linear-gradient(97deg, transparent 0 18%, rgba(255,255,255,.35) 18.1% 18.2%, transparent 18.3%) 0 86% / 60% 1px no-repeat,
    linear-gradient(176deg, transparent 0 40%, rgba(0,0,0,.18) 40.1% 40.3%, transparent 40.4%) 60% 92% / 40% 1px no-repeat,
    linear-gradient(88deg, transparent 0 10%, rgba(255,255,255,.4) 10.1% 10.3%, transparent 10.4%) 10% 74% / 50% 1px no-repeat,
    linear-gradient(101deg, transparent 0 55%, rgba(0,0,0,.15) 55.1% 55.3%, transparent 55.4%) 40% 63% / 45% 1px no-repeat,
    linear-gradient(92deg, transparent 0 30%, rgba(255,255,255,.35) 30.1% 30.3%, transparent 30.4%) 70% 97% / 30% 1px no-repeat; }
.screw { position: absolute; width: 14px; height: 14px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 35% 30%, #e8ecee, #9aa2a6 55%, var(--alu-d)); box-shadow: inset 0 -1px 2px rgba(0,0,0,.35), 0 1px 0 rgba(255,255,255,.5); }
.screw::after { content: ""; position: absolute; left: 2px; right: 2px; top: 6px; height: 2px; background: rgba(40,48,52,.65); transform: rotate(var(--r, 35deg)); }
.screw.a { top: 10px; left: 10px; } .screw.b { top: 10px; right: 10px; --r: -20deg; }
.screw.c { bottom: 10px; left: 10px; --r: 80deg; } .screw.d { bottom: 10px; right: 10px; --r: 15deg; }
.plate { align-self: center; padding: 8px 18px; border-radius: 8px; background: linear-gradient(180deg, #d4d9db, #aab1b4); box-shadow: inset 0 1px 0 #fff8, 0 1px 3px rgba(0,0,0,.3); }
.plate img { display: block; height: 40px; width: auto; max-width: 220px; }

/* lo schermo e' il quadrante */
.screen { position: relative; border-radius: 16px; padding: 18px 16px; background: var(--page); color: var(--text);
  box-shadow: inset 0 3px 10px rgba(0,0,0,.35), 0 1px 0 rgba(255,255,255,.5); transition: background-color 60s linear, color 60s linear; overflow: hidden; }
.screen::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(135deg, rgba(255,255,255,.14), transparent 35%); }
.clock { font-size: clamp(96px, 28vw, 118px); font-weight: 200; line-height: 1.05; text-align: center; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.who { text-align: center; font-size: 22px; margin: 2px 0 12px; }
h1, h2 { font-weight: 500; margin: 0 0 8px; } h1 { font-size: 22px; } h2 { font-size: 18px; }
.muted { opacity: .75; }

/* pulsanti nel metallo */
.btn { display: block; width: 100%; min-height: 56px; border: 0; border-radius: 12px; padding: 12px 18px; font: inherit; font-weight: 600; cursor: pointer;
  color: var(--text); background: linear-gradient(180deg, #dfe3e5, #b4bbbe); box-shadow: 0 2px 0 var(--alu-d), 0 3px 6px rgba(0,0,0,.3), inset 0 1px 0 #fff9;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.btn:active, .btn.down { transform: translateY(2px); box-shadow: 0 0 0 var(--alu-d), inset 0 2px 5px rgba(0,0,0,.3); }
.btn.big { min-height: 64px; font-size: 22px; color: #fff; background: linear-gradient(180deg, #1c6ae0, var(--accent) 60%, #0a449f); box-shadow: 0 2px 0 #072f70, 0 3px 6px rgba(0,0,0,.35), inset 0 1px 0 #fff5; }
.btn.big.holdable { padding-top: 26px; touch-action: none; }
.btn.small { min-height: 56px; margin-top: 10px; }
.btn[disabled] { opacity: .5; cursor: default; }
.lights { position: absolute; left: 14px; right: 14px; top: 8px; display: flex; gap: 6px; height: 10px; pointer-events: none; }
.lights i { flex: 1; border-radius: 5px; background: rgba(0,0,0,.35); position: relative; overflow: hidden; }
.lights i::before { content: ""; position: absolute; inset: 0; background: #fff; border-radius: 5px; opacity: var(--f, 0); transform-origin: left; transform: scaleX(var(--f, 0));
  box-shadow: 0 0 calc(var(--f, 0) * 10px) calc(var(--f, 0) * 3px) #8fc0ff; }
.lights.fading i::before { transition: opacity .3s, transform .3s; opacity: 0; box-shadow: none; }
.bar { display: none; }
.calm .lights { display: none; } .calm .bar { display: block; position: absolute; left: 14px; right: 14px; top: 8px; height: 8px; border-radius: 4px; background: rgba(0,0,0,.35); overflow: hidden; pointer-events: none; }
.calm .bar::before { content: ""; display: block; height: 100%; width: calc(var(--p, 0) * 100%); background: #fff; }
.btn.big { position: relative; }

/* scheda di carta con timbri d'inchiostro */
.card { margin: 10px 0 14px; padding: 12px 14px; border-radius: 6px; background: #fffdf7; color: #1b2326; box-shadow: 0 2px 6px rgba(0,0,0,.25); border-top: 4px solid var(--accent); }
.card .date { font-size: 16px; letter-spacing: .04em; text-transform: uppercase; opacity: .7; margin-bottom: 6px; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 5px 0; border-bottom: 1px dashed rgba(27,35,38,.25); }
.row:last-child { border-bottom: 0; }
.stamp { display: inline-block; padding: 1px 10px; border: 2px solid #1a3f86; color: #1a3f86; border-radius: 4px; font-weight: 700; font-variant-numeric: tabular-nums;
  transform: rotate(var(--rot, -2deg)); opacity: .88; text-shadow: 0 0 1px rgba(26,63,134,.4); }
.stamp.land { animation: land .3s ease-out; }
@keyframes land { from { transform: translateY(-16px) rotate(var(--rot, -2deg)) scale(1.4); opacity: 0; } to { transform: rotate(var(--rot, -2deg)); opacity: .88; } }
.unsent { font-size: 14px; color: #7a4a00; }
.confirm { min-height: 1.5em; margin: 8px 0 12px; text-align: center; font-size: 18px; }
.confirm.show { animation: fadein .3s; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.band { display: block; width: 100%; margin: 0 0 12px; padding: 12px 14px; border: 0; border-radius: 8px; background: var(--amber); color: #1b2326; font: inherit; font-weight: 600; text-align: left; cursor: pointer; }

/* tastierino e punti del codice */
.dots { display: flex; justify-content: center; gap: 16px; margin: 14px 0; }
.dots i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; }
.dots i.on { background: currentColor; }
.shake { animation: shake .4s; }
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-9px); } 40% { transform: translateX(9px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(6px); } }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pad .btn { min-height: 56px; font-size: 24px; }
.list { display: flex; flex-direction: column; gap: 10px; }
.link { background: none; border: 0; padding: 10px 4px; min-height: 44px; font: inherit; color: inherit; text-decoration: underline; cursor: pointer; }
.nav { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; }
input.field { width: 100%; min-height: 56px; padding: 10px 14px; font: inherit; font-size: 22px; letter-spacing: .15em; text-transform: uppercase; border-radius: 10px; border: 2px solid var(--alu-d); background: #fff; color: #1b2326; }
.err { color: var(--red); } .screen .err { font-weight: 600; }
.switch { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.switch button { min-width: 52px; min-height: 44px; border-radius: 22px; border: 2px solid var(--alu-d); background: #fff; font: inherit; cursor: pointer; color: #1b2326; }
.switch button[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }

/* tabelle del titolare */
.wide .screen { padding: 22px 26px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 9px 6px; border-bottom: 1px solid rgba(127,140,145,.4); }
tr.open { cursor: pointer; } tr.open:hover td, tr.open:focus-visible td { background: rgba(11,81,194,.08); }
.flag { color: var(--red); font-weight: 600; }
.calm * { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } .lights { display: none; } .bar { display: block; position: absolute; left: 14px; right: 14px; top: 8px; height: 8px; border-radius: 4px; background: rgba(0,0,0,.35); overflow: hidden; pointer-events: none; } .bar::before { content: ""; display: block; height: 100%; width: calc(var(--p, 0) * 100%); background: #fff; } }
@media (min-width: 600px) { body { padding: 24px 0; align-items: flex-start; } .body { border-radius: 22px; min-height: 0; } #app { min-height: 0; } }

/* anteprima provvisoria: barra fissa in alto, sempre visibile (contrasto bianco su #8a1c1c = 8.6:1) */
.preview { position: fixed; top: 0; left: 0; right: 0; z-index: 50; padding: 6px 10px; background: #8a1c1c; color: #fff; font: 700 13px/1.3 system-ui, sans-serif; text-align: center; letter-spacing: .02em; }
body.has-preview { padding-top: 30px; }
