/* =====================================================================
   Controle de Frota - Design System
   CSS puro, sem dependências. Tema claro/escuro selecionado (não invertido).
   Paleta de dados validada para daltonismo (CVD) nos dois modos.
   ===================================================================== */

/* ---------------------------------------------------------------------
   1. Tokens
   --------------------------------------------------------------------- */
:root {
  color-scheme: light;

  /* Superfícies */
  --surface-1: #fcfcfb;          /* superfície de cartão/gráfico */
  --surface-2: #f4f3f0;          /* superfície secundária */
  --page: #f9f9f7;               /* plano da página */
  --overlay: rgba(11, 11, 11, .42);

  /* Tinta */
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;

  /* Linhas */
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, .10);
  --border-strong: rgba(11, 11, 11, .18);

  /* Identidade */
  --brand: #2a78d6;
  --brand-ink: #ffffff;
  --brand-soft: rgba(42, 120, 214, .10);

  /* Status (fixos, nunca tematizados) */
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;
  --status-good-ink: #006300;

  /* Séries categóricas (ordem fixa — nunca ciclar) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;

  /* Forma */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(11, 11, 11, .06);
  --shadow: 0 4px 16px rgba(11, 11, 11, .08);
  --shadow-lg: 0 12px 40px rgba(11, 11, 11, .18);

  /* Espaço */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --sidebar-w: 244px;
  --topbar-h: 60px;
  --transition: 160ms ease;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --surface-1: #1a1a19;
  --surface-2: #232322;
  --page: #0d0d0d;
  --overlay: rgba(0, 0, 0, .62);

  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;

  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, .10);
  --border-strong: rgba(255, 255, 255, .20);

  --brand: #3987e5;
  --brand-ink: #ffffff;
  --brand-soft: rgba(57, 135, 229, .16);

  --status-good: #0ca30c;
  --status-good-ink: #0ca30c;

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 4px 16px rgba(0, 0, 0, .45);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .6);
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --surface-2: #232322;
    --page: #0d0d0d;
    --overlay: rgba(0, 0, 0, .62);
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, .10);
    --border-strong: rgba(255, 255, 255, .20);
    --brand: #3987e5;
    --brand-soft: rgba(57, 135, 229, .16);
    --status-good-ink: #0ca30c;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 4px 16px rgba(0, 0, 0, .45);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .6);
  }
}

/* ---------------------------------------------------------------------
   2. Reset
   --------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; line-height: 1.25; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0 0 var(--space-3); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------------------------------------------------------------------
   3. Layout
   --------------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: transform var(--transition);
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--topbar-h);
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.sidebar__logo {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--brand);
  color: var(--brand-ink);
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px;
  flex: 0 0 auto;
}

.sidebar__title { font-size: 14px; font-weight: 600; }
.sidebar__subtitle { font-size: 11px; color: var(--text-muted); }

.sidebar__nav { flex: 1 1 auto; overflow-y: auto; padding: var(--space-3) var(--space-2); }

.nav-group__label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  padding: var(--space-4) var(--space-3) var(--space-2);
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 9px var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background var(--transition), color var(--transition);
}

.nav-item:hover { background: var(--surface-2); color: var(--text-primary); text-decoration: none; }
.nav-item.is-active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-item__icon { width: 18px; height: 18px; flex: 0 0 auto; opacity: .85; }
.nav-item__badge {
  margin-left: auto;
  background: var(--status-critical);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}

.sidebar__footer {
  flex: 0 0 auto;
  border-top: 1px solid var(--border);
  padding: var(--space-3) var(--space-4);
  font-size: 11px;
  color: var(--text-muted);
}

.main { flex: 1 1 auto; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-5);
  z-index: 30;
}

.topbar__menu { display: none; }
.topbar__title { font-size: 15px; font-weight: 600; }
.topbar__breadcrumb { font-size: 12px; color: var(--text-muted); }
.topbar__spacer { flex: 1 1 auto; }

.content { padding: var(--space-5); flex: 1 1 auto; max-width: 1600px; width: 100%; }

.page-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}
.page-header__text { flex: 1 1 260px; }
.page-header__desc { color: var(--text-muted); font-size: 13px; margin: 2px 0 0; }
.page-header__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* ---------------------------------------------------------------------
   4. Cartões e grades
   --------------------------------------------------------------------- */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
}
.card__title { font-size: 14px; font-weight: 600; }
.card__subtitle { font-size: 12px; color: var(--text-muted); }
.card__actions { margin-left: auto; display: flex; gap: var(--space-2); align-items: center; }
.card__body { padding: var(--space-4); }
.card__body--flush { padding: 0; }
.card__footer { padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); }

.grid { display: grid; gap: var(--space-4); }
.grid--kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid--sidebar { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.row { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.spacer { flex: 1 1 auto; }

/* ---------------------------------------------------------------------
   5. KPI / stat tiles
   --------------------------------------------------------------------- */
.kpi {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.kpi__label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  font-weight: 600;
}
.kpi__value { font-size: 28px; font-weight: 650; line-height: 1.1; letter-spacing: -.01em; }
.kpi__unit { font-size: 14px; font-weight: 500; color: var(--text-secondary); margin-left: 3px; }
.kpi__meta { font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.kpi__delta { font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.kpi__delta--up { color: var(--status-good-ink); }
.kpi__delta--down { color: var(--status-critical); }
.kpi__spark { height: 34px; margin-top: auto; }

/* ---------------------------------------------------------------------
   6. Botões
   --------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-1);
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition), opacity var(--transition);
}
.btn:hover:not(:disabled) { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn--primary:hover:not(:disabled) { background: color-mix(in srgb, var(--brand) 86%, black); }
.btn--danger { background: var(--status-critical); border-color: var(--status-critical); color: #fff; }
.btn--danger:hover:not(:disabled) { background: color-mix(in srgb, var(--status-critical) 86%, black); }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn--sm { padding: 5px 10px; font-size: 12.5px; }
.btn--icon { padding: 7px; width: 34px; height: 34px; }
.btn--block { width: 100%; }
.btn__icon { width: 16px; height: 16px; flex: 0 0 auto; }

/* ---------------------------------------------------------------------
   7. Formulários
   --------------------------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-4); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field--full { grid-column: 1 / -1; }
.field__label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.field__required { color: var(--status-critical); margin-left: 2px; }
.field__hint { font-size: 11.5px; color: var(--text-muted); }
.field__error { font-size: 12px; color: var(--status-critical); font-weight: 500; }

.input, .select, .textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-2); color: var(--text-muted); }
.input--invalid, .select--invalid, .textarea--invalid { border-color: var(--status-critical); }
.textarea { min-height: 84px; resize: vertical; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%); background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 30px; }

.checkbox, .radio { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; font-size: 13.5px; }
.checkbox input, .radio input { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; }

.filters {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  align-items: flex-end;
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
}
.filters .field { min-width: 150px; flex: 0 1 auto; }
.filters .field--grow { flex: 1 1 220px; }

/* ---------------------------------------------------------------------
   8. Tabelas
   --------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 10px var(--space-4); text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  font-weight: 600;
  background: var(--surface-2);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
.table th.is-sortable { cursor: pointer; user-select: none; }
.table th.is-sortable:hover { color: var(--text-primary); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table td.is-numeric, .table th.is-numeric { text-align: right; font-variant-numeric: tabular-nums; }
.table td.is-actions { text-align: right; white-space: nowrap; }
.table--compact th, .table--compact td { padding: 7px var(--space-3); }
.table__empty { padding: var(--space-6); text-align: center; color: var(--text-muted); }

.pagination {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}
.pagination__pages { margin-left: auto; display: flex; gap: var(--space-1); align-items: center; }
.pagination__btn {
  min-width: 30px; height: 30px;
  border: 1px solid var(--border-strong);
  background: var(--surface-1);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12.5px;
  display: inline-grid; place-items: center;
}
.pagination__btn:hover:not(:disabled) { background: var(--surface-2); }
.pagination__btn:disabled { opacity: .4; cursor: not-allowed; }
.pagination__btn.is-active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }

/* ---------------------------------------------------------------------
   9. Badges, pills e status
   --------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.badge--good { color: var(--status-good-ink); background: color-mix(in srgb, var(--status-good) 12%, transparent); border-color: color-mix(in srgb, var(--status-good) 30%, transparent); }
.badge--warning { color: color-mix(in srgb, var(--status-warning) 72%, var(--text-primary)); background: color-mix(in srgb, var(--status-warning) 15%, transparent); border-color: color-mix(in srgb, var(--status-warning) 34%, transparent); }
.badge--serious { color: color-mix(in srgb, var(--status-serious) 78%, var(--text-primary)); background: color-mix(in srgb, var(--status-serious) 15%, transparent); border-color: color-mix(in srgb, var(--status-serious) 34%, transparent); }
.badge--critical { color: var(--status-critical); background: color-mix(in srgb, var(--status-critical) 12%, transparent); border-color: color-mix(in srgb, var(--status-critical) 30%, transparent); }
.badge--brand { color: var(--brand); background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 30%, transparent); }

/* ---------------------------------------------------------------------
   10. Abas
   --------------------------------------------------------------------- */
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
  padding: 10px var(--space-4);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--text-primary); }
.tab.is-active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* ---------------------------------------------------------------------
   11. Modal
   --------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: var(--overlay);
  display: grid; place-items: center;
  padding: var(--space-4);
  z-index: 60;
  animation: fadeIn 140ms ease;
}
.modal {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: min(720px, 100%);
  max-height: min(90vh, 900px);
  display: flex;
  flex-direction: column;
  animation: slideUp 160ms ease;
}
.modal--sm { width: min(440px, 100%); }
.modal--lg { width: min(1000px, 100%); }
.modal__header { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border); }
.modal__title { font-size: 15px; font-weight: 600; }
.modal__close { margin-left: auto; }
.modal__body { padding: var(--space-5); overflow-y: auto; flex: 1 1 auto; }
.modal__footer { display: flex; gap: var(--space-2); justify-content: flex-end; padding: var(--space-4) var(--space-5); border-top: 1px solid var(--border); }

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { transform: translateY(10px); opacity: 0 } to { transform: none; opacity: 1 } }

/* ---------------------------------------------------------------------
   12. Toasts
   --------------------------------------------------------------------- */
.toast-stack {
  position: fixed;
  right: var(--space-5);
  bottom: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 80;
  max-width: min(380px, calc(100vw - 32px));
}
.toast {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-3) var(--space-4);
  animation: slideUp 160ms ease;
}
.toast--success { border-left-color: var(--status-good); }
.toast--warning { border-left-color: var(--status-warning); }
.toast--error { border-left-color: var(--status-critical); }
.toast__title { font-size: 13.5px; font-weight: 600; }
.toast__msg { font-size: 12.5px; color: var(--text-secondary); }
.toast__close { margin-left: auto; background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 16px; line-height: 1; padding: 0 2px; }

/* ---------------------------------------------------------------------
   13. Gráficos
   --------------------------------------------------------------------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart__legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-3) var(--space-4) 0;
  font-size: 12.5px;
  color: var(--text-secondary);
}
.chart__legend-item { display: inline-flex; align-items: center; gap: 6px; }
.chart__swatch { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.chart__grid-line { stroke: var(--grid); stroke-width: 1; }
.chart__axis-line { stroke: var(--axis); stroke-width: 1; }
.chart__tick { fill: var(--text-muted); font-size: 11px; }
.chart__label { fill: var(--text-secondary); font-size: 11.5px; font-weight: 600; }
.chart__empty { display: grid; place-items: center; min-height: 180px; color: var(--text-muted); font-size: 13px; }

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 7px 10px;
  font-size: 12px;
  z-index: 5;
  white-space: nowrap;
  transform: translate(-50%, -110%);
  opacity: 0;
  transition: opacity 100ms ease;
}
.tooltip.is-visible { opacity: 1; }
.tooltip__title { font-weight: 600; margin-bottom: 3px; }
.tooltip__row { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.tooltip__value { font-variant-numeric: tabular-nums; font-weight: 600; }
.tooltip__swatch { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 auto; }

/* ---------------------------------------------------------------------
   14. Mapa
   --------------------------------------------------------------------- */
.map {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 320px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: grab;
}
.map:active { cursor: grabbing; }
.map__grid { stroke: var(--grid); stroke-width: .5; }
.map__water { fill: color-mix(in srgb, var(--brand) 5%, transparent); }
.map__geofence { fill-opacity: .12; stroke-width: 1.5; }
.map__vehicle { cursor: pointer; }
.map__vehicle-ring { fill: var(--surface-1); stroke-width: 2; }
.map__controls { position: absolute; top: var(--space-3); right: var(--space-3); display: flex; flex-direction: column; gap: var(--space-1); }
.map__control {
  width: 30px; height: 30px;
  border: 1px solid var(--border-strong);
  background: var(--surface-1);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 15px;
  line-height: 1;
}
.map__control:hover { background: var(--surface-2); }
.map__legend {
  position: absolute;
  left: var(--space-3);
  bottom: var(--space-3);
  background: color-mix(in srgb, var(--surface-1) 92%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  font-size: 11.5px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 240px;
}
.map__badge {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  background: color-mix(in srgb, var(--surface-1) 92%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 600;
}

/* ---------------------------------------------------------------------
   15. Alertas / lista
   --------------------------------------------------------------------- */
.alert-list { display: flex; flex-direction: column; }
.alert-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.alert-item:last-child { border-bottom: none; }
.alert-item--unread { background: var(--brand-soft); }
.alert-item__icon { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; font-size: 14px; }
.alert-item__body { flex: 1 1 auto; min-width: 0; }
.alert-item__title { font-size: 13.5px; font-weight: 600; }
.alert-item__msg { font-size: 12.5px; color: var(--text-secondary); }
.alert-item__meta { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; display: flex; gap: var(--space-3); flex-wrap: wrap; }
.alert-item__actions { flex: 0 0 auto; }

.icon-info { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); }
.icon-warning { background: color-mix(in srgb, var(--status-warning) 20%, transparent); color: color-mix(in srgb, var(--status-warning) 70%, var(--text-primary)); }
.icon-critical { background: color-mix(in srgb, var(--status-critical) 16%, transparent); color: var(--status-critical); }

.bell { position: relative; }
.bell__count {
  position: absolute;
  top: -3px; right: -3px;
  background: var(--status-critical);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 5px;
  min-width: 17px;
  text-align: center;
  border: 2px solid var(--page);
}
.bell.is-ringing { animation: ring 500ms ease; }
@keyframes ring { 0%, 100% { transform: rotate(0) } 25% { transform: rotate(12deg) } 75% { transform: rotate(-12deg) } }

/* ---------------------------------------------------------------------
   16. Diversos
   --------------------------------------------------------------------- */
.empty-state { text-align: center; padding: var(--space-6) var(--space-4); color: var(--text-muted); }
.empty-state__icon { font-size: 30px; margin-bottom: var(--space-2); opacity: .5; }
.empty-state__title { font-size: 14px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
  border-radius: var(--radius-sm);
  min-height: 14px;
}
@keyframes shimmer { 0% { background-position: 100% 0 } 100% { background-position: -100% 0 } }

.spinner {
  width: 22px; height: 22px;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }
.loading-overlay { display: grid; place-items: center; padding: var(--space-6); }

.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-critical { color: var(--status-critical); }
.text-good { color: var(--status-good-ink); }
.text-sm { font-size: 12.5px; }
.text-xs { font-size: 11.5px; }
.text-mono { font-variant-numeric: tabular-nums; }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fw-600 { font-weight: 600; }
.mt-0 { margin-top: 0 } .mt-2 { margin-top: var(--space-2) } .mt-3 { margin-top: var(--space-3) } .mt-4 { margin-top: var(--space-4) }
.mb-0 { margin-bottom: 0 } .mb-2 { margin-bottom: var(--space-2) } .mb-3 { margin-bottom: var(--space-3) } .mb-4 { margin-bottom: var(--space-4) }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--brand);
  color: var(--brand-ink);
  display: grid; place-items: center;
  font-size: 12.5px; font-weight: 650;
  flex: 0 0 auto;
}

.dropdown { position: relative; }
.dropdown__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 210px;
  padding: var(--space-2);
  z-index: 50;
}
.dropdown__item {
  display: flex; align-items: center; gap: var(--space-3);
  width: 100%;
  padding: 8px var(--space-3);
  background: none; border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  font-size: 13.5px;
  color: var(--text-secondary);
}
.dropdown__item:hover { background: var(--surface-2); color: var(--text-primary); text-decoration: none; }
.dropdown__divider { height: 1px; background: var(--border); margin: var(--space-2) 0; }
.dropdown__header { padding: var(--space-2) var(--space-3); font-size: 12px; color: var(--text-muted); }

/* Tela de login */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-5);
  background:
    radial-gradient(circle at 15% 20%, var(--brand-soft), transparent 45%),
    radial-gradient(circle at 85% 80%, color-mix(in srgb, var(--series-3) 12%, transparent), transparent 45%),
    var(--page);
}
.login-card { width: min(400px, 100%); }

/* Login em tela cheia: a casca (menu lateral e barra superior) sai de cena */
body.is-auth .sidebar,
body.is-auth .topbar { display: none; }
body.is-auth .main { width: 100%; }
body.is-auth .content { padding: 0; max-width: none; }

.login-split {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  min-height: 100vh;
}
.login-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-5);
  padding: clamp(24px, 5vw, 64px);
  color: var(--brand-ink);
  background:
    radial-gradient(circle at 20% 15%, color-mix(in srgb, #ffffff 18%, transparent), transparent 55%),
    linear-gradient(150deg, var(--brand) 0%, color-mix(in srgb, var(--brand) 62%, #10161f) 100%);
}
.login-brand__logo {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, #ffffff 18%, transparent);
  border: 1px solid color-mix(in srgb, #ffffff 26%, transparent);
}
.login-brand__title { font-size: clamp(26px, 3.4vw, 38px); font-weight: 680; line-height: 1.15; margin: 0; letter-spacing: -0.02em; }
.login-brand__subtitle { margin: 0; max-width: 46ch; font-size: 15px; opacity: 0.86; line-height: 1.6; }
.login-brand__list { display: grid; gap: var(--space-3); margin: 0; padding: 0; list-style: none; }
.login-brand__item { display: flex; align-items: flex-start; gap: 12px; font-size: 14px; opacity: 0.94; }
.login-brand__bullet {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, #ffffff 20%, transparent);
  font-size: 13px;
}
.login-form { display: grid; place-items: center; padding: var(--space-6) var(--space-5); background: var(--page); }
.login-form__inner { width: min(400px, 100%); }
.login-demo { display: grid; gap: 6px; margin-top: 10px; }
.login-demo__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  font-size: 12.5px;
  color: var(--text-secondary);
  text-align: left;
  cursor: pointer;
}
.login-demo__item:hover { border-color: var(--brand); color: var(--text-primary); }
.password-toggle {
  position: absolute;
  inset-inline-end: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}
.password-toggle:hover { color: var(--text-primary); background: var(--surface-2); }
.password-strength { display: flex; gap: 4px; margin-top: 6px; }
.password-strength__bar { height: 4px; flex: 1 1 0; border-radius: 2px; background: var(--border); }
.password-strength__bar.is-on-1 { background: var(--status-critical); }
.password-strength__bar.is-on-2 { background: var(--status-warning); }
.password-strength__bar.is-on-3 { background: var(--status-good); }

@media (max-width: 900px) {
  .login-split { grid-template-columns: 1fr; }
  .login-brand { display: none; }
}
.login-card__brand { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); margin-bottom: var(--space-5); text-align: center; }
.login-card__logo { width: 54px; height: 54px; border-radius: 16px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-size: 22px; font-weight: 700; }
.login-hint { margin-top: var(--space-4); padding: var(--space-3); background: var(--surface-2); border-radius: var(--radius-sm); font-size: 12px; color: var(--text-secondary); }
.login-hint code { background: var(--surface-1); padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }

/* ---------------------------------------------------------------------
   17. Responsivo
   --------------------------------------------------------------------- */
@media (max-width: 1080px) {
  .grid--sidebar { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.is-open { transform: none; }
  .main { margin-left: 0; }
  .topbar__menu { display: inline-flex; }
  .content { padding: var(--space-4); }
  .topbar { padding: 0 var(--space-4); }
  .grid { gap: var(--space-3); }
  .kpi__value { font-size: 24px; }
}

@media (max-width: 560px) {
  .grid--kpi { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .page-header__actions { width: 100%; }
  .page-header__actions .btn { flex: 1 1 auto; }
  .toast-stack { left: var(--space-4); right: var(--space-4); bottom: var(--space-4); max-width: none; }
}

@media print {
  .sidebar, .topbar, .page-header__actions, .filters, .pagination { display: none !important; }
  .main { margin-left: 0; }
  .card { break-inside: avoid; box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
