*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }

/* =====================================================================
   Tokens — a escada do azul da marca: o azul cheio só nos detalhes
   (botão principal, item ativo, dados); os tons claros dele nas áreas.
   Cada situação tem a sua cor, sempre: verde = ok, âmbar = atenção,
   vermelho = erro, ardósia = a verificar. Bater o olho e entender.
   ===================================================================== */
/* Modo claro "suave": nenhuma área grande em branco puro. O fundo é um cinza-azulado médio-claro,
   os cards ficam um passo acima dele (não brancos) e os tons de situação são um pouco mais densos,
   para continuarem legíveis sem ofuscar. */
:root {
  color-scheme: light;
  --ground: #d9e0eb;
  --sidebar: #e0e6ef;
  --surface: #ebf0f6;
  --raised: #e2e8f1;
  --sunken: #d1d9e5;
  --border: #c4cfdd;
  --rule: #d5dde8;
  --control: #b9c6d8;
  --control-hover: #9aabc3;
  --text: #13253d;
  --text-2: #2f3f56;
  --muted: #4c5b72;
  --faint: #56657c;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-ink: #1d4ed8;
  --accent-soft: #d6e2f8;
  --accent-soft-2: #c6d6f4;
  --on-accent: #ffffff;
  --hue: #2563eb;
  --hue-track: #cfd8e6;
  --focus: #3b82f6;

  --positive: #036c4e;
  --negative: #b3193a;
  --warning: #a14709;
  --danger-solid: #c81e3c;

  /* Situação (nomes usados pelo app.js) */
  --st-ok-fg: #036c4e;       --st-ok-bg: #d0ecdd;
  --st-aviso-fg: #a14709;    --st-aviso-bg: #f6e3bf;
  --st-erro-fg: #b3193a;     --st-erro-bg: #f5d6dc;
  --st-pendente-fg: #44526a; --st-pendente-bg: #d9e1ec;
  --st-ausente-fg: #56657c;  --st-ausente-bg: #e2e8f0;
  --bar-erro: #dc4146;
  --bar-aviso: #e89b23;
  --bar-ok: #199a65;
  --bate-bg: #d0ecdd;
  --bate-bd: #7cc6a0;

  --sev-critico: var(--st-erro-fg);
  --sev-medio: var(--st-aviso-fg);
  --sev-baixo: var(--muted);
  --text-muted: var(--muted);

  --shadow-card: 0 1px 2px rgba(23, 50, 90, .08);
  --shadow-lift: 0 12px 28px -16px rgba(23, 50, 90, .4);
  --shadow-float: 0 24px 56px -20px rgba(16, 35, 70, .45), 0 2px 8px rgba(16, 35, 70, .08);
  --overlay: rgba(16, 35, 70, .45);

  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --fs-title: 26px; --fs-section: 16px; --fs-kpi: 28px; --fs-body: 14px; --fs-small: 12px;

  --sidebar-width: 248px;
  --pad: 32px;
  --gap: 14px;
  --card-pad: 20px;
  --radius-card: 16px;
  --radius-inner: 12px;
  --radius-control: 10px;
  --control-height: 38px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --t-press: 120ms; --t-hover: 160ms; --t-ui: 200ms;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #0b1220; --sidebar: #0e1729; --surface: #131d30; --raised: #18243a; --sunken: #1e2b44;
    --border: #24324c; --rule: #1d2a42; --control: #33445f; --control-hover: #47597a;
    --text: #e8eef8; --text-2: #c9d4e6; --muted: #9aabc6; --faint: #8394b2;
    --accent: #2f6fe4; --accent-hover: #3b82f6; --accent-ink: #93bbfb; --accent-soft: #172a4a; --accent-soft-2: #1d3560;
    --hue: #5b9bf8; --hue-track: #1e2b44; --focus: #60a5fa;
    --positive: #4ade9b; --negative: #ff7a8f; --warning: #f7b955; --danger-solid: #d4213f;
    --st-ok-fg: #4ade9b;       --st-ok-bg: #0f2e25;
    --st-aviso-fg: #f7b955;    --st-aviso-bg: #3a2a10;
    --st-erro-fg: #ff7a8f;     --st-erro-bg: #3e1725;
    --st-pendente-fg: #aebbd2; --st-pendente-bg: #1e2a40;
    --st-ausente-fg: #8394b2;  --st-ausente-bg: #172238;
    --bar-erro: #f2555a; --bar-aviso: #f0a73a; --bar-ok: #2fbf7f;
    --bate-bg: #0f2e25; --bate-bd: #23714f;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lift: 0 14px 30px -16px rgba(0, 0, 0, .7);
    --shadow-float: 0 24px 56px -20px rgba(0, 0, 0, .75), 0 2px 8px rgba(0, 0, 0, .35);
    --overlay: rgba(2, 6, 14, .64);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #0b1220; --sidebar: #0e1729; --surface: #131d30; --raised: #18243a; --sunken: #1e2b44;
  --border: #24324c; --rule: #1d2a42; --control: #33445f; --control-hover: #47597a;
  --text: #e8eef8; --text-2: #c9d4e6; --muted: #9aabc6; --faint: #8394b2;
  --accent: #2f6fe4; --accent-hover: #3b82f6; --accent-ink: #93bbfb; --accent-soft: #172a4a; --accent-soft-2: #1d3560;
  --hue: #5b9bf8; --hue-track: #1e2b44; --focus: #60a5fa;
  --positive: #4ade9b; --negative: #ff7a8f; --warning: #f7b955; --danger-solid: #d4213f;
  --st-ok-fg: #4ade9b;       --st-ok-bg: #0f2e25;
  --st-aviso-fg: #f7b955;    --st-aviso-bg: #3a2a10;
  --st-erro-fg: #ff7a8f;     --st-erro-bg: #3e1725;
  --st-pendente-fg: #aebbd2; --st-pendente-bg: #1e2a40;
  --st-ausente-fg: #8394b2;  --st-ausente-bg: #172238;
  --bar-erro: #f2555a; --bar-aviso: #f0a73a; --bar-ok: #2fbf7f;
  --bate-bg: #0f2e25; --bate-bd: #23714f;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lift: 0 14px 30px -16px rgba(0, 0, 0, .7);
  --shadow-float: 0 24px 56px -20px rgba(0, 0, 0, .75), 0 2px 8px rgba(0, 0, 0, .35);
  --overlay: rgba(2, 6, 14, .64);
}

/* ============ Base ============ */
body { background: var(--ground); color: var(--text); font: 500 var(--fs-body)/20px var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
svg { flex: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::placeholder { color: var(--faint); opacity: 1; }
::selection { background: var(--accent-soft-2); }
[hidden] { display: none !important; }
.num, table, input.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12.5px; letter-spacing: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.c-erro { color: var(--st-erro-fg); font-weight: 700; }
.c-aviso { color: var(--st-aviso-fg); font-weight: 700; }

/* ============ Botões ============ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--control-height); padding: 0 16px;
  border-radius: var(--radius-control); border: 0; background: var(--accent-soft); color: var(--accent-ink);
  font-size: 14px; font-weight: 700; white-space: nowrap; transition: background-color var(--t-hover) ease, color var(--t-hover) ease, transform var(--t-press) var(--ease-out); }
.btn:hover { background: var(--accent-soft-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { cursor: progress; opacity: .7; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--sunken); color: var(--text); }
.btn-danger, .btn-soft-red { background: var(--st-erro-bg); color: var(--st-erro-fg); }
.btn-danger:hover, .btn-soft-red:hover { background: var(--st-erro-bg); filter: brightness(.96); }
.btn-soft-amber { background: var(--st-aviso-bg); color: var(--st-aviso-fg); }
.btn-soft-amber:hover { background: var(--st-aviso-bg); filter: brightness(.96); }
.btn-ghost.btn-danger { background: transparent; color: var(--muted); }
.btn-ghost.btn-danger:hover { background: var(--st-erro-bg); color: var(--st-erro-fg); filter: none; }
.btn-danger-solid { background: var(--danger-solid); color: #fff; }
.btn-danger-solid:hover { background: var(--danger-solid); filter: brightness(.92); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn-full { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: var(--radius-control); background: transparent; color: var(--text); }
.icon-btn:hover { background: var(--accent-soft); color: var(--accent-ink); }
.icon-btn svg { width: 20px; height: 20px; }
.link { display: inline-flex; align-items: center; gap: 2px; padding: 0; border: 0; background: none; color: var(--accent-ink); font-weight: 700; font-size: 13px; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.link svg { width: 14px; height: 14px; }

/* ============ Campos ============ */
.field-input, .field-textarea { width: 100%; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--raised);
  color: var(--text); font-size: 14px; font-weight: 500; transition: border-color var(--t-hover) ease, background-color var(--t-hover) ease; }
.field-input { height: var(--control-height); padding: 0 12px; }
.field-input:hover, .field-textarea:hover { border-color: var(--control); }
.field-input:focus, .field-textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; background: var(--surface); }
.field-textarea { padding: 9px 12px; line-height: 21px; resize: vertical; min-height: 60px; display: block; }
select.field-input { appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5l3-3' fill='none' stroke='%237c8aa0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
select.field-input option { background: var(--surface); color: var(--text); }
.field-mono { font-family: var(--mono); font-size: 13px; }
.field-label { display: block; font-size: 13px; font-weight: 700; color: var(--text-2); margin-bottom: 7px; }
.field-hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; line-height: 18px; font-weight: 500; }
.field-hint .mono { font-size: 12px; }

/* Caixa liga/desliga (Integrado, Possui o módulo… no azul; Conferido no verde) */
.check { --c: var(--accent-ink); --cbg: var(--accent-soft); --cbox: var(--accent);
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px 0 9px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: background-color var(--t-hover) ease, color var(--t-hover) ease, border-color var(--t-hover) ease; }
.check.v-ok { --c: var(--st-ok-fg); --cbg: var(--st-ok-bg); --cbox: var(--bar-ok); }
.check:hover { border-color: var(--control); color: var(--text); }
.check-box { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--control-hover); background: var(--surface); }
.check-box svg { width: 10px; height: 10px; opacity: 0; color: #fff; }
.check.on { background: var(--cbg); border-color: transparent; color: var(--c); }
.check.on .check-box { background: var(--cbox); border-color: var(--cbox); }
.check.on .check-box svg { opacity: 1; }

/* Controle segmentado: o selecionado ganha a cor do que significa */
.seg { display: inline-flex; width: max-content; max-width: 100%; gap: 3px; padding: 3px; border-radius: 999px; background: var(--sunken); }
.seg button { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 13px; border: 0; border-radius: 999px;
  background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap; transition: background-color var(--t-hover) ease, color var(--t-hover) ease; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--accent); color: var(--on-accent); }
.seg button.on.s-ok, .seg button.on.s-operando { background: var(--st-ok-bg); color: var(--st-ok-fg); }
.seg button.on.s-falha { background: var(--st-erro-bg); color: var(--st-erro-fg); }
.seg button.on.s-pausado { background: var(--st-aviso-bg); color: var(--st-aviso-fg); }
.seg button.on.s-nao_verificado, .seg button.on.s-nao_criado { background: var(--surface); color: var(--st-pendente-fg); }
.seg .seg-n { opacity: .8; font-weight: 500; }
.seg button.on .rb { color: currentColor; }

/* Abas */
.tabs { display: flex; align-items: flex-end; gap: 6px; border-bottom: 1px solid var(--border); }
.tab { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 42px; padding: 0 12px; border: 0; background: none; color: var(--muted);
  font-size: 14px; font-weight: 700; white-space: nowrap; border-radius: 10px 10px 0 0; transition: color var(--t-hover) ease, background-color var(--t-hover) ease; }
.tab:hover { color: var(--accent-ink); background: var(--accent-soft); }
.tab[aria-selected="true"] { color: var(--accent-ink); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--accent); }
.tab:disabled { cursor: not-allowed; color: var(--muted); background: none; }
.tab .tab-n { font-weight: 600; font-size: 12px; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center;
  background: var(--sunken); color: var(--muted); font-variant-numeric: tabular-nums; }
.tab[aria-selected="true"] .tab-n { background: var(--accent-soft); color: var(--accent-ink); }
.tab-aside { margin-left: auto; align-self: center; padding-bottom: 4px; display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--text-2); }
.tab-aside select.field-input { height: 34px; width: auto; font-size: 13px; font-weight: 700; }

/* Abas de situação (Sistemas): cada uma com a cor da situação */
.st-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 999px; background: var(--sunken); }
.st-tab { --c: var(--accent-ink); --cbg: var(--accent-soft); --cdot: var(--accent);
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border: 0; border-radius: 999px; background: transparent;
  color: var(--text-2); font-size: 13px; font-weight: 600; white-space: nowrap; transition: background-color var(--t-hover) ease, color var(--t-hover) ease; }
.st-tab .dot { background: var(--cdot); }
.st-tab.st-erro { --c: var(--st-erro-fg); --cbg: var(--st-erro-bg); --cdot: var(--bar-erro); }
.st-tab.st-aviso { --c: var(--st-aviso-fg); --cbg: var(--st-aviso-bg); --cdot: var(--bar-aviso); }
.st-tab.st-pendente { --c: var(--st-pendente-fg); --cbg: var(--surface); --cdot: var(--st-pendente-fg); }
.st-tab.st-ok { --c: var(--st-ok-fg); --cbg: var(--st-ok-bg); --cdot: var(--bar-ok); }
.st-tab:hover { color: var(--c); }
.st-tab[aria-selected="true"] { background: var(--cbg); color: var(--c); }
.st-tab.st-todos[aria-selected="true"] { background: var(--accent); color: var(--on-accent); }
.st-tab .tab-n { font-weight: 700; opacity: .75; font-variant-numeric: tabular-nums; }

/* ============ Selos de situação ============ */
.tag { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  white-space: nowrap; flex: none; background: var(--st-pendente-bg); color: var(--st-pendente-fg); }
.tag-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.tag-erro { background: var(--st-erro-bg); color: var(--st-erro-fg); }
.tag-aviso { background: var(--st-aviso-bg); color: var(--st-aviso-fg); }
.tag-ok { background: var(--st-ok-bg); color: var(--st-ok-fg); }
.tag-blue { background: var(--accent-soft); color: var(--accent-ink); }

/* Sinal do robô de coleta: ponto = operando, barras = pausado, anel = não criado */
.rb { width: 12px; height: 12px; flex: none; }
.rb-operando { color: var(--st-ok-fg); }
.rb-pausado { color: var(--st-aviso-fg); }
.rb-nao_criado { color: var(--faint); }
.robo-tag { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  white-space: nowrap; background: var(--st-ok-bg); color: var(--st-ok-fg); }
.robo-tag.pausado { background: var(--st-aviso-bg); color: var(--st-aviso-fg); }
.robo-tag.nao_criado { background: var(--st-pendente-bg); color: var(--st-pendente-fg); }
.panel-foot .robo-tag { background: none; padding: 0; height: auto; font-weight: 600; color: var(--muted); }

/* ============ Moldura do app ============ */
.app-shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }
.topbar { display: none; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 22px 14px 16px; overflow: auto;
  background: var(--sidebar); border-right: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 24px; }
.brand-chip { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--accent); flex: none; }
.brand-chip svg { width: 24px; height: 24px; }
.brand-name { font-size: 15px; font-weight: 700; line-height: 19px; letter-spacing: -0.01em; }
.brand-scope { font-size: 12px; line-height: 16px; color: var(--muted); font-weight: 600; }
.sidebar-close { display: none; margin-left: auto; }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-btn { display: flex; align-items: center; gap: 11px; height: 42px; width: 100%; padding: 0 12px; border: 0; border-radius: 12px;
  background: transparent; color: var(--muted); font-size: 14px; font-weight: 600; text-align: left; transition: background-color var(--t-hover) ease, color var(--t-hover) ease; }
.nav-btn svg { width: 18px; height: 18px; }
.nav-btn:hover { background: var(--accent-soft); color: var(--accent-ink); }
.nav-btn[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; }
.nav-btn[aria-current="page"] svg { color: var(--accent); }
.nav-label { flex: 1; min-width: 0; }
.nav-count { font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 22px; height: 20px; padding: 0 7px; border-radius: 999px;
  display: inline-grid; place-items: center; background: var(--st-erro-bg); color: var(--st-erro-fg); }
.sidebar-foot { margin-top: auto; padding-top: 16px; }
.theme-switch { display: flex; align-items: center; gap: 10px; border: 0; background: transparent; padding: 0; color: var(--muted); font-size: 14px; font-weight: 600; }
.sidebar-theme-switch { width: 100%; height: 42px; padding: 0 12px; border-radius: 12px; justify-content: space-between; }
.sidebar-theme-switch:hover { background: var(--accent-soft); color: var(--accent-ink); }
.theme-switch-track { position: relative; width: 34px; height: 20px; border-radius: 999px; background: var(--control); flex: none; transition: background-color var(--t-ui) ease; }
.theme-switch-thumb { position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform var(--t-ui) var(--ease-out); }
:root[data-theme="dark"] .theme-switch-track { background: var(--accent); }
:root[data-theme="dark"] .theme-switch-thumb { transform: translateX(14px); }

.main { min-width: 0; }
.page { padding: 30px var(--pad) 56px; display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head-text { min-width: 0; flex: 1 1 360px; }
.page-title { font-size: var(--fs-title); line-height: 32px; font-weight: 700; letter-spacing: -0.03em; }
.page-sub { margin-top: 5px; color: var(--muted); font-size: 14px; font-weight: 500; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-erro { flex-basis: 100%; text-align: right; font-size: 13px; font-weight: 600; color: var(--negative); }
.title-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ============ Painéis ============ */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: var(--card-pad); min-width: 0; box-shadow: var(--shadow-card); }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-title { font-size: var(--fs-section); line-height: 22px; font-weight: 700; letter-spacing: -0.015em; }
.panel-meta { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.panel-foot { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--rule); display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); font-weight: 600; }
.panel-foot b { color: var(--text); font-weight: 700; }

.empty { display: grid; place-items: center; gap: 6px; min-height: 96px; padding: 24px; border: 1.5px dashed var(--control); border-radius: var(--radius-card);
  color: var(--muted); text-align: center; font-size: 14px; background: var(--surface); }
.empty .t { color: var(--text); font-weight: 700; font-size: 15px; }

/* ============ Painel (visão geral) ============ */
/* Faixa de situação dos sistemas: o número na cor da situação */
.kpis { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: var(--gap); }
.kpi { position: relative; display: grid; gap: 4px; align-content: start; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius-card);
  background: var(--surface); text-align: left; transition: border-color var(--t-hover) ease, box-shadow var(--t-hover) ease, transform var(--t-hover) var(--ease-out); }
.kpi:hover { border-color: var(--k, var(--control)); box-shadow: var(--shadow-lift); transform: translateY(-1px); }
.kpi-label { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; font-weight: 700; }
.kpi-value { font-size: var(--fs-kpi); line-height: 34px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--k, var(--text)); }
.kpi-value small { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 6px; letter-spacing: 0; }
.kpi-cap { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi.on { border-color: var(--k); background: color-mix(in srgb, var(--k) 8%, var(--surface)); }
.kpi.on .kpi-label { color: var(--k); }
.kpi.on::after { content: ""; position: absolute; left: 18px; right: 18px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--k); }

.ov-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr); gap: var(--gap); align-items: start; }
.ov-side { display: grid; gap: var(--gap); min-width: 0; }
.ov-matrix { padding-bottom: 14px; }

/* Mapa: sistema × módulo */
.legend { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; flex: none; max-width: 60%; }
.legend-tile { height: 24px; font-size: 12px; padding: 0 9px; }
.matrix { width: 100%; border-collapse: collapse; table-layout: fixed; }
.matrix th { height: 30px; padding: 0 5px 6px; font-size: 12px; font-weight: 700; color: var(--muted); text-align: left; white-space: nowrap; vertical-align: bottom; }
.matrix th:first-child, .matrix td:first-child { padding-left: 0; }
.matrix th.num { text-align: right; }
.matrix col.c-mun { width: 132px; }
.matrix col.c-mod { width: 120px; }
.matrix col.c-chev { width: 26px; }
.mx-row { cursor: pointer; }
.mx-row td { height: 40px; padding: 3px 5px; border-top: 1px solid var(--rule); vertical-align: middle; transition: background-color var(--t-hover) ease; }
.mx-row:hover td { background: var(--accent-soft); }
.mx-row:hover td:first-child { box-shadow: -8px 0 0 var(--accent-soft); }
.mx-row:hover td:last-child { box-shadow: 8px 0 0 var(--accent-soft); color: var(--accent-ink); }
.mx-nome { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mx-link { min-width: 0; padding: 0; border: 0; background: none; font-weight: 700; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mx-link:hover { color: var(--accent-ink); }
.st-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--bar-ok); }
.st-dot.st-erro { background: var(--bar-erro); }
.st-dot.st-aviso { background: var(--bar-aviso); }
.st-dot.st-pendente { background: var(--st-pendente-fg); }
.mx-mun { text-align: right; }
.mx-mun-in { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.mx-mun-bar { width: 70px; height: 6px; border-radius: 3px; background: var(--hue-track); overflow: hidden; display: flex; }
.mx-mun-bar i { display: block; height: 100%; background: var(--hue); border-radius: 3px; }
.mx-mun-n { min-width: 22px; text-align: right; font-weight: 700; }
.mx-chev { color: var(--faint); text-align: right; }
.mx-chev svg { width: 14px; height: 14px; display: inline-block; vertical-align: middle; }

/* Ladrilho de módulo: cada situação com a sua cor */
.tile { display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 9px; border-radius: 9px; font-size: 12.5px; font-weight: 700; white-space: nowrap;
  min-width: 0; background: var(--st-ok-bg); color: var(--st-ok-fg); }
.tile-txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tile-glyph { display: none; }
.tile .rb { margin-left: auto; }
.tile.t-erro { background: var(--st-erro-bg); color: var(--st-erro-fg); }
.tile.t-aviso { background: var(--st-aviso-bg); color: var(--st-aviso-fg); }
.tile.t-pendente { background: var(--st-pendente-bg); color: var(--st-pendente-fg); }
.tile.t-ausente { color: var(--st-ausente-fg); font-weight: 600;
  background: var(--st-ausente-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='6' viewBox='0 0 6 6'%3E%3Cpath d='M-1 1l2-2M0 6l6-6M5 7l2-2' stroke='%238394b2' stroke-opacity='.4' stroke-width='1'/%3E%3C/svg%3E"); }
.tile.t-erro .rb, .tile.t-aviso .rb { color: currentColor; }

/* Números de destaque e barras */
.lead { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.lead-n { font-size: var(--fs-kpi); line-height: 34px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.lead-n.sm { font-size: 26px; line-height: 30px; }
.lead-txt { color: var(--text-2); font-weight: 600; }
.stack { display: flex; gap: 3px; height: 12px; border-radius: 999px; overflow: hidden; background: var(--hue-track); }
.stack i { display: block; height: 100%; flex: 1 1 0; min-width: 3px; }
.s-erro { background: var(--bar-erro); }
.s-aviso { background: var(--bar-aviso); }
.s-ok { background: var(--bar-ok); }
.s-pendente { background: var(--st-pendente-fg); }
.s-track, .s-sem { background: var(--hue-track); }
.stack-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; font-size: 13px; color: var(--muted); font-weight: 600; }
.stack-legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.stack-legend b { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.legend-sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.legend-sw.s-track { box-shadow: inset 0 0 0 1px var(--control); }
.progress-list { display: grid; gap: 16px; }
.progress-row { display: grid; gap: 8px; padding: 0; border: 0; background: none; text-align: left; }
.progress-row:hover .progress-label { color: var(--k); }
.progress-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.progress-label { font-weight: 700; transition: color var(--t-hover) ease; }
.progress-val { font-variant-numeric: tabular-nums; }
.progress-val b { font-size: 22px; font-weight: 700; color: var(--k); letter-spacing: -0.02em; }
.progress-val small { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.progress { height: 10px; border-radius: 999px; background: var(--hue-track); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: 999px; background: var(--kb, var(--hue)); }
.aviso-linha { display: flex; align-items: center; gap: 8px; width: 100%; margin-top: 16px; padding: 10px 12px; border: 0; border-radius: var(--radius-inner);
  background: var(--st-aviso-bg); color: var(--st-aviso-fg); font-size: 13px; font-weight: 700; text-align: left; }
.aviso-linha .dot { background: var(--bar-aviso); }

/* Ocorrências abertas (resumo) */
.oco-mini { display: grid; gap: 6px; }
.oco-mini-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; width: 100%; padding: 10px 12px;
  border: 0; border-radius: var(--radius-inner); background: var(--raised); text-align: left; transition: background-color var(--t-hover) ease; }
.oco-mini-row:hover { background: var(--accent-soft); }
.oco-mini-sis { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oco-mini-sis span { color: var(--muted); font-weight: 600; }
.oco-mini-desc { grid-column: 1 / 4; color: var(--text-2); font-size: 13px; line-height: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.oco-mini-age { color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }

/* Ranking curto */
.rank { display: grid; gap: 12px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--rule); }
.rank-title { font-size: 12.5px; color: var(--muted); font-weight: 700; }
.rank-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; align-items: baseline; width: 100%; padding: 0; border: 0; background: none; text-align: left; }
.rank-row:hover .rank-nome { color: var(--accent-ink); }
.rank-nome { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-val { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; font-weight: 600; }
.rank-val b { color: var(--st-aviso-fg); font-weight: 700; font-size: 14px; }
.rank-bar { grid-column: 1 / -1; height: 6px; border-radius: 999px; background: var(--hue-track); overflow: hidden; display: flex; gap: 2px; }
.rank-bar i { display: block; height: 100%; }

/* ============ Sistemas ============ */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar-card { display: grid; gap: 10px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
.toolbar-card .search { flex: 1 1 320px; }
.list-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -4px 0 -8px; }
.list-bar .toolbar-count { margin-left: 4px; }
.list-bar .mun-ordem { width: auto; height: 34px; font-size: 13px; background-color: var(--surface); }
.toolbar .search { flex: 1 1 220px; min-width: 200px; position: relative; }
.toolbar .search svg { position: absolute; left: 12px; top: 11px; width: 16px; height: 16px; color: var(--faint); pointer-events: none; }
.toolbar .search .field-input { padding-left: 36px; }
.toolbar select.field-input { width: auto; max-width: 240px; }
.toolbar-count { margin-left: auto; font-size: 13px; color: var(--muted); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; padding-right: 4px; }

.group { display: grid; gap: 12px; }
.group + .group { margin-top: 18px; }
.group-head { display: flex; align-items: center; gap: 9px; font-size: 14px; }
.group-head .label { font-weight: 700; }
.group-head .n { color: var(--muted); font-weight: 600; font-size: 13px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--gap); }

.system-card { display: flex; flex-direction: column; gap: 12px; width: 100%; padding: 18px 20px 16px; text-align: left; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-card);
  transition: border-color var(--t-hover) ease, box-shadow var(--t-hover) ease, transform var(--t-hover) var(--ease-out); }
.system-card:hover { border-color: var(--accent-soft-2); box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.sc-head { display: flex; align-items: center; gap: 10px; }
.sc-nome { flex: 1; min-width: 0; font-size: 17px; line-height: 22px; font-weight: 700; letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-motivo { display: block; margin-top: -6px; font-size: 13px; color: var(--muted); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.tiles .tile { height: auto; padding: 8px 10px; flex-wrap: wrap; row-gap: 2px; align-items: flex-start; border-radius: 11px; }
.tile-sigla { flex: 0 0 100%; font-family: var(--mono); font-size: 11px; line-height: 16px; font-weight: 500; opacity: .85; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.tiles .tile-txt { line-height: 18px; }
.sc-foot { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--rule); font-size: 12.5px; color: var(--muted); font-weight: 600; }
.sc-foot b { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.sc-robo { display: inline-flex; align-items: center; gap: 6px; color: var(--st-ok-fg); }
.sc-robo::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* Painel de hover no card do sistema: um bloco colorido por módulo */
.hover-wrap { position: fixed; z-index: 60; pointer-events: none; display: flex; }
.hover-panel { width: 352px; max-width: 78vw; background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow-float); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.hover-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.hover-title { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; }
.hover-sub { font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 1px; }
.hover-mods { display: grid; gap: 8px; }
.hover-mod { display: grid; gap: 6px; padding: 10px 12px; border-radius: 12px; background: var(--st-ok-bg); }
.hover-mod.m-erro { background: var(--st-erro-bg); }
.hover-mod.m-aviso { background: var(--st-aviso-bg); }
.hover-mod.m-pendente, .hover-mod.m-ausente { background: var(--st-pendente-bg); }
.hover-mod-head { display: flex; align-items: center; gap: 8px; }
.hover-sigla { font-family: var(--mono); font-size: 11px; font-weight: 500; color: var(--muted); }
.hover-mod-nome { flex: 1; min-width: 0; font-size: 13px; font-weight: 700; }
.hover-mod .tag { height: 22px; padding: 0 8px; font-size: 11.5px; background: var(--surface) !important; }
.hover-robo { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; }
.hover-probs { display: grid; gap: 3px; }
.hover-prob { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; line-height: 18px; color: var(--text-2); font-weight: 500; }
.hover-prob-dot { margin-top: 6px; width: 6px; height: 6px; flex: 0 0 6px; border-radius: 50%; }
.hover-oco { display: grid; gap: 6px; padding-top: 4px; }
.hover-oco-title { font-size: 12.5px; font-weight: 700; color: var(--text-2); }

/* ============ Detalhe do sistema ============ */
.crumb { display: flex; align-items: center; gap: 6px; margin-bottom: -6px; }
.crumb-link { display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 12px 0 8px; border: 0; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-ink); font-size: 12.5px; font-weight: 700; }
.crumb-link:hover { background: var(--accent-soft-2); }
.crumb-link svg { width: 14px; height: 14px; }
.detail-url { display: inline-block; max-width: 100%; margin-top: 6px; font-family: var(--mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: top; }
.detail-body { min-width: 0; }
.tab-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: var(--gap); align-items: start; max-width: 1200px; }
.kv { display: grid; }
.kv-row { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--rule); }
.kv-row:first-child { border-top: 0; padding-top: 0; }
.kv-label { color: var(--muted); font-weight: 600; }
.kv-value { text-align: right; min-width: 0; word-break: break-word; font-weight: 700; }
.kv-value.vazio { color: var(--faint); font-weight: 500; }
.stack-fields { display: grid; gap: 16px; }

/* Municípios: um card por município (cadastro) ou linhas em tom claro (dentro do sistema) */
.list-head { display: grid; align-items: end; gap: 12px; padding: 0 16px 8px; font-size: 12px; font-weight: 700; color: var(--muted); }
.mun-row, .list-head.mun { grid-template-columns: 96px minmax(180px, 1fr) 210px 236px 168px; }
.mun-row.no-sis, .list-head.mun.no-sis { grid-template-columns: 96px minmax(180px, 1fr) 236px 200px; }
.mun-row { display: grid; align-items: center; gap: 12px; min-height: 60px; padding: 10px 16px; }
.mun-cards .mun-list { display: grid; gap: 8px; }
.mun-cards .mun-row { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-card); transition: border-color var(--t-hover) ease; }
.mun-cards .mun-row:hover { border-color: var(--accent-soft-2); }
.panel .mun-list { display: grid; gap: 6px; }
.panel .mun-row { background: var(--raised); border-radius: 12px; }
.panel .list-head { padding-top: 6px; }
.ibge { justify-self: start; font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--text-2); font-variant-numeric: tabular-nums;
  padding: 3px 8px; border-radius: 8px; background: var(--raised); border: 1px solid var(--border); }
.mun-ident { min-width: 0; }
.mun-nome { font-weight: 700; }
.uf { color: var(--muted); margin-left: 6px; font-family: var(--mono); font-size: 11.5px; font-weight: 500; }
.mun-url { margin-top: 2px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); }
/* URLs longas: uma linha, cortada dentro da própria caixa (quebra em qualquer ponto e mostra só a primeira linha). */
.mun-url a, .conf-mun-url { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; word-break: break-all; }
.herda { color: var(--faint); font-family: var(--font); font-weight: 500; }
.mun-flags { display: flex; gap: 6px; flex-wrap: wrap; }
.row-acoes { display: flex; gap: 4px; justify-content: flex-end; }
.mun-uf-head { display: flex; align-items: baseline; gap: 10px; padding: 14px 4px 2px; }
.mun-list > .mun-uf-head:first-child { padding-top: 0; }
.mun-uf-head .uf-sigla { font-family: var(--mono); font-weight: 500; font-size: 13px; padding: 2px 8px; border-radius: 8px; background: var(--accent-soft); color: var(--accent-ink); }
.mun-uf-head .n { font-size: 12.5px; color: var(--muted); font-weight: 600; }

/* Seletor com busca */
.picker-trigger { display: flex; align-items: center; gap: 8px; text-align: left; cursor: pointer; }
.picker-trigger .picker-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-trigger .picker-seta { flex: 0 0 auto; color: var(--faint); }
.picker-trigger.vazio { color: var(--st-aviso-fg); background: var(--st-aviso-bg); border-color: transparent; }
.picker-trigger.aberto { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
.mun-sis { height: 36px; font-size: 13.5px; font-weight: 600; }
.picker-panel { position: fixed; z-index: 70; background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-float); padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.picker-busca { width: 100%; height: 36px; border: 1px solid var(--border); border-radius: var(--radius-control); padding: 0 11px; font-size: 13.5px; font-weight: 500;
  background: var(--raised); color: var(--text); }
.picker-busca:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
.picker-lista { max-height: 264px; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.picker-opt { display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 10px; border-radius: 9px; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.picker-opt > span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-opt.vazio { color: var(--st-aviso-fg); }
.picker-opt:hover { background: var(--raised); }
.picker-opt.ativo { background: var(--accent-soft); color: var(--accent-ink); }
.picker-check { flex: 0 0 auto; display: inline-flex; color: var(--accent); }
.picker-check svg { width: 14px; height: 14px; }
.picker-vazio { padding: 14px 10px; text-align: center; font-size: 13px; color: var(--muted); }

/* Módulos do sistema */
.modules-list { max-width: 1200px; display: grid; gap: var(--gap); }
.module-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-card); overflow: hidden; }
.module-head { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; padding: 16px var(--card-pad); }
.module-toggle { display: flex; align-items: center; gap: 12px; flex: 1 1 380px; min-width: 0; padding: 0; border: 0; background: none; text-align: left; }
.module-toggle > svg { width: 18px; height: 18px; color: var(--faint); transition: transform var(--t-ui) var(--ease-out); }
.module-toggle[aria-expanded="true"] > svg { transform: rotate(90deg); color: var(--accent); }
.module-head-text { min-width: 0; display: grid; gap: 4px; }
.module-head-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.module-sigla { order: -1; font-family: var(--mono); font-size: 11px; font-weight: 500; padding: 3px 8px; border-radius: 8px; background: var(--accent-soft); color: var(--accent-ink); }
.module-nome { font-size: 17px; line-height: 22px; font-weight: 700; letter-spacing: -0.02em; }
.module-resumo { font-size: 13px; color: var(--muted); font-weight: 500; }
.module-toggles { display: flex; gap: 6px; flex-wrap: wrap; }
.module-body { border-top: 1px solid var(--rule); padding: 4px var(--card-pad) var(--card-pad); display: grid; }
.module-section { padding: 16px 0; display: grid; gap: 10px; }
.module-section + .module-section { border-top: 1px solid var(--rule); }
.module-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.module-section-title { font-size: 14px; font-weight: 700; }
.module-section-desc { font-size: 13px; color: var(--muted); margin-top: 2px; font-weight: 500; }
.req-list { display: grid; gap: 6px; }
.req-row { display: grid; gap: 8px; padding: 10px 12px 10px 14px; border-radius: 12px; background: var(--raised); }
.req-row.r-ok { background: var(--st-ok-bg); }
.req-row.r-falha { background: var(--st-erro-bg); }
.req-row.r-nao_verificado { background: var(--st-pendente-bg); }
.req-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.req-label { flex: 1 1 260px; min-width: 0; line-height: 20px; font-weight: 600; }
.req-row.r-falha .req-label { color: var(--st-erro-fg); }
.req-row .seg { background: var(--surface); }
.req-nota { width: 100%; height: 36px; padding: 0 11px; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface); color: var(--text); font-size: 13.5px; font-weight: 500; }
.req-nota:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
.occ-list { display: grid; gap: 6px; }
.occ-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 12px; align-items: start; padding: 12px 14px; border-radius: 12px; background: var(--raised); }
.occ-row.resolvida { opacity: .6; }
.occ-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.occ-sev { font-weight: 700; }
.occ-desc { margin-top: 4px; color: var(--text-2); line-height: 20px; max-width: 840px; overflow-wrap: anywhere; font-weight: 500; }
.occ-resolved { color: var(--st-ok-fg); font-weight: 700; }
.occ-acoes { display: flex; gap: 4px; }
.occ-empty { font-size: 13.5px; color: var(--muted); padding: 4px 0; font-weight: 500; }

/* ============ Ocorrências ============ */
.occ-cards { display: grid; gap: 8px; }
.occ-row-lg { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: 4px 14px; align-items: start; padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-card); }
.occ-row-lg.resolvida { opacity: .6; }
.occ-row-lg .tag { justify-content: center; }
.occ-sis { padding: 0; border: 0; background: none; font-weight: 700; font-size: 14.5px; color: var(--accent-ink); }
.occ-sis:hover { text-decoration: underline; text-underline-offset: 3px; }
.occ-row-lg .occ-desc { font-size: 14px; }

/* ============ Conferência ============ */
.conf-layout { display: grid; grid-template-columns: 268px minmax(0, 1fr); gap: var(--gap); align-items: start; }
.conf-sis-col { padding: 8px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
.conf-sis-titulo { font-size: 12.5px; font-weight: 700; color: var(--muted); padding: 8px 10px 6px; }
.conf-sis { width: 100%; text-align: left; border: 0; background: transparent; border-radius: 12px; padding: 9px 10px; display: grid; gap: 6px;
  transition: background-color var(--t-hover) ease; }
.conf-sis:hover { background: var(--raised); }
.conf-sis.ativo { background: var(--accent-soft); }
.conf-sis.ativo .conf-sis-nome { color: var(--accent-ink); }
.conf-sis.vazio .conf-sis-nome { color: var(--muted); }
.conf-sis-top { display: flex; align-items: baseline; gap: 8px; }
.conf-sis-nome { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conf-sis-n { font-size: 12px; color: var(--muted); font-weight: 600; font-family: var(--mono); }
.conf-bar { height: 5px; border-radius: 999px; background: var(--hue-track); overflow: hidden; display: flex; }
.conf-bar > span { display: block; height: 100%; flex: 0 0 auto; transition: width var(--t-ui) ease; }
.conf-bar-ok { background: var(--bar-ok); }
.conf-bar-div { background: var(--bar-aviso); }
.conf-sis-sub { font-size: 12px; font-weight: 700; color: var(--st-aviso-fg); line-height: 16px; }
.conf-sis-sub:empty { display: none; }
.conf-sis-titulo-semrec { margin-top: 8px; padding-top: 14px; border-top: 1px dashed var(--control); }
.conf-sis.sem-rec .conf-sis-nome { color: var(--muted); font-weight: 600; }

.conf-painel { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.conf-painel-head { display: grid; gap: 16px; }
.conf-painel-top { display: flex; align-items: flex-start; gap: 12px; }
.conf-painel-info { flex: 1; min-width: 0; }
.conf-painel-nome { display: flex; align-items: center; gap: 10px; font-size: 20px; line-height: 26px; font-weight: 700; letter-spacing: -0.02em; }
.conf-painel-nome .tag { background: var(--accent-soft); color: var(--accent-ink); font-family: var(--mono); font-weight: 500; }
.conf-resumo { font-size: 13.5px; color: var(--text-2); margin-top: 4px; font-weight: 600; }
.conf-ident { font-size: 12.5px; color: var(--muted); margin-top: 3px; font-weight: 500; }
.conf-ident .mono { color: var(--text); padding: 1px 6px; border-radius: 6px; background: var(--raised); border: 1px solid var(--border); }
.conf-ident.sem { color: var(--st-aviso-fg); font-weight: 700; }
.conf-prob { border-radius: var(--radius-inner); padding: 12px 14px; background: var(--st-pendente-bg); display: grid; gap: 6px; }
.conf-prob.tom-erro { background: var(--st-erro-bg); }
.conf-prob.tom-aviso { background: var(--st-aviso-bg); }
.conf-prob-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.conf-prob-titulo { font-weight: 700; }
.conf-prob.tom-erro .conf-prob-titulo { color: var(--st-erro-fg); }
.conf-prob.tom-aviso .conf-prob-titulo { color: var(--st-aviso-fg); }
.conf-prob .tag { background: var(--surface) !important; }
.conf-prob-ver { margin-left: auto; }
.conf-prob-obs { font-size: 12.5px; color: var(--muted); padding-left: 14px; font-weight: 500; }
.conf-barra { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; }
.conf-legenda { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.conf-legenda-ok { display: inline-flex; align-items: center; gap: 4px; padding: 0 8px; height: 22px; border-radius: 999px; background: var(--bate-bg); color: var(--st-ok-fg); font-weight: 700; }
.conf-legenda-ok svg { width: 12px; height: 12px; }
.conf-mun-list { display: grid; gap: var(--gap); }
.conf-mun { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: 16px var(--card-pad) var(--card-pad); display: grid; gap: 14px; }
.conf-mun-head { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; }
.conf-mun-ident { flex: 1 1 220px; min-width: 0; }
.conf-mun-nome { font-size: 16px; font-weight: 700; letter-spacing: -0.015em; }
.conf-mun-url { display: block; margin-top: 2px; font-family: var(--mono); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conf-pill { flex: none; }
.conf-grid { display: grid; grid-template-columns: 84px repeat(3, minmax(120px, 1fr)) 164px; gap: 8px 10px; align-items: center; }
.conf-h { font-size: 12px; font-weight: 700; color: var(--muted); }
.conf-h:nth-child(n+2):nth-child(-n+4) { text-align: right; padding-right: 32px; }
.conf-rotulo { font-weight: 700; cursor: help; }
.conf-cel { position: relative; display: block; }
.conf-input { width: 100%; height: 38px; text-align: right; font-family: var(--mono); font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; padding: 0 32px 0 10px;
  border-radius: var(--radius-control); border: 1px solid var(--border); background: var(--raised); color: var(--text);
  transition: background-color var(--t-hover) ease, border-color var(--t-hover) ease; }
.conf-input:hover { border-color: var(--control); }
.conf-input:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; background: var(--surface); }
.conf-check { position: absolute; right: 11px; top: 50%; margin-top: -7px; width: 14px; height: 14px; color: var(--st-ok-fg); opacity: 0; transition: opacity var(--t-hover); pointer-events: none; }
.conf-cel.bate .conf-input { background: var(--bate-bg); border-color: var(--bate-bd); }
.conf-cel.bate .conf-check { opacity: 1; }
.conf-input.invalido { border-color: var(--negative); background: var(--st-erro-bg); }
.conf-status { font-size: 12.5px; font-weight: 700; line-height: 17px; }
.conf-st-ok { color: var(--st-ok-fg); }
.conf-st-aviso { color: var(--st-aviso-fg); }
.conf-st-muted { color: var(--muted); font-weight: 600; }
.conf-notas { min-height: 42px; }
.conf-gf { display: grid; gap: 4px; min-width: 0; align-self: start; }
.conf-gf-fonte { display: none; font-size: 12px; font-weight: 700; color: var(--muted); }
.conf-gf-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: 100%; height: 32px; border: 0;
  background: var(--accent-soft); color: var(--accent-ink); font-size: 12.5px; font-weight: 700; padding: 0 10px; border-radius: 9px;
  transition: background-color var(--t-hover) ease; }
.conf-gf-btn:hover:not(:disabled) { background: var(--accent-soft-2); }
.conf-gf-btn:disabled { cursor: default; opacity: .7; }
.conf-gf-btn.config { background: transparent; border: 1.5px dashed var(--control); color: var(--muted); font-weight: 600; }
.conf-gf-btn.config:hover { color: var(--accent-ink); border-color: var(--accent); background: transparent; }
.conf-gf-ico { width: 14px; height: 14px; }
.conf-gf-spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--accent-soft-2); border-top-color: var(--accent); animation: conf-gf-giro .7s linear infinite; }
@keyframes conf-gf-giro { to { transform: rotate(360deg); } }
.conf-gf-msg { font-size: 11.5px; font-weight: 600; line-height: 15px; padding: 0 2px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.conf-gf-erro { color: var(--st-erro-fg); }

.gf-btn .dot { width: 8px; height: 8px; background: var(--faint); }
.gf-btn .dot.tom-ok { background: var(--bar-ok); }
.gf-btn .dot.tom-aviso { background: var(--bar-aviso); }
.gf-btn-st { color: var(--muted); font-weight: 600; font-size: 12.5px; padding-left: 8px; border-left: 1px solid var(--accent-soft-2); }
.gf-btn-st.tom-ok { color: var(--st-ok-fg); }
.gf-btn-st.tom-aviso { color: var(--st-aviso-fg); }
.gf-aviso { font-size: 13px; line-height: 19px; color: var(--muted); background: var(--raised); border: 1px solid var(--border); border-radius: var(--radius-inner); padding: 10px 12px; font-weight: 500; }
.gf-aviso b { color: var(--text); font-weight: 700; }
.gf-aviso .mono { font-size: 12px; }
.gf-token { -webkit-text-security: disc; }
.gf-limpar { margin-right: auto; }

/* ============ Modais ============ */
.modal-overlay { position: fixed; inset: 0; background: var(--overlay); display: flex; align-items: flex-start; justify-content: center;
  padding: 64px 20px; overflow: auto; z-index: 40; animation: fade-in var(--t-ui) ease; }
.modal-card { width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-float);
  animation: rise-in var(--t-ui) var(--ease-out); }
@keyframes fade-in { from { opacity: 0; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(10px); } }
.modal-header { padding: 24px 26px 16px; }
.modal-title { font-size: 19px; line-height: 25px; font-weight: 700; letter-spacing: -0.02em; }
.modal-sub { font-size: 13.5px; color: var(--muted); margin-top: 4px; font-weight: 500; }
.modal-body { padding: 4px 26px 0; display: grid; gap: 16px; }
.modal-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.modal-grid-mun { display: grid; grid-template-columns: 140px minmax(0, 1fr) 96px; gap: 12px; }
.modal-error { background: var(--st-erro-bg); color: var(--st-erro-fg); font-size: 13.5px; font-weight: 700; padding: 11px 13px; border-radius: var(--radius-inner); }
.modal-footer { padding: 20px 26px 24px; display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.modal-flags { display: flex; gap: 8px; flex-wrap: wrap; }

.modal-overlay.confirm { align-items: center; padding: 24px; z-index: 60; }
.confirm-card { max-width: 460px; padding: 24px 26px 22px; display: grid; gap: 16px; }
.confirm-title { font-size: 18px; line-height: 24px; font-weight: 700; letter-spacing: -0.02em; }
.confirm-text { font-size: 13.5px; color: var(--muted); margin-top: 6px; line-height: 20px; font-weight: 500; }
.confirm-detail { background: var(--st-erro-bg); color: var(--st-erro-fg); border-radius: var(--radius-inner); padding: 11px 14px; font-size: 13.5px; font-weight: 700; line-height: 20px; white-space: pre-line; }
.confirm-footer { display: flex; justify-content: flex-end; gap: 8px; }

/* Modal "Vincular existente" */
.vinc-list { max-height: 52vh; overflow: auto; display: grid; gap: 16px; }
.vinc-group { display: grid; gap: 6px; }
.vinc-group-label { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.vinc-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 52px; padding: 8px 12px; border-radius: 12px; background: var(--raised); }
.vinc-ident { min-width: 0; }
.vinc-origem { font-size: 12.5px; color: var(--muted); margin-top: 1px; font-weight: 500; }
.vinc-ok { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 700; color: var(--st-ok-fg); white-space: nowrap; }
.vinc-ok svg { width: 14px; height: 14px; }
.vinc-sem-resultado { padding: 24px 12px; text-align: center; color: var(--muted); }
.vinc-feitos { margin-right: auto; font-size: 13.5px; font-weight: 700; color: var(--st-ok-fg); }

/* ============ Login ============ */
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 384px; background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 30px; box-shadow: var(--shadow-lift); }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.login-title { font-size: 22px; line-height: 28px; font-weight: 700; letter-spacing: -0.03em; }
.login-sub { font-size: 13.5px; color: var(--muted); margin: 6px 0 22px; font-weight: 500; }
.login-error { background: var(--st-erro-bg); color: var(--st-erro-fg); font-size: 13px; font-weight: 700; padding: 10px 12px; border-radius: var(--radius-inner); margin-top: 12px; }
.login-card .btn-primary { margin-top: 16px; height: 42px; }
.login-theme { display: flex; justify-content: center; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--rule); }

/* ============ Carregando ============ */
.skeleton { background: var(--sunken); border-radius: 8px; }
.loading-page { gap: 24px; }
.loading-page .skeleton.s { width: 360px; height: 18px; margin-top: 8px; }
.loading-page .skeleton.b { height: 420px; border-radius: var(--radius-card); }

/* ============ Responsivo ============ */
.th-short { display: none; }
.tile-glyph svg { width: 12px; height: 12px; }
.search-field { display: block; }

@media (max-width: 1180px) {
  .ov-grid { grid-template-columns: minmax(0, 1fr); }
  .ov-side { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; }
  .ov-side > :nth-child(2) { order: 3; grid-column: 1 / -1; }
  .ov-side > :nth-child(3) { order: 2; }
  .conf-layout { grid-template-columns: minmax(0, 1fr); }
  .conf-sis-col { position: static; max-height: 280px; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .conf-sis-titulo { grid-column: 1 / -1; }
  .mun-row, .list-head.mun { grid-template-columns: 88px minmax(160px, 1fr) 190px 222px; }
  .mun-row .row-acoes { grid-column: 2 / -1; justify-content: flex-start; margin-top: -4px; }
  .mun-row.no-sis, .list-head.mun.no-sis { grid-template-columns: 88px minmax(160px, 1fr) 222px 190px; }
  .mun-row.no-sis .row-acoes { grid-column: auto; margin-top: 0; justify-content: flex-end; }
  .list-head.mun > :last-child { display: none; }
}

@media (max-width: 960px) {
  .kpis { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  :root { --pad: 20px; }
  .app-shell { display: block; }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30; height: 56px; padding: 0 8px 0 16px;
    background: var(--sidebar); border-bottom: 1px solid var(--border); }
  .topbar .brand-chip { width: 32px; height: 32px; border-radius: 10px; }
  .topbar .brand-chip svg { width: 20px; height: 20px; }
  .topbar-title { flex: 1; min-width: 0; font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sidebar { position: fixed; inset: 0; z-index: 50; width: 100%; height: 100%; padding: 12px 16px 20px; border-right: 0;
    transform: translateX(-100%); visibility: hidden; transition: transform var(--t-ui) var(--ease-out), visibility 0s linear var(--t-ui); }
  .sidebar.open { transform: none; visibility: visible; transition: transform var(--t-ui) var(--ease-out); }
  .sidebar-close { display: inline-grid; }
  .brand { padding: 4px 0 18px 4px; }
  .nav-btn { height: 48px; font-size: 16px; }
  .sidebar-theme-switch { height: 48px; font-size: 16px; }
  .page { padding-top: 22px; }
  .conf-grid { grid-template-columns: 70px repeat(3, minmax(0, 1fr)); }
  .conf-grid .conf-status { grid-column: 2 / -1; margin-top: -4px; }
  .conf-grid .conf-h:nth-child(5), .conf-grid .conf-gf-fim { display: none; }
  .conf-h:nth-child(n+2):nth-child(-n+4) { padding-right: 0; }
}

@media (max-width: 720px) {
  .ov-side { grid-template-columns: minmax(0, 1fr); }
  .ov-side > * { order: 0 !important; grid-column: auto !important; }
  .list-head.mun { display: none; }
  .mun-row, .mun-row.no-sis { grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; padding: 12px 14px; }
  .mun-row .ibge { grid-column: 1 / -1; grid-row: 1; }
  .mun-row .mun-ident { grid-column: 1; grid-row: 2; }
  .mun-row .row-acoes, .mun-row.no-sis .row-acoes { grid-column: 2; grid-row: 2; margin-top: 0; align-self: start; }
  .mun-row .mun-sis { grid-column: 1 / -1; grid-row: 3; }
  .mun-row .mun-flags { grid-column: 1 / -1; grid-row: 4; flex-wrap: nowrap; }
  .toolbar .search { flex: 1 1 100%; }
  .toolbar select.field-input { flex: 1 1 calc(50% - 4px); max-width: none; }
  .toolbar-count { margin-left: 0; }
  .st-tabs { border-radius: 16px; width: 100%; }
  .occ-row-lg { grid-template-columns: minmax(0, 1fr) auto; }
  .occ-row-lg .tag { justify-self: start; grid-column: 1 / 2; }
  .occ-row-lg .occ-main { grid-column: 1 / -1; }
  .occ-row-lg .occ-acoes { grid-column: 2 / 3; grid-row: 1; }
  .tabs { overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--pad)); padding: 0 var(--pad); }
  .tab-aside { padding-left: 8px; }
  .tabs.with-aside { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
  .tabs.with-aside .tab-aside { order: -1; flex-basis: 100%; margin: 0 0 4px; padding: 0; }
}

@media (max-width: 600px) {
  :root { --pad: 16px; --card-pad: 16px; --gap: 10px; }
  .page-title { font-size: 23px; line-height: 29px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
  .legend { justify-content: flex-start; max-width: none; flex: 1 1 100%; }
  .panel-head { flex-wrap: wrap; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 24px; line-height: 30px; }
  .matrix col.c-mun { width: 40px; }
  .matrix col.c-mod { width: 50px; }
  .matrix col.c-chev { width: 0; }
  .mx-chev { display: none; }
  .mx-mun-bar { display: none; }
  .mx-row td { height: 44px; padding: 3px 3px; }
  .matrix th { padding: 0 3px 6px; font-size: 12px; text-align: center; }
  .matrix th.num { text-align: right; }
  .matrix th .th-long { display: none; }
  .matrix th .th-short { display: inline; }
  .matrix th:first-child { text-align: left; }
  .matrix .tile { justify-content: center; padding: 0 4px; gap: 3px; }
  .matrix .tile-txt { display: none; }
  .matrix .tile-glyph { display: inline-flex; font-weight: 700; font-size: 13px; }
  .matrix .tile .rb { margin-left: 0; }
  .grid-cards { grid-template-columns: minmax(0, 1fr); }
  .modal-overlay { padding: 16px 12px; }
  .modal-header { padding: 20px 18px 12px; }
  .modal-body { padding: 4px 18px 0; }
  .modal-footer { padding: 18px; flex-wrap: wrap; }
  .modal-grid-mun { grid-template-columns: 1fr 88px; }
  .modal-grid-mun > :nth-child(2) { grid-column: 1 / -1; order: -1; }
  .conf-legenda { margin-left: 0; }
  .detail-head .page-actions .btn { flex: 0 1 auto; }
  .module-toggle { flex-basis: 100%; }
  .req-top .seg { width: 100%; }
  .req-top .seg button { flex: 1; justify-content: center; }
  /* Conferência no celular: um valor por linha, com a fonte escrita ao lado. */
  .conf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .conf-grid > div:empty, .conf-grid .conf-h { display: none; }
  .conf-grid .conf-rotulo { grid-column: 1 / -1; margin-top: 6px; }
  .conf-grid .conf-cel { grid-column: 1 / -1; display: grid; grid-template-columns: 116px minmax(0, 1fr); align-items: center; gap: 8px; }
  .conf-grid .conf-cel::before { content: attr(data-fonte); font-size: 12.5px; font-weight: 600; color: var(--muted); }
  .conf-grid .conf-status { grid-column: 1 / -1; margin-top: 0; }
  .conf-grid .conf-gf { grid-column: auto; }
  .conf-gf-fonte { display: block; }
  .conf-barra .seg { flex-wrap: wrap; border-radius: 18px; }
}

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