:root {
  --brand: #1b3a5b;
  --brand-2: #27568a;
  --ok: #2e7d32;
  --no: #c62828;
  --na: #757575;
  --bg: #eef1f4;
  --card: #ffffff;
  --line: #dfe4ea;
  --txt: #1a1a1a;
  --muted: #6b7480;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, "Segoe UI", Roboto, sans-serif;
  color: var(--txt); background: var(--bg);
  display: flex; flex-direction: column; min-height: 100vh;
}

/* Header */
header.app {
  background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; position: sticky; top: 0; z-index: 10;
}
header.app img { height: 38px; }
header.app .title { font-size: .95rem; font-weight: 600; color: var(--brand); }
header.app .net { margin-left: auto; font-size: .72rem; padding: 4px 9px; border-radius: 20px; }
.net.online { background: #e6f4ea; color: var(--ok); }
.net.offline { background: #fdecea; color: var(--no); }

/* Step bar */
.steps { display: flex; overflow-x: auto; background: #fff; border-bottom: 1px solid var(--line); }
.steps button {
  flex: 0 0 auto; border: 0; background: none; padding: 11px 14px;
  font-size: .82rem; color: var(--muted); border-bottom: 3px solid transparent; cursor: pointer;
}
.steps button.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.steps button .num {
  display: inline-flex; width: 20px; height: 20px; border-radius: 50%;
  background: var(--bg); color: var(--muted); align-items: center; justify-content: center;
  font-size: .72rem; margin-right: 6px;
}
.steps button.active .num { background: var(--brand); color: #fff; }
.steps button.done .num { background: var(--ok); color: #fff; }

/* Layout */
main { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.card > h2 { margin: 0 0 4px; font-size: 1.05rem; color: var(--brand); }
.card > .sub { margin: 0 0 12px; color: var(--muted); font-size: .85rem; }

/* Form */
label { display: block; font-size: .8rem; color: #4a5560; margin: 10px 0 4px; font-weight: 500; }
input, select, textarea {
  width: 100%; padding: 11px; border: 1px solid #c7ced6; border-radius: 9px;
  font-size: 1rem; background: #fff; color: var(--txt);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); border-color: var(--brand-2); }
textarea { min-height: 64px; resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
@media (max-width: 480px) { .row-3 { grid-template-columns: 1fr 1fr; } }
.req { color: var(--no); }

/* Buttons */
button.btn {
  border: 0; border-radius: 10px; padding: 13px 16px; font-size: 1rem; font-weight: 600; cursor: pointer;
  background: var(--brand); color: #fff;
}
button.btn.sec { background: #eaeef3; color: var(--brand); }
button.btn.ghost { background: none; color: var(--brand); padding: 8px; }
button.btn.danger { background: #fbe9e7; color: var(--no); }
button.btn:disabled { opacity: .5; }
.actions { display: flex; gap: 10px; justify-content: space-between; margin-top: 8px; }
.actions .spacer { flex: 1; }

/* Pills / chips */
.pill { display: inline-block; background: #eef2f6; border-radius: 20px; padding: 3px 10px; font-size: .78rem; color: #44515f; }
.chip-ok { background: #e6f4ea; color: var(--ok); }
.chip-no { background: #fdecea; color: var(--no); }
.chip-na { background: #eceff1; color: var(--na); }

/* Lists */
.item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.item .hd { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.item .hd .grow { flex: 1; }
.item .hd .name { font-weight: 600; }
.item .body { margin-top: 10px; }
.collapsed .body { display: none; }

/* String matrix */
.mppt-block { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; }
.mppt-block > .lbl { font-weight: 600; color: var(--brand); font-size: .9rem; margin-bottom: 6px; }
.str-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 480px) { .str-grid { grid-template-columns: 1fr; } }
.str-cell { border: 1px dashed #c7ced6; border-radius: 9px; padding: 8px; }
.str-cell.filled { border-style: solid; border-color: var(--ok); background: #f6fbf7; }

/* Ispezione wizard */
.iv-wrap { text-align: center; }
.iv-progress { height: 6px; background: #e4e9ef; border-radius: 6px; overflow: hidden; margin-bottom: 14px; }
.iv-progress > i { display: block; height: 100%; background: var(--brand); }
.iv-group { font-size: .8rem; color: var(--brand); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.iv-q { font-size: 1.12rem; margin: 10px 0 4px; line-height: 1.35; }
.iv-flag { font-size: .76rem; color: var(--no); margin-bottom: 14px; }
.iv-btns { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.iv-btns button { padding: 16px 0; font-size: 1.05rem; font-weight: 700; border: 2px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; }
.iv-btns button.sel-si { background: var(--ok); color: #fff; border-color: var(--ok); }
.iv-btns button.sel-no { background: var(--no); color: #fff; border-color: var(--no); }
.iv-btns button.sel-na { background: var(--na); color: #fff; border-color: var(--na); }
.iv-counter { color: var(--muted); font-size: .82rem; margin-top: 4px; }

/* Home / drafts */
.draft { display: flex; align-items: center; gap: 10px; }
.draft .grow { flex: 1; }
.toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  background: #263238; color: #fff; padding: 10px 16px; border-radius: 24px; font-size: .9rem;
  opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 50;
}
.toast.show { opacity: .96; }
.hidden { display: none !important; }
.small { font-size: .8rem; color: var(--muted); }

/* Foto */
.foto-w { margin-top: 8px; }
.foto-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.foto-th { position: relative; width: 84px; height: 84px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.foto-th img { width: 100%; height: 100%; object-fit: cover; }
.foto-th .foto-del {
  position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border: 0;
  border-radius: 50%; background: rgba(198,40,40,.92); color: #fff; font-size: .8rem; cursor: pointer;
}
.foto-add { padding: 8px 0; }
