/* Repair Portal — stile ispirato ai portali dei servizi online comunali */
:root {
  --navy: #1d3352;
  --navy-2: #2c4a73;
  --blue: #2f6aa3;
  --brown: #6e5b4b;
  --teal: #1f4a68;
  --olive: #5c6a37;
  --brown-2: #7c6a5a;
  --teal-2: #3e5d7c;
  --olive-2: #7f8b5d;
  --bg: #ececec;
  --panel: #f7f7f7;
  --line: #cfd4da;
  --text: #2a2a2a;
  --muted: #6b7178;
  --ok: #3d7a3a;
  --warn: #b07d2a;
  --err: #a33a3a;
  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 13px; color: var(--text); background: var(--bg); display: flex; flex-direction: column; min-height: 100vh; }
a { color: var(--blue); text-decoration: none; cursor: pointer; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }

/* ---------- Splash ---------- */
#splash { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #ffffff 0%, #e3e9f0 55%, #c9d5e3 100%); transition: opacity .45s ease; }
#splash.hide { opacity: 0; pointer-events: none; }
.splash-box { text-align: center; width: 340px; }
.splash-logo { width: 84px; height: 94px; animation: pop .6s ease; }
.splash-bar { margin: 22px auto 10px; height: 6px; width: 100%; background: #d5dce4; border-radius: 3px; overflow: hidden; }
.splash-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--navy-2), var(--blue)); transition: width .35s ease; }
.splash-msg { color: var(--muted); font-size: 12px; letter-spacing: .3px; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- Header ---------- */
.top { height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px;
  background: linear-gradient(90deg, #ffffff 0%, #ffffff 35%, #dfe6ee 70%, #b9c7d8 100%); }
.brand { display: flex; align-items: center; gap: 12px; }
.crest { width: 40px; height: 45px; }
.brand-name { font-weight: 700; font-size: 13px; line-height: 15px; color: #23364f; letter-spacing: .2px; }
.wordmark { font-family: "Arial Narrow", "Helvetica Neue", Arial, sans-serif; font-stretch: condensed; font-size: 30px; letter-spacing: -1px; user-select: none; }
.wordmark .wm-light { color: #f4f6f9; font-weight: 300; text-shadow: 0 0 1px #9fb0c4; }
.wordmark .wm-bold { color: var(--navy); font-weight: 700; margin-left: 2px; }
.wordmark.big { font-size: 40px; margin-top: 10px; }
.wordmark.big .wm-light { color: #8ea2ba; text-shadow: none; }
.navbar { height: 14px; background: linear-gradient(#2a4568, var(--navy)); display: flex; justify-content: flex-end; align-items: center; padding: 0 8px; color: #c7d3e2; font-size: 10px; gap: 10px; }
.navbar-up { background: none; border: 0; color: #fff; font-size: 9px; cursor: pointer; padding: 0; }
.crumbs { height: 18px; line-height: 18px; background: linear-gradient(#dfe5ec, #cdd6e0); color: #4b5d73; font-size: 11px; padding: 0 10px; border-bottom: 1px solid #bcc7d4; }
.crumbs a { color: #2c4a73; }

/* ---------- Layout ---------- */
.layout { flex: 1; display: flex; gap: 14px; padding: 10px 14px 20px 3px; align-items: flex-start; }
.side { width: 168px; flex-shrink: 0; display: flex; flex-direction: column; gap: 10px; }
.main { flex: 1; min-width: 0; }
.foot { font-size: 10px; color: #8a9099; text-align: center; padding: 10px; border-top: 1px solid #dadada; background: #f2f2f2; }

/* ---------- Pannelli laterali ---------- */
.box { background: var(--panel); border: 1px solid var(--line); }
.box-h { background: linear-gradient(#5e86b5, #3c6596); color: #fff; font-weight: 700; font-size: 11px; padding: 3px 8px; }
.box-b { padding: 6px 8px; font-size: 11px; }
.box-b .who { font-weight: 700; }
.box-b .muted { color: var(--muted); font-style: italic; }
.side-btn { display: inline-flex; align-items: center; gap: 4px; margin: 6px auto 2px; padding: 2px 10px; font-size: 10px; font-weight: 700;
  background: linear-gradient(#ffffff, #e2e2e2); border: 1px solid #c3c3c3; border-radius: 3px; cursor: pointer; color: #333; }
.side-btn:hover { background: linear-gradient(#ffffff, #d6dde6); }
.side-menu a { display: block; padding: 4px 2px; border-bottom: 1px dotted #d3d7dc; color: #2c4a73; font-size: 11px; }
.side-menu a.active { font-weight: 700; color: var(--navy); }
.side-menu a:last-child { border-bottom: 0; }
.side input { width: 100%; font-size: 11px; padding: 3px 4px; border: 1px solid #b7bfca; }

/* ---------- Home: riquadri ---------- */
.welcome { font-size: 13px; color: #33465e; margin: 2px 0 10px; }
.welcome b { color: var(--navy); }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(140px, 180px)); gap: 6px; }
.tile { position: relative; height: 82px; color: #fff; text-decoration: none !important; display: flex; align-items: flex-end; justify-content: flex-end;
  padding: 8px 10px; font-weight: 700; font-size: 13px; text-align: right; text-transform: uppercase; line-height: 1.15; cursor: pointer; transition: filter .15s, transform .15s; }
.tile:hover { filter: brightness(1.12); transform: translateY(-1px); }
.tile .ico { position: absolute; top: 8px; right: 10px; width: 22px; height: 22px; opacity: .95; }
.tile .count { position: absolute; top: 8px; left: 10px; font-size: 22px; font-weight: 300; }
.tile.sm { height: 52px; font-size: 11px; text-transform: none; }
.tile.sm .ico { width: 14px; height: 14px; top: 6px; left: 8px; right: auto; }
.tile.sm .count { font-size: 15px; top: 5px; left: auto; right: 10px; }
.t-blue { background: var(--blue); } .t-brown { background: var(--brown); } .t-teal { background: var(--teal); } .t-olive { background: var(--olive); }
.t-brown2 { background: var(--brown-2); } .t-teal2 { background: var(--teal-2); } .t-olive2 { background: var(--olive-2); } .t-navy { background: var(--navy-2); }
.tiles-sm { margin-top: 6px; }
.home-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; margin-top: 16px; max-width: 1100px; }

/* ---------- Card / pannello contenuti ---------- */
.card { background: #fafafa; border: 1px solid #d6d6d6; border-radius: 3px; box-shadow: 0 1px 2px rgba(0,0,0,.04); margin-bottom: 12px; }
.card-h { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid #e1e1e1; font-size: 14px; color: #2b3a4d; }
.card-h .ico { width: 16px; height: 16px; color: var(--navy-2); }
.card-h .sp { flex: 1; }
.card-b { padding: 12px; }
.card-b.tight { padding: 0; }
.inner { background: #f2f4f7; border: 1px solid #dde2e8; border-radius: 3px; padding: 14px; }
.page-title { font-size: 17px; color: var(--navy); margin: 0 0 10px; font-weight: 400; display: flex; align-items: center; gap: 10px; }
.page-title .sp { flex: 1; }

/* ---------- Form ---------- */
.grid { display: grid; gap: 10px 14px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.grid .full { grid-column: 1 / -1; }
.grid .span2 { grid-column: span 2; }
label.f { display: flex; flex-direction: column; gap: 3px; font-size: 11px; font-weight: 700; color: #3c4a5c; }
label.f small { font-weight: 400; color: var(--muted); }
input, select, textarea { font-family: inherit; font-size: 12px; padding: 5px 6px; border: 1px solid #b7bfca; border-radius: 2px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px rgba(47,106,163,.18); }
textarea { resize: vertical; min-height: 54px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; font-weight: 400; font-size: 12px; }
.checks label { display: flex; align-items: center; gap: 4px; }
.section-t { font-size: 12px; font-weight: 700; color: var(--navy-2); text-transform: uppercase; letter-spacing: .4px; margin: 4px 0 8px; padding-bottom: 4px; border-bottom: 1px solid #dfe3e8; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; align-items: center; }

.btn { display: inline-flex; align-items: center; gap: 5px; padding: 5px 12px; font-size: 12px; font-weight: 700; border-radius: 3px; cursor: pointer;
  background: linear-gradient(#ffffff, #e4e4e4); border: 1px solid #bdbdbd; color: #333; text-decoration: none !important; }
.btn:hover { background: linear-gradient(#ffffff, #d7dee7); }
.btn.primary { background: linear-gradient(#4b7fb6, #2c5d91); border-color: #24507e; color: #fff; }
.btn.primary:hover { background: linear-gradient(#5a8cc2, #2f6299); }
.btn.danger { background: linear-gradient(#c45555, #9b3333); border-color: #852a2a; color: #fff; }
.btn.ok { background: linear-gradient(#5c9b58, #3d7a3a); border-color: #346a31; color: #fff; }
.btn.sm { padding: 2px 8px; font-size: 11px; }
.btn .ico { width: 13px; height: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Login ---------- */
.login-wrap { display: flex; justify-content: center; padding-top: 4px; }
.login { width: 300px; background: #f5f5f5; border: 1px solid #d4d4d4; border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.login .card-h { font-size: 14px; }
.login form { margin: 8px; background: #f0f2f5; border: 1px solid #dfe3e8; border-radius: 3px; padding: 18px 20px 22px; text-align: center; }
.login label { display: block; font-size: 11px; font-weight: 700; margin: 10px 0 4px; }
.login input { width: 170px; text-align: center; }
.login .btn { margin-top: 14px; }
.login .lnk { display: block; margin-top: 8px; font-size: 11px; }
.login .err { color: var(--err); font-size: 11px; margin-top: 10px; min-height: 14px; }
.login.wide { width: 420px; }
.login.wide input { width: 100%; text-align: left; }
.login.wide label { text-align: left; }

/* ---------- Tabelle ---------- */
table.t { width: 100%; border-collapse: collapse; font-size: 12px; }
table.t th { text-align: left; background: linear-gradient(#f3f5f8, #e3e8ee); color: #3a4a5f; font-size: 11px; padding: 6px 8px; border-bottom: 1px solid #ccd3dc; white-space: nowrap; }
table.t td { padding: 6px 8px; border-bottom: 1px solid #e6e6e6; vertical-align: top; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #eef3f9; }
table.t tr.low td { background: #fbeeee; }
table.t td.num, table.t th.num { text-align: right; }
.empty { padding: 20px; text-align: center; color: var(--muted); font-style: italic; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.toolbar input[type=search] { width: 260px; }
.toolbar .sp { flex: 1; }

/* ---------- Badge stato ---------- */
.badge { display: inline-block; padding: 2px 7px; border-radius: 10px; color: #fff; font-size: 10.5px; font-weight: 700; white-space: nowrap; }
.prio-urgente { color: var(--err); font-weight: 700; }
.late { color: var(--err); font-weight: 700; }
.code { font-family: Menlo, Consolas, monospace; background: #eef1f5; padding: 1px 5px; border-radius: 3px; border: 1px solid #d7dde5; }

/* ---------- Dettaglio ---------- */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 4px 10px; font-size: 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.money { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 12px; }
.money .tot { font-weight: 700; font-size: 14px; border-top: 1px solid #ccc; padding-top: 4px; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid #d3dae3; }
.timeline li { position: relative; padding: 0 0 10px 8px; font-size: 12px; }
.timeline li::before { content: ""; position: absolute; left: -21px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--c, #999); border: 2px solid #fff; box-shadow: 0 0 0 1px #c7ced8; }
.timeline .when { color: var(--muted); font-size: 11px; }

/* ---------- Statistiche ---------- */
.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 170px 1fr 60px; gap: 8px; align-items: center; font-size: 12px; }
.bar { height: 14px; background: #e3e7ec; border-radius: 2px; overflow: hidden; }
.bar > i { display: block; height: 100%; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.kpi { background: #fff; border: 1px solid #dcdcdc; border-left: 4px solid var(--blue); padding: 10px 12px; }
.kpi b { display: block; font-size: 20px; font-weight: 400; color: var(--navy); }
.kpi span { font-size: 11px; color: var(--muted); }
.cols { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 10px; }
.col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: 10px; color: var(--muted); gap: 3px; }
.col i { display: block; width: 100%; max-width: 46px; background: var(--blue); border-radius: 2px 2px 0 0; min-height: 2px; }
.col b { color: var(--text); font-size: 11px; }

/* ---------- Avvisi ---------- */
.alert { padding: 8px 10px; border-radius: 3px; font-size: 12px; margin-bottom: 10px; border: 1px solid; }
.alert.warn { background: #fdf6e7; border-color: #ecd59f; color: #7a5a14; }
.alert.err { background: #fbeeee; border-color: #e3b5b5; color: #7d2525; }
.alert.info { background: #eef4fa; border-color: #c4d6ea; color: #2c4a73; }

/* ---------- Modal e toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(20,30,45,.45); z-index: 500; display: flex; align-items: center; justify-content: center; animation: fade .15s; }
.modal { background: #f7f7f7; border: 1px solid #c9c9c9; border-radius: 4px; width: min(480px, 92vw); max-height: 88vh; overflow: auto; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.modal .card-b { padding: 14px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
#toast-root { position: fixed; right: 16px; bottom: 16px; z-index: 600; display: flex; flex-direction: column; gap: 6px; }
.toast { background: var(--navy); color: #fff; padding: 8px 14px; border-radius: 3px; font-size: 12px; box-shadow: 0 4px 12px rgba(0,0,0,.2); animation: fade .2s; }
.toast.err { background: var(--err); }
.toast.ok { background: var(--ok); }

.ico { display: inline-block; vertical-align: middle; }
.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- Stampa ---------- */
#print-area { display: none; }
@media print {
  @page { size: A4; margin: 12mm; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; font-size: 10.5px; color: #000; }
  body { background: #fff; display: block; }
}
.rcpt { border: 1px solid #000; padding: 10px 12px; page-break-inside: avoid; }
.rcpt + .cut { border-top: 1px dashed #000; margin: 10px 0; text-align: center; font-size: 9px; }
.rcpt-h { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px solid #000; padding-bottom: 6px; margin-bottom: 6px; }
.rcpt-h img { width: 34px; height: 38px; margin-right: 8px; }
.rcpt-h .lab { display: flex; }
.rcpt-h .n { text-align: right; font-size: 12px; }
.rcpt-h .n b { font-size: 16px; }
.rcpt table { width: 100%; border-collapse: collapse; }
.rcpt td { padding: 2px 4px; vertical-align: top; }
.rcpt td.l { width: 28%; color: #333; }
.rcpt .small { font-size: 8.5px; color: #222; margin-top: 6px; white-space: pre-wrap; }
.rcpt .firme { display: flex; justify-content: space-between; margin-top: 16px; }
.rcpt .firme div { width: 42%; border-top: 1px solid #000; text-align: center; padding-top: 2px; font-size: 9px; }

@media (max-width: 900px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .home-grid, .detail-grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}

/* rifiniture */
.page-title { flex-wrap: wrap; }
.page-title > .ico { width: 22px; height: 22px; color: var(--navy-2); }
.btn { white-space: nowrap; }
.side-btn .ico { width: 11px; height: 11px; }
.box-h .ico, .tile .ico { flex-shrink: 0; }
svg.ico:not([width]) { max-width: 26px; max-height: 26px; }

/* ---------- versione online ---------- */
body.busy, body.busy * { cursor: progress !important; }
#busy { margin-right: auto; color: #ffd98a; font-weight: 700; }
a.side-btn { text-decoration: none !important; }
.steps { display: flex; margin: 14px 0 4px; }
.step { flex: 1; text-align: center; font-size: 10.5px; color: var(--muted); position: relative; }
.step i { display: block; width: 14px; height: 14px; border-radius: 50%; background: #d3dae3; margin: 0 auto 4px; position: relative; z-index: 1; border: 2px solid #fff; box-shadow: 0 0 0 1px #c7ced8; }
.step::before { content: ""; position: absolute; top: 7px; left: -50%; width: 100%; height: 3px; background: #d3dae3; }
.step:first-child::before { display: none; }
.step.done i, .step.now i { background: var(--blue); }
.step.done::before, .step.now::before { background: var(--blue); }
.step.now { color: var(--navy); font-weight: 700; }
.step.now i { box-shadow: 0 0 0 3px rgba(47,106,163,.3); }
.step.now.ko i { background: var(--err); box-shadow: 0 0 0 3px rgba(163,58,58,.3); }
.qr { width: 92px; flex-shrink: 0; text-align: center; font-size: 8px; }
.qr svg { width: 86px; height: 86px; display: block; margin: 0 auto 2px; }
.login .lnk + .lnk { margin-top: 4px; }
.card-b.tight { overflow-x: auto; }
@media (max-width: 700px) {
  .layout { flex-direction: column; padding: 8px; }
  .side { width: 100%; order: 2; }
  .main { width: 100%; order: 1; }
  .page-title { font-size: 15px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .top .wordmark { font-size: 20px; }
  .login, .login.wide { width: 100%; }
  .toolbar input[type=search] { width: 100%; }
  .kv { grid-template-columns: 110px 1fr; }
}
