/* ============================================================================
 * Central de Conectividade Operacional — ESTILOS
 * Tema claro corporativo. Todas as cores principais ficam nas variáveis abaixo.
 * ========================================================================== */

:root {
  /* Paleta institucional (edite aqui para retematizar a plataforma) */
  --bg: #F4F7FA;
  --panel: #FFFFFF;
  --blue-900: #123B5D;
  --blue-600: #1D6FA5;
  --blue-100: #EAF3F9;
  --text: #1F2937;
  --text-2: #667085;
  --border: #D9E2EC;
  --online: #16A36A;
  --degraded: #F59E0B;
  --offline: #D64545;
  --maintenance: #7C5CE7;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 3px rgba(18, 59, 93, 0.08), 0 4px 14px rgba(18, 59, 93, 0.06);
  --shadow-lg: 0 6px 24px rgba(18, 59, 93, 0.14);
  --font: "Inter", "Roboto", "Segoe UI", system-ui, sans-serif;

  --header-h: 58px;
  --footer-h: 34px;
  --sidebar-w: 322px;
  --detail-w: 392px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

button { font-family: inherit; }

/* Foco visível para navegação por teclado */
:focus-visible {
  outline: 2px solid var(--blue-600);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ============================= LAYOUT GERAL ============================= */

.app {
  display: grid;
  grid-template-rows: var(--header-h) 1fr var(--footer-h);
  height: 100vh;
}

.main {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--detail-w);
  min-height: 0;
}

/* ============================== CABEÇALHO =============================== */

.header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  z-index: 1200;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand-mark {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--blue-900);
  color: #fff;
  flex: none;
}
.brand-mark svg { width: 21px; height: 21px; }

.brand-text { line-height: 1.15; min-width: 0; }
.brand-name {
  font-weight: 700; font-size: 15px; color: var(--blue-900);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-sub { font-size: 11.5px; color: var(--text-2); white-space: nowrap; }

.badge-demo {
  background: var(--blue-100);
  color: var(--blue-600);
  border: 1px solid #C6E0F0;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em;
  padding: 3px 8px; border-radius: 999px;
  flex: none;
}

.header-spacer { flex: 1; }

.header-right { display: flex; align-items: center; gap: 10px; }

.sys-clock {
  text-align: right; line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.sys-clock .time { font-weight: 600; font-size: 14px; }
.sys-clock .date { font-size: 11px; color: var(--text-2); }

.sys-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600;
  padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-2);
  white-space: nowrap;
}
.sys-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--online); }
.sys-pill.paused { background: #FEF6E7; border-color: #F1D8A5; color: #92600A; }
.sys-pill.paused .dot { background: var(--degraded); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 12.5px; font-weight: 600;
  cursor: pointer;
  min-height: 34px;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--blue-100); border-color: #BFD8E8; }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }
.btn-primary:hover { background: var(--blue-900); border-color: var(--blue-900); }
.btn-icon { padding: 7px; width: 34px; }
.btn-block { width: 100%; }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px 5px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
}
.user-chip .avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--blue-100); color: var(--blue-600);
}
.user-chip .avatar svg { width: 15px; height: 15px; }
.user-chip .name { font-size: 12px; font-weight: 600; white-space: nowrap; }

/* =========================== PAINEL ESQUERDO ============================ */

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.side-section { padding: 14px 14px 4px; }
.side-section + .side-section { border-top: 1px solid var(--border); margin-top: 10px; padding-top: 12px; }

.side-title {
  display: flex; align-items: center; gap: 7px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--text-2);
  margin: 0 0 10px;
}
.side-title svg { width: 13px; height: 13px; }

/* Resumo operacional */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.sum-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 6px;
  text-align: center;
}
.sum-card .num { font-size: 17px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.sum-card .lbl { font-size: 10px; color: var(--text-2); margin-top: 2px; }
.sum-card.s-online .num { color: var(--online); }
.sum-card.s-degraded .num { color: #B45309; }
.sum-card.s-offline .num { color: var(--offline); }

/* Busca */
.search-wrap { position: relative; }
.search-wrap svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--text-2); pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 9px 10px 9px 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit; font-size: 13px;
  background: var(--bg);
  color: var(--text);
}
.search-input:focus { background: #fff; border-color: var(--blue-600); outline: none; }
.search-input::placeholder { color: #98A2B3; }

/* Filtros */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-2);
  font-size: 12px; font-weight: 600;
  border-radius: 999px;
  padding: 5px 11px;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 28px;
}
.chip:hover { border-color: var(--blue-600); color: var(--blue-600); }
.chip.active {
  background: var(--blue-900); border-color: var(--blue-900); color: #fff;
}

.select-field {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit; font-size: 12.5px;
  color: var(--text);
  background: var(--panel);
  margin-bottom: 4px;
}

/* Switches de visualização */
.toggle-list { display: flex; flex-direction: column; gap: 2px; }
.toggle-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 2px;
  font-size: 12.5px;
  cursor: pointer;
  border-radius: 6px;
}
.toggle-item:hover { background: var(--blue-100); }
.switch { position: relative; width: 34px; height: 19px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0;
  background: #CBD5E1; border-radius: 999px;
  transition: background 0.15s;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 15px; height: 15px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.25);
  transition: transform 0.15s;
}
.switch input:checked + .track { background: var(--blue-600); }
.switch input:checked + .track::after { transform: translateX(15px); }
.switch input:focus-visible + .track { outline: 2px solid var(--blue-600); outline-offset: 2px; }

/* Lista de dispositivos */
.device-list { display: flex; flex-direction: column; gap: 6px; padding-bottom: 8px; }
.device-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.device-item:hover { border-color: var(--blue-600); background: var(--blue-100); }
.device-item.selected { border-color: var(--blue-600); background: var(--blue-100); box-shadow: inset 3px 0 0 var(--blue-600); }
.device-item .d-icon {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--blue-100); color: var(--blue-900);
}
.device-item .d-icon svg { width: 16px; height: 16px; }
.device-item .d-txt { min-width: 0; flex: 1; }
.device-item .d-name { font-weight: 600; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-item .d-meta { font-size: 11px; color: var(--text-2); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.empty-note {
  padding: 14px 10px;
  font-size: 12.5px; color: var(--text-2);
  text-align: center;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}

/* Badges de status */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 700;
  padding: 2.5px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.online      { background: #E6F7EF; color: #0E7A4F; }
.badge.degraded    { background: #FEF3DC; color: #92600A; }
.badge.offline     { background: #FBE9E9; color: #A93232; }
.badge.maintenance { background: #EFEAFD; color: #5B3ED6; }

/* Eventos */
.event-list { display: flex; flex-direction: column; gap: 6px; padding-bottom: 14px; }
.event-item {
  width: 100%; text-align: left;
  display: flex; gap: 9px;
  border: 1px solid var(--border);
  border-left-width: 3px;
  background: var(--panel);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  cursor: pointer;
  transition: background 0.15s;
}
.event-item:hover { background: var(--blue-100); }
.event-item .e-time { font-size: 11px; color: var(--text-2); font-variant-numeric: tabular-nums; flex: none; padding-top: 1px; }
.event-item .e-body { min-width: 0; }
.event-item .e-sev { font-size: 10px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.event-item .e-text { font-size: 12px; margin-top: 1px; }
.event-item.sev-critical { border-left-color: var(--offline); }
.event-item.sev-critical .e-sev { color: var(--offline); }
.event-item.sev-warning { border-left-color: var(--degraded); }
.event-item.sev-warning .e-sev { color: #B45309; }
.event-item.sev-ok { border-left-color: var(--online); }
.event-item.sev-ok .e-sev { color: var(--online); }
.event-item.sev-info { border-left-color: var(--blue-600); }
.event-item.sev-info .e-sev { color: var(--blue-600); }

/* ================================= MAPA ================================= */

.map-area { position: relative; min-width: 0; min-height: 0; background: var(--blue-100); }
#map { position: absolute; inset: 0; z-index: 1; }

/* Falha ao carregar a camada cartográfica */
.map-fallback {
  position: absolute; inset: 0; z-index: 5;
  display: none;
  place-items: center;
  background: var(--bg);
  text-align: center;
  padding: 24px;
}
.map-fallback.show { display: grid; }
.map-fallback .box {
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
  color: var(--text-2);
}
.map-fallback svg { width: 34px; height: 34px; color: var(--degraded); margin-bottom: 10px; }
.map-fallback h3 { margin: 0 0 6px; color: var(--text); font-size: 15px; }

/* Aviso "nenhum dispositivo visível" */
.map-empty {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%);
  z-index: 900;
  display: none;
  align-items: center; gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 9px 14px;
  font-size: 12.5px; color: var(--text-2);
}
.map-empty.show { display: flex; }
.map-empty svg { width: 15px; height: 15px; color: var(--degraded); }

/* Barra de indicadores sobre o mapa */
.map-kpis {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 900;
  display: flex; align-items: center; gap: 14px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(4px);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
  padding: 7px 18px;
  font-size: 12px;
  white-space: nowrap;
}
.map-kpis .kpi { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.map-kpis .kpi b { color: var(--text); font-variant-numeric: tabular-nums; }
.map-kpis .kpi .dot { width: 7px; height: 7px; border-radius: 50%; }
.map-kpis .sep { width: 1px; height: 16px; background: var(--border); }

/* Controles do mapa (coluna direita) */
.map-controls {
  position: absolute; top: 60px; right: 12px; z-index: 900;
  display: flex; flex-direction: column; gap: 6px;
}
.map-controls .btn { box-shadow: var(--shadow); }
.map-controls .btn.active { background: var(--blue-900); border-color: var(--blue-900); color: #fff; }

/* Barra de acompanhamento de viatura */
.follow-bar {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  z-index: 900;
  display: none;
  align-items: center; gap: 12px;
  background: var(--blue-900);
  color: #fff;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  padding: 8px 10px 8px 18px;
  font-size: 12.5px; font-weight: 600;
}
.follow-bar.show { display: flex; }
.follow-bar svg { width: 15px; height: 15px; }
.follow-bar .btn {
  background: rgba(255,255,255,0.14); border-color: transparent; color: #fff;
  min-height: 28px; padding: 4px 12px; font-size: 12px;
}
.follow-bar .btn:hover { background: rgba(255,255,255,0.26); }

/* Legenda */
.legend {
  position: absolute; bottom: 18px; left: 12px; z-index: 900;
  background: rgba(255,255,255,0.95);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px;
  font-size: 11.5px;
  min-width: 170px;
}
.legend h4 {
  margin: 0 0 6px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--text-2);
}
.legend .row { display: flex; align-items: center; gap: 8px; padding: 2px 0; color: var(--text); }
.legend .row svg { width: 13px; height: 13px; color: var(--blue-900); }
.legend .swatch { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.legend .grp + .grp { margin-top: 8px; padding-top: 7px; border-top: 1px solid var(--border); }

/* ======================== MARCADORES PERSONALIZADOS ===================== */

.leaflet-div-icon-clean { background: none; border: none; }

/* Movimento suave dos marcadores entre ticks da simulação */
.leaflet-marker-pane .mk-anim { transition: transform 1s linear; }
.leaflet-map-pane .leaflet-zoom-anim .mk-anim { transition: none; }

.mk { position: relative; display: grid; justify-items: center; }

.mk-body {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  background: #fff;
  border: 2.5px solid var(--online);
  box-shadow: 0 2px 6px rgba(18,59,93,0.3);
  color: var(--blue-900);
  position: relative;
  z-index: 2;
}
.mk-body svg { width: 17px; height: 17px; }

.mk-vehicle .mk-body { border-radius: 50%; }
.mk-base .mk-body    { border-radius: 9px; }
.mk-tower .mk-body   { border-radius: 50%; width: 32px; height: 32px; }

.mk.st-online .mk-body      { border-color: var(--online); }
.mk.st-degraded .mk-body    { border-color: var(--degraded); }
.mk.st-offline .mk-body     { border-color: var(--offline); color: #98A2B3; }
.mk.st-maintenance .mk-body { border-color: var(--maintenance); }

/* Ponto de status no canto do marcador */
.mk-status-dot {
  position: absolute; top: -2px; right: -2px; z-index: 3;
  width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid #fff;
  background: var(--online);
}
.mk.st-degraded .mk-status-dot    { background: var(--degraded); }
.mk.st-offline .mk-status-dot     { background: var(--offline); }
.mk.st-maintenance .mk-status-dot { background: var(--maintenance); }

/* Pulso discreto para dispositivos fixos online */
@keyframes mkPulse {
  0%   { transform: scale(0.85); opacity: 0.5; }
  70%  { transform: scale(1.7);  opacity: 0; }
  100% { transform: scale(1.7);  opacity: 0; }
}
.mk-pulse {
  position: absolute; top: 0; left: 50%; margin-left: -17px;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--online);
  opacity: 0; z-index: 1;
  pointer-events: none;
}
.mk.st-online .mk-pulse { animation: mkPulse 2.8s ease-out infinite; }

/* Ondas das torres online */
@keyframes towerWave {
  0%   { transform: scale(0.6); opacity: 0.55; }
  100% { transform: scale(2.1); opacity: 0; }
}
.mk-wave {
  position: absolute; top: -1px; left: 50%; margin-left: -17px;
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid var(--online);
  opacity: 0; z-index: 1;
  pointer-events: none;
}
.mk-tower.st-online .mk-wave    { animation: towerWave 3s ease-out infinite; }
.mk-tower.st-online .mk-wave.w2 { animation-delay: 1.5s; }

/* Seta de direção da viatura (gira conforme o deslocamento) */
.mk-heading {
  position: absolute; inset: -8px; z-index: 1;
  display: grid; justify-items: center;
  pointer-events: none;
  transition: transform 0.9s linear;
}
.mk-heading::before {
  content: "";
  width: 0; height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 8px solid var(--blue-900);
}
.mk.st-offline .mk-heading, .mk.st-maintenance .mk-heading { display: none; }

/* Rótulo sempre visível das viaturas */
.mk-label {
  margin-top: 5px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 7px;
  box-shadow: 0 1px 4px rgba(18,59,93,0.18);
  padding: 2.5px 8px;
  text-align: center;
  line-height: 1.25;
  white-space: nowrap;
  z-index: 2;
}
.mk-label b { font-size: 11px; font-weight: 700; color: var(--blue-900); display: block; }
.mk-label span { font-size: 10px; color: var(--text-2); }
.mk-label .st-txt.online { color: #0E7A4F; }
.mk-label .st-txt.degraded { color: #92600A; }
.mk-label .st-txt.offline { color: #A93232; }
.mk-label .st-txt.maintenance { color: #5B3ED6; }

/* Zoom afastado: rótulo mostra apenas o nome */
.zoom-far .mk-label span { display: none; }
/* Ocultar rótulos via switch */
.labels-off .mk-vehicle .mk-label { display: none; }
/* Rótulos de fixos aparecem apenas em zoom mais próximo */
.mk-base .mk-label, .mk-tower .mk-label { display: none; }
.zoom-near .mk-base .mk-label, .zoom-near .mk-tower .mk-label { display: block; }

/* Marcador selecionado */
.mk-selected .mk-body {
  box-shadow: 0 0 0 4px rgba(29, 111, 165, 0.35), 0 2px 8px rgba(18,59,93,0.35);
}
.mk-selected .mk-label { border-color: var(--blue-600); }

/* Tooltip do Leaflet */
.leaflet-tooltip.qs-tip {
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-family: var(--font);
  font-size: 12px;
  padding: 8px 10px;
}
.qs-tip b { color: var(--blue-900); }
.qs-tip .muted { color: var(--text-2); font-size: 11px; }

/* Rotas */
.route-line { stroke: var(--blue-600); }

/* Cluster (agrupamento) */
.qs-cluster {
  background: rgba(29, 111, 165, 0.85);
  color: #fff;
  border: 3px solid #fff;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 12px;
  box-shadow: 0 2px 8px rgba(18,59,93,0.35);
}

/* =========================== PAINEL DE DETALHES ========================= */

.detail {
  background: var(--panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.detail-empty {
  flex: 1;
  display: grid; place-items: center;
  padding: 30px 26px;
  text-align: center;
  color: var(--text-2);
  font-size: 13px;
}
.detail-empty svg { width: 38px; height: 38px; color: #B9C6D3; margin-bottom: 12px; }

.detail-head {
  position: sticky; top: 0; z-index: 10;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px 12px;
}
.detail-head .row1 { display: flex; align-items: flex-start; gap: 10px; }
.detail-head .d-icon {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--blue-900); color: #fff;
}
.detail-head .d-icon svg { width: 20px; height: 20px; }
.detail-head h2 { margin: 0; font-size: 15.5px; line-height: 1.2; }
.detail-head .sub { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.detail-head .row2 { display: flex; align-items: center; gap: 8px; margin-top: 9px; flex-wrap: wrap; }
.detail-head .upd { font-size: 11px; color: var(--text-2); }
.detail-close { margin-left: auto; flex: none; }

.detail-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 7px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.detail-actions .btn { font-size: 12px; padding: 7px 8px; }

.d-section { padding: 12px 16px 4px; }
.d-section + .d-section { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 12px; }
.d-section:last-child { padding-bottom: 16px; }
.d-section h3 {
  display: flex; align-items: center; gap: 7px;
  margin: 0 0 9px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--text-2);
}
.d-section h3 svg { width: 13px; height: 13px; }

.kv { display: grid; grid-template-columns: 46% 54%; row-gap: 6px; font-size: 12.5px; margin-bottom: 8px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 8px; }
.metric {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.metric .m-lbl { font-size: 10.5px; color: var(--text-2); }
.metric .m-val { font-size: 15px; font-weight: 700; margin-top: 1px; font-variant-numeric: tabular-nums; }
.metric .m-val small { font-size: 10.5px; font-weight: 600; color: var(--text-2); }
.metric.warn { border-color: #F1D8A5; background: #FEF9EF; }
.metric.warn .m-val { color: #B45309; }

.alert-note {
  display: flex; gap: 8px; align-items: flex-start;
  border: 1px solid #F1D8A5;
  background: #FEF6E7;
  color: #92600A;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 12px;
  margin-bottom: 8px;
}
.alert-note.crit { border-color: #F0C4C4; background: #FBEDED; color: #A93232; }
.alert-note.maint { border-color: #D8CCF7; background: #F2EEFD; color: #5B3ED6; }
.alert-note svg { width: 14px; height: 14px; flex: none; margin-top: 1px; }

/* Linha do tempo de eventos do dispositivo */
.timeline { display: flex; flex-direction: column; gap: 0; padding-bottom: 8px; }
.tl-item { display: flex; gap: 10px; position: relative; padding-bottom: 12px; }
.tl-item::before {
  content: ""; position: absolute; left: 4.5px; top: 14px; bottom: 0;
  width: 1.5px; background: var(--border);
}
.tl-item:last-child::before { display: none; }
.tl-dot {
  width: 10px; height: 10px; border-radius: 50%; flex: none;
  margin-top: 3px;
  background: var(--blue-600);
}
.tl-item.sev-warning .tl-dot { background: var(--degraded); }
.tl-item.sev-critical .tl-dot { background: var(--offline); }
.tl-item.sev-ok .tl-dot { background: var(--online); }
.tl-body { font-size: 12px; }
.tl-body .tl-time { color: var(--text-2); font-size: 11px; font-variant-numeric: tabular-nums; }

.fict-note { font-size: 10.5px; color: #98A2B3; font-style: italic; margin: 2px 0 8px; }

/* ================================ RODAPÉ ================================ */

.footer {
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--text-2);
  white-space: nowrap; overflow: hidden;
}
.footer .f-item { display: flex; align-items: center; gap: 6px; }
.footer .swatch { width: 8px; height: 8px; border-radius: 50%; }
.footer .spacer { flex: 1; }
.footer b { color: var(--text); font-weight: 600; }

/* ============================ RESPONSIVIDADE ============================ */

/* Telas médias: painel de detalhes vira sobreposição */
@media (max-width: 1279px) {
  .main { grid-template-columns: var(--sidebar-w) 1fr; }
  .detail {
    position: fixed;
    top: var(--header-h); right: 0; bottom: var(--footer-h);
    width: min(var(--detail-w), 92vw);
    box-shadow: var(--shadow-lg);
    transform: translateX(102%);
    transition: transform 0.22s ease;
    z-index: 1100;
  }
  .detail.open { transform: translateX(0); }
  .detail-empty { display: none; }
}

/* Tablet / celular: sidebar vira drawer */
@media (max-width: 899px) {
  .main { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: var(--header-h); left: 0; bottom: var(--footer-h);
    width: min(var(--sidebar-w), 88vw);
    box-shadow: var(--shadow-lg);
    transform: translateX(-102%);
    transition: transform 0.22s ease;
    z-index: 1100;
  }
  .sidebar.open { transform: translateX(0); }
  .brand-sub, .sys-clock .date, .user-chip .name, .sys-pill.auto { display: none; }
  .summary-grid { grid-template-columns: repeat(4, minmax(64px, 1fr)); overflow-x: auto; }
  .map-kpis { top: auto; bottom: 60px; max-width: 94vw; overflow-x: auto; }
  .legend { display: none; }
}

#btn-menu { display: none; }
@media (max-width: 899px) { #btn-menu { display: inline-flex; } }
