/* Painel Almighty — tema claro/escuro por tokens. Sem fontes externas (CSP 'self'). */
:root {
  color-scheme: light;
  --fundo: #f4f3f0;
  --superficie: #fcfcfb;
  --superficie-2: #f0efec;
  --borda: #e2e0da;
  --borda-forte: #cfccc4;
  --texto: #1a1916;
  --texto-2: #52514e;
  --texto-3: #7a7873;
  --destaque: #8a5a00;
  --destaque-fundo: #fbf0d9;
  --destaque-forte: #b07400;
  --link: #1c5cab;
  --ok: #006300;
  --ok-fundo: #e3f3e3;
  --aviso: #8a5a00;
  --aviso-fundo: #fdf1d6;
  --erro: #b42323;
  --erro-fundo: #fbe5e5;
  --info-fundo: #e4eefb;
  --serie-1: #2a78d6;
  --serie-2: #eb6834;
  --serie-3: #1baf7a;
  --grade: #e8e6e1;
  --sombra: 0 1px 2px rgb(0 0 0 / 0.05), 0 2px 8px rgb(0 0 0 / 0.04);
  --raio: 10px;
  --fonte: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --fundo: #121211;
    --superficie: #1a1a19;
    --superficie-2: #232321;
    --borda: #2f2f2c;
    --borda-forte: #42423e;
    --texto: #f0efec;
    --texto-2: #c3c2b7;
    --texto-3: #918f87;
    --destaque: #f0b545;
    --destaque-fundo: #3a2c10;
    --destaque-forte: #f0b545;
    --link: #86b6ef;
    --ok: #5ccb5c;
    --ok-fundo: #16301a;
    --aviso: #f0b545;
    --aviso-fundo: #3a2c10;
    --erro: #f08080;
    --erro-fundo: #3d1a1a;
    --info-fundo: #17273d;
    --serie-1: #3987e5;
    --serie-2: #d95926;
    --serie-3: #199e70;
    --grade: #2a2a27;
    --sombra: 0 1px 2px rgb(0 0 0 / 0.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --fundo: #121211;
  --superficie: #1a1a19;
  --superficie-2: #232321;
  --borda: #2f2f2c;
  --borda-forte: #42423e;
  --texto: #f0efec;
  --texto-2: #c3c2b7;
  --texto-3: #918f87;
  --destaque: #f0b545;
  --destaque-fundo: #3a2c10;
  --destaque-forte: #f0b545;
  --link: #86b6ef;
  --ok: #5ccb5c;
  --ok-fundo: #16301a;
  --aviso: #f0b545;
  --aviso-fundo: #3a2c10;
  --erro: #f08080;
  --erro-fundo: #3d1a1a;
  --info-fundo: #17273d;
  --serie-1: #3987e5;
  --serie-2: #d95926;
  --serie-3: #199e70;
  --grade: #2a2a27;
  --sombra: 0 1px 2px rgb(0 0 0 / 0.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--fundo);
  color: var(--texto);
  font: 14px/1.5 var(--fonte);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 650; color: var(--texto-2); }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.oculto { display: none !important; }
.mono { font-family: var(--mono); font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.fraco { color: var(--texto-3); }
.medio { color: var(--texto-2); }

/* ─── Estrutura ─────────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.lateral {
  background: var(--superficie);
  border-right: 1px solid var(--borda);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.marca { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; }
.marca img { width: 30px; height: 30px; }
.marca b { display: block; font-size: 15px; letter-spacing: 0.01em; }
.marca span { display: block; font-size: 12px; color: var(--texto-3); }
.nav { padding: 6px 10px 16px; display: flex; flex-direction: column; gap: 1px; }
.nav .grupo { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; color: var(--texto-3); padding: 14px 10px 6px; display: flex; align-items: center; gap: 8px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; color: var(--texto-2); font-weight: 500; }
.nav a:hover { background: var(--superficie-2); color: var(--texto); text-decoration: none; }
.nav a.ativo { background: var(--destaque-fundo); color: var(--destaque); }
.nav svg { width: 16px; height: 16px; flex: none; }
.lateral .rodape { margin-top: auto; padding: 14px; border-top: 1px solid var(--borda); display: flex; flex-direction: column; gap: 10px; }
.usuario { display: flex; align-items: center; gap: 10px; min-width: 0; }
.usuario img, .usuario .avatar { width: 30px; height: 30px; border-radius: 50%; flex: none; background: var(--superficie-2); display: grid; place-items: center; font-weight: 650; color: var(--texto-2); }
.usuario div { min-width: 0; }
.usuario b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.usuario span { font-size: 12px; color: var(--texto-3); }
.linha-botoes { display: flex; gap: 6px; }

.principal { min-width: 0; display: flex; flex-direction: column; }
.topo {
  display: flex; align-items: center; gap: 12px; padding: 12px 28px;
  border-bottom: 1px solid var(--borda); background: var(--superficie);
  position: sticky; top: 0; z-index: 5;
}
.topo .menu { display: none; }
.trilha { color: var(--texto-3); font-size: 13px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trilha b { color: var(--texto); font-weight: 600; }
.estados { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.conteudo { padding: 24px 28px 48px; max-width: 1280px; width: 100%; }
.cabecalho { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.cabecalho p { color: var(--texto-2); margin-top: 4px; }
.carregando .conteudo > * { opacity: 0.55; transition: opacity 0.2s; }

/* ─── Indicadores ───────────────────────────────────────────────────────── */
.pilula { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 550; background: var(--superficie-2); color: var(--texto-2); white-space: nowrap; border: 1px solid transparent; }
.pilula .ponto { width: 7px; height: 7px; border-radius: 50%; background: var(--texto-3); }
.pilula.ok { background: var(--ok-fundo); color: var(--ok); }
.pilula.ok .ponto { background: var(--ok); }
.pilula.aviso { background: var(--aviso-fundo); color: var(--aviso); }
.pilula.aviso .ponto { background: var(--aviso); }
.pilula.erro { background: var(--erro-fundo); color: var(--erro); }
.pilula.erro .ponto { background: var(--erro); }
.pilula.vivo .ponto { animation: pulso 2s infinite; }
@keyframes pulso { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .pilula.vivo .ponto { animation: none; } }

.etiqueta { display: inline-block; padding: 1px 8px; border-radius: 5px; font-size: 12px; font-weight: 550; background: var(--superficie-2); color: var(--texto-2); white-space: nowrap; }
.etiqueta.ok { background: var(--ok-fundo); color: var(--ok); }
.etiqueta.aviso { background: var(--aviso-fundo); color: var(--aviso); }
.etiqueta.erro { background: var(--erro-fundo); color: var(--erro); }
.etiqueta.info { background: var(--info-fundo); color: var(--link); }

/* ─── Cartões e grades ──────────────────────────────────────────────────── */
.grade { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.cartao { background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio); box-shadow: var(--sombra); min-width: 0; }
.cartao > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px 0; flex-wrap: wrap; }
.cartao > header p { color: var(--texto-3); font-size: 12px; margin-top: 2px; width: 100%; }
.cartao .corpo { padding: 14px 18px 18px; }
.cartao .corpo.sem-margem { padding: 10px 0 4px; }
.secao { margin-top: 16px; }

.numeros { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.numero { background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio); padding: 14px 16px; box-shadow: var(--sombra); }
.numero span { display: block; font-size: 12px; color: var(--texto-2); font-weight: 500; }
.numero b { display: block; font-size: 26px; font-weight: 650; letter-spacing: -0.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.numero small { display: block; font-size: 12px; color: var(--texto-3); margin-top: 2px; }

.vazio { padding: 28px 18px; text-align: center; color: var(--texto-3); }
.vazio b { display: block; color: var(--texto-2); font-weight: 600; margin-bottom: 4px; }
.alerta { padding: 12px 14px; border-radius: 8px; background: var(--aviso-fundo); color: var(--aviso); margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start; }
.alerta.erro { background: var(--erro-fundo); color: var(--erro); }
.alerta.info { background: var(--info-fundo); color: var(--link); }
.alerta p { color: inherit; }

/* ─── Listas e tabelas ──────────────────────────────────────────────────── */
.lista { list-style: none; margin: 0; padding: 0; }
.lista li { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-top: 1px solid var(--borda); min-width: 0; }
.lista li:first-child { border-top: 0; }
.lista .esticar { flex: 1; min-width: 0; }
.lista .esticar b, .lista .esticar a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.lista .esticar span { font-size: 12px; color: var(--texto-3); }
.lista .pos { width: 26px; height: 26px; border-radius: 50%; background: var(--superficie-2); display: grid; place-items: center; font-size: 12px; font-weight: 650; color: var(--texto-2); flex: none; font-variant-numeric: tabular-nums; }

.tabela-rolagem { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--borda); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--texto-2); white-space: nowrap; background: var(--superficie); position: sticky; top: 0; }
th.ordenavel { cursor: pointer; user-select: none; }
th.ordenavel:hover { color: var(--texto); }
th[aria-sort="ascending"]::after { content: " ↑"; }
th[aria-sort="descending"]::after { content: " ↓"; }
td.d, th.d { text-align: right; }
tbody tr:hover { background: var(--superficie-2); }
tbody tr.clicavel { cursor: pointer; }
tr:last-child td { border-bottom: 0; }
td:first-child, th:first-child { padding-left: 18px; }
td:last-child, th:last-child { padding-right: 18px; }
.barrinha { display: inline-block; width: 52px; height: 6px; border-radius: 3px; background: var(--superficie-2); vertical-align: middle; margin-left: 6px; overflow: hidden; }
.barrinha i { display: block; height: 100%; background: var(--serie-1); border-radius: 3px; }

/* ─── Formulários ───────────────────────────────────────────────────────── */
.botao {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px; border: 1px solid var(--borda-forte);
  background: var(--superficie); color: var(--texto); font-weight: 550; cursor: pointer; white-space: nowrap;
  text-decoration: none; line-height: 1.4;
}
.botao:hover { background: var(--superficie-2); text-decoration: none; }
.botao:disabled { opacity: 0.5; cursor: not-allowed; }
.botao.primario { background: var(--destaque-forte); border-color: var(--destaque-forte); color: #fff; }
:root[data-theme="dark"] .botao.primario { color: #1a1408; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .botao.primario { color: #1a1408; } }
.botao.primario:hover { filter: brightness(1.06); background: var(--destaque-forte); }
.botao.perigo { color: var(--erro); }
.botao.perigo:hover { background: var(--erro-fundo); }
.botao.pequeno { padding: 3px 9px; font-size: 12px; border-radius: 6px; }
.botao.icone { padding: 6px; width: 32px; height: 32px; }
.botao.icone.pequeno { width: 26px; height: 26px; padding: 3px; }
.botao svg { width: 16px; height: 16px; }
.botao.fantasma { border-color: transparent; background: transparent; }
.botao.fantasma:hover { background: var(--superficie-2); }

.filtros { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.campo { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.campo > span { font-size: 12px; font-weight: 600; color: var(--texto-2); }
.campo small { font-size: 12px; color: var(--texto-3); }
input[type="text"], input[type="search"], input[type="number"], input[type="date"], input[type="time"], input[type="datetime-local"], select, textarea {
  background: var(--superficie); border: 1px solid var(--borda-forte); border-radius: 8px; padding: 7px 10px; min-width: 0; width: 100%;
}
.filtros select, .filtros input { width: auto; }
textarea { resize: vertical; min-height: 110px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--link); outline-offset: -1px; border-color: transparent; }
.form { display: grid; gap: 14px; }
.form .linha { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.checks { display: flex; gap: 6px; flex-wrap: wrap; }
.checks label { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--borda-forte); border-radius: 7px; cursor: pointer; font-size: 13px; }
.checks label:has(input:checked) { background: var(--destaque-fundo); border-color: var(--destaque-forte); color: var(--destaque); }
.checks input { margin: 0; accent-color: var(--destaque-forte); }
.alternar { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.alternar input { appearance: none; width: 34px; height: 20px; border-radius: 10px; background: var(--borda-forte); position: relative; cursor: pointer; margin: 0; transition: background 0.15s; flex: none; }
.alternar input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.15s; box-shadow: 0 1px 2px rgb(0 0 0 / 0.3); }
.alternar input:checked { background: var(--ok); }
.alternar input:checked::after { transform: translateX(14px); }
.segmentado { display: inline-flex; border: 1px solid var(--borda-forte); border-radius: 8px; overflow: hidden; }
.segmentado button { border: 0; background: var(--superficie); padding: 6px 12px; cursor: pointer; color: var(--texto-2); font-weight: 550; border-left: 1px solid var(--borda-forte); }
.segmentado button:first-child { border-left: 0; }
.segmentado button[aria-pressed="true"] { background: var(--destaque-fundo); color: var(--destaque); }
.acoes { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.contador { font-size: 12px; color: var(--texto-3); text-align: right; }

/* Presença na conferência */
.presenca { display: inline-flex; border: 1px solid var(--borda-forte); border-radius: 7px; overflow: hidden; flex: none; }
.presenca button { border: 0; background: var(--superficie); padding: 4px 9px; font-size: 12px; cursor: pointer; color: var(--texto-3); font-weight: 600; border-left: 1px solid var(--borda-forte); }
.presenca button:first-child { border-left: 0; }
.presenca button[aria-pressed="true"][data-v="presente"] { background: var(--ok-fundo); color: var(--ok); }
.presenca button[aria-pressed="true"][data-v="ausente"] { background: var(--erro-fundo); color: var(--erro); }
.presenca button[aria-pressed="true"][data-v="justificada"] { background: var(--aviso-fundo); color: var(--aviso); }

/* ─── Diálogo, avisos ───────────────────────────────────────────────────── */
dialog { border: 1px solid var(--borda); border-radius: 14px; background: var(--superficie); color: var(--texto); padding: 0; width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 20px 60px rgb(0 0 0 / 0.25); }
dialog::backdrop { background: rgb(0 0 0 / 0.45); }
dialog > header { padding: 18px 22px 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
dialog .corpo { padding: 16px 22px; overflow-y: auto; }
dialog > footer { padding: 0 22px 18px; }
.torradas { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(380px, calc(100vw - 36px)); }
.torrada { background: var(--texto); color: var(--superficie); padding: 10px 14px; border-radius: 9px; box-shadow: 0 6px 24px rgb(0 0 0 / 0.2); font-size: 13px; display: flex; gap: 10px; align-items: flex-start; }
.torrada.erro { background: var(--erro); color: #fff; }
.torrada button { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; opacity: 0.7; padding: 0 2px; }

.diff { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.diff pre { margin: 0; padding: 10px; border-radius: 8px; background: var(--superficie-2); font: 12px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; max-height: 260px; overflow: auto; }
.diff h3 { margin-bottom: 4px; }
details.linha-aud > summary { cursor: pointer; list-style: none; }
details.linha-aud > summary::-webkit-details-marker { display: none; }

/* ─── Gráficos ──────────────────────────────────────────────────────────── */
.grafico { position: relative; }
.grafico svg { display: block; width: 100%; height: auto; overflow: visible; }
.grafico .eixo text { fill: var(--texto-3); font-size: 11px; font-family: var(--fonte); }
.grafico .rotulo { fill: var(--texto-2); font-size: 11px; font-family: var(--fonte); font-variant-numeric: tabular-nums; }
.grafico .grade-linha { stroke: var(--grade); stroke-width: 1; }
.grafico .base { stroke: var(--borda-forte); stroke-width: 1; }
.grafico .s1 { fill: var(--serie-1); }
.grafico .s2 { fill: var(--serie-2); }
.grafico .s3 { fill: var(--serie-3); }
.grafico .l1 { stroke: var(--serie-1); fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.grafico .p1 { fill: var(--serie-1); stroke: var(--superficie); stroke-width: 2; }
.grafico .marca-hover { transition: opacity 0.1s; }
.grafico .alvo { fill: transparent; cursor: default; }
.grafico.com-foco .marca-dado { opacity: 0.45; }
.grafico.com-foco .marca-dado.foco { opacity: 1; }
.grafico .cursor { stroke: var(--texto-3); stroke-width: 1; stroke-dasharray: 3 3; }
.legenda { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--texto-2); margin-bottom: 8px; }
.legenda span { display: inline-flex; align-items: center; gap: 6px; }
.legenda i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legenda i.s1 { background: var(--serie-1); }
.legenda i.s2 { background: var(--serie-2); }
.legenda i.s3 { background: var(--serie-3); }
.legenda i.linha { height: 2px; border-radius: 1px; width: 14px; }
.dica {
  position: absolute; pointer-events: none; z-index: 10;
  background: var(--superficie); border: 1px solid var(--borda-forte); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; box-shadow: 0 6px 20px rgb(0 0 0 / 0.15); min-width: 140px; white-space: nowrap;
}
.dica .titulo { color: var(--texto-2); margin-bottom: 4px; font-weight: 550; }
.dica .item { display: flex; align-items: center; gap: 8px; }
.dica .item b { font-variant-numeric: tabular-nums; color: var(--texto); }
.dica .item span { color: var(--texto-3); }
.dica .item i { width: 10px; height: 2px; border-radius: 1px; display: inline-block; }
.dica .item i.s1 { background: var(--serie-1); }
.dica .item i.s2 { background: var(--serie-2); }
.dica .item i.s3 { background: var(--serie-3); }
.ver-tabela { margin-top: 8px; font-size: 12px; }
.ver-tabela summary { cursor: pointer; color: var(--texto-3); }
.ver-tabela table { margin-top: 6px; }
.ver-tabela td, .ver-tabela th { padding: 5px 10px; }

.formula { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; align-items: baseline; }
.formula dt { font-weight: 600; }
.formula dd { margin: 0; color: var(--texto-2); }
.formula code { font-family: var(--mono); font-size: 12px; background: var(--superficie-2); padding: 1px 6px; border-radius: 4px; color: var(--texto); }

/* ─── Página simples (login negado etc.) ────────────────────────────────── */
.pagina-simples { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.cartao-simples { background: var(--superficie); border: 1px solid var(--borda); border-radius: 14px; padding: 32px 28px; max-width: 440px; width: 100%; text-align: center; box-shadow: var(--sombra); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.cartao-simples p { color: var(--texto-2); }
.cartao-simples .botao { margin-top: 8px; }
.entrada { min-height: 100vh; display: grid; place-items: center; padding: 16px; }

/* ─── Responsivo ────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-21 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .lateral { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 30; transform: translateX(-100%); transition: transform 0.2s; box-shadow: 0 0 40px rgb(0 0 0 / 0.3); }
  .app.menu-aberto .lateral { transform: none; }
  .topo { padding: 10px 16px; }
  .topo .menu { display: inline-flex; }
  .conteudo { padding: 16px 16px 40px; }
  .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .estados .pilula .txt { display: none; }
  .diff { grid-template-columns: 1fr; }
  td:first-child, th:first-child { padding-left: 12px; }
  td:last-child, th:last-child { padding-right: 12px; }
  .lista li { padding: 10px 12px; flex-wrap: wrap; }
}
#conteudo:focus { outline: none; }
