/* ═══════════════════════════════════════════════════════════════════════
   WAGURI · Design system — base
   Tokens, reset, estrutura e navegação. Ícones: Phosphor Duotone (CDN).

   REGRAS DE MANUTENÇÃO
   • Toda cor derivada usa color-mix() sobre uma variável — nunca rgba() fixo.
     Assim trocar de tema (dark/light) funciona sem caçar valores espalhados.
   • Os nomes das variáveis e das classes são CONTRATO: as 8 páginas e os
     blocos <style> inline delas dependem destes nomes. Renomear quebra tudo.
   • --rosa / --roxo são nomes herdados. Hoje são "acento secundário" e
     "acento primário". Mantidos para não quebrar as páginas.
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  color-scheme: dark;

  /* ── neutros (superfícies, do fundo para a frente) ────────────────── */
  --bg:      #0b0e14;
  --bg2:     #11151d;
  --bg3:     #171c26;
  --bg4:     #1f2531;
  --borda:   #232a36;
  --borda2:  #313a49;

  /* ── texto ────────────────────────────────────────────────────────── */
  --txt:     #e7ebf0;
  --txt2:    #97a1b0;
  --txt3:    #7b8794;   /* AA (4.99:1) mesmo nos rótulos de eixo a 10px */

  /* ── acentos ──────────────────────────────────────────────────────── */
  --roxo:    #4c8dff;   /* primário  (nome herdado) */
  --rosa:    #7fb0ff;   /* secundário (nome herdado) */
  --azul:    #58a6ff;
  --ciano:   #45c4d6;
  --verde:   #3fb950;
  --amarelo: #d9a420;
  --vermelho:#f0616d;

  /* texto SOBRE o acento (botões cheios, emblemas) */
  --sobre-acento: #05080f;

  --gradiente: linear-gradient(135deg, #3f7ff2 0%, #6aa5ff 100%);
  --gradiente-suave: linear-gradient(
    135deg,
    color-mix(in srgb, var(--roxo) 14%, transparent),
    color-mix(in srgb, var(--rosa) 5%, transparent)
  );

  /* ── superfícies translúcidas (sidebar/header com blur) ───────────── */
  --vidro:        color-mix(in srgb, var(--bg2) 84%, transparent);
  --vidro-forte:  color-mix(in srgb, var(--bg2) 96%, transparent);
  --cortina:      color-mix(in srgb, #04060a 78%, transparent);

  /* ── geometria ────────────────────────────────────────────────────── */
  --r:   12px;
  --r-p: 9px;
  --r-g: 16px;
  --lateral: 248px;
  --topo: 60px;
  --barra-baixo: 62px;

  /* ── tipografia ───────────────────────────────────────────────────── */
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono",
          Menlo, Consolas, monospace;

  /* escala de espaçamento (múltiplos de 4) */
  --e1: 4px;  --e2: 8px;  --e3: 12px; --e4: 16px;
  --e5: 20px; --e6: 24px; --e8: 32px;

  /* sombras: enterprise = sutis. A separação vem da borda, não da sombra. */
  --sombra:    0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .22);
  --sombra-alta: 0 2px 6px rgba(0, 0, 0, .34), 0 18px 48px rgba(0, 0, 0, .42);

  /* movimento */
  --t-rapido: .13s cubic-bezier(.4, 0, .2, 1);
  --t-medio:  .22s cubic-bezier(.4, 0, .2, 1);
}

/* ── Tema claro ────────────────────────────────────────────────────────
   Ativado por data-theme="light" no <html>. Mesmos nomes de variável,
   então as 8 páginas e os <style> inline herdam automaticamente.        */
:root[data-theme="light"] {
  color-scheme: light;

  --bg:      #f6f7f9;
  --bg2:     #ffffff;
  --bg3:     #f0f2f5;
  --bg4:     #e5e9ef;
  --borda:   #dfe3e9;
  --borda2:  #c7ced8;

  --txt:     #15191f;
  --txt2:    #5a6472;
  --txt3:    #6b7280;   /* AA (4.83:1) sobre branco */

  --roxo:    #2f6fe4;
  --rosa:    #4a86f0;
  --azul:    #2f6fe4;
  --ciano:   #1a8ba0;
  --verde:   #1a7f37;   /* 5.08:1 — folga acima do mínimo AA */
  --amarelo: #9a6700;
  --vermelho:#cf2f3d;

  --sobre-acento: #ffffff;

  --gradiente: linear-gradient(135deg, #2f6fe4 0%, #4a86f0 100%);
  --gradiente-suave: linear-gradient(
    135deg,
    color-mix(in srgb, var(--roxo) 10%, transparent),
    color-mix(in srgb, var(--rosa) 4%, transparent)
  );

  --vidro:       color-mix(in srgb, #ffffff 88%, transparent);
  --vidro-forte: color-mix(in srgb, #ffffff 97%, transparent);
  --cortina:     color-mix(in srgb, #0b0e14 42%, transparent);

  --sombra:      0 1px 2px rgba(16, 24, 40, .06), 0 2px 8px rgba(16, 24, 40, .05);
  --sombra-alta: 0 4px 12px rgba(16, 24, 40, .1), 0 16px 40px rgba(16, 24, 40, .14);
}

/* ── reset ───────────────────────────────────────────────────────────── */

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--txt);
  font: 14.5px/1.55 var(--sans);
  font-feature-settings: "cv05" 1, "ss01" 1;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Enterprise: sem brilho colorido no fundo. Um gradiente neutro discreto. */
  background-image: radial-gradient(
    ellipse 900px 520px at 50% -12%,
    color-mix(in srgb, var(--roxo) 6%, transparent),
    transparent 70%
  );
  background-attachment: fixed;
}

/* Números alinhados em qualquer lugar com dado — essencial em dashboard. */
.mono, .valor, .qtd, .paginacao, .tabela-dados td:last-child,
.kpi-valor, .tempo-no-ar, .ops-metric strong, .ops-pair span:last-child {
  font-variant-numeric: tabular-nums;
}

a { color: var(--azul); text-decoration: none; transition: color var(--t-rapido); }
a:hover { color: color-mix(in srgb, var(--azul) 82%, var(--txt)); }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--roxo) 70%, transparent);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: color-mix(in srgb, var(--roxo) 32%, transparent); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--bg4);
  border-radius: 6px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--borda2); }

[class*=" ph-"], [class^="ph-"] { line-height: 1; vertical-align: -.13em; }

h1, h2, h3, h4 { letter-spacing: -.018em; font-weight: 620; }

/* ── estrutura ───────────────────────────────────────────────────────── */

.app { display: flex; min-height: 100vh; min-height: 100dvh; }

.lateral {
  width: var(--lateral);
  flex-shrink: 0;
  background: var(--vidro);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-right: 1px solid var(--borda);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
}

.marca {
  display: flex; align-items: center; gap: 11px;
  height: var(--topo);
  padding: 0 18px;
  border-bottom: 1px solid var(--borda);
  font-weight: 640; font-size: 15.5px;
  letter-spacing: -.02em;
  flex-shrink: 0;
}
.marca .simbolo-marca {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--gradiente);
  display: grid; place-items: center;
  color: var(--sobre-acento);
  font-size: 17px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px color-mix(in srgb, var(--roxo) 40%, transparent);
}

.menu {
  padding: 12px 10px;
  display: flex; flex-direction: column; gap: 2px;
  flex: 1; overflow-y: auto;
}

.menu .item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px;
  border-radius: var(--r-p);
  color: var(--txt2);
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--t-rapido), color var(--t-rapido);
  position: relative;
}
.menu .item i { font-size: 19px; width: 20px; text-align: center; flex-shrink: 0; }
.menu .item:hover { background: var(--bg3); color: var(--txt); }
.menu .item.ativo {
  background: color-mix(in srgb, var(--roxo) 12%, transparent);
  color: var(--txt);
  font-weight: 600;
}
.menu .item.ativo::before {
  content: "";
  position: absolute; left: -10px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 20px;
  border-radius: 0 3px 3px 0;
  background: var(--roxo);
}
.menu .item.ativo i { color: var(--roxo); }

.lateral-rodape {
  padding: 10px;
  border-top: 1px solid var(--borda);
  flex-shrink: 0;
  display: flex; flex-direction: column; gap: 6px;
}

.conteudo {
  flex: 1; min-width: 0;
  margin-left: var(--lateral);
  display: flex; flex-direction: column;
}

.cabecalho {
  height: var(--topo);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 22px;
  background: var(--vidro);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid var(--borda);
  position: sticky; top: 0; z-index: 20;
}
.cabecalho h1 {
  font-size: 16px; font-weight: 620; letter-spacing: -.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cabecalho-dir { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }

main { padding: 22px; flex: 1; max-width: 1560px; width: 100%; }

/* ── selo de conexão ─────────────────────────────────────────────────── */

.selo {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--bg3);
  border: 1px solid var(--borda);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.ponto {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--txt3); flex-shrink: 0;
}
.selo.on { border-color: color-mix(in srgb, var(--verde) 34%, transparent); }
.selo.on .ponto {
  background: var(--verde);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--verde) 18%, transparent);
  animation: pulsa 2.4s ease-in-out infinite;
}
.selo.off { border-color: color-mix(in srgb, var(--vermelho) 32%, transparent); }
.selo.off .ponto { background: var(--vermelho); }
.selo.meio { border-color: color-mix(in srgb, var(--amarelo) 32%, transparent); }
.selo.meio .ponto { background: var(--amarelo); animation: pulsa 1.1s ease-in-out infinite; }
@keyframes pulsa { 50% { opacity: .45; } }

.tempo-no-ar { color: var(--txt2); font-size: 12px; white-space: nowrap; }

/* Nome curto da aba: só a barra de baixo do celular usa. */
.menu .item .rotulo-curto { display: none; }

/* ── alternador de tema ──────────────────────────────────────────────── */

.alternar-tema { position: relative; }
.alternar-tema .ph-sun { display: none; }
:root[data-theme="light"] .alternar-tema .ph-sun { display: inline; }
:root[data-theme="light"] .alternar-tema .ph-moon { display: none; }

/* ── responsivo (comportamento preservado do original) ───────────────── */

@media (max-width: 1080px) and (min-width: 721px) {
  :root { --lateral: 68px; }
  .marca > .marca-nome { display: none; }
  .marca { justify-content: center; padding: 0; }
  .menu .item { justify-content: center; padding: 12px 0; }
  .menu .item span { display: none; }
  .menu .item.ativo::before { left: 0; }
  .lateral-rodape .rotulo { display: none; }
}

@media (max-width: 720px) {
  .lateral {
    inset: auto 0 0 0;
    width: 100%;
    height: var(--barra-baixo);
    flex-direction: row;
    border-right: 0;
    border-top: 1px solid var(--borda);
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--vidro-forte);
  }
  .marca, .lateral-rodape { display: none; }
  .menu { flex-direction: row; padding: 0; gap: 0; width: 100%; overflow-x: auto; }
  .menu .item {
    flex: 1;
    flex-direction: column;
    gap: 3px;
    padding: 8px 2px;
    border-radius: 0;
    font-size: 10px;
    text-align: center;
    justify-content: center;
    min-width: 48px; min-height: 48px;
  }
  /* 7 abas em 320px de tela: o nome longo sai, entra o curto, e o item pode
     encolher ate 44px (o minimo confortavel para o dedo). Sem isso a ultima
     aba — a do Chat — ficava fora da tela e ninguem achava ela. */
  .menu .item span { display: none; }
  .menu .item .rotulo-curto {
    display: block; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; max-width: 100%;
  }
  .menu .item { flex: 1 1 0; min-width: 44px; }
  .menu .item i { font-size: 21px; width: auto; }
  .menu .item.ativo { background: transparent; }
  .menu .item.ativo::before {
    left: 50%; top: 0;
    transform: translateX(-50%);
    width: 24px; height: 3px;
    border-radius: 0 0 3px 3px;
  }

  .conteudo { margin-left: 0; padding-bottom: var(--barra-baixo); }
  .cabecalho { padding: 0 14px; }
  .cabecalho h1 { font-size: 15px; }
  .tempo-no-ar { display: none; }
  main { padding: 14px; }

  /* ── dedo não é ponteiro: nada interativo abaixo de 44px no celular ──
     Medido em auditoria mobile: o seletor de período tinha 28px de altura,
     os ícones do topo 34px e os .btn-mini do Banco 23px. Alvo pequeno demais
     erra o toque e faz o usuário achar que o painel "não responde". */
  button,
  a.btn,
  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea,
  .ficha { min-height: 44px; }
  .btn-icone,
  .ficha { min-width: 44px; width: auto; height: auto; padding-inline: 8px; }
}

@media (max-width: 400px) {
  .selo .rotulo-conexao { display: none; }
  .selo { padding: 5px 9px; }
}

/* Celular pequeno: 7 abas em DUAS fileiras de 4. Apertar tudo numa linha
   so funcionava em telas de 320px para cima; com a letra grande do Android
   (ou num aparelho mais estreito) a ultima aba teimava em sair da tela. Em
   grade, todas aparecem sempre. A barra cresce e --barra-baixo acompanha,
   para o conteudo nao ficar escondido atras dela. */
@media (max-width: 400px) {
  :root { --barra-baixo: calc(96px + env(safe-area-inset-bottom)); }
  .lateral { height: auto; min-height: 96px; }
  .menu {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    overflow: visible;
  }
  .menu .item { flex: none; min-width: 0; height: 48px; padding: 5px 1px; }
}

/* ── acessibilidade: respeita quem pede menos movimento ──────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── impressão: enterprise = o relatório precisa sair legível ────────── */

@media print {
  .lateral, .cabecalho, .alternar-tema, .btn { display: none !important; }
  .conteudo { margin-left: 0; }
  body { background: #fff; color: #000; }
  .bloco, .metrica, .ops-card { break-inside: avoid; border-color: #ccc; }
}
