/*
 * 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: #4f46e5;
  --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: #818cf8;
    --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: #818cf8;
  --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); }

/* ------------------------------------------------------------------ */
/* Barra superior                                                      */
/* ------------------------------------------------------------------ */

.topbar {
  background: var(--surface);
  border-top: 3px solid var(--accent);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 8px var(--gutter);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

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

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

.nav a {
  display: block;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 2px solid transparent;
}

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

.nav a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.topbar-user {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.user-id {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
}

.user-name { font-weight: 600; }

.topbar form { margin: 0; }

/* 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; }

  .topbar-user {
    margin-left: 0;
    width: 100%;
    justify-content: space-between;
  }

  .nav { order: 3; width: 100%; }

  .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; }
}
