/* Uma coluna só, pensada no iPhone; no computador a coluna fica centralizada. */
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 400; font-display: swap; src: url(/fontes/atkinson-hyperlegible-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 700; font-display: swap; src: url(/fontes/atkinson-hyperlegible-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "Fraunces"; font-weight: 100 900; font-display: swap; src: url(/fontes/fraunces-latin-wght-normal.woff2) format("woff2"); }

:root {
  --bg: #F4F7F5;
  --surface: #FFFFFF;
  --ink: #15201B;
  --muted: #4F5E57;
  --line: #D5DED9;
  --accent: #1B6A57;
  --accent-ink: #FFFFFF;
  --accent-soft: #DBECE5;
  --danger: #B42318;
  --danger-soft: #FBE5E2;
  --note: #FFF3D1;
  --note-ink: #5A4500;
  --veil: rgba(10, 20, 15, .42);
  --shadow: 0 1px 2px rgba(20, 40, 30, .06), 0 6px 18px rgba(20, 40, 30, .06);
  --font-body: "Atkinson Hyperlegible", -apple-system, "SF Pro Text", system-ui, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --base: 18px;
  --tap: 3.4rem;
  --radius: 18px;
  --gx-l: max(20px, env(safe-area-inset-left, 0px));
  --gx-r: max(20px, env(safe-area-inset-right, 0px));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101715; --surface: #18221E; --ink: #EDF3F0; --muted: #A4B4AC; --line: #2B3833;
    --accent: #63C7A6; --accent-ink: #062219; --accent-soft: #1C3A30; --danger: #FF8D82; --danger-soft: #3B1F1C;
    --note: #3A3218; --note-ink: #F3DE9C; --veil: rgba(0, 0, 0, .6); --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
html { font-size: var(--base); height: 100%; -webkit-text-size-adjust: 100%; }
html.grande { --base: 21px; }
* { box-sizing: border-box; }
body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 1rem; line-height: 1.45; overscroll-behavior-y: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
img { max-width: 100%; }

#app { height: 100%; display: flex; flex-direction: column; max-width: 680px; margin: 0 auto; padding-top: env(safe-area-inset-top, 0px); position: relative; }
@media (min-width: 760px) { #app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }
.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; animation: enter .22s ease-out; }
.screen.back { animation-name: enterBack; }
.screen.quiet { animation: none; }
@keyframes enter { from { transform: translateX(24px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes enterBack { from { transform: translateX(-24px); opacity: .4; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .screen, .sheet, .toast { animation: none !important; } }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.gx { padding-left: var(--gx-l); padding-right: var(--gx-r); }

/* Barra de cima */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 3.2rem; padding-block: 6px; background: var(--bg); border-bottom: 1px solid transparent; flex: none; }
.topbar.lined { border-bottom-color: var(--line); }
.topbar .title { font-weight: 700; font-size: 1.05rem; text-align: center; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tbtn { background: none; border: 0; color: var(--accent); font-weight: 700; font-size: 1.05rem; min-height: 2.8rem; padding: 0 4px; display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }
.tbtn svg { width: 1.3rem; height: 1.3rem; }
.brandline { font-size: .82rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 700; }

/* Botões */
.btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: var(--tap); border-radius: var(--radius); border: 0; font-weight: 700; font-size: 1.1rem; padding: 0 20px; text-decoration: none; text-align: center; }
.btn svg { width: 1.4rem; height: 1.4rem; flex: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.soft { background: var(--accent-soft); color: var(--accent); }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1.5px solid var(--line); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn:active { transform: scale(.985); filter: brightness(.96); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.bottombar { flex: none; padding-top: 12px; padding-bottom: max(14px, env(safe-area-inset-bottom, 0px)); background: linear-gradient(to bottom, transparent, var(--bg) 22%); }
.linkdanger { background: none; border: 0; color: var(--danger); font-weight: 700; min-height: 3rem; }

/* Carregando */
.loading { flex: 1; display: grid; place-items: center; color: var(--muted); }
.spin { width: 36px; height: 36px; border-radius: 50%; border: 4px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Entrada */
.login .scroll { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding-block: 24px; gap: 4px; }
.mark { width: 64px; height: 64px; border-radius: 20px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-family: var(--font-display); font-size: 34px; font-weight: 600; margin-bottom: 10px; }
.login h1 { font-family: var(--font-display); font-weight: 600; font-size: 2.1rem; margin: 18px 0 2px; line-height: 1.1; text-wrap: balance; }
.login p { margin: 0; color: var(--muted); }
.dots { display: flex; gap: 18px; margin: 26px 0 8px; }
.dots i { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--accent); }
.dots i.on { background: var(--accent); }
.dots.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
.err { min-height: 1.5em; color: var(--danger); font-weight: 700; max-width: 22rem; }
.keypad { display: grid; grid-template-columns: repeat(3, 84px); gap: 16px 26px; margin: 10px 0 18px; }
.keypad button { width: 84px; height: 84px; border-radius: 50%; border: 0; background: var(--surface); box-shadow: var(--shadow); font-size: 2rem; }
.keypad button:active { background: var(--accent-soft); }
.keypad .blank { visibility: hidden; }
.keypad .del { background: none; box-shadow: none; font-size: 1rem; font-weight: 700; color: var(--muted); }
.faceid { max-width: 20rem; margin-top: 10px; }

/* Lista */
.hello { padding-block: 6px 4px; }
.hello small { color: var(--muted); font-size: .95rem; }
.hello h1 { font-family: var(--font-display); font-weight: 600; font-size: 2.2rem; line-height: 1.1; margin: 2px 0 0; text-wrap: balance; }
.search { position: relative; margin: 14px 0 6px; }
.search svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 1.3rem; height: 1.3rem; color: var(--muted); }
.search input { width: 100%; min-height: var(--tap); border-radius: var(--radius); border: 1.5px solid var(--line); background: var(--surface); padding: 0 16px 0 50px; font-size: 1.05rem; -webkit-appearance: none; appearance: none; }
.search input::placeholder { color: var(--muted); }
.count { color: var(--muted); font-size: .9rem; margin: 10px 4px 8px; }
.list { display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 16px; }
.row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; width: 100%; min-height: 4.6rem; }
.row:last-child { border-bottom: 0; }
.row:active { background: var(--accent-soft); }
.av { flex: none; width: 3rem; height: 3rem; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 1.05rem; }
.row .who { flex: 1; min-width: 0; }
.row .name { font-weight: 700; font-size: 1.1rem; display: block; }
.row .sub { color: var(--muted); font-size: .92rem; display: block; }
.chev { width: 1.1rem; height: 1.1rem; color: var(--muted); flex: none; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.empty strong { color: var(--ink); font-size: 1.1rem; }

/* Paciente */
.phead { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding-block: 4px 18px; }
.phead .av { width: 5rem; height: 5rem; font-size: 1.7rem; margin-bottom: 6px; }
.phead h1 { font-family: var(--font-display); font-weight: 600; font-size: 1.85rem; line-height: 1.15; margin: 0; text-wrap: balance; }
.phead .sub { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.chip { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 4px 12px; font-size: .88rem; font-weight: 700; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card.muted { color: var(--muted); }
.contact { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.contact .num { font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; user-select: all; -webkit-user-select: all; }
.contact .lbl { color: var(--muted); font-size: .85rem; display: block; }
.contact .acts { display: flex; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 2.8rem; padding: 0 16px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 700; text-decoration: none; font-size: .95rem; border: 0; }
.pill svg { width: 1.15rem; height: 1.15rem; }
.stack { display: flex; flex-direction: column; gap: 14px; padding-bottom: 28px; }
.sect { display: flex; align-items: baseline; justify-content: space-between; margin: 14px 4px 0; gap: 12px; }
.sect h2 { font-size: 1.2rem; margin: 0; }
.sect span { color: var(--muted); font-size: .9rem; }
.evo { display: block; width: 100%; text-align: left; border: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.evo .d { font-weight: 700; color: var(--accent); font-size: .95rem; display: flex; justify-content: space-between; gap: 8px; }
.evo .d em { font-style: normal; color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.evo p { margin: 4px 0 0; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.mais { background: none; border: 0; color: var(--accent); font-weight: 700; min-height: 2.8rem; }
.fgroup h3 { font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.fgroup dl { margin: 0; }
.fitem { padding: 10px 0; border-top: 1px solid var(--line); }
.fitem:first-child { border-top: 0; padding-top: 0; }
.fitem dt { color: var(--muted); font-size: .88rem; }
.fitem dd { margin: 2px 0 0; white-space: pre-line; overflow-wrap: anywhere; }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.thumb { aspect-ratio: 1; max-width: 100%; border-radius: 14px; overflow: hidden; border: 0; padding: 0; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: .9rem; position: relative; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .doc { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; text-align: center; }
.thumb .doc svg { width: 2rem; height: 2rem; }
.thumb .doc span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: .78rem; }

/* Formulário */
.form { display: flex; flex-direction: column; gap: 22px; padding-block: 10px 30px; }
.fs { display: flex; flex-direction: column; gap: 16px; }
.fs > h2 { font-size: 1.25rem; margin: 6px 4px 0; display: flex; gap: 10px; align-items: center; }
.fs > h2 b { width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: .95rem; flex: none; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .lab { font-weight: 700; font-size: 1rem; padding-left: 4px; }
.field .help { color: var(--muted); font-size: .88rem; padding-left: 4px; margin-top: -2px; }
.field input, .field textarea { width: 100%; min-height: var(--tap); border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface); padding: 12px 14px; font-size: 1.05rem; -webkit-appearance: none; appearance: none; }
.field input[type="date"] { display: block; text-align: left; }
.field input[type="password"] { letter-spacing: .4em; font-size: 1.4rem; }
.field textarea { min-height: 6.5rem; resize: none; line-height: 1.45; }
.field input:focus, .field textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 4px var(--accent-soft); }
.field.bad input, .field.bad textarea { border-color: var(--danger); }
.field .msg { color: var(--danger); font-weight: 700; font-size: .92rem; padding-left: 4px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.two > * { min-width: 0; }
.agebox { display: flex; align-items: center; min-height: var(--tap); padding: 0 14px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 1.1rem; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { min-height: 2.9rem; border: 0; border-radius: 10px; background: none; font-weight: 700; color: var(--muted); padding: 0 6px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.toggles { display: flex; flex-wrap: wrap; gap: 10px; }
.toggles button { min-height: 3rem; padding: 0 18px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 700; display: inline-flex; align-items: center; gap: 8px; }
.toggles button svg { width: 1.1rem; height: 1.1rem; display: none; }
.toggles button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.toggles button[aria-pressed="true"] svg { display: block; }
.tip { display: flex; gap: 12px; align-items: flex-start; background: var(--note); color: var(--note-ink); border-radius: 14px; padding: 12px 14px; font-size: .95rem; }
.tip svg { width: 1.4rem; height: 1.4rem; flex: none; margin-top: 1px; }

/* Folha de baixo e aviso */
.veil { position: fixed; inset: 0; background: var(--veil); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 680px; background: var(--bg); border-radius: 26px 26px 0 0; padding-top: 10px; padding-bottom: max(18px, env(safe-area-inset-bottom, 0px)); animation: up .22s ease-out; max-height: 92%; overflow-y: auto; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }
.grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
.sheet h2 { font-size: 1.35rem; margin: 0 0 6px; text-wrap: balance; }
.sheet p { margin: 0 0 18px; color: var(--muted); }
.sheet .stack { padding-bottom: 0; gap: 12px; }
.sheet .preview { max-height: 50vh; width: 100%; object-fit: contain; border-radius: 14px; background: var(--surface); }
.steps { margin: 8px 0 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 6px; }
.toast { position: fixed; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); font-weight: 700; padding: 12px 20px; border-radius: 999px; z-index: 60; display: flex; gap: 8px; align-items: center; width: max-content; max-width: calc(100% - 40px); animation: up .2s ease-out; }
.toast.bad { background: var(--danger); color: #fff; }
.toast svg { width: 1.2rem; height: 1.2rem; flex: none; }
