:root {
  --bg: #f6f7f9; --panel: #fff; --ink: #1d2433; --muted: #667085; --line: #e3e6ec;
  --accent: #0e7490; --accent-ink: #fff; --ok: #15803d; --warn: #b45309; --bad: #b91c1c;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 14px; }
header { position: sticky; top: 0; z-index: 10; background: #0f172a; color: #fff; display: flex; align-items: center; gap: 18px; padding: 0 16px; }
.brand { font-weight: 700; font-size: 17px; white-space: nowrap; }
.brand span { font-weight: 400; opacity: .7; }
nav { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
nav button { background: none; border: 0; color: #cbd5e1; padding: 14px 10px; cursor: pointer; font-size: 13px; border-bottom: 3px solid transparent; }
nav button:hover { color: #fff; }
nav button.active { color: #fff; border-bottom-color: #22d3ee; }
nav .sep { color: #64748b; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; margin-left: 12px; }
main { padding: 20px 24px 60px; max-width: 1400px; margin: 0 auto; }
h1 { font-size: 21px; margin: 4px 0 12px; }
h3 { margin: 0 0 8px; font-size: 15px; }
h4 { margin: 14px 0 6px; font-size: 13px; }
.tab { display: none; }
.tab.active { display: block; }
.hidden { display: none !important; }
.hint { color: var(--muted); font-size: 12.5px; }
.badge { font-size: 11px; background: #e0f2fe; color: #075985; padding: 2px 8px; border-radius: 10px; vertical-align: middle; font-weight: 500; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 14px; margin-bottom: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
.card label, .toolbar label, .row label { margin-right: 10px; display: inline-block; margin-bottom: 6px; }
label.inline { display: inline-flex; gap: 4px; align-items: center; }
.toolbar, .row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0; }
input, select, textarea { font: inherit; padding: 5px 8px; border: 1px solid #cfd4dc; border-radius: 6px; background: #fff; }
textarea { width: 100%; min-height: 70px; margin: 8px 0; }
button, .button { font: inherit; padding: 6px 12px; border: 1px solid #cfd4dc; background: #fff; border-radius: 6px; cursor: pointer; color: var(--ink); text-decoration: none; display: inline-block; }
button:hover, .button:hover { background: #f1f5f9; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { filter: brightness(1.08); }
button:disabled { opacity: .5; cursor: default; }
.msg { margin: 8px 0; font-size: 13px; white-space: pre-wrap; }
.msg.err { color: var(--bad); }
.msg.ok { color: var(--ok); }
pre { background: #0f172a; color: #e2e8f0; padding: 10px; border-radius: 6px; max-height: 260px; overflow: auto; font-size: 12px; white-space: pre-wrap; }
table.grid { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; font-size: 13px; margin: 10px 0; }
table.grid th, table.grid td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.grid th { background: #f8fafc; font-weight: 600; font-size: 12px; color: #475467; position: sticky; top: 46px; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid tr.clickable { cursor: pointer; }
table.grid tr.clickable:hover { background: #f0f9ff; }
.thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 4px; }
.split { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(360px, 1fr); gap: 18px; }
.imgPane img { width: 100%; max-height: 78vh; object-fit: contain; background: #111; border-radius: 8px; cursor: zoom-in; }
.code { font-weight: 700; font-size: 16px; margin-bottom: 6px; }
.formPane { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; max-height: 84vh; overflow: auto; }
.pgroup { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 12px 0 4px; }
.prow { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.prow .lbl b { font-size: 13.5px; }
.prow .def { font-size: 11.5px; color: var(--muted); }
.tri { display: inline-flex; border: 1px solid #cfd4dc; border-radius: 6px; overflow: hidden; }
.tri label { margin: 0; padding: 5px 9px; cursor: pointer; font-size: 12.5px; border-left: 1px solid #cfd4dc; user-select: none; }
.tri label:first-child { border-left: 0; }
.tri input { display: none; }
.tri input:checked + span { font-weight: 700; }
.tri label:has(input:checked) { background: #0e7490; color: #fff; }
.tri label.nv:has(input:checked) { background: #64748b; }
.pct { display: flex; gap: 10px; flex-wrap: wrap; }
.pct input { width: 5em; }
.likert { display: flex; gap: 6px; }
.likert label { border: 1px solid #cfd4dc; border-radius: 6px; padding: 6px 14px; cursor: pointer; }
.likert label:has(input:checked) { background: var(--accent); color: #fff; }
.likert input, .seg3 input { margin-right: 4px; }
.seg3 { display: flex; flex-direction: column; gap: 4px; }
blockquote { margin: 0; padding: 10px 12px; background: #f8fafc; border-left: 4px solid var(--accent); white-space: pre-wrap; }
.progress { height: 6px; background: #e5e7eb; border-radius: 3px; overflow: hidden; margin: 10px 0 4px; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.segTools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.segTools .spacer { flex: 1; }
.segInfo { margin: 8px 2px; }
.canvasWrap { background: #111; border-radius: 8px; display: flex; justify-content: center; padding: 6px; }
#segCanvas { max-width: 100%; cursor: crosshair; }
.consItem { display: grid; grid-template-columns: 90px 1fr; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-bottom: 8px; }
.consItem img { width: 90px; height: 90px; object-fit: cover; border-radius: 6px; cursor: zoom-in; }
.vals span { display: inline-block; margin-right: 10px; }
.good { color: var(--ok); font-weight: 600; }
.mid { color: var(--warn); font-weight: 600; }
.poor { color: var(--bad); font-weight: 600; }
#lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 50; display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
#lightbox img { max-width: 96vw; max-height: 96vh; }
.statBlock { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 12px 0; }
.statBlock h3 { margin-bottom: 4px; }
.gallery { display: flex; flex-wrap: wrap; gap: 10px; }
.gallery figure { margin: 0; width: 190px; font-size: 12px; }
.gallery .ov { position: relative; width: 190px; height: 190px; }
.gallery .ov img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #111; border-radius: 6px; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }

.supRow { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: center; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.supRow .ia { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 10px; background: #e0f2fe; color: #075985; margin-left: 6px; font-weight: 600; }
.supRow.ok { background: #f0fdf4; }
.supRow.err { background: #fef2f2; }
.okerr button { padding: 5px 10px; }
.okerr button.on.okb { background: var(--ok); border-color: var(--ok); color: #fff; }
.okerr button.on.errb { background: var(--bad); border-color: var(--bad); color: #fff; }
.fix { grid-column: 1 / -1; font-size: 12.5px; }
.fix label { margin-right: 12px; }
.aut { display: grid; gap: 6px; }
.aut label { display: block; border: 1px solid #cfd4dc; border-radius: 8px; padding: 7px 10px; cursor: pointer; }
.aut label:has(input:checked) { border-color: var(--accent); background: #ecfeff; }
.aut small { color: var(--muted); display: block; margin-left: 22px; }
.bar { display: flex; height: 22px; border-radius: 5px; overflow: hidden; font-size: 11px; color: #fff; }
.bar div { display: flex; align-items: center; justify-content: center; }

header .who { margin-left: auto; color: #cbd5e1; font-size: 13px; white-space: nowrap; display: flex; gap: 8px; align-items: center; }
header .who button { background: transparent; color: #cbd5e1; border-color: #475569; padding: 3px 10px; }
#loginBox { position: fixed; inset: 0; background: var(--bg); z-index: 40; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 10px; }
.login label { display: flex; flex-direction: column; gap: 4px; margin: 0; }
.login input { font-size: 16px; padding: 9px 10px; }
.login button { padding: 10px; font-size: 15px; }
body.role-valutatore .adminOnly { display: none !important; }
/* ---------- telefono ---------- */
@media (max-width: 760px) {
  header { flex-wrap: wrap; gap: 4px 10px; padding: 6px 10px; }
  .brand { font-size: 15px; }
  nav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  nav button { padding: 9px 8px; white-space: nowrap; }
  nav .sep { display: none; }
  main { padding: 12px 10px 80px; }
  h1 { font-size: 18px; }
  .cards { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; gap: 10px; }
  .imgPane img { max-height: 46vh; }
  .formPane { max-height: none; overflow: visible; padding: 10px; }
  .supRow, .prow { grid-template-columns: 1fr; }
  .okerr { display: flex; gap: 8px; }
  .okerr button { flex: 1; padding: 11px 8px; font-size: 15px; }
  .tri { width: 100%; }
  .tri label { flex: 1; text-align: center; padding: 10px 4px; font-size: 14px; }
  .fix label { display: inline-flex; padding: 6px 4px; }
  .aut label { padding: 10px; }
  .toolbar label, .row label { width: 100%; }
  .toolbar input, .row input { width: 100%; font-size: 16px; }
  .toolbar .inline, .toolbar .likert label { width: auto; }
  button.primary { padding: 11px 14px; font-size: 15px; }
  table.grid { display: block; overflow-x: auto; }
  input, select, textarea { font-size: 16px; }
}
@media (max-width: 760px) {
  header { position: static; }
  #supArea .imgPane, #rateArea .imgPane, #revArea .imgPane { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 4px 0 6px; }
  #supArea .imgPane img, #rateArea .imgPane img, #revArea .imgPane img { max-height: 30vh; }
  .imgPane .hint { display: none; }
  .imgPane .code { margin-bottom: 2px; font-size: 14px; }
  table.grid th { top: 0; }
}
