/* Wildfire Gestionale — layout: barra laterale scura a sinistra (in alto su telefono), area di lavoro chiara */
:root {
  --bg: #f6f3f0; --surface: #ffffff; --sunk: #efeae5; --line: #e2d9d1; --line-strong: #cbbfb4;
  --fg: #1f1a17; --muted: #6f645c; --faint: #9a8e85;
  --ember: #c81e25; --ember-strong: #a3161c; --ember-soft: #fdeceb;
  --nav: #1d1714; --nav-fg: #e9e1da; --nav-muted: #a3958a; --nav-active: #2e2420;
  --ok: #2f7d4f; --ok-soft: #e7f4ec; --warn: #a16207; --warn-soft: #fdf3dc; --bad: #b42318; --bad-soft: #fdecea;
  --info: #2c5f8a; --info-soft: #e8f0f7;
  --r: 10px; --r-sm: 7px;
  --shadow: 0 1px 2px rgba(40, 25, 15, .06), 0 2px 8px rgba(40, 25, 15, .05);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15110f; --surface: #1e1916; --sunk: #191411; --line: #2f2723; --line-strong: #45392f;
    --fg: #efe8e2; --muted: #ab9e94; --faint: #7d7068;
    --ember: #ef4a50; --ember-strong: #f6787c; --ember-soft: #2e1415;
    --nav: #0f0c0a; --nav-fg: #e9e1da; --nav-muted: #8f8278; --nav-active: #241c18;
    --ok: #5cc28a; --ok-soft: #13271b; --warn: #e3b341; --warn-soft: #2a2310; --bad: #f2786d; --bad-soft: #2d1513;
    --info: #79aee0; --info-soft: #132230;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--ember); }
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 24px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.num, td.n, .money { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13px; }
.boot { padding: 40px; color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- struttura ---------- */
.shell { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: 100%; }
.nav { background: var(--nav); color: var(--nav-fg); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding-top: max(18px, env(safe-area-inset-top)); }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: #111; display: grid; place-items: center; flex: none; padding: 4px; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.brand-name { font-weight: 700; letter-spacing: .01em; }
.brand-sub { font-size: 12px; color: var(--nav-muted); }
.nav a { color: var(--nav-fg); text-decoration: none; padding: 9px 10px; border-radius: 8px; display: flex; gap: 10px; align-items: center; font-weight: 500; }
.nav a:hover { background: var(--nav-active); }
.nav a.active { background: var(--nav-active); box-shadow: inset 3px 0 0 #ee262c; }
.nav a svg { width: 18px; height: 18px; opacity: .85; flex: none; }
.nav .sep { height: 1px; background: #2c2420; margin: 10px 6px; }
.nav .who { margin-top: auto; padding: 12px 10px 4px; font-size: 13px; color: var(--nav-muted); display: flex; flex-direction: column; gap: 6px; }
.nav .who b { color: var(--nav-fg); font-weight: 600; }
.nav .who button { background: none; border: 1px solid #3a2f29; color: var(--nav-fg); border-radius: 7px; padding: 6px 10px; cursor: pointer; text-align: left; }
.main { min-width: 0; padding: 26px max(16px, env(safe-area-inset-right)) 60px max(28px, env(safe-area-inset-left)); max-width: 1320px; width: 100%; }
.topbar { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .nav { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .shell.menu-open .nav { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45); }
  .topbar { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 30; background: var(--nav); color: var(--nav-fg);
    padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left)); }
  .topbar button { background: none; border: 0; color: inherit; padding: 6px; cursor: pointer; display: grid; place-items: center; }
  .topbar .t { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .main { padding: 18px max(16px, env(safe-area-inset-right)) 80px max(16px, env(safe-area-inset-left)); }
}

/* ---------- elementi ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1050px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .g2, .g3 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 420px) { .g4 { grid-template-columns: minmax(0, 1fr); } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card.pad0 { padding: 0; }
.card > .card-head { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-bottom: 12px; flex-wrap: wrap; }
.card.pad0 > .card-head { padding: 14px 16px 0; }

.kpi .k { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.kpi .v { font-size: 25px; font-weight: 650; letter-spacing: -.01em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .d { font-size: 13px; color: var(--muted); margin-top: 2px; }
.kpi.alert { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); background: color-mix(in srgb, var(--bad-soft) 65%, var(--surface)); }
.kpi.alert .v { color: var(--bad); }
.kpi.warn .v { color: var(--warn); }

button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: var(--r-sm); border: 1px solid var(--line-strong);
  background: var(--surface); padding: 8px 14px; min-height: 38px; cursor: pointer; font-weight: 550; text-decoration: none; color: var(--fg); white-space: nowrap; }
button:hover, .btn:hover { border-color: var(--ember); }
button:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; }
button.primary, .btn.primary { background: var(--ember); border-color: var(--ember); color: #fff; }
button.primary:hover { background: var(--ember-strong); border-color: var(--ember-strong); }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover { background: var(--sunk); border-color: transparent; }
button.danger { color: var(--bad); }
button.big { min-height: 52px; font-size: 17px; padding: 10px 22px; }
button.sm { min-height: 30px; padding: 4px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { padding: 6px; min-height: 32px; min-width: 32px; }

label.f { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 500; min-width: 0; }
label.f.req > span::after { content: " *"; color: var(--ember); }
input, select, textarea { background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 8px 10px; min-height: 38px; color: var(--fg); min-width: 0; width: 100%; font-size: 15px; }
textarea { min-height: 76px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: auto; accent-color: var(--ember); }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--fg); }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-sm); overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; border-radius: 0; min-height: 40px; border-right: 1px solid var(--line); background: var(--surface); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--ember); color: #fff; }
.search { position: relative; }
.search input { padding-left: 34px; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--faint); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); }
td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.n, th.n { text-align: right; white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--sunk); }
td .t { font-weight: 550; }
td .s { font-size: 12.5px; color: var(--muted); }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--sunk); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.ember { background: var(--ember-soft); color: var(--ember); }
.empty { text-align: center; color: var(--muted); padding: 34px 16px; }
.empty h2 { color: var(--fg); margin-bottom: 6px; }
.note { background: var(--info-soft); color: var(--fg); border-radius: var(--r-sm); padding: 10px 12px; font-size: 14px; }
.note.warn { background: var(--warn-soft); }
.note.bad { background: var(--bad-soft); }

.bars { display: flex; align-items: flex-end; gap: 4px; height: 90px; padding-top: 6px; }
.bars .b { flex: 1; background: color-mix(in srgb, var(--ember) 70%, transparent); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.bars .b.today { background: var(--ember); }
.bars-x { display: flex; gap: 4px; font-size: 11px; color: var(--faint); margin-top: 4px; }
.bars-x span { flex: 1; text-align: center; }
.meter { height: 8px; background: var(--sunk); border-radius: 99px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--ember); border-radius: 99px; }
.list { display: flex; flex-direction: column; }
.list > .li { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list > .li:last-child { border-bottom: 0; }

/* ---------- banco ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
@media (max-width: 980px) { .pos { grid-template-columns: minmax(0, 1fr); } }
.scanbox { display: flex; gap: 10px; }
.scanbox input { font-size: 20px; min-height: 54px; font-family: var(--mono); letter-spacing: .02em; }
.cart-line { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cart-line .qty { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.cart-line .qty button { border: 0; border-radius: 0; min-height: 34px; min-width: 34px; padding: 0; background: var(--sunk); }
.cart-line .qty span { min-width: 30px; text-align: center; font-variant-numeric: tabular-nums; }
.cart-line input.price { width: 92px; text-align: right; min-height: 34px; padding: 4px 8px; }
.total { font-size: 38px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.pos-side { position: sticky; top: 16px; }

/* ---------- fattura ---------- */
.inv-lines td { padding: 6px 8px; }
.inv-lines input, .inv-lines select { min-height: 32px; padding: 4px 7px; font-size: 13.5px; }
.inv-lines input.w-qty { width: 64px; text-align: right; }
.inv-lines input.w-money { width: 86px; text-align: right; }
.inv-lines td.desc { min-width: 260px; }
.inv-lines tr.k-promo td, .inv-lines tr.k-spedizione td, .inv-lines tr.k-altro td { background: var(--sunk); color: var(--muted); }
.inv-lines tr.sel td { background: var(--ember-soft); }
.margin-ok { color: var(--ok); } .margin-low { color: var(--warn); } .margin-bad { color: var(--bad); }

/* ---------- firma e foto ---------- */
.sig { border: 1.5px dashed var(--line-strong); border-radius: var(--r); background: #fff; touch-action: none; width: 100%; height: 170px; display: block; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs .th { width: 84px; height: 84px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); position: relative; background: var(--sunk); }
.thumbs .th img { width: 100%; height: 100%; object-fit: cover; }
.thumbs .th button { position: absolute; top: 3px; right: 3px; min-height: 22px; min-width: 22px; padding: 0; font-size: 12px; border-radius: 99px; }
.drop { border: 1.5px dashed var(--line-strong); border-radius: var(--r); padding: 26px; text-align: center; background: var(--sunk); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.drop.over { border-color: var(--ember); background: var(--ember-soft); }

/* ---------- modale e toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(15, 10, 8, .55); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-card { background: var(--surface); border-radius: 14px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.3); display: flex; flex-direction: column; gap: 14px; }
.modal-card.wide { max-width: 860px; }
#toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 520px); }
#toast .t { background: var(--nav); color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,.25); pointer-events: auto; }
#toast .t.err { background: var(--bad); }
#toast .t.ok { background: var(--ok); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--nav); }
.login .card { width: 100%; max-width: 400px; padding: 26px; }
.login .brand { padding: 0 0 18px; color: var(--fg); }
.login .brand-sub { color: var(--muted); }

/* ---------- stampa ricevuta ---------- */
.receipt { background: #fff; color: #111; max-width: 760px; margin: 0 auto; padding: 32px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.receipt h1 { font-size: 20px; color: #111; }
.receipt table td, .receipt table th { border-color: #ddd; color: #111; background: #fff; }
.receipt .sig-img { height: 80px; }
.receipt .box { border: 1px solid #ccc; border-radius: 6px; padding: 12px; }
@media print {
  .nav, .topbar, .no-print, #toast { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  body { background: #fff; }
  .receipt { border: 0; padding: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.nav-badge { background: #ee262c; color: #fff; font-size: 12px; font-weight: 700; min-width: 22px; height: 22px; border-radius: 99px; display: grid; place-items: center; padding: 0 6px; }
.receipt .box { color: #111; }

.login .login-logo { height: 46px; width: auto; display: block; }
@media (prefers-color-scheme: dark) { .login .login-logo { content: url(/shop/logo-h-white.png); } }

/* ---------- inventario ---------- */
.tabs { display: inline-flex; gap: 2px; background: var(--sunk); padding: 3px; border-radius: 10px; }
.tabs button { border: 0; background: transparent; min-height: 32px; padding: 4px 12px; font-size: 13.5px; border-radius: 8px; }
.tabs button.active { background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.08); font-weight: 600; }
button.pick { display: block; width: 100%; text-align: left; }
button.big { min-height: 48px; font-size: 15.5px; display: inline-flex; align-items: center; gap: 8px; }
.nowrap { white-space: nowrap; }
.qtyb { display: inline-block; min-width: 2.2em; text-align: center; cursor: pointer; text-decoration: underline dotted; }
.inv-last { padding: 12px 14px; border-radius: 10px; background: var(--sunk); font-size: 15px; }
.inv-last.ok { background: var(--ok-soft); color: var(--ok); }
.inv-last.warn { background: var(--warn-soft); color: var(--warn); }
.cam { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 4 / 3; max-width: 100%; }
.cam video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-line { position: absolute; left: 10%; right: 10%; top: 50%; height: 2px; background: #ff3b3b; box-shadow: 0 0 8px #ff3b3b; }
.cam-msg { min-height: 2.6em; padding: 8px 2px; font-size: 15px; }
@media (max-width: 640px) { .inv-scan button.big { width: 100%; justify-content: center; } }
.neg { color: var(--ember); }
a.btn.sm, .btn.sm { min-height: 32px; padding: 4px 10px; font-size: 13px; text-decoration: none; }
