/* Pleno Contábil: um único arquivo de estilo. Cores e medidas em variáveis (tokens).
   Fontes do sistema (nenhuma requisição externa). Pensado para celular: 360 px sem rolagem horizontal.
   A matriz da EFD vira cartões até 860 px. */

/* ---------- Tokens ---------- */
:root {
  --bg: #f3f6f9; --surface: #ffffff; --surface-2: #eef2f6; --fg: #14202b; --muted: #566676;
  --line: #dde4eb; --line-strong: #b9c5d1;
  --accent: #1f5f8c; --accent-fg: #ffffff; --accent-soft: #e1eef7;
  --ok: #1f7a4d; --ok-soft: #e1f3e9;
  --warn: #8a5a00; --warn-soft: #fcefcf;
  --crit: #a3262a; --crit-soft: #fbe3e3;
  --na: #5d6b79; --na-soft: #e9edf1;
  --shadow: 0 8px 24px rgba(20, 32, 43, .14);
  --radius: 12px; --radius-sm: 8px;
  --alvo: 34px; /* menor alvo de toque */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}
/* Modo escuro segue o sistema; data-tema="claro" no <html> força o claro (usado nas capturas de docs/screens). */
@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) {
    --bg: #0f1720; --surface: #16212c; --surface-2: #1d2a37; --fg: #e8eef4; --muted: #9fb0bf;
    --line: #2a3947; --line-strong: #43566a;
    --accent: #6db3e3; --accent-fg: #0b1a26; --accent-soft: #17303f;
    --ok: #4cc08a; --ok-soft: #143527;
    --warn: #e6b450; --warn-soft: #3a2f12;
    --crit: #ff8a8d; --crit-soft: #401c1e;
    --na: #a2b0be; --na-soft: #222f3b;
    --shadow: 0 8px 24px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 15px; line-height: 1.45; }
a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 24px; line-height: 1.2; margin: 18px 0 6px; }
h2 { font-size: 17px; margin: 22px 0 10px; }
.titulo { margin-top: 20px; }
.sub { color: var(--muted); margin: 0 0 16px; }
.pular { position: absolute; left: -9999px; top: 0; background: var(--surface); padding: 8px 12px; border-radius: var(--radius-sm); z-index: 100; }
.pular:focus { left: 16px; top: 8px; }

/* ---------- Topo e menu ---------- */
.topo { background: var(--surface); border-bottom: 1px solid var(--line); }
.topo-interno { max-width: 1240px; margin: 0 auto; padding: 10px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.marca { font-weight: 700; font-size: 18px; color: var(--accent); margin-right: 10px; letter-spacing: -.01em; }
.menu { display: flex; flex-wrap: wrap; gap: 2px; }
.menu a { color: var(--muted); text-decoration: none; padding: 7px 12px; border-radius: var(--radius-sm); font-weight: 500; min-height: var(--alvo); display: inline-flex; align-items: center; }
.menu a:hover { background: var(--surface-2); color: var(--fg); }
.menu a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.usuario { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.quem { white-space: nowrap; }

.conteudo { max-width: 1240px; margin: 0 auto; padding: 4px 16px 72px; }

/* ---------- Botões e formulários ---------- */
.botao { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; background: var(--accent); color: var(--accent-fg);
  border: 1px solid var(--accent); border-radius: var(--radius-sm); padding: 7px 14px; font-weight: 600; text-decoration: none; cursor: pointer; }
.botao:hover { filter: brightness(1.08); }
.botao.secundario { background: var(--surface); color: var(--fg); border-color: var(--line-strong); font-weight: 500; }
.botao.secundario:hover { background: var(--surface-2); filter: none; }
.botao.pequeno { min-height: var(--alvo); padding: 4px 12px; }
.link-perigo { background: none; border: 0; color: var(--crit); cursor: pointer; padding: 6px 0; min-height: var(--alvo); text-decoration: underline; }
.em-linha { display: inline-flex; align-items: center; gap: 6px; }

.cartao { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 16px 0; }
.cartao.estreito { max-width: 420px; margin: 40px auto; }
.cabecalho-secao { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin: 18px 0 8px; }
.cabecalho-secao h1 { margin: 0; }

.formulario label { display: block; margin-bottom: 14px; font-size: 13px; font-weight: 500; color: var(--muted); }
.formulario input[type=text], .formulario input[type=email], .formulario input[type=password], .formulario input[type=search],
.formulario input[type=date], .formulario input[type=file], .formulario select, .formulario textarea {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px; min-height: 40px; font-size: 16px; color: var(--fg);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface);
}
.formulario fieldset { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.formulario legend { font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 6px; padding: 0; }
.formulario label.em-linha { display: inline-flex; margin: 0 16px 8px 0; color: var(--fg); font-size: 15px; min-height: var(--alvo); }
.formulario input[type=radio], .formulario input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }
.acoes-form { display: flex; gap: 16px; align-items: center; margin-top: 8px; }
.erro-campo { display: block; color: var(--crit); font-size: 13px; margin-top: 4px; font-weight: 500; }

/* Formulário em seções: lado a lado no desktop, uma coluna no celular. */
.secoes { display: grid; gap: 14px; }
.formulario .secao, .secao { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 4px; margin: 0; min-width: 0; }
.formulario .secao > legend, .secao > h2 { float: left; width: 100%; font-size: 15px; font-weight: 700; color: var(--fg); margin: 0 0 12px; padding: 0; }
.secao > legend + * { clear: both; }
.grade { display: grid; gap: 0 16px; grid-template-columns: minmax(0, 1fr); }
.grade .largo { grid-column: 1 / -1; }
@media (min-width: 760px) {
  .grade { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Busca, avisos e listas ---------- */
.busca { display: flex; gap: 8px; margin: 12px 0; }
.busca input { flex: 1; padding: 8px 10px; min-height: 40px; font-size: 16px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); min-width: 0; background: var(--surface); color: var(--fg); }
.aviso { padding: 10px 12px; border-radius: var(--radius-sm); margin: 12px 0; border: 1px solid transparent; }
.aviso-erro { background: var(--crit-soft); color: var(--crit); border-color: color-mix(in srgb, var(--crit) 30%, transparent); }
.aviso-aviso { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.aviso-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.aviso-linha { color: var(--warn); font-size: 14px; }
.vazio, .resumo { color: var(--muted); }
.destaque { color: var(--crit); font-weight: 600; }

.lista-cartoes, .lista-simples { list-style: none; padding: 0; margin: 0; }
.lista-cartoes li, .lista-simples li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; }
.lista-simples li.inativa, .cartao-linha.inativa { opacity: .6; }
.cartao-linha { display: grid; gap: 6px; }
.codigo { display: inline-block; font-family: var(--font-mono); font-size: 13px; background: var(--surface-2); padding: 2px 6px; border-radius: 4px; margin-right: 6px; }
.cartao-linha small, .lista-simples small { display: block; color: var(--muted); }
.detalhe { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 14px; color: var(--muted); }
.acoes { display: flex; gap: 14px; align-items: center; font-size: 15px; flex-wrap: wrap; }
.acoes a { min-height: var(--alvo); display: inline-flex; align-items: center; }
.uf-destacada { border-left: 4px solid var(--crit) !important; }
@media (min-width: 720px) {
  .cartao-linha { grid-template-columns: 2fr 1.4fr auto; align-items: center; }
}
details { margin-top: 6px; }
details > summary { cursor: pointer; color: var(--accent); min-height: var(--alvo); display: inline-flex; align-items: center; }
details form { margin-top: 8px; }

/* ---------- Painel ---------- */
.blocos { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.bloco { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.bloco:hover { border-color: var(--accent); }
.bloco .n { font-size: 38px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.bloco .l { font-weight: 600; margin-top: 4px; }
.bloco .h { color: var(--muted); font-size: 13px; }
.bloco.crit .n { color: var(--crit); }
.bloco.warn .n { color: var(--warn); }
.bloco.ok .n { color: var(--ok); }
.paineis { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 12px; margin-top: 12px; }
.painel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.painel h2 { margin: 0 0 8px; font-size: 16px; }
.lista { list-style: none; margin: 0; padding: 0; }
.lista li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); min-width: 0; }
.lista li:first-child { border-top: 0; }
.lista .t { min-width: 0; flex: 1; color: inherit; text-decoration: none; }
.lista .t:hover b { text-decoration: underline; }
.lista .t b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.lista .t span { color: var(--muted); font-size: 13px; }
.total { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 14px 0 0; color: var(--muted); font-size: 14px; }
.total .barra { flex: 1; min-width: 160px; height: 8px; }
.vazio-grande { text-align: center; color: var(--muted); padding: 28px 16px; }

/* Barra de andamento: <progress> com as cores dos tokens. */
.barra { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 6px; border: 0; border-radius: 99px; background: var(--surface-2); overflow: hidden; color: var(--accent); }
.barra::-webkit-progress-bar { background: var(--surface-2); border-radius: 99px; }
.barra::-webkit-progress-value { background: var(--accent); border-radius: 99px; }
.barra::-moz-progress-bar { background: var(--accent); border-radius: 99px; }
.barra.completa::-webkit-progress-value { background: var(--ok); }
.barra.completa::-moz-progress-bar { background: var(--ok); }
.barra.curta { width: 72px; flex: none; }

.badge { display: inline-block; border-radius: 99px; padding: 2px 9px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.b-crit { background: var(--crit-soft); color: var(--crit); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-neutro { background: var(--na-soft); color: var(--na); }

/* ---------- Matriz da EFD ---------- */
.ferramentas { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin: 6px 0 12px; }
.campo { display: flex; flex-direction: column; gap: 3px; font-size: 12px; font-weight: 500; color: var(--muted); }
.campo input, .campo select { font-size: 16px; color: var(--fg); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 6px 10px; min-height: 40px; }
.campo.cresce { flex: 1; min-width: 180px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { display: inline-flex; gap: 6px; align-items: center; min-height: var(--alvo); border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg);
  border-radius: 99px; padding: 4px 12px; font-weight: 500; text-decoration: none; }
.chip b { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.chip:hover { border-color: var(--accent); }
.chip[aria-current="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.chip[aria-current="true"] b { color: inherit; }

.matriz { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.matriz thead th { position: sticky; top: 0; z-index: 5; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left;
  padding: 9px 8px; border-bottom: 1px solid var(--line); }
.matriz thead th:first-child { border-top-left-radius: var(--radius); padding-left: 14px; }
.matriz thead th:last-child { border-top-right-radius: var(--radius); padding-right: 14px; }
.matriz th.c { text-align: center; }
.matriz th.dir { text-align: right; }
.matriz tr.grupo th { background: var(--bg); color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .02em; text-align: left;
  padding: 8px 14px; border-bottom: 1px solid var(--line); }
.matriz td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.matriz tbody:last-child tr:last-child td { border-bottom: 0; }
.matriz td:first-child { padding-left: 14px; }
.matriz td:last-child { padding-right: 14px; }
.linha { scroll-margin-top: 60px; }
.linha.prazo-atrasada td.co { box-shadow: inset 3px 0 0 var(--crit); }
.linha.prazo-vence_logo td.co { box-shadow: inset 3px 0 0 var(--warn); }
.co { min-width: 200px; }
.co b { display: block; font-weight: 600; }
.co span { color: var(--muted); font-size: 12.5px; }
.venc { white-space: nowrap; }
.venc .d { display: block; font-variant-numeric: tabular-nums; font-weight: 500; margin-bottom: 3px; }
.etapa { position: relative; text-align: center; min-width: 92px; }
.etapa .lab { display: none; }
.ctl { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; }
.ctl form { margin: 0; }
.dot { width: var(--alvo); height: var(--alvo); border-radius: 50%; border: 1.5px solid var(--line-strong); background: var(--surface); display: grid; place-items: center;
  color: transparent; padding: 0; margin: 0; cursor: pointer; list-style: none; }
.dot::-webkit-details-marker { display: none; }
.dot svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.dot.p:hover, .dot.p:focus-visible { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.dot.d { background: var(--ok); border-color: var(--ok); color: #fff; cursor: default; }
.dot.n { border-style: dashed; border-color: var(--na); color: var(--na); background: var(--na-soft); cursor: default; }
.meta { display: block; font-size: 11px; color: var(--muted); line-height: 1.25; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sem-etapa { color: var(--muted); }
details.recibo, details.mais { margin: 0; }
details.recibo > summary.dot { display: grid; min-height: 0; }
.mais { position: absolute; top: 2px; right: 0; }
.btn-mais { width: var(--alvo); height: var(--alvo); min-height: var(--alvo); border-radius: var(--radius-sm); display: grid !important; place-items: center; color: var(--muted);
  list-style: none; opacity: .35; }
.btn-mais::-webkit-details-marker { display: none; }
.btn-mais svg { width: 16px; height: 16px; fill: currentColor; }
.etapa:hover .btn-mais, .btn-mais:focus-visible, details.mais[open] > .btn-mais { opacity: 1; background: var(--surface-2); }
@media (pointer: coarse) { .btn-mais { opacity: .85; } }
.pop { position: absolute; z-index: 40; top: calc(100% + 4px); right: 0; text-align: left; background: var(--surface); color: var(--fg); border: 1px solid var(--line-strong);
  border-radius: 10px; box-shadow: var(--shadow); padding: 6px; width: 260px; max-width: calc(100vw - 32px); }
details.recibo > .pop { right: auto; left: 50%; transform: translateX(-50%); }
.pop .item { display: flex; align-items: center; width: 100%; min-height: var(--alvo); text-align: left; background: transparent; border: 0; border-radius: 6px; padding: 8px 10px; cursor: pointer; }
.pop .item:hover { background: var(--surface-2); }
.pop .frm { display: flex; flex-direction: column; gap: 6px; padding: 8px; margin: 0; }
.pop .frm + .frm { border-top: 1px solid var(--line); }
.pop form + form { border-top: 1px solid var(--line); }
.pop label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.pop input { width: 100%; font-size: 16px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg); border-radius: var(--radius-sm); padding: 6px 9px; min-height: 38px; }
.pop small { color: var(--muted); font-size: 11.5px; }
.pop .acts { display: flex; gap: 8px; justify-content: flex-end; }
.prog { text-align: right; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 80px; }
.prog .barra { margin-top: 4px; }
.gerar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 18px 0 0; font-size: 13px; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 50; background: var(--fg); color: var(--bg);
  border-radius: 10px; padding: 8px 10px 8px 14px; display: flex; gap: 12px; align-items: center; box-shadow: var(--shadow);
  width: max-content; max-width: calc(100vw - 32px); }
.toast form { margin: 0; }
.link-toast { background: transparent; border: 0; color: inherit; font-weight: 700; text-decoration: underline; min-height: var(--alvo); padding: 0 6px; cursor: pointer; }

/* ---------- Responsivo ---------- */
@media (max-width: 1000px) {
  .blocos { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .paineis { grid-template-columns: minmax(0, 1fr); }
}
/* Até 860 px: cada empresa é um cartão, com as etapas em lista (nome à esquerda, círculo à direita). */
@media (max-width: 860px) {
  .matriz, .matriz tbody, .matriz tr, .matriz td, .matriz th { display: block; width: 100%; }
  .matriz { border: 0; background: transparent; }
  .matriz thead { display: none; }
  .matriz tr.grupo th { background: transparent; border: 0; padding: 14px 2px 6px; }
  .matriz tr.linha { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 4px; margin-bottom: 10px; }
  .matriz tr.linha td { border: 0; padding: 0; min-width: 0; }
  .matriz td:first-child, .matriz td:last-child { padding-left: 0; padding-right: 0; }
  .linha.prazo-atrasada { border-left: 4px solid var(--crit) !important; }
  .linha.prazo-vence_logo { border-left: 4px solid var(--warn) !important; }
  .linha.prazo-atrasada td.co, .linha.prazo-vence_logo td.co { box-shadow: none; }
  .venc { display: flex !important; align-items: center; gap: 8px; flex-wrap: wrap; margin: 6px 0 4px; }
  .venc .d { display: inline; margin: 0; }
  .prog { order: 3; display: flex !important; align-items: center; gap: 10px; text-align: left; margin-bottom: 6px; }
  .prog .barra { margin: 0; flex: 1; }
  .etapa { order: 4; display: flex !important; align-items: center; justify-content: space-between; gap: 8px; text-align: left; padding: 7px 0 !important; border-top: 1px solid var(--line) !important; }
  .etapa .lab { display: block; font-weight: 500; flex: 1; min-width: 0; }
  .ctl { flex-direction: row-reverse; align-items: center; gap: 8px; }
  .ctl .meta { text-align: right; max-width: 130px; }
  .mais { position: relative; top: auto; right: auto; }
  .btn-mais { opacity: .85; }
  details.recibo > .pop { left: auto; right: 0; transform: none; }
}
@media (max-width: 520px) {
  .usuario { order: 2; }
  .menu { order: 3; width: 100%; }
  .menu a { padding: 6px 10px; }
  h1 { font-size: 21px; }
  .bloco .n { font-size: 30px; }
  .quem { display: none; }
  .ctl { flex-wrap: wrap; justify-content: flex-start; }
  .ctl .meta { max-width: 110px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* Nº do sistema no formulário de empresa (D-008) e telas de usuários. */
.numero-sistema { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.numero-sistema strong { color: var(--fg); font-variant-numeric: tabular-nums; }
.senha-temporaria { font-family: var(--font-mono); font-size: 22px; letter-spacing: .06em; background: var(--surface-2); border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm); padding: 10px 14px; display: inline-block; user-select: all; word-break: break-all; }
.etiqueta { display: inline-block; border-radius: 99px; padding: 1px 8px; font-size: 12px; font-weight: 600; background: var(--na-soft); color: var(--na); }
.etiqueta.ativo { background: var(--ok-soft); color: var(--ok); }
.etiqueta.alerta { background: var(--warn-soft); color: var(--warn); }
.link-senha { font-size: 13px; min-height: var(--alvo); display: inline-flex; align-items: center; }
