:root {
  --blue: #1f4e79; --blue2: #2e75b6; --bg: #f4f6f9; --card: #fff; --text: #17202a; --muted: #6b7785;
  --ok: #1e8e3e; --danger: #c62828; --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; overscroll-behavior: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .center { text-align: center; } .small-text { font-size: 13px; line-height: 1.4; }

.screen { display: none; position: fixed; inset: 0; flex-direction: column; overflow: hidden; }
.screen.active { display: flex; }
.screen.dark { background: #000; color: #fff; }

.bar { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(10px + var(--safe-t)) 12px 10px; background: var(--blue); color: #fff; }
.bar.dark { background: rgba(0,0,0,.85); }
.bar h1 { font-size: 18px; margin: 0; font-weight: 600; }
.bar span { width: 40px; }

button, .big, .small { font: inherit; border: 0; cursor: pointer; }
.icon { background: transparent; font-size: 22px; width: 40px; height: 40px; border-radius: 50%; color: inherit; }
.big { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 60px; border-radius: var(--radius);
  font-size: 18px; font-weight: 600; margin: 8px 0; padding: 0 16px; }
.small { padding: 10px 16px; border-radius: 10px; font-size: 15px; font-weight: 600; }
.primary { background: var(--blue2); color: #fff; }
.primary:active { background: var(--blue); }
.secondary { background: #dfe9f5; color: var(--blue); }
.ghost { background: transparent; color: var(--blue); border: 1.5px solid #b9cbe0; }
.ghost.light, .light { color: #fff; border-color: rgba(255,255,255,.5); }
button:disabled { opacity: .5; }

.home-main, .review-main, .setup-main { flex: 1; overflow-y: auto; padding: 16px 16px calc(24px + var(--safe-b)); }
.card { background: var(--card); border-radius: var(--radius); padding: 12px 14px; margin: 12px 0;
  box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.card h2 { font-size: 15px; margin: 0 0 8px; }
.history { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.history li { padding: 6px 0; border-bottom: 1px solid #eef1f4; display: flex; justify-content: space-between; gap: 8px; }
.history li:last-child { border: 0; }
.history .ok { color: var(--ok); } .history .wait { color: #b26a00; }

.field { display: block; margin: 12px 0; font-size: 14px; color: var(--muted); }
.field input, .field select { display: block; width: 100%; margin-top: 6px; padding: 12px; font-size: 16px;
  border: 1px solid #cfd8e3; border-radius: 10px; background: #fff; color: var(--text); }
.check { display: flex; gap: 8px; align-items: center; margin: 12px 0; font-size: 15px; }

/* câmara */
.cam-wrap { position: relative; flex: 1; overflow: hidden; background: #000; }
#video, #overlay { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.cam-hint { position: absolute; left: 50%; top: calc(14px + var(--safe-t)); transform: translateX(-50%);
  background: rgba(0,0,0,.6); padding: 8px 14px; border-radius: 20px; font-size: 14px; white-space: nowrap; }
.cam-bar, .crop-bar { display: flex; align-items: center; justify-content: space-around; gap: 10px;
  padding: 14px 12px calc(14px + var(--safe-b)); background: #000; }
.shutter { width: 74px; height: 74px; border-radius: 50%; background: #fff; border: 5px solid #9ab; }
.shutter:active { transform: scale(.94); }
.toggle { display: flex; align-items: center; gap: 6px; font-size: 14px; width: 70px; }

/* recorte */
.crop-wrap { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden;
  touch-action: none; }
#cropCanvas { max-width: 100%; max-height: 100%; touch-action: none; }

/* revisão */
.pages { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.page { position: relative; flex: 0 0 auto; }
.page img { height: 46vh; max-width: 86vw; object-fit: contain; border-radius: 8px; background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.page button { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.6); color: #fff;
  width: 32px; height: 32px; border-radius: 50%; }
.page .num { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.6); color: #fff;
  font-size: 12px; padding: 2px 8px; border-radius: 10px; }
.filters { display: flex; gap: 8px; margin: 12px 0; }
.filters label { flex: 1; text-align: center; background: #fff; border: 1.5px solid #cfd8e3; border-radius: 10px;
  padding: 10px 4px; font-size: 14px; }
.filters label:has(input:checked) { border-color: var(--blue2); background: #e8f1fb; color: var(--blue); font-weight: 600; }
.filters input { display: none; }

.toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%) translateY(150%);
  background: #222; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 15px; max-width: 90vw;
  transition: transform .25s; z-index: 50; }
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }
.busy { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; flex-direction: column;
  align-items: center; justify-content: center; color: #fff; z-index: 40; }
.spinner { width: 46px; height: 46px; border: 5px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%;
  animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
