/* Digimax Preventivi — stesso sistema grafico dell'app Presenze */
:root {
  --ink: #1d1d1f; --ink-2: #4a4a4f; --muted: #7a7a82; --line: #e4e4e8; --bg: #f6f6f4; --card: #ffffff;
  --accent: #f39200; --accent-d: #c97600; --accent-l: #fff2df;
  --ok: #2f7d32; --ok-l: #e7f4e8; --warn: #b26a00; --warn-l: #fff4e0; --err: #c62828; --err-l: #fdecea;
  --info: #1a56a8; --info-l: #e3edfb;
  --pend: #e3edfb; --omit: #fdecea; --opt: #fff4e0;
  --r: 10px; --sh: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px; color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
a { color: var(--accent-d); }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 18px 0 8px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.right { margin-left: auto; }
.mb { margin-bottom: 14px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #fff; padding: 18px 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 18px; font-weight: 700; letter-spacing: .02em; color: #fff; text-decoration: none; }
.brand .logo { width: 38px; height: 38px; border-radius: 50%; display: block; flex: none; }
.brand small { display: block; font-weight: 400; color: #aaa; font-size: 12px; letter-spacing: 0; }
.nav a { display: block; color: #ddd; text-decoration: none; padding: 9px 12px; border-radius: 8px; font-size: 14px; }
.nav a:hover { background: #2c2c30; color: #fff; }
.nav a.on { background: var(--accent); color: var(--ink); font-weight: 600; }
.nav .sep { height: 1px; background: #333; margin: 10px 6px; }
.nav .lab { font-size: 11px; color: #888; text-transform: uppercase; letter-spacing: .08em; padding: 8px 12px 4px; }
.side .who { margin-top: auto; font-size: 13px; color: #bbb; padding: 10px 12px; border-top: 1px solid #333; }
.side .who b { color: #fff; display: block; }
.side .who a, .side .who button { color: var(--accent); cursor: pointer; background: none; border: 0; padding: 0; font: inherit; min-height: 0; }
.main { padding: 22px 28px 60px; min-width: 0; display: flex; flex-direction: column; gap: 0; }
.topbar { display: none; }
.sideclose { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 30; transform: translateX(-105%); transition: transform .2s; height: 100%; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .sideclose { display: block; margin-left: auto; background: none; border: 0; color: #fff; font-size: 22px; }
  .topbar { display: flex; align-items: center; gap: 10px; background: var(--ink); color: #fff; padding: calc(8px + env(safe-area-inset-top, 0px)) 14px 10px; position: sticky; top: 0; z-index: 20; }
  .topbar button { background: none; border: 0; color: #fff; font-size: 22px; min-height: 0; padding: 4px; }
  .topbar img { width: 28px; height: 28px; border-radius: 50%; }
  .main { padding: 16px 12px 60px; }
}

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--sh); margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card > h2:first-child { margin-top: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.warn { border-color: #f3c27a; background: var(--warn-l); }
.stat.err { border-color: #f1a9a5; background: var(--err-l); }
.stat.info { border-color: #c5d8f3; background: var(--pend); }
.stat.opt { border-color: #f3d9a5; background: var(--opt); }

/* controls */
button, .btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; line-height: 1.2; white-space: nowrap; }
button:hover, .btn:hover { border-color: #cfcfd5; background: #fafafa; }
button.pri, .btn.pri { background: var(--accent); border-color: var(--accent); color: var(--ink); font-weight: 600; }
button.pri:hover, .btn.pri:hover { background: var(--accent-d); border-color: var(--accent-d); }
button.dark, .btn.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
button.danger, .btn.danger { color: var(--err); border-color: #f1c4c1; }
button.ghost, .btn.ghost { border-color: transparent; background: none; color: var(--muted); }
button.ghost:hover { color: var(--ink); background: #f1f1f3; }
button.sm, .btn.sm { padding: 5px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { font: inherit; border: 1px solid #d6d6dc; border-radius: 8px; padding: 8px 10px; background: #fff; color: var(--ink); width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
input:disabled, select:disabled, textarea:disabled { background: transparent; border-color: transparent; color: var(--ink); }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
input[type=number] { text-align: right; font-variant-numeric: tabular-nums; }
label.f { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 10px; }
label.f > span { display: block; margin-bottom: 4px; }
label.chk { display: flex; gap: 8px; align-items: center; font-size: 14px; margin: 0; }
.help { font-size: 12px; color: var(--muted); margin-top: 3px; }
.errorlist { color: var(--err); font-size: 12.5px; margin: 4px 0 0; padding-left: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 14px; }
@media (max-width: 700px) { .grid2, .grid3, .grid4 { grid-template-columns: 1fr 1fr; } }
.seg { display: inline-flex; border: 1px solid #d6d6dc; border-radius: 8px; overflow: hidden; background: #fff; flex-wrap: wrap; }
.seg a, .seg button { border: 0; border-radius: 0; padding: 7px 14px; color: var(--ink); text-decoration: none; background: #fff; font-size: 14px; }
.seg a + a, .seg button + button { border-left: 1px solid #ececf0; }
.seg a.on, .seg button.on { background: var(--ink); color: #fff; }

/* tables */
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fff; }
table.t td { padding: 9px 10px; border-bottom: 1px solid #efeff2; vertical-align: middle; }
table.t.dense th { padding: 7px 8px; }
table.t.dense td { padding: 5px 8px; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #fbfbfa; }
table.t tfoot td { font-weight: 650; border-top: 2px solid var(--line); }
table.t th.num, table.t td.num { text-align: right; }
table.t th.ctr, table.t td.ctr { text-align: center; }
table.t td input { width: 100%; }
table.t tr.grp td { background: #fafafa; font-size: 12px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.tablewrap { overflow-x: auto; }

/* badges */
.b { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.b.bozza { background: #eee; color: #555; }
.b.emesso { background: var(--info-l); color: var(--info); }
.b.inviato { background: var(--warn-l); color: var(--warn); }
.b.accettato { background: var(--ok-l); color: var(--ok); }
.b.rifiutato, .b.scaduto { background: #eee; color: #777; }
.b.ok { background: var(--ok-l); color: var(--ok); }
.b.warn { background: var(--warn-l); color: var(--warn); }
.b.err { background: var(--err-l); color: var(--err); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); display: inline-block; flex: none; }
.dep { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.m-ok { color: var(--ok); } .m-warn { color: var(--warn); } .m-bad { color: var(--err); }

/* banners e messaggi */
.banner { border-radius: var(--r); padding: 12px 16px; margin-bottom: 14px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.banner.info { background: var(--accent-l); border: 1px solid #f7cf91; }
.banner.success, .banner.ok { background: var(--ok-l); border: 1px solid #b7dcb9; }
.banner.warning, .banner.warn { background: var(--warn-l); border: 1px solid #f3c27a; }
.banner.error, .banner.err { background: var(--err-l); border: 1px solid #f1a9a5; }
.note { font-size: 13px; color: var(--ink-2); background: var(--accent-l); border-radius: 8px; padding: 8px 12px; }
.empty { padding: 24px; text-align: center; color: var(--muted); }

/* intestazione preventivo */
.phead { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.numbox { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.numbox.draft { color: var(--muted); }
.back { font-size: 13px; color: var(--accent-d); text-decoration: none; display: inline-block; margin-bottom: 10px; }
.tabsrow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }

/* breakdown */
.cap-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--line); background: #fafafa; }
.cap-h input.title { font-size: 16px; font-weight: 700; background: transparent; border-color: transparent; min-width: 180px; flex: 1; max-width: 460px; padding: 5px 8px; }
.cap-h input.title:hover, .cap-h input.title:focus { border-color: #d6d6dc; background: #fff; }
.cap-h select { width: auto; padding: 5px 8px; font-size: 13px; }
.cap-add { padding: 10px 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.cap-add select { width: auto; max-width: 320px; }
input.code { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; padding: 5px 8px; min-width: 170px; }
input.cell { width: 62px; padding: 4px 6px; font-size: 13px; }
input.desc { min-width: 230px; padding: 5px 8px; }
select.mini { width: auto; padding: 4px 6px; font-size: 13px; }
input.forf { width: 100px; padding: 4px 6px; font-size: 13px; }
input.forf.set { border-color: var(--accent); background: var(--accent-l); }
select.st { width: auto; padding: 3px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; border: 1px solid transparent; }
select.st.VALID { background: var(--ok-l); color: var(--ok); }
select.st.PENDING { background: #d5e4f8; color: var(--info); }
select.st.OMITTED { background: #f9d9d6; color: var(--err); }
select.st.OPTIONAL { background: #fbe6c2; color: var(--warn); }
tr.vs-PENDING > td { background: var(--pend); }
tr.vs-OMITTED > td { background: var(--omit); }
tr.vs-OMITTED input.desc, tr.vs-OMITTED .q { text-decoration: line-through; }
tr.vs-OPTIONAL > td { background: var(--opt); }
tr.detail > td { background: #fafafa; padding: 12px 16px 16px 40px; }
.chev { display: inline-block; width: 14px; color: var(--muted); transition: transform .15s; }
.chev.open { transform: rotate(90deg); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 0 2px 12px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; border: 1px solid #ddd; }
.bar { height: 8px; border-radius: 4px; background: #f1f1f3; overflow: hidden; min-width: 80px; }
.bar i { display: block; height: 100%; background: var(--c); }

/* thumbnail */
.thumb { width: 64px; height: 36px; border: 1px dashed #cfcfd5; border-radius: 5px; display: flex; align-items: center; justify-content: center; color: #b0b0b8; position: relative; background: #fff; font-size: 15px; flex: none; }
.thumb[data-voce] { cursor: pointer; }
.thumb.has { border-style: solid; border-color: transparent; overflow: hidden; background: var(--ink); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.thumb .tx { position: absolute; top: 1px; right: 1px; border: 0; border-radius: 3px; background: rgba(0,0,0,.6); color: #fff; font-size: 10px; line-height: 1; padding: 2px 4px; cursor: pointer; display: none; min-height: 0; }
.thumb.has:hover .tx, .thumb.has:focus-within .tx { display: block; }
.dragover { outline: 2px dashed var(--accent); outline-offset: -2px; }
.lb { position: fixed; inset: 0; background: rgba(20,20,22,.85); z-index: 90; display: flex; align-items: center; justify-content: center; padding: 24px; cursor: zoom-out; }
.lb img { max-width: 100%; max-height: 100%; border-radius: 6px; }
.busy { opacity: 0; transition: opacity .2s; font-size: 12px; color: var(--muted); }
.htmx-request .busy, .htmx-request.busy { opacity: 1; }
iframe.pdf { width: 100%; height: 80vh; border: 1px solid var(--line); border-radius: var(--r); background: #fff; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; background: var(--ink); padding: 20px; }
.login .box { background: #fff; border-radius: 16px; padding: 30px 28px; width: 100%; max-width: 400px; }
.login .logo { width: 64px; height: 64px; border-radius: 50%; display: block; margin-bottom: 14px; }
.login form { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.login label { font-size: 12.5px; color: var(--ink-2); }
.login button { justify-content: center; }
.login .or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 6px 0; }
.login .or::before, .login .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.login ul { padding-left: 18px; }
.qrbox { display: grid; place-items: center; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin: 8px 0; }

@media (max-width: 700px) {
  input, select, textarea { font-size: 16px; }
  h1 { font-size: 21px; }
  .cards { grid-template-columns: 1fr 1fr; }
  .card { padding: 14px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ciclo del preventivo */
.steps { display: grid; grid-template-columns: repeat(5, 1fr); margin-bottom: 16px; }
.step { padding: 10px 10px 10px 14px; border-top: 4px solid var(--line); min-width: 0; }
.step.done { border-top-color: var(--accent); }
.step.now { border-top-color: var(--ink); }
.step .k { font-size: 12px; color: var(--muted); }
.step .v { font-weight: 650; font-size: 14px; margin-top: 2px; }
.step .s { font-size: 12px; color: var(--ink-2); margin-top: 2px; overflow-wrap: anywhere; }
.file { display: flex; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fafafa; }
.file .ic { width: 34px; height: 42px; border-radius: 4px; background: var(--err); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; flex: none; }
@media (max-width: 860px) { .steps { grid-template-columns: 1fr 1fr; } }

/* Scheda cliente: suggerimenti e ricerca P.IVA */
label.f.ac { position: relative; }
.ac-list { position: absolute; left: 0; right: 0; top: 100%; margin-top: 4px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 20; overflow: hidden; display: none; }
.ac-list.on { display: block; }
.ac-it { display: flex; gap: 10px; align-items: center; padding: 9px 12px; cursor: pointer; border-bottom: 1px solid #f0f0f2; font-size: 14px; color: var(--ink); }
.ac-it.vuoto { cursor: default; }
.ac-it:last-child { border-bottom: 0; }
.ac-it[data-i]:hover, .ac-it.sel { background: var(--accent-l); }
.ac-it .n { font-weight: 600; }
.ac-it .d { font-size: 12px; color: var(--muted); }
.ac-it .src { margin-left: auto; }
.ac-foot { padding: 8px 12px; font-size: 12px; color: var(--muted); background: #fafafa; }
.ac-foot.err { color: var(--err); background: var(--err-l); }
.b.app { background: #eee; color: #555; }
.b.fic { background: var(--info-l); color: var(--info); }
.inbtn { display: flex; gap: 6px; }
.inbtn input { flex: 1; min-width: 0; }
.filled input, .filled textarea { background: #fff8ec; border-color: #f3c27a; }
.hint { font-size: 12px; margin-top: 4px; }
.hint.ok { color: var(--ok); } .hint.err { color: var(--err); } .hint.warn { color: var(--warn); }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid #ddd; border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Impostazioni: collegamenti */
.sez { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 18px 0 8px; font-weight: 600; }
.card h2 .b { font-size: 12px; vertical-align: 2px; margin-left: 8px; }
.test { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding-top: 12px; margin-top: 4px; border-top: 1px solid var(--line); }
.test input { width: 260px; max-width: 100%; }
.esito { font-size: 13px; }
.esito.ok { color: var(--ok); } .esito.err { color: var(--err); }

/* Scheda cliente: varianti in Fatture in Cloud */
.ac-it { align-items: flex-start; }
.ac-it .src { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; text-align: right; }
.ac-grp { padding: 6px 12px; font-size: 11px; font-weight: 600; color: var(--muted); background: #fafafa; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid #f0f0f2; }
.sdi { display: inline-block; font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; background: #f4f4f6; border-radius: 5px; padding: 0 5px; color: var(--ink-2); }
.scelte { display: grid; gap: 8px; }
.scelta { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; background: #fff; }
.scelta:has(input:checked) { border-color: var(--accent); background: var(--accent-l); }
.scelta input { margin-top: 3px; width: auto; }
.scelta .n { font-weight: 600; } .scelta .d { font-size: 12.5px; color: var(--ink-2); }
.linked { display: flex; gap: 12px; align-items: flex-start; border: 1px solid #b7dcb9; background: var(--ok-l); border-radius: 10px; padding: 10px 12px; }
#form-cliente .ac-list { max-height: 420px; overflow-y: auto; }

/* Zona sviluppo e ruolo Root */
.zona { border: 1px solid #f1a9a5; }
.zona h2 { color: var(--err); }
.conta { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 12px 0; }
.conta div { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fafafa; }
.conta b { display: block; font-size: 20px; } .conta span { font-size: 12px; color: var(--muted); }
.resta { font-size: 13px; color: var(--ink-2); margin: 0 0 12px; } .resta b { color: var(--ok); }
button.rosso { background: var(--err); border-color: var(--err); color: #fff; font-weight: 600; }
button.rosso:disabled { opacity: .45; cursor: not-allowed; }
.b.root { background: #1d1d1f; color: #fff; }

/* Importi in colonna: € a sinistra, numero a destra */
.eurc { display: block; min-width: 5.5em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.eurc .e { float: left; color: var(--muted); margin-right: 6px; }
label.eurin { display: flex; align-items: center; gap: 4px; border: 1px solid #d6d6dc; border-radius: 8px; background: #fff; padding: 0 6px 0 8px; width: 112px; margin-left: auto; cursor: text; }
label.eurin .e { color: var(--muted); font-size: 13px; }
label.eurin input.forf { border: 0; outline: none; width: 100%; padding: 4px 0; text-align: right; background: transparent; font-variant-numeric: tabular-nums; }
label.eurin:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
label.eurin.set { border-color: var(--accent); background: var(--accent-l); }

/* Griglia ore: colonne numeriche tutte uguali, larghe per 4 cifre, titoli su due righe */
table.t th.n4 { width: 66px; min-width: 66px; max-width: 66px; white-space: normal; line-height: 1.15; text-align: center; vertical-align: bottom; font-size: 11.5px; }
table.t input.cell { width: 58px; text-align: right; font-variant-numeric: tabular-nums; padding: 4px 6px; }
table.t select.n4s { width: 66px; padding: 3px 4px; font-size: 11.5px; }

/* Riordino a trascinamento (come nelle presenze) */
td.handle { cursor: grab; color: #b0b0b8; font-size: 16px; letter-spacing: -2px; width: 28px; text-align: center; user-select: none; }
td.handle:hover { color: var(--accent-d); }
tr.dragging td { background: var(--accent-l) !important; opacity: .7; }
tr.moved td { background: var(--accent-l); transition: background .6s; }
.frecce { display: flex; gap: 4px; flex-wrap: nowrap; }
.frecce button { padding: 2px 8px; }
#toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; }
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--err); }

/* Vista «Lavorazioni»: una pillola per lavorazione, con la quantità */
td.lav { min-width: 320px; }
details.pill { display: inline-block; position: relative; margin: 2px 4px 2px 0; vertical-align: middle; }
details.pill > summary { list-style: none; cursor: pointer; border: 1px solid var(--line); background: #fafafa; border-radius: 99px; padding: 2px 9px; font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
details.pill > summary::-webkit-details-marker { display: none; }
details.pill > summary b { font-weight: 600; color: var(--ink); }
details.pill > summary:hover, details.pill[open] > summary { border-color: var(--accent); background: var(--accent-l); }
details.pill.add > summary { border-style: dashed; color: var(--muted); padding: 2px 8px; }
details.pill .pop { position: absolute; top: calc(100% + 4px); left: 0; z-index: 30; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 10px; min-width: 260px; }
details.pill .pop select { width: 100%; }

/* Selettore colore ben visibile */
label.sw { display: flex; align-items: center; gap: 8px; border: 1px solid #d6d6dc; border-radius: 8px; padding: 4px 8px; background: #fff; cursor: pointer; }
label.sw input[type=color] { width: 34px; height: 24px; padding: 0; border: 0; border-radius: 5px; background: none; cursor: pointer; flex: none; }
label.sw input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
label.sw input[type=color]::-webkit-color-swatch { border: 1px solid rgba(0,0,0,.15); border-radius: 5px; }
label.sw input[type=color]::-moz-color-swatch { border: 1px solid rgba(0,0,0,.15); border-radius: 5px; }
label.sw span { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--ink-2); }
.chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 99px; padding: 2px 9px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.chip b { font-weight: 600; color: var(--ink); }

/* Impostazioni → Aspetto del PDF: anteprima dal vivo */
.aspetto { display: grid; grid-template-columns: minmax(240px, 300px) 1fr; gap: 20px; align-items: start; }
@media (max-width: 800px) { .aspetto { grid-template-columns: 1fr; } }
.anteprima-pdf { --pdf_sfondo: #fff; --pdf_testo: #1d1d1f; --pdf_barra: #1d1d1f; --pdf_titolo: #fff; --pdf_sottotitolo: #f39200; --pdf_pending: #e3edfb; --pdf_omesso: #fdecea; --pdf_opzione: #fff4e0;
  background: var(--pdf_sfondo); color: var(--pdf_testo); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--sh); padding: 14px; font-family: "Liberation Sans", Arial, sans-serif; font-size: 11px; }
.anteprima-pdf table { width: 100%; border-collapse: collapse; table-layout: fixed; margin-bottom: 12px; }
.anteprima-pdf tr.cap th { background: var(--bar, var(--pdf_barra)); color: var(--pdf_titolo); text-align: left; padding: 6px 9px; font-size: 12px; }
.anteprima-pdf tr.cap th span { color: var(--sub, var(--pdf_sottotitolo)); font-weight: normal; margin-left: 8px; }
.anteprima-pdf td { padding: 5px 6px; border-bottom: 1px solid #ececf0; }
.anteprima-pdf td.code { font-family: ui-monospace, Menlo, monospace; font-size: 10px; }
.anteprima-pdf td.r { text-align: right; white-space: nowrap; }
.anteprima-pdf tr.r-p td { background: var(--pdf_pending); } .anteprima-pdf tr.r-o td { background: var(--pdf_omesso); } .anteprima-pdf tr.r-x td { background: var(--pdf_opzione); }
.anteprima-pdf tr.r-o td.r { text-decoration: line-through; }
.anteprima-pdf .pl { display: inline-block; border: 1px solid; border-radius: 8px; padding: 0 6px; margin: 1px 2px 1px 0; font-size: 10px; color: #1d1d1f; white-space: nowrap; }

/* Pillole e capitoli col colore del reparto */
section.cap { border-left: 4px solid var(--rep, var(--line)); }

/* Verifica in due passaggi */
.metodo { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; width: 100%; text-align: left; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; background: #fff; color: var(--ink); text-decoration: none; }
.metodo:hover { border-color: var(--accent); background: var(--accent-l); }
.metodo span { font-size: 12.5px; color: var(--muted); }
input.otp { font-size: 22px; letter-spacing: .2em; text-align: center; font-family: ui-monospace, Menlo, monospace; }
.otp-form { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.qrbox { display: flex; justify-content: center; margin: 6px 0 10px; }
.qrbox svg { width: 190px; height: 190px; background: #fff; }
code.key { font-family: ui-monospace, Menlo, monospace; word-break: break-all; background: #f4f4f6; padding: 2px 6px; border-radius: 6px; }
.codici { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 16px; font-family: ui-monospace, Menlo, monospace; background: #f4f4f6; border-radius: 10px; padding: 12px 16px; font-size: 15px; text-align: center; }

/* Importa shot da CSV */
dialog.imp-dlg { border: 0; border-radius: 16px; box-shadow: 0 20px 50px rgba(0,0,0,.25); width: min(920px, calc(100vw - 32px)); max-height: calc(100vh - 40px); padding: 22px 24px; color: var(--ink); background: var(--card); }
dialog.imp-dlg::backdrop { background: rgba(20,20,22,.45); }
.imp-dlg h3 { margin-top: 16px; }
.imp-dlg .drop { border: 2px dashed #cfcfd6; border-radius: 14px; padding: 30px; text-align: center; color: var(--ink-2); background: #fafafa; cursor: pointer; }
.imp-dlg .drop b { display: block; font-size: 16px; color: var(--ink); margin-bottom: 6px; }
.imp-dlg .drop.over { border-color: var(--accent); background: var(--accent-l); }
.imp-dlg .files { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.imp-dlg .fileb { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: #fff; font-size: 13px; }
.imp-dlg .fileb i { font-style: normal; font-weight: 700; color: #fff; background: #3a7fc2; border-radius: 6px; padding: 2px 6px; font-size: 11px; }
.imp-dlg .fileb i.err { background: var(--err); }
.imp-dlg .imp-tab { max-height: 46vh; overflow: auto; margin-top: 6px; border: 1px solid var(--line); border-radius: 10px; }
.imp-dlg .imp-tab thead th { position: sticky; top: 0; background: var(--card); z-index: 1; }
.imp-dlg img.th, .imp-dlg .th.vuota { width: 96px; height: 54px; object-fit: cover; border-radius: 6px; display: block; background: var(--ink); }
.imp-dlg .th.vuota { background: #f4f4f6; display: grid; place-items: center; color: #bbb; border: 1px dashed #ddd; }
.imp-dlg input.code { width: 100%; min-width: 160px; }
.imp-dlg tr.skip td { opacity: .5; }
.imp-dlg .b { margin: 1px 0; }
@media (max-width: 700px) { dialog.imp-dlg { padding: 16px; } }
