/* ==========================================================================
   MapaDestinos - Modern Stylesheet
   Designed for Galicia RPT Public Job Destinations
   ========================================================================== */

:root {
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #e0f2fe;
  --primary-subtle: #f0f9ff;
  --accent: #0ea5e9;
  --accent-warm: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;

  /* Neutrals */
  --bg-app: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --border: #e2e8f0;
  --border-focus: #38bdf8;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 30px rgba(15, 23, 42, 0.12);
  --shadow-xl: 0 20px 45px rgba(15, 23, 42, 0.18);

  /* Subgroups colors */
  --badge-a1: #8b5cf6;
  --badge-a2: #3b82f6;
  --badge-b: #06b6d4;
  --badge-c1: #10b981;
  --badge-c2: #f59e0b;
  --badge-ap: #ec4899;

  --sidebar-w: 430px;
  --header-h: 70px;
  --filterbar-h: 56px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg-app: #090d16;
  --surface: #111827;
  --surface-alt: #1f2937;
  --border: #283548;
  --border-focus: #38bdf8;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  --primary-light: #172554;
  --primary-subtle: #0f172a;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.5);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
}

/* App Container Layout */
#app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  position: relative;
}

/* Top Header */
.app-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 1000;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

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

.brand-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: white;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

.brand-info h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-main);
  line-height: 1.1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 7px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

.brand-info p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Province Stats Chips in Header */
.header-provinces {
  display: flex;
  align-items: center;
  gap: 8px;
}

.prov-chip {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
  user-select: none;
}

.prov-chip .count {
  background: var(--primary);
  color: white;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 700;
}

.prov-chip:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.prov-chip.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 3px 8px rgba(2, 132, 199, 0.35);
}

.prov-chip.active .count {
  background: white;
  color: var(--primary);
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-header {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-main);
  transition: var(--transition);
}

.btn-header:hover {
  background: var(--surface-alt);
  border-color: var(--text-muted);
}

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

.btn-listas:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.3);
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-main);
  cursor: pointer;
  font-size: 16px;
  transition: var(--transition);
}

.btn-icon:hover {
  background: var(--surface-alt);
}

/* Filter Bar */
.filter-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  z-index: 999;
  flex-shrink: 0;
}

.search-input-wrap {
  position: relative;
  flex: 1 1 240px;
  min-width: 200px;
}

.search-input-wrap input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-main);
  font-size: 13px;
  outline: none;
  transition: var(--transition);
}

.search-input-wrap input:focus {
  border-color: var(--border-focus);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.search-input-wrap .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}

.search-input-wrap .btn-clear-search {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  display: none;
}

.filter-select {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-main);
  font-size: 13px;
  outline: none;
  cursor: pointer;
  min-width: 140px;
  transition: var(--transition);
}

.filter-select:focus {
  border-color: var(--border-focus);
  background: var(--surface);
}

.btn-filter-action {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.btn-filter-action:hover {
  background: var(--surface-alt);
}

.filter-counter-badge {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.filter-counter-badge strong {
  color: var(--primary);
  font-size: 14px;
}

/* Main Workspace: Map + Sidebar */
.main-workspace {
  flex: 1 1 auto;
  display: flex;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

/* Map Container */
#mapContainer {
  flex: 1 1 auto;
  height: 100%;
  width: 100%;
  background: #cbd5e1;
  position: relative;
  z-index: 10;
}

/* Sidebar Drawer */
.sidebar-panel {
  width: var(--sidebar-w);
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  z-index: 500;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  flex-shrink: 0;
}

.sidebar-panel.collapsed {
  transform: translateX(100%);
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
}

.sidebar-toggle-tab {
  position: absolute;
  left: -36px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 50px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 10px 0 0 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: -4px 2px 10px rgba(0, 0, 0, 0.12);
  color: var(--text-main);
  font-size: 16px;
  transition: var(--transition);
  z-index: 600;
}

.sidebar-toggle-tab:hover {
  background: var(--primary-light);
  color: var(--primary);
}

/* Leaflet Zoom Control: situado en la esquina superior derecha sin interferencias */
.leaflet-top.leaflet-right {
  top: 16px;
  right: 16px;
}

.leaflet-control-zoom {
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  overflow: hidden !important;
  box-shadow: var(--shadow-md) !important;
  margin: 0 !important;
}

.leaflet-control-zoom a {
  background-color: var(--surface) !important;
  color: var(--text-main) !important;
  border-bottom: 1px solid var(--border) !important;
  width: 34px !important;
  height: 34px !important;
  line-height: 34px !important;
  font-size: 16px !important;
  font-weight: 700 !important;
  transition: var(--transition) !important;
}

.leaflet-control-zoom a:last-child {
  border-bottom: none !important;
}

.leaflet-control-zoom a:hover {
  background-color: var(--surface-alt) !important;
  color: var(--primary) !important;
}

.sidebar-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
  flex-shrink: 0;
}

.sidebar-title-area {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-counter-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-alt);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.sidebar-title-area h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.sidebar-title-area p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.sidebar-center-filter {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.center-filter-label {
  font-size: 11px;
  font-weight: 600;
  color: #0369a1;
  background: #e0f2fe;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid #bae6fd;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

[data-theme="dark"] .center-filter-label {
  color: #7dd3fc;
  background: rgba(14, 165, 233, 0.2);
  border-color: #0369a1;
}

.btn-clear-center-filter {
  font-size: 11px;
  font-weight: 600;
  color: #b91c1c;
  background: #fee2e2;
  border: 1px solid #fecaca;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-clear-center-filter:hover {
  background: #fecaca;
}

[data-theme="dark"] .btn-clear-center-filter {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.2);
  border-color: #991b1b;
}

.sidebar-sort-tag {
  color: var(--primary);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

[data-theme="dark"] .sidebar-sort-tag {
  color: #38bdf8;
}

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

/* Destination Card in Sidebar */
.dest-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  transition: var(--transition);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.dest-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.dest-card.highlighted {
  border-color: var(--primary);
  background: var(--primary-subtle);
  box-shadow: 0 0 0 2px var(--primary);
}

.dest-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.dest-code {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.dest-code:hover {
  background: #bae6fd;
}

.dest-num {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-light);
}

.dest-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
}

.dest-center {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: flex-start;
  gap: 6px;
  line-height: 1.3;
}

.dest-location-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #0369a1;
}

.dest-location-search {
  margin-left: 4px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--primary);
  font-size: 10px;
  font-weight: 600;
  text-decoration: none;
}

.dest-location-search:hover {
  background: var(--primary-light);
}

.dest-card-distance {
  display: flex;
  align-items: center;
  margin-top: 2px;
}

.dest-dist-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(2, 132, 199, 0.08);
  border: 1px solid rgba(2, 132, 199, 0.2);
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  transition: var(--transition);
}

.dest-dist-pill.no-loc {
  background: var(--surface-alt);
  border-color: var(--border);
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 500;
}

.dest-dist-pill.no-loc:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.dest-dist-pill.is-road {
  background: rgba(2, 132, 199, 0.12);
  border-color: rgba(2, 132, 199, 0.35);
  color: var(--primary);
}

[data-theme="dark"] .dest-dist-pill {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.25);
  color: #38bdf8;
}

[data-theme="dark"] .dest-dist-pill.no-loc {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}

.dest-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.tag-subgrupo {
  color: white;
}
.tag-subgrupo.A1 { background: var(--badge-a1); }
.tag-subgrupo.A2 { background: var(--badge-a2); }
.tag-subgrupo.B  { background: var(--badge-b); }
.tag-subgrupo.C1 { background: var(--badge-c1); }
.tag-subgrupo.C2 { background: var(--badge-c2); }
.tag-subgrupo.AP { background: var(--badge-ap); }

.tag-nivel {
  background: var(--surface-alt);
  color: var(--text-main);
  border: 1px solid var(--border);
}

.tag-cons {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}

.dest-notes {
  font-size: 11px;
  color: #b45309;
  background: #fef3c7;
  padding: 4px 8px;
  border-radius: 6px;
  border-left: 3px solid #f59e0b;
  margin-top: 2px;
}

/* Floating Map Buttons */
.map-floating-controls {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.map-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.map-btn:hover {
  background: var(--surface-alt);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.map-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary-hover);
  box-shadow: 0 2px 8px rgba(30, 92, 153, 0.35);
}

.map-btn.active:hover {
  background: var(--primary-hover);
  color: #fff;
  border-color: var(--primary-hover);
}

[data-theme="dark"] .map-btn.active {
  background: #0284c7;
  color: #fff;
  border-color: #38bdf8;
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.35);
}

[data-theme="dark"] .map-btn.active:hover {
  background: #0369a1;
  color: #fff;
}

/* Basemap selector dropdown */
.map-layer-selector {
  position: absolute;
  bottom: 24px;
  left: 16px;
  z-index: 400;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 8px;
  box-shadow: var(--shadow-lg);
  display: flex;
  gap: 6px;
}

.layer-btn {
  padding: 6px 10px;
  border-radius: 6px;
  border: none;
  background: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.layer-btn:hover {
  color: var(--text-main);
  background: var(--surface-alt);
}

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

/* Custom Marker Pins */
.custom-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.custom-pin:hover {
  transform: scale(1.15) translateY(-3px);
  z-index: 9999 !important;
}

.pin-bubble {
  background: #0284c7;
  color: white;
  border: 2px solid #ffffff;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
  transition: var(--transition);
}

.pin-bubble.large {
  width: 40px;
  height: 40px;
  font-size: 14px;
  background: #0369a1;
  border-width: 3px;
}

.pin-bubble.huge {
  width: 48px;
  height: 48px;
  font-size: 15px;
  background: #0f172a;
  border-width: 3px;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.45);
}

.pin-tail {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 7px solid #0284c7;
}

.pin-bubble.huge + .pin-tail {
  border-top-color: #0f172a;
}

/* Limited Hours (Media xornada) Pin Variations */
.pin-bubble.pin-limited-all {
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  border-color: #ffedd5;
  box-shadow: 0 3px 12px rgba(234, 88, 12, 0.45);
}

.pin-bubble.pin-limited-all.large {
  background: linear-gradient(135deg, #ea580c 0%, #c2410c 100%);
}

.pin-bubble.pin-limited-all.huge {
  background: linear-gradient(135deg, #c2410c 0%, #9a3412 100%);
  box-shadow: 0 4px 16px rgba(234, 88, 12, 0.55);
}

.custom-pin.pin-limited-all .pin-tail {
  border-top-color: #ea580c;
}

.custom-pin.pin-limited-all .pin-bubble.huge + .pin-tail {
  border-top-color: #9a3412;
}

/* Mixed destinations (both full time and limited hours) */
.pin-bubble.pin-limited-mixed {
  background: linear-gradient(135deg, #0284c7 48%, #ea580c 52%);
  border-color: #ffffff;
  box-shadow: 0 3px 12px rgba(234, 88, 12, 0.4);
}

.custom-pin.pin-limited-mixed .pin-tail {
  border-top-color: #ea580c;
}

/* Mini badge indicator on pin */
.pin-mini-badge {
  position: absolute;
  top: -6px;
  right: -7px;
  font-size: 11px;
  line-height: 1;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(234, 88, 12, 0.3);
  padding: 1px;
  z-index: 2;
}

[data-theme="dark"] .pin-mini-badge {
  background: #1e293b;
  border-color: rgba(249, 115, 22, 0.4);
}

/* Floating Map Legend */
.map-legend {
  position: absolute;
  bottom: 74px;
  left: 16px;
  z-index: 400;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  pointer-events: auto;
  user-select: none;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}

.legend-dot.dot-full {
  background: #0284c7;
}

.legend-dot.dot-limited {
  background: #ea580c;
}

.legend-dot.dot-mixed {
  background: linear-gradient(135deg, #0284c7 48%, #ea580c 52%);
}

/* Popup Badges */
.badge-tag-limited {
  display: inline-block;
  background: #ffedd5;
  color: #c2410c;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 4px;
  vertical-align: middle;
  border: 1px solid #fed7aa;
}

[data-theme="dark"] .badge-tag-limited {
  background: rgba(234, 88, 12, 0.2);
  color: #fdba74;
  border-color: rgba(234, 88, 12, 0.4);
}

.popup-badge-hours {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
}

.popup-badge-hours.full-limited {
  background: #ffedd5;
  color: #c2410c;
  border: 1px solid #fed7aa;
}

.popup-badge-hours.mixed-limited {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

[data-theme="dark"] .popup-badge-hours.full-limited {
  background: rgba(234, 88, 12, 0.2);
  color: #fdba74;
  border-color: rgba(234, 88, 12, 0.4);
}

[data-theme="dark"] .popup-badge-hours.mixed-limited {
  background: rgba(245, 158, 11, 0.2);
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.4);
}

.puesto-obs.obs-limited-alert {
  background: #fff7ed;
  color: #c2410c;
  border-color: #fed7aa;
  font-weight: 600;
}

[data-theme="dark"] .puesto-obs.obs-limited-alert {
  background: rgba(234, 88, 12, 0.15);
  color: #fdba74;
  border-color: rgba(234, 88, 12, 0.3);
}

/* Leaflet Cluster overrides */
.marker-cluster-small {
  background-color: rgba(56, 189, 248, 0.4) !important;
}
.marker-cluster-small div {
  background-color: rgba(2, 132, 199, 0.9) !important;
  color: white !important;
  font-family: 'Outfit', sans-serif !important;
  font-weight: 700 !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2) !important;
}

.marker-cluster-medium {
  background-color: rgba(245, 158, 11, 0.4) !important;
}
.marker-cluster-medium div {
  background-color: rgba(217, 119, 6, 0.9) !important;
  color: white !important;
  font-family: 'Outfit', sans-serif !important;
  font-weight: 700 !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2) !important;
}

.marker-cluster-large {
  background-color: rgba(239, 68, 68, 0.4) !important;
}
.marker-cluster-large div {
  background-color: rgba(220, 38, 38, 0.9) !important;
  color: white !important;
  font-family: 'Outfit', sans-serif !important;
  font-weight: 700 !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2) !important;
}

/* Leaflet Popups */
.leaflet-popup {
  z-index: 4000 !important;
}

.leaflet-popup-content-wrapper {
  border-radius: 12px !important;
  padding: 0 !important;
  overflow: hidden !important;
  box-shadow: var(--shadow-xl) !important;
  background: var(--surface) !important;
  color: var(--text-main) !important;
}

.leaflet-popup-content {
  margin: 0 !important;
  width: 300px !important;
  max-width: calc(100vw - 40px) !important;
}

.popup-container {
  padding: 16px;
  max-height: 420px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

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

.popup-title {
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.popup-prov-badge {
  font-size: 11px;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 10px;
}

.popup-center-count {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.popup-center-count strong {
  color: var(--primary);
}

.popup-center-group + .popup-center-group {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 10px;
}

.location-precision {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
}

.popup-center-search {
  display: inline-block;
  margin-top: 5px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
}

.popup-center-search:hover {
  background: var(--primary-light);
}

.popup-puestos-list {
  max-height: 160px;
  overflow-y: auto;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.popup-puesto-item {
  background: var(--surface-alt);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  transition: background-color 0.15s ease;
}

.popup-puesto-item:hover {
  background: #e2e8f0;
}

[data-theme="dark"] .popup-puesto-item:hover {
  background: #334155;
}

.popup-puesto-prio {
  font-weight: 700;
  color: #b45309;
}

[data-theme="dark"] .popup-puesto-prio {
  color: #fbbf24;
}

.popup-puesto-item .puesto-den {
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.3;
}

.popup-puesto-item .puesto-obs {
  margin-top: 4px;
  font-size: 11px;
  color: #b45309;
  background: #fef3c7;
  padding: 3px 6px;
  border-radius: 4px;
  border-left: 2px solid #f59e0b;
  line-height: 1.35;
  word-break: break-word;
}

[data-theme="dark"] .popup-puesto-item .puesto-obs {
  color: #fde68a;
  background: rgba(180, 83, 9, 0.25);
  border-left-color: #f59e0b;
}

.popup-btn-view-all {
  display: block;
  width: 100%;
  padding: 8px 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  text-decoration: none;
}

.popup-btn-view-all:hover {
  background: var(--primary-hover);
}

/* Popup Toolbar & Priority Button Styling */
.popup-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: 6px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.popup-toolbar .btn-toolbar-action {
  font-size: 11px;
  padding: 4px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.popup-toolbar .btn-toolbar-action:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

[data-theme="dark"] .popup-toolbar .btn-toolbar-action {
  background: #1e293b;
  border-color: #334155;
  color: #f1f5f9;
}

[data-theme="dark"] .popup-toolbar .btn-toolbar-action:hover {
  background: #0f172a;
  border-color: var(--primary);
  color: #38bdf8;
}

.popup-puesto-item .btn-prio-top {
  font-size: 10px;
  height: 22px;
  padding: 1px 6px;
  border-radius: 5px;
  flex-shrink: 0;
}

/* Modal for Single Destination Details */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

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

.modal-card {
  background: var(--surface);
  border-radius: 16px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border);
  animation: modalEnter 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

.modal-header h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
}

.modal-close:hover {
  color: var(--text-main);
  background: var(--surface-alt);
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.modal-val {
  font-size: 14px;
  color: var(--text-main);
  font-weight: 500;
}

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  color: white;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-xl);
  z-index: 10000;
  opacity: 0;
  transform: translateY(20px);
  transition: var(--transition);
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .header-provinces {
    display: none;
  }
  .sidebar-panel {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    max-width: 380px;
    box-shadow: -5px 0 20px rgba(0,0,0,0.15);
  }
}

@media (max-width: 600px) {
  .app-header {
    padding: 0 12px;
  }
  .filter-bar {
    padding: 8px 12px;
    gap: 8px;
  }
  .filter-select {
    min-width: 100px;
    flex: 1 1 45%;
  }
  .brand-info p {
    display: none;
  }
}

/* User Location Draggable Marker */
.user-location-marker-container {
  background: transparent;
  border: none;
}

.user-location-marker {
  position: relative;
  width: 26px;
  height: 26px;
  cursor: grab;
  user-select: none;
}

.user-location-marker:active {
  cursor: grabbing;
}

.user-location-pulse {
  position: absolute;
  top: -9px;
  left: -9px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.35);
  animation: user-loc-pulse 2s infinite cubic-bezier(0.25, 0.46, 0.45, 0.94);
  pointer-events: none;
}

.user-location-dot {
  position: absolute;
  top: 0;
  left: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #2563eb;
  border: 3px solid #ffffff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease;
}

.user-location-marker:hover .user-location-dot {
  transform: scale(1.15);
  background: #1d4ed8;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.5);
}

.user-location-inner {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffffff;
}

@keyframes user-loc-pulse {
  0% {
    transform: scale(0.4);
    opacity: 0.9;
  }
  70% {
    transform: scale(1.6);
    opacity: 0;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

/* Custom Data Banner (Active Local Import) */
.custom-data-banner {
  background: linear-gradient(90deg, #eff6ff 0%, #dbeafe 100%);
  border-bottom: 1px solid #bfdbfe;
  padding: 8px 16px;
  font-size: 13px;
  color: #1e40af;
  z-index: 1001;
  position: relative;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

[data-theme="dark"] .custom-data-banner {
  background: linear-gradient(90deg, #1e293b 0%, #0f172a 100%);
  border-bottom: 1px solid #334155;
  color: #93c5fd;
}

.custom-banner-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.custom-banner-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.custom-banner-btns {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.custom-banner-btn {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.custom-banner-btn.btn-manage {
  background: #ffffff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}
.custom-banner-btn.btn-manage:hover {
  background: #f8fafc;
}

.custom-banner-btn.btn-reset {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}
.custom-banner-btn.btn-reset:hover {
  background: #fecaca;
}

/* ==========================================================================
   Road Distance & Route Styles
   ========================================================================== */

/* Floating Route Widget on Map */
.route-floating-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 220px;
  max-width: 280px;
  cursor: pointer;
  transition: var(--transition);
  animation: slideInDown 0.25s ease-out;
}

.route-floating-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-xl);
}

.route-floating-card.hidden {
  display: none !important;
}

.route-card-body {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.route-card-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.route-card-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.route-card-metrics {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.route-card-metrics strong {
  font-size: 14px;
  color: var(--primary);
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
}

.route-card-metrics span {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.route-card-dest {
  font-size: 11px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 170px;
}

.btn-clear-route {
  background: none;
  border: none;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: var(--transition);
}

.btn-clear-route:hover {
  background: var(--surface-alt);
  color: var(--danger);
}

/* Modal Road Distance Box */
.route-calc-box {
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 14px 16px;
  background: var(--surface-alt);
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
  transition: var(--transition);
}

.route-calc-box.no-location {
  background: var(--surface-alt);
  border-left: 4px solid var(--accent-warm);
}

.route-calc-box.loading {
  background: var(--surface-alt);
  border-left: 4px solid var(--primary);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.route-calc-box.success {
  background: rgba(2, 132, 199, 0.05);
  border: 1px solid rgba(2, 132, 199, 0.25);
  border-left: 4px solid var(--primary);
}

.route-calc-box.warning {
  background: #fffbeb;
  border: 1px solid #fef3c7;
  border-left: 4px solid #f59e0b;
}

[data-theme="dark"] .route-calc-box.warning {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
}

.route-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.route-stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.route-stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.route-stat-val {
  font-size: 18px;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
}

.route-stat-val.text-primary {
  color: var(--primary);
}

.route-stat-val.text-accent {
  color: #0284c7;
}

[data-theme="dark"] .route-stat-val.text-primary,
[data-theme="dark"] .route-stat-val.text-accent {
  color: #38bdf8;
}

.route-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.route-precision-badge {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.route-precision-badge.precise {
  color: var(--success);
}

.btn-gmaps-dir {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--primary);
  color: #ffffff !important;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  text-decoration: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: var(--transition);
}

.btn-gmaps-dir:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-locate-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--primary);
  color: #ffffff;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-locate-inline:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.route-calc-text {
  display: flex;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Route Polyline Tooltip */
.route-line-tooltip {
  background: var(--surface) !important;
  color: var(--text-main) !important;
  border: 1px solid var(--border) !important;
  box-shadow: var(--shadow-md) !important;
  font-family: 'Outfit', sans-serif !important;
  font-weight: 700 !important;
  font-size: 12px !important;
  border-radius: 6px !important;
  padding: 4px 8px !important;
}

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

/* Selected Destination Badge Marker on Map */
.map-route-dest-badge-container {
  background: none;
  border: none;
  pointer-events: none !important;
}

.map-route-dest-badge {
  background: var(--surface);
  border: 2px solid var(--primary);
  border-radius: 20px;
  padding: 4px 10px;
  font-family: 'Outfit', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  position: relative;
  transform: translateX(-50%);
  animation: popBadge 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none !important;
}

.map-route-dest-badge::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid var(--primary);
}

.map-route-dest-badge strong {
  color: var(--primary);
}

.map-route-dest-badge .badge-time {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

[data-theme="dark"] .map-route-dest-badge {
  background: #0f172a;
  border-color: #38bdf8;
  color: #f8fafc;
}

[data-theme="dark"] .map-route-dest-badge strong {
  color: #38bdf8;
}

[data-theme="dark"] .map-route-dest-badge::after {
  border-top-color: #38bdf8;
}

@keyframes popBadge {
  0% { transform: translateX(-50%) scale(0.6); opacity: 0; }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* Route Banner in Map Popup */
.popup-route-banner {
  background: rgba(2, 132, 199, 0.08);
  border: 1px solid rgba(2, 132, 199, 0.2);
  border-radius: 6px;
  padding: 6px 10px;
  margin: 6px 0 10px 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.popup-route-banner strong {
  font-weight: 700;
  color: var(--primary);
}

[data-theme="dark"] .popup-route-banner {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.25);
  color: #38bdf8;
}

[data-theme="dark"] .popup-route-banner strong {
  color: #38bdf8;
}

/* Sidebar Toolbar & Sort Tabs */
.sidebar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 2px;
}

.sort-tabs {
  display: inline-flex;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}

.sort-tab-btn {
  border: none;
  background: transparent;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sort-tab-btn:hover {
  color: var(--text-main);
  background: rgba(0, 0, 0, 0.04);
}

.sort-tab-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .sort-tab-btn.active {
  background: #1e293b;
  color: #38bdf8;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.sidebar-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.btn-toolbar-action {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-toolbar-action:hover {
  background: var(--surface-alt);
  color: var(--primary);
  border-color: var(--primary-light);
}

/* Priority Card Controls */
.dest-priority-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 5px 8px;
  margin-top: 2px;
  transition: all 0.15s ease;
}

[data-theme="dark"] .dest-priority-badge {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.25);
}

.prio-tag-label {
  font-size: 11px;
  font-weight: 700;
  color: #b45309;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

[data-theme="dark"] .prio-tag-label {
  color: #fbbf24;
}

.prio-controls-right {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.prio-stepper-box {
  display: inline-flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.btn-prio-step {
  border: none;
  background: transparent;
  width: 22px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 9px;
  transition: all 0.15s ease;
  padding: 0;
}

.btn-prio-step:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.btn-prio-step:active {
  transform: scale(0.92);
}

.prio-num-input {
  width: 44px;
  height: 24px;
  border: none;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  background: transparent;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700;
  font-size: 12px;
  color: var(--text-main);
  padding: 0 2px;
  -moz-appearance: textfield;
}

.prio-num-input::-webkit-outer-spin-button,
.prio-num-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.prio-num-input:focus {
  outline: 2px solid #f59e0b;
  background: var(--surface);
  border-radius: 2px;
  z-index: 2;
}

.btn-prio-top {
  border: 1px solid #fde68a;
  background: var(--surface);
  color: #b45309;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  height: 24px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.btn-prio-top:hover {
  background: #fde68a;
  color: #78350f;
}

[data-theme="dark"] .btn-prio-top {
  background: #1e293b;
  border-color: rgba(245, 158, 11, 0.3);
  color: #fbbf24;
}

[data-theme="dark"] .btn-prio-top:hover {
  background: rgba(245, 158, 11, 0.25);
  color: #fef3c7;
}

/* Highlight animation for card moved via btn-prio-top */
.dest-card.card-highlight-moved {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(30, 92, 153, 0.28), var(--shadow-lg) !important;
  animation: cardMovedFlash 2.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

[data-theme="dark"] .dest-card.card-highlight-moved {
  border-color: #38bdf8 !important;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.35), var(--shadow-lg) !important;
}

@keyframes cardMovedFlash {
  0% {
    transform: scale(1.02);
    background: rgba(30, 92, 153, 0.1);
  }
  30% {
    transform: scale(1.01);
  }
  100% {
    transform: scale(1);
  }
}

.dest-card.card-highlight-moved .btn-prio-lock {
  transform: scale(1.2);
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 2px rgba(30, 92, 153, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
}

.dest-priority-badge.is-locked {
  background: #fef3c7;
  border-color: #f59e0b;
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.4);
}

[data-theme="dark"] .dest-priority-badge.is-locked {
  background: rgba(245, 158, 11, 0.2);
  border-color: #f59e0b;
}

.btn-prio-lock {
  border: 1px solid #cbd5e1;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  height: 24px;
  width: 24px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-prio-lock:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  transform: scale(1.06);
}

.btn-prio-lock.locked {
  background: #fbbf24;
  border-color: #d97706;
  color: #78350f;
  box-shadow: 0 1px 3px rgba(217, 119, 6, 0.25);
}

.btn-prio-lock.large {
  width: auto;
  height: 32px;
  padding: 0 10px;
  gap: 5px;
  font-size: 13px;
  font-weight: 700;
}

/* Modal Priority Section */
.modal-priority-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 12px;
}

[data-theme="dark"] .modal-priority-box {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.25);
}

.modal-priority-interactive {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.prio-stepper-box.large {
  border-radius: 8px;
}

.prio-stepper-box.large .btn-prio-step {
  width: 32px;
  height: 34px;
  font-size: 12px;
}

.prio-stepper-box.large .prio-num-input {
  width: 60px;
  height: 34px;
  font-size: 15px;
}

.btn-prio-top.large {
  height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.prio-help-hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* ==========================================================================
   AI Assistant Styles (Hybrid AI Agent)
   ========================================================================== */

.map-btn-ai {
  background: linear-gradient(135deg, #eff6ff 0%, #ede9fe 100%);
  border: 1px solid #c7d2fe;
  color: #4338ca;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.18);
}

.map-btn-ai:hover {
  background: linear-gradient(135deg, #e0e7ff 0%, #ddd6fe 100%);
  border-color: #818cf8;
  color: #3730a3;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

[data-theme="dark"] .map-btn-ai {
  background: linear-gradient(135deg, #1e1b4b 0%, #2e1065 100%);
  border-color: #4f46e5;
  color: #c7d2fe;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .map-btn-ai:hover {
  background: linear-gradient(135deg, #312e81 0%, #3b0764 100%);
  border-color: #818cf8;
  color: #e0e7ff;
}

/* Floating AI Chat Panel */
.ai-chat-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 420px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 16px 40px -8px rgba(15, 23, 42, 0.28), 0 0 0 1px rgba(99, 102, 241, 0.15);
  display: flex;
  flex-direction: column;
  z-index: 2500;
  overflow: hidden;
  backdrop-filter: blur(12px);
  animation: aiPanelEnter 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-chat-panel.hidden {
  display: none !important;
}

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

/* Chat Header (Draggable) */
.ai-chat-header {
  padding: 10px 14px;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.ai-chat-header:active {
  cursor: grabbing;
}

.ai-chat-panel.is-dragging {
  user-select: none;
  box-shadow: 0 24px 50px -4px rgba(15, 23, 42, 0.4), 0 0 0 2px rgba(99, 102, 241, 0.35);
  opacity: 0.95;
  transition: none !important;
}

.ai-chat-panel.minimized {
  height: auto !important;
  max-height: none !important;
  box-shadow: 0 8px 24px -4px rgba(15, 23, 42, 0.2);
}

.ai-chat-panel.minimized .ai-chat-messages,
.ai-chat-panel.minimized .ai-chat-suggestions,
.ai-chat-panel.minimized .ai-chat-input-bar,
.ai-chat-panel.minimized .ai-config-drawer {
  display: none !important;
}

[data-theme="dark"] .ai-chat-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

.ai-chat-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-header-sparkle {
  font-size: 20px;
  filter: drop-shadow(0 2px 4px rgba(99, 102, 241, 0.3));
}

.ai-title-wrap h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.ai-status-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  display: inline-block;
  margin-top: 2px;
}

.ai-status-badge.is-local {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}

[data-theme="dark"] .ai-status-badge.is-local {
  background: #1e293b;
  color: #94a3b8;
  border-color: #334155;
}

.ai-status-badge.is-gemini {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}

[data-theme="dark"] .ai-status-badge.is-gemini {
  background: rgba(37, 99, 235, 0.2);
  color: #60a5fa;
  border-color: #1d4ed8;
}

.ai-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-header-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: all 0.15s ease;
}

.ai-header-btn:hover {
  background: var(--surface-alt);
  color: var(--text-main);
  border-color: var(--border);
}

/* Config Drawer (API Key settings) */
.ai-config-drawer {
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  flex-shrink: 0;
  animation: slideDown 0.2s ease-out;
}

.ai-config-drawer.hidden {
  display: none !important;
}

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

.ai-config-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text-main);
}

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

.ai-config-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 10px;
}

.ai-config-field input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-main);
  font-size: 12px;
  font-family: ui-monospace, monospace;
}

.ai-config-field input:focus {
  outline: 2px solid var(--primary);
  border-color: transparent;
}

.ai-config-buttons {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.btn-ai-save {
  flex: 1;
  background: var(--primary);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-ai-save:hover {
  background: var(--primary-hover);
}

.btn-ai-remove {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
}

.btn-ai-remove:hover {
  color: #b91c1c;
  background: #fee2e2;
  border-color: #fecaca;
}

.ai-config-link-wrap {
  margin-top: 8px;
  text-align: right;
}

.link-ai-studio {
  font-size: 11px;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.link-ai-studio:hover {
  text-decoration: underline;
}

/* Chat Messages */
.ai-chat-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-msg {
  display: flex;
  width: 100%;
}

.ai-msg-user {
  justify-content: flex-end;
}

.ai-msg-assistant {
  justify-content: flex-start;
}

.ai-msg-bubble {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
}

.ai-msg-user .ai-msg-bubble {
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.25);
}

.ai-msg-assistant .ai-msg-bubble {
  background: var(--surface-alt);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.ai-msg-assistant .ai-msg-bubble code {
  background: rgba(0, 0, 0, 0.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
}

[data-theme="dark"] .ai-msg-assistant .ai-msg-bubble code {
  background: rgba(255, 255, 255, 0.1);
}

/* Action button inside AI messages */
.ai-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--primary-light);
  color: var(--primary);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  margin: 4px 4px 4px 0;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.ai-action-btn.small {
  padding: 2px 8px;
  font-size: 11px;
  margin-top: 2px;
}

.ai-action-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: translateY(-1px);
}

/* Typing Indicator Animation */
.ai-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px !important;
}

.ai-typing span {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: aiBounce 1.2s infinite ease-in-out;
}

.ai-typing span:nth-child(1) { animation-delay: -0.32s; }
.ai-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes aiBounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.3; }
  40% { transform: scale(1); opacity: 1; }
}

/* Suggestion Chips */
.ai-chat-suggestions {
  display: flex;
  gap: 6px;
  padding: 6px 14px 10px 14px;
  overflow-x: auto;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.ai-chat-suggestions::-webkit-scrollbar {
  height: 4px;
}

.ai-chip {
  white-space: nowrap;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.ai-chip:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary-light);
}

/* Input Bar */
.ai-chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.ai-chat-input-bar input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-alt);
  color: var(--text-main);
  font-size: 13px;
  transition: border-color 0.15s ease;
}

.ai-chat-input-bar input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.ai-chat-input-bar button {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: none;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 15px;
  flex-shrink: 0;
}

.ai-chat-input-bar button:hover {
  background: var(--primary-hover);
  transform: scale(1.04);
}

.ai-chat-input-bar button:active {
  transform: scale(0.96);
}

/* Auto Assign Priorities Modal */
.auto-assign-modal-card {
  max-width: 480px;
}

.auto-assign-intro {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
}

.auto-assign-stats {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.auto-assign-stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface-alt);
  color: var(--text-main);
  border: 1px solid var(--border);
}

.auto-assign-stat-badge.highlight {
  background: rgba(30, 92, 153, 0.1);
  color: var(--primary);
  border-color: rgba(30, 92, 153, 0.3);
}

[data-theme="dark"] .auto-assign-stat-badge.highlight {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.3);
}

.auto-assign-stat-badge.locked {
  background: rgba(245, 158, 11, 0.1);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.3);
}

[data-theme="dark"] .auto-assign-stat-badge.locked {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.3);
}

.auto-assign-field {
  margin-bottom: 16px;
}

.auto-assign-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 8px;
}

.auto-assign-input-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auto-assign-input {
  width: 110px;
  padding: 8px 12px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-main);
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.auto-assign-input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(30, 92, 153, 0.15);
}

.auto-assign-range-hint {
  font-size: 13px;
  color: var(--text-muted);
}

.auto-assign-checkbox-field {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  transition: background 0.2s, border-color 0.2s;
}

.auto-assign-checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  user-select: none;
}

.auto-assign-checkbox {
  width: 17px;
  height: 17px;
  accent-color: var(--primary);
  cursor: pointer;
  margin: 0;
}

.auto-assign-checkbox-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  margin-left: 27px;
  line-height: 1.35;
}

.auto-assign-preview {
  padding: 12px 14px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-main);
  margin-bottom: 20px;
  line-height: 1.45;
}

.auto-assign-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn-modal-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-modal-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-modal-secondary {
  background: var(--surface-alt);
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-modal-secondary:hover {
  background: var(--border);
}
