/* ===== Tokens ===== */
:root {
  /* cor */
  --bg: #faf8fb; --surface: #ffffff; --surface-2: #f3eff6; --fg: #1f1a24; --fg-2: #5a5163; --line: #e3dce9;
  --accent: #6b3a8c; --accent-hover: #5a2f77; --on-accent: #ffffff; --accent-soft: #efe6f5;
  --ok: #17603f; --ok-bg: #e5f3ea; --warn: #7a4a00; --warn-bg: #fdf1d8; --bad: #9b2222; --bad-bg: #fbe6e6; --info: #1f4f7a; --info-bg: #e5eef7;
  --focus: #6b3a8c;
  /* tipo */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --t-xs: .8125rem; --t-sm: .9375rem; --t-md: 1rem; --t-lg: 1.1875rem; --t-xl: 1.5rem; --t-2xl: 2rem;
  /* espaço (escala de 4) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --r-sm: 10px; --r-md: 14px; --r-lg: 20px;
  --tap: 48px;
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root {
  --bg: #141117; --surface: #1d1922; --surface-2: #26212d; --fg: #f2edf6; --fg-2: #b4aabd; --line: #3a3343;
  --accent: #c9a3e4; --accent-hover: #d8bbec; --on-accent: #1a1220; --accent-soft: #33283d;
  --ok: #86d6ab; --ok-bg: #163527; --warn: #f0c46e; --warn-bg: #3a2b0f; --bad: #f3a1a1; --bad-bg: #3e1c1c; --info: #9cc6ef; --info-bg: #162a3d;
  --focus: #c9a3e4;
  color-scheme: dark; } }

/* ===== Base ===== */
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: var(--t-md); line-height: 1.5; -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; }
/* Foco e rolagem nunca param embaixo do cabeçalho fixo nem da barra de baixo (WCAG 2.4.11) */
html { scroll-padding-top: 72px; scroll-padding-bottom: calc(var(--nav-h) + var(--s4) + env(safe-area-inset-bottom, 0px)); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: var(--t-xl); line-height: 1.25; text-wrap: balance; }
h2 { font-size: var(--t-lg); line-height: 1.3; }
h3 { font-size: var(--t-md); }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--fg-2); font-size: var(--t-sm); }
.stack { display: grid; gap: var(--s4); }
.stack-sm { display: grid; gap: var(--s2); }

/* ===== Layout do app ===== */
.app-header { position: sticky; top: 0; z-index: 10; background: var(--bg);
  padding: calc(var(--s3) + env(safe-area-inset-top, 0px)) max(var(--s4), env(safe-area-inset-right, 0px)) var(--s3) max(var(--s4), env(safe-area-inset-left, 0px));
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3); border-bottom: 1px solid var(--line); }
.app-header .title { font-weight: 700; font-size: var(--t-md); }
.screen { max-width: 560px; margin: 0 auto; display: grid; gap: var(--s4);
  padding: var(--s5) max(var(--s4), env(safe-area-inset-right, 0px)) calc(var(--nav-h) + var(--s6) + env(safe-area-inset-bottom, 0px)) max(var(--s4), env(safe-area-inset-left, 0px)); }
.screen.no-nav { padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px)); }

/* ===== Botão ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: var(--tap); padding: 0 var(--s5);
  border-radius: var(--r-md); border: 1px solid transparent; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; transition: background .15s, transform .1s; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--accent); border-color: var(--line); }
.btn-ghost { background: none; color: var(--accent); padding: 0 var(--s2); }
.btn-danger { background: none; color: var(--bad); padding: 0 var(--s2); }
.btn-full { width: 100%; }
.btn svg { width: 20px; height: 20px; flex: none; }

/* ===== Cartão ===== */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s4); display: grid; gap: var(--s3); }
.card-eyebrow { font-size: var(--t-xs); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--fg-2); }

/* ===== Situação ===== */
.status { border-radius: var(--r-lg); padding: var(--s4); display: grid; grid-template-columns: 28px 1fr; gap: var(--s3); align-items: start; }
.status svg { width: 28px; height: 28px; }
.status-title { font-weight: 800; font-size: var(--t-lg); line-height: 1.3; }
.status-text { font-size: var(--t-sm); margin-top: var(--s1); }
.status-meta { margin-top: var(--s3); font-size: var(--t-sm); font-weight: 700; }
.tone-ok { background: var(--ok-bg); color: var(--ok); }
.tone-warn { background: var(--warn-bg); color: var(--warn); }
.tone-bad { background: var(--bad-bg); color: var(--bad); }
.tone-info { background: var(--info-bg); color: var(--info); }

/* ===== Campo ===== */
.field { display: grid; gap: var(--s2); }
.field-label { font-weight: 700; }
.field-hint { color: var(--fg-2); font-size: var(--t-sm); }
.field-error { color: var(--bad); font-size: var(--t-sm); font-weight: 600; }
.input, .select { font: inherit; color: var(--fg); background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-md);
  min-height: var(--tap); padding: 0 var(--s3); width: 100%; }
.input:focus, .select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { padding: var(--s3); min-height: 110px; resize: vertical; }
.field.has-error .input, .field.has-error .select { border-color: var(--bad); }
.month { display: grid; grid-template-columns: 1.4fr 1fr; gap: var(--s2); }

/* ===== Lista de escolhas ===== */
.choices { display: grid; gap: var(--s2); border: 0; margin: 0; padding: 0; }
.choice { position: relative; display: grid; grid-template-columns: 24px 1fr; gap: var(--s3); align-items: start; padding: var(--s4);
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-md); cursor: pointer; min-height: var(--tap); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--fg-2); margin-top: 1px; display: grid; place-items: center; }
.choice .dot::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); transform: scale(0); transition: transform .12s; }
.choice-label { font-weight: 700; }
.choice-desc { color: var(--fg-2); font-size: var(--t-sm); margin-top: 2px; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice:has(input:checked) .dot { border-color: var(--accent); }
.choice:has(input:checked) .dot::after { transform: scale(1); }
.choice:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ===== Progresso ===== */
.progress { display: grid; gap: var(--s2); }
.progress-bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress-bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }
.progress-label { font-size: var(--t-sm); color: var(--fg-2); font-weight: 600; }

/* ===== Assistente (pergunta por tela) ===== */
.wizard { display: grid; gap: var(--s5); }
.wizard-head { display: grid; gap: var(--s3); }
.wizard-title { font-size: var(--t-xl); line-height: 1.25; }
.action-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--bg); border-top: 1px solid var(--line);
  padding: var(--s3) max(var(--s4), env(safe-area-inset-right, 0px)) calc(var(--s3) + env(safe-area-inset-bottom, 0px)) max(var(--s4), env(safe-area-inset-left, 0px)); }
.action-bar-inner { max-width: 560px; margin: 0 auto; display: grid; gap: var(--s2); }

/* ===== Ajuda (folha) ===== */
.sheet { border: 0; padding: 0; width: 100%; max-width: 560px; max-height: 88dvh; margin: auto auto 0; border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: var(--surface); color: var(--fg); }
.sheet::backdrop { background: rgb(0 0 0 / .45); }
.sheet-body { padding: var(--s5) var(--s4) calc(var(--s5) + env(safe-area-inset-bottom, 0px)); display: grid; gap: var(--s4); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); }
.icon-btn { display: inline-grid; place-items: center; width: var(--tap); height: var(--tap); border-radius: 50%; border: 0; background: var(--surface-2); color: var(--fg); cursor: pointer; }
.icon-btn svg { width: 22px; height: 22px; }

/* ===== Exemplo do extrato (CNIS) ===== */
.cnis { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; font-size: var(--t-xs); background: var(--surface); }
.cnis-top { background: var(--surface-2); padding: var(--s2) var(--s3); font-weight: 700; }
.cnis table { width: 100%; border-collapse: collapse; }
.cnis th, .cnis td { padding: 6px var(--s2); text-align: left; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.cnis th { color: var(--fg-2); font-weight: 600; }
.cnis .hl { background: var(--warn-bg); color: var(--warn); font-weight: 800; }
.cnis .ring { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ===== Linha do tempo ===== */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; }
.tl-item { display: grid; grid-template-columns: 64px 20px 1fr; gap: var(--s3); position: relative; padding-bottom: var(--s5); }
.tl-item:last-child { padding-bottom: 0; }
.tl-date { text-align: right; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tl-date small { display: block; font-weight: 500; color: var(--fg-2); font-size: var(--t-xs); }
.tl-rail { position: relative; display: grid; justify-items: center; }
.tl-rail::before { content: ""; position: absolute; top: 18px; bottom: calc(-1 * var(--s5)); width: 2px; background: var(--line); }
.tl-item:last-child .tl-rail::before { display: none; }
.tl-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--accent); margin-top: 3px; z-index: 1; }
.tl-title { font-weight: 700; }
.tl-when { font-size: var(--t-sm); font-weight: 700; color: var(--accent); }
.tl-item.is-past { opacity: .5; }
.tl-item.is-past .tl-dot { background: var(--accent); }
.tl-item.is-alert .tl-dot { border-color: var(--bad); }
.tl-item.is-alert .tl-when { color: var(--bad); }
.tl-item.is-today .tl-dot { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

/* ===== Passo (checklist) ===== */
.steps { display: grid; gap: var(--s2); }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.step-row { display: grid; grid-template-columns: var(--tap) 1fr 24px; align-items: center; gap: var(--s2); padding: var(--s2) var(--s3) var(--s2) var(--s2); }
.check { width: var(--tap); height: var(--tap); border-radius: 50%; border: 0; background: none; cursor: pointer; display: grid; place-items: center; }
.check span { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--fg-2); display: grid; place-items: center; }
.check svg { width: 16px; height: 16px; opacity: 0; color: var(--on-accent); }
.step.is-done .check span { background: var(--accent); border-color: var(--accent); }
.step.is-done .check svg { opacity: 1; }
.step.is-done .step-title { color: var(--fg-2); text-decoration: line-through; }
.step.is-next { border-color: var(--accent); }
.step summary { list-style: none; cursor: pointer; display: contents; }
.step summary::-webkit-details-marker { display: none; }
.step-title { font-weight: 700; padding: var(--s2) 0; }
.step-tag { font-size: var(--t-xs); font-weight: 700; color: var(--accent); }
.chev { width: 24px; height: 24px; color: var(--fg-2); transition: transform .2s; }
.step details[open] .chev { transform: rotate(180deg); }
.step-body { padding: 0 var(--s4) var(--s4) calc(var(--tap) + var(--s3)); display: grid; gap: var(--s3); }
.step-body ol { margin: 0; padding-left: var(--s4); display: grid; gap: var(--s2); }

/* ===== Linha chave/valor ===== */
.rows { display: grid; }
.row-kv { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); padding: var(--s3) 0; border-bottom: 1px solid var(--line); min-height: var(--tap); }
.row-kv:last-child { border-bottom: 0; }
.row-kv .k { color: var(--fg-2); font-size: var(--t-sm); }
.row-kv .v { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }

/* ===== Número em destaque ===== */
.figure { display: grid; gap: 2px; }
.figure-value { font-size: var(--t-2xl); font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.figure-sub { color: var(--fg-2); font-size: var(--t-sm); }

/* ===== Estado vazio ===== */
.empty { text-align: center; padding: var(--s6) var(--s4); display: grid; gap: var(--s2); justify-items: center; color: var(--fg-2); }
.empty svg { width: 40px; height: 40px; color: var(--accent); }
.empty strong { color: var(--fg); font-size: var(--t-lg); }

/* ===== Nota ===== */
.note { display: grid; gap: var(--s1); padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
.note:last-child { border-bottom: 0; }
.note-date { font-size: var(--t-xs); color: var(--fg-2); font-weight: 700; }
.note-actions { display: flex; justify-content: flex-end; }

/* ===== Navegação inferior ===== */
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--surface); border-top: 1px solid var(--line);
  padding: var(--s1) max(var(--s2), env(safe-area-inset-right, 0px)) calc(var(--s1) + env(safe-area-inset-bottom, 0px)) max(var(--s2), env(safe-area-inset-left, 0px)); }
.bottom-nav ul { list-style: none; margin: 0 auto; padding: 0; max-width: 560px; display: grid; grid-template-columns: repeat(5, 1fr); }
.bottom-nav button { width: 100%; min-height: 56px; border: 0; background: none; color: var(--fg-2); font: inherit; font-size: var(--t-xs); font-weight: 700;
  display: grid; justify-items: center; align-content: center; gap: 2px; cursor: pointer; border-radius: var(--r-sm); }
.bottom-nav svg { width: 24px; height: 24px; }
.bottom-nav button[aria-current="page"] { color: var(--accent); }
.bottom-nav button[aria-current="page"] svg { background: var(--accent-soft); border-radius: 99px; width: 52px; padding: 2px 14px; box-sizing: border-box; height: 28px; }

/* ===== Aviso rápido ===== */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--s4) + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px); opacity: 0;
  background: var(--fg); color: var(--bg); padding: var(--s3) var(--s4); border-radius: var(--r-md); font-weight: 600; z-index: 20; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== Selo ===== */
.badge { display: inline-block; font-size: var(--t-xs); font-weight: 800; padding: 2px var(--s2); border-radius: 99px; background: var(--accent-soft); color: var(--accent); }


/* ===== Caixa de marcar (aceites) ===== */
.check-row { display: grid; grid-template-columns: 24px 1fr; gap: var(--s3); align-items: start; padding: var(--s3) 0; font-size: var(--t-sm); cursor: pointer; min-height: var(--tap); }
.check-input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accent); }

/* ===== Separador "ou" ===== */
.divider { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--s3); color: var(--fg-2); font-size: var(--t-sm); }
.divider::before, .divider::after { content: ""; height: 1px; background: var(--line); }

/* ===== Botão do Google (fundo branco, segue a marca deles) ===== */
.btn-google { background: #fff; color: #1f1f1f; border-color: #747775; }
.btn-google svg { width: 20px; height: 20px; }
.btn[aria-busy="true"] { opacity: .75; cursor: progress; }

/* ===== Entrada ===== */
.entrada { max-width: 440px; margin: 0 auto; padding: var(--s6) var(--s4) var(--s7); display: grid; gap: var(--s5); }
.entrada-marca { display: grid; gap: var(--s2); justify-items: start; }
.entrada-marca img { width: 56px; height: 56px; border-radius: 14px; }

/* ===== Situação da sincronização ===== */
.sync { display: flex; align-items: center; gap: var(--s2); font-size: var(--t-xs); color: var(--fg-2); }
.sync svg { width: 16px; height: 16px; flex: none; }
.sync.is-pendente { color: var(--warn); }

/* ===== Lista simples com marcador ===== */
.passos-lista { margin: 0; padding-left: 1.25rem; display: grid; gap: var(--s2); font-size: var(--t-sm); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
