/* Identità ClericiAuto, come le altre applicazioni (cle-serviceman): blu corporate #003f52, font Inter, header chiaro con logo. */
@font-face { font-family: "Inter Variable"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url("fonts/inter-latin-ext-wght-normal-ZIT2UBIY.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Inter Variable"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url("fonts/inter-latin-wght-normal-DIHYUR35.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --bg: #f9fafb;
  --card: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #003f52;
  --primary-hover: #003646;
  --primary-tint: #e6ecee;
  --primary-soft: #bfcfd4;
  --primary-ink: #ffffff;
  --ok: #12a150;
  --warn: #b26a00;
  --err: #c62828;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 27, 45, .06), 0 6px 20px rgba(15, 27, 45, .06);
  font-family: "Inter Variable", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { display: flex; flex-direction: column; min-height: 100vh; padding-bottom: env(safe-area-inset-bottom); }
[hidden] { display: none !important; }

/* Header come in serviceman/Filament: barra chiara con logo, "| nome app" in blu corporate e menu utente a destra */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: #fff; color: var(--ink); border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: .35rem; font-weight: 700; color: var(--primary); min-width: 0; }
.brand-logo { height: 1.5rem; width: auto; flex: none; }
.brand-name { font-size: 1.125rem; white-space: nowrap; }
.user { display: flex; align-items: center; gap: 10px; font-size: 14px; min-width: 0; }
.user #userName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 520px) { .brand-name { font-size: 1rem; } .user #userName { display: none; } }

/* Schermata di accesso: senza barra, logo grande al centro sopra la scheda (come il login Filament) */
body.on-login .topbar { display: none; }
body.on-login main { display: flex; flex-direction: column; justify-content: center; }
.login-card { margin-top: 0; padding: 28px 24px; }
.login-logo { display: block; height: 2.25rem; width: auto; margin: 0 auto 20px; }
.login-card h1 { text-align: center; font-size: 24px; font-weight: 700; }
.login-card > .muted { text-align: center; margin: 0 0 20px; }
.login-or { display: flex; align-items: center; gap: 12px; margin: 18px 0 14px; color: var(--muted); font-size: 13px; }
.login-or::before, .login-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }


main { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.narrow { max-width: 420px; margin: 24px auto; }
.center { text-align: center; }
h1 { font-size: 22px; margin: 0 0 6px; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 22px 0 10px; }
h2:first-child { margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; background: var(--bg); padding: 6px 10px; border-radius: 8px; display: inline-block; word-break: break-all; }

label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 12px; }
input, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 12px; font: inherit; font-weight: 400;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
/* 16px: sotto questa soglia iOS Safari ingrandisce la pagina al focus di un campo */
input, textarea, select { font-size: 16px; }
input:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
.upper { text-transform: uppercase; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .row { grid-template-columns: 1fr; gap: 0; } }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 16px 0; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 13px 18px; border-radius: 12px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; min-height: 48px;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
a.btn { text-decoration: none; }
.btn.primary:disabled { opacity: .55; cursor: progress; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; margin-top: 6px; }
.btn-link { background: none; border: 0; color: var(--primary); font: inherit; cursor: pointer; padding: 4px; }
.back { margin-top: 14px; }

.error { color: var(--err); background: #fdecec; padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.warn { color: var(--warn); background: #fff4e0; padding: 10px 12px; border-radius: 10px; font-size: 14px; }

.steps { display: flex; list-style: none; padding: 0; margin: 0 0 14px; gap: 6px; counter-reset: s; }
.steps li { flex: 1; font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; padding-top: 8px; border-top: 3px solid var(--line); }
.steps li.active { color: var(--primary); border-color: var(--primary); }
.steps li.done { color: var(--ok); border-color: var(--ok); }

.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.doc-opt { position: relative;
  border: 1.5px solid var(--line); border-radius: 12px; padding: 12px; background: #fff; text-align: left;
  font: inherit; cursor: pointer; min-height: 72px; color: var(--ink);
}
.doc-opt .ico { font-size: 22px; display: block; margin-bottom: 4px; }
.doc-opt .lbl { font-size: 14px; font-weight: 600; }
.doc-opt[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-tint); box-shadow: 0 0 0 2px rgba(0, 63, 82, .18); }

.camera { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 3 / 4; max-height: 70vh; width: 100%; }
@media (min-width: 640px) { .camera { aspect-ratio: 4 / 3; } }
.camera video { width: 100%; height: 100%; object-fit: cover; display: block; }
.frame { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.frame span {
  width: 88%; aspect-ratio: 1.586; border: 3px solid rgba(255, 255, 255, .95); border-radius: 14px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .45);
}
.frame.passport span { aspect-ratio: 1.42; }
.camera-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; color: #fff; background: rgba(0, 0, 0, .7); font-size: 15px; }

.preview img { width: 100%; border-radius: 12px; display: block; border: 1px solid var(--line); }
.preview .warn { margin-top: 10px; }
.fix-note { margin: 8px 0 0; }

.actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
.actions .btn { flex: 1; }
.shutter {
  width: 72px; height: 72px; flex: none; border-radius: 50%; border: 5px solid var(--primary); background: #fff;
  cursor: pointer; box-shadow: inset 0 0 0 4px #fff, inset 0 0 0 40px var(--primary);
}
.shutter:active { transform: scale(.94); }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }

.summary { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 16px; font-size: 14px; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 600; word-break: break-word; }
.thumbs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.thumbs figure { margin: 0; }
.thumbs img { width: 100%; border-radius: 10px; border: 1px solid var(--line); display: block; }
.thumbs figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; text-align: center; }

.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 16px; }
.progress div { height: 100%; width: 0; background: var(--primary); transition: width .15s; }

.ok-icon { width: 64px; height: 64px; border-radius: 50%; background: var(--ok); color: #fff; font-size: 34px; line-height: 64px; margin: 4px auto 14px; }
.foot { text-align: center; font-size: 12px; color: var(--muted); padding: 16px; }

/* ---- Profilo in attesa ---- */
.pending-icon { font-size: 44px; text-align: center; margin-bottom: 6px; }
#viewPending h1 { text-align: center; }
.info-box { background: var(--bg); border-radius: 12px; padding: 12px; margin: 16px 0; text-align: center; }
.info-box .mono { background: #fff; margin-top: 6px; font-size: 15px; }
#viewPending .btn.ghost { margin-top: 8px; }

/* ---- Demo ---- */
.demo-banner {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 8px 16px; background: repeating-linear-gradient(-45deg, #ffb300, #ffb300 14px, #ffc233 14px, #ffc233 28px);
  color: #3a2600; font-size: 13px;
}
.demo-banner .btn-link { color: #3a2600; text-decoration: underline; font-weight: 600; }
body.demo .btn.primary { background: #b26a00; border-color: #b26a00; }
body.demo .shutter { border-color: #b26a00; box-shadow: inset 0 0 0 4px #fff, inset 0 0 0 40px #b26a00; }

/* ---- Gestione ---- */
.admin-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.spaced { margin-top: 14px; }
.profile-list { display: flex; flex-direction: column; gap: 10px; }
.profile-row { border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.profile-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.profile-name { font-weight: 600; }
.profile-ident { overflow-wrap: anywhere; }
.profile-ctrls { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-top: 10px; }
@media (max-width: 520px) { .profile-ctrls { grid-template-columns: 1fr 1fr; } .profile-ctrls .btn { grid-column: 1 / -1; } }
.profile-ctrls .btn { min-height: 44px; padding: 10px 16px; }
select { font: inherit; font-size: 16px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); min-height: 44px; width: 100%; }
.badge { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 99px; white-space: nowrap; }
.badge.pending { background: #fff4e0; color: var(--warn); }
.badge.active { background: #e6f6ed; color: var(--ok); }
.badge.disabled { background: #eceff3; color: var(--muted); }

.sticky-head { position: sticky; top: 0; z-index: 5; }
@media (max-width: 440px) {
  .brand-sub { display: none; }
  .user { gap: 8px; font-size: 13px; }
  .user #userName { max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ---- Multi-documento ---- */
.bundles { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  font: inherit; font-size: 13px; font-weight: 600; padding: 8px 12px; border-radius: 99px; cursor: pointer;
  border: 1.5px solid var(--line); background: #fff; color: var(--ink); min-height: 38px;
}
.chip[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-tint); color: var(--primary); }
.doc-opt .order {
  position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 13px; font-weight: 700; line-height: 24px; text-align: center;
}
.doc-opt .already { display: block; font-size: 11px; color: var(--ok); margin-top: 4px; font-weight: 600; }
#selectionInfo { margin: 8px 0 0; }
body.demo .doc-opt .order { background: #b26a00; }

.customer-lock {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  background: var(--primary-tint); border: 1px solid var(--primary-soft); border-radius: 12px; padding: 12px 14px; margin-bottom: 18px;
}
.customer-lock-name { font-weight: 700; font-size: 17px; }
.customer-lock-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; }
.ok-text { color: var(--ok); margin-top: 4px; font-weight: 600; }

.capture-progress { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.capture-progress .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.capture-progress .dot.done { background: var(--ok); }
.capture-progress .dot.cur { background: var(--primary); box-shadow: 0 0 0 3px rgba(0, 63, 82, .22); }

.doc-review { display: flex; flex-direction: column; gap: 12px; }
.doc-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.doc-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 14px; }
.doc-card.sent { border-color: #b7e3c8; background: #f3fbf6; }
.doc-card.sent .doc-status { color: var(--ok); font-weight: 700; }
.doc-card.error { border-color: #f3c1c1; background: #fff7f7; }
.doc-card.error .doc-status { color: var(--err); font-weight: 700; }
.doc-card.sending .doc-status { color: var(--primary); }
.doc-card .error { margin: 8px 0 0; }

.done-list { list-style: none; padding: 0; margin: 4px 0 14px; text-align: left; display: inline-block; }
.done-list li { color: var(--ok); font-weight: 600; padding: 2px 0; }
#viewDone .btn.ghost { margin-top: 8px; }
#customerFields h2:first-child { margin-top: 22px; }

/* ---- Lettura automatica ---- */
.doc-opt .reads { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
.read-hint { background: var(--primary-tint); border-radius: 10px; padding: 10px 12px; color: #1b3d80; }
.read-status { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-size: 14px; }
.read-status.busy { background: var(--primary-tint); color: #1b3d80; }
.read-status.ok { background: #e6f6ed; color: #0d6b36; }
.read-status.fail { background: #fff4e0; color: var(--warn); }
.spinner { width: 18px; height: 18px; flex: none; border-radius: 50%; border: 3px solid #cddcff; border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.read-warnings { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-direction: column; gap: 6px; }
.read-warnings li { background: #fff4e0; color: #7a4a00; border-radius: 10px; padding: 9px 12px; font-size: 14px; }
label.auto { position: relative; }
label.auto::after {
  content: "📷 letto"; position: absolute; top: 0; right: 0; font-size: 11px; font-weight: 700;
  color: #0d6b36; background: #e6f6ed; border-radius: 99px; padding: 1px 8px;
}
label.auto input { border-color: #9fd8b5; background: #f6fcf8; }
.doc-fields { border: 1px solid var(--line); border-radius: 12px; padding: 12px 12px 0; margin-bottom: 10px; }
.doc-fields-title { font-weight: 600; font-size: 14px; margin-bottom: 8px; }
#docFields h2 { margin-top: 22px; }
#dataBackBtn { display: block; margin: 12px auto 0; }

/* Archivio documenti (admin) */
.archive-list { display: grid; gap: 8px; margin: 10px 0; }
.archive-row { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.archive-head { display: block; width: 100%; text-align: left; background: none; border: 0; font: inherit; padding: 12px; cursor: pointer; color: var(--ink); }
.archive-head .t { font-weight: 700; }
.archive-detail { padding: 0 12px 12px; }
.archive-detail .summary { margin: 8px 0 12px; }
.archive-imgs { display: grid; gap: 10px; }
.archive-imgs figure { margin: 0; }
.archive-imgs img { width: 100%; border-radius: 10px; border: 1px solid var(--line); display: block; }
.archive-imgs figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; }
