/* Tokens — paleta de dataviz validada (rampa azul sequencial, status fixos). Claro e escuro. */
:root {
  color-scheme: light;
  --surface: #fcfcfb; --plane: #f9f9f7;
  --ink: #0b0b0b; --ink-2: #52514e; --muted: #898781;
  --grid: #e1e0d9; --axis: #c3c2b7; --ring: rgba(11,11,11,.10);
  --accent: #2a78d6; --accent-ink: #ffffff;
  --nd: #898781;
  --good: #0ca30c; --warn: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --shadow: 0 6px 24px rgba(0,0,0,.14);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface: #1a1a19; --plane: #0d0d0d; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --ring: rgba(255,255,255,.10);
    --accent: #3987e5; --shadow: 0 6px 24px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface: #1a1a19; --plane: #0d0d0d; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --ring: rgba(255,255,255,.10);
  --accent: #3987e5; --shadow: 0 6px 24px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--plane); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex; flex-direction: column; }
h1 { font-size: 16px; margin: 0 8px 0 0; white-space: nowrap; }
button, select, input, textarea { font: inherit; color: inherit; }

.bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--grid); z-index: 5; }
.field { display: flex; flex-direction: column; gap: 2px; position: relative; }
.field label { font-size: 11px; color: var(--ink-2); }
.field.chk { justify-content: flex-end; padding-bottom: 6px; }
.field.chk label { font-size: 13px; color: var(--ink); display: flex; gap: 6px; align-items: center; }
select, input[type=search], input[type=text], textarea {
  background: var(--surface); border: 1px solid var(--axis); border-radius: 6px; padding: 6px 8px; min-height: 32px; }
select:focus-visible, input:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; }
.ghost { background: transparent; border: 1px solid var(--axis); border-radius: 6px; min-width: 32px; min-height: 32px;
  cursor: pointer; }
.ghost:hover { background: var(--grid); }
.search { min-width: 200px; }
.sugestoes { position: absolute; top: 100%; left: 0; right: 0; margin: 2px 0 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--axis); border-radius: 6px; box-shadow: var(--shadow); z-index: 20; }
.sugestoes li { padding: 6px 8px; border-radius: 4px; cursor: pointer; }
.sugestoes li:hover, .sugestoes li[aria-selected=true] { background: var(--grid); }

.stage { position: relative; flex: 1; min-height: 0; }
#map { position: absolute; inset: 0; background: var(--plane); }

.legenda, .painel, .ficha, .aviso { position: absolute; background: var(--surface); border: 1px solid var(--ring);
  border-radius: 10px; box-shadow: var(--shadow); }
.legenda { left: 12px; bottom: 28px; padding: 10px 12px; max-width: 290px; font-size: 12px; }
.legenda h2 { font-size: 12px; margin: 0 0 2px; }
.legenda p { margin: 0 0 8px; color: var(--ink-2); font-size: 11px; }
.legenda .item { display: flex; align-items: center; gap: 8px; padding: 1px 0; color: var(--ink); }
.legenda .sw { width: 14px; height: 14px; border-radius: 50%; flex: none; border: 1.5px solid var(--surface);
  box-shadow: 0 0 0 1px var(--ring); }
.legenda .nd .sw { background: transparent; border: 2px solid var(--nd); box-shadow: none; }

.painel { right: 12px; top: 12px; width: 340px; max-height: calc(100% - 24px); display: flex; flex-direction: column; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 10px 0; }
.presets button { background: transparent; border: 1px solid var(--axis); border-radius: 99px; padding: 4px 10px;
  font-size: 12px; cursor: pointer; }
.presets button:hover { background: var(--grid); }
.presets button[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tabs { display: flex; border-bottom: 1px solid var(--grid); }
.tabs button { flex: 1; background: none; border: 0; padding: 9px; cursor: pointer; color: var(--ink-2);
  border-bottom: 2px solid transparent; }
.tabs button[aria-selected=true] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tabbody { overflow: auto; padding: 8px 10px 12px; }
.tabbody .nota { color: var(--ink-2); font-size: 11px; margin: 2px 0 8px; }

table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 4px 6px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { font-weight: 600; font-size: 11px; color: var(--ink-2); position: sticky; top: 0; background: var(--surface); }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--grid); }
td.nd { color: var(--muted); }
.pill { display: inline-block; padding: 0 6px; border-radius: 99px; font-size: 10px; border: 1px solid var(--axis); color: var(--ink-2); }

.ficha { left: 12px; top: 12px; width: min(560px, calc(100% - 24px)); max-height: calc(100% - 24px); overflow: auto;
  padding: 14px 16px 16px; z-index: 6; }
.ficha header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.ficha h2 { margin: 0; font-size: 18px; }
.ficha h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); margin: 16px 0 6px; }
.ficha .sub { color: var(--ink-2); font-size: 12px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-top: 10px; }
.kpi { border: 1px solid var(--grid); border-radius: 8px; padding: 8px 10px; }
.kpi b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 11px; color: var(--ink-2); }
.form { display: grid; gap: 8px; }
.form textarea { min-height: 70px; resize: vertical; width: 100%; }
.btn { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 6px; padding: 7px 14px; cursor: pointer; }
.btn:hover { filter: brightness(1.08); }
.aviso { left: 50%; transform: translateX(-50%); top: 12px; padding: 8px 14px; font-size: 13px; z-index: 30; }
.maplibregl-popup-content { background: var(--surface); color: var(--ink); border-radius: 8px; padding: 8px 10px; font-size: 12px;
  box-shadow: var(--shadow); }
.maplibregl-popup-tip { display: none; }

@media (max-width: 860px) {
  .painel { top: auto; right: 0; left: 0; bottom: 0; width: auto; max-height: 38%; border-radius: 10px 10px 0 0; }
  .legenda { bottom: calc(38% + 10px); }
  .ficha { inset: 8px; width: auto; max-height: none; }
}
@media (forced-colors: active) { .legenda .sw { forced-color-adjust: none; } }
