:root {
  --bg: #f3f5f8; --card: #fff; --ink: #1c2430; --muted: #6b7686; --line: #dde2e9;
  --nav: #1d2633; --nav-ink: #c9d2de; --acc: #1f6feb; --acc-dk: #1758c4;
  --ok: #1a7f37; --warn: #b26a00; --bad: #cf222e; --sel: #e8f0fe;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { display: flex; font: 14px/1.4 "Segoe UI", system-ui, -apple-system, Arial, sans-serif; color: var(--ink); background: var(--bg); }
#nav { width: 200px; flex: none; background: var(--nav); color: var(--nav-ink); padding: 12px 0; overflow-y: auto; }
#nav .logo { font-size: 20px; padding: 4px 18px 14px; color: #fff; }
#nav .logo b { color: #6ea8ff; }
#nav .sez { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #7d8a9c; padding: 14px 18px 4px; }
#nav a { display: block; padding: 6px 18px; color: var(--nav-ink); text-decoration: none; }
#nav a:hover { background: #2a3545; color: #fff; }
#nav a.on { background: var(--acc); color: #fff; }
main { flex: 1; min-width: 0; overflow-y: auto; padding: 18px 24px 60px; }
h1 { font-size: 21px; margin: 0; }
h1 small { font-weight: normal; color: var(--muted); font-size: 15px; }
h2 { font-size: 15px; margin: 18px 0 8px; }
a { color: var(--acc); }
.muted { color: var(--muted); }
.bar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.bar .sp { flex: 1; }
button, .btn { font: inherit; padding: 6px 12px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; color: var(--ink); text-decoration: none; display: inline-block; }
button:hover, .btn:hover { border-color: #b8c1cc; background: #f8f9fb; }
button.pri { background: var(--acc); color: #fff; border-color: var(--acc); }
button.pri:hover { background: var(--acc-dk); }
button.danger { color: var(--bad); }
button.x { border: 0; background: none; color: var(--muted); padding: 2px 6px; }
button.x:hover { color: var(--bad); }
kbd { font-size: 11px; opacity: .75; margin-left: 4px; }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc2ff; border-color: var(--acc); }
input[type=checkbox] { width: auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 12px; background: var(--card); padding: 14px; border: 1px solid var(--line); border-radius: 8px; }
.f { display: flex; flex-direction: column; gap: 3px; }
.f > span { font-size: 12px; color: var(--muted); }
.f.w2 { grid-column: span 2; } .f.w3 { grid-column: span 3; } .f.wall { grid-column: 1 / -1; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-top: 14px; }
table.t { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
table.t th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; }
table.t td { padding: 7px 10px; border-bottom: 1px solid #eef1f4; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--sel); }
.n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 12px; background: #eef1f4; color: var(--muted); white-space: nowrap; }
.badge.ok { background: #dafbe1; color: var(--ok); }
.badge.warn { background: #fff1d6; color: var(--warn); }
.badge.bad { background: #ffebe9; color: var(--bad); }
.kpi { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin: 16px 0; }
.kpi a, .kpi div.k { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; text-decoration: none; color: var(--ink); }
.kpi small { display: block; color: var(--muted); font-size: 12px; }
.kpi b { font-size: 20px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cerca-big input { font-size: 18px; padding: 12px 14px; }
.ac { position: relative; }
.drop { display: none; position: absolute; z-index: 20; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 420px; overflow-y: auto; }
.drop .opt { padding: 7px 10px; cursor: pointer; display: flex; gap: 10px; align-items: center; border-bottom: 1px solid #f1f3f6; }
.drop .opt.sel, .drop .opt:hover { background: var(--sel); }
.drop .opt .cod { font-weight: 600; min-width: 130px; }
.drop .opt .ds { flex: 1; min-width: 0; }
.drop .opt .alt { font-size: 12px; color: var(--muted); }
.cerca-art { margin: 14px 0 8px; }
.cerca-art input { font-size: 16px; padding: 10px 12px; border: 2px solid var(--acc); }
table.righe { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); }
table.righe th { font-size: 12px; color: var(--muted); text-align: left; padding: 6px; background: #fafbfc; border-bottom: 1px solid var(--line); }
table.righe td { padding: 3px 4px; border-bottom: 1px solid #eef1f4; vertical-align: middle; }
table.righe input, table.righe select { padding: 4px 6px; border-color: transparent; background: transparent; }
table.righe input:hover, table.righe select:hover { border-color: var(--line); }
table.righe input:focus { background: #fff; }
table.righe tr.daddt td { background: #fbfaf2; }
.w-cod { width: 140px !important; } .w-q { width: 70px !important; } .w-p { width: 100px !important; } .w-sc { width: 80px !important; }
.w-iva { width: 70px !important; } .w-nat { width: 80px !important; }
.giac { font-size: 11px; margin-left: 6px; }
.foot { display: flex; gap: 16px; margin-top: 12px; align-items: flex-start; }
.foot .f { flex: 1; }
.tot { min-width: 280px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.tot div { display: flex; justify-content: space-between; padding: 2px 0; }
.tot .r { font-size: 12px; color: var(--muted); }
.tot .g { font-size: 20px; font-weight: 700; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
.info { background: #eef5ff; border: 1px solid #c8dcff; padding: 8px 12px; border-radius: 6px; margin-bottom: 12px; }
.err { background: #ffebe9; border: 1px solid #ffc1bb; padding: 10px 14px; border-radius: 6px; white-space: pre-wrap; }
details { margin-top: 10px; }
details summary { cursor: pointer; color: var(--muted); margin-bottom: 6px; }
#toast { position: fixed; right: 20px; bottom: 20px; background: #1d2633; color: #fff; padding: 10px 16px; border-radius: 8px; opacity: 0; transform: translateY(10px); transition: .2s; pointer-events: none; max-width: 480px; white-space: pre-wrap; z-index: 100; }
#toast.show { opacity: 1; transform: none; }
#toast.err { background: var(--bad); }
.filtri { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filtri input, .filtri select { width: auto; }
.filtri input.grow { flex: 1; min-width: 220px; }
.prev { overflow-x: auto; max-height: 260px; }
.prev table td, .prev table th { font-size: 12px; white-space: nowrap; }
.inline td input, .inline td select { padding: 4px 6px; }
#bannerProva { position: fixed; top: 0; left: 0; right: 0; z-index: 300; background: #e8590c; color: #fff; text-align: center;
  font-weight: 600; padding: 6px 12px; font-size: 13px; }
body.prova #nav { background: #5c2a0e; }
.tot .cassa { flex-direction: column; align-items: stretch; background: #dafbe1; border-radius: 6px; padding: 8px 10px; margin-top: 8px; }
.tot .cassa span { font-size: 12px; color: #0f5323; }
.tot .cassa b { font-size: 28px; color: #0f5323; text-align: right; }
.oggi { display: flex; flex-direction: column; gap: 6px; }
.oggi .voce { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-left-width: 5px;
  border-radius: 8px; padding: 10px 14px; text-decoration: none; color: var(--ink); }
.oggi .voce:hover { background: var(--sel); }
.oggi .voce .tx { flex: 1; display: flex; flex-direction: column; }
.oggi .voce small { color: var(--muted); }
.oggi .voce .ic { width: 22px; text-align: center; }
.oggi .lv-urgente { border-left-color: var(--bad); }
.oggi .lv-attenzione { border-left-color: var(--warn); }
.oggi .lv-info { border-left-color: #8fb3f0; }
button.rec { background: var(--bad); color: #fff; border-color: var(--bad); animation: pulsa 1s infinite; }
@keyframes pulsa { 50% { opacity: .6; } }
.modal { position: fixed; inset: 0; background: rgba(20, 28, 40, .45); display: flex; align-items: center; justify-content: center; z-index: 150; padding: 16px; }
.modal > .card { width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; margin: 0; }
#login { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 16px; }
.utenti-login { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.utenti-login button { padding: 12px 8px; font-size: 15px; }
.utenti-login button.on { background: var(--acc); color: #fff; border-color: var(--acc); }
#login form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 8px; }
.drop-zone { border: 2px dashed #b8c1cc; text-align: center; padding: 22px; }
.drop-zone.over { border-color: var(--acc); background: var(--sel); }
.tabs .btn.on { background: var(--acc); color: #fff; border-color: var(--acc); }
.inv-in { display: flex; gap: 8px; }
.inv-in input { font-size: 20px; padding: 12px 14px; border: 2px solid var(--acc); }
.esito { margin-top: 10px; padding: 12px 14px; border-radius: 8px; font-size: 17px; background: #f3f5f8; color: var(--muted); }
.esito.ok { background: #dafbe1; color: #0f5323; }
.esito.ko { background: #ffebe9; color: #8a1720; }
@media (max-width: 900px) {
  body { flex-direction: column; }
  #nav { width: auto; display: flex; flex-wrap: wrap; padding: 6px; }
  #nav .sez, #nav .logo { display: none; }
  #nav a { padding: 6px 10px; }
  main { padding: 12px 16px 60px; }
  .cols { grid-template-columns: 1fr; }
  .f.w2, .f.w3 { grid-column: 1 / -1; }
  .foot { flex-direction: column; }
  table.righe, table.t { display: block; overflow-x: auto; }
  .oggi .voce { flex-wrap: wrap; }
}
@media print { #nav, .bar button { display: none; } }
