/* Layout: app iOS a schede. Titoli grandi in Bodoni che si comprimono nella barra allo scorrere, liste raggruppate,
   barra delle schede in basso. Su desktop l'app è mostrata dentro una cornice di iPhone; su telefono occupa lo schermo. */
:root{
  --paper:#eef1f5; --sheet:#ffffff; --ink:#1b1f2e; --muted:#6b7286; --rule:#d9dde6;
  --stamp:#2b44a3; --stamp-ink:#ffffff; --stamp-soft:#e4e8f7;
  --red:#b02a20; --red-soft:#f8e4e1; --amber:#875700; --amber-soft:#f7eed9; --green:#22704a; --green-soft:#e0f0e6;
  --bar:rgba(246,247,250,.95); --bezel:#1d1f26; --stage:#dfe3ea;
  --f-display:"Bodoni Moda", "Didot", "Bodoni 72", Georgia, serif;
  --f-body:-apple-system, BlinkMacSystemFont, "Figtree", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]){
  --paper:#0f1117; --sheet:#1b1e28; --ink:#e9ebf1; --muted:#9aa1b5; --rule:#2c3142;
  --stamp:#9aabf2; --stamp-ink:#12141c; --stamp-soft:#232a45;
  --red:#f08a80; --red-soft:#3a1f1d; --amber:#e2b354; --amber-soft:#33291a; --green:#7cc79f; --green-soft:#172d21;
  --bar:rgba(22,24,32,.95); --bezel:#000000; --stage:#171a22;
  color-scheme:dark }}
:root[data-theme="dark"]{
  --paper:#0f1117; --sheet:#1b1e28; --ink:#e9ebf1; --muted:#9aa1b5; --rule:#2c3142;
  --stamp:#9aabf2; --stamp-ink:#12141c; --stamp-soft:#232a45;
  --red:#f08a80; --red-soft:#3a1f1d; --amber:#e2b354; --amber-soft:#33291a; --green:#7cc79f; --green-soft:#172d21;
  --bar:rgba(22,24,32,.95); --bezel:#000000; --stage:#171a22;
  color-scheme:dark }

*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
[hidden]{display:none!important}
html,body{height:100%}
body{margin:0;background:var(--stage);color:var(--ink);font-family:var(--f-body);font-size:17px;line-height:1.35;font-variant-numeric:tabular-nums;
  padding-left:max(16px, env(safe-area-inset-left, 0px));padding-right:max(16px, env(safe-area-inset-right, 0px));padding-block:24px}
h1,h2,h3,p{margin:0}
button,input,select{font:inherit;color:inherit}
:focus-visible{outline:2px solid var(--stamp);outline-offset:2px;border-radius:6px}

/* Palco desktop */
.stage{min-height:100%;display:flex;align-items:center;justify-content:center;gap:56px;flex-wrap:wrap}
.caption{max-width:340px;display:flex;flex-direction:column;gap:12px}
.caption h1{font-family:var(--f-display);font-weight:700;font-size:2.4rem;line-height:1.05;letter-spacing:-.01em}
.caption p{color:var(--muted);font-size:1rem;line-height:1.5}
.caption a{color:var(--stamp);font-weight:600}

/* Bodoni piccolo: taglio ottico robusto, i filetti sottili sparirebbero */
.vh,.phh .no,.dd b,.prog b,.tot b{font-optical-sizing:none}

/* Telefono */
.device{--sat:54px;--sab:22px;--sal:0px;--sar:0px;position:relative;width:393px;height:852px;max-width:100%;border-radius:58px;background:var(--bezel);padding:12px;flex:none;
  box-shadow:0 30px 60px -20px rgba(15,20,40,.35)}
.screen{position:relative;width:100%;height:100%;border-radius:46px;overflow:hidden;background:var(--paper)}
.island{position:absolute;top:11px;left:50%;transform:translateX(-50%);width:120px;height:35px;border-radius:20px;background:#000;z-index:30}
.status{position:absolute;top:0;left:0;right:0;height:var(--sat);display:flex;justify-content:space-between;align-items:center;padding:6px 34px 0 44px;font-weight:600;font-size:16px;z-index:25;pointer-events:none}
.status svg{height:12px;width:auto}
.scroll{position:absolute;inset:0;overflow-y:auto;overscroll-behavior:contain;padding:calc(var(--sat) + 44px) calc(16px + var(--sar)) calc(var(--sab) + 92px) calc(16px + var(--sal));scrollbar-width:none}
.scroll::-webkit-scrollbar{display:none}

/* Barra di navigazione compatta */
.nav{position:absolute;top:0;left:0;right:0;z-index:20;padding:var(--sat) 16px 0;height:calc(var(--sat) + 44px);display:flex;align-items:center;justify-content:center;
  background:transparent;border-bottom:.5px solid transparent;transition:background .2s,border-color .2s}
.nav.solid{background:var(--bar);-webkit-backdrop-filter:saturate(180%) blur(20px);backdrop-filter:saturate(180%) blur(20px);border-bottom-color:var(--rule)}
.nav b{font-size:17px;font-weight:600;opacity:0;transition:opacity .2s}
.nav.solid b{opacity:1}

/* Schermate */
.view{display:flex;flex-direction:column;gap:22px}
.lt{font-family:var(--f-display);font-weight:700;font-size:34px;line-height:1.05;letter-spacing:-.01em}
.sub{color:var(--muted);font-size:15px;margin-top:4px}
.group{display:flex;flex-direction:column;gap:7px}
.gh{font-size:13px;color:var(--muted);padding:0 16px}
.gf{font-size:13px;color:var(--muted);padding:0 16px;line-height:1.4}
.gf a{color:var(--stamp)}
.proto{background:var(--stamp-soft);border-radius:12px;padding:10px 14px;font-size:13px;line-height:1.4}
.cell-btn{border:0;background:none;width:100%;color:var(--stamp);cursor:pointer;text-align:left}
.phases{display:flex;flex-direction:column;gap:20px}
.fine{font-size:.88rem}
.list{background:var(--sheet);border-radius:12px;overflow:hidden}
.cell{display:flex;align-items:center;gap:12px;padding:11px 16px;min-height:44px;position:relative}
.cell + .cell::before{content:"";position:absolute;top:0;left:16px;right:0;border-top:.5px solid var(--rule)}
.cell .txt{flex:1;min-width:0}
.cell small{display:block;color:var(--muted);font-size:13px;margin-top:2px;line-height:1.3}

/* Controllo segmentato */
.segm{display:grid;grid-auto-flow:column;grid-auto-columns:1fr;background:var(--rule);border-radius:9px;padding:2px}
.segm button{border:0;background:transparent;border-radius:7px;padding:6px 0;font-size:14px;font-weight:600;cursor:pointer;color:var(--ink)}
.segm button[aria-pressed="true"]{background:var(--sheet);box-shadow:0 2px 6px rgba(0,0,0,.12)}

/* Verdetto */
.card{background:var(--sheet);border-radius:16px;padding:16px;display:flex;flex-direction:column;gap:12px}
.pill{display:inline-flex;align-items:center;gap:7px;font-weight:700;font-size:13px;padding:4px 10px 4px 8px;border-radius:999px;align-self:flex-start}
.pill i{width:8px;height:8px;border-radius:50%;background:currentColor}
.pill.r{color:var(--red);background:var(--red-soft)} .pill.y{color:var(--amber);background:var(--amber-soft)} .pill.g{color:var(--green);background:var(--green-soft)}
.vh{font-family:var(--f-display);font-weight:700;font-size:25px;line-height:1.1}
.mk{width:22px;height:22px;border-radius:50%;display:grid;place-items:center;font-size:12px;font-weight:700;flex:none;align-self:flex-start;margin-top:1px}
.mk.d::before{content:"";width:8px;height:8px;border-radius:50%;background:currentColor}
.mk.r{color:var(--red)} .mk.y{color:var(--amber)} .mk.g{color:var(--green)}

/* Interruttore iOS */
.sw{appearance:none;width:51px;height:31px;border-radius:999px;background:var(--rule);position:relative;cursor:pointer;flex:none;transition:background .2s}
.sw::after{content:"";position:absolute;top:2px;left:2px;width:27px;height:27px;border-radius:50%;background:#fff;box-shadow:0 2px 4px rgba(0,0,0,.2);transition:transform .2s}
.sw:checked{background:var(--stamp)}
.sw:checked::after{transform:translateX(20px)}

/* Checklist */
.prog{display:flex;align-items:center;gap:12px}
.prog b{font-family:var(--f-display);font-size:28px;font-weight:700;line-height:1}
.prog .bar{flex:1;height:5px;border-radius:3px;background:var(--rule);overflow:hidden}
.prog .bar i{display:block;height:100%;background:var(--stamp);transition:width .25s}
.phh{display:flex;align-items:center;gap:10px;width:100%;border:0;background:none;padding:0 16px;cursor:pointer;text-align:left}
.phh .no{font-family:var(--f-display);font-size:22px;font-weight:700;color:var(--stamp);width:22px}
.phh .nm{flex:1;font-weight:700;font-size:17px}
.phh .ct{color:var(--muted);font-size:14px}
.phh .ch{color:var(--muted);transition:transform .2s;display:inline-block}
.phh[aria-expanded="true"] .ch{transform:rotate(90deg)}
.ckc{align-items:flex-start;cursor:pointer}
.circ{width:24px;height:24px;border-radius:50%;border:1.5px solid var(--muted);flex:none;display:grid;place-items:center;margin-top:1px;transition:background .15s,border-color .15s}
.done .circ{background:var(--stamp);border-color:var(--stamp)}
.done .circ::after{content:"";width:10px;height:5px;border-left:2px solid var(--stamp-ink);border-bottom:2px solid var(--stamp-ink);transform:rotate(-45deg) translate(1px,-1px)}
.done .ttl{color:var(--muted);text-decoration:line-through;text-decoration-color:var(--rule)}
.meta{display:flex;flex-wrap:wrap;gap:3px 10px;font-size:12px;color:var(--muted);margin-top:4px;align-items:center}
.meta span{display:inline-flex;align-items:center;gap:5px}
.lv{width:7px;height:7px;border-radius:50%;display:inline-block}
.lv.r{background:var(--red)} .lv.y{background:var(--amber)} .lv.g{background:var(--green)}
.ver{border-bottom:1px dotted var(--muted)}

/* Scadenze */
.cell input[type="date"],.cell input[type="number"],.cell select{border:0;background:transparent;text-align:right;color:var(--stamp);font-size:17px;min-width:0;width:150px;padding:0}
.cell select{width:auto;direction:rtl}
.ev{align-items:flex-start}
.dd{width:46px;flex:none;display:flex;flex-direction:column;align-items:center;line-height:1}
.dd b{font-family:var(--f-display);font-size:24px;font-weight:700}
.dd span{font-size:11px;color:var(--muted);margin-top:3px;text-transform:lowercase}
.ev .rel{font-size:13px;color:var(--muted);white-space:nowrap}
.ev.past{opacity:.55}
.ev.soon .rel{color:var(--amber);font-weight:600}
.ev.late .rel,.ev.late .dd b{color:var(--red)}
.ev.key .dd b{color:var(--stamp)}

/* Calcoli */
.tot{display:flex;justify-content:space-between;align-items:baseline}
.tot b{font-family:var(--f-display);font-size:30px;font-weight:700}
.cell .v{color:var(--muted)}

/* Barra delle schede */
.tabbar{position:absolute;left:0;right:0;bottom:0;z-index:20;display:grid;grid-template-columns:repeat(4,1fr);padding:7px calc(8px + var(--sar)) calc(var(--sab) + 4px) calc(8px + var(--sal));
  background:var(--bar);-webkit-backdrop-filter:saturate(180%) blur(20px);backdrop-filter:saturate(180%) blur(20px);border-top:.5px solid var(--rule)}
.tabbar button{border:0;background:none;display:flex;flex-direction:column;align-items:center;gap:3px;font-size:10.5px;font-weight:600;color:var(--muted);cursor:pointer;padding:2px 0}
.tabbar svg{width:26px;height:26px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.tabbar button[aria-current="page"]{color:var(--stamp)}

/* Su telefono: app a tutto schermo */
@media (max-width:600px), (pointer:coarse) and (max-height:500px){
  body{padding:0}
  .stage{display:block}
  .caption,.island,.status{display:none}
  .device{position:fixed;inset:0;width:auto;height:auto;border-radius:0;padding:0;box-shadow:none;background:var(--paper);
    --sat:env(safe-area-inset-top, 0px);--sab:env(safe-area-inset-bottom, 0px);--sal:env(safe-area-inset-left, 0px);--sar:env(safe-area-inset-right, 0px)}
  .screen{border-radius:0}
}
@media (prefers-reduced-motion:reduce){ *{transition:none!important} }
