/* Gestionale Cantina */
/* Stile minimal: Arial ovunque, toni di grigio chiari; colori solo per gli stati (scaduto, esaurito, consegnato…) */
:root {
  --bg: #F4F4F4;
  --sheet: #FFFFFF;
  --sheet-2: #FAFAFA;
  --sunk: #EFEFEF;
  --line: #E2E2E2;
  --line-2: #CDCDCD;
  --ink: #262626;
  --ink-2: #505050;
  --muted: #7B7B7B;
  --wine: #3F3F3F;
  --wine-ink: #FFFFFF;
  --wine-soft: #EEEEEE;
  --wine-line: #D5D5D5;
  --straw: #6A6A6A;
  --straw-soft: #F1F1F1;
  --ok: #2E6B45;
  --ok-soft: #EAF2ED;
  --warn: #87580F;
  --warn-soft: #F7EFE1;
  --bad: #A3362E;
  --bad-soft: #F7E8E6;
  --info: #4B5D75;
  --info-soft: #ECEFF3;
  --side: #F8F8F8;
  --side-ink: #2E2E2E;
  --side-muted: #8A8A8A;
  --side-active: #EAEAEA;
  --side-line: #E4E4E4;
  --focus: #5C5C5C;
  --s1: #4D4D4D;
  --s2: #B3B3B3;
  --photo-bg: #FFFFFF;
  --logo-k: #1F4A2E;
  --logo-f: #E6E6E6;
  --logo-h: #B3B3B3;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 14px rgba(0, 0, 0, .05);
  --shadow-lg: 0 10px 36px rgba(0, 0, 0, .16);
  --f-ui: Arial, Helvetica, sans-serif;
  --f-disp: Arial, Helvetica, sans-serif;
  --f-mono: Arial, Helvetica, sans-serif;
  --r: 8px;
  --r-s: 6px;
  --gut-l: max(16px, env(safe-area-inset-left, 0px));
  --gut-r: max(16px, env(safe-area-inset-right, 0px));
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151515; --sheet: #1D1D1D; --sheet-2: #222222; --sunk: #191919; --line: #2F2F2F; --line-2: #3D3D3D;
    --ink: #E9E9E9; --ink-2: #BEBEBE; --muted: #8E8E8E;
    --wine: #D4D4D4; --wine-ink: #151515; --wine-soft: #2C2C2C; --wine-line: #474747;
    --straw: #BDBDBD; --straw-soft: #292929;
    --ok: #7FC39C; --ok-soft: #1B2A21; --warn: #D9AA5E; --warn-soft: #2E2518; --bad: #E58D86; --bad-soft: #321E1C; --info: #A3B3C7; --info-soft: #1E242B;
    --side: #111111; --side-ink: #DCDCDC; --side-muted: #888888; --side-active: #232323; --side-line: #222222;
    --focus: #BDBDBD;
    --logo-k: #8FBF9C; --logo-f: #2A2A2A; --logo-h: #4A4A4A;
    --s1: #D0D0D0; --s2: #6B6B6B; --photo-bg: #F1F1F1;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
    --shadow-lg: 0 10px 40px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #151515; --sheet: #1D1D1D; --sheet-2: #222222; --sunk: #191919; --line: #2F2F2F; --line-2: #3D3D3D;
  --ink: #E9E9E9; --ink-2: #BEBEBE; --muted: #8E8E8E;
  --wine: #D4D4D4; --wine-ink: #151515; --wine-soft: #2C2C2C; --wine-line: #474747;
  --straw: #BDBDBD; --straw-soft: #292929;
  --ok: #7FC39C; --ok-soft: #1B2A21; --warn: #D9AA5E; --warn-soft: #2E2518; --bad: #E58D86; --bad-soft: #321E1C; --info: #A3B3C7; --info-soft: #1E242B;
  --side: #111111; --side-ink: #DCDCDC; --side-muted: #888888; --side-active: #232323; --side-line: #222222;
  --focus: #BDBDBD;
  --logo-k: #8FBF9C; --logo-f: #2A2A2A; --logo-h: #4A4A4A;
  --s1: #D0D0D0; --s2: #6B6B6B; --photo-bg: #F1F1F1;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.6);
  color-scheme: dark;
}

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.45 var(--f-ui);
  -webkit-font-smoothing: antialiased;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--sheet); }
* { box-sizing: border-box; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--wine); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.num { text-align: right; white-space: nowrap; }
.mono { font-family: var(--f-mono); font-size: .95em; letter-spacing: .01em; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.ic { width: 1em; height: 1em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- avvio ---------- */
.boot { min-height: 100%; display: grid; place-items: center; padding-block: 40px; padding-left: var(--gut-l); padding-right: var(--gut-r); }
.boot-card { max-width: 460px; width: 100%; background: var(--sheet); border: 1px solid var(--line); border-radius: 12px; padding: 28px; box-shadow: var(--shadow); }
.boot-card h1 { font: 400 22px/1.2 var(--f-disp); margin: 14px 0 6px; text-wrap: balance; }
.boot-card p { margin: 6px 0; color: var(--ink-2); }
.boot-card .btn { margin-top: 14px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { display: block; flex: none; line-height: 0; }
.brand-mark svg { display: block; height: 40px; width: 26.5px; }
.ag-top .brand-mark svg { height: 32px; width: 21.2px; }
.lg-k { fill: var(--logo-k); }
.lg-f { fill: var(--logo-f); }
.lg-h { fill: var(--logo-h); }
.brand-name { font: 700 17px/1.1 var(--f-disp); letter-spacing: .02em; }
.brand-sub { font-size: 11px; color: var(--side-muted); text-transform: uppercase; letter-spacing: .08em; }
.spin { width: 18px; height: 18px; border: 2px solid var(--line-2); border-top-color: var(--wine); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- shell amministratore ---------- */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100%; }
.side { background: var(--side); color: var(--side-ink); border-right: 1px solid var(--side-line); position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; padding: calc(14px + env(safe-area-inset-top, 0px)) 12px 16px max(12px, env(safe-area-inset-left, 0px)); gap: 6px; }
.side .brand { padding: 4px 6px 12px; border-bottom: 1px solid var(--side-line); margin-bottom: 4px; }
.nav-h { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--side-muted); padding: 12px 8px 4px; }
.nav-a { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border: 0; background: none; border-radius: 6px; color: var(--side-ink); cursor: pointer; text-align: left; font-size: 13.5px; }
.nav-a:hover { background: var(--side-active); }
.nav-a.on { background: var(--side-active); color: var(--ink); box-shadow: inset 2px 0 0 var(--wine); font-weight: 600; }
:root[data-theme="dark"] .nav-a.on { color: var(--ink); }
.nav-a .ic { color: var(--side-muted); font-size: 16px; }
.nav-a.on .ic { color: var(--side-ink); }
.nav-a .nb { margin-left: auto; background: var(--wine); color: var(--wine-ink); font-size: 11px; font-weight: 600; border-radius: 10px; padding: 0 7px; line-height: 18px; }
.side-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--side-line); font-size: 12px; color: var(--side-muted); }
.mainwrap { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--sheet); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; gap: 10px; padding-block: 9px; padding-left: var(--gut-l); padding-right: var(--gut-r); min-height: 56px; flex-wrap: wrap; }
.top .spacer { flex: 1; }
.top .menu-btn { display: none; }
.main { padding-block: 22px 60px; padding-left: var(--gut-l); padding-right: var(--gut-r); min-width: 0; }
.page { max-width: 1320px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.page-h { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.page-t { font: 400 24px/1.15 var(--f-disp); margin: 0; letter-spacing: -.01em; text-wrap: balance; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.page-h .acts { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; }

/* selettore cantina */
.cant { position: relative; }
.cant-btn { display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); background: var(--sheet-2); border-radius: 8px; padding: 6px 10px; cursor: pointer; max-width: 320px; }
.cant-btn:hover { border-color: var(--line-2); }
.cant-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px var(--sheet); }
.cant-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cant-lab { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; display: block; line-height: 1; margin-bottom: 2px; }

/* ---------- elementi base ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line-2); background: var(--sheet); color: var(--ink); border-radius: var(--r-s); padding: 7px 12px; font-weight: 500; cursor: pointer; white-space: nowrap; line-height: 1.25; min-height: 34px; text-decoration: none; }
.btn:hover { background: var(--sheet-2); border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .ic { font-size: 15px; }
.btn-p { background: var(--wine); border-color: var(--wine); color: var(--wine-ink); }
.btn-p:hover { background: var(--wine); filter: brightness(1.08); border-color: var(--wine); }
.btn-g { border-color: transparent; background: transparent; }
.btn-g:hover { background: var(--sunk); border-color: transparent; }
.btn-d { color: var(--bad); border-color: var(--bad-soft); background: var(--sheet); }
.btn-d:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn-dd { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-s { padding: 4px 9px; min-height: 28px; font-size: 13px; }
.btn-i { padding: 6px; min-height: 32px; min-width: 32px; }
.btn-l { min-height: 44px; padding: 10px 16px; font-size: 15px; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

.card { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-t { font-weight: 600; font-size: 14px; margin: 0; }
.card-b { padding: 16px; }
.card-b.tight { padding: 0; }

.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px 14px; }
.fld { display: flex; flex-direction: column; gap: 4px; min-width: 0; grid-column: span 3; }
.fld.auto, .grid .fld.auto { grid-column: auto !important; }
.fld.s2 { grid-column: span 2; } .fld.s4 { grid-column: span 4; } .fld.s5 { grid-column: span 5; } .fld.s6 { grid-column: span 6; } .fld.s8 { grid-column: span 8; } .fld.s9 { grid-column: span 9; } .fld.s12 { grid-column: 1 / -1; }
.fl { font-size: 12px; color: var(--ink-2); font-weight: 500; }
.fh { font-size: 11.5px; color: var(--muted); }
.fe { font-size: 11.5px; color: var(--bad); }
.in { width: 100%; border: 1px solid var(--line-2); background: var(--sheet); border-radius: var(--r-s); padding: 7px 9px; min-height: 34px; color: var(--ink); }
.in:hover { border-color: var(--muted); }
.in:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.in.num { text-align: right; font-variant-numeric: tabular-nums; }
.in.err { border-color: var(--bad); }
.in[readonly] { background: var(--sheet-2); }
textarea.in { min-height: 70px; resize: vertical; line-height: 1.4; }
select.in { padding-right: 26px; }
.in-sm { min-height: 30px; padding: 4px 7px; font-size: 13px; }
.chk { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.chk input { width: 16px; height: 16px; accent-color: var(--wine); }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.cols2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.cols3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }

.chip { font-family: var(--f-ui); display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; padding: 1px 8px; border-radius: 20px; line-height: 20px; white-space: nowrap; background: var(--sunk); color: var(--ink-2); }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.chip.plain::before { display: none; }
.c-ok { background: var(--ok-soft); color: var(--ok); }
.c-warn { background: var(--warn-soft); color: var(--warn); }
.c-bad { background: var(--bad-soft); color: var(--bad); }
.c-info { background: var(--info-soft); color: var(--info); }
.c-wine { background: var(--wine-soft); color: var(--wine); }
.c-straw { background: var(--straw-soft); color: var(--straw); }
.c-mute { background: var(--sunk); color: var(--muted); }
.tag { display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .04em; padding: 0 6px; border-radius: 4px; line-height: 18px; border: 1px solid var(--line-2); color: var(--ink-2); }
.esempio { background: var(--straw-soft); color: var(--straw); border-color: transparent; text-transform: uppercase; }

.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r-s); overflow: hidden; background: var(--sheet); flex-wrap: wrap; }
.fld > .seg, .fld > .inline > .seg { align-self: flex-start; }
.seg button { border: 0; background: none; padding: 6px 11px; cursor: pointer; font-size: 13px; color: var(--ink-2); border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--wine-soft); color: var(--wine); font-weight: 600; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { border: 0; background: none; padding: 9px 12px; cursor: pointer; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab.on { color: var(--ink); border-bottom-color: var(--wine); }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search { position: relative; flex: 1 1 220px; max-width: 360px; min-width: 0; }
.search .ic { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .in { padding-left: 30px; }

/* ---------- tabelle ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--sheet-2); white-space: nowrap; position: sticky; top: 0; }
.tbl th.num { text-align: right; }
.tbl th.sort { cursor: pointer; }
.tbl th.sort:hover { color: var(--ink); }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover td { background: var(--sheet-2); }
.tbl tbody tr.sel td { background: var(--wine-soft); }
.tbl tfoot td { font-weight: 600; background: var(--sheet-2); border-bottom: 0; }
.tbl .strong { font-weight: 600; }
.tbl .sub { display: block; font-size: 12px; color: var(--muted); }
.tbl td.act { width: 1%; white-space: nowrap; text-align: right; }
.tbl .w-chk { width: 34px; }
.more { padding: 10px; text-align: center; }

.bar { height: 6px; border-radius: 3px; background: var(--sunk); overflow: hidden; min-width: 60px; }
.bar > i { display: block; height: 100%; background: var(--wine); border-radius: 3px; }

/* ---------- KPI e grafico ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.kpis.k6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpis.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (min-width: 1500px) { .kpis.k6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@media (max-width: 900px) { .kpis.k4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .kpis.k6, .kpis.k3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpis.k3 > :last-child:nth-child(odd), .kpis.k6 > :last-child:nth-child(odd) { grid-column: 1 / -1; } }
.kpi { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi-l { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi-v { font: 400 24px/1.15 var(--f-ui); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi-s { font-size: 12px; color: var(--ink-2); }
.kpi.alert { border-color: var(--wine-line); }
button.kpi { text-align: left; cursor: pointer; font: inherit; }
button.kpi:hover { border-color: var(--line-2); }
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--f-ui); }
.chart .grid-l { stroke: var(--line); stroke-width: 1; }
.chart .b1 { fill: var(--s1); }
.chart .b2 { fill: var(--s2); }
.chart .base-l { stroke: var(--line-2); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit.on { fill: var(--sunk); opacity: .6; }
.chart-box { position: relative; }
.chart-tip { position: absolute; top: 4px; transform: translateX(-50%); background: var(--sheet); border: 1px solid var(--line-2); border-radius: 6px; box-shadow: var(--shadow); padding: 8px 10px; font-size: 12.5px; pointer-events: none; white-space: nowrap; z-index: 5; }
.chart-tip b { display: block; margin-bottom: 3px; }
.chart-tip .r { display: flex; gap: 10px; justify-content: space-between; font-variant-numeric: tabular-nums; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.sw.s1 { background: var(--s1); } .sw.s2 { background: var(--s2); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* ---------- editor documento ---------- */
.doc-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.doc-h .page-t { font-size: 22px; }
.doc-acts { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.sogg { border: 1px dashed var(--line-2); border-radius: var(--r-s); padding: 10px 12px; background: var(--sheet-2); font-size: 13px; line-height: 1.5; }
.sogg b { font-size: 14px; }
.lines { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.lines th { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); background: var(--sheet-2); white-space: nowrap; }
.lines th.num { text-align: right; }
.lines td { padding: 5px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.lines td:first-child, .lines th:first-child { padding-left: 10px; }
.lines .in { min-height: 32px; padding: 5px 7px; }
.lines td.c-desc { min-width: 200px; }
.lines td.c-qta { width: 74px; min-width: 70px; } .lines td.c-pr { width: 92px; min-width: 86px; } .lines td.c-sc { width: 64px; min-width: 60px; } .lines td.c-iva { width: 84px; min-width: 82px; } .lines td.c-imp { width: 92px; min-width: 84px; padding-top: 11px; } .lines td.c-lot { width: 92px; min-width: 86px; } .lines td.c-mrg { width: 56px; min-width: 52px; padding-top: 11px; } .lines td.c-x { width: 70px; white-space: nowrap; }
.lines .c-iva .in { padding-left: 6px; padding-right: 20px; }
.lines-tot { display: flex; gap: 6px 22px; flex-wrap: wrap; justify-content: flex-end; padding: 10px 14px; border-top: 1px solid var(--line); background: var(--sheet-2); border-radius: 0 0 var(--r) var(--r); font-variant-numeric: tabular-nums; color: var(--ink-2); }
.lines-tot b { color: var(--ink); font-weight: 600; }
.lines tr.descr td { background: var(--sheet-2); }
.lines .hint { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.addline { display: flex; gap: 8px; align-items: center; padding: 10px; flex-wrap: wrap; border-top: 1px solid var(--line); }
.addline .combo { flex: 1 1 280px; min-width: 0; }
.tot { display: flex; flex-direction: column; gap: 0; }
.tot-r { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-variant-numeric: tabular-nums; }
.tot-r + .tot-r { border-top: 1px dashed var(--line); }
.tot-r.big { font-size: 18px; font-weight: 600; border-top: 1px solid var(--line-2) !important; padding-top: 10px; }
.tot-r .l { color: var(--ink-2); }
.side-panel { position: sticky; top: calc(72px + env(safe-area-inset-top, 0px)); display: flex; flex-direction: column; gap: 12px; }
.mrg { background: var(--sheet-2); }
.mrg .tot-r .v.pos { color: var(--ok); }
.mrg .tot-r .v.neg { color: var(--bad); }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-s); font-size: 13px; line-height: 1.45; }
.notice .ic { font-size: 16px; margin-top: 1px; }
.notice.info { background: var(--info-soft); color: var(--ink); } .notice.info .ic { color: var(--info); }
.notice.warn { background: var(--warn-soft); color: var(--ink); } .notice.warn .ic { color: var(--warn); }
.notice.bad { background: var(--bad-soft); color: var(--ink); } .notice.bad .ic { color: var(--bad); }
.notice.ok { background: var(--ok-soft); color: var(--ink); } .notice.ok .ic { color: var(--ok); }
.notice ul { margin: 4px 0 0; padding-left: 18px; }

/* ---------- combo / menu ---------- */
.combo { position: relative; }
.combo-list { position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px); background: var(--sheet); border: 1px solid var(--line-2); border-radius: var(--r-s); box-shadow: var(--shadow-lg); max-height: 320px; overflow-y: auto; min-width: 260px; }
.combo-item { display: flex; gap: 10px; align-items: baseline; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; cursor: pointer; border-bottom: 1px solid var(--line); }
.combo-item:last-child { border-bottom: 0; }
.combo-item.on, .combo-item:hover { background: var(--wine-soft); }
.combo-item .cm { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.combo-empty { padding: 10px; color: var(--muted); font-size: 13px; }
.dd { position: relative; display: inline-block; }
.dd-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 45; background: var(--sheet); color: var(--ink); border: 1px solid var(--line-2); border-radius: var(--r-s); box-shadow: var(--shadow-lg); min-width: 230px; padding: 4px; }
.dd-menu.left { right: auto; left: 0; }
.dd-item { display: flex; align-items: center; gap: 9px; width: 100%; border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 5px; cursor: pointer; white-space: nowrap; }
.dd-item:hover { background: var(--sunk); }
.dd-item.danger { color: var(--bad); }
.dd-sep { height: 1px; background: var(--line); margin: 4px 0; }
.dd-h { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 8px 10px 4px; }

/* ---------- modale e notifiche ---------- */
.modal-bg { position: fixed; inset: 0; z-index: 60; background: rgba(20, 20, 20, .38); display: flex; align-items: flex-start; justify-content: center; padding: calc(40px + env(safe-area-inset-top, 0px)) var(--gut-r) 40px var(--gut-l); overflow-y: auto; }
.modal { background: var(--sheet); border-radius: 12px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; display: flex; flex-direction: column; border: 1px solid var(--line); }
.modal.wide { max-width: 920px; }
.modal.xwide { max-width: 1120px; }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-h h2 { font: 600 18px/1.2 var(--f-disp); margin: 0; }
.modal-h .x { margin-left: auto; }
.modal-b { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-f { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--sheet-2); border-radius: 0 0 12px 12px; flex-wrap: wrap; }
.modal-f .l { margin-right: auto; }
.toasts { position: fixed; z-index: 80; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; align-items: center; gap: 8px; width: max-content; max-width: min(460px, calc(100vw - 32px)); pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow-lg); font-size: 13.5px; display: flex; gap: 10px; align-items: center; animation: tin .18s ease-out; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.ok .ic { color: var(--ok-soft); }
@keyframes tin { from { transform: translateY(6px); opacity: 0; } }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty .ic { font-size: 34px; color: var(--line-2); }
.empty h3 { margin: 0; color: var(--ink); font: 600 16px/1.3 var(--f-disp); }
.empty p { margin: 0; max-width: 46ch; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
.list-plain li:last-child { border-bottom: 0; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--sheet); box-shadow: 0 0 0 1px var(--line-2); cursor: pointer; }
.swatch.on { box-shadow: 0 0 0 2px var(--ink); }
.logo-prev { max-width: 160px; max-height: 70px; object-fit: contain; background: var(--photo-bg); border: 1px solid var(--line); border-radius: 6px; padding: 4px; }
.thumb { width: 40px; height: 40px; flex: none; border-radius: 6px; object-fit: contain; background: var(--photo-bg); border: 1px solid var(--line); display: block; }
.thumb.ph { display: grid; place-items: center; background: var(--sunk); color: var(--line-2); font-size: 18px; }
.thumb.md { width: 64px; height: 64px; }
.thumb.lg { width: 100%; height: 220px; border-radius: var(--r-s); }
.thumb.lg.ph { font-size: 42px; }
.art-cell { display: flex; gap: 10px; align-items: center; min-width: 0; }
.prod-info { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.prod .thumb { width: 64px; height: 64px; }
.drop { border: 1.5px dashed var(--line-2); border-radius: var(--r); padding: 22px; text-align: center; color: var(--muted); background: var(--sheet-2); }
.drop.on { border-color: var(--wine); background: var(--wine-soft); }
.hr { height: 1px; background: var(--line); border: 0; margin: 4px 0; }
.sec-t { font: 600 15px/1.3 var(--f-disp); margin: 0; }

/* ---------- area agenti ---------- */
.ag { min-height: 100%; display: flex; flex-direction: column; }
.ag-top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--side); color: var(--side-ink); border-bottom: 1px solid var(--line); }
.ag-top-in { display: flex; align-items: center; gap: 10px; padding-block: 10px; padding-left: var(--gut-l); padding-right: var(--gut-r); max-width: 1080px; margin: 0 auto; width: 100%; flex-wrap: wrap; }
.ag-top .brand-sub { color: var(--side-muted); }
.ag-top .cant-btn { background: var(--side-active); border-color: var(--side-line); color: var(--side-ink); }
.ag-top .cant-lab { color: var(--side-muted); }
.ag-nav { display: flex; gap: 4px; padding-left: var(--gut-l); padding-right: var(--gut-r); max-width: 1080px; margin: 0 auto; width: 100%; overflow-x: auto; }
.ag-nav button { border: 0; background: none; color: var(--side-muted); padding: 9px 12px; border-bottom: 2px solid transparent; cursor: pointer; font-weight: 500; white-space: nowrap; }
.ag-nav button.on { color: var(--ink); border-bottom-color: var(--wine); }
:root[data-theme="dark"] .ag-nav button.on { color: var(--ink); }
.ag-main { flex: 1; padding-block: 18px 120px; padding-left: var(--gut-l); padding-right: var(--gut-r); max-width: 1080px; margin: 0 auto; width: 100%; display: flex; flex-direction: column; gap: 14px; }
.ag-preview { background: var(--straw-soft); color: var(--ink); font-size: 13px; padding-block: 8px; padding-left: var(--gut-l); padding-right: var(--gut-r); display: flex; gap: 10px; align-items: flex-start; }
.ag-preview .ic { margin-top: 2px; }
.ag-top .cant-dot { box-shadow: none; }
.prod-list { display: flex; flex-direction: column; gap: 8px; }
.prod { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 14px; align-items: center; }
.prod.in-cart { border-color: var(--wine-line); box-shadow: inset 3px 0 0 var(--wine); }
.prod-n { font-weight: 600; font-size: 15px; line-height: 1.3; }
.prod-m { display: flex; gap: 6px 10px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; margin-top: 3px; align-items: center; }
.prod-p { font-weight: 600; font-variant-numeric: tabular-nums; font-size: 15px; text-align: right; }
.prod-p small { display: block; font-weight: 400; font-size: 11.5px; color: var(--muted); }
.prod-q { grid-column: 1 / -1; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding-top: 8px; border-top: 1px dashed var(--line); }
.qty { display: inline-flex; align-items: stretch; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; background: var(--sheet); }
.qty button { border: 0; background: var(--sheet-2); width: 40px; min-height: 40px; cursor: pointer; font-size: 18px; color: var(--ink); }
.qty button:hover { background: var(--sunk); }
.qty input { width: 64px; border: 0; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; background: var(--sheet); }
.qty input:focus { outline: none; }
.cat-chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.cat-chips button { border: 1px solid var(--line-2); background: var(--sheet); border-radius: 18px; padding: 5px 12px; cursor: pointer; white-space: nowrap; font-size: 13px; }
.cat-chips button.on { background: var(--wine); border-color: var(--wine); color: var(--wine-ink); }
.nota-v { margin-top: 5px; color: var(--ink-2); max-width: 68ch; }
.nota-v summary { cursor: pointer; color: var(--wine); font-weight: 500; width: max-content; max-width: 100%; }
.nota-t { white-space: pre-line; margin-top: 4px; line-height: 1.5; }
.ag-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--sheet); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(0,0,0,.08); padding-top: 10px; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); padding-left: var(--gut-l); padding-right: var(--gut-r); }
.ag-bar-in { max-width: 1080px; margin: 0 auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.ag-bar .tt { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ag-bar .ts { font-size: 12px; color: var(--muted); }
.qcard { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: flex; gap: 12px; align-items: center; cursor: pointer; width: 100%; text-align: left; }
.qcard:hover { border-color: var(--line-2); }
.qcard .q-n { font-weight: 600; }
.qcard .q-m { font-size: 12.5px; color: var(--muted); }
.qcard .q-t { margin-left: auto; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.steps { display: flex; gap: 8px; flex-wrap: wrap; }
.step { flex: 1 1 140px; border: 1px solid var(--line); border-radius: var(--r); background: var(--sheet); padding: 10px 12px; display: flex; gap: 10px; align-items: center; cursor: pointer; text-align: left; min-width: 0; }
.step .n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--sunk); font-size: 12px; font-weight: 600; flex: none; }
.step.on { border-color: var(--wine); }
.step.on .n { background: var(--wine); color: var(--wine-ink); }
.step.done .n { background: var(--ok-soft); color: var(--ok); }
.step .st { font-weight: 600; font-size: 13px; }
.step .ss { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- responsive ---------- */
@media (max-width: 1400px) {
  .row2 { grid-template-columns: minmax(0, 1fr); }
  .side-panel { position: static; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-items: start; }
}
@media (max-width: 980px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; z-index: 70; left: 0; top: 0; bottom: 0; width: 272px; transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .side.open { transform: none; }
  .side-scrim { position: fixed; inset: 0; z-index: 65; background: rgba(0,0,0,.35); }
  .top .menu-btn { display: inline-flex; }
  .grid .fld, .grid .fld.s2 { grid-column: span 6; }
  .grid .fld.s4, .grid .fld.s5 { grid-column: span 6; }
  .grid .fld.s8, .grid .fld.s9, .grid .fld.s12 { grid-column: 1 / -1; }
  .cols3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .main { padding-block: 16px 60px; }
  .page-t { font-size: 21px; }
  .grid .fld, .grid .fld.s2, .grid .fld.s4, .grid .fld.s5, .grid .fld.s6 { grid-column: 1 / -1; }
  .grid .fld.half { grid-column: span 6; }
  .cols2 { grid-template-columns: minmax(0, 1fr); }
  .cant-btn { max-width: 210px; }
  .top-in .hide-s { display: none; }
  /* tabelle → schede */
  table.tbl.resp thead { display: none; }
  table.tbl.resp, table.tbl.resp tbody, table.tbl.resp tr, table.tbl.resp td { display: block; width: 100%; }
  table.tbl.resp tr { border-bottom: 1px solid var(--line); padding: 8px 12px; }
  table.tbl.resp td { border: 0; padding: 2px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.tbl.resp td::before { content: attr(data-l); color: var(--muted); font-size: 12px; text-align: left; flex: none; }
  table.tbl.resp td.first { font-weight: 600; text-align: left; }
  table.tbl.resp td.first::before { display: none; }
  table.tbl.resp td.act { justify-content: flex-end; width: 100%; }
  table.tbl.resp td.act::before { display: none; }
  table.tbl.resp tfoot { display: block; }
  table.tbl.resp tfoot tr { display: block; }
  .lines thead { display: none; }
  .lines, .lines tbody, .lines tr, .lines td { display: block; width: 100% !important; }
  .lines tr { border-bottom: 1px solid var(--line-2); padding: 8px 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
  .lines td { border: 0; padding: 0; grid-column: span 2; }
  .lines td.c-desc { grid-column: 1 / -1; min-width: 0; }
  .lines td.c-cod { grid-column: span 3; } .lines td.c-lot { grid-column: span 3; }
  .lines td.c-imp, .lines td.c-mrg { padding-top: 6px; }
  .lines td.c-x { grid-column: 1 / -1; text-align: right; }
  .lines td[data-l]::before { content: attr(data-l); display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
  .modal-bg { padding-top: calc(12px + env(safe-area-inset-top, 0px)); padding-bottom: 12px; }
  .modal-b { padding: 14px; }
  .prod { grid-template-columns: minmax(0, 1fr); }
  .prod .thumb { width: 56px; height: 56px; }
  table.tbl.resp td.first .art-cell { justify-content: flex-start; }
  .ag-nav button { padding: 9px 8px; font-size: 13.5px; }
  .kpi-v { font-size: 19px; }
  .prod-p { text-align: left; }
}

/* ---------- versione installabile: accesso, installazione, utenti ---------- */
html, body { margin: 0; }
[hidden] { display: none !important; }
img { max-width: 100%; }
.boot-card.wide { max-width: 680px; }
.boot-card form .btn-l { margin-top: 4px; }
.setup .sec-t { margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.setup .sec-t:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.login-help summary { cursor: pointer; width: max-content; max-width: 100%; }
.login-help p { margin: 6px 0 0; }
.side-foot.acc { display: flex; flex-direction: column; gap: 2px; padding: 10px 0 0; }
.side-user { display: flex; flex-direction: column; gap: 1px; padding: 0 8px 6px; min-width: 0; }
.side-user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-un { color: var(--side-ink); font-weight: 500; font-size: 13px; }
.side-foot.acc .nav-a { font-size: 13px; padding-block: 6px; }
.setup > .seg { align-self: flex-start; }
.ag-top .ag-acc { color: var(--side-ink); }
.ag-top .ag-acc:hover { background: var(--side-active); }
@media (max-width: 560px) {
  .ag-top-in { flex-wrap: nowrap; gap: 8px; }
  .ag-top-in > .brand { min-width: 0; flex: 0 1 auto; }
  .ag-top-in > .brand > span:last-child { min-width: 0; overflow: hidden; }
  .ag-top-in > .brand .brand-name, .ag-top-in > .brand .brand-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ag-top-in > .dd { min-width: 0; flex: 0 1 auto; }
  .ag-top-in > .dd:last-child { flex: none; }
  .ag-top .cant-btn { max-width: 100%; min-width: 0; padding: 5px 8px; gap: 7px; }
  .ag-top .cant-btn > span:not(.cant-dot) { min-width: 0; overflow: hidden; }
  .ag-top-in > .brand .brand-mark { display: none; }
}
pre.cred { white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.55 var(--f-mono); background: var(--sunk); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; margin: 0; user-select: all; -webkit-user-select: all; }
