/* Sinal: perfil Operacional do DESIGN (frontend-design). Tokens da §1.1, copiados verbatim. */
:root {
  --page:#f9f9f7; --surface:#fcfcfb;
  --ink:#0b0b0b; --ink2:#52514e; --muted:#898781;
  --grid:#e1e0d9; --baseline:#c3c2b7; --border:rgba(11,11,11,.10);
  --pos:#006300; --neg:#d03b3b;
  --good:#0ca30c; --warn:#fab219; --crit:#d03b3b;
  --hover:rgba(11,11,11,.045);
  --serie-a:#2a78d6;
  --serie-b:#1baf7a;
  --nav-largura:212px;
  --tabbar-altura:58px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page:#0d0d0d; --surface:#1a1a19;
    --ink:#ffffff; --ink2:#c3c2b7; --muted:#898781;
    --grid:#2c2c2a; --baseline:#383835; --border:rgba(255,255,255,.10);
    --pos:#0ca30c;
    --hover:rgba(255,255,255,.06);
    --serie-a:#3987e5; --serie-b:#199e70;
  }
}

* { box-sizing: border-box; }
html { color-scheme: light dark; }
body { margin: 0; background: var(--page); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-text-size-adjust: 100%; }
h1 { font-size: 1.25rem; font-weight: 650; margin: 0; }
h2 { font-size: .95rem; font-weight: 650; margin: 0; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--serie-a); outline-offset: 2px; }
.mini { font-size: .78rem; color: var(--muted); }
.sub { font-size: .85rem; color: var(--ink2); }
.carregando { min-height: 100vh; }

/* Ícones (§1.10): traço em currentColor. */
.ico { width: 20px; height: 20px; flex: none; }

/* Botões. */
.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 8px; padding: 7px 14px; min-height: 36px; cursor: pointer; font: inherit; font-weight: 600; font-size: .9rem; text-decoration: none; position: relative; }
.btn::after { content: ""; position: absolute; inset: -5px 0; } /* área de toque ≥ 44 px sem inflar o visual */
.btn:hover:not(:disabled) { background: var(--hover); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primario { background: var(--serie-a); border-color: transparent; color: #fff; }
.btn.primario:hover:not(:disabled) { filter: brightness(1.08); background: var(--serie-a); }
.btn.perigo { color: var(--crit); }
.btn.discreto { background: transparent; border-color: transparent; color: var(--ink2); padding: 7px 8px; }
.btn.discreto:hover:not(:disabled) { background: var(--hover); }

/* Campos. */
label.campo { display: grid; gap: 4px; font-size: .85rem; color: var(--ink2); }
input, textarea, select { font: inherit; font-size: 16px; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; width: 100%; min-height: 44px; }
textarea { min-height: 84px; resize: vertical; }
input.codigo { font-size: 1.4rem; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }
form.pilha { display: grid; gap: 12px; }
.linha-form { display: flex; gap: 8px; align-items: stretch; }
.linha-form > input, .linha-form > select { flex: 1; min-width: 0; }
.acoes { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.acoes.inicio { justify-content: flex-start; }

/* Telas sem sessão: cartão de leitura centrado. */
.porta { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.porta .cartao { width: 100%; max-width: 400px; }
.marca { display: flex; align-items: center; gap: 8px; color: var(--serie-a); text-decoration: none; }
.marca span { color: var(--ink); font-weight: 650; font-size: 1.1rem; }
.cartao { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 18px; display: grid; gap: 14px; }

/* Shell com sessão: sidebar no desktop, tabbar no mobile (§1.11). */
.shell { min-height: 100vh; }
.nav { display: flex; }
.nav a { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .9rem; border-radius: 8px; }
.nav a[aria-current="page"] { color: var(--ink); }
.principal { min-width: 0; padding: 12px 14px calc(var(--tabbar-altura) + 20px + env(safe-area-inset-bottom)); }
.topo { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-bottom: 10px; }
.topo h1 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topo .marca-mobile { color: var(--serie-a); display: flex; }

@media (max-width: 899px) {
  .lateral { display: contents; }
  .lateral .marca, .lateral .rodape-nav { display: none; }
  .nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); height: calc(var(--tabbar-altura) + env(safe-area-inset-bottom)); }
  .nav a { flex: 1; flex-direction: column; justify-content: center; gap: 2px; font-size: .72rem; min-height: 44px; }
}
@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: var(--nav-largura) minmax(0, 1fr); }
  .lateral { position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--border); background: var(--surface); padding: 16px 10px; display: flex; flex-direction: column; gap: 18px; }
  .lateral .marca { padding: 0 8px; }
  .nav { flex-direction: column; gap: 2px; }
  .nav a { padding: 10px 10px; min-height: 44px; }
  .nav a:hover { background: var(--hover); }
  .nav a[aria-current="page"] { background: var(--hover); }
  .rodape-nav { margin-top: auto; padding: 0 8px; }
  .principal { padding: 20px clamp(16px, 3vw, 36px) 40px; }
  .topo .marca-mobile { display: none; }
  .colunas { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
}

/* Seções e listas (§3.2). */
.secao { margin-bottom: 18px; min-width: 0; }
.secao > header { display: flex; align-items: center; gap: 8px; margin: 8px 0 6px; }
.secao > header h2 { flex: 1; }
.lista { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.lista > li { min-width: 0; }
.item { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px; display: flex; align-items: center; gap: 10px; min-height: 52px; }
.item .corpo { flex: 1; min-width: 0; }
.item .titulo { font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.item .meta { font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item.clicavel { cursor: pointer; text-decoration: none; color: inherit; }
.item.clicavel:hover { background: var(--hover); }
.tag { font-size: .72rem; padding: 2px 8px; border-radius: 999px; background: var(--hover); border: 1px solid var(--border); color: var(--ink2); white-space: nowrap; }
.vazio { color: var(--muted); font-style: italic; text-align: center; padding: 18px 8px; }
.descricao { color: var(--ink2); white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 12px; max-width: 70ch; }
.leitura { max-width: 520px; }

/* Sinais: cartão clicável com cabeça (quem, onde, estado), texto cortado em 4 linhas e rodapé. */
.item.sinal { display: grid; gap: 6px; width: 100%; text-align: left; font: inherit; color: inherit; align-items: start; }
.sinal .cabeca { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.sinal .quem { font-weight: 600; overflow-wrap: anywhere; }
.sinal .onde { font-size: .78rem; color: var(--muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sinal .texto { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink2); }
.sinal .rodape { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.sinal .motivo { font-size: .78rem; color: var(--ink2); flex-basis: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag.estado, .tag.andamento { display: inline-flex; align-items: center; gap: 5px; }
.tag.estado::before, .tag.andamento::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.tag.enviado::before { background: var(--serie-a); }
.tag.em-analise::before, .tag.na-fila::before { background: var(--warn); }
.tag.aprovado::before, .tag.em-execucao::before { background: var(--serie-b); }
.tag.concluido::before { background: var(--good); }

/* Diálogo de leitura (pares rótulo/valor). */
dialog.largo { width: min(92vw, 600px); }
dl.blocos { margin: 0 0 14px; display: grid; gap: 4px; }
dl.blocos dt { font-size: .78rem; color: var(--muted); margin-top: 8px; }
dl.blocos dt:first-child { margin-top: 0; }
dl.blocos dd { margin: 0; overflow-wrap: anywhere; }
dl.blocos dd.longo { white-space: pre-wrap; background: var(--page); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }

/* Avisos. */
.aviso { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-altura) + 14px + env(safe-area-inset-bottom)); z-index: 20; display: grid; gap: 6px; width: min(92vw, 420px); pointer-events: none; }
@media (min-width: 900px) { .aviso { bottom: 20px; } }
.aviso .msg { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--good); border-radius: 8px; padding: 10px 12px; box-shadow: 0 4px 14px rgba(0,0,0,.14); font-size: .9rem; }
.aviso .msg.erro { border-left-color: var(--crit); }
.caixa-erro { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--crit); border-radius: 8px; padding: 10px 12px; }
.caixa-ok { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--good); border-radius: 8px; padding: 10px 12px; }
.atualizar { position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 14px; display: flex; gap: 10px; align-items: center; justify-content: center; font-size: .9rem; }

/* Diálogo. */
dialog { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--ink); padding: 18px; width: min(92vw, 440px); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog h2 { margin-bottom: 12px; }

/* Tokens de Radar (Conta, só donos): o valor aparece uma vez, em fonte de largura fixa para conferir. */
code, input.token { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
input.token { letter-spacing: 0; }
