:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e1e0dc;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #75746f;
  --accent: #2a78d6;
  --accent-text: #ffffff;
  --grid: #e7e6e2;
  --st-ativo: #0ca30c;
  --st-inativo: #fab219;
  --st-nunca: #ec835a;
  --st-desativado: #9a9993;
  --st-removido: #c3c2b7;
  --erro-bg: #fbe9e9;
  --erro-text: #8f1f1f;
  --ok-bg: #e6f4e6;
  --ok-text: #135c13;
  --alerta-bg: #fff4d6;
  --alerta-text: #6b4a00;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110;
    --surface: #1a1a19;
    --surface-2: #232321;
    --border: #2f2f2c;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --text-3: #9a9993;
    --accent: #3987e5;
    --grid: #2a2a28;
    --st-desativado: #75746f;
    --st-removido: #52514e;
    --erro-bg: #3a1d1d;
    --erro-text: #f3b4b4;
    --ok-bg: #16301a;
    --ok-text: #a8e0a8;
    --alerta-bg: #362a0c;
    --alerta-text: #f5d58a;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 650; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 650; }
.sub { color: var(--text-2); margin: 0 0 20px; }
.muted { color: var(--text-3); }
.num { font-variant-numeric: tabular-nums; text-align: right; }

/* topo */
.topo {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.marca { font-weight: 700; letter-spacing: .2px; }
.topo nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.topo nav a { color: var(--text-2); padding: 6px 10px; border-radius: 6px; }
.topo nav a:hover { background: var(--surface-2); text-decoration: none; }
.topo nav a.sel { color: var(--text); background: var(--surface-2); font-weight: 600; }
.quem { color: var(--text-2); display: flex; gap: 8px; align-items: center; }

main { max-width: 1240px; margin: 0 auto; padding: 24px; }

/* blocos */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 18px; margin-bottom: 20px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; display: block; color: inherit; }
a.kpi:hover { text-decoration: none; border-color: var(--text-3); }
.kpi .rot { color: var(--text-2); display: flex; align-items: center; gap: 8px; font-size: 13px; }
.kpi .val { font-size: 30px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 4px; }
.kpi .det { color: var(--text-3); font-size: 12px; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.flash.ok { background: var(--ok-bg); color: var(--ok-text); }
.flash.erro { background: var(--erro-bg); color: var(--erro-text); }
.aviso { background: var(--alerta-bg); color: var(--alerta-text); padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }

/* status: ponto colorido + texto (cor nunca sozinha) */
.st { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--st-desativado); }
.dot.ativo { background: var(--st-ativo); }
.dot.inativo { background: var(--st-inativo); }
.dot.nunca { background: var(--st-nunca); }
.dot.desativado { background: var(--st-desativado); }
.dot.removido { background: transparent; border: 1.5px solid var(--st-removido); }

/* tabelas */
.tabela-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .3px; white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; }
.zero { color: var(--text-3); }
.grupo-titulo { display: flex; align-items: baseline; gap: 10px; margin: 18px 0 6px; }
.grupo-titulo h2 { margin: 0; }

/* filtros e formulários */
.filtros { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.filtros label, .campo { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); }
.filtros label.check { flex-direction: row; align-items: center; gap: 6px; font-size: 14px; color: var(--text); padding-bottom: 8px; }
input, select, button {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 7px; padding: 7px 10px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button, .btn {
  cursor: pointer; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 7px; padding: 7px 12px; display: inline-block;
}
button:hover, .btn:hover { border-color: var(--text-3); text-decoration: none; }
button.prim, .btn.prim { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.perigo { color: var(--erro-text); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); }
form.inline { display: inline; }
.acoes { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.linha-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }

/* login */
.login-box { max-width: 360px; margin: 10vh auto; }
.login-box form { display: flex; flex-direction: column; gap: 12px; }

/* gráfico */
.grafico svg { width: 100%; height: auto; display: block; }
.grafico .grid { stroke: var(--grid); stroke-width: 1; }
.grafico .eixo { fill: var(--text-3); font-size: 11px; }
.grafico rect.ativos { fill: var(--st-ativo); }
.grafico rect.inativos { fill: var(--st-inativo); }
.grafico rect.nunca { fill: var(--st-nunca); }
.grafico rect.desativados { fill: var(--st-desativado); }
.grafico g.barra:hover rect.seg { opacity: .8; }
.grafico rect.hit { fill: transparent; }
.legenda { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; color: var(--text-2); font-size: 13px; }
.tooltip {
  position: fixed; pointer-events: none; z-index: 10; display: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; box-shadow: 0 4px 16px rgba(0,0,0,.15); font-size: 13px; min-width: 170px;
}
.tooltip .l { display: flex; justify-content: space-between; gap: 16px; }

@media (max-width: 640px) {
  main { padding: 16px; }
  .topo { padding: 10px 16px; gap: 8px; }
  .acoes { margin-left: 0; }
}
