/* Fiches d'appréciation FRAM — charte FRAM (rouge #E42618, bordure rouge sur les cartes, pas de barre top) */
:root {
  --red: #E42618;
  --red-hover: #c41e12;
  --red-ink: #b3261e;
  --red-bg: #fff2f1;
  --red-border: #f5a29a;
  --green: #1b7a2b;
  --green-bg: #f0faf1;
  --green-border: #82c98c;
  --ink: #111;
  --ink-2: #444;
  --muted: #5c5c5c;
  --line: #ececec;
  --bg: #f7f7f7;
  --card: #fff;
  --radius: 10px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Segoe UI', -apple-system, system-ui, Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input, textarea { font: inherit; color: inherit; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- Écrans ---------- */
.screen { display: none; min-height: 100vh; min-height: 100dvh; flex-direction: column; max-width: 560px; margin: 0 auto; }
.screen.is-active { display: flex; }
.screen-dark { background: #121212; color: #fff; max-width: none; height: 100dvh; overflow: hidden; }

.topbar { background: #fff; border-bottom: 1px solid #eee; padding: calc(16px + var(--safe-top)) 16px 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.topbar-back { justify-content: flex-start; gap: 4px; padding-left: 6px; }
.topbar-col { flex-direction: column; align-items: flex-start; gap: 2px; padding-left: 20px; }
.logo { height: 26px; width: auto; display: block; }
.tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.1px; color: #6b6b6b; }
.tag-out { margin: 4px 2px 8px; }
.content { flex: 1; padding: 16px 16px 8px; display: flex; flex-direction: column; gap: 14px; }
.foot { padding: 14px 20px calc(14px + var(--safe-bottom)); text-align: center; font-size: 12px; color: #888; }
h1 { margin: 0; font-size: 21px; line-height: 1.2; }
h2 { margin: 0 0 8px; font-size: 19px; }
.h-small { font-size: 18px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.center-self { align-self: center; }
p { margin: 0; line-height: 1.45; }

/* ---------- Cartes ---------- */
.card { background: var(--card); border: 1px solid #eee; border-radius: var(--radius); padding: 18px; }
.card-accent { border: 1.5px solid var(--red); box-shadow: 0 2px 16px rgba(0,0,0,.05); }
.card h1 { margin-top: 4px; }
.week-row { margin-top: 14px; padding-top: 14px; border-top: 1px solid #f0f0f0; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.week-title { font-size: 15px; font-weight: 700; }
#week-deadline { margin-top: 8px; }
#week-deadline strong { color: var(--ink); }

.week-switch { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.week-chip { min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1.5px solid #ddd; background: #fff; font-size: 14px; font-weight: 600; cursor: pointer; }
.week-chip[aria-checked="true"] { border-color: var(--red); background: var(--red-bg); color: var(--red-ink); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 20px; font-size: 13px; font-weight: 700; white-space: nowrap; border: 1.5px solid; }
.pill-todo { background: var(--red-bg); color: var(--red-ink); border-color: var(--red-border); }
.pill-late { background: var(--red); color: #fff; border-color: var(--red); }
.pill-done { background: var(--green-bg); color: var(--green); border-color: var(--green-border); }
.pill-none { background: #f1f4f8; color: #3d4b5c; border-color: #c9d3df; }

/* ---------- Boutons ---------- */
.btn { min-height: 50px; padding: 0 18px; border-radius: 7px; border: none; font-size: 15px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; text-decoration: none; transition: background .15s; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-hover); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: #fff; color: var(--ink-2); border: 1.5px solid #e0e0e0; font-weight: 600; }
.btn-light { background: #fff; color: #111; }
.btn-danger { background: #fff; color: #b3261e; border: 1.5px solid var(--red-border); }
.btn-grow { flex: 1.6; }
.link-btn { align-self: center; background: none; border: none; color: var(--red); font-size: 14px; padding: 10px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: none; background: transparent; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: inherit; }
.icon-btn-dark { background: rgba(255,255,255,.14); }

.btn-big { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 66px; border-radius: var(--radius); padding: 14px 18px; text-align: left; cursor: pointer; }
.btn-big svg { width: 30px; height: 30px; }
.btn-big > span { display: flex; flex-direction: column; }
.btn-big-title { font-size: 17px; font-weight: 700; }
.btn-big-sub { font-size: 13px; }
.btn-big-primary { background: var(--red); color: #fff; border: none; }
.btn-big-primary .btn-big-sub { opacity: .92; }
.btn-big-secondary { background: #fff; border: 1.5px solid #e0e0e0; color: var(--ink); }
.btn-big-secondary svg { color: var(--red); }
.btn-big-secondary .btn-big-sub { color: var(--muted); }

.actions-bar { position: sticky; bottom: 0; background: #fff; border-top: 1px solid #eee; padding: 12px 16px calc(14px + var(--safe-bottom)); display: flex; gap: 10px; }
.actions-bar .btn { flex: 1; }
.actions-inline { display: flex; gap: 10px; }
.actions-inline .btn { flex: 1; }
.stack-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.actions-inline.stack-bottom { flex-direction: row; }

/* ---------- Listes ---------- */
.list { list-style: none; margin: 0; padding: 0; background: #fff; border: 1px solid #eee; border-radius: var(--radius); }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid #f2f2f2; font-size: 14px; }
.list li:last-child { border-bottom: none; }
.list .l-title { font-weight: 600; }
.st-done { color: var(--green); font-weight: 600; font-size: 13px; }
.st-todo { color: var(--red-ink); font-weight: 600; font-size: 13px; }
.st-none { color: var(--muted); font-weight: 600; font-size: 13px; }
.list-empty { color: var(--muted); font-size: 13px; justify-content: center !important; }

.alert { padding: 12px 14px; background: #fafafa; border: 1px solid var(--red); border-radius: 4px; font-size: 14px; color: #333; line-height: 1.45; }
.alert a, .alert button.inline-link { color: var(--red); background: none; border: none; padding: 0; font-weight: 700; text-decoration: underline; cursor: pointer; }
.banner-offline { background: #fff7e0; border: 1px solid #f0c75e; color: #6b4e00; border-radius: 6px; padding: 10px 12px; font-size: 13px; }
.draft-banner { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: #fff; border: 1.5px dashed var(--red); border-radius: var(--radius); padding: 14px 16px; color: var(--ink); text-decoration: none; font-size: 14px; }
.draft-banner span { color: var(--red); font-weight: 700; }

/* ---------- Capture ---------- */
.cam-top { padding: calc(14px + var(--safe-top)) 14px 10px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cam-title { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.cam-pill { background: #fff; color: #111; border-radius: 20px; padding: 7px 16px; font-size: 16px; font-weight: 700; }
.cam-pill b { color: var(--red); }
.cam-dots { display: flex; align-items: center; gap: 5px; font-size: 12px; color: #ccc; }
.dot { width: 8px; height: 8px; border-radius: 4px; background: #555; display: inline-block; margin-left: 4px; }
.dot.on { background: var(--red); box-shadow: 0 0 0 2px rgba(228,38,24,.35); }
.cam-count { min-width: 44px; text-align: right; display: flex; flex-direction: column; line-height: 1.1; }
.cam-count b { font-size: 18px; }
.cam-count span { font-size: 11px; color: #ccc; }

.viewfinder { position: relative; flex: 1; overflow: hidden; background: #000; }
.viewfinder video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.guide { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); pointer-events: none; box-shadow: 0 0 0 9999px rgba(0,0,0,.35); border-radius: 4px; }
.guide i { position: absolute; width: 34px; height: 34px; border: 4px solid var(--red); }
.guide i:nth-child(1) { left: -2px; top: -2px; border-right: none; border-bottom: none; border-top-left-radius: 6px; }
.guide i:nth-child(2) { right: -2px; top: -2px; border-left: none; border-bottom: none; border-top-right-radius: 6px; }
.guide i:nth-child(3) { left: -2px; bottom: -2px; border-right: none; border-top: none; border-bottom-left-radius: 6px; }
.guide i:nth-child(4) { right: -2px; bottom: -2px; border-left: none; border-top: none; border-bottom-right-radius: 6px; }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .25s; }
.flash.go { opacity: .7; transition: none; }
.cam-hint { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); background: rgba(0,0,0,.65); border-radius: 20px; padding: 8px 14px; font-size: 13px; white-space: nowrap; max-width: 92%; overflow: hidden; text-overflow: ellipsis; }
.cam-fallback { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; background: #1b1b1b; }
.cam-fallback .btn { width: 100%; max-width: 300px; }

.cam-bottom { padding: 16px 22px calc(24px + var(--safe-bottom)); display: flex; align-items: center; justify-content: space-between; }
.thumb-last { position: relative; width: 52px; height: 68px; border-radius: 4px; border: 2px solid #fff; background: #333; padding: 0; overflow: visible; cursor: pointer; }
.thumb-last img { width: 100%; height: 100%; object-fit: cover; border-radius: 2px; display: block; }
.thumb-last img:not([src]) { visibility: hidden; }
.thumb-badge { position: absolute; right: -10px; top: -10px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; border-radius: 10px; padding: 2px 6px; }
.shutter { width: 80px; height: 80px; border-radius: 40px; border: 4px solid #fff; background: transparent; padding: 0; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.shutter span { width: 62px; height: 62px; border-radius: 31px; background: var(--red); display: block; transition: transform .1s; }
.shutter:active span, .shutter.busy span { transform: scale(.88); }
.shutter:disabled { opacity: .5; }
.btn-pill { background: #fff; color: #111; font-size: 15px; font-weight: 700; border-radius: 22px; padding: 0 16px; height: 44px; border: none; cursor: pointer; }

/* ---------- Vérification ---------- */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stats > div { background: #fff; border: 1px solid #eee; border-radius: 8px; padding: 10px; text-align: center; display: flex; flex-direction: column; }
.stats b { font-size: 20px; }
.stats span { font-size: 12px; color: var(--muted); }
.fiche-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.fiche { background: #fff; border: 1px solid #eee; border-radius: 8px; padding: 10px; }
.fiche-title { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.fiche-pages { display: flex; gap: 8px; }
.page-btn { flex: 1; height: 96px; border: 1px solid #ddd; border-radius: 3px; padding: 0; background: #f4f2ee; position: relative; overflow: hidden; cursor: pointer; }
.page-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.page-btn .face { position: absolute; left: 4px; bottom: 4px; font-size: 11px; font-weight: 800; color: #fff; background: rgba(0,0,0,.55); border-radius: 3px; padding: 1px 4px; }
.page-missing { flex: 1; height: 96px; border: 1.5px dashed var(--red); border-radius: 3px; display: flex; align-items: center; justify-content: center; color: var(--red); font-size: 24px; background: #fff; cursor: pointer; }

/* ---------- Envoi ---------- */
.progress-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; gap: 10px; }
.big-pct { font-size: 26px; font-weight: 700; color: var(--red); white-space: nowrap; }
.bar { height: 10px; border-radius: 5px; background: #f1f1f1; overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--red); border-radius: 5px; transition: width .2s; }
#up-detail { margin-top: 8px; }
.lot-state { display: inline-flex; align-items: center; gap: 6px; }
.lot-bar { width: 90px; height: 6px; border-radius: 3px; background: #f1f1f1; overflow: hidden; }
.lot-bar > div { height: 100%; background: var(--red); width: 0; }

/* ---------- Confirmation ---------- */
.round-icon { width: 70px; height: 70px; border-radius: 35px; display: flex; align-items: center; justify-content: center; margin: 4px auto 14px; border: 2px solid; }
.round-icon svg { width: 34px; height: 34px; stroke-width: 2.3; }
.round-icon-green { background: var(--green-bg); border-color: var(--green-border); color: var(--green); }
.round-icon-red { background: var(--red-bg); border-color: var(--red-border); color: #c62828; }
.info-grid { background: #fafafa; border-radius: 8px; padding: 16px 18px; margin: 18px 0 0; text-align: left; display: grid; grid-template-columns: auto 1fr; gap: 10px 14px; }
.info-grid dt { font-size: 12px; color: #666; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; align-self: baseline; }
.info-grid dd { margin: 0; font-size: 14px; font-weight: 500; }
.badge-go { display: inline-flex; padding: 6px 16px; border-radius: 20px; background: var(--green-bg); color: var(--green); border: 1.5px solid var(--green-border); font-weight: 700; font-size: 14px; }

/* ---------- PDF ---------- */
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 8px; border: 1.5px dashed #c9c9c9; border-radius: var(--radius); background: #fff; padding: 22px 16px; text-align: center; cursor: pointer; position: relative; }
.dropzone svg { width: 34px; height: 34px; color: var(--red); }
.dz-title { font-weight: 700; }
.file-row { display: flex; align-items: center; gap: 12px; }
.file-ico { width: 42px; height: 52px; border-radius: 4px; background: var(--red-bg); border: 1px solid var(--red-border); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; color: var(--red-ink); flex-shrink: 0; }
.file-meta { flex: 1; min-width: 0; }
.file-name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.checks { list-style: none; padding: 12px 0 0; margin: 12px 0 0; border-top: 1px solid #f0f0f0; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.checks li { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.checks .ok { color: var(--green); }
.checks .ko { color: var(--red-ink); }
.checks svg { width: 16px; height: 16px; stroke-width: 2.4; }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.field > span { font-size: 13px; font-weight: 600; color: #333; }
.field input, .field textarea { border: 1.5px solid #e0e0e0; border-radius: 7px; padding: 10px 12px; font-size: 16px; background: #fff; }
.field input { height: 46px; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--red); outline-offset: 1px; }

/* ---------- Rien à déposer ---------- */
.radios { border: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.radios legend { margin-bottom: 8px; padding: 0; }
.radio { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 14px; background: #fff; border: 1.5px solid #e6e6e6; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer; }
.radio:has(input:checked) { border-color: var(--red); }
.radio input { width: 20px; height: 20px; accent-color: var(--red); margin: 0; }

/* ---------- Feuille d'actions, toast, chargement ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.sheet { background: #fff; width: 100%; max-width: 560px; border-radius: 14px 14px 0 0; padding: 16px 16px calc(18px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 10px; }
.sheet img { max-height: 42vh; object-fit: contain; border-radius: 4px; background: #f4f2ee; }
.sheet-title { text-align: center; font-weight: 700; }
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%); background: #222; color: #fff; padding: 12px 16px; border-radius: 8px; font-size: 14px; z-index: 60; max-width: 90%; }
.center-box { margin: auto; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; color: var(--muted); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #f3c3bf; border-top-color: var(--red); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
