/* ======================================================================
   Liberto Mobile — design system (navy + dourado)
   Mobile-first, premium, ergonômico. Sem dependências externas.
   ====================================================================== */
:root {
  color-scheme: dark; /* selects/date/scrollbars nativos seguem o tema escuro */
  --navy-900: #06080F;
  --navy-850: #070b16;
  --navy-800: #08111f;
  --navy-700: #0c1b33;
  --navy-600: #102444;
  --line: rgba(215, 165, 50, 0.16);
  --line-soft: rgba(255, 255, 255, 0.08);
  --gold-500: #D7A532;
  --gold-400: #F4C95D;
  --gold-300: #ffe39a;
  --text: #F8FAFC;
  --muted: #94A3B8;
  --muted-2: #64748b;
  --ok: #22C55E;
  --warn: #F59E0B;
  --err: #EF4444;
  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 22px;
  --maxw: 480px; /* cresce nos breakpoints (768/1080) — médicos também usam no desktop */
  --pad: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.35);
  --glass: rgba(9, 15, 28, 0.82); /* superfícies flutuantes (nav/appbar) com blur */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1100px 520px at 50% -10%, rgba(215, 165, 50, 0.16), transparent 60%),
    radial-gradient(800px 600px at 90% 10%, rgba(16, 36, 68, 0.6), transparent 55%),
    var(--navy-900);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}
button, input, select, textarea { font-family: inherit; font-size: 16px; color: inherit; }
/* Mãozinha em tudo que é botão (desktop): muitos botões-ícone herdavam a seta padrão. */
button:not([disabled]) { cursor: pointer; }
a { color: var(--gold-400); text-decoration: none; cursor: pointer; }

/* Foco visível por teclado em TODOS os elementos interativos (acessibilidade) — :focus-visible não
   "gruda" após toque no mobile. Cobre botões, iconbtns, navitem, links, chips, linhas de campo. */
:focus-visible { outline: 2px solid var(--gold-400); outline-offset: 2px; }
.linkbtn--danger:focus-visible, .titem-del:focus-visible, .btn-danger:focus-visible { outline-color: #fca5a5; }

/* Ergonomia de toque: mata o atraso/zoom do toque duplo em TODOS os controles (iOS/Android) e evita
   seleção acidental de texto ao segurar botões/nav (Android). Linhas de DADOS (frow/titem) ficam
   selecionáveis de propósito — copiar o nome do paciente é útil. */
a, button, input, select, textarea, .chip, .navitem, .opt, .frow, .titem, .stat { touch-action: manipulation; }
.btn, .chip, .navitem, .iconbtn, .linkbtn, .tab, .imgbtn { user-select: none; -webkit-user-select: none; }
::selection { background: rgba(215, 165, 50, 0.25); } /* 0.25: texto muted selecionado segue AA */

/* Scroll: modal/lightbox não "vazam" a rolagem p/ a tela de trás; barras finas SÓ nos scrollers
   internos (a barra principal da página fica no tamanho nativo — alvo de arraste no desktop).
   (No body NÃO desativar overscroll: puxar-para-atualizar é o único gesto de recarga no PWA.) */
.modal-card, .lightbox { overscroll-behavior: contain; }
.modal-card, textarea.input { scrollbar-width: thin; scrollbar-color: rgba(215,165,50,0.35) transparent; }
.modal-card::-webkit-scrollbar, textarea.input::-webkit-scrollbar { width: 8px; height: 8px; }
.modal-card::-webkit-scrollbar-thumb, textarea.input::-webkit-scrollbar-thumb { background: rgba(215,165,50,0.28); border-radius: 999px; }
.modal-card::-webkit-scrollbar-track, textarea.input::-webkit-scrollbar-track { background: transparent; }

/* Estados de HOVER para desktop (gated por ponteiro — não afeta toque/mobile). */
@media (hover: hover) {
  .btn-primary:hover { filter: brightness(1.12); }
  .btn-ghost:hover, .btn-danger:hover, .btn-sm:hover { background: rgba(255,255,255,0.09); }
  .chip:hover { border-color: var(--line); }
  .opt:hover { background: rgba(255,255,255,0.06); }
  .frow:hover { border-color: var(--gold-400); box-shadow: 0 0 0 1px rgba(215,165,50,0.25); }
  .linkbtn:hover { color: var(--text); }
  .titem:hover { border-color: var(--line); }
  .titem-del:hover { background: rgba(239,68,68,0.22); border-color: rgba(239,68,68,0.55); }
  .navitem:hover { color: var(--gold-300); }
  .appbar .iconbtn:hover, .iconbtn:hover { background: rgba(255,255,255,0.10); }
  .capture-btn:hover { filter: brightness(1.06); }
  .editlink:hover { color: var(--gold-300); }
}

/* Telas bem estreitas (≤360px): garante folga p/ a marca + chip de plantão + botão de sair no topo. */
@media (max-width: 360px) {
  .shiftchip { max-width: min(34vw, 200px); }
  .stat .n { font-size: 24px; }
}

/* ---------- App shell ---------- */
.app { max-width: var(--maxw); margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; position: relative; }
.screen { padding: calc(var(--safe-t) + 14px) var(--pad) calc(var(--safe-b) + 106px); flex: 1; animation: fade 0.25s ease both; } /* folga p/ a nav flutuante */
.screen--plain { padding-bottom: calc(var(--safe-b) + 24px); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.boot { height: 100vh; height: 100dvh; display: grid; place-items: center; } /* vh = fallback iOS <15.4 */
.boot-logo { width: 84px; height: 84px; border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, var(--gold-300), var(--gold-500) 60%, #8a6a18);
  box-shadow: 0 0 0 6px rgba(215,165,50,0.12), var(--shadow); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(0.94); opacity: 0.7; } 50% { transform: scale(1.04); opacity: 1; } }

/* ---------- Appbar ---------- */
/* Vidro fosco: o conteúdo passa POR BAIXO com blur (moderno) em vez do gradiente que sumia no scroll. */
.appbar { display: flex; align-items: center; gap: 12px; padding: calc(var(--safe-t) + 12px) var(--pad) 10px;
  position: sticky; top: 0; z-index: 20;
  background: rgba(6, 8, 15, 0.72);
  -webkit-backdrop-filter: blur(14px) saturate(1.25); backdrop-filter: blur(14px) saturate(1.25); }
.appbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: 0.5px; }
.appbar .brand img { width: 32px; height: 32px; border-radius: 50%; }
.appbar .spacer { flex: 1; }
.appbar .iconbtn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 13px;
  background: rgba(255,255,255,0.05); border: 1px solid var(--line-soft); }

/* ---------- Typography ---------- */
h1, h2, h3 { margin: 0 0 8px; letter-spacing: -0.02em; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 20px; font-weight: 700; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.14em; font-size: 12px; color: var(--gold-400); font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

/* ---------- Cards ---------- */
.card { background: linear-gradient(180deg, rgba(16,36,68,0.55), rgba(8,17,31,0.65));
  border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.045); /* fio de luz no topo = profundidade */
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.card + .card { margin-top: 14px; }
.card--gold { border-color: var(--line); box-shadow: 0 10px 40px rgba(0,0,0,0.45), inset 0 0 0 1px rgba(215,165,50,0.06); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; width: 100%; padding: 0 18px; border-radius: 16px; border: 1px solid transparent;
  font-weight: 700; font-size: 16px; cursor: pointer; transition: transform 0.08s ease, filter 0.15s ease, background 0.15s; }
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.btn-primary { background: linear-gradient(180deg, var(--gold-400), var(--gold-500)); color: #2a1d02;
  box-shadow: 0 8px 24px rgba(215,165,50,0.28), inset 0 1px 0 rgba(255,255,255,0.38); }
.btn-primary:active { filter: brightness(1.05); }
.btn-ghost { background: rgba(255,255,255,0.04); border-color: var(--line-soft); color: var(--text); }
.btn-danger { background: rgba(239,68,68,0.14); border-color: rgba(239,68,68,0.4); color: #fecaca; }
.btn-sm { min-height: 42px; width: auto; font-size: 14px; padding: 0 14px; border-radius: 12px; gap: 7px; }
.btn-sm svg { width: 18px; height: 18px; } /* ícone proporcional ao botão pequeno (folga p/ o rótulo) */
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { width: auto; flex: 1; }
.stack > * + * { margin-top: 12px; }

/* ---------- Big capture button ---------- */
.capture-hero { display: grid; place-items: center; gap: 14px; margin: 8px 0 4px; }
.capture-btn { width: 198px; height: 198px; border-radius: 50%; border: none; cursor: pointer; position: relative; isolation: isolate;
  text-align: center; line-height: 1.12; padding: 0 22px;
  background: radial-gradient(circle at 50% 28%, #ffe7a6 0%, #F4C95D 42%, #D7A532 68%, #a8791c 100%);
  color: #2a1d02; font-weight: 800; font-size: 17px; display: grid; place-items: center; gap: 8px;
  box-shadow: 0 18px 50px rgba(215,165,50,0.42), inset 0 2px 9px rgba(255,255,255,0.60), inset 0 -12px 24px rgba(120,80,10,0.35);
  transition: transform 0.12s ease, box-shadow 0.2s ease; }
.capture-btn:active { transform: scale(0.95); box-shadow: 0 8px 22px rgba(215,165,50,0.50), inset 0 2px 9px rgba(255,255,255,0.55); }
.capture-btn svg { width: 52px; height: 52px; filter: drop-shadow(0 1px 1px rgba(255,255,255,0.45)); }
.capture-btn span { display: block; }

/* ---------- Fields ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.input { width: 100%; min-height: 52px; padding: 0 14px; border-radius: 14px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--line-soft); color: var(--text); outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease; }
.input:focus { border-color: var(--gold-500); box-shadow: 0 0 0 3px rgba(215,165,50,0.18); background: rgba(255,255,255,0.06); }
.input.error { border-color: var(--err); background: rgba(239,68,68,0.08); }
.input.error:focus { border-color: var(--err); box-shadow: 0 0 0 3px rgba(239,68,68,0.18); }
textarea.input { padding: 12px 14px; min-height: 96px; resize: vertical; line-height: 1.4; }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { padding: 12px 16px; border-radius: 999px; background: rgba(255,255,255,0.05);
  border: 1px solid var(--line-soft); font-weight: 600; cursor: pointer; min-height: 46px; display: inline-flex; align-items: center; }
.chip:active { transform: scale(0.97); }
.chip--gold { background: linear-gradient(180deg, var(--gold-400), var(--gold-500)); color: #2a1d02; border-color: transparent; }

/* ---------- Stats ---------- */
.stats { display: flex; gap: 12px; }
.stat { flex: 1; text-align: center; padding: 14px 8px; border-radius: var(--radius-sm); background: rgba(255,255,255,0.03); border: 1px solid var(--line-soft);
  transition: transform 0.08s ease, border-color 0.15s ease, background 0.15s ease; } /* são botões-filtro no Hoje */
.stat:active { transform: scale(0.97); }
.stat .n { font-size: 28px; font-weight: 800; color: var(--gold-400); }
.stat .l { font-size: 12px; color: var(--muted); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge--ok { background: rgba(34,197,94,0.15); color: #86efac; }
.badge--warn { background: rgba(245,158,11,0.15); color: #fcd34d; }
.badge--err { background: rgba(239,68,68,0.15); color: #fca5a5; }
.badge--muted { background: rgba(148,163,184,0.15); color: var(--muted); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- Key/value (confirmação) ---------- */
.kv { display: flex; flex-direction: column; gap: 2px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.kv:last-child { border-bottom: none; }
.kv .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.kv .v { font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.kv .v.low { color: var(--gold-300); }
.editlink { font-size: 13px; color: var(--gold-400); font-weight: 600; cursor: pointer; }

/* ---------- Lists (Hoje) ---------- */
.tlist { display: flex; flex-direction: column; gap: 12px; }
.titem { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.03); border: 1px solid var(--line-soft); }
.titem .time { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 700; font-size: 14px; min-width: 46px; }
.titem .main { flex: 1; min-width: 0; }
.titem { cursor: pointer; }
.titem .main { min-width: 0; }
.titem .main .pt { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: 8px; }
.titem .main .meta { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.titem .main .row .badge { flex: none; }
.titem .main .small { overflow-wrap: anywhere; }
.titem-del { flex: none; align-self: flex-start; width: 44px; height: 44px; /* alvo de toque mínimo (HIG) */
  color: #fca5a5; background: rgba(239,68,68,0.10); border-color: rgba(239,68,68,0.30); }
.titem-del:active { transform: scale(0.94); }

/* ---------- Stepper (processando) ---------- */
.stepper { display: flex; flex-direction: column; gap: 14px; }
.step { display: flex; align-items: center; gap: 12px; color: var(--muted); transition: color 0.3s; }
.step .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-soft); display: grid; place-items: center; flex: none; }
.step.active { color: var(--text); }
.step.active .dot { border-color: var(--gold-500); box-shadow: 0 0 0 4px rgba(215,165,50,0.15); animation: pulse 1.1s ease-in-out infinite; }
.step.done .dot { background: var(--gold-500); border-color: var(--gold-500); }
.step.done .dot::after { content: "✓"; color: #2a1d02; font-size: 13px; font-weight: 900; }

/* ---------- Toast ---------- */
/* Offset do toast depende da TELA: com a nav flutuante ele sobe (limpa a pílula E o pico do CTA);
   sem nav (Conferir/Login) ele desce — senão cobria o botão "Registrar produção" bem na hora do
   2º toque da confirmação de duplicata. body.has-nav é alternado pelo roteador. */
.toast-host { position: fixed; left: 0; right: 0; bottom: calc(var(--safe-b) + 16px); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 60; pointer-events: none; }
body.has-nav .toast-host { bottom: calc(var(--safe-b) + 118px); }
.toast { pointer-events: auto; max-width: min(calc(var(--maxw) - 28px), 560px); width: calc(100% - 28px); background: var(--navy-700);
  border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 10px; animation: toastin 0.25s ease both; }
.toast--ok { border-color: rgba(34,197,94,0.5); }
.toast--err { border-color: rgba(239,68,68,0.5); }
.toast .t-actions { margin-left: auto; }
.toast .t-btn { background: rgba(255,255,255,0.08); border: 1px solid var(--line-soft); border-radius: 10px; padding: 8px 12px; font-weight: 700; font-size: 13px; cursor: pointer; }
@keyframes toastin { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Net banner ---------- */
.net-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 70; text-align: center; font-size: 13px; font-weight: 600;
  padding: calc(var(--safe-t) + 8px) 12px 8px; background: var(--warn); color: #2a1d02; }
/* Quando offline (body.offline, alternado no app.js): reserva a altura da faixa para que ela NÃO
   cubra a appbar/o botão Voltar — justamente quando o médico mais precisa navegar (wifi de plantão). */
body.offline #app { padding-top: calc(var(--safe-t) + 38px); }
body.offline .appbar { top: calc(var(--safe-t) + 38px); }

/* ---------- Bottom nav (pílula flutuante de vidro) ---------- */
.bottomnav { position: fixed; bottom: calc(var(--safe-b) + 12px); left: 50%; transform: translateX(-50%);
  width: calc(100% - 28px); max-width: min(calc(var(--maxw) - 28px), 520px); z-index: 30; /* pílula não estica no desktop */
  display: flex; justify-content: space-around; padding: 8px 10px;
  border-radius: 26px; border: 1px solid var(--line-soft);
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px) saturate(1.3); backdrop-filter: blur(16px) saturate(1.3);
  box-shadow: 0 16px 44px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.05); }
/* Teclado aberto (Android, viewport encolhida): a pílula some — senão flutuava sobre os chips de
   sugestão e o toque acertava "Início/Capturar" no meio da digitação. body.kb-open vem do app.js.
   Só em TOQUE: no desktop o teclado físico não cobre nada e sumir a nav ao focar a busca seria ruído. */
@media (pointer: coarse) {
  body.kb-open .bottomnav { display: none; }
}
.navitem { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 6px; color: var(--muted); font-size: 11px; font-weight: 600;
  background: none; border: 0; font-family: inherit; cursor: pointer; border-radius: 16px;
  transition: color 0.15s ease, background 0.15s ease; } /* é <button>: reseta a aparência nativa */
.navitem.active { color: var(--gold-400); background: rgba(215,165,50,0.12); }
.navitem svg { width: 24px; height: 24px; }
.navitem--cta { color: #2a1d02; }
.navitem--cta .ico { width: 50px; height: 50px; margin-top: -26px; border-radius: 50%;
  background: linear-gradient(180deg, var(--gold-400), var(--gold-500)); display: grid; place-items: center; box-shadow: 0 8px 24px rgba(215,165,50,0.35); }
.navitem--cta .ico svg { width: 26px; height: 26px; }

/* ---------- Image preview ---------- */
.preview { position: relative; width: 100%; border-radius: var(--radius); border: 1px solid var(--line-soft); overflow: hidden; background: #000; }
.imgbtn { position: absolute; top: 8px; right: 8px; z-index: 2; width: 44px; height: 44px; border-radius: 10px;
  background: rgba(6,8,15,0.62); border: 1px solid var(--line-soft); color: var(--gold-400); display: grid; place-items: center;
  cursor: pointer; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.imgbtn svg { width: 20px; height: 20px; }
/* Documento na revisão: tamanho médio/grande (âncora de confiança), com overlay. */
.docview { position: relative; width: 100%; height: clamp(240px, 38vh, 420px); height: clamp(240px, 38dvh, 420px); border-radius: var(--radius);
  overflow: hidden; background: #05070d; cursor: zoom-in; }
.docview img { width: 100%; height: 100%; object-fit: contain; display: block; }
.docview-bar { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 12px 8px; font-size: 12px;
  color: var(--gold-300); text-align: center; pointer-events: none;
  background: linear-gradient(rgba(6,8,15,0), rgba(6,8,15,0.85)); }
.preview img { width: 100%; display: block; max-height: 56vh; object-fit: contain; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.thumbs .thumb { width: 60px; height: 60px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line-soft); position: relative; }
.thumbs .thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Skeleton ---------- */
.skeleton { border-radius: 10px; background: linear-gradient(90deg, rgba(255,255,255,0.04), rgba(255,255,255,0.10), rgba(255,255,255,0.04)); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Misc ---------- */
.hr { height: 1px; background: var(--line-soft); margin: 16px 0; border: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; }
.hidden { display: none !important; }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(0,0,0,0.25); border-top-color: #2a1d02; animation: rot 0.7s linear infinite; }
.btn-ghost .spin, .step .spin { border: 2px solid rgba(255,255,255,0.25); border-top-color: var(--gold-400); }
@keyframes rot { to { transform: rotate(360deg); } }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.empty .big svg { width: 42px; height: 42px; color: var(--gold-400); }

/* ---------- Lightbox (olho humano: documento em tela cheia) ---------- */
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,0.93);
  display: flex; align-items: center; justify-content: center;
  padding: calc(env(safe-area-inset-top) + 10px) 10px calc(env(safe-area-inset-bottom) + 10px); animation: fade 0.2s ease both; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.lightbox-close { position: absolute; top: calc(env(safe-area-inset-top) + 10px); right: 14px; z-index: 3;
  width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,0.14);
  border: 1px solid var(--line-soft); color: #fff; display: grid; place-items: center; cursor: pointer; }
/* Visualizador com zoom (pinça / toque duplo / arrastar) */
.zstage { position: absolute; inset: 0; overflow: hidden; touch-action: none; display: flex; align-items: center; justify-content: center; }
.zimg { max-width: 100%; max-height: 100%; object-fit: contain; transform-origin: center center; will-change: transform;
  -webkit-user-drag: none; user-select: none; cursor: zoom-in; border-radius: 6px; }
.lightbox-hint { position: absolute; bottom: calc(env(safe-area-inset-bottom) + 14px); left: 0; right: 0; text-align: center;
  color: var(--muted); font-size: 12px; pointer-events: none; }

/* ====================================================================
   High-tech / Scanner
   ==================================================================== */
/* Moldura do scanner com o documento dentro */
.scanner { position: relative; width: 100%; border-radius: var(--radius); overflow: hidden;
  background: #05070d; border: 1px solid var(--line);
  box-shadow: 0 0 44px rgba(215,165,50,0.12), inset 0 0 70px rgba(0,0,0,0.65); }
.scanner img { width: 100%; display: block; max-height: 50vh; object-fit: contain; opacity: 0.96; }
.scanner .ph { height: 42vh; display: grid; place-items: center; color: var(--muted); } /* contraste AA sobre navy */

/* Grade tecnológica sutil sobre a imagem */
.scan-grid { position: absolute; inset: 0; pointer-events: none; opacity: 0.45; mix-blend-mode: screen;
  background-image:
    linear-gradient(rgba(215,165,50,0.10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(215,165,50,0.10) 1px, transparent 1px);
  background-size: 26px 26px; }

/* Feixe do scanner varrendo de cima para baixo */
.scan-beam { position: absolute; left: 0; right: 0; top: -16%; height: 16%; pointer-events: none;
  background: linear-gradient(180deg, rgba(244,201,93,0) 0%, rgba(244,201,93,0.10) 45%, rgba(244,201,93,0.55) 90%, rgba(255,255,255,0.9) 100%);
  box-shadow: 0 0 26px 6px rgba(244,201,93,0.45); animation: scanmove 2.1s cubic-bezier(.45,0,.2,1) infinite; }
.scan-beam::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: var(--gold-300); box-shadow: 0 0 14px 2px var(--gold-300); }
@keyframes scanmove { 0% { top: -16%; } 100% { top: 100%; } }

/* Cantoneiras (reticle) */
.reticle { position: absolute; inset: 0; pointer-events: none; }
.reticle i { position: absolute; width: 26px; height: 26px; border: 2px solid var(--gold-400); opacity: 0.9; }
.reticle i:nth-child(1) { top: 10px; left: 10px; border-right: 0; border-bottom: 0; border-top-left-radius: 7px; }
.reticle i:nth-child(2) { top: 10px; right: 10px; border-left: 0; border-bottom: 0; border-top-right-radius: 7px; }
.reticle i:nth-child(3) { bottom: 10px; left: 10px; border-right: 0; border-top: 0; border-bottom-left-radius: 7px; }
.reticle i:nth-child(4) { bottom: 10px; right: 10px; border-left: 0; border-top: 0; border-bottom-right-radius: 7px; }
.reticle.pulse i { animation: reticlePulse 1.6s ease-in-out infinite; }
@keyframes reticlePulse { 0%,100% { opacity: 0.45; } 50% { opacity: 1; } }

/* Status do scanner */
.scan-status { display: flex; align-items: center; gap: 10px; justify-content: center; margin-top: 14px;
  font-weight: 600; color: var(--gold-300); letter-spacing: 0.02em; }
.scan-status .blink { width: 8px; height: 8px; border-radius: 50%; background: var(--gold-400);
  box-shadow: 0 0 10px var(--gold-400); animation: reticlePulse 1s infinite; }

/* Reduz movimento para quem pediu (acessibilidade) — cobre TODAS as animações contínuas/de entrada. */
@media (prefers-reduced-motion: reduce) {
  .scan-beam, .reticle.pulse i, .scan-status .blink, .capture-btn::before, .capture-btn::after,
  .appbar::after, .btn-primary::after, .skeleton, .boot-logo,
  .screen, .modal, .modal-card, .toast, .lightbox { animation: none !important; }
  .scan-beam { top: 50%; opacity: 0.4; }
}

/* Anéis pulsantes no botão de captura (vibe radar/scanner) */
/* Anel cônico girando atrás do botão (sweep tipo radar/scanner). */
.capture-btn::before { content: ''; position: absolute; inset: -12px; border-radius: 50%; z-index: -2; filter: blur(3px);
  background: conic-gradient(from 0deg, transparent 0deg, rgba(244,201,93,0) 80deg, var(--gold-300) 130deg, #fff 160deg, var(--gold-400) 195deg, transparent 270deg);
  animation: captureSpin 3.2s linear infinite; }
/* Aura pulsante. */
.capture-btn::after { content: ''; position: absolute; inset: -12px; border-radius: 50%; z-index: -1;
  border: 2px solid rgba(215,165,50,0.45); animation: captureRing 2.8s ease-out infinite; }
@keyframes captureSpin { to { transform: rotate(360deg); } }
@keyframes captureRing { 0% { transform: scale(1); opacity: 0.75; } 100% { transform: scale(1.5); opacity: 0; } }

/* Linha dourada animada sob o appbar */
.appbar { position: sticky; }
.appbar::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(215,165,50,0.55), transparent);
  background-size: 200% 100%; animation: sheen 4s linear infinite; }
@keyframes sheen { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Brilho sutil no botão primário */
.btn-primary { position: relative; overflow: hidden; }
.btn-primary::after { content: ''; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent); transform: skewX(-20deg);
  animation: btnsheen 3.6s ease-in-out infinite; }
@keyframes btnsheen { 0%, 60% { left: -60%; } 100% { left: 130%; } }

/* ---------- Revisão validativa: linhas de campo (verde/amarelo) + modal ---------- */
.frow { display: flex; align-items: center; gap: 12px; padding: 13px 12px; border: 1px solid var(--line-soft);
  border-radius: 12px; margin-top: 10px; background: rgba(255,255,255,0.03); cursor: pointer; transition: transform .08s; }
.frow:active { transform: scale(0.99); }
.frow .ic { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.frow .ic svg { width: 16px; height: 16px; }
.frow .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.frow .v { font-weight: 600; overflow-wrap: anywhere; }
.frow .conf { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.frow .chev { color: var(--muted-2); flex: none; }
.frow .chev svg { width: 18px; height: 18px; }
.frow--ok { border-color: rgba(34,197,94,0.30); }
.frow--ok .ic { background: rgba(34,197,94,0.15); color: #86efac; }
.frow--warn { border-color: rgba(245,158,11,0.55); background: rgba(245,158,11,0.07); }
.frow--warn .ic { background: rgba(245,158,11,0.18); color: #fcd34d; font-weight: 800; }
.frow--unknown { border-color: var(--line-soft); background: rgba(148,163,184,0.07); }
.frow--unknown .ic { background: rgba(148,163,184,0.18); color: var(--muted); font-weight: 800; }
.frow--err { border-color: rgba(239,68,68,0.5); background: rgba(239,68,68,0.07); }
.frow--err .ic { background: rgba(239,68,68,0.18); color: #fca5a5; font-weight: 800; }

.modal { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,0.6); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s ease both;
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.modal-card { width: 100%; max-width: min(var(--maxw), 560px); background: var(--navy-700); border: 1px solid var(--line);
  border-top-left-radius: 22px; border-top-right-radius: 22px; padding: 16px 16px max(18px, env(safe-area-inset-bottom));
  max-height: 86vh; max-height: 86dvh; overflow: auto; scroll-padding-bottom: 24px; animation: sheetup .25s ease both; }
/* Alça do bottom-sheet: sinal universal de "arraste/é um painel" (afford moderno). Só no mobile. */
.modal-card::before { content: ''; display: block; width: 44px; height: 5px; border-radius: 999px;
  background: rgba(255,255,255,0.18); margin: -2px auto 12px; }
@keyframes sheetup { from { transform: translateY(36px); opacity: .5; } to { transform: none; opacity: 1; } }
/* Desktop/tablet: diálogo centralizado (bottom-sheet colado no rodapé de um monitor fica perdido). */
@media (min-width: 720px) {
  .modal { align-items: center; padding: 28px; }
  .modal-card { border-radius: var(--radius-lg); animation: popin .18s ease both; }
  .modal-card::before { display: none; }
}
@keyframes popin { from { transform: scale(0.97); opacity: 0.4; } to { transform: none; opacity: 1; } }
.opt { display: flex; align-items: center; gap: 10px; padding: 13px 12px; border: 1px solid var(--line-soft);
  border-radius: 12px; margin-top: 8px; cursor: pointer; font-weight: 600; }
.opt:active { transform: scale(0.99); }
.opt svg { width: 18px; height: 18px; color: var(--gold-400); flex: none; }

/* ---------- Login cinematográfico (identidade visual) ---------- */
.login { position: relative; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 6vh) 20px calc(env(safe-area-inset-bottom) + 22px); overflow: hidden; background: #06080F; }
.login::before { content: ''; position: absolute; inset: 0; background: url('/brand/hero-corredor.jpg') 64% 34% / cover no-repeat; }
.login::after { content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(6,8,15,0.45) 0%, rgba(6,8,15,0.30) 26%, rgba(6,8,15,0.86) 70%, rgba(6,8,15,0.98) 100%); }
.login > * { position: relative; z-index: 1; }
.login-top { text-align: center; }
.login-logo { width: 88px; height: 88px; margin: 0 auto 12px; display: block; filter: drop-shadow(0 8px 26px rgba(0,0,0,0.55)); }
.login-card { -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); background: linear-gradient(180deg, rgba(12,27,51,0.72), rgba(8,17,31,0.85));
  width: 100%; max-width: 460px; margin-inline: auto; } /* no desktop o formulário não estica a tela toda */

/* ---------- Banner da Home (identidade visual) ---------- */
.home-banner { position: relative; border-radius: var(--radius); overflow: hidden; min-height: 124px;
  padding: 18px; margin: 2px 0 16px; display: flex; flex-direction: column; justify-content: flex-end; }
.home-banner::before { content: ''; position: absolute; inset: 0; background: url('/brand/goldenhour.jpg') center 32% / cover no-repeat; }
.home-banner::after { content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(6,8,15,0.25) 0%, rgba(6,8,15,0.50) 55%, rgba(6,8,15,0.92) 100%); }
.home-banner > * { position: relative; z-index: 1; }

/* ---------- Ergonomia: barra fixa de confirmar, links, chip de plantão ---------- */
.confirmbar { position: sticky; bottom: 0; z-index: 20; margin: 16px calc(-1 * var(--pad)) 0; padding: 14px var(--pad) calc(env(safe-area-inset-bottom) + 14px);
  background: linear-gradient(rgba(6,8,15,0), var(--navy-900) 36%); } /* full-bleed acompanha o --pad responsivo */
/* Separa os botões empilhados (Registrar / Capturar próximo) — evita tocar no errado. */
.confirmbar .btn + .btn { margin-top: 10px; }
.linkbtn { background: transparent; border: none; color: var(--muted); font-weight: 600; font-size: 14px; padding: 8px 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; } /* ícone nunca cola no texto (Android) */
.linkbtn:active { transform: scale(0.98); }
.linkbtn--danger { color: #fca5a5; }
.shiftchip { display: inline-flex; align-items: center; gap: 6px; max-width: min(46vw, 280px); overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  background: rgba(215,165,50,0.12); border: 1px solid var(--line); color: var(--gold-300); font-size: 12px; font-weight: 600;
  padding: 6px 10px; border-radius: 999px; cursor: pointer; }
.shiftchip .sd { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); flex: none; }

/* Modo Expresso (revisão "tudo verde") */
.btn-xl { padding: 18px; font-size: 17px; box-shadow: 0 10px 30px rgba(215,165,50,0.35); }
.confirmbar--express { box-shadow: 0 -2px 0 rgba(55,211,153,0.4) inset; }
.express-tag { color: var(--ok); font-weight: 700; font-size: 13.5px; text-align: center; margin-bottom: 10px; }

/* Banner de instalação (PWA) */
.install-banner { background: linear-gradient(180deg, rgba(215,165,50,0.10), rgba(11,16,32,0.55)); border: 1px solid rgba(215,165,50,0.35); border-radius: 14px; padding: 14px; margin: 14px 0; }
.install-banner .iconbtn { margin: -4px -4px 0 0; flex: none; }

/* ====================================================================
   Responsivo (2026-07-03): o app deixa de ser uma coluna de celular
   esticada — tablet/desktop ganham espaço útil. Os médicos usam o app
   também no Chrome do consultório (feedbacks vieram de Windows).
   ==================================================================== */
@media (min-width: 768px) {
  :root { --maxw: 640px; --pad: 24px; }
  h1 { font-size: 30px; }
  .docview { height: clamp(280px, 46vh, 560px); height: clamp(280px, 46dvh, 560px); } /* documento maior = conferência mais fácil */
}

@media (min-width: 1080px) {
  :root { --maxw: 800px; }

  /* Hoje: a lista vira grade de 2 colunas (30+ cards do PACS sem rolagem infinita). */
  .tlist { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
  .tlist > .empty { grid-column: 1 / -1; }

  /* Conferir: documento AO LADO dos campos (o médico compara sem rolar). A classe .has-doc é posta
     pela tela só quando há imagem — sem foto, a coluna única continua. */
  .screen--review.has-doc { display: grid; grid-template-columns: minmax(300px, 5fr) 7fr;
    gap: 16px; align-items: start; align-content: start; }
  .screen--review.has-doc > .card:first-child { position: sticky; top: calc(var(--safe-t) + 78px); }
  /* Offline: a appbar desce 38px (faixa de rede) — o sticky do documento acompanha. */
  body.offline .screen--review.has-doc > .card:first-child { top: calc(var(--safe-t) + 116px); }
  .screen--review.has-doc .docview { height: clamp(320px, 60vh, 720px); height: clamp(320px, 60dvh, 720px); }
  /* Tudo que não é o documento vive na coluna DIREITA (de trabalho): campos, aviso de duplicata e a
     barra de ações — o alerta não se perde na coluna estreita, e as colunas alinham no topo. */
  .screen--review.has-doc > .card:not(:first-child) { grid-column: 2; margin-top: 0; }
  .screen--review.has-doc > .confirmbar { grid-column: 2; position: static; margin: 4px 0 0; padding: 0;
    background: none; border-radius: 0; } /* no desktop a barra é o fim do formulário, não overlay */
}

/* Desktop/tablet: login centrado verticalmente — space-between em monitor alto deixava a marca no
   topo e o formulário colado no rodapé com um vão gigante no meio. */
@media (min-width: 768px) {
  .login { justify-content: center; gap: 28px; }
}

/* ======================================================================
   Calendário de registros (ideia do Dr. Wagner, 18/ago/2026)
   Estilo "tarifa de voo": dia com registro verde + valor pequeno; sem
   registro neutro; futuro apagado. Célula é <button> (toque abre o dia).
   ====================================================================== */
.cal { border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 10px;
  background: rgba(8, 17, 31, 0.55); }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-dow { text-align: center; font-size: 10.5px; color: var(--muted-2); text-transform: uppercase;
  letter-spacing: 0.04em; padding: 2px 0 6px; }
.cal-day { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 48px; padding: 4px 1px; border: 1px solid var(--line-soft); border-radius: 10px;
  background: transparent; color: var(--text); }
.cal-day .d { font-size: 13px; font-weight: 600; line-height: 1; }
/* Valor sempre ocupa a linha (mesmo vazio) — os números dos dias ficam alinhados entre células. */
.cal-day .v { font-size: 10px; line-height: 1; min-height: 10px; color: var(--ok); font-weight: 700;
  font-variant-numeric: tabular-nums; }
.cal-day--on { border-color: rgba(34, 197, 94, 0.45); background: rgba(34, 197, 94, 0.10); }
.cal-day--today { outline: 2px solid var(--gold-400); outline-offset: -2px; }
.cal-day--future { opacity: 0.32; }
.cal-day--blank { border: none; background: transparent; pointer-events: none; }
.cal-day:not([disabled]):active { transform: scale(0.96); }
