:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e3e5ea;
  --border-strong: #cfd3db;
  --text: #14171c;
  --text-2: #4a5160;
  --muted: #7b8291;
  --brand: #1f3a5f;
  --brand-ink: #ffffff;
  --primary: #1f5fbf;
  --primary-hover: #194f9f;
  --primary-soft: #e8f0fc;
  --danger: #c43030;
  --danger-soft: #fdecec;
  --ok: #117a3a;
  --ok-soft: #e6f5ec;
  --warn: #9a5b00;
  --warn-soft: #fff4dc;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --radius: 10px;
  --sidebar: 236px;
  /* grafici */
  --viz-surface: #fcfcfb;
  --viz-series-1: #2a78d6;
  --viz-grid: #e1e0d9;
  --viz-axis: #898781;
  --viz-ink-2: #52514e;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1d2128;
    --border: #2a2f38;
    --border-strong: #3a404b;
    --text: #eef0f4;
    --text-2: #b9bfcb;
    --muted: #8a91a0;
    --brand: #16283f;
    --primary: #4a8fe8;
    --primary-hover: #6aa3ee;
    --primary-soft: #1b2a40;
    --danger: #ef6b6b;
    --danger-soft: #3a1c1c;
    --ok: #3cc46d;
    --ok-soft: #173024;
    --warn: #f2b545;
    --warn-soft: #3a2e14;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
    --viz-surface: #1a1a19;
    --viz-series-1: #3987e5;
    --viz-grid: #2c2c2a;
    --viz-axis: #898781;
    --viz-ink-2: #c3c2b7;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
h1 > svg, h2 > svg, h3 > svg { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.hidden { display: none !important; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 16px; }

/* ------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  background: var(--brand); color: var(--brand-ink); padding: 16px 12px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand-logo { width: 34px; height: 34px; border-radius: 8px; background: #fff; color: var(--brand); display: grid; place-items: center; font-weight: 800; font-size: 18px; }
.brand-name { font-weight: 700; font-size: 15px; line-height: 1.1; }
.brand-sub { font-size: 11px; opacity: .7; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: rgba(255,255,255,.82);
  font-weight: 500; text-decoration: none;
}
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.active { background: rgba(255,255,255,.16); color: #fff; }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav-sep { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; opacity: .5; padding: 14px 10px 4px; }
.nav-badge { margin-left: auto; background: #fff; color: var(--brand); border-radius: 999px; font-size: 11px; font-weight: 700; padding: 0 7px; }
.sidebar-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.12); font-size: 12px; }
.sidebar-foot .who { font-weight: 600; font-size: 13px; }
.sidebar-foot a { color: rgba(255,255,255,.8); }

.topbar { display: none; }
.scrim { display: none; }
.shell.menu-open .scrim { display: block; }
.main { min-width: 0; padding: 24px 28px 48px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .spacer { flex: 1; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .shell.menu-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .shell.menu-open .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
  .topbar {
    display: flex; align-items: center; gap: 10px; background: var(--brand); color: #fff; padding: 10px 16px;
    position: sticky; top: 0; z-index: 30;
  }
  .topbar button { background: none; border: 0; color: #fff; padding: 4px; display: grid; }
  .topbar .title { font-weight: 600; }
  .main { padding: 16px 16px 90px; }
  h1 { font-size: 19px; }
}

/* ------------------------------------------------------------ controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600;
  cursor: pointer; white-space: nowrap; min-height: 36px; text-decoration: none !important;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.btn.icon { padding: 6px; min-height: 32px; width: 32px; }
.btn svg { width: 16px; height: 16px; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 7px 10px; min-height: 36px; width: 100%;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 35%, transparent); border-color: var(--primary); }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--primary); }
input[type="color"] { padding: 2px; width: 60px; }
input.num-in { text-align: right; font-variant-numeric: tabular-nums; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label, .lbl { font-size: 12px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.grid { display: grid; gap: 12px; }
.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)); }
.span2 { grid-column: span 2; }
@media (max-width: 700px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr 1fr; }
  .span2 { grid-column: span 2; }
}
@media (max-width: 460px) {
  .g3, .g4 { grid-template-columns: 1fr; }
  .g2 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
}

.search { position: relative; flex: 1; min-width: 200px; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.search input { padding-left: 34px; }

.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 7px 14px; font: inherit; font-weight: 600; color: var(--text-2); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button.on { background: var(--primary); color: #fff; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border-strong); background: var(--surface); border-radius: 999px; padding: 4px 12px; font: inherit;
  font-size: 13px; cursor: pointer; color: var(--text-2);
}
.chip.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }

/* ------------------------------------------------------------ cards & tables */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.card-head .spacer { flex: 1; }

.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap; position: sticky; top: 0;
}
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover td { background: var(--surface-2); }
.tbl th.num, .tbl td.num { text-align: right; }
.tbl .code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; color: var(--text-2); }
.tbl input { min-height: 32px; padding: 4px 8px; }
.tbl tfoot td { font-weight: 700; background: var(--surface-2); }

/* Tabelle che diventano schede su schermi piccoli */
@media (max-width: 700px) {
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr { border-bottom: 1px solid var(--border); padding: 10px 12px; position: relative; }
  table.cards td { border: 0; padding: 2px 0; text-align: left !important; }
  table.cards td[data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-size: 12px; }
  table.cards td.primary-cell { font-weight: 600; font-size: 15px; }
  table.cards td.actions-cell { padding-top: 6px; }
}

.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.empty svg { width: 36px; height: 36px; opacity: .5; display: block; margin: 0 auto 8px; }

.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-bozza { background: #eef0f3; color: #4a5160; }
.st-inviato { background: #e5efff; color: #1f5fbf; }
.st-in_preparazione { background: #fff1d6; color: #8a5300; }
.st-pronto { background: #efe9ff; color: #5b3cc4; }
.st-consegnato { background: #e3f5ea; color: #117a3a; }
.st-annullato { background: #fdeaea; color: #b42727; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .st-bozza { background: #262a31; color: #b9bfcb; }
  :root:not([data-theme="light"]) .st-inviato { background: #18294a; color: #7fb0f5; }
  :root:not([data-theme="light"]) .st-in_preparazione { background: #3a2c10; color: #f2b545; }
  :root:not([data-theme="light"]) .st-pronto { background: #2a2146; color: #b3a1ff; }
  :root:not([data-theme="light"]) .st-consegnato { background: #15301f; color: #4fd07f; }
  :root:not([data-theme="light"]) .st-annullato { background: #3a1b1b; color: #f08a8a; }
}
.tag { display: inline-block; border-radius: 6px; padding: 1px 7px; font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.tag.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); font-weight: 600; }
.tag.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); font-weight: 600; }
.tag.bad { background: var(--danger-soft); border-color: transparent; color: var(--danger); font-weight: 600; }
.alert { border-radius: 8px; padding: 10px 12px; background: var(--warn-soft); color: var(--warn); font-weight: 500; }
.alert.info { background: var(--primary-soft); color: var(--primary); }
.alert.bad { background: var(--danger-soft); color: var(--danger); }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* ------------------------------------------------------------ modal & toast */
.modal-back { position: fixed; inset: 0; background: rgba(10, 14, 22, .45); z-index: 100; display: grid; place-items: center; padding: 16px; }
.modal {
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: min(640px, 100%); max-height: calc(100vh - 32px);
  display: flex; flex-direction: column;
}
.modal.wide { width: min(980px, 100%); }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; flex: 1; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--border); flex-wrap: wrap; }
@media (max-width: 600px) {
  .modal-back { padding: 0; place-items: end stretch; }
  .modal { border-radius: 14px 14px 0 0; max-height: 92vh; }
}

#toasts { position: fixed; bottom: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast { background: #1d2430; color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 500; animation: tin .18s ease-out; }
.toast.err { background: #a82525; }
.toast.ok { background: #136b36; }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

/* ------------------------------------------------------------ login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, #1f3a5f, #0f1f35); }
.login { width: min(380px, 100%); background: var(--surface); border-radius: 16px; padding: 28px; box-shadow: var(--shadow-lg); }
.login .brand-logo { background: var(--brand); color: #fff; width: 44px; height: 44px; font-size: 22px; margin-bottom: 14px; }

/* ------------------------------------------------------------ listino */
.price { font-weight: 700; font-variant-numeric: tabular-nums; }
.qty-add { display: flex; gap: 4px; align-items: center; justify-content: flex-end; }
.qty-add input { width: 70px; }
.stock-ok { color: var(--ok); font-weight: 600; }
.stock-low { color: var(--warn); font-weight: 600; }
.stock-no { color: var(--danger); font-weight: 600; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-top: 1px solid var(--border); }

.cart-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 20; display: none; box-shadow: var(--shadow-lg); border-radius: 999px; padding: 12px 18px;
}
.cart-fab.show { display: inline-flex; }

/* ------------------------------------------------------------ editor ordine */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.editor-side { position: sticky; top: 16px; }
@media (max-width: 1100px) { .editor { grid-template-columns: 1fr; } .editor-side { position: static; } }

.typeahead { position: relative; }
.ta-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px;
  box-shadow: var(--shadow-lg); z-index: 60; max-height: 360px; overflow-y: auto;
}
.ta-item { padding: 9px 12px; cursor: pointer; display: flex; gap: 10px; align-items: center; border-bottom: 1px solid var(--border); }
.ta-item:last-child { border-bottom: 0; }
.ta-item:hover, .ta-item.hl { background: var(--primary-soft); }
.ta-item .ta-main { flex: 1; min-width: 0; }
.ta-item .ta-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.ta-item .ta-sub { font-size: 12px; color: var(--muted); }

.totals { width: 100%; }
.totals td { padding: 4px 0; }
.totals td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.totals tr.big td { font-size: 18px; font-weight: 800; padding-top: 8px; border-top: 1px solid var(--border); }

.map { height: 320px; border-radius: 10px; border: 1px solid var(--border); z-index: 0; }
.map.tall { height: 460px; }
.vehicle-opt { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.vehicle-opt.on { border-color: var(--primary); background: var(--primary-soft); }
.vehicle-opt .grow { flex: 1; }
.sugg { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; cursor: pointer; display: flex; gap: 10px; align-items: center; }
.sugg:hover { border-color: var(--primary); }

.satbar { height: 8px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.satbar > span { display: block; height: 100%; border-radius: 4px; background: var(--primary); }
.satbar.over > span { background: var(--danger); }

/* ------------------------------------------------------------ calendario consegne */
.cal { display: grid; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.cal-h { background: var(--surface-2); padding: 8px 10px; font-weight: 600; font-size: 12px; color: var(--text-2); }
.cal-h.today { color: var(--primary); }
.cal-v { background: var(--surface-2); padding: 10px; font-weight: 600; display: flex; flex-direction: column; gap: 2px; }
.cal-c { background: var(--surface); padding: 6px; min-height: 92px; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.cal-c.today { background: color-mix(in srgb, var(--primary-soft) 55%, var(--surface)); }
.cal-load { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; gap: 4px; }
.stop {
  border-left: 3px solid var(--c, var(--primary)); background: var(--surface-2); border-radius: 6px; padding: 4px 6px; font-size: 12px; cursor: pointer;
  line-height: 1.25; overflow: hidden;
}
.stop:hover { background: var(--primary-soft); }
.stop.bozza { opacity: .6; border-left-style: dashed; }
.stop-tag {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase;
  color: var(--text-2); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 4px; padding: 0 4px; margin-bottom: 2px;
}
.stop b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-scroll { overflow-x: auto; }
.cal-scroll .cal { min-width: 860px; }

/* ------------------------------------------------------------ statistiche */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .k-l { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .k-v { font-size: 24px; font-weight: 700; margin-top: 2px; letter-spacing: -.01em; }
.kpi .k-s { font-size: 12px; color: var(--text-2); }
.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 380px; }
.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1000px) { .stats-grid { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------ import */
.steps { display: flex; gap: 8px; list-style: none; padding: 0; margin: -4px 0 18px; flex-wrap: wrap; }
.steps li { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 600; font-size: 13px; }
.steps li + li::before { content: ""; width: 28px; height: 1px; background: var(--border-strong); margin-right: 4px; }
.steps li span {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px;
  border: 1px solid var(--border-strong); background: var(--surface);
}
.steps li.on { color: var(--text); }
.steps li.on span { background: var(--primary); border-color: var(--primary); color: #fff; }
.steps li.done span { background: var(--ok-soft); border-color: transparent; color: var(--ok); }

.import-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(260px, 2fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .import-grid { grid-template-columns: 1fr; } }
.drop {
  border: 2px dashed var(--border-strong); border-radius: 12px; padding: 28px 16px; color: var(--text-2); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; transition: border-color .15s, background .15s;
}
.drop:hover { border-color: var(--primary); }
.drop.over { border-color: var(--primary); background: var(--primary-soft); }
.drop-icon { width: 52px; height: 52px; border-radius: 14px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }
.drop-icon svg { width: 26px; height: 26px; }
.drop-title { font-weight: 700; font-size: 15px; color: var(--text); }
.col-list { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: 13px; }
.col-list li::before { content: "·"; color: var(--muted); margin-right: 6px; }

.file-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.file-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; flex: none; }
.file-icon svg { width: 20px; height: 20px; }

.map-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.map-field { border: 1px solid var(--border); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 6px; background: var(--surface-2); }
.map-field.set { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); background: var(--surface); }
.map-field label { font-size: 12px; font-weight: 700; color: var(--text-2); }
.map-field .req { color: var(--danger); }
.map-field .ex { min-height: 18px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.preview td, .preview th { font-size: 12px; padding: 6px 10px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview .mapped { background: color-mix(in srgb, var(--primary-soft) 70%, transparent); }
.preview th.mapped { color: var(--primary); background: color-mix(in srgb, var(--primary-soft) 70%, var(--surface-2)); z-index: 1; }
.col-map { font-size: 11px; font-weight: 700; color: var(--primary); min-height: 14px; }

.action-bar {
  position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow-lg);
}
.ok-circle { width: 32px; height: 32px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; font-weight: 800; }

/* ------------------------------------------------------------ noleggi */
.nav-badge.late { background: #ffd9d9; color: #a11d1d; }
.foto-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.foto-item { position: relative; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.foto-item img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; display: block; }
.foto-del {
  position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(0, 0, 0, .6); color: #fff; display: grid; place-items: center; padding: 0;
}
.foto-del svg { width: 14px; height: 14px; }
.foto-add {
  aspect-ratio: 4 / 3; border: 2px dashed var(--border-strong); border-radius: 8px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px; color: var(--primary); cursor: pointer; font-size: 12px; font-weight: 600;
}
.foto-add:hover { border-color: var(--primary); background: var(--primary-soft); }
.foto-add svg { width: 24px; height: 24px; }
.trasporto { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--surface-2); min-width: 0; }
.trasporto .lbl { margin-bottom: 6px; }
.seg-wide { display: flex; width: 100%; }
.seg-wide button { flex: 1; white-space: normal; line-height: 1.25; padding: 8px 10px; }
.riga-addebito td { background: color-mix(in srgb, var(--warn-soft) 40%, transparent); }
.firme { display: none; }

/* ------------------------------------------------------------ stampa */
.print-only { display: none; }
@media print {
  /* sempre chiaro su carta, anche se il computer usa il tema scuro */
  :root:not(.__stampa), :root:not(.__stampa)[data-theme] {
    color-scheme: light;
    --bg: #fff; --surface: #fff; --surface-2: #f3f3f3; --border: #bbb; --border-strong: #999;
    --text: #000; --text-2: #222; --muted: #555; --primary: #000; --primary-soft: #eee;
  }
  .badge, .tag { background: none !important; color: #000 !important; }
  body { background: #fff; color: #000; font-size: 12px; }
  .sidebar, .topbar, .no-print, .cart-fab, #toasts { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .print-only { display: block; }
  .editor { display: block; }
  .tbl th { background: #eee !important; position: static; }
  a { color: #000; }
  /* documento di uscita / rientro noleggio */
  .print-head { border-bottom: 2px solid #000; padding-bottom: 8px; margin-bottom: 12px; }
  body[data-print="uscita"] .fase-rientro, body[data-print="uscita"] .riga-addebito { display: none !important; }
  body[data-print] .editor-side { display: none !important; }
  body[data-print] .card { border: 1px solid #bbb; padding: 10px; margin-bottom: 10px; break-inside: avoid; }
  .foto-grid { grid-template-columns: repeat(4, 1fr); }
  .foto-add, .foto-del { display: none !important; }
  .firme { display: grid !important; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 40px; font-size: 12px; }
  .firma-line { border-bottom: 1px solid #000; height: 48px; margin-bottom: 4px; }
  .badge, .tag { border: 1px solid #999; }
}
