
:root{
  --bg:#f6f7f8;--card:#fff;--text:#15171a;--muted:#656b73;--border:#dfe3e8;
  --green:#166534;--green-bg:#dcfce7;--red:#991b1b;--red-bg:#fee2e2;
  --amber:#92400e;--amber-bg:#fef3c7;--gray-bg:#eef0f2;--accent:#166534;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0;background:var(--bg);color:var(--text);font-family:system-ui,-apple-system,Segoe UI,Roboto,sans-serif}
button,input,textarea,select{font:inherit}
button{touch-action:manipulation}
.app{max-width:720px;margin:0 auto;padding:0 14px 96px}
.topbar{position:sticky;top:0;z-index:20;background:rgba(246,247,248,.96);backdrop-filter:blur(8px);padding:12px 0 10px;border-bottom:1px solid var(--border)}
.toprow{display:flex;align-items:center;gap:10px}
.iconbtn{width:46px;height:46px;border:1px solid var(--border);border-radius:14px;background:#fff;font-size:22px}
h1{font-size:22px;line-height:1.15;margin:0;flex:1}
.sub{color:var(--muted);font-size:14px;margin-top:4px}
.progress{height:9px;background:#e5e7eb;border-radius:999px;overflow:hidden;margin-top:10px}
.progress>div{height:100%;background:var(--accent);border-radius:inherit}
.card{background:var(--card);border:1px solid var(--border);border-radius:18px;padding:15px;margin:12px 0}
.visit-card{padding:18px}
.visit-title{display:flex;justify-content:space-between;gap:10px;align-items:flex-start}
.visit-title h2{font-size:20px;margin:0}
.pill{font-size:13px;padding:5px 9px;border-radius:999px;background:var(--gray-bg);white-space:nowrap}
.stats{display:flex;gap:8px;flex-wrap:wrap;margin:12px 0}
.stat{font-size:14px;background:#f3f4f6;padding:7px 9px;border-radius:10px}
.actions{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.btn{min-height:48px;border:0;border-radius:14px;padding:11px 14px;font-weight:700}
.btn.primary{background:var(--accent);color:white}
.btn.secondary{background:#fff;border:1px solid var(--border);color:var(--text)}
.btn.danger{background:var(--red-bg);color:var(--red)}
.section-grid{display:grid;grid-template-columns:1fr;gap:10px;margin-top:12px}
.section-btn{width:100%;text-align:left;background:#fff;border:1px solid var(--border);border-radius:16px;padding:14px;min-height:62px;display:flex;justify-content:space-between;align-items:center;gap:12px}
.section-btn strong{font-size:16px}
.item{background:#fff;border:1px solid var(--border);border-radius:18px;padding:15px;margin:12px 0}
.item.critical{border-left:5px solid #d97706}
.item-label{font-size:17px;line-height:1.25;font-weight:750;margin-bottom:12px}
.quick{display:grid;grid-template-columns:1fr 1fr;gap:9px}
.choice{min-height:52px;border-radius:14px;border:1px solid var(--border);background:#fff;font-weight:750}
.choice[data-v="ok"].selected{background:var(--green-bg);border-color:#86efac;color:var(--green)}
.choice[data-v="bad"].selected{background:var(--red-bg);border-color:#fca5a5;color:var(--red)}
.choice[data-v="check"].selected{background:var(--amber-bg);border-color:#fcd34d;color:var(--amber)}
.choice[data-v="na"].selected{background:var(--gray-bg);border-color:#cbd5e1}
.fieldrow{display:flex;gap:8px;align-items:center}
.field{width:100%;min-height:52px;border:1px solid var(--border);border-radius:14px;padding:12px 13px;background:#fff;font-size:18px}
.unit{color:var(--muted);font-weight:700;min-width:max-content}
.note{width:100%;min-height:70px;border:1px solid var(--border);border-radius:14px;padding:11px 12px;margin-top:10px;resize:vertical;font-size:16px}
.details-toggle{margin-top:10px;border:0;background:transparent;color:var(--accent);font-weight:700;padding:8px 0}
.photo-row{margin-top:10px;display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.photo-btn{display:inline-flex;align-items:center;justify-content:center;min-height:46px;padding:10px 12px;border:1px solid var(--border);border-radius:12px;background:#fff;font-weight:700}
.photo-btn input{display:none}
.thumb{width:68px;height:68px;object-fit:cover;border-radius:10px;border:1px solid var(--border)}
.navbar{position:sticky;bottom:0;background:rgba(246,247,248,.97);backdrop-filter:blur(8px);padding:10px 0 14px;display:grid;grid-template-columns:1fr 1fr;gap:10px;border-top:1px solid var(--border);z-index:20}
.section-head{padding:14px 0 2px}
.section-head h2{font-size:21px;margin:0}
.section-head p{font-size:14px;color:var(--muted);margin:5px 0 0}
.compare{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.compare .col{min-width:0}
.compare-head{font-weight:800;margin-bottom:7px}
.compare-row{background:#fff;border:1px solid var(--border);border-radius:14px;padding:12px;margin:9px 0}
.compare-label{font-size:14px;color:var(--muted);margin-bottom:8px}
.compare-values{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.cval{padding:10px;border-radius:10px;background:#f8fafc;min-height:44px;word-break:break-word}
.summarybox{width:100%;min-height:88px;border:1px solid var(--border);border-radius:14px;padding:12px;font-size:16px}
.export-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.small{font-size:13px;color:var(--muted)}
.toast{position:sticky;bottom:86px;margin:0 auto;width:max-content;max-width:90%;background:#111827;color:white;padding:9px 12px;border-radius:12px;font-size:14px;z-index:30}
@media(min-width:560px){
  .section-grid{grid-template-columns:1fr 1fr}
  .actions{grid-template-columns:auto auto}
}

/* ---- Ajouts : synchro, photos, comparatif ------------------------- */

.syncbadge{
  font-size:12px;padding:4px 8px;border-radius:999px;white-space:nowrap;
  align-self:center;flex:0 0 auto;
}
.syncbadge:empty{display:none}
.syncbadge.syncing{background:#e0e7ff;color:#3730a3}
.syncbadge.ok{background:#dcfce7;color:#166534}
.syncbadge.offline{background:#f1f5f9;color:#475569}
.syncbadge.error{background:#fef3c7;color:#92400e}

.visit-card.archived{opacity:.6}

.photogrid{display:flex;flex-wrap:wrap;gap:8px;margin:8px 0}
.phototile{position:relative;width:96px;height:96px;border-radius:10px;overflow:hidden;background:#e2e8f0}
.phototile img{width:100%;height:100%;object-fit:cover;display:block}
.phototile .badge{
  position:absolute;left:0;right:0;bottom:0;font-size:10px;text-align:center;
  background:rgba(15,23,42,.72);color:#fff;padding:2px 0;
}
/* Large enough to hit reliably one-handed, per the 48px rule everything else
   in this app follows. */
.photodel{
  position:absolute;top:0;right:0;width:32px;height:32px;border:0;
  background:rgba(15,23,42,.66);color:#fff;font-size:16px;line-height:32px;
  padding:0;cursor:pointer;
}

.compare-pickers{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-bottom:10px}
/* A criterion where exactly one side is a problem is the reason this screen
   exists, so it is the only thing highlighted. No winner is computed. */
.compare-row.differs{background:#fffbeb;border-radius:8px;padding:6px;margin:0 -6px}
.cval.bad{color:#b91c1c;font-weight:600}
