:root {
  --bg: #f3f5f8;
  --text: #172b20;
  --muted: #64748b;
  --border: #dfe7e1;
  --brand: #157c36;
  --brand-hover: #115d29;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--text);
  background: radial-gradient(ellipse at 50% 0%, #157c360c, transparent 55%);
}
button, input { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.page {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 12px calc(24px + env(safe-area-inset-bottom));
}
body.gate .page { min-height: 100dvh; display: flex; flex-direction: column; }
body.gate main { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-top: 3px solid var(--brand);
  border-radius: 16px;
  padding: 11px 12px;
  margin: 0 0 16px;
  box-shadow: 0 2px 8px #173b2307;
}
body.desk-on .topbar { position: sticky; top: 8px; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--text); text-decoration: none; }
.brand img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  object-position: center;
  flex-shrink: 0;
  border: 1px solid #e7eee8;
  border-radius: 14px;
  background: #fff;
}
.brand span { min-width: 0; }
.brand small { display: block; margin: 0; color: var(--brand); font-size: 10px; font-weight: 750; letter-spacing: 1.2px; line-height: 1.3; }
.brand small b { color: #cf5910; font-weight: 750; }
.brand strong { display: block; margin: 2px 0 0; font-size: 18px; font-weight: 700; letter-spacing: -.4px; line-height: 1.25; white-space: nowrap; }
.brand em { display: block; margin-top: 1px; color: var(--brand-hover); font-style: normal; font-size: 13px; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.logout, .install {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 700;
}
.logout { padding: 10px 14px; background: #fff; color: #9f1239; border: 1px solid #f0c4cc; }
.install { gap: 6px; padding: 10px 14px; background: var(--brand); color: #fff; border: 1px solid var(--brand); }
.install svg { width: 20px; height: 20px; }
.install-help { margin: 0 0 16px; padding: 12px 14px; border: 1px solid #f3d994; border-radius: 12px; background: #fff9e8; color: #754b12; font-size: 14px; }
@media (max-width: 700px) {
  .brand { gap: 9px; }
  .brand img { width: 42px; height: 42px; border-radius: 12px; }
  .brand strong { font-size: 17px; }
  .brand small { font-size: 9px; letter-spacing: 1px; }
  .install-label { display: none; }
  .install { width: 44px; height: 44px; padding: 0; }
}
.login {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 2px 8px #173b2307;
  padding: 22px 18px 18px;
}
.login h2, dialog h2 { margin: 0; }
.login h2 { text-align: center; font-size: 22px; font-weight: 700; }
.login .muted { text-align: center; margin: 8px 0 18px; line-height: 1.45; }
#login-form { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; color: #3d5246; font-size: 14px; font-weight: 650; }
input { width: 100%; border: 1.5px solid #d5dfd8; border-radius: 14px; padding: 14px 16px; background: #fff; color: var(--text); }
.login input { min-height: 52px; font-size: 18px; }
.login input:focus { outline: none; border-color: #ea580c; box-shadow: 0 0 0 3px rgba(234, 88, 12, .18); }
button { border: 0; border-radius: 12px; background: var(--brand); color: #fff; font-weight: 700; }
#login-submit { min-height: 56px; margin-top: 4px; font-size: 18px; border-radius: 14px; }
#login-submit:disabled { opacity: .72; }
#login-submit:active { background: var(--brand-hover); }
.muted { margin: 0; color: var(--muted); }
.warn { margin: 0; padding: 10px 12px; border-radius: 12px; background: #ffe4e6; color: #9f1239; font-weight: 650; }
#login-whatsapp a { color: var(--brand-hover); font-weight: 800; }
.scan { display: flex; gap: 8px; height: 208px; }
.view { position: relative; flex: 1; overflow: hidden; border-radius: 16px; background: #0f172a; }
video { width: 100%; height: 100%; object-fit: cover; background: #111; }
#scan-search, #scan-close {
  position: absolute;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, .94);
  color: var(--text);
}
#scan-search { top: 8px; left: 8px; width: 48px; height: 48px; }
#scan-search svg { width: 22px; height: 22px; }
#scan-search:disabled { opacity: .4; }
#scan-close { top: 8px; right: 8px; width: 44px; height: 44px; font-size: 18px; }
.groups { width: 96px; display: flex; flex-direction: column; gap: 6px; }
.groups button { flex: 1; border: 1px solid transparent; border-radius: 14px; font-size: 13px; font-weight: 800; padding: 0 4px; }
.closed { display: flex; gap: 8px; align-items: center; }
.add-row {
  flex: 1;
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 52px;
  padding: 0 4px;
  background: transparent;
  color: var(--text);
  font-size: 17px;
  text-align: left;
}
.cam, #settings-open {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex: none;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  color: var(--brand-hover);
}
.cam svg { width: 24px; height: 24px; }
#settings-open { font-size: 22px; }
.note { margin: 10px 0 0; padding: 10px 12px; border-radius: 12px; font-weight: 650; }
.note.ok { color: var(--brand-hover); background: #ecf7f0; }
.note.warn { color: #b6490d; background: #fff4e9; }
.note.bad { color: #9f1239; background: #ffe4e6; }
.note.info { color: var(--text); background: #fff; border: 1px solid var(--border); }
.filters { display: flex; gap: 6px; margin-top: 14px; }
.filters button {
  flex: 1;
  min-height: 44px;
  padding: 8px 2px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
}
.tools { display: flex; gap: 8px; align-items: stretch; margin-top: 10px; }
.switch, .ghost {
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--brand-hover);
  font-size: 14px;
}
.switch { display: flex; align-items: center; gap: 8px; padding: 0 12px; }
.switch i { position: relative; width: 36px; height: 20px; border-radius: 999px; background: #d5ddd8; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; }
.switch.on { border-color: var(--brand); }
.switch.on i { background: var(--brand); }
.switch.on i::after { left: 18px; }
#print-pdf, #email-pdf { flex: 1; padding: 0 8px; }
.group-head { display: flex; align-items: baseline; gap: 8px; margin-top: 14px; }
.group-head strong { font-size: 18px; }
.group-head span { color: var(--muted); font-weight: 700; }
.list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.card {
  display: flex;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 2px 8px #173b2307;
}
.card img, .ph { width: 72px; height: 72px; flex: none; object-fit: cover; border: 1px solid var(--border); border-radius: 12px; background: #f3f5f8; }
.card .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.card strong { display: block; font-size: 16px; line-height: 1.3; }
.meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.mark { padding: 3px 7px; border-radius: 8px; font-size: 12px; font-weight: 800; }
.date-row { display: flex; align-items: center; gap: 8px; }
.date-row b { display: inline-flex; align-items: center; min-height: 36px; padding: 6px 12px; border-radius: 10px; font-size: 15px; }
.date-row button {
  width: 44px;
  height: 44px;
  margin-left: auto;
  flex: none;
  padding: 0;
  border-radius: 12px;
  background: #fff1f2;
  color: #9f1239;
  font-size: 18px;
}
.pager { display: flex; justify-content: center; align-items: center; gap: 8px; padding: 8px 0 4px; }
.pager button { min-width: 88px; min-height: 44px; background: #fff; color: var(--brand-hover); border: 1px solid var(--border); }
.pager button:disabled { color: #94a3b8; }
dialog { width: min(720px, 100vw); max-width: none; margin: auto; padding: 0; border: 0; background: transparent; }
dialog:not([open]) { display: none !important; }
dialog::backdrop { background: rgba(15, 23, 42, .4); }
#date-dialog { margin: auto 8px 8px; }
.sheet, #search-dialog { padding: 14px; border-radius: 18px; background: #fff; }
#search-dialog {
  display: flex;
  flex-direction: column;
  width: min(680px, calc(100vw - 16px));
  height: min(640px, calc(100dvh - 16px));
}
.pending-head, .hit, .search-head, .search-row { display: flex; gap: 10px; align-items: center; }
.pending-head img { width: 64px; height: 64px; object-fit: cover; border-radius: 12px; }
#pending-group { margin: 0; font-size: 13px; font-weight: 800; }
#pending-code, .hit span { color: var(--muted); font-size: 13px; }
.big-date { margin: 10px 0; text-align: center; font-size: 24px; font-weight: 800; }
.wheels { display: flex; gap: 8px; }
.wheels > div { flex: 1; }
.wheels .year { flex: 1.25; }
.wheels span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; font-weight: 700; text-align: center; }
.wheel { height: 196px; overflow: auto; border: 1px solid var(--border); border-radius: 12px; background: #f3f5f8; }
.wheel button { width: 100%; min-height: 44px; border-radius: 0; background: transparent; color: var(--text); font-weight: 600; }
.wheel button.on { background: var(--brand); color: #fff; font-weight: 800; }
.pair { display: flex; gap: 8px; margin-top: 8px; }
.pair button { flex: 1; min-height: 52px; font-size: 16px; }
.quiet { background: #f4f6f5; color: var(--text); border: 1px solid var(--border); }
.search-head { justify-content: space-between; }
#search-close { min-height: 44px; padding: 8px 12px; background: transparent; color: var(--brand-hover); }
.search-row input { flex: 1; min-height: 52px; }
#search-go { width: 56px; height: 52px; font-size: 22px; }
.hits { display: flex; flex: 1; flex-direction: column; gap: 8px; overflow: auto; }
.hit { padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: #fff; color: var(--text); text-align: left; }
.hit img { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; }
.hit div { display: flex; flex-direction: column; gap: 2px; }
#password-form { display: flex; flex-direction: column; gap: 12px; }
#password-form input { min-height: 52px; font-size: 17px; }
