/* Moto Bizzotto · App interna — stile minimal scuro */
:root {
  --bg: #000000; --s1: #141416; --s2: #1C1D20; --line: #1F2023; --line2: #2A2B2E;
  --tx: #F5F5F7; --tx2: #A1A1A6; --tx3: #8A8A90; --red: #E30613; --link: #8AB4F8;
  --ok: #86EFAC; --okbg: rgba(74,222,128,.12); --warn: #FDBA74; --warnbg: rgba(251,146,60,.12);
  --bad: #FCA5A5; --badbg: rgba(248,113,113,.12); --info: #C9DCFF; --infobg: rgba(138,180,248,.12);
  --pur: #E9D5FF; --purbg: rgba(192,132,252,.12); --grey: #D1D1D6; --greybg: rgba(255,255,255,.08);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--tx); font: 400 16px/1.4 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--link); }
::-webkit-scrollbar { width: 0; height: 0; }
.boot { min-height: 100vh; display: flex; align-items: center; justify-content: center; color: var(--tx2); }

/* Struttura */
.screen { max-width: 640px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; padding-top: var(--safe-t); }
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 12px 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.top .logo { width: 104px; height: auto; display: block; }
.top .title { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.top .title b { font-size: 17px; font-weight: 600; }
.top .title span { font-size: 13px; color: var(--tx2); }
.spacer { flex: 1; }
.body { flex: 1; padding: 16px 16px calc(110px + var(--safe-b)); display: flex; flex-direction: column; gap: 14px; }
.foot { position: sticky; bottom: 0; background: var(--bg); border-top: 1px solid var(--line); padding: 12px 16px calc(14px + var(--safe-b)); display: flex; gap: 10px; }

/* Elementi */
.ib { width: 40px; height: 40px; border: 0; border-radius: 20px; background: var(--s2); display: inline-flex; align-items: center; justify-content: center; position: relative; flex: 0 0 40px; }
.ib svg { width: 18px; height: 18px; stroke: var(--tx); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dot { position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.card { background: var(--s1); border: 1px solid #232427; border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.h2 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--tx2); }
.cap { font-size: 12px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--tx2); }
.muted { font-size: 13px; color: var(--tx2); }
.small { font-size: 12px; color: var(--tx3); }
.lbl { display: flex; flex-direction: column; gap: 8px; font-size: 12px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--tx2); }
.in { width: 100%; min-height: 48px; padding: 12px 14px; border: 1px solid var(--line2); border-radius: 12px; background: var(--s2); color: var(--tx); font-size: 16px; text-transform: none; letter-spacing: 0; }
.in:focus { outline: none; border-color: var(--tx3); }
.in::placeholder { color: var(--tx3); }
textarea.in { resize: vertical; }
.bp { min-height: 54px; border: 0; border-radius: 14px; background: var(--tx); color: #0B0B0C; font-weight: 600; font-size: 16px; padding: 0 18px; }
.bp:disabled { opacity: .5; }
.bs { min-height: 50px; border: 1px solid var(--line2); border-radius: 14px; background: var(--s2); color: var(--tx); font-weight: 600; font-size: 15px; padding: 0 16px; }
.bs.danger { color: #F87171; border-color: rgba(248,113,113,.4); }
.bs.blue { color: var(--link); }
.bl { min-height: 44px; border: 0; background: transparent; color: var(--link); font-weight: 600; font-size: 15px; }
.full { width: 100%; }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.pills { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.pill { min-height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--line2); background: transparent; color: var(--grey); font-size: 13px; font-weight: 600; white-space: nowrap; flex: 0 0 auto; }
.pill.on { background: var(--tx); color: #0B0B0C; border-color: var(--tx); }
.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 999px; white-space: nowrap; }
.c-da { background: var(--warnbg); color: var(--warn); } .c-rim { background: rgba(251,146,60,.18); color: var(--warn); border: 1px solid rgba(251,146,60,.4); }
.c-val { background: var(--okbg); color: var(--ok); } .c-scad { background: var(--badbg); color: var(--bad); }
.c-rit { background: var(--infobg); color: var(--info); } .c-rif, .c-ann, .c-grey { background: var(--greybg); color: var(--grey); }
.c-pur { background: var(--purbg); color: var(--pur); border: 1px solid rgba(192,132,252,.45); }
.c-rip { background: rgba(255,255,255,.06); color: var(--tx); border: 1px solid #3A3B40; }
.note { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border-radius: 14px; font-size: 14px; }
.n-info { background: rgba(138,180,248,.08); border: 1px solid rgba(138,180,248,.3); color: var(--info); }
.n-warn { background: var(--warnbg); border: 1px solid rgba(251,146,60,.35); color: #FED7AA; }
.n-bad { background: var(--badbg); border: 1px solid rgba(248,113,113,.4); color: #FECACA; }
.n-ok { background: var(--okbg); border: 1px solid rgba(74,222,128,.35); color: #BBF7D0; }
.n-pur { background: var(--purbg); border: 1px solid rgba(192,132,252,.45); color: var(--pur); }
.n-grey { background: var(--greybg); border: 1px solid #3A3B40; color: var(--grey); }
.err { margin: 0; color: #F87171; font-size: 14px; font-weight: 500; white-space: pre-line; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--tx2); flex: 0 0 auto; }
.kv span:last-child { font-weight: 500; text-align: right; white-space: pre-line; }
.pre { white-space: pre-line; }

/* Elenco */
.search { display: flex; align-items: center; gap: 8px; background: var(--s2); border: 1px solid var(--line2); border-radius: 12px; padding: 0 12px; }
.search input { flex: 1; border: 0; outline: none; background: transparent; min-height: 46px; font-size: 16px; }
.item { text-align: left; width: 100%; background: var(--s1); border: 1px solid #232427; border-radius: 18px; padding: 16px; display: flex; flex-direction: column; gap: 10px; color: var(--tx); }
.item.dim { opacity: .72; }
.item .r1 { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.item .r1 b { font-size: 16px; font-weight: 600; display: block; }
.item .meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-top: 1px solid #222326; padding-top: 10px; font-size: 12px; color: var(--tx2); }
.price { font-size: 16px; font-weight: 700; color: #4ADE80; white-space: nowrap; }
.price.old { color: var(--tx2); text-decoration: line-through; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.fab { position: fixed; right: max(16px, calc(50% - 304px)); bottom: calc(24px + var(--safe-b)); min-height: 52px; padding: 0 20px; border: 0; border-radius: 26px; background: var(--tx); color: #0B0B0C; font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.6); z-index: 6; }
.empty { text-align: center; color: var(--tx2); padding: 32px 0; }

/* Home */
.home { background: #000; }
.big { display: flex; align-items: baseline; gap: 12px; }
.big b { font-size: 88px; font-weight: 200; line-height: .9; letter-spacing: -.04em; }
.big span { font-size: 17px; color: var(--tx2); white-space: pre-line; }
.bar { height: 3px; border-radius: 2px; background: var(--s2); overflow: hidden; }
.bar i { display: block; height: 3px; background: var(--red); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stats b { display: block; font-size: 22px; font-weight: 300; }
.stats span { font-size: 12px; color: var(--tx2); }
.mods { border-top: 1px solid var(--line); }
.mod { text-align: left; width: 100%; display: flex; align-items: center; gap: 14px; padding: 16px 0; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--tx); }
.mod.off { color: var(--tx3); cursor: default; }
.mod .ic { width: 44px; height: 44px; border-radius: 22px; background: var(--s1); display: flex; align-items: center; justify-content: center; flex: 0 0 44px; }
.mod .ic svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.mod .tx { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.mod .tx b { font-size: 17px; font-weight: 500; }
.mod .tx span { font-size: 13px; color: var(--tx2); }

/* Login */
.login { min-height: 100vh; background: #000; display: flex; flex-direction: column; max-width: 480px; margin: 0 auto; padding: calc(40px + var(--safe-t)) 20px 32px; gap: 16px; }
.login .hero { display: flex; flex-direction: column; align-items: center; gap: 18px; margin-bottom: 8px; }

/* Wizard */
.steps { height: 4px; border-radius: 2px; background: var(--s2); overflow: hidden; margin: 0 16px 0; }
.steps i { display: block; height: 4px; background: var(--red); }
.yn { display: flex; gap: 6px; }
.yn button { width: 64px; min-height: 44px; border-radius: 10px; border: 1px solid var(--line2); background: transparent; color: var(--grey); font-weight: 600; }
.yn button.on { background: var(--tx); color: #0B0B0C; border-color: var(--tx); }
.ynrow { display: flex; flex-direction: column; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.ynrow .h { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 16px; font-weight: 500; }
.choice { display: flex; gap: 8px; }
.choice button { flex: 1; min-height: 48px; border-radius: 12px; border: 1px solid var(--line2); background: transparent; color: var(--grey); font-weight: 600; }
.choice button.on { background: var(--tx); color: #0B0B0C; border-color: var(--tx); }

/* Foto */
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ph { position: relative; aspect-ratio: 1/1; border-radius: 12px; overflow: hidden; background: var(--s2); border: 0; padding: 0; }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph .x { position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border: 0; border-radius: 16px; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; }
.ph .x svg { width: 14px; height: 14px; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; fill: none; }
.add { aspect-ratio: 1/1; border: 1px dashed #3A3B40; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--tx); font-size: 13px; font-weight: 500; position: relative; background: var(--s1); cursor: pointer; }
.add input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.add svg { width: 26px; height: 26px; stroke: var(--tx); fill: none; stroke-width: 1.6; }

/* Overlay: dialoghi e foto grandi */
#overlay:empty { display: none; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 50; }
.modal .box { background: var(--s1); border: 1px solid var(--line2); border-radius: 18px; padding: 20px; width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 12px; }
.lightbox { position: fixed; inset: 0; background: #000; z-index: 60; display: flex; flex-direction: column; padding-top: var(--safe-t); }
.lightbox .lt { display: flex; justify-content: space-between; align-items: center; padding: 12px 12px 8px 16px; }
.lightbox .img { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 8px; }
.lightbox .img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox .lb { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px calc(24px + var(--safe-b)); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + var(--safe-b)); background: var(--tx); color: #0B0B0C; padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 14px; z-index: 70; max-width: 90vw; }
.busy { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 80; display: flex; align-items: center; justify-content: center; color: var(--tx); font-weight: 600; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
