@import url('../components/notifications.css');
@import url('../components/tooltips.css');

/* =========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
  /* Colors */
  --primary-color: #001f4c;
  --primary-hover: #1a4d8c;
  --secondary-color: #e30613;
  --accent-color: #e30613;
  --danger-color: #e30613;
  --success-color: #22c55e;

  --bg-body: #f1f5f9;
  --bg-panel: #ffffff;
  --bg-header: #ffffff;

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

  --border-color: #e2e8f0;

  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;

  /* UI */
  --border-radius-sm: 4px;
  --border-radius-md: 6px;
  --border-radius-lg: 8px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

  --header-height: 72px;
  --toolbar-height: 60px;
  --transition: all 0.2s ease;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-body);
  min-height: 100vh;
}

/* Layout fixo apenas para páginas com header/toolbar fixos (ex: coleta) */
body.coleta-page,
body.fixed-layout {
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* =========================================
   2. LAYOUT
   ========================================= */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.96) 100%);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
  z-index: 1001;
  backdrop-filter: saturate(180%) blur(8px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 18px;
}

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

.logo-3tentos {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 6px 12px rgba(15, 23, 42, 0.08);
}

.logo-3tentos:hover {
  transform: scale(1.05);
}

.logo-3tentos img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.header-titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-kicker {
  font-size: 11px;
  font-weight: 600;
  color: rgba(0, 31, 76, 0.7);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-title {
  font-family: 'Inter', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-color);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

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

.header-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0, 31, 76, 0.08);
  color: var(--primary-color);
  font-size: 12px;
  font-weight: 600;
}

.state-badge {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--primary-color);
  color: #ffffff;
  font-size: 11px;
  letter-spacing: 0.08em;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  transition: all 0.2s ease;
  cursor: pointer;
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.8);
  box-shadow: 0 6px 12px rgba(15, 23, 42, 0.08);
}

.user-profile:hover {
  background: #f8fafc;
}

.user-profile img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  background: #f1f5f9;
}

.user-profile .user-info {
  text-align: right;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.user-profile .user-name {
  font-weight: 600;
  font-size: 13px;
  color: #334155;
  line-height: 1.2;
}

.user-profile .user-role {
  font-size: 11px;
  color: #64748b;
  font-weight: 500;
  line-height: 1.2;
}

.btn-header {
  background: #ffffff;
  border: 1px solid rgba(0, 31, 76, 0.18);
  color: var(--primary-color);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
}

.btn-header:hover {
  background: rgba(0, 31, 76, 0.06);
  color: var(--primary-color);
  border-color: rgba(0, 31, 76, 0.28);
}

.btn-header.logout {
  color: #e30613;
  border-color: rgba(227, 6, 19, 0.22);
  background: rgba(227, 6, 19, 0.08);
}

.btn-header.logout:hover {
  background: rgba(227, 6, 19, 0.14);
  border-color: rgba(227, 6, 19, 0.32);
  color: #c00510;
}

/* Toolbar (Secondary) */
.toolbar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  height: var(--toolbar-height);
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 var(--spacing-lg);
  gap: var(--spacing-lg);
  box-shadow: var(--shadow-sm);
  z-index: 1000;
  flex-shrink: 0;
  overflow-x: auto;
}

#map {
  flex: 1;
  width: 100%;
  /* 64 + 60 = 124px */
  margin-top: calc(var(--header-height) + var(--toolbar-height));
  height: calc(100vh - (var(--header-height) + var(--toolbar-height)));
  position: relative;
  z-index: 1;
  background: #e2e8f0;
}

/* Panels position update */
.panel-info {
  top: calc(var(--header-height) + var(--toolbar-height) + 20px) !important;
  right: 20px;
  width: 360px;
  max-height: calc(100vh - 160px);
  display: none;
}

.info-message {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 16px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
}

.info-message-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.info-message-icon {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(15, 118, 110, 0.12);
  color: var(--primary-color);
  font-size: 18px;
}

.info-message-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.info-message-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.info-message-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.info-message-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.info-message-list {
  list-style: none;
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.info-message-list li {
  position: relative;
  padding-left: 20px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.info-message-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.info-message-footer {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.08);
  color: var(--primary-color);
  font-size: 12px;
  font-weight: 600;
}

.panel-filter {
  top: calc(var(--header-height) + var(--toolbar-height) + 20px) !important;
  left: 20px;
  width: 300px;
  display: none;
  border: 1px solid var(--border-color);
}

/* =========================================
   3. COMPONENTS
   ========================================= */
.toolbar-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-divider {
  width: 1px;
  height: 32px;
  background: var(--border-color);
  margin: 0 4px;
}

/* Inputs */
.input,
.select {
  height: 34px;
  /* Smaller inputs for toolbar */
  padding: 0 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
  color: #1e293b;
  background: white;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 200px;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.input:focus,
.select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
  outline: none;
}

.input::placeholder {
  color: #94a3b8;
}

.input-sm {
  min-width: 120px;
}

.input-coord {
  min-width: 80px;
  width: 80px;
  text-align: center;
}

/* Grouping inputs visually */
.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  background: white;
  padding: 3px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
  transition: all 0.2s;
}

.toolbar-group:focus-within {
  border-color: #cbd5e1;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  transform: translateY(-1px);
}

.toolbar-group .input,
.toolbar-group .select {
  border: none;
  box-shadow: none;
  background: transparent;
  height: 30px;
  padding: 0 8px;
}

.toolbar-group .input:focus,
.toolbar-group .select:focus {
  box-shadow: none;
}

/* Buttons */
.btn {
  height: 34px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  letter-spacing: 0.01em;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.btn:active {
  transform: translateY(0) scale(0.98);
}

.btn-icon {
  width: 34px;
  padding: 0;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(0, 31, 76, 0.2);
}

.btn-secondary {
  background: white;
  border: 1px solid #e2e8f0;
  color: var(--secondary-color);
}

.btn-secondary:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: var(--text-primary);
}

.btn-outline {
  background: transparent;
  border: 1px solid rgba(0, 31, 76, 0.18);
  color: var(--primary-color);
}

.btn-outline:hover {
  background: rgba(0, 31, 76, 0.06);
  color: var(--primary-color);
  border-color: rgba(0, 31, 76, 0.3);
}

/* Buttons inside groups need specific styling */
.toolbar-group .btn {
  height: 30px;
  border-radius: 5px;
  box-shadow: none;
}

.btn-danger {
  background: rgba(227, 6, 19, 0.08);
  color: #e30613;
  border: 1px solid rgba(227, 6, 19, 0.25);
}

.btn-danger:hover {
  background: rgba(227, 6, 19, 0.14);
  border-color: rgba(227, 6, 19, 0.35);
}

.btn-reset {
  margin-left: auto;
  background: white;
  border: 1px solid rgba(0, 31, 76, 0.18);
  color: var(--primary-color);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-reset:hover {
  background: rgba(0, 31, 76, 0.06);
  color: var(--primary-color);
  border-color: rgba(0, 31, 76, 0.3);
}

.btn-vinculos {
  margin-left: auto;
}

/* Panels */
.panel {
  position: absolute;
  background: var(--bg-panel);
  box-shadow: var(--shadow-lg);
  border-radius: var(--border-radius-lg);
  z-index: 1000;
  transition: var(--transition);
}

.panel-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-body {
  padding: 16px;
  overflow-y: auto;
  max-height: 400px;
}

.btn-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
}

.btn-close:hover {
  color: var(--danger-color);
}

/* =========================================
   4. LEAFLET CUSTOMIZATION
   ========================================= */
.leaflet-popup-content-wrapper {
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 0;
  overflow: hidden;
}

.leaflet-popup-content {
  margin: 0 !important;
  width: auto !important;
}

.leaflet-container {
  font-family: 'Inter', sans-serif !important;
}

/* Popup Styles */
.custom-popup-clean .leaflet-popup-content-wrapper {
  background: transparent;
  box-shadow: none;
}

.custom-popup-detail .leaflet-popup-content-wrapper {
  background: transparent;
  box-shadow: none;
  border-radius: 0;
}

.custom-popup-detail .leaflet-popup-tip {
  background: white;
}

/* Popup Custom */
.popup-custom {
  font-family: 'Inter', system-ui, sans-serif;
  min-width: 280px;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.popup-header {
  color: white;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.popup-content {
  padding: 16px;
}

.popup-info-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #f1f5f9;
}

.popup-info-row:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.popup-info-label {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
}

.popup-info-value {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 13px;
  text-align: right;
}

.id-row .popup-info-value {
  font-family: 'Monaco', monospace;
  font-size: 12px;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
}

.popup-button {
  width: 100%;
  border: none;
  padding: 10px;
  border-radius: 6px;
  color: white;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: opacity 0.2s;
  margin-top: 8px;
}

.popup-button:hover {
  opacity: 0.9;
}

/* =========================================
   5. LOADING OVERLAY
   ========================================= */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s ease;
}

.loading-card {
  background: white;
  padding: 40px;
  border-radius: 16px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  text-align: center;
  min-width: 340px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid #e2e8f0;
  border-top-color: var(--primary-color);
  border-radius: 50%;
  margin: 0 auto 20px;
  animation: spin 0.8s linear infinite;
}

.loading-text {
  font-size: 18px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.loading-progress {
  font-size: 13px;
  color: #64748b;
  font-weight: 500;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* =========================================
   6. UTILITIES
   ========================================= */
.hidden {
  display: none !important;
}

.fade-out {
  opacity: 0;
  pointer-events: none;
}

/* Custom Checkbox */
.custom-checkbox {
  position: relative;
  width: 18px;
  height: 18px;
}

.custom-checkbox input {
  opacity: 0;
  width: 0;
  height: 0;
}

.checkmark {
  position: absolute;
  top: 0;
  left: 0;
  height: 18px;
  width: 18px;
  background-color: white;
  border: 2px solid #cbd5e1;
  border-radius: 4px;
  transition: all 0.2s;
}

.custom-checkbox input:checked~.checkmark {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

.checkmark:after {
  content: "";
  position: absolute;
  display: none;
  left: 5px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.custom-checkbox input:checked~.checkmark:after {
  display: block;
}

/* Painel de Camadas */
.painel-camadas {
  background: white;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  width: 300px;
  overflow: hidden;
  transition: var(--transition);
  margin-bottom: 24px;
  margin-right: 12px;
}

/* Minimized State */
.painel-camadas.minimized {
  width: auto;
  min-width: 180px;
}

.painel-camadas.minimized #painel-body {
  display: none !important;
}

.painel-camadas.minimized #painel-header {
  border-bottom: none;
}

.painel-camadas.minimized .toggle-icon {
  transform: rotate(180deg);
}

#painel-header {
  padding: 16px;
  background: white;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#painel-header:hover {
  background: #f8fafc;
}

#painel-body {
  padding: 16px;
  background: #ffffff;
}

.layer-card {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 12px;
  margin-bottom: 8px;
  transition: var(--transition);
}

.layer-card:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-sm);
}

input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: #e2e8f0;
  border-radius: 2px;
  outline: none;
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: white;
  border: 2px solid var(--text-secondary);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  transition: all 0.2s;
}

input[type=range]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  border-color: var(--primary-color);
}

/* =========================================
   7. VINCULOS MANAGER MODAL
   ========================================= */
.vinculos-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 9999;
  /* Above everything */
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.vinculos-modal-overlay[style*="display: flex"] {
  opacity: 1;
}

.vinculos-modal {
  background: white;
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.vinculos-modal-active {
  transform: translateY(0);
}

.vinculos-modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
}

.vinculos-modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.vinculos-modal-title i {
  color: var(--primary-color);
}

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

.vinculos-modal-close:hover {
  color: var(--danger-color);
}

.vinculos-modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.vinculos-search-section {
  margin-bottom: 24px;
  background: #fff;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}

.vinculos-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.vinculos-input-group {
  display: flex;
  gap: 10px;
}

.vinculos-input-group input {
  flex: 1;
}

.vinculos-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.vinculos-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.vinculos-empty i {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* Items do Vinculo */
.vinculo-item {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.2s;
}

.vinculo-item:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.vinculo-item-header {
  padding: 12px 16px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.vinculo-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.vinculo-item-number {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  background: #e2e8f0;
  padding: 2px 6px;
  border-radius: 4px;
}

.vinculo-item-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #166534;
  background: #dcfce7;
  padding: 2px 8px;
  border-radius: 12px;
}

.btn-remover-vinculo {
  background: white;
  border: 1px solid #fee2e2;
  color: #ef4444;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-remover-vinculo:hover {
  background: #fee2e2;
  border-color: #ef4444;
}

.vinculo-item-body {
  padding: 16px;
}

.vinculo-main-info {
  margin-bottom: 16px;
}

.vinculo-cpf-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'Monaco', monospace;
}

.vinculo-nome-value {
  font-size: 14px;
  color: var(--text-secondary);
}

.vinculo-details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
}

.vinculo-detail-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.vinculo-detail-item i {
  color: var(--text-muted);
  font-size: 14px;
}

.vinculo-detail-content {
  display: flex;
  flex-direction: column;
}

.vinculo-detail-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.vinculo-detail-value {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* CAR Info Card */
.vinculos-car-info-card {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.vinculos-car-info-header {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.vinculos-car-icon {
  width: 40px;
  height: 40px;
  background: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-color);
  box-shadow: var(--shadow-sm);
  font-size: 18px;
}

.vinculos-car-id-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  font-family: 'Monaco', monospace;
}

.vinculos-car-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.vinculos-meta-badge {
  font-size: 11px;
  color: var(--text-secondary);
  background: white;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Loading Spinner */
.loading-spinner-small {
  width: 20px;
  height: 20px;
  border: 2px solid #e2e8f0;
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.vinculos-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 13px;
}

/* =========================================
   TOOLBAR MODERN - COLETA.HTML
   ========================================= */
#map.map-modern {
  margin-top: calc(var(--header-height) + var(--toolbar-height)) !important;
  height: calc(100vh - (var(--header-height) + var(--toolbar-height))) !important;
  z-index: 1;
}



/* =========================================
   TOOLBAR MODERN
   ========================================= */
.toolbar-modern {
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  height: var(--toolbar-height);
  background: linear-gradient(180deg, #0b111c 0%, #0f1726 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 0;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
  z-index: 1500;
  flex-shrink: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.toolbar-modern::-webkit-scrollbar {
  display: none;
}

.toolbar-modern .toolbar-section {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 0 10px;
  flex-shrink: 0;
}

.toolbar-modern .toolbar-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  color: rgba(42, 111, 219, 0.75);
  letter-spacing: 0.1em;
}

.toolbar-modern .toolbar-group {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  transition: all 0.2s ease;
  gap: 4px;
}

.toolbar-modern .toolbar-group:focus-within {
  background: rgba(42, 111, 219, 0.08);
  border-color: rgba(42, 111, 219, 0.4);
  box-shadow: 0 0 0 3px rgba(42, 111, 219, 0.12), 0 4px 12px rgba(0, 0, 0, 0.3);
  transform: translateY(-1px);
}

.toolbar-modern .input,
.toolbar-modern .select {
  border: none;
  background: transparent;
  box-shadow: none;
  height: 27px;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
  min-width: 130px;
}

.toolbar-modern .input::placeholder {
  color: rgba(100, 116, 139, 0.8);
  font-weight: 400;
}

.toolbar-modern .select option {
  background: #111c2d;
  color: rgba(255, 255, 255, 0.85);
}

.toolbar-modern .btn {
  height: 27px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 10px;
  transition: all 0.18s ease;
  border: 1px solid transparent;
}

.toolbar-modern .btn-primary {
  background: #2a6fdb;
  color: #fff;
  box-shadow: 0 2px 8px rgba(42, 111, 219, 0.35);
}

.toolbar-modern .btn-primary:hover {
  background: #3a83f5;
  box-shadow: 0 4px 14px rgba(42, 111, 219, 0.5);
  transform: translateY(-1px);
}

.toolbar-modern .btn-secondary,
.toolbar-modern .btn-outline {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(148, 163, 184, 0.9);
}

.toolbar-modern .btn-secondary:hover,
.toolbar-modern .btn-outline:hover {
  background: rgba(42, 111, 219, 0.1);
  border-color: rgba(42, 111, 219, 0.35);
  color: rgba(255, 255, 255, 0.9);
}

.toolbar-modern .btn-icon {
  width: 27px;
  padding: 0;
}

.toolbar-modern .btn-danger {
  background: rgba(229, 62, 62, 0.1);
  color: rgba(229, 62, 62, 0.85);
  border: 1px solid rgba(229, 62, 62, 0.25);
}

.toolbar-modern .btn-danger:hover {
  background: rgba(229, 62, 62, 0.18);
  border-color: rgba(229, 62, 62, 0.4);
  color: #e53e3e;
}

.toolbar-modern .toolbar-divider {
  width: 1px;
  height: 28px;
  background: rgba(255, 255, 255, 0.07);
  margin: 0;
  flex-shrink: 0;
}

.toolbar-modern .btn-vinculos {
  margin-left: auto;
  height: 32px;
  padding: 0 16px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.18), rgba(5, 150, 105, 0.12));
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-weight: 700;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.1);
  flex-shrink: 0;
}

.toolbar-modern .btn-vinculos:hover {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.28), rgba(5, 150, 105, 0.2));
  border-color: rgba(16, 185, 129, 0.5);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
  transform: translateY(-1px);
}

.toolbar-modern .btn-vinculos svg {
  stroke: currentColor;
}

.toolbar-modern .input-coord {
  width: 72px;
  min-width: 72px;
  text-align: center;
  padding: 0 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}

.panel-info.panel-modern,
.panel-filter.panel-modern {
  top: calc(var(--header-height) + var(--toolbar-height) + 16px) !important;
  right: 16px;
  z-index: 1100;
  max-height: calc(100vh - var(--header-height) - var(--toolbar-height) - 32px);
  background: rgba(17, 28, 45, 0.97);
  backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 14px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  animation: slideInPanel 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  overflow: hidden;
}

@keyframes slideInPanel {
  from {
    opacity: 0;
    transform: translateX(30px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.toolbar-modern .input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.toolbar-modern .input-wrapper svg.icon-internal {
  position: absolute;
  left: 8px;
  color: rgba(100, 116, 139, 0.7);
  pointer-events: none;
}

.toolbar-modern .input-wrapper .input {
  padding-left: 28px !important;
}

@media (max-width: 1400px) {
  .toolbar-modern {
    gap: 0;
    padding: 0 8px;
  }

  .toolbar-modern .toolbar-section {
    padding: 0 6px;
  }
}

/* =========================================
   HEADER DARK
   ========================================= */
.app-header {
  background: linear-gradient(180deg, rgba(8, 13, 21, 0.97) 0%, rgba(12, 20, 33, 0.95) 100%) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07) !important;
  box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.04), 0 8px 32px rgba(0, 0, 0, 0.55) !important;
}

.app-kicker {
  color: rgba(42, 111, 219, 0.85) !important;
}

.app-title {
  color: rgba(255, 255, 255, 0.95) !important;
}

.header-meta {
  background: rgba(42, 111, 219, 0.1) !important;
  border: 1px solid rgba(42, 111, 219, 0.2) !important;
  color: rgba(148, 163, 184, 0.9) !important;
}

.state-badge {
  background: #2a6fdb !important;
  color: #fff !important;
}

.user-profile {
  background: rgba(255, 255, 255, 0.04) !important;
  border: 1px solid rgba(255, 255, 255, 0.09) !important;
}

.user-profile:hover {
  background: rgba(255, 255, 255, 0.07) !important;
}

.user-profile .user-name {
  color: rgba(255, 255, 255, 0.92) !important;
}

.user-profile .user-role {
  color: rgba(100, 116, 139, 0.8) !important;
}

.user-profile img {
  border-color: rgba(42, 111, 219, 0.4) !important;
}

.btn-header {
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  color: rgba(148, 163, 184, 0.85) !important;
}

.btn-header.logout {
  background: rgba(229, 62, 62, 0.08) !important;
  border-color: rgba(229, 62, 62, 0.2) !important;
  color: rgba(229, 62, 62, 0.8) !important;
}

.btn-header.logout:hover {
  background: rgba(229, 62, 62, 0.15) !important;
  color: #e53e3e !important;
}

/* =========================================
   MAP + PANELS POSITION (dark)
   ========================================= */
#map.map-modern {
  margin-top: calc(var(--header-height) + var(--toolbar-height)) !important;
  height: calc(100vh - var(--header-height) - var(--toolbar-height)) !important;
}

/* Painel de camadas dark */
#painel-header {
  background: rgba(17, 28, 45, 0.97) !important;
  border-bottom-color: rgba(255, 255, 255, 0.07) !important;
  color: rgba(255, 255, 255, 0.9) !important;
}

#painel-header:hover {
  background: rgba(22, 36, 58, 0.97) !important;
}

#painel-body {
  background: rgba(12, 20, 33, 0.97) !important;
  color: rgba(255, 255, 255, 0.85) !important;
}

.layer-card {
  background: rgba(22, 32, 50, 0.95) !important;
  border-color: rgba(255, 255, 255, 0.07) !important;
  color: rgba(255, 255, 255, 0.8) !important;
}

.layer-card:hover {
  border-color: rgba(42, 111, 219, 0.35) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
}

.painel-camadas {
  background: rgba(17, 28, 45, 0.97) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.65) !important;
}

/* Popup dark */
.leaflet-popup-content-wrapper {
  background: rgba(17, 28, 45, 0.97) !important;
  border: 1px solid rgba(255, 255, 255, 0.09) !important;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7) !important;
}

.leaflet-popup-tip {
  background: rgba(17, 28, 45, 0.97) !important;
}

.popup-custom {
  background: rgba(17, 28, 45, 0.97) !important;
  border: 1px solid rgba(255, 255, 255, 0.09) !important;
  font-family: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif !important;
}

.popup-header {
  background: rgba(42, 111, 219, 0.15) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07) !important;
  color: rgba(255, 255, 255, 0.92) !important;
}

.popup-info-label {
  color: rgba(100, 116, 139, 0.8) !important;
}

.popup-info-value {
  color: rgba(255, 255, 255, 0.88) !important;
}

.id-row .popup-info-value {
  background: rgba(42, 111, 219, 0.1) !important;
  border: 1px solid rgba(42, 111, 219, 0.2) !important;
  color: #5d9cf5 !important;
  font-family: 'JetBrains Mono', monospace !important;
  font-size: 10px !important;
}

.popup-button {
  background: #2a6fdb !important;
  border-radius: 7px !important;
}

/* Loading dark */
.loading-overlay {
  background: rgba(8, 13, 21, 0.92) !important;
}

.loading-card {
  background: rgba(17, 28, 45, 0.97) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  box-shadow: 0 32px 60px rgba(0, 0, 0, 0.8) !important;
}

.loading-text {
  color: rgba(255, 255, 255, 0.92) !important;
}

.loading-progress {
  color: rgba(100, 116, 139, 0.85) !important;
}

.loading-spinner {
  border-color: rgba(255, 255, 255, 0.08) !important;
  border-top-color: #2a6fdb !important;
}

/* Panel filter left */
.panel-filter.panel-modern {
  right: auto !important;
  left: 16px !important;
}

.panel-header {
  background: rgba(42, 111, 219, 0.08) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07) !important;
  color: rgba(255, 255, 255, 0.9) !important;
}

.panel-body {
  background: transparent !important;
  color: rgba(255, 255, 255, 0.8) !important;
}

/* Info message dark */
.info-message {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.info-message-icon {
  background: rgba(42, 111, 219, 0.15) !important;
  border: 1px solid rgba(42, 111, 219, 0.25) !important;
  color: #5d9cf5 !important;
}

.info-message-kicker {
  color: rgba(100, 116, 139, 0.75) !important;
}

.info-message-title {
  color: rgba(255, 255, 255, 0.92) !important;
}

.info-message-label {
  color: rgba(100, 116, 139, 0.7) !important;
}

.info-message-list li {
  color: rgba(148, 163, 184, 0.85) !important;
}

.info-message-footer {
  background: rgba(42, 111, 219, 0.1) !important;
  color: #5d9cf5 !important;
  border: 1px solid rgba(42, 111, 219, 0.2) !important;
}