/* ==========================================================================
   EASECOM PTT - SISTEMA DE RONDA E GESTÃO TÁTICA DE VIGILÂNCIA
   Design System: Tactical Dark Glassmorphism, Neon Accents, Cyber-Surveillance
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
  --bg-deep: #07090e;
  --bg-surface: #0d121d;
  --bg-card: #131b2e;
  --bg-card-hover: #1a253d;
  --bg-elevated: #1f2b47;
  
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-active: rgba(16, 185, 129, 0.4);
  --border-focus: rgba(6, 182, 212, 0.5);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-dim: #475569;

  /* Tactical Accents */
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.25);
  --accent-cyan: #06b6d4;
  --accent-cyan-glow: rgba(6, 182, 212, 0.25);
  --accent-amber: #f59e0b;
  --accent-amber-glow: rgba(245, 158, 11, 0.25);
  --accent-rose: #f43f5e;
  --accent-rose-glow: rgba(244, 63, 94, 0.25);
  --accent-indigo: #6366f1;
  
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 20px rgba(16, 185, 129, 0.15);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --font-main: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-deep);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbars customizadas */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

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

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* HEADER TÁTICO */
.app-header {
  height: 64px;
  background: linear-gradient(180deg, #0f1626 0%, #0a0f1a 100%);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 1000;
  flex-shrink: 0;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-badge {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #059669, #0d9488);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px var(--accent-emerald-glow);
  color: #fff;
}

.brand-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #fff;
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-subtitle {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--accent-cyan);
  text-transform: uppercase;
}

.nav-links {
  display: flex;
  gap: 6px;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition);
}

.nav-item:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
  color: #fff;
  background: var(--bg-card);
  border: 1px solid rgba(16, 185, 129, 0.3);
  box-shadow: 0 0 10px var(--accent-emerald-glow);
}

/* GRUPOS DE MENU COM SUBMENU (dropdown) */
.nav-group {
  position: relative;
}

.nav-group-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.nav-group-trigger:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.nav-group.active .nav-group-trigger {
  color: #fff;
  background: var(--bg-card);
  border: 1px solid rgba(16, 185, 129, 0.3);
  box-shadow: 0 0 10px var(--accent-emerald-glow);
}

.nav-group-chevron {
  transition: transform 0.15s ease;
  opacity: 0.7;
}

.nav-group.open .nav-group-chevron {
  transform: rotate(180deg);
}

.nav-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 220px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
  z-index: 1100;
}

.nav-group:hover .nav-dropdown,
.nav-group.open .nav-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.nav-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition);
  white-space: nowrap;
}

.nav-dropdown-item:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

.nav-dropdown-item.active {
  color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.1);
}

/* KPI STRIP NO HEADER */
.kpi-strip {
  display: flex;
  align-items: center;
  gap: 16px;
}

.kpi-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(19, 27, 46, 0.8);
  border: 1px solid var(--border-subtle);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 12px;
}

.kpi-label {
  color: var(--text-secondary);
  font-weight: 500;
}

.kpi-val {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-emerald);
}

.kpi-val.warning {
  color: var(--accent-amber);
}

.kpi-val.danger {
  color: var(--accent-rose);
}

/* STATUS WS */
.live-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-emerald);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--accent-emerald);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* CORPO PRINCIPAL COM PAINÉIS */
.main-stage {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* SIDEBAR ESQUERDA */
.sidebar-panel {
  width: 380px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 500;
  flex-shrink: 0;
  transition: transform 0.3s ease;
  overflow: hidden;
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-deep);
}

.tab-btn {
  flex: 1;
  padding: 12px 6px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.02);
}

.tab-btn.active {
  color: var(--accent-emerald);
  border-bottom-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.05);
}

.tab-badge {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

.tab-btn.active .tab-badge {
  background: var(--accent-emerald);
  color: #000;
  font-weight: 700;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* CARDS DE RONDA / OPERADORES */
.patrol-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.patrol-card:hover {
  border-color: rgba(16, 185, 129, 0.4);
  background: var(--bg-card-hover);
  transform: translateY(-1px);
}

.patrol-card.selected {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 15px var(--accent-cyan-glow);
}

.patrol-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.route-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  display: flex;
  align-items: center;
  gap: 5px;
}

.route-badge.ordered {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
}

.status-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.status-tag.in_progress {
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-emerald);
}

.status-tag.delayed {
  background: rgba(245, 158, 11, 0.2);
  color: var(--accent-amber);
}

.status-tag.completed {
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
}

.operator-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.operator-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: #fff;
  border: 1px solid var(--border-subtle);
}

.operator-meta {
  display: flex;
  flex-direction: column;
}

.operator-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.operator-details {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* BARRA DE PROGRESSO */
.progress-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-secondary);
}

.progress-bar-bg {
  height: 6px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-emerald), var(--accent-cyan));
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

/* ÁREA CENTRAL DO MAPA */
.map-stage {
  flex: 1;
  height: 100%;
  position: relative;
  background: #060910;
}

#map {
  width: 100%;
  height: 100%;
  background: #060910;
}

/* GOOGLE MAPS DARK MODE TÁTICO */
.google-dark-tiles {
  filter: invert(100%) hue-rotate(180deg) brightness(92%) contrast(95%);
}

/* CONTROLES FLUTUANTES DO MAPA */
.leaflet-control-layers {
  background: rgba(13, 18, 29, 0.88) !important;
  backdrop-filter: blur(8px) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: var(--radius-md) !important;
  color: var(--text-primary) !important;
  font-family: var(--font-main) !important;
  font-size: 12px !important;
  padding: 8px 12px !important;
  box-shadow: var(--shadow-lg) !important;
}

.leaflet-control-layers-base label {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  margin-bottom: 4px !important;
  cursor: pointer !important;
}

.map-floating-controls {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-btn {
  background: rgba(13, 18, 29, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
}

.control-btn:hover {
  background: var(--bg-card-hover);
  color: #fff;
  border-color: var(--border-active);
}

.control-btn.active {
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-emerald);
  border-color: var(--accent-emerald);
}

/* SIMULATOR QUICK PANEL */
.simulator-dock {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(13, 18, 29, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(6, 182, 212, 0.3);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6), 0 0 15px var(--accent-cyan-glow);
  padding: 8px 18px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 450;
}

.sim-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.btn-primary:hover {
  filter: brightness(1.15);
  box-shadow: 0 0 12px var(--accent-emerald-glow);
}

.btn-danger {
  background: linear-gradient(135deg, #e11d48, #f43f5e);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.btn-danger:hover {
  filter: brightness(1.15);
  box-shadow: 0 0 12px var(--accent-rose-glow);
}

/* DRAWER DIREITO DE DETALHES */
.detail-drawer {
  width: 360px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 500;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.drawer-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-title {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  transition: var(--transition);
}

.close-btn:hover {
  color: #fff;
}

.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* LISTA DE CHECKPOINTS NO DRAWER */
.checkpoint-step {
  display: flex;
  gap: 12px;
  position: relative;
  padding-bottom: 16px;
}

.checkpoint-step:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 13px;
  top: 28px;
  bottom: 0;
  width: 2px;
  background: var(--bg-elevated);
}

.step-marker {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  z-index: 1;
  flex-shrink: 0;
}

.checkpoint-step.completed .step-marker {
  background: var(--accent-emerald);
  border-color: var(--accent-emerald);
  color: #000;
  box-shadow: 0 0 10px var(--accent-emerald-glow);
}

.checkpoint-step.dwelling .step-marker {
  background: var(--accent-cyan);
  border-color: var(--accent-cyan);
  color: #000;
  animation: pulse 1s infinite;
}

.checkpoint-step.out_of_order .step-marker {
  background: var(--accent-amber);
  border-color: var(--accent-amber);
  color: #000;
}

.step-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.step-title {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.step-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.step-badge-nfc {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  width: fit-content;
}

/* MODAL DE CRIAÇÃO / FORM */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 520px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 12px;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input, .form-select, .form-textarea {
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  color: #fff;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 13px;
  outline: none;
  transition: var(--transition);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.form-select {
  cursor: pointer;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-select option {
  background: #0d121d;
  color: #f8fafc;
  padding: 10px 12px;
}

[data-theme="light"] .form-select option {
  background: #ffffff;
  color: #0f172a;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent-emerald);
  box-shadow: 0 0 10px var(--accent-emerald-glow);
}

.form-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.form-row > * {
  flex: 1 1 0;
  min-width: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

/* ==========================================================================
   MELHORIAS DE LAYOUT: GRUPO DE RÁDIOS, SLOTS NA ROTA & GPS TRACKING
   ========================================================================== */

/* Sub-card de seções dentro de formulários complexos */
.form-section-card {
  background: rgba(13, 18, 29, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 8px;
}

.form-section-title {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Grid de Seleção de Rádios / Operadores */
.radio-selector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
  padding: 2px;
}

.radio-card-item {
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

.radio-card-item:hover {
  border-color: rgba(6, 182, 212, 0.4);
  background: rgba(6, 182, 212, 0.05);
}

.radio-card-item.selected {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.1);
}

.radio-checkbox {
  accent-color: var(--accent-emerald);
  cursor: pointer;
  width: 15px;
  height: 15px;
}

.radio-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #1f2b47;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  border: 1.5px solid var(--border-subtle);
  flex-shrink: 0;
}

.radio-card-item.selected .radio-avatar {
  border-color: var(--accent-emerald);
  color: var(--accent-emerald);
}

.radio-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
}

.radio-name {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.radio-meta {
  font-size: 9.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Seletor Interativo de Dias da Semana (Pills) */
.weekdays-bar {
  display: flex;
  gap: 4px;
}

.weekday-btn {
  flex: 1;
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 5px 0;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.weekday-btn:hover {
  border-color: var(--accent-cyan);
  color: #fff;
}

.weekday-btn.active {
  background: var(--accent-cyan);
  color: #07090e;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan-glow);
}

/* Tabela e Itens de Slots no Route Builder */
.slot-builder-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}

.slot-builder-item {
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  transition: var(--transition);
}

.slot-builder-item:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

.slot-time-badge {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 11px;
}

.slot-days-tag {
  color: var(--text-muted);
  font-size: 10px;
}

/* Rastreamento Estilo Uber (Uber-Track Glow Polyline) */
.uber-track-glow {
  filter: drop-shadow(0 0 6px #06b6d4);
}

.crumb-point-marker {
  width: 8px;
  height: 8px;
  background: #06b6d4;
  border: 1.5px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(6, 182, 212, 0.8);
}

/* ==========================================================================
   CARDS DE CHECKPOINT MODERNOS E EXPANSÍVEIS (SEM QUEBRAS)
   ========================================================================== */
.checkpoint-item-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: var(--transition);
  cursor: pointer;
}

.checkpoint-item-card:hover {
  border-color: var(--accent-cyan);
  background: var(--bg-card-hover);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.checkpoint-item-card.editing {
  border-color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.08);
  box-shadow: 0 0 15px var(--accent-amber-glow);
}

.cp-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.cp-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.cp-code-badge {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.35);
  padding: 3px 8px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.cp-name-text {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cp-actions-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.cp-site-row {
  font-size: 11.5px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.cp-meta-pills {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.cp-pill {
  font-size: 10.5px;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.cp-pill.cyan {
  color: var(--accent-cyan);
  border-color: rgba(6, 182, 212, 0.25);
  background: rgba(6, 182, 212, 0.08);
}

.cp-pill.emerald {
  color: var(--accent-emerald);
  border-color: rgba(16, 185, 129, 0.25);
  background: rgba(16, 185, 129, 0.08);
}

.cp-pill.indigo {
  color: #a5b4fc;
  border-color: rgba(99, 102, 241, 0.25);
  background: rgba(99, 102, 241, 0.08);
}

/* ==========================================================================
   HEADER ACTION CONTROLS (TEMA & PROVEDOR DE MAPA)
   ========================================================================== */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-map-control {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
}

.header-map-select {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 11.5px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  padding: 2px 4px;
}

.header-map-select option {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.btn-theme-toggle {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 11.5px;
  font-weight: 700;
  transition: var(--transition);
}

.btn-theme-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent-cyan);
}

.btn-theme-toggle.is-light {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #0f172a;
}

/* ==========================================================================
   MODO CLARO (LIGHT THEME) SISTEMA COMPLETO
   ========================================================================== */
[data-theme="light"] {
  --bg-deep: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-card: #f8fafc;
  --bg-card-hover: #e2e8f0;
  --bg-elevated: #ffffff;

  --border-subtle: rgba(0, 0, 0, 0.09);
  --border-active: rgba(16, 185, 129, 0.5);
  --border-focus: rgba(6, 182, 212, 0.6);

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-dim: #94a3b8;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] body {
  background-color: var(--bg-deep);
  color: var(--text-primary);
}

[data-theme="light"] .app-header {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .brand-title {
  color: #0f172a;
}

[data-theme="light"] .nav-links {
  background: #e2e8f0;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .nav-item {
  color: #475569;
}

[data-theme="light"] .nav-item:hover {
  background: rgba(255, 255, 255, 0.6);
  color: #0f172a;
}

[data-theme="light"] .nav-item.active {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid rgba(16, 185, 129, 0.3);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .sidebar-panel,
[data-theme="light"] .detail-drawer {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .form-input,
[data-theme="light"] .form-select,
[data-theme="light"] .form-textarea {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
}

[data-theme="light"] .form-input:focus,
[data-theme="light"] .form-select:focus,
[data-theme="light"] .form-textarea:focus {
  border-color: var(--accent-emerald);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

[data-theme="light"] .checkpoint-item-card,
[data-theme="light"] .route-card,
[data-theme="light"] .form-section-card,
[data-theme="light"] .kpi-chip,
[data-theme="light"] .modal-container {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.09);
  color: #0f172a;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .checkpoint-name,
[data-theme="light"] .route-name,
[data-theme="light"] .modal-title,
[data-theme="light"] .drawer-title {
  color: #0f172a;
}

[data-theme="light"] .cp-pill {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #475569;
}

[data-theme="light"] .header-map-control {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

[data-theme="light"] .header-map-select {
  color: #0f172a;
}

[data-theme="light"] .header-map-select option {
  background: #ffffff;
  color: #0f172a;
}

[data-theme="light"] .btn-secondary {
  border-color: #cbd5e1;
  color: #334155;
}

[data-theme="light"] .btn-secondary:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.leaflet-popup-content-wrapper {
  background: rgba(13, 18, 29, 0.96) !important;
  color: #f8fafc !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  backdrop-filter: blur(14px) !important;
  box-shadow: 0 12px 30px -4px rgba(0, 0, 0, 0.8), 0 0 1px 1px rgba(255, 255, 255, 0.08) !important;
  border-radius: 10px !important;
}

.leaflet-popup-tip {
  background: rgba(13, 18, 29, 0.96) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
}

.leaflet-popup-close-button {
  color: #94a3b8 !important;
  padding: 6px !important;
}

.leaflet-popup-close-button:hover {
  color: #fff !important;
}

[data-theme="light"] .leaflet-control-layers {
  background: rgba(255, 255, 255, 0.95) !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
  color: #0f172a !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12) !important;
}

[data-theme="light"] .leaflet-popup-content-wrapper {
  background: #ffffff !important;
  color: #0f172a !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15) !important;
}

[data-theme="light"] .leaflet-popup-tip {
  background: #ffffff !important;
}

/* ==========================================================================
   PAINEL DE AUDITORIA EXPANSÍVEL (TABELA HISTÓRICO / RELATÓRIOS)
   ========================================================================== */

.btn-audit-expander {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid rgba(6, 182, 212, 0.28);
  color: var(--accent-cyan);
  padding: 6px 13px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.btn-audit-expander:hover {
  background: rgba(6, 182, 212, 0.22);
  border-color: var(--accent-cyan);
  color: #fff;
  box-shadow: 0 0 14px var(--accent-cyan-glow);
  transform: translateY(-1px);
}

.btn-audit-expander.active {
  background: linear-gradient(135deg, var(--accent-cyan) 0%, #0891b2 100%);
  color: #04121d;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 16px var(--accent-cyan-glow);
}

.btn-audit-expander .chevron-icon {
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-audit-expander.active .chevron-icon {
  transform: rotate(180deg);
}

.audit-row-container {
  background: rgba(8, 12, 20, 0.98);
}

.audit-card-wrapper {
  padding: 22px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  border-left: 4px solid var(--accent-cyan);
  border-top: 1px solid rgba(6, 182, 212, 0.2);
  border-bottom: 2px solid rgba(6, 182, 212, 0.3);
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.92) 0%, rgba(10, 14, 23, 0.99) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 16px 36px rgba(0, 0, 0, 0.5);
  animation: auditFadeDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes auditFadeDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Barra Superior da Ficha de Auditoria */
.audit-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.audit-route-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.audit-device-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.35);
  color: #c4b5fd;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.audit-metrics-row {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.audit-metric-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
}

.audit-metric-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.audit-metric-val {
  font-size: 13.5px;
  font-weight: 800;
  color: #fff;
  font-family: var(--font-mono);
}

/* ==========================================================================
   LINHA DO TEMPO SEQUENCIAL (STEPPER TIMELINE DE CHECKPOINTS)
   ========================================================================== */
.audit-timeline-stepper {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  position: relative;
  margin-top: 6px;
}

.audit-step-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.22s ease;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.audit-step-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

/* Status do Step Card */
.audit-step-card.visited {
  border-color: rgba(16, 185, 129, 0.35);
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.08) 0%, rgba(13, 20, 32, 0.95) 100%);
  border-top: 3px solid var(--accent-emerald);
}

.audit-step-card.pending {
  border-color: rgba(255, 255, 255, 0.07);
  background: rgba(17, 24, 39, 0.45);
  opacity: 0.82;
}

.audit-step-card.out-of-order {
  border-color: rgba(245, 158, 11, 0.5);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.08) 0%, rgba(13, 20, 32, 0.95) 100%);
  border-top: 3px solid var(--accent-amber);
}

.audit-step-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.audit-step-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  font-weight: 800;
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.audit-step-card.visited .audit-step-number {
  background: var(--accent-emerald);
  color: #04121d;
  box-shadow: 0 0 10px var(--accent-emerald-glow);
}

.audit-step-card.pending .audit-step-number {
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.audit-step-card.out-of-order .audit-step-number {
  background: var(--accent-amber);
  color: #04121d;
  box-shadow: 0 0 10px var(--accent-amber-glow);
}

.audit-step-badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.audit-step-badge.visited {
  color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.audit-step-badge.pending {
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
}

.audit-step-badge.out-of-order {
  color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.audit-step-telemetry {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

.telemetry-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
}

.telemetry-label {
  color: var(--text-muted);
  font-size: 10.5px;
}

.telemetry-val {
  color: var(--text-primary);
  font-weight: 600;
  font-family: var(--font-mono);
}

.audit-method-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
}

.audit-method-tag.nfc {
  background: rgba(139, 92, 246, 0.18);
  color: #c4b5fd;
  border: 1px solid rgba(139, 92, 246, 0.35);
}

.audit-method-tag.qr {
  background: rgba(6, 182, 212, 0.18);
  color: #67e8f9;
  border: 1px solid rgba(6, 182, 212, 0.35);
}

.audit-method-tag.gps {
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.audit-method-tag.manual {
  background: rgba(245, 158, 11, 0.18);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

/* Incidentes */
.audit-incident-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(244, 63, 94, 0.08);
  border: 1px solid rgba(244, 63, 94, 0.3);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.audit-clean-badge {
  background: rgba(16, 185, 129, 0.06);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--accent-emerald);
}

/* ==========================================================================
   MODAL DE TRILHA TÁTICA NO MAPA
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.2s ease;
}

.modal-map-trail-content {
  width: 90vw;
  max-width: 960px;
  max-height: 90vh;
  background: var(--bg-surface);
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.8), 0 0 30px rgba(6, 182, 212, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: popIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 16px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: var(--transition);
}

.btn-close-modal:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.modal-footer {
  padding: 14px 20px;
  background: var(--bg-card);
  border-top: 1px solid var(--border-subtle);
}

.trail-map-legend {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(13, 18, 29, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  z-index: 1000;
  box-shadow: var(--shadow-md);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot.green { background: var(--accent-emerald); box-shadow: 0 0 6px var(--accent-emerald); }
.legend-dot.amber { background: var(--accent-amber); box-shadow: 0 0 6px var(--accent-amber); }
.legend-line { width: 14px; height: 3px; background: var(--accent-cyan); border-radius: 2px; }

/* Tema Claro */
[data-theme="light"] .btn-audit-expander {
  background: rgba(2, 132, 199, 0.1);
  border-color: rgba(2, 132, 199, 0.3);
  color: #0284c7;
}

[data-theme="light"] .btn-audit-expander.active {
  background: #0284c7;
  color: #ffffff;
}

[data-theme="light"] .audit-row-container {
  background: #f8fafc;
}

[data-theme="light"] .audit-card-wrapper {
  background: #ffffff;
  border-left-color: #0284c7;
  border-bottom: 1px solid #e2e8f0;
}

[data-theme="light"] .audit-step-card {
  background: #ffffff;
  border-color: #e2e8f0;
}
[data-theme="light"] .audit-metric-val {
  color: #0f172a;
}

/* ==========================================================================
   EASECOM ENTERPRISE TOAST & CONFIRM SYSTEM
   ========================================================================== */
.easecom-toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 420px;
  width: calc(100% - 32px);
  pointer-events: none;
}

.easecom-toast {
  pointer-events: auto;
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(13, 18, 29, 0.94);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 12px 30px -4px rgba(0, 0, 0, 0.7), 0 4px 12px rgba(0, 0, 0, 0.5);
  animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transition: all 0.25s ease;
  overflow: hidden;
}

.easecom-toast.toast-hiding {
  opacity: 0;
  transform: translateX(30px) scale(0.95);
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateY(-16px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.easecom-toast.success {
  border-left: 4px solid var(--accent-emerald);
  box-shadow: 0 12px 30px -4px rgba(0, 0, 0, 0.7), 0 0 15px var(--accent-emerald-glow);
}
.easecom-toast.error {
  border-left: 4px solid var(--accent-rose);
  box-shadow: 0 12px 30px -4px rgba(0, 0, 0, 0.7), 0 0 15px var(--accent-rose-glow);
}
.easecom-toast.warning {
  border-left: 4px solid var(--accent-amber);
  box-shadow: 0 12px 30px -4px rgba(0, 0, 0, 0.7), 0 0 15px var(--accent-amber-glow);
}
.easecom-toast.info {
  border-left: 4px solid var(--accent-cyan);
  box-shadow: 0 12px 30px -4px rgba(0, 0, 0, 0.7), 0 0 15px var(--accent-cyan-glow);
}

.toast-icon {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 2px;
}

.toast-message {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  word-break: break-word;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 16px;
  line-height: 1;
  border-radius: 4px;
  transition: var(--transition);
}

.toast-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.2);
  width: 100%;
  animation: toastProgress linear forwards;
}

.easecom-toast.success .toast-progress { background: var(--accent-emerald); }
.easecom-toast.error .toast-progress { background: var(--accent-rose); }
.easecom-toast.warning .toast-progress { background: var(--accent-amber); }
.easecom-toast.info .toast-progress { background: var(--accent-cyan); }

@keyframes toastProgress {
  from { width: 100%; }
  to { width: 0%; }
}

/* CONFIRM MODAL ENTERPRISE */
.easecom-confirm-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  padding: 16px;
}

.easecom-confirm-modal.active {
  display: flex;
}

.easecom-confirm-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 440px;
  max-width: 95vw;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-lg);
  animation: modalScaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScaleIn {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.confirm-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.confirm-icon-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.confirm-icon-circle.danger {
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: var(--accent-rose);
}

.confirm-icon-circle.warning {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--accent-amber);
}

.confirm-icon-circle.info {
  background: rgba(6, 182, 212, 0.15);
  border: 1px solid rgba(6, 182, 212, 0.3);
  color: var(--accent-cyan);
}

.confirm-title {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
}

.confirm-body {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

/* Light Theme for Toast & Confirm */
[data-theme="light"] .easecom-toast {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 10px 25px -4px rgba(0, 0, 0, 0.1), 0 4px 10px rgba(0, 0, 0, 0.05);
}
[data-theme="light"] .toast-title { color: #0f172a; }
[data-theme="light"] .toast-message { color: #475569; }
[data-theme="light"] .toast-close { color: #94a3b8; }
[data-theme="light"] .toast-close:hover { color: #0f172a; background: #f1f5f9; }
[data-theme="light"] .easecom-confirm-box {
  background: #ffffff;
  border-color: #cbd5e1;
}
[data-theme="light"] .confirm-title { color: #0f172a; }
[data-theme="light"] .confirm-body { color: #475569; }

/* HEADER USER PROFILE & SSO BADGE */
.header-user-profile {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-badge-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  padding: 4px 12px 4px 6px;
  border-radius: var(--radius-full);
  transition: var(--transition);
}

.user-badge-wrapper:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(6, 182, 212, 0.3);
}

.user-badge-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.user-badge-details {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  text-align: left;
}

.user-badge-name {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-badge-company {
  font-size: 10px;
  color: var(--accent-cyan);
  font-weight: 600;
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-logout {
  background: none;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-logout:hover {
  color: var(--accent-rose);
  border-color: rgba(244, 63, 94, 0.4);
  background: rgba(244, 63, 94, 0.1);
}

[data-theme="light"] .user-badge-wrapper {
  background: #f1f5f9;
  border-color: #cbd5e1;
}
[data-theme="light"] .user-badge-name {
  color: #0f172a;
}
[data-theme="light"] .user-badge-company {
  color: #0284c7;
}

/* =========================================================================
   SISTEMA DE EMERGÊNCIA & PÂNICO SOS DOS RÁDIOS (MISSION-CRITICAL)
   ========================================================================= */

@keyframes sosRadarPulse {
  0% {
    transform: scale(0.6);
    opacity: 0.95;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.9);
  }
  60% {
    transform: scale(1.6);
    opacity: 0.2;
    box-shadow: 0 0 0 16px rgba(239, 68, 68, 0);
  }
  100% {
    transform: scale(1.95);
    opacity: 0;
  }
}

@keyframes sosBeaconBlink {
  0% {
    opacity: 0.35;
    transform: scale(0.85);
  }
  100% {
    opacity: 1;
    transform: scale(1.15);
  }
}

@keyframes sosCardBlink {
  0% {
    border-color: rgba(239, 68, 68, 0.5);
    background: rgba(239, 68, 68, 0.1);
  }
  50% {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.25);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
  }
  100% {
    border-color: rgba(239, 68, 68, 0.5);
    background: rgba(239, 68, 68, 0.1);
  }
}

.operator-marker-sos {
  background: transparent !important;
  border: none !important;
  color: #ffffff !important;
  z-index: 99999 !important;
}

.operator-card-sos {
  border-color: #ef4444 !important;
  animation: sosCardBlink 1.4s infinite ease-in-out !important;
}

.sos-beacon-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 10px #ef4444;
  animation: sosRadarPulse 1s infinite;
  display: inline-block;
}

/* BANNER DE EMERGÊNCIA FLUTUANTE SOBRE O MAPA */
.sos-emergency-banner {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, rgba(185, 28, 28, 0.95), rgba(127, 29, 29, 0.95));
  border: 2px solid #ef4444;
  box-shadow: 0 8px 30px rgba(239, 68, 68, 0.6), 0 0 20px rgba(0, 0, 0, 0.8);
  border-radius: 10px;
  padding: 12px 20px;
  color: #fff;
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 16px;
  animation: sosRadarPulse 1.8s infinite ease-in-out;
  backdrop-filter: blur(8px);
}

.sos-emergency-banner .banner-title {
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.3px;
  color: #ffffff;
}

.sos-emergency-banner .banner-sub {
  font-size: 11.5px;
  color: #fecaca;
  margin-top: 2px;
}

.sos-emergency-banner .btn-sos-action {
  background: #ffffff;
  color: #b91c1c;
  font-weight: 800;
  border: none;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.sos-emergency-banner .btn-sos-action:hover {
  background: #fee2e2;
  transform: scale(1.04);
}

.sos-emergency-banner .btn-sos-resolve {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.sos-emergency-banner .btn-sos-resolve:hover {
  background: rgba(255, 255, 255, 0.3);
}
