/*
 * Monitor inf-lab: sistema visual.
 *
 * Sem frameworks, sem fontes externas, sem etapa de build.
 * Referência de classes e marcação em docs/ui.md.
 *
 * Cores: verde (#2f9e41) é o acento e o estado "ok"; vermelho (#cd191e)
 * é só para "crítico"; âmbar para "atenção". Contraste dos textos
 * conferido para WCAG AA (4,5:1) nos dois temas.
 */

/* ------------------------------------------------------------------ */
/* Tokens: tema claro (padrão)                                         */
/* ------------------------------------------------------------------ */

:root {
  color-scheme: light;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans",
    "Liberation Sans", Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Mono",
    "DejaVu Sans Mono", "Liberation Mono", Menlo, Consolas, monospace;

  /* Superfícies e texto */
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #eceff2;
  --border: #d7dde3;
  --border-strong: #8a96a3; /* bordas de campos: 3:1 sobre a superfície */
  --text: #1b2026;
  --text-muted: #56606b;

  /* Acento (verde) */
  --accent: #2f9e41;          /* preenchimentos: barra fina, menu ativo */
  --accent-text: #1d7a2e;     /* verde para texto sobre fundo claro */
  --accent-strong: #23863a;   /* fundo do botão principal */
  --accent-strong-hover: #1c6f2f;
  --on-accent: #ffffff;       /* texto sobre --accent-strong */
  --accent-soft: #e5f3e7;
  --focus: #2f9e41;

  /* Estados */
  --ok: #1d7a2e;
  --ok-fill: #2f9e41;
  --ok-soft: #e5f3e7;
  --warn: #8a5300;
  --warn-fill: #b27a00;
  --warn-soft: #fcf0d9;
  --crit: #cd191e;
  --crit-fill: #cd191e;
  --crit-soft: #fbe6e6;
  --info: #2a5bb8;
  --info-soft: #e6eefb;

  /* Séries dos gráficos: paleta neutra, sem verde nem vermelho */
  --series-1: #2563eb;
  --series-2: #7c3aed;
  --series-3: #0891b2;
  --series-4: #d97706;
  --series-5: #0369a1;
  --series-6: #9333ea;

  /* Forma */
  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 1px 2px rgb(16 24 32 / 0.06), 0 1px 3px rgb(16 24 32 / 0.05);
  --gutter: 16px;
  --max-width: 1240px;
}

/* ------------------------------------------------------------------ */
/* Tokens: tema escuro (sistema, quando o usuário não forçou o claro)   */
/* Mantenha este bloco idêntico ao de [data-theme="dark"] abaixo.       */
/* ------------------------------------------------------------------ */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg: #111416;
    --surface: #181c1f;
    --surface-2: #20252a;
    --border: #2b3238;
    --border-strong: #5d6873;
    --text: #e4e8ec;
    --text-muted: #9ba5af;

    --accent: #2f9e41;
    --accent-text: #4fc262;
    --accent-strong: #2f9e41;
    --accent-strong-hover: #3cb04f;
    --on-accent: #0b130d;
    --accent-soft: #16271a;
    --focus: #4fc262;

    --ok: #4fc262;
    --ok-fill: #2f9e41;
    --ok-soft: #16271a;
    --warn: #f2b23a;
    --warn-fill: #e0a100;
    --warn-soft: #2d2414;
    --crit: #ff6b6b;
    --crit-fill: #cd191e;
    --crit-soft: #341a1b;
    --info: #7aa7ff;
    --info-soft: #18233a;

    --series-1: #60a5fa;
    --series-2: #a78bfa;
    --series-3: #22d3ee;
    --series-4: #fbbf24;
    --series-5: #38bdf8;
    --series-6: #c084fc;

    --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
  }
}

/* Tema escuro escolhido manualmente */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #111416;
  --surface: #181c1f;
  --surface-2: #20252a;
  --border: #2b3238;
  --border-strong: #5d6873;
  --text: #e4e8ec;
  --text-muted: #9ba5af;

  --accent: #2f9e41;
  --accent-text: #4fc262;
  --accent-strong: #2f9e41;
  --accent-strong-hover: #3cb04f;
  --on-accent: #0b130d;
  --accent-soft: #16271a;
  --focus: #4fc262;

  --ok: #4fc262;
  --ok-fill: #2f9e41;
  --ok-soft: #16271a;
  --warn: #f2b23a;
  --warn-fill: #e0a100;
  --warn-soft: #2d2414;
  --crit: #ff6b6b;
  --crit-fill: #cd191e;
  --crit-soft: #341a1b;
  --info: #7aa7ff;
  --info-soft: #18233a;

  --series-1: #60a5fa;
  --series-2: #a78bfa;
  --series-3: #22d3ee;
  --series-4: #fbbf24;
  --series-5: #38bdf8;
  --series-6: #c084fc;

  --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
}

/* ------------------------------------------------------------------ */
/* Base                                                                */
/* ------------------------------------------------------------------ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

h1, h2, h3, h4 {
  margin: 0 0 0.5em;
  line-height: 1.25;
  font-weight: 600;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }

p { margin: 0 0 1em; }

a {
  color: var(--accent-text);
  text-underline-offset: 2px;
}

a:hover { text-decoration-thickness: 2px; }

code, kbd, pre, samp {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

code {
  background: var(--surface-2);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

::selection {
  background: var(--accent-soft);
  color: var(--text);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  z-index: 10;
  background: var(--surface);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.skip-link:focus { top: 8px; }

/* Utilitários */
.muted { color: var(--text-muted); }
.mono { font-family: var(--font-mono); }
.num { font-variant-numeric: tabular-nums; }
.small { font-size: 0.87rem; }
.mt-12 { margin-top: 12px; }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.text-crit { color: var(--crit); }

/* ------------------------------------------------------------------ */
/* Estrutura: menu lateral + área principal                           */
/* ------------------------------------------------------------------ */

.shell {
  flex: 1;
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}

.shell-main {
  flex: 1;
  min-width: 0;
  overflow-x: clip;  /* rede de segurança: nada empurra a página para o lado */
  display: flex;
  flex-direction: column;
}

.sidebar {
  flex: 0 0 15rem;
  width: 15rem;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 12px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 16px;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.brand-logo { border-radius: 8px; flex: none; }
.brand-mark { color: var(--accent-text); }

.nav-group {
  margin: 14px 8px 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav a,
.nav-button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.nav a:hover,
.nav-button:hover {
  color: var(--text);
  background: var(--surface-2);
}

.nav a[aria-current="page"] {
  color: var(--text);
  background: var(--accent-soft);
  font-weight: 600;
}

.nav a[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.icon { flex: none; }

/* Cabeçalho fino da área principal: botão do menu (celular) e estado geral */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 8px var(--gutter);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.menu-toggle {
  display: inline-flex;
  align-items: center;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

.menu-toggle[hidden] { display: none; }

.status-ok { color: var(--ok); background: var(--ok-soft); }
.status-warn { color: var(--warn); background: var(--warn-soft); }
.status-crit { color: var(--crit); background: var(--crit-soft); }
.status-nodata { color: var(--text-muted); background: var(--surface-2); }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgb(0 0 0 / 0.45);
}
.sidebar-backdrop[hidden] { display: none; }

/* Seletor de tema: grupo segmentado de botões num formulário */
.theme-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
}

.theme-switch button {
  appearance: none;
  border: 0;
  margin: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.8rem;
  line-height: 1;
  padding: 6px 9px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.theme-switch button + button {
  border-left: 1px solid var(--border);
}

.theme-switch button:hover { color: var(--text); }

.theme-switch button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--accent);
}

.theme-switch button:focus-visible {
  outline-offset: -2px;
}

/* ------------------------------------------------------------------ */
/* Página                                                              */
/* ------------------------------------------------------------------ */

.page {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px var(--gutter) 40px;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 20px;
}

.page-header h1 { margin: 0; }

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.section { margin-bottom: 32px; }

.section-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.footer {
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 12px var(--gutter);
}

/* Indicador "última coleta há X min" */
.last-update {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.87rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.last-update::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok-fill);
}

.last-update.is-stale {
  color: var(--crit);
  font-weight: 600;
}

.last-update.is-stale::before { background: var(--crit-fill); }

/* ------------------------------------------------------------------ */
/* Cartões                                                             */
/* ------------------------------------------------------------------ */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
  gap: 16px;
}

.cards-wide {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Faixa lateral com a cor do estado (a cor nunca vem sozinha: use .status) */
.card.is-ok { border-left: 4px solid var(--ok-fill); }
.card.is-warn { border-left: 4px solid var(--warn-fill); }
.card.is-crit { border-left: 4px solid var(--crit-fill); }

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.card-title {
  margin: 0;
  font-size: 0.87rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card-value {
  font-size: 2.1rem;
  font-weight: 650;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin: 0;
}

.card-unit {
  font-size: 0.5em;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 2px;
  letter-spacing: 0;
}

.card-meta {
  margin: 0;
  font-size: 0.87rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.card-footer {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 0.87rem;
  color: var(--text-muted);
}

/* Lista chave/valor dentro de cartão (ex.: serviços, alvos de ping) */
.kv {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  font-size: 0.9rem;
}

.kv dt { color: var(--text-muted); min-width: 0; }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

/* Painel genérico (ex.: política de CPU, gráfico) */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  min-width: 0;
}

.panel + .panel { margin-top: 16px; }

.chart {
  width: 100%;
  height: 260px;
}

/* Barra de progresso (<progress class="meter">) */
.meter {
  appearance: none;
  display: block;
  width: 100%;
  height: 8px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ok-fill);
  overflow: hidden;
}

.meter::-webkit-progress-bar {
  background: var(--surface-2);
  border-radius: 999px;
}

.meter::-webkit-progress-value {
  background: var(--meter-fill, var(--ok-fill));
  border-radius: 999px;
}

.meter::-moz-progress-bar {
  background: var(--meter-fill, var(--ok-fill));
  border-radius: 999px;
}

.meter.is-warn { --meter-fill: var(--warn-fill); color: var(--warn-fill); }
.meter.is-crit { --meter-fill: var(--crit-fill); color: var(--crit-fill); }
.meter.is-neutral { --meter-fill: var(--series-1); color: var(--series-1); }

/* ------------------------------------------------------------------ */
/* Estado: cor + ícone + texto                                         */
/* ------------------------------------------------------------------ */

.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px 2px 4px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--text-muted);
}

.status-icon {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  color: var(--surface);
  background: var(--text-muted);
  flex: none;
}

.status-ok { background: var(--ok-soft); color: var(--ok); }
.status-ok .status-icon { background: var(--ok-fill); color: #ffffff; }

.status-warn { background: var(--warn-soft); color: var(--warn); }
.status-warn .status-icon { background: var(--warn-fill); color: #1b1300; }

.status-crit { background: var(--crit-soft); color: var(--crit); }
.status-crit .status-icon { background: var(--crit-fill); color: #ffffff; }

/* Sem dados / desconhecido */
.status-unknown { background: var(--surface-2); color: var(--text-muted); }

/* ------------------------------------------------------------------ */
/* Selos neutros (papel do usuário, rótulos)                           */
/* ------------------------------------------------------------------ */

.badge {
  display: inline-block;
  padding: 1px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text-muted);
  background: var(--surface-2);
  white-space: nowrap;
}

.badge-accent {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: transparent;
}

/* ------------------------------------------------------------------ */
/* Botões                                                              */
/* ------------------------------------------------------------------ */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 7px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover { background: var(--surface-2); }

.btn-primary {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--on-accent);
}

.btn-primary:hover {
  background: var(--accent-strong-hover);
  border-color: var(--accent-strong-hover);
}

/* Só para ações destrutivas/irreversíveis (desativar, excluir) */
.btn-danger {
  color: var(--crit);
  border-color: var(--crit);
}

.btn-danger:hover { background: var(--crit-soft); }

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover { color: var(--text); background: var(--surface-2); }

.btn-sm {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 0.8rem;
}

.btn-block { width: 100%; }

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Grupo segmentado genérico (ex.: seletor de período 1 h / 6 h / ...) */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
}

.segmented > a,
.segmented > button {
  appearance: none;
  border: 0;
  margin: 0;
  padding: 6px 11px;
  font: inherit;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  background: transparent;
  text-decoration: none;
  cursor: pointer;
}

.segmented > * + * { border-left: 1px solid var(--border); }

.segmented > :hover { color: var(--text); }

.segmented > [aria-current="true"],
.segmented > [aria-current="page"],
.segmented > [aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--accent);
}

/* ------------------------------------------------------------------ */
/* Formulários                                                         */
/* ------------------------------------------------------------------ */

.form { display: grid; gap: 16px; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: 16px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.field { display: grid; gap: 5px; min-width: 0; }

.field > label,
.label {
  font-weight: 600;
  font-size: 0.9rem;
}

.input,
.select {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.input:focus-visible,
.select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 0;
  border-color: var(--focus);
}

.input[aria-invalid="true"] { border-color: var(--crit); }

.field-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0;
}

.field-error {
  font-size: 0.82rem;
  color: var(--crit);
  font-weight: 600;
  margin: 0;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  cursor: pointer;
}

.check input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent-strong);
}

/* ------------------------------------------------------------------ */
/* Tabela                                                              */
/* ------------------------------------------------------------------ */

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.table {
  width: 100%;
  border-collapse: collapse;
  overflow-wrap: normal;
  font-size: 0.9rem;
}

.table th,
.table td {
  padding: 9px 12px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

.table th {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--surface-2);
  white-space: nowrap;
}

.table tbody tr:last-child td { border-bottom: 0; }

.table tbody tr:hover { background: var(--surface-2); }

.table .num,
.table td.num,
.table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table .actions {
  text-align: right;
  white-space: nowrap;
}

.table .actions form { display: inline; margin: 0; }

.table caption {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
}

/* ------------------------------------------------------------------ */
/* Alertas e mensagens (flash)                                         */
/* ------------------------------------------------------------------ */

.flashes {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-left-width: 4px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.92rem;
}

.alert .status-icon { margin-top: 2px; }

.alert-body { min-width: 0; }

.alert-title { font-weight: 700; }

.alert-ok {
  background: var(--ok-soft);
  border-color: var(--ok-fill);
}
.alert-ok .status-icon { background: var(--ok-fill); color: #ffffff; }

.alert-warning {
  background: var(--warn-soft);
  border-color: var(--warn-fill);
}
.alert-warning .status-icon { background: var(--warn-fill); color: #1b1300; }

.alert-error {
  background: var(--crit-soft);
  border-color: var(--crit-fill);
}
.alert-error .status-icon { background: var(--crit-fill); color: #ffffff; }

.alert-info {
  background: var(--info-soft);
  border-color: var(--info);
}
.alert-info .status-icon { background: var(--info); color: var(--surface); }

/* ------------------------------------------------------------------ */
/* Estado vazio                                                        */
/* ------------------------------------------------------------------ */

.empty-state {
  text-align: center;
  padding: 40px 16px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-muted);
  background: var(--surface);
}

.empty-state-icon {
  font-size: 1.8rem;
  line-height: 1;
  margin-bottom: 8px;
}

.empty-state-title {
  color: var(--text);
  font-weight: 600;
  font-size: 1rem;
  margin: 0 0 4px;
}

.empty-state p { margin: 0 0 12px; }
.empty-state p:last-child { margin-bottom: 0; }

/* ------------------------------------------------------------------ */
/* Login                                                               */
/* ------------------------------------------------------------------ */

.page-auth {
  display: grid;
  place-items: center;
  padding-top: 48px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
}

.wordmark {
  margin: 0 0 4px;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.wordmark .brand-mark { color: var(--accent-text); }

.auth-card .lead {
  color: var(--text-muted);
  margin-bottom: 20px;
}

.auth-card .alert { margin-bottom: 16px; }

/* ------------------------------------------------------------------ */
/* Guia de componentes                                                 */
/* ------------------------------------------------------------------ */

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.swatches li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-family: var(--font-mono);
}

.swatch {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid var(--border);
  flex: none;
}

.swatch-series-1 { background: var(--series-1); }
.swatch-series-2 { background: var(--series-2); }
.swatch-series-3 { background: var(--series-3); }
.swatch-series-4 { background: var(--series-4); }
.swatch-series-5 { background: var(--series-5); }
.swatch-series-6 { background: var(--series-6); }
.swatch-accent { background: var(--accent); }
.swatch-warn { background: var(--warn-fill); }
.swatch-crit { background: var(--crit-fill); }

.demo-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* ------------------------------------------------------------------ */
/* Telas estreitas                                                     */
/* ------------------------------------------------------------------ */

@media (max-width: 640px) {
  body { font-size: 15px; }

  .page { padding-top: 16px; }

  .card-value { font-size: 1.8rem; }

  .auth-card { padding: 24px 16px; }

  .page-auth { padding-top: 24px; }
}

@media (prefers-reduced-motion: no-preference) {
  .btn,
  .nav a,
  .theme-switch button,
  .segmented > * {
    transition: background-color 0.12s ease, color 0.12s ease;
  }
}

@media print {
  .topbar, .footer, .theme-switch { display: none; }
  .card, .panel { box-shadow: none; }
}

/* ================================================================== */
/* Painel: visão geral, detalhes, gráficos e modo ao vivo             */
/* (etapa 3; JS em static/js/, referência em docs/ui.md)              */
/* Só usa os tokens acima: nenhuma cor nova, os dois temas valem.     */
/* ================================================================== */

.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

.dash-notice { margin-bottom: 16px; }
.dash-notice[hidden] { display: none; }

/* Política de CPU (cartão largo no topo da visão geral) */
.policy { padding: 20px; gap: 12px; }

.policy-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 16px 32px;
  align-items: start;
}

.policy-main { display: grid; gap: 8px; min-width: 0; }

.policy-value { font-size: 3.2rem; }

.policy-partial { justify-self: start; margin: 0; }
.policy-partial[hidden] { display: none; }

.policy-meter { height: 12px; }
.policy-meter[hidden] { display: none; }

.policy-scale { margin: 0; }

.policy-side { display: grid; gap: 8px; min-width: 0; }

.policy-line { margin: 0; }

.policy-help {
  margin: 4px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* Valor em texto (ex.: "12 d 4 h") um pouco menor que o número grande */
.card-value-text { font-size: 1.6rem; }

.meter[hidden], .kv[hidden] { display: none; }

/* Lista chave/valor em duas colunas largas (valores atuais nos detalhes) */
@media (min-width: 720px) {
  .kv-cols { grid-template-columns: auto 1fr auto 1fr; column-gap: 24px; }
}

/* Grade de gráficos: duas colunas quando cabe, uma no celular */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr));
  gap: 16px;
}

.chart-grid:empty { display: none; }

.chart-grid .panel + .panel { margin-top: 0; }

.chart-grid-cell { display: grid; gap: 16px; min-width: 0; }
.chart-grid-cell:empty { display: none; }

.chart-panel { display: flex; flex-direction: column; gap: 8px; }
.chart-panel[hidden] { display: none; }

.chart-title { margin: 0; font-size: 1rem; }

.chart-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.chart[hidden] { display: none; }

/* Estado vazio no lugar do gráfico, com a mesma altura */
.chart-empty:not([hidden]) {
  height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

/* Dica (tooltip) do ECharts: só classes, a CSP proíbe style="" no HTML */
.chart-tip { font-family: var(--font-sans); font-variant-numeric: tabular-nums; }

.chart-tip-time {
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

.chart-tip-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 8px;
  line-height: 1.5;
}

.chart-tip-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
  background: var(--text-muted);
}

.chart-tip-name { color: var(--text-muted); }
.chart-tip-value { margin-left: auto; font-weight: 600; color: var(--text); }
.chart-tip-range { flex-basis: 100%; padding-left: 18px; font-size: 0.8rem; color: var(--text-muted); }

.tip-series-1 { background: var(--series-1); }
.tip-series-2 { background: var(--series-2); }
.tip-series-3 { background: var(--series-3); }
.tip-series-4 { background: var(--series-4); }
.tip-series-5 { background: var(--series-5); }
.tip-series-6 { background: var(--series-6); }

/* Modo ao vivo */
.live-toggle[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex: none;
}

.live-toggle[aria-pressed="true"] .live-dot,
.live .live-dot { background: var(--accent); }

.live {
  padding: 16px;
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.live[hidden] { display: none; }

.live-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  margin-bottom: 12px;
}

.live-header .section-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.live-meta {
  margin: 0;
  font-size: 0.87rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.live-notice { margin: 0 0 12px; }
.live-notice[hidden] { display: none; }

/* Aviso clicável de fim do modo ao vivo (é um <button>) */
.live-resume {
  width: 100%;
  margin-bottom: 16px;
  font: inherit;
  font-size: 0.92rem;
  text-align: left;
  cursor: pointer;
}

.live-resume:hover { border-color: var(--accent); }
.live-resume[hidden] { display: none; }

@media (prefers-reduced-motion: no-preference) {
  .live-toggle[aria-pressed="true"] .live-dot {
    animation: live-pulse 1.6s ease-in-out infinite;
  }
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@media (max-width: 640px) {
  .policy { padding: 16px; }
  .policy-value { font-size: 2.6rem; }
  .page-actions .segmented { width: 100%; }
  .page-actions .segmented > a,
  .page-actions .segmented > button { flex: 1; text-align: center; padding: 6px 4px; }
}

/* ------------------------------------------------------------------
   uPlot (vendor/uPlot.min.css traz a base; aqui só tokens e ajustes)
   ------------------------------------------------------------------ */
.chart { position: relative; overflow: hidden; }

.chart .uplot {
  display: flex;
  flex-direction: column;
  width: 100%;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
}

.chart .u-legend { order: -1; margin: 0 0 4px; text-align: left; font-size: 0.8125rem; }
.chart .u-legend .u-series > * { padding: 2px 10px 2px 0; }
.chart .u-legend .u-series th { font-weight: 400; color: var(--text); }
.chart .u-legend .u-marker { width: 14px !important; height: 4px !important; border-radius: 2px; vertical-align: middle; }
.chart .u-legend .u-marker.chart-marker-fill { height: 10px !important; }

.chart .u-select { background: var(--accent-soft); }
.chart .u-cursor-x { border-right: 1px solid var(--text-muted) !important; }
.chart .u-over { touch-action: pan-y; cursor: crosshair; }

/* Dica (tooltip) do gráfico: posicionada por transform via JS (CSSOM) */
.chart .chart-tip {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  max-width: 80%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.8125rem;
  pointer-events: none;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.15);
}
.chart .chart-tip[hidden] { display: none; }
.chart .u-legend .chart-legend-off { display: none !important; }


/* ------------------------------------------------------------------ */
/* Menu lateral em telas médias e no celular                          */
/* ------------------------------------------------------------------ */

@media (min-width: 901px) { .menu-toggle { display: none; } }

/* sem JavaScript o menu continua visível, empilhado em cima do conteúdo */
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { position: static; width: auto; height: auto; flex: none; border-right: 0; border-bottom: 1px solid var(--border); }
}

/* com JavaScript (classe .js no <html>) o menu vira uma gaveta */
@media (max-width: 900px) {
  .js .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: min(18rem, 85vw);
    height: 100vh;
    border-bottom: 0;
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    visibility: hidden;
  }
  .js[data-sidebar-open] .sidebar { transform: none; visibility: visible; }
}

@media (max-width: 900px) and (prefers-reduced-motion: no-preference) {
  .js .sidebar { transition: transform 0.2s ease, visibility 0.2s; }
}

@media print {
  .sidebar, .sidebar-backdrop { display: none; }
}

/* ------------------------------------------------------------------ */
/* Guia                                                                */
/* ------------------------------------------------------------------ */

.guide { display: grid; grid-template-columns: 15rem minmax(0, 1fr); gap: 24px; align-items: start; }
.guide-toc { position: sticky; top: 16px; padding: 10px; }
.guide-toc ol { margin: 0; padding: 0; list-style: none; counter-reset: tema; display: flex; flex-direction: column; gap: 2px; }
.guide-toc li { counter-increment: tema; }
.guide-toc a {
  display: block; padding: 6px 10px; border-radius: var(--radius-sm);
  color: var(--text-muted); text-decoration: none; font-size: 0.9rem;
}
.guide-toc a::before { content: counter(tema) ". "; }
.guide-toc a:hover { background: var(--surface-2); color: var(--text); }
.guide-toc a[aria-current="page"] { background: var(--accent-soft); color: var(--text); font-weight: 600; }

.guide-body {
  max-width: 46rem; padding: 20px 24px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.prose h1 { display: none; }  /* o título já está no cabeçalho da página */
.prose h2 { margin-top: 1.6em; padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.prose h3 { margin-top: 1.2em; }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 1em; }
.prose li { margin-bottom: 0.3em; }
.prose code { font-family: var(--font-mono); font-size: 0.9em; padding: 1px 5px; border-radius: 4px; background: var(--surface-2); }
.prose pre { overflow-x: auto; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); }
.prose pre code { padding: 0; background: none; }
.prose .table-wrap { margin: 0 0 1em; }
.prose blockquote.note { margin: 0 0 1em; padding: 8px 14px; border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.prose blockquote.note p { margin: 0; }

.guide-pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--border); }
.guide-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr)); gap: 12px; }
.guide-tile { display: flex; align-items: center; gap: 12px; padding: 14px 16px; color: var(--text); text-decoration: none; }
.guide-tile:hover { border-color: var(--accent); background: var(--accent-soft); }
.guide-tile-num { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); font-weight: 700; }
.guide-tile-title { font-weight: 600; }

@media (max-width: 900px) {
  .guide { grid-template-columns: minmax(0, 1fr); }  /* minmax(0): sem isso uma tabela larga alarga a coluna inteira */
  .guide-toc { position: static; }
  .guide-body { padding: 16px; }
}

@media print {
  .guide { display: block; }
  .guide-toc, .guide-pager, .page-actions, .status-pill { display: none; }
  .guide-body { max-width: none; border: 0; padding: 0; }
  .prose h2 { break-after: avoid; }
  .prose pre, .prose table { break-inside: avoid; }
}

/* ------------------------------------------------------------------ */
/* Balões de ajuda (?)                                                 */
/* ------------------------------------------------------------------ */

.help { position: relative; display: inline-block; margin-left: 8px; vertical-align: middle; }

.help-btn {
  width: 22px; height: 22px; padding: 0;
  border: 1px solid var(--border-strong); border-radius: 50%;
  background: var(--surface); color: var(--text-muted);
  font: inherit; font-size: 0.8rem; font-weight: 700; line-height: 1; cursor: pointer;
}
.help-btn:hover, .help-btn[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent); }
.help-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.help-pop {
  position: absolute; z-index: 30; top: calc(100% + 8px); left: 0;
  width: min(24rem, 86vw); padding: 12px 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
  font-size: 0.85rem; font-weight: 400; text-transform: none; letter-spacing: 0; line-height: 1.45; text-align: left;
}
.help-pop[hidden] { display: none; }
.help-pop p { margin: 0 0 8px; }
.help-pop .help-more { margin: 0; }


@media print { .help { display: none; } }


/* ------------------------------------------------------------------ */
/* Cabeçalho: menu do usuário; menu lateral: estado geral e recolher  */
/* ------------------------------------------------------------------ */

.topbar { justify-content: space-between; }

.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.sidebar-head .brand { padding-bottom: 12px; min-width: 0; }

.collapse-toggle {
  display: inline-flex; padding: 6px; margin-bottom: 8px;
  border: 0; border-radius: var(--radius-sm); background: none;
  color: var(--text-muted); cursor: pointer;
}
.collapse-toggle[hidden] { display: none; }
.collapse-toggle:hover { background: var(--surface-2); color: var(--text); }

.status-card {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 6px; padding: 8px 10px;
  border: 1px solid currentColor; border-radius: var(--radius);
  text-decoration: none;
}
.status-text { display: flex; flex-direction: column; line-height: 1.2; }
.status-label { font-weight: 700; font-size: 0.9rem; }
.status-hint { font-size: 0.72rem; opacity: 0.85; }
.status-ok { color: var(--ok); background: var(--ok-soft); }
.status-warn { color: var(--warn); background: var(--warn-soft); }
.status-crit { color: var(--crit); background: var(--crit-soft); }
.status-nodata { color: var(--text-muted); background: var(--surface-2); }

.user-menu { position: relative; margin-left: auto; }
.user-menu > summary { list-style: none; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu-button {
  display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text); cursor: pointer;
}
.user-menu-button:hover, .user-menu[open] .user-menu-button { background: var(--surface-2); }
.user-menu-button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-strong); color: var(--on-accent); font-weight: 700;
}
.user-id { padding: 0; }
.user-menu-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 45;
  width: 16rem; padding: 10px;
  display: flex; flex-direction: column; gap: 4px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
}
.user-menu-panel form { margin: 0; }
.user-menu-label { margin: 2px 6px 0; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.user-menu-panel .theme-switch { display: flex; }
.user-menu-panel .theme-switch button { flex: 1; white-space: nowrap; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--text); font: inherit; text-align: left; text-decoration: none; cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); }
.student-toggle[aria-pressed="true"] { background: var(--accent-soft); }

/* menu lateral recolhido: só os ícones (preferência guardada no navegador) */
@media (min-width: 901px) {
  [data-sidebar="collapsed"] .sidebar { flex-basis: 4.25rem; width: 4.25rem; padding-inline: 8px; }
  [data-sidebar="collapsed"] .brand-text,
  [data-sidebar="collapsed"] .nav a span,
  [data-sidebar="collapsed"] .status-text,
  [data-sidebar="collapsed"] .nav-group { display: none; }
  [data-sidebar="collapsed"] .sidebar-head { flex-direction: column; align-items: center; }
  [data-sidebar="collapsed"] .sidebar-head .brand { padding-inline: 0; }
  [data-sidebar="collapsed"] .nav a { justify-content: center; padding-inline: 0; }
  [data-sidebar="collapsed"] .nav a[aria-current="page"]::before { left: -8px; }
  [data-sidebar="collapsed"] .status-card { justify-content: center; padding-inline: 0; }
  [data-sidebar="collapsed"] .nav + .nav { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
  [data-sidebar="collapsed"] .collapse-toggle svg { transform: scaleX(-1); }
}

@media (max-width: 900px) {
  .collapse-toggle { display: none; }
  .user-id .badge { display: none; }
}

/* ------------------------------------------------------------------ */
/* Benchmark                                                           */
/* ------------------------------------------------------------------ */

.bench-level { margin-bottom: 16px; }
.bench-table progress.bar, .bench-progress { width: min(18rem, 60%); height: 14px; vertical-align: middle; border: 0; border-radius: 7px; background: var(--surface-2); appearance: none; }
.bench-progress { width: 100%; }
.bench-table progress::-webkit-progress-bar, .bench-progress::-webkit-progress-bar { background: var(--surface-2); border-radius: 7px; }
.bench-table progress::-moz-progress-bar, .bench-progress::-moz-progress-bar { border-radius: 7px; }
.bench-progress::-webkit-progress-value { background: var(--accent); border-radius: 7px; }
.bench-progress::-moz-progress-bar { background: var(--accent); }
progress.bar.s1::-webkit-progress-value { background: var(--series-1); border-radius: 7px; }
progress.bar.s2::-webkit-progress-value { background: var(--series-4); border-radius: 7px; }
progress.bar.s3::-webkit-progress-value { background: var(--series-3); border-radius: 7px; }
progress.bar.s1::-moz-progress-bar { background: var(--series-1); }
progress.bar.s2::-moz-progress-bar { background: var(--series-4); }
progress.bar.s3::-moz-progress-bar { background: var(--series-3); }
.bench-num { margin-left: 8px; font-variant-numeric: tabular-nums; }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
/* aviso longo em forma de selo: quebra de linha em vez de estourar a tela */
.badge-note { display: block; width: fit-content; max-width: 100%; margin-top: 6px; white-space: normal; border-radius: var(--radius-sm); padding: 4px 10px; }
.check { display: inline-flex; align-items: center; gap: 6px; margin-right: 16px; }


/* lista de temas do guia: <details> (aberto no computador; recolhível no celular) */
.guide-toc > summary { display: none; cursor: pointer; font-weight: 600; list-style: none; }
.guide-toc > summary::-webkit-details-marker { display: none; }
.guide-toc > summary::after { content: "▾"; float: right; }
.guide-toc:not([open]) > summary::after { content: "▸"; }
@media (max-width: 900px) {
  .guide-toc > summary { display: block; }
}

/* tabelas do guia: fonte menor; no celular cada linha vira um cartão "coluna: valor" */
.prose .table { font-size: 0.85rem; }
.prose .table th, .prose .table td { padding: 7px 10px; }
@media (max-width: 640px) {
  .prose .table-wrap { border: 0; background: none; overflow: visible; }
  .prose .table, .prose .table tbody { display: block; }
  .prose .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .prose .table tr {
    display: block; margin-bottom: 10px; padding: 6px 10px;
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  }
  .prose .table td { display: block; padding: 5px 0; border-bottom: 1px solid var(--border); }
  .prose .table td:last-child { border-bottom: 0; }
  .prose .table td::before { display: block; margin-bottom: 1px; content: attr(data-label); font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
}

/* balão de ajuda no celular: folha fixa na parte de baixo da tela, nunca fora dela */
.help-close { display: none; }
@media (max-width: 640px) {
  .help-pop {
    position: fixed; left: 12px; right: 12px; bottom: 12px; top: auto;
    width: auto; max-height: 70vh; overflow-y: auto;
  }
  .help-close { display: block; margin-top: 4px; }
}


/* tabelas de dados no celular: cada linha vira um cartão "coluna: valor" (classe .table-stack + data-label nas células) */
@media (max-width: 640px) {
  .table-stack { display: block; }
  .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-stack tbody { display: block; }
  .table-wrap:has(.table-stack) { border: 0; background: none; overflow: visible; }
  .table-stack tbody tr {
    display: block; margin-bottom: 10px; padding: 6px 12px;
    border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  }
  .table-stack tbody th {
    display: block; padding: 6px 0; text-align: left; text-transform: none; letter-spacing: 0;
    font-size: 0.95rem; color: var(--text); background: none; border-bottom: 1px solid var(--border); white-space: normal;
  }
  .table-stack td {
    display: block; padding: 6px 0; text-align: left; border-bottom: 1px solid var(--border);
  }
  .table-stack td:last-child { border-bottom: 0; }
  .table-stack td::before {
    display: block; content: attr(data-label); margin-bottom: 2px; font-size: 0.72rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted);
  }
  .table-stack td.num { text-align: left; }
  /* formulários dentro das células (ex.: lista de usuários) empilham em largura total */
  .table-stack td, .table-stack td.actions { white-space: normal; }  /* a regra do computador impede quebra de linha */
  .table-stack td form, .table-stack td.actions form { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 6px; min-width: 0; }
  .table-stack td .input, .table-stack td .select { flex: 1 1 10rem; min-width: 0; width: auto; }
  .table-stack td.actions { text-align: left; }
  .table-stack td.actions .btn { flex: 0 0 auto; }
  .bench-table progress.bar { width: 100%; }
}

/* página Operação: o título já está no cabeçalho e o texto ocupa a largura toda */
.ops { max-width: none; }
.prose.ops h1 { display: none; }

/* Bandeiras de países: o Windows não desenha o emoji, então uma fonte só de bandeiras (Twemoji,
   78 KB) cobre os indicadores regionais. O nome fica no texto: some no computador (aparece no
   title ao passar o mouse) e aparece no celular, onde não há mouse. */
@font-face {
  font-family: "Twemoji Country Flags";
  src: url("../vendor/TwemojiCountryFlags.woff2") format("woff2");
  unicode-range: U+1F1E6-1F1FF, U+1F3F4, U+E0062-E007F;
  font-display: swap;
}

.flag {
  font-family: "Twemoji Country Flags", "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  font-size: 1.4em;
  line-height: 1;
  vertical-align: middle;
  cursor: help;
}

.flag-name {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 640px) {
  .flag-name {
    position: static;
    width: auto;
    height: auto;
    margin: 0 0 0 6px;
    clip: auto;
    white-space: normal;
  }
}

/* Gráfico de tentativas (página Segurança) */
.bans-chart { position: relative; }
.bans-tip {
  position: absolute;
  top: 4px;
  right: 14px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: .85rem;
  pointer-events: none;
}
.bans-table { margin-top: 12px; }
.bans-table > summary { cursor: pointer; color: var(--text-muted); }

/* Identidade da instância (Oracle, Azure, Integrator...): faixa no topo e selo colorido.
   --instance-color vem de /instancia.css (a CSP não aceita estilo embutido). */
body[data-instance]::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 5px;
  background: var(--instance-color, #6d28d9);
  z-index: 200;
}

.instance-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--instance-color, #6d28d9);
  color: #fff;
  font-weight: 600;
  line-height: 1.15;
  min-width: 0;
}

.instance-chip > span { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.instance-chip small { font-weight: 400; opacity: .92; font-size: .75rem; }
.instance-chip .icon { flex: none; }

.instance-chip-login { justify-content: center; margin: 0 auto 16px; width: fit-content; }

[data-sidebar="collapsed"] .instance-chip > span { display: none; }
[data-sidebar="collapsed"] .instance-chip { justify-content: center; padding-inline: 0; }
