/* Closer Count: design system Graphite & sage. Tokens e regras de uso em DESIGN.md.
   Fonte Manrope (OFL, static/fonts/OFL.txt) servida pelo próprio motor: nada de terceiros (CSP default-src 'self'). */

@font-face { font-family: Manrope; font-style: normal; font-weight: 500; font-display: swap; src: url('/assets/fonts/manrope-500.woff2') format('woff2'); }
@font-face { font-family: Manrope; font-style: normal; font-weight: 600; font-display: swap; src: url('/assets/fonts/manrope-600.woff2') format('woff2'); }
@font-face { font-family: Manrope; font-style: normal; font-weight: 700; font-display: swap; src: url('/assets/fonts/manrope-700.woff2') format('woff2'); }
@font-face { font-family: Manrope; font-style: normal; font-weight: 800; font-display: swap; src: url('/assets/fonts/manrope-800.woff2') format('woff2'); }

:root {
  color-scheme: light dark;
  /* Tokens da marca (Restrições globais do plano) */
  --ink: #1F2124;
  --bg: #F3F4F5;
  --card: #FFFFFF;
  --line: #E2E4E7;
  --soft: #ECEEF0;
  --muted: #5F6368;
  --sage: #9DB89A;
  --forest: #2E4A3A;
  --ok-bg: #E3ECE1;
  --amber: #7A5410;
  --amber-bg: #F4E9D3;
  --red: #8A2D22;
  --red-bg: #F6E1DE;
  /* Apoio: texto sobre o grafite, campos, sugestão e estados */
  --on-ink: #D5D5D1;
  --on-ink-strong: #EDEDEA;
  --on-ink-muted: #A9AAA6;
  --field: #C9CED4;
  --forest-hover: #263F31;
  --disabled-bg: #C9CDD2;
  --disabled-text: #3D4146;
  --track: #E9EBEE;
  --sug-bg: #F4F8F3;
  --sug-line: #B9CDB6;
  --amber-line: #E8D7B4;
  /* Texto sobre o botão principal; superfície grafite do topo, do painel de acesso e da barra em massa */
  --on-forest: #FFFFFF;
  --graphite: #1F2124;
  /* Painel inicial: as 5 faixas verdes do mapa do ano, dos anéis e da esteira (h1 a mais clara; h5 = 100%) e o texto
     sobre a faixa 3. Texto sobre h1 e h2: ink; sobre h4 e h5: on-forest (tests/test_design_system.py confere). */
  --h1: #C9D9C6;
  --h2: #9DB89A;
  --h3: #739878;
  --h4: #4E7259;
  --h5: #2E4A3A;
  --on-h3: #1F2124;
}

/* O ícone de tema do topo (cookie `closer_tema`) fixa o tema; sem escolha, segue o sistema. */
:root[data-theme="light"] { color-scheme: light; }

/* Tema escuro: a mesma família Graphite & sage. Texto claro sobre grafite; o verde vira sálvia clara (ação legível
   sobre o escuro) com texto escuro no botão; etiquetas com fundo translúcido (alfa no hex) e texto claro.
   Contraste AA conferido em tests/test_design_system.py (fórmula WCAG, a partir destes valores). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #ECEDEA;
    --bg: #16181B;
    --card: #1F2124;
    --line: #2C2F33;
    --soft: #272A2E;
    --muted: #A4A8AE;
    --sage: #9DB89A;
    --forest: #93C29A;
    --ok-bg: #9DB89A26;
    --amber: #E9C27C;
    --amber-bg: #E3A53A29;
    --red: #F2A497;
    --red-bg: #E0614F2E;
    --on-ink: #D5D5D1;
    --on-ink-strong: #EDEDEA;
    --on-ink-muted: #A9AAA6;
    --field: #4A4F56;
    --forest-hover: #ABD2B0;
    --disabled-bg: #33363B;
    --disabled-text: #A9ADB3;
    --track: #2C2F33;
    --sug-bg: #232C26;
    --sug-line: #4F6B53;
    --amber-line: #5A4724;
    --on-forest: #12201A;
    --graphite: #0F1113;
    --h1: #2D4A35;
    --h2: #41704C;
    --h3: #5E9369;
    --h4: #7AAE83;
    --h5: #93C29A;
    --on-h3: #12201A;
  }
}
/* A escolha "Dark" do topo: os mesmos tokens de cima (tests/test_design_system.py confere). */
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #ECEDEA;
  --bg: #16181B;
  --card: #1F2124;
  --line: #2C2F33;
  --soft: #272A2E;
  --muted: #A4A8AE;
  --sage: #9DB89A;
  --forest: #93C29A;
  --ok-bg: #9DB89A26;
  --amber: #E9C27C;
  --amber-bg: #E3A53A29;
  --red: #F2A497;
  --red-bg: #E0614F2E;
  --on-ink: #D5D5D1;
  --on-ink-strong: #EDEDEA;
  --on-ink-muted: #A9AAA6;
  --field: #4A4F56;
  --forest-hover: #ABD2B0;
  --disabled-bg: #33363B;
  --disabled-text: #A9ADB3;
  --track: #2C2F33;
  --sug-bg: #232C26;
  --sug-line: #4F6B53;
  --amber-line: #5A4724;
  --on-forest: #12201A;
  --graphite: #0F1113;
  --h1: #2D4A35;
  --h2: #41704C;
  --h3: #5E9369;
  --h4: #7AAE83;
  --h5: #93C29A;
  --on-h3: #12201A;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* A página é uma coluna: a faixa da demo (quando há) tem a altura do próprio texto, e o layout ocupa o resto. */
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 500 14px/1.5 Manrope, system-ui, sans-serif;
}
a { color: inherit; }
img, svg { max-width: 100%; }
:focus-visible { outline: 2px solid var(--forest); outline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
p { margin: 0; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Marca */
.wm { font-weight: 800; letter-spacing: -0.02em; text-decoration: none; }
.wm span { color: var(--forest); }

/* Faixa da demo */
.demo-banner {
  background: var(--amber-bg);
  color: var(--amber);
  border-bottom: 1px solid var(--amber-line);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

/* Área logada: o topo e, embaixo, a coluna do conteúdo. */
.shell { flex: 1 0 auto; display: flex; flex-direction: column; min-width: 0; }

/* Topo (spec 6.2): barra grafite nos dois temas com o wordmark, o módulo, o tema e o menu do avatar. Os menus são
   <details>, sem JavaScript; o que abre é uma camada com borda (sem sombra, The Flat Rule). */
.topbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 56px;
  padding: 8px 22px;
  background: var(--graphite);
  color: var(--on-ink);
}
.topbar :focus-visible { outline-color: var(--sage); }
.topbar .wm { font-size: 19px; color: var(--on-ink-strong); white-space: nowrap; }
.topbar .wm span { color: var(--sage); }
.topbar summary { list-style: none; cursor: pointer; }
.topbar summary::-webkit-details-marker { display: none; }
.modulo { position: relative; }
.modulo summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--on-ink-strong);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.modulo summary::after { content: ""; width: 6px; height: 6px; margin-top: -3px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); opacity: 0.7; }
.modulo summary:hover, .theme-icon:hover { background: rgba(255, 255, 255, 0.14); }
.modulo p {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 240px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--muted);
  font-size: 13px;
}
/* Tema: só o ícone do tema oposto ao da tela. Sem cookie vêm os dois, e o do tema do sistema some aqui. */
.theme { margin-left: auto; display: flex; }
.theme-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--on-ink-strong);
  cursor: pointer;
}
:root:not([data-theme]) .to-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .to-dark { display: none; }
  :root:not([data-theme]) .to-light { display: inline-flex; }
}
/* Avatar: as iniciais num círculo sálvia (o mesmo par sálvia/grafite do wordmark); o menu abre embaixo, à direita. */
.avatar { position: relative; }
.avatar summary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--sage);
  color: var(--graphite);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.avatar-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 260px;
  max-width: calc(100vw - 32px);
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
}
.avatar-menu :focus-visible { outline-color: var(--forest); }
.avatar-who { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 10px; border-bottom: 1px solid var(--soft); overflow-wrap: anywhere; }
.avatar-who b { font-weight: 700; }
.avatar-who span { color: var(--muted); font-size: 13px; }
.avatar-menu form { margin: 0; }
.avatar-menu form:last-child { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--soft); }
.avatar-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.avatar-item:hover { background: var(--soft); }
/* Celular: o módulo sai; ficam o wordmark, o tema e o avatar, sem passar da largura. */
@media (max-width: 640px) {
  .topbar { gap: 10px; padding: 8px 16px; }
  .topbar .modulo { display: none; }
  .topbar .wm { font-size: 18px; }
}

/* Coluna do conteúdo: o <main> cresce e o rodapé (contentinfo, fora do <main>) fica no fim. */
.content { min-width: 0; display: flex; flex-direction: column; }
.main { flex: 1 0 auto; padding: 24px 28px 0; min-width: 0; display: flex; flex-direction: column; }
.content > .foot { padding: 16px 28px 20px; }

/* Caminho de volta das telas internas ("← Bookkeeping"), a primeira linha do conteúdo: alvo de 24px de altura. */
.back { align-self: flex-start; margin: 0 0 8px; padding: 4px 0; color: var(--muted); font-size: 13px; font-weight: 600; text-decoration: none; }
.back:hover { color: var(--ink); text-decoration: underline; }

/* Cabeçalho de página: trilha, título, subtítulo, ação principal */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.crumb { margin: 0 0 4px; color: var(--muted); font-size: 13px; }
.crumb a { text-decoration: none; }
.crumb a:hover { text-decoration: underline; }
.page-head h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.015em; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.head-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
h2 { font-size: 16px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }

/* Botões e links de ação */
.btn, .btn-secondary {
  display: inline-block;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  border-radius: 8px;
  padding: 9px 14px;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.btn { color: var(--on-forest); background: var(--forest); border: 1px solid var(--forest); }
.btn:hover { background: var(--forest-hover); border-color: var(--forest-hover); }
.btn-secondary { color: var(--ink); background: var(--card); border: 1px solid var(--field); }
.btn-secondary:hover { background: var(--soft); }
.btn:disabled, .btn[aria-disabled="true"] {
  background: var(--disabled-bg);
  border-color: var(--disabled-bg);
  color: var(--disabled-text);
  cursor: not-allowed;
}
.btn-block { display: block; width: 100%; text-align: center; padding: 12px 16px; font-size: 15px; }
.link {
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--forest);
  background: none;
  border: 0;
  padding: 4px 0;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.link:hover { text-decoration: underline; }

/* Cartões de indicadores */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 13px 16px; }
.kpi .v { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .k { color: var(--muted); font-size: 13px; }
.meter { height: 6px; margin-top: 8px; border-radius: 9px; overflow: hidden; background: var(--track); }
.meter i { display: block; height: 100%; background: var(--forest); }
/* A mesma barra num <progress> (quadro de fechamentos): sem largura em `style=""`, o navegador desenha o valor. */
progress.meter { display: block; width: 100%; border: 0; -webkit-appearance: none; appearance: none; background: var(--track); color: var(--forest); }
progress.meter::-webkit-progress-bar { background: var(--track); }
progress.meter::-webkit-progress-value { background: var(--forest); }
progress.meter::-moz-progress-bar { background: var(--forest); }

/* Cartão */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px 12px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 8px 0 10px; }
.card-head small { color: var(--muted); font-size: 13px; }
.card-pad { padding: 20px 22px; }
.narrow { max-width: 760px; }

/* Lista de extratos (quadro de fechamentos) */
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) auto auto;
  gap: 10px 16px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--soft);
}
.rows > li:last-child { border-bottom: 0; }
.row-title { display: block; font-weight: 700; overflow-wrap: anywhere; }
.rows .m { overflow-wrap: anywhere; }
.empty { padding: 16px 0 12px; }
.empty h3 { margin: 0 0 4px; }

/* Envio do extrato (quadro) */
.upload-form { margin-top: 16px; }
.upload-note { margin: 14px 0 0; }

/* Extrato: linha de fatos (período, saldos, PDF original) e aprovação no cabeçalho */
.facts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin: -6px 0 16px; color: var(--muted); font-size: 13px; }
.facts b { color: var(--ink); font-weight: 700; }
.facts .link { font-size: 13px; padding: 0; }
.approve { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; margin: 0; }
.approve .hint { margin: 0; }

/* Tabela: rola na horizontal dentro do cartão, nunca a página */
/* `position: relative` faz o recorte valer também para o que é absoluto lá dentro (ex.: `.visually-hidden`). */
.scroll { position: relative; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  padding: 10px 8px 9px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
td { padding: 10px 8px; border-bottom: 1px solid var(--soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tr.selected td { background: var(--sug-bg); }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.m { color: var(--muted); font-size: 13px; }
.why { margin-top: 2px; color: var(--muted); font-size: 12px; }
/* "Also apply to the N other lines like this", embaixo do motivo da linha pendente. */
.similar { display: flex; align-items: center; gap: 6px; margin: 6px 0 0; color: var(--ink); font-size: 12px; font-weight: 600; cursor: pointer; }
/* Revisão em tabela: largura mínima para conta e vendor; no celular a tabela rola dentro do `.scroll`. */
.table-review { min-width: 960px; }
.table-review td .sel { min-width: 190px; }
.table-review td.desc { min-width: 220px; overflow-wrap: anywhere; }
.table-review td.status { white-space: nowrap; }
.table-review td.status form { display: inline; margin: 0 0 0 10px; }
.col-select { width: 34px; }
/* Reconciliação do extrato bloqueado: rótulo da linha em texto de corpo e a diferença fora do zero destacada. */
.table-rec { min-width: 560px; }
.table-rec tbody th {
  padding: 10px 8px;
  border-bottom: 1px solid var(--soft);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}
.table-rec tbody tr:last-child th { border-bottom: 0; }
.table-rec td.off { background: var(--red-bg); color: var(--red); }
.swipe { display: none; margin: 0 0 6px; color: var(--muted); font-size: 12px; }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 16px; padding: 10px 4px 2px; border-top: 1px solid var(--soft); }
.nw { white-space: nowrap; }

/* Etiqueta de status: Reconciled, In review, Blocked, Auto, Approved */
.chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--soft);
  color: var(--muted);
}
.chip-ok { background: var(--ok-bg); color: var(--forest); }
.chip-review { background: var(--amber-bg); color: var(--amber); }
.chip-blocked { background: var(--red-bg); color: var(--red); }

/* Filtros em pílulas */
.tabs { display: flex; gap: 6px; margin: 0 0 12px; overflow-x: auto; padding-bottom: 2px; }
.tab {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-current], .tab[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--card); }

/* Formulários e seletor */
label { display: block; margin: 0 0 6px; font-size: 13px; font-weight: 700; }
input[type="text"], input[type="email"], input[type="password"], select, .sel {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--field);
  border-radius: 8px;
  padding: 10px 12px;
}
input:focus-visible, select:focus-visible { outline: 2px solid var(--forest); outline-offset: 1px; border-color: var(--forest); }
.field { margin: 0 0 16px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.hint { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
td .sel, td select { font-size: 14px; padding: 7px 9px; min-width: 160px; }
.sel.sug { background: var(--sug-bg); border-color: var(--sug-line); }
/* Lista da busca de conta (`review.js`): presa à janela, para a tabela que rola de lado não a cortar. */
.busca-lista {
  position: fixed;
  z-index: 40;
  max-width: calc(100vw - 16px);
  margin: 0;
  padding: 4px;
  overflow-y: auto;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font-size: 14px;
}
.busca-lista[hidden] { display: none; }
.busca-lista li { padding: 7px 10px; border-radius: 6px; cursor: pointer; overflow-wrap: anywhere; }
/* O tipo do QuickBooks à direita do nome, como na lista de contas do QuickBooks. */
.busca-lista li[role="option"]:has(.busca-tipo) { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.busca-lista .busca-tipo { flex: none; color: var(--muted); font-size: 13px; white-space: nowrap; }
.busca-lista li[aria-selected="true"], .busca-lista li[role="option"]:not([aria-disabled]):hover { background: var(--sug-bg); }
.busca-lista .busca-vazia { color: var(--muted); cursor: default; }
/* Campo recusado na gravação da revisão (`review.js`): borda e anel na cor de erro. */
.sel[aria-invalid="true"], .row-select[aria-invalid="true"] { border-color: var(--red); box-shadow: 0 0 0 2px var(--red-bg); outline: 2px solid var(--red); outline-offset: 1px; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--forest); }
.field-check label { display: flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; }
.field-check .hint { margin-left: 28px; }

/* Cadastro: seção do formulário e arquivos. O seletor é um rótulo-botão (`.pick`) com o `input` nativo transparente
   dentro: o texto do nativo viria no idioma do navegador. Sem JavaScript, o estado escolhido vem do `:valid` do campo
   obrigatório: a linha fica destacada, "no file chosen" vira "PDF chosen" e "Choose PDF" vira "Replace". */
.form-section { margin: 8px 0 12px; padding-top: 18px; border-top: 1px solid var(--soft); }
.form-section .hint { margin-top: 2px; font-size: 14px; }
.files { display: grid; gap: 8px; }
.file {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 14px;
}
.file b { display: block; font-size: 14px; }
.file .m { display: block; }
.pick {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 7px 12px;
  border: 1px solid var(--field);
  border-radius: 8px;
  background: var(--card);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.pick:hover { background: var(--soft); }
.pick input { position: absolute; width: 1px; height: 1px; margin: 0; padding: 0; border: 0; opacity: 0; overflow: hidden; }
.pick:has(input:focus-visible) { outline: 2px solid var(--forest); outline-offset: 2px; }  /* só com o teclado */
.file .when-chosen { display: none; }
.file:has(input:required:valid) { background: var(--sug-bg); border-color: var(--sug-line); }
.file:has(input:required:valid) .when-empty { display: none; }
.file:has(input:required:valid) .when-chosen { display: inline; }
.file:has(input:required:valid) .m .when-chosen { color: var(--forest); font-weight: 600; }
.pick-native { max-width: 100%; font-size: 14px; }
.actions { display: flex; align-items: center; gap: 12px; margin-top: 20px; flex-wrap: wrap; }

/* Memória: nota do cartão e a chave do padrão */
.intro { max-width: 760px; margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.key { font-weight: 700; letter-spacing: 0.01em; }
.table-memory { min-width: 760px; }

/* Modelos de plano de contas: lista (nome e tipo de estabelecimento, contas, autor e data), abas da origem e a lista
   de erros por linha dentro do aviso. */
.template-list { list-style: none; margin: 0; padding: 0; }
.template-list > li {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 0.7fr) minmax(0, 1.1fr);
  gap: 4px 16px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--soft);
}
.template-list > li:last-child { border-bottom: 0; }
.template-list .m { overflow-wrap: anywhere; }
.count { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.source-tabs { flex-wrap: wrap; overflow: visible; margin: 16px 0; padding-bottom: 0; }  /* duas abas: quebram, não rolam */
.card-pad > .source-tabs:first-child { margin-top: 0; }  /* abas no topo do cartão (Add company) */
.row-errors { margin: 8px 0 0; padding-left: 18px; font-weight: 500; overflow-wrap: anywhere; }
.row-errors li + li { margin-top: 2px; }
.alert .row-errors + p { margin-top: 8px; }
.types { margin-top: 12px; }
/* Plano de contas da empresa: a mesma lista, com o nome (e o caminho Pai:Filho) e o tipo do QuickBooks. */
.account-list > li { grid-template-columns: minmax(0, 1fr) minmax(0, 13em); }
.account-form { margin-top: 18px; }
.types summary { display: inline-block; padding: 0; font-size: 13px; }
.types ul { columns: 2; gap: 16px; margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }

/* Confirmação em duas etapas (details/summary) */
details summary { list-style: none; cursor: pointer; }
details summary::-webkit-details-marker { display: none; }
.confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.confirm p { flex-basis: 100%; color: var(--muted); font-size: 13px; }
/* Renomear vendor e editar conta: o formulário abre na própria linha, embaixo do nome que ele muda. */
.row-edit { margin-top: 4px; }
.row-edit > summary { display: inline-block; font-size: 13px; }
.row-edit > form { margin-top: 10px; max-width: 40em; }
.row-edit .field { margin-bottom: 10px; }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* Barra fixa de ação em massa. Ela vem depois do cartão da tabela, dentro de `.with-bulk`: enquanto a tabela rola,
   fica colada no fim da tela; no fim da lista, volta ao lugar dela, abaixo da última linha (que nunca fica coberta).
   O `padding-bottom` reserva o respiro entre a barra e o que vem depois (o rodapé ou o próximo cartão). */
.with-bulk { padding-bottom: 24px; margin-bottom: 16px; }
.with-bulk > .card { margin-bottom: 0; }
.bulk {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 16px;
  margin-top: 12px;
  padding: 10px 10px 10px 16px;
  border-radius: 10px;
  background: var(--graphite);
  color: var(--on-ink-strong);
}
.bulk :focus-visible { outline-color: var(--sage); }
.bulk-all { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; font-weight: 600; cursor: pointer; }
.bulk-note { flex: 1; color: var(--on-ink); font-size: 13px; }
.bulk .btn:disabled { border-color: var(--disabled-bg); }
/* Região de status (`role="status"`): sempre no documento, para o leitor de tela anunciar a mensagem. Vazia, sai da
   vista com o recorte do `.visually-hidden` (sem `display: none`, que a tiraria da árvore de acessibilidade), e a
   barra não fica com uma linha vazia; com mensagem, ocupa a linha inteira em 14px. */
.bulk-feedback { flex-basis: 100%; margin: -4px 0 0; color: var(--on-ink-strong); font-size: 14px; font-weight: 600; line-height: 1.4; }
.bulk-feedback:empty {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
/* Com mensagem, é um alerta (`.alert`) dentro da barra: sem a margem de baixo dos alertas da página. */
.bulk-feedback.alert { margin: 0; }
/* Página do lote em revisão: ao andar por Tab, o navegador para o campo focado acima da barra fixa. */
html:has(.with-bulk) { scroll-padding-bottom: 96px; }

/* Avisos: informação, atenção, erro */
.alert { margin: 0 0 16px; padding: 11px 14px; border-radius: 10px; background: var(--soft); color: var(--ink); font-size: 14px; }
.alert-warn { background: var(--amber-bg); color: var(--amber); font-weight: 600; }
.alert-error { background: var(--red-bg); color: var(--red); font-weight: 600; }
.alert a { font-weight: 700; }

/* Conteúdo centralizado (erro) */
.center { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px 0; }
.error-card { width: 100%; max-width: 520px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 26px 28px; }
.error-card h1 { margin: 0 0 14px; font-size: 22px; font-weight: 700; letter-spacing: -0.015em; }
.error-card .alert { margin-bottom: 14px; padding: 12px 14px; font-size: 15px; }
.help { color: var(--muted); font-size: 14px; }

/* Tabela de arquivos da demo: grupos, ordem de envio e nome do arquivo */
.group-head th {
  padding: 16px 8px 8px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  white-space: normal;
}
.group-head strong { display: block; font-size: 15px; }
.group-head span { color: var(--muted); font-size: 13px; }
.col-order { width: 44px; }
.table-files { min-width: 760px; }
/* Aba Documents: os anos como abas pequenas no cabeçalho do cartão. */
.years { display: flex; flex-wrap: wrap; gap: 4px; }
.years .tab { padding: 4px 10px; font-size: 13px; }
/* Razão do mês (aba Ledger): uma seção por conta, como o General Ledger do QuickBooks. */
.table-ledger { min-width: 900px; }
.table-ledger td.desc { min-width: 220px; overflow-wrap: anywhere; }
/* Nome da conta e linha de total: texto normal, não o rótulo pequeno em maiúsculas do `th` do cabeçalho. */
.table-ledger tbody th, .table-ledger tfoot th { color: var(--ink); font-size: 14px; letter-spacing: normal; text-transform: none; white-space: normal; }
.table-ledger .ledger-account th { background: var(--soft); font-weight: 700; padding-top: 12px; }
.table-ledger .ledger-total th, .table-ledger .ledger-total td { font-weight: 600; border-bottom: 0; }
.table-ledger .ledger-total th { text-align: right; }
.table-ledger tfoot .ledger-total th, .table-ledger tfoot .ledger-total td { border-top: 2px solid var(--line); }
.ledger-note { margin: 0; padding: 12px 20px; color: var(--muted); border-bottom: 1px solid var(--line); }
.step {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--card);
  font-size: 12px;
  font-weight: 700;
}
.fname { font-weight: 600; white-space: nowrap; }
.right { text-align: right; white-space: nowrap; }

/* Rodapé */
.foot { margin-top: auto; padding: 16px 0 4px; color: var(--muted); font-size: 12px; text-align: center; }

/* Área de acesso: painel grafite com o wordmark + formulário */
.access { flex: 1 0 auto; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
.panel {
  background: var(--graphite);
  color: var(--on-ink-strong);
  padding: 44px 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}
.panel .wm { font-size: 44px; line-height: 1; }
.panel .wm span { color: var(--sage); }
/* Selo do modo piloto, dentro do wordmark: sempre sobre o grafite (topo e painel de acesso), nos dois temas; sálvia
   sobre grafite passa AA nos dois. Discreto: contorno, sem preenchimento. */
.topbar .wm .badge-pilot, .panel .wm .badge-pilot {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border: 1px solid currentColor;
  border-radius: 999px;
  color: var(--sage);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.4;
  vertical-align: middle;
}
.panel .line { color: var(--on-ink); font-size: 16px; font-weight: 600; }
.side { display: flex; flex-direction: column; padding: 40px 32px 18px; }
.side .center { padding: 0; }
.access-form { width: 100%; max-width: 380px; }
.access-form h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 6px; }
.lead { margin: 0 0 24px; color: var(--muted); font-size: 15px; }
.small { margin: 16px 0 0; color: var(--muted); font-size: 13px; text-align: center; }
/* Cadastro do 2FA (piloto): os passos, o QR (o SVG já traz o fundo branco e a margem do QR, legível nos dois temas)
   e a chave em texto, em grupos de 4, que pode quebrar no celular. */
.setup-step { margin: 0 0 10px; font-size: 15px; font-weight: 600; }
.qr { width: 200px; max-width: 100%; margin: 0 0 12px; }
.qr svg { display: block; width: 100%; height: auto; border-radius: 8px; }
.secret { font-weight: 700; letter-spacing: 0.06em; color: var(--ink); overflow-wrap: anywhere; }
.access-form > .hint { margin: 0 0 18px; }

/* Tablet e celular: o conteúdo com o respiro de 16px */
@media (max-width: 900px) {
  .topbar { padding: 8px 16px; }
  .main { padding: 18px 16px 0; }
  .content > .foot { padding: 16px 16px 12px; }
  .page-head { flex-wrap: wrap; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .fields { grid-template-columns: 1fr; }
  .template-list > li { grid-template-columns: minmax(0, 1fr); }
  .types ul { columns: 1; }
  .rows > li { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
  .rows > li > :nth-child(2), .rows > li > .chip { grid-column: 1; }
  .rows > li > .chip { justify-self: start; }
  .rows > li > .link { grid-column: 2; grid-row: 1 / span 3; }
  .head-actions { width: 100%; }
  .head-actions > .btn:only-child { width: 100%; text-align: center; }
  .approve { width: 100%; align-items: stretch; }
  .approve .btn { width: 100%; text-align: center; }
  .approve .hint { text-align: center; }
  .swipe { display: block; }
  /* Quadro no celular (mockup 10): os três indicadores lado a lado, com rótulo de 12px. */
  .kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpis-3 .kpi { padding: 10px; }
  .kpis-3 .kpi .v { font-size: 20px; }
  .kpis-3 .kpi .k { font-size: 12px; line-height: 1.35; }
  .bulk-note { display: none; }
  .card-pad { padding: 16px; }
  .error-card { padding: 20px; }
  .access { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .panel { padding: 28px 24px; }
  .panel .wm { font-size: 32px; }
  .side { padding: 32px 16px 18px; }
}

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

/* Companies e página da empresa (Bookkeeping, T4) */
.filters { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) auto; gap: 0 12px; align-items: end; }
.table-companies { min-width: 720px; }
.table-companies td { vertical-align: top; }
.months { list-style: none; margin: 0; padding: 0 0 4px; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.month { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.month-open { background: var(--soft); border-style: dashed; }
/* Fatura de cartão do mês, abaixo da corrente (uma linha por cartão). */
.month-card { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; width: 100%; padding-top: 6px; border-top: 1px solid var(--line); font-size: 13px; }
.chip-missing { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.chip-history { background: var(--ok-bg); color: var(--forest); }
@media (max-width: 720px) {
  .filters { grid-template-columns: minmax(0, 1fr); }
}

/* Settings da empresa (protótipo 11): a ficha no estilo do QuickBooks. Verde = veio dos documentos; âmbar = falta. */
.settings-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.settings-form { padding: 22px 24px; }
.settings-form h2 { font-size: 16px; margin: 0 0 4px; }
.settings-form > p { margin: 0 0 18px; color: var(--muted); }
.set-row { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 14px; align-items: center; padding: 7px 0; }
.set-row > label { font-weight: 600; text-align: right; color: var(--ink); }
.set-row > label em { color: var(--red); font-style: normal; margin-left: 2px; }
.set-field { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.set-field input, .set-field select { flex: 1 1 160px; min-width: 0; }
.set-field input.found, .set-field select.found { background: var(--sug-bg); border-color: var(--sug-line); }
.set-field input.missing, .set-field select.missing { border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-bg); }
.set-pair { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 10px; align-items: center; }
.set-pair > span { font-weight: 600; }
.set-src { font-size: 12px; font-weight: 600; color: var(--forest); white-space: nowrap; }
.set-note { font-size: 12px; font-weight: 600; color: var(--amber); white-space: nowrap; }
.set-foot { display: flex; justify-content: flex-end; gap: 10px; padding-top: 14px; }
.set-aside h3 { margin: 0 0 4px; font-size: 15px; }
.set-aside ul { margin: 10px 0 0; padding-left: 18px; }
.set-aside li { margin: 4px 0; }
@media (max-width: 900px) {
  .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .set-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .set-row > label { text-align: left; }
  .set-pair { grid-template-columns: minmax(0, 1fr); }
}

/* Closings por mês (spec 3.2): trilho dos 12 meses e legenda; as cores são os tokens de estado. */
.table-closings { min-width: 760px; }
.table-closings td { vertical-align: middle; }
.filters-closings { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto; }
.rail { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; min-width: 250px; }
.rail i { display: block; height: 22px; border-radius: 5px; background: var(--track); position: relative; }
.rail i.rail-approved, .legend i.rail-approved { background: var(--sage); }
.rail i.rail-review, .legend i.rail-review { background: var(--amber-bg); box-shadow: inset 0 0 0 1.5px var(--amber); }
.rail i.rail-blocked, .legend i.rail-blocked { background: var(--red-bg); box-shadow: inset 0 0 0 1.5px var(--red); }
.rail i.rail-processing, .legend i.rail-processing { background: var(--card); box-shadow: inset 0 0 0 1.5px var(--muted); }
.rail i.rail-history, .legend i.rail-history { background: var(--ok-bg); box-shadow: inset 0 0 0 1.5px var(--sage); }
.rail i.now::after { content: ""; position: absolute; left: 50%; bottom: -7px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--ink); }
.railhead { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; font-size: 12px; color: var(--muted); font-weight: 700; text-align: center; min-width: 250px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 12.5px; color: var(--muted); padding: 12px 4px 4px; border-top: 1px solid var(--line); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -2px; background: var(--track); }

/* Charts of accounts (detalhe): contas por tipo, a subconta indentada pelo nível, e a tabela do resultado da importação */
.grp { padding: 12px 0 4px; }
.grp h3 { margin: 0 0 4px; font-size: 14px; color: var(--muted); }
.acct-list, .plain-list { list-style: none; margin: 0; padding: 0; }
.acct-list > li { padding: 7px 0; border-bottom: 1px solid var(--soft); overflow-wrap: anywhere; }
.acct-list > li.level-1 { padding-left: 20px; }
.acct-list > li.level-2 { padding-left: 40px; }
.acct-list > li.level-3 { padding-left: 60px; }
.acct-list > li.level-4 { padding-left: 80px; }
.acct-list > li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; }
.acct-num { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 700; margin-right: 2px; }
.acct-desc { order: 2; flex-basis: 100%; font-size: 12.5px; }
.acct-edit { order: 1; margin-left: auto; font-size: 13px; }
.remove-account { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.plain-list > li { padding: 6px 0; }
.table-import { min-width: 480px; }
.table-import td { overflow-wrap: anywhere; }

/* New bookkeeping (módulo Bookkeeping, 4.1): passos, zona de soltar e tabela de arquivos */
.steps { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; padding: 0; list-style: none; font-size: 13px; font-weight: 700; color: var(--muted); }
.steps li { padding: 6px 12px; border-radius: 999px; background: var(--soft); }
.steps li.on { background: var(--forest); color: var(--on-forest); }
.drop { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 0 0 16px; padding: 36px 24px; text-align: center; border: 2px dashed var(--field); border-radius: 16px; background: var(--card); }
.drop:hover, .drop:focus-within { border-color: var(--forest); background: var(--sug-bg); }
.drop-title { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.drop-note { max-width: 560px; color: var(--muted); font-size: 14px; }
.for-company { margin: 0 0 14px; font-size: 14px; }
.files td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.files tr.skipped td { color: var(--muted); }
.match { margin: 0 0 14px; font-size: 14px; }
.card-pad h2 { margin: 0 0 10px; font-size: 16px; font-weight: 700; }
form.card + form.card, section.card + form.card { margin-top: 0; }
@media (max-width: 640px) { .steps { flex-direction: column; } }

/* ---------- Aba Documents: o quadro do ano (`documentos.quadro`), a lista e o envio ---------- */
.yr-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0 12px; flex-wrap: wrap; }
.yr-head h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; }
.yr-wrap { position: relative; overflow-x: auto; padding-bottom: 4px; }
.yr-matrix { width: 100%; min-width: 720px; border-collapse: collapse; table-layout: fixed; }
.yr-matrix th, .yr-matrix td { height: 40px; padding: 0; text-align: center; border-top: 1px solid var(--soft); }
.yr-matrix thead th, .yr-matrix thead td { height: 28px; border-top: 0; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: normal; text-transform: none; }
.yr-matrix abbr { text-decoration: none; }
.yr-matrix thead td:first-child, .yr-matrix tbody th { width: 170px; }
/* o nome da linha fica parado à esquerda quando o quadro rola de lado */
.yr-matrix tbody th, .yr-matrix thead td:first-child { position: sticky; left: 0; z-index: 1; background: var(--card); }
.yr-matrix tbody th { padding-right: 12px; text-align: left; font-size: 13px; font-weight: 600; color: var(--ink); letter-spacing: normal; text-transform: none; white-space: nowrap; }
.yr-matrix tbody th small { margin-left: 6px; color: var(--muted); font-weight: 500; font-size: 12px; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .yr-matrix { width: 592px; min-width: 592px; } .yr-matrix thead td:first-child, .yr-matrix tbody th { width: 112px; } .yr-matrix tbody th { font-size: 12px; } }

.yr-cell { position: relative; width: 26px; height: 26px; margin: 0 auto; border-radius: 7px; display: grid; place-items: center; text-decoration: none; }
.yr-cell svg { width: 13px; height: 13px; }
.yr-on { background: var(--forest); color: var(--on-forest); }
a.yr-on:hover { background: var(--forest-hover); }
.yr-miss { border: 1.5px dashed var(--field); }
.yr-review { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-line); }
.yr-cell:focus-visible, .yr-span:focus-visible, .yr-pill:focus-visible { outline: 2px solid var(--forest); outline-offset: 2px; }
.yr-n { position: absolute; top: -7px; right: -8px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--card); color: var(--forest); border: 1px solid var(--sug-line); font-size: 10px; font-weight: 700; line-height: 14px; }
.yr-dot { display: inline-block; width: 5px; height: 5px; border-radius: 999px; background: var(--line); vertical-align: middle; }
/* um arquivo que cobre vários meses (o General Ledger do ano até a data) */
.yr-span { display: flex; align-items: center; gap: 8px; height: 26px; margin: 0 6px; padding: 0 10px; border-radius: 7px; background: var(--ok-bg); color: var(--forest); border: 1px solid var(--sug-line); font-size: 12px; font-weight: 600; text-decoration: none; white-space: nowrap; overflow: hidden; }
.yr-span:hover { background: var(--sug-bg); }
.yr-span svg { flex: none; width: 13px; height: 13px; }

.yr-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 14px 0 2px; color: var(--muted); font-size: 12px; }
.yr-legend span { display: inline-flex; align-items: center; gap: 7px; }
.yr-legend .yr-cell { width: 14px; height: 14px; margin: 0; border-radius: 4px; }
.yr-files { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; padding: 12px 0 4px; border-top: 1px solid var(--soft); font-size: 13px; }
.yr-files > span { color: var(--muted); margin-right: 4px; }
.yr-pill { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 5px 10px 5px 8px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); text-decoration: none; font-weight: 600; }
.yr-pill small { color: var(--muted); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.yr-pill:hover { border-color: var(--field); background: var(--soft); }
.yr-pill svg { flex: none; width: 14px; height: 14px; color: var(--forest); }

.docs-cols { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.docs-cols > .docs-side:only-child { grid-column: 2; }
.docs-side { position: sticky; top: 16px; }
@media (max-width: 1080px) { .docs-cols { grid-template-columns: minmax(0, 1fr); } .docs-cols > .docs-side:only-child { grid-column: auto; } .docs-side { position: static; } }
.doc-group { border-top: 1px solid var(--soft); }
.doc-group:first-of-type { border-top: 0; }
.doc-group > summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 10px; padding: 12px 2px; }
.doc-group > summary::-webkit-details-marker { display: none; }
.doc-group > summary::before { content: ""; align-self: center; width: 7px; height: 7px; margin-right: 2px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; }
.doc-group[open] > summary::before { transform: rotate(45deg); }
.doc-group > summary strong { font-size: 14px; }
.doc-group > summary small { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.doc-group > summary:focus-visible { outline: 2px solid var(--forest); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { .doc-group > summary::before { transition: none; } }
.doc-list { list-style: none; margin: 0 0 8px; padding: 0; }
.doc-list li { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto auto; gap: 14px; align-items: center; padding: 9px 2px 9px 20px; border-top: 1px solid var(--soft); font-size: 14px; }
.doc-mes { color: var(--muted); font-size: 13px; }
.doc-nome b, .doc-nome small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-nome b { font-weight: 600; }
.doc-nome small { color: var(--muted); font-size: 12px; }
.doc-quando { color: var(--muted); font-size: 12px; text-align: right; }
.doc-list .link { white-space: nowrap; }
.doc-acoes { display: flex; gap: 14px; justify-content: flex-end; }
@media (max-width: 560px) { .doc-list li { grid-template-columns: 44px minmax(0, 1fr) auto; padding-left: 4px; } .doc-quando { display: none; } }
.docs-envio { display: grid; justify-items: center; gap: 4px; padding: 20px 16px 8px; text-align: center; border: 1.5px dashed var(--sug-line); border-radius: 12px; background: var(--sug-bg); }
.docs-envio > svg { width: 30px; height: 30px; color: var(--forest); }
.docs-envio > p { margin: 0 0 6px; color: var(--muted); font-size: 13px; }
.docs-envio .field { width: 100%; min-width: 0; text-align: left; }
.docs-envio input[type="file"] { width: 100%; min-width: 0; font-size: 13px; }
.docs-side .hint { margin: 12px 0 0; }
.docs-opcoes { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--soft); }
.docs-opcoes summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--forest); }
.docs-opcoes .field { margin-top: 10px; }
.docs-salvar { margin-top: 16px; width: 100%; }

/* ---------- View ledger de um mês do histórico (`historico.html`) ---------- */
.gl-fonte { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.gl-meses { display: flex; gap: 6px; }
.gl-meses a { white-space: nowrap; }
.gl-figuras { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0 0 16px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.gl-figuras.gl-duas { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.gl-figuras div { padding: 14px 18px; border-left: 1px solid var(--soft); }
.gl-figuras div:first-child { border-left: 0; }
.gl-figuras dt { color: var(--muted); font-size: 12px; font-weight: 600; }
.gl-figuras dd { margin: 4px 0 0; font-size: 22px; font-weight: 800; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.gl-figuras .gl-entra dd { color: var(--forest); }
@media (max-width: 760px) { .gl-figuras { grid-template-columns: repeat(2, minmax(0, 1fr)); } .gl-figuras div:nth-child(3) { border-left: 0; } .gl-figuras div:nth-child(n+3) { border-top: 1px solid var(--soft); } }
.table-gl { min-width: 900px; }
.table-gl td.split { white-space: nowrap; }
.table-gl td.tipo { color: var(--muted); }
.table-gl .gl-conta th { background: var(--soft); font-weight: 700; color: var(--ink); font-size: 14px; letter-spacing: normal; text-transform: none; }
.table-gl .gl-conta th span { color: var(--muted); font-weight: 500; }
.table-gl .gl-abre td { color: var(--muted); }
.table-gl tfoot th, .table-gl tfoot td { font-weight: 700; border-top: 2px solid var(--line); color: var(--ink); font-size: 14px; letter-spacing: normal; text-transform: none; }
.gl-barra { height: 6px; min-width: 80px; border-radius: 999px; background: var(--track); overflow: hidden; }
.gl-barra i { display: block; height: 100%; background: var(--sage); }

/* ---------- Painel inicial (spec 6.3, protótipo v7): chave de escritório, botões, esteira, anéis e mapa do ano ---------- */
.painel-head { align-items: flex-end; flex-wrap: wrap; }
.seg { display: flex; flex-wrap: wrap; gap: 2px; max-width: 100%; padding: 3px; border-radius: 10px; background: var(--track); }
.seg a { display: inline-flex; align-items: center; min-height: 28px; padding: 4px 11px; border-radius: 8px; color: var(--muted); font-size: 13px; font-weight: 600; text-decoration: none; }
.seg a:hover { color: var(--ink); }
.seg a[aria-current] { background: var(--forest); color: var(--on-forest); }
.seg a:focus-visible { outline-offset: 1px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 14px; margin: 0 0 16px; }
.tile { position: relative; display: flex; flex-direction: column; gap: 4px; min-width: 0; min-height: 118px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); text-decoration: none; }
.tile:hover { border-color: var(--forest); }
.tile-ic { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; margin-bottom: 6px; border-radius: 10px; background: var(--soft); color: var(--forest); }
.tile-t { font-size: 15px; font-weight: 700; }
.tile-n { color: var(--muted); font-size: 13px; }
.tile-n b { color: var(--ink); font-weight: 800; font-variant-numeric: tabular-nums; }
.tile-ar { position: absolute; top: 18px; right: 16px; color: var(--muted); font-size: 16px; }
.tile-pri { border-color: var(--forest); background: var(--forest); color: var(--on-forest); }
.tile-pri:hover { border-color: var(--forest-hover); background: var(--forest-hover); }
.tile-pri .tile-ic { background: rgba(255, 255, 255, 0.16); color: var(--on-forest); }
.tile-pri .tile-n, .tile-pri .tile-ar { color: var(--on-forest); }

.painel { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 0 16px; }
.painel-card { padding: 18px 20px; }
.painel-sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

/* Esteira: uma coluna por etapa; a barra cresce de baixo (altura em `style`, a contagem sobre a maior). */
.esteira { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; align-items: start; margin: 16px 0 0; padding: 0; list-style: none; }
.et { display: flex; flex-direction: column; min-width: 0; text-align: center; }
.et-n { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.et-l { display: flex; align-items: flex-end; justify-content: center; min-height: 2.8em; margin: 2px 0 8px; color: var(--muted); font-size: 12px; font-weight: 600; line-height: 1.35; overflow-wrap: normal; hyphens: manual; }
.et-poste { display: flex; align-items: flex-end; height: 120px; border-bottom: 2px solid var(--track); }
.et-poste i { display: block; width: 100%; border-radius: 8px 8px 3px 3px; background: var(--h3); }
.et-missing .et-poste i { background: var(--field); }
.et-blocked .et-poste i { background: var(--red); }
.et-blocked.et-com .et-n { color: var(--red); }
.et-review .et-poste i { background: var(--amber); }
.et-exported .et-poste i { background: var(--h5); }
.et-go { display: inline-flex; align-items: center; justify-content: center; min-height: 24px; margin-top: 6px; color: var(--forest); font-size: 12px; font-weight: 700; text-decoration: none; }
.et-go:hover { text-decoration: underline; }
.auto { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.auto b { color: var(--ink); font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.auto em { color: var(--forest); font-style: normal; font-weight: 700; }

/* Anéis: um por office (o de fora é o primeiro), o total do filtro no miolo; ao lado, as barras com o número. */
.aneis { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 20px; margin-top: 10px; }
.aneis-svg { flex: none; width: 210px; height: 210px; max-width: 100%; }
.ring-track { fill: none; stroke: var(--track); }
.ring { fill: none; stroke: var(--h5); stroke-linecap: round; }
.ring-r2, .gb-r2 .gb-t i { stroke: var(--h4); background: var(--h4); }
.ring-r3, .gb-r3 .gb-t i { stroke: var(--h3); background: var(--h3); }
.ring-r4, .gb-r4 .gb-t i { stroke: var(--h2); background: var(--h2); }
.ring-r5, .gb-r5 .gb-t i { stroke: var(--h1); background: var(--h1); }
.ring-r6, .gb-r6 .gb-t i { stroke: var(--sug-line); background: var(--sug-line); }
.ring-none, .gb-none .gb-t i { stroke: var(--muted); background: var(--muted); }
.ring-pct { fill: var(--ink); font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ring-sub { fill: var(--muted); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.grupos { flex: 1 1 200px; min-width: 0; margin: 0; padding: 0; list-style: none; }
.gb { display: grid; grid-template-columns: minmax(2.5em, 8.5em) minmax(40px, 1fr) 3.5em; gap: 10px; align-items: center; margin: 9px 0; font-size: 13px; }
.gb-l { overflow: hidden; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.gb-t { height: 6px; overflow: hidden; border-radius: 3px; background: var(--track); }
.gb-t i { display: block; height: 100%; border-radius: 3px; background: var(--h5); }
.gb-missing .gb-t i { background: var(--field); }
.gb-blocked .gb-t i { background: var(--red); }
.gb-review .gb-t i { background: var(--amber); }
.gb-approved .gb-t i { background: var(--h3); }
.gb-v { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

/* Mapa do ano: % fechadas em 5 faixas de verde, listrado = histórico do QuickBooks, contorno = o mês de fechamento. */
.mapa { min-width: 520px; margin-top: 8px; border-collapse: separate; border-spacing: 4px; table-layout: fixed; }
.mapa th, .mapa td { padding: 0; border: 0; }
.mapa thead th { padding-bottom: 2px; letter-spacing: 0; text-align: center; }
.mapa thead td:first-child { width: 88px; }
.mapa tbody th { overflow: hidden; color: var(--ink); font-size: 13px; font-weight: 700; letter-spacing: 0; text-overflow: ellipsis; text-transform: none; }
.mapa .c { height: 28px; border-radius: 6px; background: var(--track); color: var(--muted); font-size: 12px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.mapa .h1 { background: var(--h1); color: var(--ink); }
.mapa .h2 { background: var(--h2); color: var(--ink); }
.mapa .h3 { background: var(--h3); color: var(--on-h3); }
.mapa .h4 { background: var(--h4); color: var(--on-forest); }
.mapa .h5 { background: var(--h5); color: var(--on-forest); }
.mapa .c-hist { background: repeating-linear-gradient(135deg, var(--ok-bg) 0 4px, var(--card) 4px 8px); box-shadow: inset 0 0 0 1px var(--sug-line); }
.mapa .c-agora { background: var(--card); box-shadow: inset 0 0 0 2px var(--ink); }
.mapa .c-futuro { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }

/* Chip da etapa no Closings (`?stage=`): o ✕ limpa o filtro, com área de toque de 24px e foco visível. */
.filters-chips { margin: 4px 0 10px; }
.chip-filter { display: inline-flex; align-items: center; gap: 4px; padding: 2px 3px 2px 12px; border-radius: 999px; background: var(--soft); color: var(--ink); font-size: 13px; font-weight: 600; }
.chip-filter a { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; min-height: 24px; border-radius: 999px; color: var(--muted); text-decoration: none; }
.chip-filter a:hover { background: var(--track); color: var(--ink); }
.chip-filter a:focus-visible { outline: 2px solid var(--forest); outline-offset: 1px; }

.project-list { margin: 0.5rem 0 0 1.25rem; border-left: 2px solid var(--line); }

/* Celular: a chave quebra em linhas, os botões e os blocos se empilham (o botão vira linha com o ícone à esquerda) e o
   mapa rola dentro do cartão. */
@media (max-width: 640px) {
  .painel-head { align-items: flex-start; }
  .tiles { gap: 10px; }
  .tile { display: grid; grid-template-columns: 36px minmax(0, 1fr); column-gap: 12px; min-height: 0; padding: 12px 40px 12px 14px; }
  .tile-ic { grid-row: span 2; margin: 0; }
  .tile-ar { top: 50%; transform: translateY(-50%); }
  .painel-card { padding: 16px 14px; }
  .esteira { gap: 6px; }
  .et-n { font-size: 18px; }
  .et-l, .et-go { font-size: 11px; }
  .et-poste { height: 88px; }
  .aneis { justify-content: center; }
  .aneis-svg { width: 180px; height: 180px; }
}
