/* Tema grafico ripreso dal Prototipo 3 (assets/style.css, rev. 06/11/2026; la base è quella del Prototipo 2 del 25/10/2026). Le aggiunte vanno in app.css. */
/* Mondo Cucina · Gestionale logistica — prototipo */
:root {
  --xl-light: #f2f8ee;
  --xl-green: #dcecd2;
  --xl-hover: #c9e2bb;
  --xl-head: #c6e0b4;
  --xl-line: #c3dbb4;
  --bg: #f4f3f0;
  --surface: #ffffff;
  --surface-2: #faf9f7;
  --surface-3: #f0eee9;
  --line: #e4e1da;
  --line-strong: #cfcac0;
  --ink: #1d1c1a;
  --ink-2: #55534e;
  --ink-3: #8a877f;
  --brand: #0f5e4f;
  --brand-2: #127562;
  --brand-soft: #e3f0ec;
  --brand-ink: #0b4a3e;
  --sidebar: #17201e;
  --sidebar-2: #212c29;
  --sidebar-ink: #c9d3cf;
  --ext: #6250d6;
  --ext-soft: #efedfc;
  --ext-yes: #0e7c86; /* esterni YES: YES incassa e paga il montatore */
  --manual: #c98500;
  --manual-soft: #fff6df;
  --good: #1a7f4b;
  --good-soft: #e3f4ea;
  --warn: #b26b00;
  --warn-soft: #fff1d6;
  --bad: #c43d3c;
  --bad-soft: #fde8e7;
  --info-soft: #e7f0fb;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-7: #6250d6;
  --sel: #2a78d6;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(20, 18, 14, .06), 0 4px 16px rgba(20, 18, 14, .05);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); font-size: 13px; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-2); text-decoration: none; }
.hidden { display: none !important; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.small { font-size: 11.5px; }

/* ---------- Login ---------- */
.login { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.login-hero { background: var(--sidebar); color: #e8efec; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-hero::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%; background: radial-gradient(circle, rgba(18,117,98,.55), rgba(18,117,98,0) 70%); }
.login-hero h1 { font-size: 34px; line-height: 1.15; font-weight: 600; margin: 0 0 14px; max-width: 520px; letter-spacing: -.01em; }
.login-hero p { color: #a9b8b3; max-width: 480px; line-height: 1.55; font-size: 14px; }
.login-feats { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 28px; max-width: 520px; position: relative; z-index: 1; }
.login-feats div { font-size: 13px; color: #c9d3cf; border-left: 2px solid #2f8a76; padding-left: 10px; }
.login-feats b { display: block; color: #fff; font-weight: 600; margin-bottom: 2px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: .01em; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; background: linear-gradient(135deg, #1b8a72, #0f5e4f); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.login-form-wrap { display: grid; place-items: center; padding: 40px; background: var(--surface); }
.login-form { width: 100%; max-width: 360px; }
.login-form h2 { font-size: 22px; margin: 0 0 6px; font-weight: 600; }
.login-form .sub { color: var(--ink-2); margin-bottom: 26px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.input { height: 36px; border: 1px solid var(--line-strong); border-radius: 7px; padding: 0 11px; background: #fff; outline: none; transition: border-color .12s, box-shadow .12s; }
.input:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(18,117,98,.15); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 7px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-3); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 6px; }
.btn.block { width: 100%; height: 38px; }
.btn svg { width: 15px; height: 15px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; background: var(--brand-2); flex: none; }
.login-err { color: var(--bad); font-size: 12.5px; min-height: 18px; margin-bottom: 6px; }

/* ---------- Shell (navbar in alto) ---------- */
.app { display: flex; flex-direction: column; height: 100vh; }
.hnav { height: 46px; flex: none; display: flex; align-items: center; gap: 6px; padding: 0 10px 0 12px; background: var(--sidebar); color: var(--sidebar-ink); }
.hnav .brand { color: #fff; font-size: 13px; white-space: nowrap; margin-right: 14px; }
.hnav .brand-mark { width: 28px; height: 28px; font-size: 11px; border-radius: 7px; }
.hnav .brand small { display: block; font-weight: 400; color: #8fa29c; font-size: 10.5px; line-height: 1.1; }
.hnav .sp { flex: 1; }
.nav { display: flex; align-items: center; gap: 2px; min-width: 0; overflow: hidden; }
.nav a { display: flex; align-items: center; gap: 7px; color: var(--sidebar-ink); padding: 6px 10px; border-radius: 7px; white-space: nowrap; font-size: 12.5px; }
.nav a:hover { background: var(--sidebar-2); color: #fff; }
.nav a.active { background: #26443d; color: #fff; box-shadow: inset 0 -2px 0 #3fb393; }
.nav a svg { width: 16px; height: 16px; flex: none; opacity: .9; }
.nav a .badge { background: #c43d3c; color: #fff; font-size: 10px; border-radius: 9px; padding: 0 6px; font-weight: 600; font-style: normal; }
.hnav .btn { color: var(--sidebar-ink); }
.hnav .btn:hover { background: var(--sidebar-2); }
.hnav .who { display: flex; align-items: center; gap: 7px; font-size: 12px; color: #e8efec; margin-left: 6px; white-space: nowrap; }
.hnav .who .avatar { width: 26px; height: 26px; font-size: 10.5px; }
.hnav .proto-tag { background: rgba(255,241,214,.12); color: #f3d79a; border-color: rgba(243,220,174,.25); }
@media (max-width: 1280px) { .nav a span { display: none; } .nav a.active span { display: inline; } .hnav .brand-txt, .hnav .who span { display: none; } }
.proto-tag { font-size: 11px; color: var(--warn); background: var(--warn-soft); border: 1px solid #f3dcae; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.content { flex: 1; min-height: 0; overflow: auto; padding: 14px 16px 18px; }
.content.flush { padding: 0; display: flex; flex-direction: column; overflow: hidden; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: 8px; padding: 9px 12px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.toolbar .sp { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 7px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 0 11px; height: 28px; cursor: pointer; font-size: 12.5px; color: var(--ink-2); border-right: 1px solid var(--line); white-space: nowrap; }
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--surface-3); }
.seg button.on { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.seg button .c { font-size: 11px; color: var(--ink-3); margin-left: 4px; font-weight: 400; }
.sel, .search { height: 28px; border: 1px solid var(--line-strong); border-radius: 7px; padding: 0 8px; background: #fff; font-size: 12.5px; outline: none; }
.search { padding-left: 28px; width: 200px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%238a877f' stroke-width='2' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 9px center; }
.sel:focus, .search:focus { border-color: var(--brand-2); }
.tb-label { font-size: 12px; color: var(--ink-3); }
.legend-inline { display: flex; gap: 12px; align-items: center; font-size: 11.5px; color: var(--ink-2); }
.legend-inline i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }

/* ---------- Excel-like grid ---------- */
.grid-wrap { flex: 1; min-height: 0; overflow: auto; background: var(--surface); position: relative; }
table.grid { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0; font-size: 11.5px; }
.grid th, .grid td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0 4px; height: 26px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid thead th { position: sticky; z-index: 3; background: var(--surface-3); font-weight: 600; color: var(--ink-2); font-size: 11px; text-align: left; user-select: none; }
.grid thead tr.grp th { top: 0; height: 20px; font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); background: var(--surface-2); text-align: center; }
.grid thead tr.hdr th { top: 20px; cursor: pointer; }
.grid thead tr.hdr th.num { text-align: right; }
.grid thead tr.hdr th:hover { background: #e8e5de; }
.grid thead tr.flt th { top: 46px; background: var(--surface-2); padding: 2px 2px; height: 26px; cursor: default; }
.grid thead tr.flt input { width: 100%; height: 21px; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; font-size: 11px; background: #fff; outline: none; }
.grid thead tr.flt input:focus { border-color: var(--sel); }
.grid thead th .sort { color: var(--brand-2); font-size: 9px; margin-left: 2px; }
.grid thead th.calc-h { color: var(--brand-ink); }
.grid thead th.calc-h::before { content: "ƒ"; font-style: italic; font-family: Georgia, serif; margin-right: 3px; color: var(--brand-2); font-weight: 400; }
.grid tbody td { background: var(--surface); position: relative; cursor: cell; }
.grid tbody tr:nth-child(even) td { background: #fbfbf9; }
.grid tbody tr:hover td { background: #f3f7f6; }
.grid td.rh, .grid th.rh { background: var(--surface-3) !important; color: var(--ink-3); text-align: center; font-size: 10.5px; padding: 0 2px; cursor: context-menu; position: sticky; left: 0; z-index: 2; }
.grid thead th.rh { z-index: 4; }
.grid tr.sel-row td.rh { background: #dfe9f7 !important; color: var(--sel); font-weight: 600; }
.grid td.active { outline: 2px solid var(--sel); outline-offset: -2px; z-index: 1; }
.grid td.calc { color: var(--ink-2); }
.grid td.calc.zero, .grid tr.est td.calc.zero { color: transparent; }
.grid td.manual { color: var(--ink); font-weight: 600; }
.grid td.manual::before { content: ""; position: absolute; left: 0; top: 0; border-style: solid; border-width: 6px 6px 0 0; border-color: var(--manual) transparent transparent transparent; }
.grid td.prov { color: var(--ink-3); font-style: italic; }
.grid td.tot { font-weight: 700; color: var(--ink); background: #f6f8f7 !important; }
.grid td.ro { cursor: default; }
.grid td.ph { color: var(--ink-3); font-style: italic; }
.grid td.bad-ref { color: var(--bad); text-decoration: underline dotted; }
.grid tr.est td:not(.rh) { background: #f8f7fe; }
.grid tr.est:nth-child(even) td:not(.rh) { background: #f4f2fd; }
.grid tr.est td.rh { box-shadow: inset 3px 0 0 var(--ext); }
.grid tr.est td.to-mont { color: var(--ext); }
.grid tr.est td.to-mont:not(.zero)::after { content: "↗"; font-size: 9px; margin-left: 2px; }
.grid tr.new td:not(.rh) { background: #fffbea !important; }
.grid td.editing { padding: 0; outline: 2px solid var(--sel); outline-offset: -2px; overflow: visible; z-index: 5; }
.grid td.editing input, .grid td.editing select { width: 100%; height: 25px; border: 0; padding: 0 5px; font-size: 12px; outline: none; background: #fff; }
.grid td.editing input.formula { font-family: var(--mono); font-size: 11.5px; color: var(--brand-ink); }
.grid td.editing.wide input { position: absolute; left: 0; top: 0; min-width: 240px; box-shadow: 0 4px 14px rgba(0,0,0,.14); border: 2px solid var(--sel); height: 27px; }
.flag { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 4px; border: 1.5px solid var(--line-strong); font-size: 9.5px; font-weight: 700; color: transparent; vertical-align: middle; }
.flag.on { background: var(--ext); border-color: var(--ext); color: #fff; }
.chip { display: inline-block; padding: 0 5px; height: 17px; line-height: 17px; border-radius: 4px; font-size: 10.5px; font-weight: 600; background: var(--surface-3); color: var(--ink-2); }
.chip.CUC { background: #e3eefb; color: #1c5cab; }
.chip.ASS { background: #fde9e1; color: #a8461f; }
.chip.GN { background: #e2f5ed; color: #11744f; }
.chip.COM { background: #fff2d6; color: #8a5c00; }
.chip.VAR { background: #ece8f7; color: #5a45a0; }
.chip.ESP { background: #fbe6ee; color: #a3325c; }
.pag { font-weight: 700; font-size: 11px; }
.pag.P { color: var(--good); }
.pag.X { color: var(--bad); }
.grid tfoot td { position: sticky; bottom: 0; background: var(--surface-3); font-weight: 700; border-top: 1px solid var(--line-strong); z-index: 2; font-size: 11px; padding: 0 3px; }
.grid tfoot td.rh { z-index: 3; }
.grid tfoot tr.f2 td { bottom: 0; }
.grid tfoot tr.f1 td { bottom: 26px; }
.grid tfoot td.ext-tot { color: var(--ext); }
.statusbar { flex: none; display: flex; align-items: center; gap: 16px; padding: 0 12px; height: 32px; border-top: 1px solid var(--line); background: var(--surface-2); font-size: 12px; color: var(--ink-2); }
.statusbar .sp { flex: 1; }
.statusbar b { color: var(--ink); font-variant-numeric: tabular-nums; }
.formula-bar { flex: none; display: flex; align-items: center; gap: 0; height: 30px; border-bottom: 1px solid var(--line); background: var(--surface); font-size: 12px; }
.formula-bar .ref { width: 150px; padding: 0 10px; border-right: 1px solid var(--line); height: 100%; display: flex; align-items: center; color: var(--ink-2); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.formula-bar .fx { width: 30px; text-align: center; font-style: italic; font-family: Georgia, serif; color: var(--brand-2); border-right: 1px solid var(--line); height: 100%; display: grid; place-items: center; }
.formula-bar .expr { flex: 1; padding: 0 10px; font-family: var(--mono); font-size: 11.5px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.formula-bar .expr .muted { font-family: var(--font); }
.formula-bar .expr .src { font-family: var(--font); font-size: 11px; margin-left: 10px; padding: 1px 7px; border-radius: 9px; background: var(--surface-3); color: var(--ink-2); }
.formula-bar .expr .src.man { background: var(--manual-soft); color: var(--manual); }
.formula-bar .expr .src.ext { background: var(--ext-soft); color: var(--ext); }

.pager { display: flex; align-items: center; gap: 6px; }

/* context menu */
.ctx { position: fixed; z-index: 100; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: 0 8px 28px rgba(0,0,0,.16); padding: 4px; min-width: 220px; font-size: 12.5px; }
.ctx div { padding: 7px 10px; border-radius: 5px; cursor: pointer; display: flex; gap: 8px; align-items: center; }
.ctx div:hover { background: var(--surface-3); }
.ctx div.danger { color: var(--bad); }
.ctx hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.ctx .k { margin-left: auto; color: var(--ink-3); font-size: 11px; }

/* ---------- Cards / pages ---------- */
.page-h { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 14px; }
.page-h h2 { margin: 0; font-size: 18px; font-weight: 600; }
.page-h p { margin: 3px 0 0; color: var(--ink-2); }
.page-h .sp { flex: 1; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.card-h h3 { margin: 0; font-size: 13.5px; font-weight: 600; }
.card-h .sp { flex: 1; }
.card-b { padding: 14px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 14px; box-shadow: var(--shadow); }
.kpi .l { font-size: 11.5px; color: var(--ink-2); font-weight: 500; }
.kpi .v { font-size: 23px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi .d { font-size: 11.5px; margin-top: 3px; color: var(--ink-3); }
.kpi .d .up { color: var(--good); font-weight: 600; }
.kpi .d .down { color: var(--bad); font-weight: 600; }
.kpi.ext { border-top: 3px solid var(--ext); }
.kpi.warn { border-top: 3px solid var(--warn); }
.kpi.kb { border-top: 3px solid var(--brand-2); }
.kpi.bad { border-top: 3px solid var(--bad); }
.two { display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; }
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 1250px) { .two, .cols-2 { grid-template-columns: 1fr; } }

table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th { text-align: left; font-size: 11px; color: var(--ink-2); font-weight: 600; padding: 7px 10px; border-bottom: 1px solid var(--line-strong); background: var(--surface-2); white-space: nowrap; }
.tbl th.num { text-align: right; }
.tbl td { padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl tr:hover td { background: #f7f8f7; }
.tbl tfoot td { font-weight: 700; background: var(--surface-3); border-top: 1px solid var(--line-strong); }
.tbl td.pos { color: var(--good); }
.tbl td.neg { color: var(--bad); }
.tbl .sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: #1c5cab; }
.pill.neutral { background: var(--surface-3); color: var(--ink-2); }
.pill.ext { background: var(--ext-soft); color: var(--ext); }

/* report layout */
.rep { display: grid; grid-template-columns: 236px 1fr; gap: 14px; align-items: start; }
.rep-nav { position: sticky; top: 0; }
.rep-nav a { display: block; padding: 9px 12px; border-radius: 7px; color: var(--ink); border: 1px solid transparent; margin-bottom: 3px; }
.rep-nav a small { display: block; color: var(--ink-3); font-size: 11.5px; margin-top: 1px; }
.rep-nav a:hover { background: var(--surface); border-color: var(--line); }
.rep-nav a.active { background: var(--surface); border-color: var(--brand-2); box-shadow: inset 3px 0 0 var(--brand-2); }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* charts */
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .ax { font-size: 10.5px; fill: var(--ink-3); }
.chart .grid-l { stroke: #ebe8e2; stroke-width: 1; }
.chart .base { stroke: var(--line-strong); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); margin-bottom: 8px; flex-wrap: wrap; }
.legend span i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.tip { position: fixed; pointer-events: none; z-index: 200; background: #1d1c1a; color: #fff; padding: 7px 9px; border-radius: 6px; font-size: 11.5px; line-height: 1.45; box-shadow: 0 4px 14px rgba(0,0,0,.2); white-space: nowrap; }
.tip b { font-weight: 600; }
.tip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }
.hbar { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 12px; }
.hbar .lab { width: 92px; color: var(--ink-2); flex: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar .track { flex: 1; height: 14px; display: flex; gap: 2px; }
.hbar .track span { height: 100%; border-radius: 2px; }
.hbar .track span:last-child { border-radius: 2px 4px 4px 2px; }
.hbar .val { width: 84px; text-align: right; font-variant-numeric: tabular-nums; flex: none; }

/* depositi */
table.dep { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0; font-size: 12px; background: var(--surface); }
.dep th { position: sticky; top: 0; z-index: 2; background: var(--surface-3); font-size: 11px; color: var(--ink-2); font-weight: 600; padding: 6px 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line-strong); text-align: left; }
.dep th.num { text-align: right; }
.dep td { height: 26px; padding: 0 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: relative; }
.dep td.ed { cursor: cell; }
.dep td.active { outline: 2px solid var(--sel); outline-offset: -2px; }
.dep td.editing { padding: 0; outline: 2px solid var(--sel); outline-offset: -2px; }
.dep td.editing input { width: 100%; height: 25px; border: 0; padding: 0 6px; outline: none; font-size: 12px; }
.dep td.pr { background: #eef5ee; vertical-align: top; padding-top: 5px; }
.dep td.pr-imp { background: #fff3c9; font-weight: 700; font-size: 14px; text-align: right; vertical-align: top; padding-top: 4px; }
.dep td.pr-res { background: #fff3c9; font-weight: 700; font-size: 14px; text-align: right; vertical-align: top; padding-top: 4px; }
.dep td.pr-res.open { background: var(--bad); color: #fff; }
.dep td.pr-res.closed { background: var(--good-soft); color: var(--good); }
.dep tr.contr td.c-desc { background: #e9f1f8; font-weight: 600; color: #1c4f86; }
.dep tr.contr td.c-std { background: #e9f1f8; }
.dep tr.scad td.s-left { background: #f3f8fc; }
.dep tr.scad td.s-right { background: #fdf3ef; }
.dep tr.scad td.s-imp { background: #f3f8fc; font-weight: 600; }
.dep td.no { background: var(--bad) !important; color: #fff; font-weight: 700; text-align: center; }
.dep tr.tot td { background: var(--surface-2); font-weight: 700; }
.dep tr.tot td.t-g { background: #4f7a35; color: #fff; text-align: center; }
.dep tr.sepr td { height: 10px; background: var(--bg); border-right: 0; border-bottom: 0; }
.dep .acts { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(20,18,14,.38); z-index: 150; display: grid; place-items: center; }
.modal { background: var(--surface); border-radius: 10px; width: 480px; max-width: calc(100vw - 32px); box-shadow: 0 18px 50px rgba(0,0,0,.25); }
.modal-h { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-h h3 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-b { padding: 16px 18px; }
.modal-f { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.preview { background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: 7px; padding: 10px; font-size: 12px; max-height: 190px; overflow: auto; }

/* parametri */
.formula-in { width: 100%; font-family: var(--mono); font-size: 12px; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; outline: none; background: #fbfcfb; color: var(--brand-ink); }
.formula-in:focus { border-color: var(--brand-2); background: #fff; }
.formula-in.err { border-color: var(--bad); background: var(--bad-soft); }
.vars { display: flex; flex-wrap: wrap; gap: 5px; }
.vars code { font-family: var(--mono); font-size: 11px; background: var(--surface-3); padding: 2px 6px; border-radius: 4px; color: var(--ink-2); cursor: pointer; }
.vars code.p { background: var(--brand-soft); color: var(--brand-ink); }
.note { background: var(--info-soft); border: 1px solid #cddff5; border-radius: 8px; padding: 10px 12px; font-size: 12.5px; color: #24456e; line-height: 1.5; }
.note.ext { background: var(--ext-soft); border-color: #dcd7f8; color: #3d3196; }
.cell-in { width: 100%; height: 26px; border: 1px solid transparent; border-radius: 4px; padding: 0 6px; background: transparent; outline: none; font-size: 12.5px; }
.cell-in:hover { border-color: var(--line); background: #fff; }
.cell-in:focus { border-color: var(--brand-2); background: #fff; }
.cell-in.num { text-align: right; }
.cell-in.formula { font-family: var(--mono); font-size: 11.5px; color: var(--brand-ink); }
.cell-in.manual { color: var(--manual); font-weight: 600; }
.cell-in.manual:not(:focus):not(:hover) { border-color: var(--manual-soft); background: var(--manual-soft); }
.cell-in.bad-ref { color: var(--bad); text-decoration: underline dotted; }
.cell-in.to-mont { color: var(--ext); }
.cell-in.ext { color: var(--ext); font-weight: 600; }
.tbl tr.est td { background: #f8f7fe; }
.tbl tr.est:hover td { background: #f3f1fc; }
.tbl tr.new td { background: #fffbea; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tabs a { padding: 8px 14px; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--brand-ink); border-bottom-color: var(--brand-2); font-weight: 600; }
.tabs a .c { font-size: 11px; color: var(--ink-3); margin-left: 4px; font-weight: 400; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #1d1c1a; color: #fff; padding: 9px 16px; border-radius: 8px; font-size: 12.5px; z-index: 300; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.empty { padding: 40px; text-align: center; color: var(--ink-3); }
.list-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.list-row:last-child { border-bottom: 0; }
.list-row .sp { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media print {
  .hnav, .rep-nav, .toolbar .btn, .filters .btn { display: none !important; }
  .app { display: block; }
  .rep { display: block; }
  .content { overflow: visible; }
}

.rep > div, .two > *, .cols-2 > * { min-width: 0; }
.card-b { overflow-x: auto; }

/* ---------- IN-OUT prototipo 2: tabella editabile a tutta larghezza, senza scroll orizzontale ---------- */
table.tbl2 { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0; font-size: 11.5px; background: var(--surface); }
.tbl2 th { position: sticky; top: 0; z-index: 2; background: var(--surface-3); color: var(--ink-2); font-size: 11px; font-weight: 600; text-align: left; padding: 0 4px; height: 28px; border-bottom: 1px solid var(--line-strong); border-right: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tbl2 th.num { text-align: right; }
.tbl2 th.calc-h { color: var(--brand-ink); }
.tbl2 th.calc-h::before { content: "ƒ"; font-style: italic; font-family: Georgia, serif; margin-right: 2px; color: var(--brand-2); font-weight: 400; }
.tbl2 td { padding: 0; height: 26px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tbl2 tbody tr:nth-child(odd) td { background: var(--xl-light); }
.tbl2 tbody tr:nth-child(even) td { background: var(--xl-green); }
.tbl2 tbody tr:hover td { background: var(--xl-hover); }
.tbl2 tr.est td.c-flag { box-shadow: inset 3px 0 0 var(--ext); }
.tbl2 tr.new td { background: #fffbea !important; }
.tbl2 .ci { display: block; width: 100%; height: 25px; border: 0; background: transparent; padding: 0 3px; font-size: 11.5px; outline: none; border-radius: 0; color: var(--ink); text-overflow: ellipsis; }
.tbl2 select.ci { -webkit-appearance: none; appearance: none; cursor: pointer; padding-right: 2px; font-weight: 600; }
.tbl2 .ci:hover { background: #fff; box-shadow: 0 0 0 1px var(--line-strong) inset; }
.tbl2 .ci:focus { background: #fff; box-shadow: 0 0 0 2px var(--sel) inset; }
.tbl2 .ci:focus::placeholder { color: var(--ink-3); }
.tbl2 .ci.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl2 .ci::placeholder { color: var(--ink-3); opacity: .8; }
.tbl2 .ci.calc { color: var(--ink-2); }
.tbl2 .ci.calc.editing { font-family: var(--mono); font-size: 11px; color: var(--brand-ink); text-align: left; position: relative; z-index: 3; }
.tbl2 td { position: relative; }
.tbl2 td:has(.ci.calc.editing) { overflow: visible; z-index: 5; }
.tbl2 .ci.calc.editing { position: absolute; left: 0; top: 0; width: 300px; max-width: none; background: #fff; box-shadow: 0 0 0 2px var(--sel) inset, 0 6px 18px rgba(0,0,0,.18); z-index: 20; }
.tbl2 .ci.manual { color: var(--ink); font-weight: 700; background: linear-gradient(135deg, var(--manual) 0 6px, transparent 6px); }
.tbl2 .ci.prov { font-style: italic; color: var(--ink-3); }
.tbl2 .ci.to-mont { color: var(--ext); }
.tbl2 .ci.bad-ref { color: var(--bad); text-decoration: underline dotted; }
.tbl2 td.c-flag { text-align: center; }
.tbl2 td.c-flag input { margin: 0; accent-color: var(--ext); vertical-align: middle; }
.tbl2 td.c-tot { font-weight: 700; padding: 0 4px; background: #f6f8f7 !important; font-variant-numeric: tabular-nums; }
.tbl2 td.c-del { text-align: center; }
.tbl2 td.c-del button { border: 0; background: transparent; color: var(--ink-3); cursor: pointer; font-size: 11px; opacity: 0; padding: 0; width: 100%; height: 25px; }
.tbl2 tr:hover td.c-del button { opacity: 1; }
.tbl2 td.c-del button:hover { color: var(--bad); }
.tbl2 tfoot td { position: sticky; bottom: 0; z-index: 2; background: var(--surface-3) !important; font-weight: 700; font-size: 11px; padding: 0 4px; border-top: 1px solid var(--line-strong); height: 26px; }

@media (max-width: 1440px) { .toolbar .legend-inline { display: none; } }
/* nasconde la freccetta dei suggerimenti (datalist) che ruba spazio al valore */
.tbl2 input.ci::-webkit-calendar-picker-indicator { display: none !important; }
.tbl2 input.ci::-webkit-list-button { display: none !important; }

/* ---------- Montatori: selezione multipla ---------- */
.tbl2 .msel { display: flex; align-items: center; gap: 3px; text-align: left; cursor: pointer; overflow: hidden; white-space: nowrap; padding: 0 3px; }
.tbl2 .msel:disabled { cursor: default; }
.tbl2 .msel .mph { color: var(--ink-3); opacity: 0; font-weight: 600; }
.tbl2 tr:hover .msel .mph, .tbl2 .msel:focus .mph { opacity: 1; }
.mchip { display: inline-flex; align-items: center; gap: 3px; height: 17px; padding: 0 5px; border-radius: 4px; font-size: 10.5px; font-weight: 700; background: #e6eef0; color: #24524a; white-space: nowrap; flex: none; letter-spacing: .01em; }
.mchip.ext { background: var(--ext-soft); color: var(--ext); }
.mchip.srv { background: var(--surface-3); color: var(--ink-2); }
.mchip.bad { background: var(--bad-soft); color: var(--bad); }
.mchip.big { height: 22px; padding: 0 4px 0 7px; font-size: 11.5px; }
.mchip.big i { font-style: normal; cursor: pointer; padding: 0 4px; border-radius: 3px; opacity: .7; }
.mchip.big i:hover { background: rgba(0,0,0,.08); opacity: 1; }
.mpick { position: fixed; z-index: 120; width: 310px; max-height: min(420px, calc(100vh - 16px)); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 9px; box-shadow: 0 12px 34px rgba(0,0,0,.2); overflow: hidden; }
.mpick .mp-h { display: flex; align-items: center; gap: 8px; padding: 8px; border-bottom: 1px solid var(--line); }
.mpick .mp-q { flex: 1; height: 30px; border: 1px solid var(--line-strong); border-radius: 6px; padding: 0 9px; outline: none; font-size: 12.5px; }
.mpick .mp-q:focus { border-color: var(--brand-2); }
.mpick .mp-sel { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; min-height: 38px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.mpick .mp-list { overflow-y: auto; flex: 1; min-height: 0; padding: 4px 0; overscroll-behavior: contain; }
.mpick .mp-g { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; padding: 8px 10px 4px; }
.mpick .mp-i { display: flex; align-items: center; gap: 8px; padding: 5px 10px; cursor: pointer; font-size: 12.5px; }
.mpick .mp-i:hover { background: var(--surface-3); }
.mpick .mp-i.on { background: var(--brand-soft); }
.mpick .mp-i input { margin: 0; accent-color: var(--brand-2); }
.mpick .mp-nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mpick .mp-f { display: flex; align-items: center; gap: 6px; padding: 8px; border-top: 1px solid var(--line); }
.mpick .mp-f .sp { flex: 1; }

/* ---------- Prototipo 3: righe alternate verde / verde chiaro (stile Excel) ---------- */
.tbl2 th { background: var(--xl-head); color: #1f3d17; border-bottom-color: #9cc487; border-right-color: #b1d39c; }
.tbl2 td { border-right-color: var(--xl-line); border-bottom-color: var(--xl-line); }
.tbl2 td.c-tot { background: transparent !important; }
.tbl2 tbody tr:nth-child(odd) td.c-tot { background: #e8f2e2 !important; }
.tbl2 tbody tr:nth-child(even) td.c-tot { background: #d0e5c3 !important; }
.tbl2 tbody tr:hover td.c-tot { background: var(--xl-hover) !important; }
.tbl2 .ci:hover { background: rgba(255,255,255,.75); }
.tbl2 tr.est td.c-flag { box-shadow: inset 4px 0 0 var(--ext); }
.tbl2 tr.new td { background: #fff4c4 !important; }
.tbl2 tfoot td { background: var(--xl-head) !important; color: #1f3d17; border-top-color: #9cc487; }

/* riepilogo per tipologia */
.riep { flex: none; display: flex; align-items: center; gap: 6px; padding: 6px 12px; background: #eaf3e4; border-top: 1px solid #9cc487; font-size: 12px; flex-wrap: wrap; }
.riep .sp { flex: 1; }
.riep .rp-g { display: inline-flex; align-items: center; gap: 5px; background: #fff; border: 1px solid #c3dbb4; border-radius: 6px; padding: 3px 8px; white-space: nowrap; }
.riep .rp-t { color: var(--ink-3); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.riep .rp-big { font-size: 15px; }
.riep .rp-l { color: var(--ink-2); }
.riep .rp-p { color: var(--brand-ink); font-weight: 600; font-size: 11px; background: var(--brand-soft); border-radius: 8px; padding: 0 6px; }
.riep .rp-ctl { display: inline-flex; align-items: center; gap: 12px; flex-wrap: wrap; white-space: nowrap; }
.riep .rp-ctl b { color: var(--ink); }

/* selettore anno nell'header */
.yearsel { display: inline-flex; align-items: center; background: #fff; border: 1px solid var(--line-strong); border-radius: 7px; overflow: hidden; margin-right: 6px; }
.yearsel button { border: 0; background: transparent; color: var(--ink-2); width: 26px; height: 28px; padding: 0; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.yearsel button svg { display: block; }
.yearsel button:hover:not(:disabled) { background: var(--surface-3); color: var(--ink); }
.yearsel button:disabled { opacity: .3; cursor: default; }
.yearsel select { appearance: none; -webkit-appearance: none; border: 0; background: transparent; color: var(--ink); font-weight: 700; font-size: 14px; padding: 0 6px; height: 28px; line-height: 28px; cursor: pointer; text-align: center; text-align-last: center; }
.yearsel select option { color: var(--ink); }

/* ---------- Prototipo 3 · rev. 06/11/2026: esterni YES / MC ---------- */
.tbl2 tr.esty td.c-flag { box-shadow: inset 4px 0 0 var(--ext-yes); }

/* commessa: numero + progressivo dell'elemento (1568-1) */
.tbl2 .comm { display: flex; align-items: center; }
.tbl2 .comm .c-nv { flex: 1 1 auto; min-width: 0; padding-right: 0; }
.tbl2 .comm .c-pr { flex: 0 0 auto; width: auto; font-size: 11.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; padding: 0 3px 0 0; }
.tbl2 .comm select.c-pr { display: inline-block; height: 25px; font-weight: 600; color: var(--brand-ink); padding: 0 2px; }
.tbl2 .comm select.c-pr.todo { color: var(--ink-3); font-weight: 400; }