/* Wrap Facile — stile Windows 11 (Fluent): superfici chiare, angoli 4–8 px, barra comandi, navigazione laterale */
:root {
  --accent: #b0124f;
  --accent-2: #93103f;
  --accent-3: #7a0d34;
  --accent-soft: color-mix(in srgb, var(--accent) 10%, transparent);
  --accent-line: color-mix(in srgb, var(--accent) 35%, transparent);
  --on-accent: #fff;
  --bg: #f3f3f3;
  --bg-mica: #eef0f3;
  --card: #ffffff;
  --card-2: #fbfbfb;
  --subtle: rgba(0, 0, 0, .037);
  --subtle-2: rgba(0, 0, 0, .06);
  --stroke: #e3e3e3;
  --stroke-2: #d1d1d1;
  --ctl-bottom: #8a8a8a;
  --text: #1b1b1b;
  --text-2: #595959;
  --text-3: #6e6e6e;
  --ok: #0f7b0f;
  --ok-bg: #dff6dd;
  --warn: #8a5300;
  --warn-bg: #fff4ce;
  --err: #c42b1c;
  --err-bg: #fde7e9;
  --info-bg: #eaf3fb;
  --info: #0a5aa8;
  --sheet: #fdfdfb;
  --sheet-line: #c9ccd1;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .06), 0 2px 6px rgba(0, 0, 0, .05);
  --shadow-2: 0 8px 16px rgba(0, 0, 0, .12), 0 2px 4px rgba(0, 0, 0, .06);
  --shadow-dlg: 0 32px 64px rgba(0, 0, 0, .19), 0 2px 21px rgba(0, 0, 0, .15);
  --r: 4px;
  --r2: 8px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-d: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, sans-serif;
  --nav-w: 248px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent-soft: color-mix(in srgb, var(--accent) 22%, transparent);
    --bg: #202020; --bg-mica: #1c1c1c; --card: #2b2b2b; --card-2: #272727;
    --subtle: rgba(255, 255, 255, .06); --subtle-2: rgba(255, 255, 255, .09);
    --stroke: #3a3a3a; --stroke-2: #474747; --ctl-bottom: #8a8a8a;
    --text: #f3f3f3; --text-2: #c5c5c5; --text-3: #a8a8a8;
    --ok: #6ccb5f; --ok-bg: #1f3a1d; --warn: #fce100; --warn-bg: #433519; --err: #ff99a4; --err-bg: #442726; --info: #8cc6ff; --info-bg: #1d2f42;
    --sheet: #f5f5f2; --sheet-line: #6b6f75;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .3); --shadow-2: 0 8px 16px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --accent-soft: color-mix(in srgb, var(--accent) 22%, transparent);
  --bg: #202020; --bg-mica: #1c1c1c; --card: #2b2b2b; --card-2: #272727;
  --subtle: rgba(255, 255, 255, .06); --subtle-2: rgba(255, 255, 255, .09);
  --stroke: #3a3a3a; --stroke-2: #474747;
  --text: #f3f3f3; --text-2: #c5c5c5; --text-3: #a8a8a8;
  --ok: #6ccb5f; --ok-bg: #1f3a1d; --warn: #fce100; --warn-bg: #433519; --err: #ff99a4; --err-bg: #442726; --info: #8cc6ff; --info-bg: #1d2f42;
  --sheet: #f5f5f2; --sheet-line: #6b6f75;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font: 14px/1.43 var(--font); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; border-radius: var(--r); }
* { scrollbar-width: thin; scrollbar-color: var(--stroke-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--stroke-2); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
svg.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.num, td.n, .tab { font-variant-numeric: tabular-nums; }
h1, h2, h3 { font-family: var(--font-d); margin: 0; text-wrap: balance; }
h1 { font-size: 28px; line-height: 36px; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 20px; line-height: 28px; font-weight: 600; }
h3 { font-size: 14px; line-height: 20px; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 2px; }
.muted { color: var(--text-2); }
.small { font-size: 12px; line-height: 16px; }
.hidden { display: none !important; }
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot-msg { color: var(--text-2); }

/* ------------------------------------------------ controlli */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 32px; padding: 5px 12px; border-radius: var(--r);
  font: inherit; font-weight: 400; color: var(--text); text-decoration: none; white-space: nowrap;
  background: var(--card); border: 1px solid var(--stroke); border-bottom-color: var(--stroke-2);
  cursor: pointer; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--card-2); }
.btn:active { background: var(--subtle); color: var(--text-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: transparent; border-bottom-color: var(--accent-3); color: var(--on-accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent-2); }
.btn.primary:active { background: var(--accent-3); color: color-mix(in srgb, var(--on-accent) 80%, transparent); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--subtle); }
.btn.danger { color: var(--err); }
.btn.icon { padding: 5px; min-width: 32px; }
.btn.big { min-height: 40px; padding: 8px 18px; font-size: 15px; }
.btn .ic { width: 18px; height: 18px; }

label.f { display: grid; gap: 4px; font-size: 13px; color: var(--text-2); min-width: 0; }
label.f > span { line-height: 18px; }
.in, select.in, textarea.in {
  width: 100%; min-height: 32px; padding: 5px 10px; font: inherit; font-size: 14px; color: var(--text);
  background: var(--card); border: 1px solid var(--stroke); border-bottom: 1px solid var(--ctl-bottom);
  border-radius: var(--r); outline: none; transition: border-color .12s, box-shadow .12s;
}
.in:hover { background: var(--card-2); }
.in:focus { border-bottom: 2px solid var(--accent); padding-bottom: 4px; background: var(--card); }
textarea.in { resize: vertical; min-height: 72px; line-height: 1.45; }
textarea.in:focus { padding-bottom: 4px; }
.in::placeholder { color: var(--text-3); }
input.in[type=number] { -moz-appearance: textfield; }
input.in[type=number]::-webkit-inner-spin-button { opacity: .4; }
select.in { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%23777' stroke-width='1.3'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 12px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 14px; color: var(--text); }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 16px; }
.span2 { grid-column: span 2; } .spanall { grid-column: 1 / -1; }
.unit { position: relative; }
.unit .in { padding-right: 38px; }
.unit::after { content: attr(data-u); position: absolute; right: 10px; bottom: 7px; font-size: 12px; color: var(--text-3); pointer-events: none; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 99px; font-size: 12px; line-height: 18px; background: var(--subtle-2); color: var(--text-2); white-space: nowrap; }
.pill.s-preventivo { background: var(--info-bg); color: var(--info); }
.pill.s-accettato { background: var(--accent-soft); color: var(--accent); }
.pill.s-lavorazione { background: var(--warn-bg); color: var(--warn); }
.pill.s-posato { background: var(--ok-bg); color: var(--ok); }
.pill.s-annullato { text-decoration: line-through; }
.pill.low { background: var(--err-bg); color: var(--err); }
.swatch { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0, 0, 0, .15); flex: none; display: inline-block; vertical-align: -2px; }

/* ------------------------------------------------ guscio */
.shell { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); grid-template-rows: 48px minmax(0, 1fr); min-height: 100vh; }
.titlebar { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--bg-mica); position: sticky; top: 0; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; color: var(--text); }
.brand img { height: 28px; width: auto; max-width: 140px; object-fit: contain; }
.brand .mark { width: 26px; height: 26px; border-radius: 6px; background: var(--accent); display: grid; place-items: center; flex: none; }
.brand .mark svg { width: 18px; height: 18px; stroke: #fff; fill: none; stroke-width: 1.6; }
.brand b { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { color: var(--text-2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.titlebar .sp { flex: 1; }
.who { font-size: 12px; color: var(--text-2); }
.demo-flag { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--warn-bg); color: var(--warn); }
nav.side { background: var(--bg-mica); padding: 4px 8px 16px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 48px; height: calc(100vh - 48px); overflow: auto; }
nav.side a { position: relative; display: flex; align-items: center; gap: 12px; height: 38px; padding: 0 12px; border-radius: var(--r); color: var(--text); text-decoration: none; font-size: 14px; }
nav.side a:hover { background: var(--subtle); }
nav.side a.on { background: var(--subtle-2); font-weight: 600; }
nav.side a.on::before { content: ""; position: absolute; left: 0; top: 11px; bottom: 11px; width: 3px; border-radius: 3px; background: var(--accent); }
nav.side .sep { height: 1px; background: var(--stroke); margin: 8px 4px; }
nav.side .bottom { margin-top: auto; }
main#main { background: var(--bg); padding: 0 24px 40px; min-width: 0; }
.page { max-width: 1440px; margin: 0 auto; }
.pagehead { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; padding: 20px 0 14px; }
.pagehead h1 { flex: 1 1 auto; min-width: 0; }
.pagehead .sub { color: var(--text-2); margin-top: 2px; }

.cmdbar { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding: 4px; margin-bottom: 16px; background: var(--card); border: 1px solid var(--stroke); border-radius: var(--r2); box-shadow: var(--shadow-1); position: sticky; top: 52px; z-index: 20; }
.cmdbar .btn { border-color: transparent; background: transparent; }
.cmdbar .btn:hover { background: var(--subtle); }
.cmdbar .btn.primary { background: var(--accent); }
.cmdbar .vr { width: 1px; align-self: stretch; margin: 6px 4px; background: var(--stroke); }
.cmdbar .sp { flex: 1; }
.cmdbar .search { position: relative; min-width: 220px; flex: 0 1 300px; }
.cmdbar .search .in { padding-left: 34px; }
.cmdbar .search .ic { position: absolute; left: 9px; top: 7px; width: 18px; height: 18px; color: var(--text-2); }

.card { background: var(--card); border: 1px solid var(--stroke); border-radius: var(--r2); box-shadow: var(--shadow-1); }
.card > .hd { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; }
.card > .hd h2, .card > .hd h3 { flex: 1; }
.card > .bd { padding: 4px 16px 16px; }
.stack { display: grid; gap: 16px; align-content: start; }

/* tabelle */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-weight: 400; font-size: 12px; color: var(--text-2); padding: 8px 10px; border-bottom: 1px solid var(--stroke); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--stroke); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.n, .tbl th.n { text-align: right; }
.tbl tr.rowlink { cursor: pointer; }
.tbl tr.rowlink:hover td { background: var(--subtle); }
.tbl .t1 { font-weight: 600; }
.empty { padding: 40px 16px; text-align: center; color: var(--text-2); display: grid; gap: 12px; justify-items: center; }
.empty .ic { width: 40px; height: 40px; stroke-width: 1.1; color: var(--text-3); }
.empty b { color: var(--text); font-size: 15px; }

/* chip filtri */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { border: 1px solid var(--stroke); background: var(--card); border-radius: 99px; padding: 4px 12px; font: inherit; font-size: 13px; cursor: pointer; color: var(--text); }
.chip:hover { background: var(--card-2); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip .c { opacity: .7; margin-left: 4px; }

/* ------------------------------------------------ lavori */
.home { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.jobsum { color: var(--text-2); font-size: 12px; }
.agenda li, .stocklow li { list-style: none; display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--stroke); }
.agenda, .stocklow { margin: 0; padding: 0; }
.agenda li:last-child, .stocklow li:last-child { border-bottom: 0; }
.agenda .day { width: 44px; text-align: center; flex: none; border-radius: var(--r); background: var(--subtle); padding: 2px 0; line-height: 1.15; }
.agenda .day b { display: block; font-size: 18px; font-family: var(--font-d); }
.agenda .day span { font-size: 11px; color: var(--text-2); text-transform: uppercase; }
.agenda a { color: var(--text); text-decoration: none; font-weight: 600; }
.agenda a:hover { color: var(--accent); }

/* ------------------------------------------------ editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 440px); gap: 16px; align-items: start; }
.res { position: sticky; top: 112px; max-height: calc(100vh - 124px); overflow: auto; }
.jobhead { padding: 16px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 16px; }
.titlein { font-family: var(--font-d); font-size: 18px; font-weight: 600; }
.pz { width: 100%; border-collapse: collapse; }
.pz th { font-size: 12px; font-weight: 400; color: var(--text-2); text-align: left; padding: 6px 4px; white-space: nowrap; }
.pz td { padding: 3px 4px; vertical-align: middle; }
.pz tr + tr td { border-top: 1px solid var(--stroke); }
.pz .in { min-height: 30px; padding: 4px 8px; }
.pz .w-n { width: 64px; } .pz .w-q { width: 52px; } .pz .w-d { width: 104px; } .pz .w-m { width: 210px; }
.pz td.area { text-align: right; color: var(--text-2); font-size: 12px; white-space: nowrap; width: 62px; }
.pz .tag { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 4px; font-size: 12px; font-weight: 600; color: #1b1b1b; }
.addrow { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 0 0; }
.opts { display: flex; gap: 12px 20px; flex-wrap: wrap; align-items: end; }
.opts label.f { width: 130px; }
.extra td { padding: 3px 4px; }

.ai-box { border: 1px solid var(--accent-line); background: linear-gradient(var(--accent-soft), var(--accent-soft)), var(--card); border-radius: var(--r2); padding: 14px 16px; display: grid; gap: 10px; }
.ai-box .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ai-prop { background: var(--card); border: 1px solid var(--stroke); border-radius: var(--r); padding: 10px 12px; display: grid; gap: 8px; }
.ai-prop ul { margin: 0; padding-left: 18px; }
.ai-notes { color: var(--text-2); font-size: 12px; }
.ai-text { white-space: pre-wrap; font-size: 13px; line-height: 1.55; }

/* risultati */
.big { display: grid; gap: 2px; padding: 12px 16px 14px; border-top: 1px solid var(--stroke); }
.big:first-of-type { border-top: 0; }
.big .mat { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }
.big .qty { font-family: var(--font-d); font-size: 32px; line-height: 40px; font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.big .qty small { font-size: 15px; font-weight: 400; color: var(--text-2); margin-left: 4px; letter-spacing: 0; }
.big .det { color: var(--text-2); font-size: 12px; }
.big .lam { font-size: 12px; color: var(--text-2); }
.sheets { display: flex; gap: 8px; overflow-x: auto; padding: 8px 0 4px; }
.sheets .sh { flex: none; cursor: zoom-in; border: 0; padding: 0; background: none; display: grid; gap: 2px; justify-items: center; font: inherit; color: var(--text-2); font-size: 11px; }
.sheets svg { display: block; border-radius: 2px; box-shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 0 0 1px var(--sheet-line); background: var(--sheet); }
.sheets .sh:hover svg { box-shadow: 0 2px 6px rgba(0, 0, 0, .3), 0 0 0 2px var(--accent); }
.roll { overflow-x: auto; padding: 8px 0 4px; }
.roll svg { display: block; background: var(--sheet); box-shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 0 0 1px var(--sheet-line); border-radius: 2px; cursor: zoom-in; }
.svgtxt { font-family: var(--font); fill: #1b1b1b; }
.tot { padding: 4px 16px 16px; }
.tot table { width: 100%; border-collapse: collapse; }
.tot td { padding: 5px 0; }
.tot td.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tot tr.sum td { border-top: 1px solid var(--stroke); padding-top: 8px; }
.tot tr.grand td { font-family: var(--font-d); font-size: 22px; font-weight: 600; padding-top: 8px; }
.tot .cost td { color: var(--text-2); font-size: 12px; }
.times { display: flex; gap: 20px; padding: 0 16px 12px; flex-wrap: wrap; }
.times div { display: grid; }
.times b { font-family: var(--font-d); font-size: 18px; font-variant-numeric: tabular-nums; }
.times span { font-size: 12px; color: var(--text-2); }
.alerts { display: grid; gap: 6px; padding: 0 16px 14px; }
.al { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; line-height: 16px; padding: 7px 10px; border-radius: var(--r); background: var(--info-bg); color: var(--info); }
.al .ic { width: 16px; height: 16px; margin-top: 0; }
.al.warn { background: var(--warn-bg); color: var(--warn); }
.al.err { background: var(--err-bg); color: var(--err); }
.mbar { display: none; }

/* ------------------------------------------------ dialog */
dialog.dlg { border: 1px solid var(--stroke); border-radius: var(--r2); padding: 0; background: var(--card); color: var(--text); box-shadow: var(--shadow-dlg); width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); }
dialog.dlg.wide { width: min(980px, calc(100vw - 24px)); }
dialog.dlg.full { width: calc(100vw - 24px); height: calc(100vh - 24px); max-width: 1400px; }
dialog.dlg::backdrop { background: rgba(0, 0, 0, .35); }
dialog.dlg[open] { animation: pop .18s cubic-bezier(.1, .9, .2, 1); }
@keyframes pop { from { opacity: 0; transform: scale(.97); } }
.dlg form, .dlg .wrap { display: flex; flex-direction: column; max-height: calc(100vh - 34px); height: 100%; }
.dlg .dh { padding: 20px 24px 8px; display: flex; gap: 12px; align-items: center; }
.dlg .dh h2 { flex: 1; }
.dlg .db { padding: 8px 24px 20px; overflow: auto; display: grid; gap: 14px; align-content: start; flex: 1; }
.dlg .df { padding: 16px 24px; background: var(--card-2); border-top: 1px solid var(--stroke); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.dlg .df .sp { flex: 1; }
.err-msg { color: var(--err); font-size: 13px; }
.zoom svg { width: 100%; height: auto; max-height: 70vh; background: var(--sheet); box-shadow: 0 0 0 1px var(--sheet-line); }
.legend { columns: 2; column-gap: 24px; font-size: 13px; margin: 0; padding: 0; }
.legend li { list-style: none; break-inside: avoid; display: flex; gap: 8px; align-items: baseline; padding: 2px 0; }

/* libreria veicoli */
.vlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.vitem { text-align: left; font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--stroke); border-radius: var(--r2); padding: 10px 12px; cursor: pointer; display: grid; gap: 2px; }
.vitem:hover { background: var(--card-2); border-color: var(--stroke-2); }
.vitem.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.vitem b { font-weight: 600; }
.vitem span { font-size: 12px; color: var(--text-2); }
.vcat { font-size: 12px; color: var(--text-2); margin: 12px 0 6px; font-weight: 600; }

/* foto */
.foto-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; min-height: 0; flex: 1; }
.foto-stage { position: relative; background: #1b1b1b; border-radius: var(--r); overflow: hidden; min-height: 300px; touch-action: none; display: grid; place-items: center; }
.foto-stage canvas { max-width: 100%; max-height: 100%; cursor: crosshair; }
.foto-side { display: grid; gap: 12px; align-content: start; overflow: auto; }
.steps { display: grid; gap: 6px; margin: 0; padding: 0; counter-reset: s; }
.steps li { list-style: none; display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--text-2); }
.steps li::before { counter-increment: s; content: counter(s); flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--subtle-2); font-size: 12px; font-weight: 600; color: var(--text); }
.steps li.on { color: var(--text); }
.steps li.on::before { background: var(--accent); color: var(--on-accent); }
.steps li.done::before { content: "✓"; background: var(--ok-bg); color: var(--ok); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg-mica); }
.login .card { width: min(400px, 100%); padding: 28px; display: grid; gap: 16px; }
.login .brand { margin-bottom: 4px; }
.login .brand .mark { width: 40px; height: 40px; border-radius: 9px; }
.login .brand .mark svg { width: 26px; height: 26px; }
.login .brand b { font-size: 20px; font-family: var(--font-d); }
.login .hint { font-size: 13px; background: var(--info-bg); color: var(--info); border-radius: var(--r); padding: 8px 12px; }
.login .foot { font-size: 12px; color: var(--text-2); text-align: center; }

/* guida */
.guide { max-width: 760px; display: grid; gap: 18px; padding-bottom: 40px; }
.guide section { display: grid; gap: 8px; }
.guide p, .guide li { line-height: 1.6; max-width: 70ch; }
.guide ol, .guide ul { margin: 0; padding-left: 20px; }
.kbd { font-size: 12px; padding: 1px 6px; border: 1px solid var(--stroke-2); border-bottom-width: 2px; border-radius: 4px; background: var(--card); }

/* toast */
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 100; }
.toast { background: var(--card); color: var(--text); border: 1px solid var(--stroke); border-radius: var(--r2); box-shadow: var(--shadow-2); padding: 10px 14px; display: flex; gap: 10px; align-items: center; min-width: 240px; max-width: 380px; animation: slide .25s cubic-bezier(.1, .9, .2, 1); }
.toast .ic { color: var(--ok); }
.toast.err .ic { color: var(--err); }
@keyframes slide { from { transform: translateY(12px); opacity: 0; } }

/* ------------------------------------------------ responsive */
@media (max-width: 1180px) {
  .editor { grid-template-columns: minmax(0, 1fr); }
  .res { position: static; max-height: none; }
  .home { grid-template-columns: minmax(0, 1fr); }
  .jobhead { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
@media (max-width: 860px) {
  :root { --nav-w: 0px; }
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: 48px minmax(0, 1fr); }
  nav.side { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; flex-direction: row; justify-content: space-around; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); z-index: 40; border-top: 1px solid var(--stroke); background: var(--card); overflow: visible; }
  nav.side a { flex-direction: column; gap: 2px; height: 52px; padding: 6px 4px 4px; font-size: 11px; flex: 1; justify-content: center; text-align: center; }
  nav.side a.on::before { left: 30%; right: 30%; top: auto; bottom: 2px; width: auto; height: 3px; }
  nav.side .sep, nav.side .bottom, nav.side a.dk { display: none; }
  main#main { padding: 0 16px 140px; }
  .cmdbar { top: 50px; }
  .cmdbar .btn .lbl { display: none; }
  .cmdbar .search { min-width: 0; flex: 1 1 160px; }
  .grid3, .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .jobhead { grid-template-columns: minmax(0, 1fr); padding: 14px; }
  h1 { font-size: 24px; line-height: 30px; }
  .pagehead { padding-top: 16px; }
  .titlebar .who { display: none; }
  .pz .w-n, .pz .w-q { width: 76px; }
  .tbl.resp thead { display: none; }
  .tbl.resp tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; padding: 10px 4px; border-bottom: 1px solid var(--stroke); }
  .tbl.resp td { border: 0; padding: 1px 6px; }
  .tbl.resp td.hm { display: none; }
  .tbl.resp td.n { grid-column: 2; grid-row: 1; }
  .mbar { display: flex; position: fixed; left: 8px; right: 8px; bottom: calc(68px + env(safe-area-inset-bottom)); z-index: 35; background: var(--text); color: var(--bg); border-radius: var(--r2); padding: 10px 14px; gap: 12px; align-items: center; box-shadow: var(--shadow-2); font-variant-numeric: tabular-nums; border: 0; font: inherit; text-align: left; }
  .mbar b { font-size: 15px; }
  .mbar .sp { flex: 1; }
  .foto-wrap { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(260px, 1fr) auto; }
  .legend { columns: 1; }
  #toasts { left: 12px; right: 12px; bottom: 140px; }
  dialog.dlg .dh { padding: 16px 16px 6px; } dialog.dlg .db { padding: 6px 16px 16px; } dialog.dlg .df { padding: 12px 16px; }
}
@media (max-width: 520px) {
  .grid2, .grid3, .grid4 { grid-template-columns: minmax(0, 1fr); }
  .span2 { grid-column: auto; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* stampa (finestra preventivo/scheda usa stili propri) */
@media print { nav.side, .titlebar, .cmdbar, .mbar, #toasts { display: none !important; } }
nav.side a.mob { display: none; }
@media (max-width: 860px) { nav.side a.mob { display: flex; } }

/* righe dei pezzi su due livelli: nome e materiale sopra, misure sotto */
.pzr, .pzr tbody { display: block; }
.pzr tr { display: grid; grid-template-columns: 28px minmax(0, 1fr) minmax(0, 1fr) 76px 116px minmax(64px, .6fr) 34px; gap: 6px 8px; padding: 10px 0; align-items: center; }
.pzr tr + tr { border-top: 1px solid var(--stroke); }
.pzr tr + tr td { border-top: 0; }
.pzr td { padding: 0; min-width: 0; }
.pzr td[colspan] { grid-column: 1 / -1; }
.pzr td.c-tag { grid-row: span 2; align-self: start; padding-top: 4px; }
.pzr td.c-nome { grid-column: 2 / 4; }
.pzr td.c-mat { grid-column: 4 / 7; }
.pzr td.c-del { grid-column: 7; grid-row: 1; }
.pzr td.c-l { grid-column: 2; grid-row: 2; } .pzr td.c-h { grid-column: 3; grid-row: 2; } .pzr td.c-q { grid-column: 4; grid-row: 2; }
.pzr td.c-d { grid-column: 5; grid-row: 2; } .pzr td.area { grid-column: 6 / 8; grid-row: 2; width: auto; }
.pzr .unit .in { padding-right: 62px; }
.pzr .c-q .unit .in { padding-right: 26px; }
.pzr input[data-k=nome] { font-weight: 600; }
@media (max-width: 860px) {
  .pzr tr { grid-template-columns: 28px minmax(0, 1fr) minmax(0, 1fr) 64px 34px; }
  .pzr td.c-nome { grid-column: 2 / 5; } .pzr td.c-del { grid-column: 5; grid-row: 1; }
  .pzr td.c-mat { grid-column: 2 / 6; grid-row: 2; }
  .pzr td.c-tag { grid-row: span 4; }
  .pzr td.c-l { grid-column: 2; grid-row: 3; } .pzr td.c-h { grid-column: 3; grid-row: 3; } .pzr td.c-q { grid-column: 4 / 6; grid-row: 3; }
  .pzr td.c-d { grid-column: 2 / 4; grid-row: 4; } .pzr td.area { grid-column: 4 / 6; grid-row: 4; }
}
.unit::after { bottom: auto; top: 50%; transform: translateY(-50%); }
.unit input[type=number]::-webkit-inner-spin-button, .unit input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
@media (max-width: 860px) { nav.side a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; } }
.pzr .unit .in { padding-right: 44px; }
@media (max-width: 860px) { .cmdbar .vr { display: none; } .cmdbar { gap: 2px; } }
@media (max-width: 860px) { .cmdbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; } .cmdbar::-webkit-scrollbar { display: none; } .cmdbar .btn { flex: none; } }
