/* États des lieux — styles propres à cette application (s'ajoutent à base.css) */

body { overscroll-behavior-y: none; }
.wrap { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.top { padding-top: calc(10px + env(safe-area-inset-top)); }
@media (display-mode: standalone) { body { -webkit-user-select: none; user-select: none; } input, textarea { -webkit-user-select: text; user-select: text; } }

/* ---------- Pastille de synchronisation ---------- */
.sync {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: 99px;
  border: 1px solid #ffffff33; color: #fff; text-decoration: none; font-size: 14px; font-weight: 650; white-space: nowrap;
}
.sync-dot { width: 10px; height: 10px; border-radius: 50%; background: #9ca3af; flex: none; }
.sync[data-s=ok] .sync-dot { background: #4ade80; }
.sync[data-s=warn] .sync-dot { background: #fbbf24; }
.sync[data-s=bad] .sync-dot { background: #f87171; }
.sync[data-s=busy] .sync-dot { background: #60a5fa; animation: pulse 1.2s ease-in-out infinite; }
@media (max-width: 380px) { .sync { padding: 0 10px; font-size: 13px; } .brand img { height: 28px; } }

/* ---------- Généralités ---------- */
.check { display: flex; align-items: center; gap: 12px; min-height: 44px; font-weight: 600; cursor: pointer; }
.check input { width: 26px; height: 26px; flex: none; accent-color: var(--brand); }
.section-title { font-size: 13px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; color: var(--brand); margin: 22px 0 8px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 6px 12px; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
dl.kv { margin: 0; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.btn-row > .btn { flex: 1 1 auto; }
.link-btn { background: none; border: 0; padding: 0; min-height: 44px; color: var(--brand); font-weight: 650; text-decoration: underline; cursor: pointer; }
.search { margin-bottom: 12px; }
.badge { display: inline-block; min-width: 22px; padding: 1px 7px; border-radius: 99px; background: var(--ink); color: #fff; font-size: 13px; font-weight: 700; text-align: center; }
.back-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.notice-row { display: flex; gap: 10px; align-items: flex-start; }

/* ---------- Catalogue : sélection du matériel d'un dossier ---------- */
.pick { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.pick:first-of-type { border-top: 0; }
.pick-name { font-weight: 650; overflow-wrap: anywhere; }
.pick-name small { display: block; color: var(--muted); font-weight: 500; }
.mini-step { display: flex; align-items: center; gap: 6px; flex: none; }
.mini-step button { width: 48px; height: 48px; border-radius: 12px; border: 2px solid var(--ink); background: #fff; font-size: 26px; line-height: 1; cursor: pointer; }
.mini-step button:active { background: var(--brand-soft); }
.mini-step output { min-width: 34px; text-align: center; font-size: 20px; font-weight: 750; font-variant-numeric: tabular-nums; }
.mini-step output.zero { color: var(--muted); font-weight: 500; }

/* ---------- Carte d'une phase (page dossier) ---------- */
.phase-card { display: grid; gap: 10px; }
.phase-card h3 { font-size: 19px; }
.phase-card.locked { opacity: .85; }
.prog { height: 8px; border-radius: 99px; background: #ece7df; overflow: hidden; }
.prog > i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }

/* ---------- Éditeur d'état des lieux ---------- */
.ed-head { position: sticky; top: calc(64px + env(safe-area-inset-top)); z-index: 15; background: var(--bg); padding: 8px 0 10px; margin: -8px 0 6px; border-bottom: 1px solid var(--line); }
.ed-head h1 { font-size: 20px; line-height: 1.2; }
.ed-head .prog { margin-top: 8px; }
.ed-sub { color: var(--muted); font-size: 14px; }
.line { padding: 14px; }
.line + .line { margin-top: 10px; }
.line-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.line-name { font-size: 18px; font-weight: 750; overflow-wrap: anywhere; }
.line-qty { font-weight: 750; color: var(--brand); white-space: nowrap; }
.line-ref { font-size: 14px; color: var(--ink-2); background: #f3eee5; border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.line-ref strong { font-weight: 700; }
.line-ref .tone-bad { color: var(--bad); }
.line-ref .tone-ok { color: var(--ok); }
.line-ref .link-btn { min-height: 36px; margin-left: auto; }
.states { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.st {
  grid-column: span 2; min-height: 52px; padding: 6px 4px; border-radius: 12px; border: 2px solid #b9ad9c; background: #fff;
  font-weight: 700; font-size: 15px; line-height: 1.15; cursor: pointer; color: var(--ink);
}
.st:nth-child(n+4) { grid-column: span 3; }
.st:active { transform: scale(.98); }
.st[aria-pressed=true] { color: #fff; border-color: transparent; }
.st-ok[aria-pressed=true] { background: var(--ok); }
.st-warn[aria-pressed=true] { background: var(--warn); }
.st-bad[aria-pressed=true] { background: var(--bad); }
.st-info[aria-pressed=true] { background: var(--info); }
.st:disabled { opacity: .6; }
.clean-row { margin-top: 10px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.clean-row > span { font-weight: 650; }
.seg { display: inline-flex; border: 2px solid #b9ad9c; border-radius: 12px; overflow: hidden; }
.seg button { min-height: 46px; padding: 0 16px; border: 0; background: #fff; font-weight: 700; cursor: pointer; }
.seg button + button { border-left: 2px solid #b9ad9c; }
.seg button[aria-pressed=true].yes { background: var(--ok); color: #fff; }
.seg button[aria-pressed=true].no { background: var(--bad); color: #fff; }
.line-tools { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tool {
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 14px; border-radius: 12px; border: 2px solid var(--ink);
  background: #fff; font-weight: 700; font-size: 15px; cursor: pointer; color: var(--ink);
}
.tool .ico { display: inline-grid; }
.tool svg { width: 22px; height: 22px; }
.tool.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.tool input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.tool { position: relative; }
.note-box { margin-top: 10px; }
.note-box textarea { min-height: 76px; font-size: 16px; }
.strip { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.thumb { position: relative; width: 76px; height: 76px; padding: 0; border: 2px solid var(--line); border-radius: 12px; overflow: hidden; background: #ece7df; cursor: pointer; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .pend { position: absolute; right: 4px; bottom: 4px; width: 14px; height: 14px; border-radius: 50%; background: var(--warn); border: 2px solid #fff; }
.thumb.busy { animation: pulse 1.2s ease-in-out infinite; }
.no-photo { font-size: 13px; color: var(--muted); margin-top: 8px; }

.bar-fixed {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: #fffdf9; border-top: 1px solid var(--line);
  padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom));
}
.bar-fixed .in { max-width: 720px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }
.bar-fixed .btn { flex: 1; }
.bar-fixed .hint { font-size: 14px; color: var(--muted); flex: 1 1 auto; }

/* ---------- Retenues ---------- */
.ret { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.ret:first-of-type { border-top: 0; }
.ret .lbl { overflow-wrap: anywhere; font-weight: 600; }
.ret .amt { font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; }
.total-line { display: flex; justify-content: space-between; gap: 10px; padding-top: 10px; border-top: 2px solid var(--ink); font-weight: 800; }

/* ---------- Signature ---------- */
.sig-wrap { border: 2px solid var(--ink); border-radius: 14px; background: #fff; position: relative; overflow: hidden; }
.sig-wrap canvas { display: block; width: 100%; height: 220px; touch-action: none; cursor: crosshair; }
.sig-wrap .sig-hint { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); text-align: center; color: #b9ad9c; font-weight: 700; pointer-events: none; }
.sig-wrap .sig-line { position: absolute; left: 16px; right: 16px; bottom: 44px; border-top: 2px dashed #d9cfc0; pointer-events: none; }
.legal { font-size: 14px; color: var(--ink-2); background: #f3eee5; border-radius: 12px; padding: 12px 14px; }
.recap { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.recap > div { background: #f3eee5; border-radius: 12px; padding: 10px; text-align: center; }
.recap b { display: block; font-size: 26px; line-height: 1.1; }
.recap span { font-size: 13px; color: var(--ink-2); }
.missing-list { margin: 8px 0 0; padding-left: 20px; }
.missing-list li { margin: 2px 0; }
.radio-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.radio-row label { display: flex; align-items: center; justify-content: center; min-height: 52px; border: 2px solid #b9ad9c; border-radius: 12px; font-weight: 700; cursor: pointer; text-align: center; padding: 6px; }
.radio-row input { position: absolute; opacity: 0; pointer-events: none; }
.radio-row label:has(input:checked) { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- Visionneuse de photo ---------- */
dialog.viewer { border: 0; padding: 0; background: #000; width: 100vw; height: 100dvh; max-width: none; max-height: none; color: #fff; }
dialog.viewer::backdrop { background: #000; }
.viewer-in { display: grid; grid-template-rows: 1fr auto; height: 100%; }
.viewer-in img { width: 100%; height: 100%; object-fit: contain; min-height: 0; }
.viewer-bar { display: flex; gap: 10px; padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom)); background: #111; align-items: center; }
.viewer-bar .grow { font-size: 14px; color: #ddd; }
.viewer-bar .btn { min-height: 48px; }

/* ---------- Divers ---------- */
.done-tick { display: grid; place-items: center; }
.tick-lg { width: 84px; height: 84px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; }
.tick-lg svg { width: 48px; height: 48px; }
.center { text-align: center; }
.storage { font-variant-numeric: tabular-nums; }
.menu-list { display: grid; gap: 8px; }
.menu-list a, .menu-list button { display: flex; align-items: center; min-height: 52px; padding: 0 14px; border: 2px solid var(--line); border-radius: 12px; background: #fff; text-decoration: none; color: var(--ink); font-weight: 650; text-align: left; cursor: pointer; width: 100%; }
.menu-list a:hover, .menu-list button:hover { border-color: var(--brand); }
.cat-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.cat-row:first-of-type { border-top: 0; }
.cat-row .nm { font-weight: 650; overflow-wrap: anywhere; }
.cat-row .nm small { display: block; color: var(--muted); font-weight: 500; }

.ret > .row { flex-wrap: nowrap; flex: none; }
.ret .btn-quiet { padding: 0 10px; min-width: 44px; }
.ret .lbl { flex: 1 1 auto; min-width: 0; }
.card.stack > .btn { width: 100%; }
.summary .page-title { margin-bottom: 10px; }
input[type=search] { width: 100%; min-height: 52px; padding: 12px 14px; border: 2px solid #b9ad9c; border-radius: 12px; background: #fff; font-size: 17px; -webkit-appearance: none; appearance: none; }
input[type=search]:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px #a8681033; }

.bulk { background: #f3eee5; border-radius: 12px; padding: 10px 12px; margin: 14px 0 10px; }
.bulk-t { font-weight: 650; font-size: 14px; margin-bottom: 8px; }
.bulk-b { display: flex; flex-wrap: wrap; gap: 8px; }
.bulk-b button { min-height: 44px; padding: 0 12px; border-radius: 10px; border: 2px solid #b9ad9c; background: #fff; font-weight: 700; cursor: pointer; }
.bulk-b button:active { background: var(--brand-soft); }
