/* Meu Reembolso — design tokens e componentes. Paleta: docs/PALETTE.md (Emergent Cold LatAm). */

:root {
  --bg: #F4F5F9; --surface: #FFFFFF; --surface-2: #F6F6F6;
  --text: #1C2543; --text-2: #5A6178; --muted: #636B87;
  --border: #E1E3EA; --border-strong: #6B7390;
  --primary: #92223E; --primary-600: #7A1B34; --primary-100: #FFDCE2; --on-primary: #FFFFFF;
  --accent: #0F4C81; --accent-100: #E7E4FF;
  --ok: #1E7A4B; --ok-100: #E3F5EA; --warn: #B45309; --warn-100: #FFF6DE; --danger: #C9341F; --danger-100: #FDEEEB;
  --navy: #1C2543; --on-navy: #F6F6F6;
  --radius: 16px; --radius-sm: 12px; --radius-xs: 8px;
  --shadow: 0 1px 2px rgba(28,37,67,.06), 0 8px 24px -12px rgba(28,37,67,.18);
  --shadow-lg: 0 12px 40px -12px rgba(28,37,67,.35);
  --font: "Lexend Deca", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  --bar-h: 76px; --maxw: 720px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0E1424; --surface: #1C2543; --surface-2: #26325A;
  --text: #F6F6F6; --text-2: #AAB3CB; --muted: #929DC4;
  --border: #33406B; --border-strong: #7B86AC;
  --primary: #E8668A; --primary-600: #F07FA0; --primary-100: #3A1F33; --on-primary: #0E1424;
  --accent: #8CC0F2; --accent-100: #1F2E55;
  --ok: #5CD394; --ok-100: #143826; --warn: #F5B94E; --warn-100: #3D2E12; --danger: #FF7A70; --danger-100: #4A1F1B;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.5);
  --shadow-lg: 0 12px 40px -12px rgba(0,0,0,.6);
} }
:root[data-theme="dark"] {
  --bg: #0E1424; --surface: #1C2543; --surface-2: #26325A;
  --text: #F6F6F6; --text-2: #AAB3CB; --muted: #929DC4;
  --border: #33406B; --border-strong: #7B86AC;
  --primary: #E8668A; --primary-600: #F07FA0; --primary-100: #3A1F33; --on-primary: #0E1424;
  --accent: #8CC0F2; --accent-100: #1F2E55;
  --ok: #5CD394; --ok-100: #143826; --warn: #F5B94E; --warn-100: #3D2E12; --danger: #FF7A70; --danger-100: #4A1F1B;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.5);
  --shadow-lg: 0 12px 40px -12px rgba(0,0,0,.6);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none; min-height: 100vh; min-height: 100dvh;
}
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; }
h1 { font-size: 28px; } h2 { font-size: 22px; } h3 { font-size: 17px; } h4 { font-size: 15px; }
p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, canvas, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }   /* o anel do :focus (box-shadow) já sinaliza */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Layout ---------- */
.app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.screen { flex: 1; width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 16px calc(var(--bar-h) + var(--safe-b) + 16px); }
.screen.no-bar { padding-bottom: calc(24px + var(--safe-b)); }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  padding: calc(10px + var(--safe-t)) 16px 10px; margin: 0 -16px 12px; background: var(--bg);
  border-bottom: 1px solid transparent; box-shadow: 0 1px 0 var(--border);
}
.topbar.navy { background: var(--navy); color: var(--on-navy); }
.topbar > h1, .topbar > h2 { flex: 1; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .brand { display: flex; align-items: center; gap: 10px; flex: 1; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--navy); display: grid; place-items: center; color: #fff; flex: none; }
.brand-name { font-weight: 800; font-size: 20px; letter-spacing: -.02em; line-height: 1.2; }
.topbar .brand:focus, .topbar > h2:focus { outline: none; }   /* foco programático ao trocar de tela (leitores de tela); sem anel visual */
.brand-name em { font-style: normal; color: var(--primary); }
.brand-sub { font-size: 12px; color: var(--text-2); margin-top: -2px; }

.bar-bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 10px 16px calc(10px + var(--safe-b));
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.bar-bottom .inner { max-width: var(--maxw); margin: 0 auto; display: flex; gap: 10px; align-items: center; }
.bar-bottom .inner > * { flex: 1; }
.bar-bottom .inner > .btn.icon, .bar-bottom .inner > .btn.fit { flex: 0 0 auto; }
@media (max-width: 430px) { .bar-bottom .btn.lg { font-size: 15px; padding: 0 12px; } }   /* "Pedir aprovação por e-mail" numa linha só */

.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 380px) { .grid-2 { grid-template-columns: 1fr; } }
.section-title { font-size: 13px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; margin: 18px 0 8px; }
.muted { color: var(--text-2); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
/* A frase do alerta que abre antes do e-mail: é o único texto do painel e o que ele precisa ler
   inteiro antes de tocar em "Abrir o e-mail" — por isso não é `small muted` como o resto. */
.alerta-anexo { margin: 0; font-size: 16px; font-weight: 600; line-height: 1.35; }
.center { text-align: center; }
.mt { margin-top: 12px; } .mb { margin-bottom: 12px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card.navy { background: var(--navy); color: var(--on-navy); border-color: transparent; }
.card.navy .muted { color: #AAB3CB; }
.card.navy .badge { background: rgba(255,255,255,.14); color: var(--on-navy); }
.card.accent { background: var(--accent-100); border-color: transparent; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h3 { flex: 1 1 auto; min-width: 60%; }
/* Card sem título (o título está no <summary> do card recolhido): o texto explicativo ocupa o lugar
   do h3, e o botão "Editar" continua à direita. Sem isto o parágrafo fica espremido numa coluna. */
.card-head p { flex: 1 1 auto; min-width: 60%; margin: 0; }
.report-hero { display: flex; flex-direction: column; gap: 6px; }
.card.navy .badge { white-space: nowrap; }
/* O título que o usuário escreveu é a referência do relatório (antes era um código curto):
   caixa normal, e cortado com "…" em vez de espremer o badge ao lado. */
.report-title { font-size: 14px; font-weight: 700; opacity: .9; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.amount-lg { font-size: 34px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.amount-lg small { font-size: 18px; font-weight: 600; opacity: .8; margin-right: 4px; }
.kpis { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; opacity: .9; }
/* Ação rara e destrutiva: presente no card, sem competir com "Fechar e enviar relatório".
   align-self impede que o flex do card a estique em um gêmeo do botão principal. */
.report-hero .btn.link { align-self: flex-start; margin: 2px 0 0; padding: 0; color: #fff; opacity: .8; font-size: 13px; font-weight: 500; }
.report-hero .btn.link:hover { opacity: 1; }
/* O --accent do anel de foco padrão some sobre o navy (1,7:1): sobre fundo escuro o anel é branco. */
.report-hero .btn:focus-visible { outline-color: #fff; opacity: 1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; font-size: 15px; text-decoration: none; user-select: none; -webkit-tap-highlight-color: transparent;
  transition: transform .06s ease, background .15s ease, box-shadow .15s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
/* O botão que espera o título ("Fechar e enviar relatório", no Início) fica com a CARA de
   desabilitado, mas continua clicável e focável: o toque leva o cursor ao campo que falta, e um
   `disabled` de verdade deixaria um botão morto que o leitor de tela nem alcança. O porquê é o
   parágrafo ligado por aria-describedby logo abaixo dele. */
.btn.needs-title[aria-disabled="true"] { pointer-events: auto; cursor: not-allowed; }
.home-title-block { margin: 6px 0 0; color: #E7C6C6; }
.btn.primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 6px 18px -8px var(--primary); }
.btn.primary:hover { background: var(--primary-600); }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.navy { background: var(--navy); color: var(--on-navy); }
.btn.on-navy { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.35); }
.btn.on-navy:hover { background: rgba(255,255,255,.2); }
.btn.ghost { background: transparent; color: var(--text); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger); color: var(--on-primary); }
.btn.danger.ghost { background: transparent; color: var(--danger); }
.btn.link { background: none; color: var(--accent); padding: 0 6px; min-height: 44px; margin: -10px -6px; font-weight: 600; }
.btn.lg { min-height: 56px; font-size: 17px; border-radius: 14px; }
.btn.sm { min-height: 40px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
@media (pointer: coarse) { .btn.sm { min-height: 44px; } }
.btn.icon { width: 44px; min-width: 44px; height: 44px; padding: 0; border-radius: 12px; }
.btn.icon.lg { width: 56px; min-width: 56px; height: 56px; }
.btn.block { width: 100%; }
.btn .ico { display: inline-flex; }
.fab-camera { flex: 2 !important; }

/* ---------- Chips e badges ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: wrap; overflow: visible; padding: 0; margin: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border-strong); font-size: 14px; font-weight: 500; white-space: nowrap;
}
.chip.sm { min-height: 28px; padding: 0 10px; font-size: 12px; }
button.chip.sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
@media (pointer: coarse) { button.chip.sm { min-height: 44px; } }
.emoji { font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.chip.active { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.chip.soft { background: var(--surface-2); border-color: transparent; }
.chip.cat { background: var(--accent-100); border-color: transparent; color: var(--text); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: .02em; background: var(--surface-2); color: var(--text-2); }
.badge.ok { background: var(--ok-100); color: var(--ok); }
.badge.warn { background: var(--warn-100); color: var(--warn); }
.badge.danger { background: var(--danger-100); color: var(--danger); }
.badge.accent { background: var(--accent-100); color: var(--accent); }
.badge.primary { background: var(--primary-100); color: var(--primary); }

/* ---------- Formulários ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.field-hint { font-size: 12px; color: var(--muted); }
.input, input:where(:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"])), select, textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 84px; resize: vertical; line-height: 1.4; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input::placeholder, textarea::placeholder { color: var(--muted); }
.input-amount { font-size: 28px; font-weight: 800; letter-spacing: -.02em; min-height: 64px; padding-left: 64px; font-variant-numeric: tabular-nums; }
.amount-wrap { position: relative; }
.amount-wrap .prefix { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); font-weight: 700; font-size: 18px; color: var(--text-2); pointer-events: none; }
.field.warn input, .field.warn select, .field.warn textarea { border-color: var(--warn); background: color-mix(in srgb, var(--warn-100) 45%, var(--surface)); }
.field.ok input, .field.ok select { border-color: var(--ok); }
select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; min-height: 44px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track { width: 48px; height: 28px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .15s; flex: none; }
.switch-thumb { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--accent); outline-offset: 2px; }
.switch-label { font-weight: 500; }

/* ---------- Listas ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); text-align: left; width: 100%; color: inherit; cursor: pointer;
}
.list-item:hover { border-color: var(--border-strong); }
/* Prévia do que a pasta tem: é uma lista para LER antes de importar, não para tocar. */
.list-item.static { cursor: default; }
.list-item.static:hover { border-color: var(--border); }
.list-item:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.thumb { width: 56px; height: 68px; border-radius: 10px; object-fit: cover; background: var(--surface-2); flex: none; border: 1px solid var(--border); }
.thumb.ph { display: grid; place-items: center; color: var(--muted); }
.thumb-btn { position: relative; width: 72px; height: 88px; padding: 0; cursor: zoom-in; overflow: hidden; }
.thumb-btn img { width: 100%; height: 100%; object-fit: cover; }
.thumb-zoom { position: absolute; right: 4px; bottom: 4px; width: 22px; height: 22px; border-radius: 50%; background: rgba(28,37,67,.8); color: #fff; display: grid; place-items: center; }
.li-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.li-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-sub { font-size: 13px; color: var(--text-2); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.nowrap { white-space: nowrap; display: inline-flex; gap: 4px; align-items: center; }
.ico-inline { display: inline-flex; color: var(--accent); }
.li-amount { font-weight: 700; font-size: 16px; white-space: nowrap; text-align: right; }
.li-amount .mini { display: block; font-size: 11px; font-weight: 500; color: var(--text-2); }

/* ---------- Estados ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--text-2); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty .illo { width: 120px; height: 120px; border-radius: 32px; background: var(--accent-100); display: grid; place-items: center; color: var(--accent); }
.empty h3 { color: var(--text); }
/* Início sem despesas: o card inteiro é o botão que abre a câmera ou a galeria. Botão de verdade
   (foco, Enter, leitor de tela), com cara de card — e por isso nenhum botão dentro dele. */
.empty-cta { width: 100%; font: inherit; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); box-shadow: var(--shadow); cursor: pointer; transition: border-color .15s, transform .1s; }
.empty-cta:hover { border-color: var(--accent); }
.empty-cta:active { transform: scale(.995); }
.empty-cta .strong { color: var(--accent); font-weight: 700; }
.progress { display: flex; flex-direction: column; gap: 6px; }
.progress-host:empty { display: none; }
.progress-track { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--primary)); border-radius: 999px; transition: width .25s ease; }
.progress-label { font-size: 12px; color: var(--text-2); }
.progress.done .progress-fill { background: var(--ok); }
.spinner { width: 20px; height: 20px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.banner { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--accent-100); font-size: 14px; }
.banner > .grow { flex: 1 1 220px; min-width: 0; }
.banner > .btn { flex: 0 0 auto; }
.banner > .btn:first-of-type { margin-left: auto; }
.banner-actions { flex: 1 0 100%; display: flex; flex-wrap: wrap; gap: 8px; }
.banner.warn { background: var(--warn-100); } .banner.ok { background: var(--ok-100); } .banner.danger { background: var(--danger-100); }
.summary-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--surface-2); }
.summary-bar span { display: block; height: 100%; }
.kv { display: flex; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; font-size: 13px; }
.kv-l { color: var(--text-2); }
.kv-v { flex: 1; min-width: 0; overflow-wrap: anywhere; text-align: right; }
.legend { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 14px; }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.cat-c0 { background: var(--primary); } .cat-c1 { background: var(--accent); } .cat-c2 { background: #1E7A4B; } .cat-c3 { background: #B45309; }
.cat-c4 { background: #6B4FBB; } .cat-c5 { background: #0E7C86; } .cat-c6 { background: #8D8D8D; } .cat-c7 { background: #5A6178; }

/* ---------- Toast / diálogo / sheet ---------- */
.toast-host { position: fixed; left: 0; right: 0; bottom: calc(var(--bar-h) + var(--safe-b) + 8px); z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 12px; }
body:not(.has-bar) .toast-host { bottom: calc(16px + var(--safe-b)); }
.toast { background: var(--navy); color: var(--on-navy); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; max-width: min(92vw, 520px); }
.toast.show { opacity: 1; transform: none; }
.toast.ok { background: var(--ok); color: var(--on-primary); } .toast.err { background: var(--danger); color: var(--on-primary); }
.dialog { border: none; border-radius: var(--radius); padding: 22px; max-width: min(92vw, 420px); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.dialog:not([open]) { display: none; }
.dialog::backdrop { background: rgba(14,20,36,.55); }
.dialog h3 { margin-bottom: 8px; } .dialog p { color: var(--text-2); margin-bottom: 18px; }
.dialog-question { display: flex; flex-direction: column; gap: 4px; margin-bottom: 18px; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; }
.sheet-wrap { position: fixed; inset: 0; z-index: 90; background: rgba(14,20,36,0); transition: background .25s; display: flex; align-items: flex-end; justify-content: center; }
.sheet-wrap.show { background: rgba(14,20,36,.55); }
.sheet { width: 100%; max-width: var(--maxw); max-height: 88dvh; background: var(--surface); border-radius: 22px 22px 0 0; padding: 8px 16px calc(16px + var(--safe-b)); transform: translateY(100%); transition: transform .25s ease; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.sheet-wrap.show .sheet { transform: none; }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 4px auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-body { overflow: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.sheet-actions { display: flex; gap: 10px; padding-top: 12px; }
.sheet-actions > * { flex: 1; }
@media (min-width: 720px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 22px; max-height: 80vh; } .sheet-wrap.show .sheet { transform: none; } .sheet-grip { display: none; } }

/* ---------- Tela de recorte ---------- */
.capture { position: fixed; inset: 0; z-index: 40; background: #0B0F1A; color: #fff; display: flex; flex-direction: column; }
.capture .cap-top { display: flex; align-items: center; justify-content: space-between; padding: calc(10px + var(--safe-t)) 12px 10px; }
.capture .cap-stage { flex: 1; position: relative; overflow: hidden; touch-action: none; }
.capture .cap-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.capture .cap-top .btn { color: inherit; }
.capture .cap-tools { display: flex; gap: 8px; justify-content: center; padding: 10px 12px; }
.capture .cap-tools .btn { flex: 1 1 0; min-width: 0; max-width: 120px; flex-direction: column; gap: 3px; min-height: 54px; padding: 6px 4px; font-size: 12px; font-weight: 500; background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.18); }
.capture .cap-tools .btn.active { background: rgba(255,255,255,.28); border-color: #fff; color: #fff; }
.capture .cap-hint { text-align: center; font-size: 12px; opacity: .75; padding: 0 16px 4px; }
.capture .cap-actions { display: flex; gap: 10px; padding: 6px 16px calc(14px + var(--safe-b)); }
.capture .cap-actions .btn { flex: 1; }
.loupe { position: absolute; width: 120px; height: 120px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 6px 24px rgba(0,0,0,.5); overflow: hidden; pointer-events: none; background: #000; }

/* ---------- Visualizador ---------- */
.viewer { position: fixed; inset: 0; z-index: 80; background: rgba(5,8,16,.96); display: flex; overflow: auto; -webkit-overflow-scrolling: touch; touch-action: manipulation; padding-bottom: 48px; }
.viewer img { display: block; margin: auto; max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-in; }
.viewer img.zoomed { max-width: none; max-height: none; width: 200%; cursor: zoom-out; }
.viewer-cap { position: fixed; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 12px; padding: 10px 16px calc(10px + var(--safe-b)); background: rgba(5,8,16,.75); color: #fff; font-size: 14px; }
.viewer-cap .tiny { opacity: .7; white-space: nowrap; }
.viewer .close { position: absolute; top: calc(12px + var(--safe-t)); right: 12px; background: rgba(255,255,255,.15); color: #fff; }

/* ---------- Tabela de mapeamento ---------- */
.map-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.map-table th, .map-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.map-table th { font-size: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; }
.map-table select { min-height: 40px; padding: 6px 30px 6px 10px; font-size: 14px; }
.table-wrap { overflow-x: auto; }
.map-table th:first-child, .map-table td:first-child { width: 1%; white-space: nowrap; }
@media (max-width: 480px) {
  .map-table thead { display: none; }
  .map-table tr { display: grid; grid-template-columns: 2.2em 1fr; gap: 2px 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
  .map-table td { border: 0; padding: 0; width: auto; }
  .map-table td:nth-child(3) { grid-column: 1 / -1; }
  .map-table select { width: 100%; }
}
/* Configurações: opções avançadas recolhidas */
.settings-adv summary { list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 12px 16px; min-height: 56px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.settings-adv summary::-webkit-details-marker { display: none; }
.settings-adv summary .ico { transition: transform .15s; }
.settings-adv[open] summary .ico { transform: rotate(90deg); }
/* Configurações: dados achados no formulário e barra de salvar */
.prefill { gap: 8px; }
.prefill-row { width: 100%; align-items: flex-start; gap: 12px; }
.prefill-row .switch-track { margin-top: 8px; }
.prefill-row .switch-label { flex: 1; min-width: 0; font-weight: 400; padding: 4px 0; }
.prefill-info { display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
.save-state { padding: 6px 12px; font-size: 13px; }

/* Campo travado: veio do formulário do usuário e só muda por "Editar". readonly (não disabled),
   para continuar focável, copiável e legível por leitor de tela. */
input.locked, input.locked:focus { background: var(--surface-2); border-style: dashed; color: var(--text-2); }
.lock-hint::before { content: '🔒 '; }

/* Dados: o que some e o que fica, lado a lado */
.data-levels { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .data-levels { grid-template-columns: 1fr 1fr; } }
.data-level { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.data-level ul { margin: 6px 0 0; padding-left: 20px; color: var(--text-2); }
.data-level li { margin: 2px 0; }

/* Início: onde os arquivos ficam. Com a pasta escolhida a linha inteira é um BOTÃO (papel, foco e
   rótulo de verdade) e leva ao histórico lido dela; "Abrir a pasta" fica FORA dela — botão dentro de
   botão não existe em HTML, e o leitor de tela anunciaria um alvo só, com o nome errado. */
.home-files { gap: 10px; }
.home-files > .row .btn.link { padding: 0; }
.folder-line {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  font: inherit; color: inherit; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; cursor: pointer;
}
.folder-line:hover { border-color: var(--accent); }
.folder-line:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.folder-line > .ico { color: var(--accent); flex: none; }
.folder-line > .ico:last-child { color: var(--text-2); }
.folder-line .grow { display: flex; flex-direction: column; gap: 2px; }
.fl-title { font-size: 14px; overflow-wrap: anywhere; }
.fl-sub { font-size: 12px; color: var(--text-2); overflow-wrap: anywhere; }
/* Subtítulo dentro do painel de dados: separa a explicação da decisão sem virar outro card. */
.sheet-sub { margin: 8px 0 0; font-size: 14px; }

/* Primeira abertura (#/intro): um card por pergunta, e nada em volta que possa ser tocado por
   engano — o fluxo vai até o fim, então esta tela não tem barra inferior nem porta de saída. */
.intro { padding-top: 8px; }
.intro-card { gap: 12px; }
.intro-passo { text-transform: uppercase; letter-spacing: .06em; font-weight: 600; margin: 0; }
.intro-titulo { font-size: 22px; letter-spacing: -.02em; line-height: 1.2; }
/* O foco vai para este título a cada troca de card (é ele que anuncia o passo novo a quem usa leitor
   de tela): programático, e por isso sem anel visual — mesma regra do cabeçalho das outras telas. */
.intro-titulo:focus { outline: none; }
.intro-option { position: relative; display: flex; flex-direction: column; gap: 6px; }
.intro-pick {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; text-align: left;
  font: inherit; color: inherit; background: var(--surface); min-height: 60px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 12px 14px; cursor: pointer;
}
.intro-pick:hover { border-color: var(--accent); }
.intro-pick:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.intro-pick > .ico { color: var(--text-2); flex: none; }
.intro-pick .grow { display: flex; flex-direction: column; gap: 3px; }
.io-title { font-weight: 600; overflow-wrap: anywhere; }
.io-sub { font-size: 12px; color: var(--text-2); overflow-wrap: anywhere; }
/* O "?" é irmão da opção, nunca filho: botão dentro de botão não existe, e o toque na explicação
   escolheria a opção — ela explica, não decide. Ele fica COLADO AO TEXTO da opção (e não num card
   à parte, como era) porque é posicionado sobre o card, na linha do título: `position` é a única
   coisa que muda, o DOM continua com os dois botões lado a lado.
   `right: 46px` o põe à esquerda do chevron, que ocupa os 32 px da borda para dentro. */
.io-q {
  position: absolute; top: 11px; right: 46px; z-index: 1;
  width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--danger); color: #fff; font: 700 15px/1 inherit; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.io-q:hover { filter: brightness(1.1); }
/* Área de toque de 44 px sem um círculo de 44 px na tela: o alvo cresce por um ::after transparente.
   Ele avança só sobre a faixa que `.has-q .grow` reserva — assim o dedo acerta o "?" e o título
   continua inteiro à vista e inteiro clicável, que é o que não pode ser coberto. */
.io-q::after { content: ""; position: absolute; top: 50%; left: 50%; width: 44px; height: 44px; transform: translate(-50%, -50%); }
.intro-pick.has-q .grow { padding-right: 40px; }
.io-why {
  margin: 0; background: var(--accent-100); border-radius: var(--radius-sm); padding: 10px 12px;
  display: flex; align-items: flex-start; gap: 6px;
}
.io-why > .grow > :first-child { margin-top: 0; }
.io-why > .grow > :last-child { margin-bottom: 0; }
.io-why p { margin: 0 0 8px; }
/* O X fica no alto: numa explicação longa (a da pasta traz permissão, dica e a regra da nuvem), um
   fecho no fim obrigaria a rolar até o fim do texto para sair dele. */
.io-why-x { flex: 0 0 auto; margin: -4px -6px 0 0; }
/* O recado de "nenhuma pasta foi escolhida": fica no card, e não num toast que some antes de a
   pessoa entender que o seletor foi fechado sem escolha. */
.io-recado { margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--warn-100); }
.intro-acoes { margin-top: 4px; }
.intro-voltar { align-self: flex-start; }

/* Dicas por tipo de aparelho */
.desktop-only { display: none; }
@media (pointer: fine) and (min-width: 700px) { .desktop-only { display: block; } }
.coarse-only { display: none; }
@media (pointer: coarse) { .coarse-only { display: inline; } }

/* ---------- Desktop ---------- */
@media (min-width: 900px) {
  body { background: linear-gradient(180deg, var(--bg), color-mix(in srgb, var(--bg) 85%, var(--accent-100))); }
  .app { padding: 24px 0; }
  .screen { background: var(--surface); border-radius: 24px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); padding: 0 28px calc(var(--bar-h) + 48px); min-height: calc(100dvh - 48px); }
  .topbar { margin: 0 -28px 12px; padding: 16px 28px 12px; border-radius: 24px 24px 0 0; background: var(--surface); }
  /* barra fixa, centrada na largura do card (sticky deixava-a flutuando no meio do card com conteúdo por baixo) */
  .bar-bottom { position: fixed; left: 50%; right: auto; bottom: 24px; transform: translateX(-50%); width: min(100%, var(--maxw)); margin: 0; border: 1px solid var(--border); border-radius: 0 0 24px 24px; }
  .toast-host { bottom: calc(var(--bar-h) + 40px); }
  body:not(.has-bar) .toast-host { bottom: 40px; }
  .capture { max-width: none; }
  .capture .cap-stage { max-width: 1100px; width: 100%; margin: 0 auto; }
  .card { box-shadow: none; }
  .input-amount { max-width: 320px; }
  .expense-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; align-items: start; }
  .expense-fields > .full { grid-column: 1 / -1; }
  .viewer img.zoomed { width: auto; }
}
.drop-active::after { content: "Solte a imagem para adicionar"; position: fixed; inset: 12px; border: 3px dashed var(--accent); border-radius: 20px; background: color-mix(in srgb, var(--accent-100) 85%, transparent); display: grid; place-items: center; font-weight: 700; font-size: 20px; color: var(--accent); z-index: 200; }

/* Conta contábil por categoria (Configurações → Modelo de planilha) */
.acc-row { gap: 8px; align-items: center; }
.acc-row .chip { flex: 0 0 auto; min-width: 132px; }
.acc-row select, .acc-row input { min-height: 40px; }
@media (max-width: 420px) { .acc-row { flex-wrap: wrap; } .acc-row .chip { min-width: 0; } .acc-row .grow { flex-basis: 100%; } }

/* Card de envio do relatório: uma coisa por linha. No celular de 390 px, qualquer texto ao lado de um
   botão vira uma coluna de duas palavras por linha — foi assim que o aviso de apagar as fotos ficou. */
.send-card { gap: 12px; }
/* Linha de estado dos anexos: o badge não estica e o nome do arquivo quebra onde der. */
.send-status { flex-wrap: wrap; gap: 8px; align-items: center; }
.send-status .badge { flex: 0 0 auto; }
.send-status > span { min-width: 0; overflow-wrap: anywhere; }
/* "Baixar arquivos avulsos": recolhido dentro do card, sem virar um card dentro do card. */
.send-more summary { background: transparent; box-shadow: none; border-style: dashed; min-height: 48px; padding: 10px 14px; font-weight: 600; }
.send-more > .stack { padding: 12px 2px 2px; }
/* Fechar o relatório: o aviso ocupa a linha inteira e o botão vem embaixo, nunca ao lado. */
.finish { display: grid; gap: 10px; border-top: 1px solid var(--border); padding-top: 14px; margin-top: 2px; }
.finish p { margin: 0; }

/* ---- Painel "Compartilhar os arquivos" (rota do gerenciador de arquivos) ---- */
/* Os nomes dos arquivos são o que ele vai procurar na lista do aparelho: quebram onde der, e nunca
   somem numa reticência — meio nome de arquivo não serve para achar arquivo nenhum. */
.file-list { margin: 0; padding-left: 20px; display: grid; gap: 4px; overflow-wrap: anywhere; }
/* Passos numerados: no celular de 390 px o número precisa de espaço próprio, ou a segunda linha de
   cada passo encosta nele e o texto perde o alinhamento. */
.passos { margin: 0; padding-left: 22px; display: grid; gap: 12px; }
.passos li { padding-left: 2px; }
.passos li::marker { font-weight: 700; color: var(--muted); }
.stack.tight { gap: 8px; }
/* Só aparece quando a área de transferência recusa (navegador antigo, permissão negada): aí ele
   seleciona o texto à mão. Sem `display` próprio, para o [hidden] continuar mandando. */
/* A recusa da área de transferência: vermelho e não muted, porque ela pede uma ação (copiar à mão). */
.err-text { color: var(--danger); margin: 0; }
.copy-fallback { width: 100%; font: inherit; font-size: 12px; line-height: 1.4; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); resize: vertical; }
