:root {
  --bg: #f8fafc;
  --bg2: #ffffff;
  --bg3: #f1f5f9;
  --accent: #2563eb;
  --accent2: #059669;
  --red: #9b1b30;
  --orange: #facc15;
  --yellow: #d97706;
  --purple: #7c3aed;
  --text: #1e293b;
  --text2: #64748b;
  --border: #e2e8f0;
  --radius: 10px;
  --sidebar-w: 380px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); overflow: hidden; height: 100vh; }

/* Layout: sidebar + map */
#app { display: flex; height: 100vh; }

#sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  flex-shrink: 0;
}

#map-container { flex: 1; position: relative; }
#map { width: 100%; height: 100%; }

/* Sidebar header */
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.sidebar-header img { height: 28px; }
.sidebar-header .brand-text { display: flex; flex-direction: column; }
.sidebar-header .brand-name { font-size: 14px; font-weight: 700; color: var(--text); line-height: 1.2; }
.sidebar-header .brand-sub { font-size: 10px; color: var(--text2); font-weight: 500; letter-spacing: 0.03em; }

/* State selector dropdown (header) */
.state-selector {
  position: relative;
  margin-left: auto;
}
.state-selector-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  transition: all 0.15s;
}
.state-selector-btn:hover { border-color: var(--accent); color: var(--accent); }
.state-selector-btn .state-arrow { font-size: 10px; color: var(--text2); transition: transform 0.2s; }
.state-selector-btn.open .state-arrow { transform: rotate(180deg); }
.state-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 220px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 2000;
  padding: 4px;
}
.state-dropdown.open { display: block; }
.state-dd-search {
  width: calc(100% - 8px);
  margin: 4px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 12px;
  background: var(--bg1);
  color: var(--text);
  outline: none;
  box-sizing: border-box;
}
.state-dd-search:focus { border-color: var(--accent); }
.state-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
}
.state-dropdown-item:hover { background: var(--bg3); }
.state-dropdown-item.active { background: var(--accent); color: #fff; }
.state-dropdown-item .state-dd-abbr { font-weight: 700; min-width: 28px; }
.state-dropdown-item .state-dd-count { font-size: 11px; color: var(--text2); font-weight: 500; }
.state-dropdown-item.active .state-dd-count { color: rgba(255,255,255,0.7); }

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.tab {
  flex: 1;
  padding: 10px 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Tab panels */
.tab-panel { display: none; flex: 1; overflow-y: auto; }
.tab-panel.active { display: flex; flex-direction: column; }

/* Search / filter bar */
.search-bar {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.search-row {
  display: flex;
  gap: 6px;
}
.search-input {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text2); }
.search-btn {
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.search-btn:hover { background: #3b8de6; }
.search-btn:active { transform: scale(0.98); }

/* Near Me button — compact, inline with search row */
.near-me-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.near-me-btn svg { width: 14px; height: 14px; }
.near-me-btn:hover { background: #3b8de6; }
.near-me-btn:active { transform: scale(0.98); }
.near-me-btn.loading { opacity: 0.6; pointer-events: none; }

/* Filter pills */
.filter-row {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}
.filter-pill {
  padding: 5px 10px;
  font-size: 11px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text2);
  cursor: pointer;
  white-space: nowrap;
}
.filter-pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.filter-select {
  padding: 5px 8px;
  font-size: 11px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  cursor: pointer;
  outline: none;
}

/* Results list */
.results-header {
  padding: 8px 12px;
  font-size: 11px;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
}

.result-card {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.result-card:hover { background: var(--bg3); }
.result-card.is-lead { border-left: 3px solid var(--accent2); }
.result-card.is-route-stop { border-left: 3px solid var(--yellow); }

.result-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.result-name .distance {
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
}
.result-meta {
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 4px;
}
.result-badges { display: flex; gap: 4px; flex-wrap: wrap; }
.badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-on { background: #dbeafe; color: #1d4ed8; }
.badge-off { background: #fef9c3; color: #a16207; }
.badge-category { background: var(--bg3); color: var(--text2); }
.badge-county { background: #d1fae5; color: #047857; }

/* Action buttons row in result cards */
.result-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

/* Save lead button */
.save-btn, .route-btn, .customer-btn {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  background: var(--bg);
  color: var(--text2);
  white-space: nowrap;
}
.save-btn { background: var(--accent); color: #fff; border-color: var(--accent); }
.save-btn:hover { opacity: 0.9; }
.save-btn.saved { background: #e2e8f0; color: var(--text2); cursor: default; border-color: var(--border); }
.save-btn.remove { background: var(--bg3); color: var(--text2); border-color: var(--border); }
.save-btn.remove:hover { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }
.route-btn:hover:not(:disabled) { background: var(--bg3); color: var(--text); }
.route-btn.added, .route-btn.in-route { background: #fef9c3; color: #854d0e; border-color: #fbbf24; }
.customer-btn { color: #dc2626; border-color: #dc2626; background: var(--bg); }
.customer-btn:hover:not(:disabled) { background: #dc2626; color: #fff; }
.customer-btn.is-customer { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }

/* Lead detail panel */
#detail-panel {
  display: none;
  flex-direction: column;
  height: 100%;
}
#detail-panel.active { display: flex; }

.detail-header {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.back-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
}
.detail-body { flex: 1; overflow-y: auto; padding: 12px; }

.detail-section {
  margin-bottom: 16px;
}
.detail-section h3 {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text2);
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

.status-pills { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.status-pill {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text2);
  cursor: pointer;
}
.status-pill.active-new { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }
.status-pill.active-contacted { background: #ffedd5; color: #c2410c; border-color: #fdba74; }
.status-pill.active-in_progress { background: #ede9fe; color: #6d28d9; border-color: #c4b5fd; }
.status-pill.active-converted { background: #d1fae5; color: #047857; border-color: #6ee7b7; }
.status-pill.active-archived { background: #f3f4f6; color: #6b7280; border-color: #d1d5db; }

/* Product status in detail */
.product-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px;
  border-radius: 6px;
  background: var(--bg);
  margin-bottom: 4px;
}
.product-name { font-size: 13px; font-weight: 600; }
.product-status {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
}
.ps-pitched { background: #dbeafe; color: #1d4ed8; }
.ps-interested { background: #ffedd5; color: #c2410c; }
.ps-sold { background: #d1fae5; color: #047857; }
.product-row-v2 { padding: 8px; border-radius: 6px; background: var(--bg); margin-bottom: 4px; }
.product-name-line { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.product-tracking { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.prod-track-input {
  width: 56px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  color: var(--text);
  background: var(--bg2);
  outline: none;
  text-align: center;
}
.prod-track-input:focus { border-color: var(--accent); }
.prod-track-field { display: flex; flex-direction: column; gap: 2px; }
.prod-track-field label { font-size: 9px; color: var(--text2); font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
.prod-track-toggle {
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text2);
  background: var(--bg2);
  cursor: pointer;
}
.prod-track-toggle.active { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }
.ps-lost { background: #fee2e2; color: #b91c1c; }

/* TTB badge */
.ttb-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: #dbeafe;
  color: #1e40af;
  vertical-align: middle;
  margin-left: 4px;
  letter-spacing: 0.5px;
}
.ttb-permit-row {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.ttb-permit-row:last-child { border-bottom: none; }
.ttb-permit-type {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--accent);
}
.ttb-permit-num {
  font-size: 11px;
  color: var(--text2);
  font-family: monospace;
}
.ttb-match-score {
  font-size: 10px;
  color: var(--text2);
  float: right;
}

/* Add input */
.add-row {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.add-input {
  flex: 1;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.add-input:focus { border-color: var(--accent); }
.add-btn {
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

/* Directions button */
.directions-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px;
  margin-top: 8px;
  background: var(--bg3);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.directions-btn:hover { background: #eff6ff; }

/* Map controls overlay */
.map-controls {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 900;
  display: flex;
  gap: 8px;
}
.map-btn {
  padding: 8px 14px;
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.map-btn:hover { background: var(--bg3); }
.map-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Map pin count badge */
.map-count {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 12px;
  color: var(--text2);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.map-count strong { color: var(--accent); }

/* List toggle button — floats next to license counter */
.list-toggle-btn {
  position: absolute;
  bottom: 24px;
  right: 16px;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 8px 16px;
  min-height: 44px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(37,99,235,0.3);
  transition: all 0.2s;
}
.list-toggle-btn:hover { background: #1d4ed8; }
.list-toggle-btn:active { transform: scale(0.96); }
.list-toggle-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.list-toggle-btn svg { flex-shrink: 0; }

/* Settings button in filter bar — hide on mobile */
.fb-settings-btn { display: none; }
@media (min-width: 769px) {
  .fb-settings-btn { display: flex !important; }
}

/* Marker highlight bounce animation */
@keyframes markerBounce {
  0%, 100% { transform: translateY(0); }
  25% { transform: translateY(-12px); }
  50% { transform: translateY(-4px); }
  75% { transform: translateY(-8px); }
}
.marker-highlight {
  animation: markerBounce 0.6s ease;
  z-index: 10000 !important;
}

/* License counter loading spinner */
.license-counter-loading {
  display: none;
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
.license-counter-loading.visible { display: inline-block; }

/* Loading overlay on map */
.map-loading {
  display: none;
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 950;
  background: rgba(248, 250, 252, 0.75);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.map-loading.visible { display: flex; }
.map-loading-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.map-loading-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

/* Route panel on map */
.route-panel {
  position: absolute;
  top: 12px;
  right: 60px;
  z-index: 900;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  min-width: 240px;
  max-width: 300px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  display: none;
}
.route-panel.active { display: block; }
.route-panel h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.route-stop {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.route-stop-num {
  width: 22px;
  height: 22px;
  background: var(--yellow);
  color: #000;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  flex-shrink: 0;
}
.route-stop-name { flex: 1; }
.route-stop-remove {
  background: none;
  border: none;
  color: var(--red);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 4px;
}
.route-actions {
  margin-top: 8px;
  display: flex;
  gap: 6px;
}
.route-action-btn {
  flex: 1;
  padding: 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  border: none;
}
.route-go { background: var(--accent); color: #fff; }
.route-go:hover { opacity: 0.9; }
.route-share { background: var(--bg3); color: var(--blue); border: 1px solid var(--blue); }
.route-share:hover { background: #eff6ff; }
.route-clear { background: var(--bg3); color: var(--text2); border: 1px solid var(--border); }

/* Collapsible stops bar */
.stops-bar {
  border-top: 2px solid var(--accent);
  background: var(--bg2);
  flex-shrink: 0;
}
.stops-bar.hidden { display: none; }
.stops-bar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
}
.stops-bar-header:hover { background: var(--bg3); }
.stops-bar-chevron {
  font-size: 10px;
  color: var(--text2);
  transition: transform 0.2s;
}
.stops-bar.expanded .stops-bar-chevron { transform: rotate(180deg); }
#stops-bar-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  flex: 1;
}
.stops-bar-actions {
  display: flex;
  gap: 6px;
}
.stops-bar-actions .route-action-btn {
  padding: 5px 12px;
  font-size: 11px;
}
.stops-bar-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}
.stops-bar.expanded .stops-bar-body {
  max-height: 40vh;
  overflow-y: auto;
}

/* Smart Account Targeting */
.target-select { font-weight: 600; }
.target-select.active {
  background: #fef3c7;
  border-color: var(--yellow);
  color: #92400e;
  font-weight: 700;
}
.target-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.target-banner[data-target="wine"] { background: #fef7ed; color: #7c2d12; }
.target-banner[data-target="spirits"] { background: #eff6ff; color: #1e3a5f; }
.target-banner[data-target="beer"] { background: #fefce8; color: #92400e; }
.target-banner-clear {
  background: none;
  border: 1px solid currentColor;
  color: inherit;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
  font-weight: 600;
}
.brand-input-row {
  display: flex;
  gap: 6px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
}
.brand-url-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  outline: none;
}
.brand-url-input:focus { border-color: var(--blue); }
.brand-detect-btn {
  padding: 6px 14px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.brand-detect-btn:hover { opacity: 0.9; }
.brand-detect-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.badge-target-3 { background: #d1fae5; color: #065f46; font-weight: 700; }
.badge-target-2 { background: #dbeafe; color: #1e40af; }
.badge-new { background: #fce4ec; color: #9b1b30; font-weight: 700; letter-spacing: 0.03em; }
.badge-fresh { background: #ff6b35; color: #fff; font-weight: 700; font-size: 10px; letter-spacing: 0.03em; }

/* Fresh Leads banner */
.fresh-banner {
  display: none;
  padding: 10px 12px;
  background: linear-gradient(135deg, #fff7ed 0%, #fff1e6 100%);
  border-bottom: 1px solid #fed7aa;
  cursor: pointer;
  transition: all 0.2s;
}
.fresh-banner:hover { background: linear-gradient(135deg, #ffedd5 0%, #ffe4cc 100%); }
.fresh-banner.visible { display: flex; align-items: center; gap: 10px; }
.fresh-banner-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: #ff6b35;
  border-radius: 10px;
  font-size: 18px;
  flex-shrink: 0;
  animation: freshPulse 2s ease-in-out infinite;
}
.fresh-banner-body { flex: 1; min-width: 0; }
.fresh-banner-title { font-size: 14px; font-weight: 700; color: #c2410c; }
.fresh-banner-sub { font-size: 11px; color: #9a3412; margin-top: 1px; }
.fresh-banner-arrow { color: #c2410c; font-size: 18px; flex-shrink: 0; }
.fresh-banner-close {
  background: none;
  border: none;
  color: #c2410c;
  font-size: 14px;
  cursor: pointer;
  padding: 4px;
  opacity: 0.5;
  flex-shrink: 0;
}
.fresh-banner-close:hover { opacity: 1; }
@keyframes freshPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* Fresh mode active state */
.fresh-mode-header {
  display: none;
  padding: 8px 12px;
  background: #fff7ed;
  border-bottom: 1px solid #fed7aa;
  align-items: center;
  justify-content: space-between;
}
.fresh-mode-header.visible { display: flex; }
.fresh-mode-label { font-size: 13px; font-weight: 700; color: #c2410c; }
.fresh-mode-exit {
  padding: 4px 10px;
  background: #fff;
  border: 1px solid #fed7aa;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #c2410c;
  cursor: pointer;
}
.fresh-mode-exit:hover { background: #fff7ed; }

/* Pulsing marker for fresh licenses on map */
.fresh-pin-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border-radius: 50%;
  background: rgba(255, 107, 53, 0.3);
  animation: freshMarkerPulse 2s ease-out infinite;
  pointer-events: none;
}
@keyframes freshMarkerPulse {
  0% { transform: scale(0.5); opacity: 1; }
  100% { transform: scale(2.5); opacity: 0; }
}

/* Fresh pin icon — orange/red */
.fresh-pin svg path { fill: #ff6b35 !important; }

/* Pending Applications banner */
.pending-banner {
  display: none;
  padding: 10px 12px;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border-bottom: 1px solid #fde68a;
  cursor: pointer;
  transition: all 0.2s;
}
.pending-banner:hover { background: linear-gradient(135deg, #fef9c3 0%, #fef08a 100%); }
.pending-banner.visible { display: flex; align-items: center; gap: 10px; }
.pending-banner-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: #f59e0b;
  border-radius: 10px;
  font-size: 18px;
  flex-shrink: 0;
}
.pending-banner-body { flex: 1; min-width: 0; }
.pending-banner-title { font-size: 14px; font-weight: 700; color: #92400e; }
.pending-banner-sub { font-size: 11px; color: #a16207; margin-top: 1px; }
.pending-banner-arrow { color: #92400e; font-size: 18px; flex-shrink: 0; }

/* Pending mode active state */
.pending-mode-header {
  display: none;
  padding: 8px 12px;
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
  align-items: center;
  justify-content: space-between;
}
.pending-mode-header.visible { display: flex; }
.pending-mode-label { font-size: 13px; font-weight: 700; color: #92400e; }
.pending-mode-exit {
  padding: 4px 10px;
  background: #fff;
  border: 1px solid #fde68a;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #92400e;
  cursor: pointer;
}
.pending-mode-exit:hover { background: #fffbeb; }

/* Business detail panel (non-lead, view from map/list) */
#biz-detail-panel {
  display: none;
  position: absolute;
  top: 0;
  right: 0;
  width: 380px;
  height: 100%;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  z-index: 1100;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,0.08);
  animation: slideInRight 0.2s ease;
}
#biz-detail-panel.active { display: flex; }
@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.bdp-header {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.bdp-close {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
}
.bdp-close:hover { background: var(--bg3); color: var(--text); }
.bdp-title { font-size: 16px; font-weight: 700; flex: 1; }
.bdp-body { flex: 1; overflow-y: auto; }
.bdp-section { padding: 12px; border-bottom: 1px solid var(--border); }
.bdp-section:last-child { border-bottom: none; }
.bdp-section-title { font-size: 10px; text-transform: uppercase; color: var(--text2); letter-spacing: 0.5px; font-weight: 600; margin-bottom: 8px; }
.bdp-row { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; font-size: 13px; }
.bdp-row-label { color: var(--text2); font-weight: 500; min-width: 80px; }
.bdp-row-value { font-weight: 600; text-align: right; flex: 1; }
.bdp-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.bdp-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg3);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  text-decoration: none;
  transition: all 0.15s;
}
.bdp-action:hover { border-color: var(--accent); color: var(--accent); }
.bdp-action svg { width: 20px; height: 20px; }
.bdp-action.bdp-call { color: #16a34a; border-color: #16a34a; }
.bdp-action.bdp-call:hover { background: #f0fdf4; }
.bdp-action.bdp-nav { color: var(--accent); border-color: var(--accent); }
.bdp-action.bdp-nav:hover { background: #eff6ff; }
.bdp-action.bdp-save { background: var(--accent); color: #fff; border-color: var(--accent); }
.bdp-action.bdp-saved { background: #d1fae5; color: #047857; border-color: #6ee7b7; }
.bdp-action.bdp-route { background: #65a30d; color: #fff; border-color: #65a30d; }
.bdp-action.bdp-routed { background: #fef9c3; color: #854d0e; border-color: #fbbf24; }
.bdp-pending-badge { display: inline-block; padding: 2px 8px; background: #f59e0b; color: #fff; border-radius: 4px; font-size: 11px; font-weight: 700; }
.bdp-fresh-badge { display: inline-block; padding: 2px 8px; background: #ff6b35; color: #fff; border-radius: 4px; font-size: 11px; font-weight: 700; }

/* Route planning toast notification */

/* Accessibility: larger tap targets + font sizes (RUB-134) */
.search-input { font-size: 16px !important; min-height: 44px; }
.search-btn { min-height: 44px; min-width: 44px; font-size: 15px; }
.tab { min-height: 44px; font-size: 13px; }
.filter-pill { min-height: 40px; padding: 8px 14px; font-size: 13px; }
.result-card { padding: 12px; }
.result-name { font-size: 15px; }
.result-meta { font-size: 13px; line-height: 1.4; }
.save-btn, .route-btn, .customer-btn { min-height: 36px; padding: 6px 12px; font-size: 12px; }
.pib-btn { min-height: 48px; min-width: 44px; font-size: 12px; }
.popup-name { font-size: 16px; }
.popup-addr { font-size: 13px; }
.bdp-action { min-height: 52px; font-size: 12px; }
.bdp-row { font-size: 14px; }
.lead-search-input { font-size: 16px !important; min-height: 44px; }
.fb-pill { min-height: 36px; }
.fb-select { min-height: 36px; font-size: 13px; }
.fb-search-input { font-size: 16px !important; }
.mic-name { font-size: 17px; }
.mic-addr { font-size: 13px; }

@media (max-width: 768px) {
  #biz-detail-panel {
    width: 100%;
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    height: 85vh;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    animation: slideInUp 0.25s ease;
  }
  @keyframes slideInUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
}

/* Licenses tab badge */
.tab-fresh-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: #ff6b35;
  color: #fff;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
  margin-left: 4px;
  vertical-align: middle;
}
.yelp-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  font-weight: 600;
  color: #d32323;
  background: #fff0ef;
  border: 1px solid #fecaca;
  border-radius: 4px;
  padding: 2px 5px;
}
.yelp-link {
  color: #d32323;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 12px;
  display: inline-block;
}
.yelp-link:hover { text-decoration: underline; }
.yelp-photo {
  width: 100%;
  max-height: 120px;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 8px;
}
.new-toggle { display:inline-flex; align-items:center; padding:3px 8px; border-radius:6px; font-size:10px; font-weight:800; letter-spacing:0.05em; cursor:pointer; border:1.5px solid var(--border); background:var(--bg2); color:var(--text2); transition:all 0.15s; white-space:nowrap; text-transform:uppercase; }
.new-toggle:hover { border-color:var(--accent); color:var(--accent); background:var(--bg3); }
.new-toggle.active { background:var(--accent); color:#fff; border-color:var(--accent); box-shadow:0 1px 4px rgba(37,99,235,0.3); }
.cluster-icon { position:relative; background:rgba(37,99,235,0.7); border:2px solid rgba(37,99,235,0.9); border-radius:50%; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:13px; color:#fff; }
.cluster-bubble { background:rgba(37,99,235,0.35); border:1.5px solid rgba(37,99,235,0.5); border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:11px; font-weight:700; color:#1e3a5f; cursor:pointer; }
.city-bubble-label { background:none !important; border:none !important; box-shadow:none !important; color:#1e3a5f; font-weight:700; font-size:12px; text-shadow:0 0 4px #fff, 0 0 4px #fff, 0 0 4px #fff; }
.target-star { font-size: 12px; margin-left: 4px; color: #059669; }

/* pulsing blue dot for current location */
.locate-pulse {
  animation: locatePulse 2s ease-in-out infinite;
}
@keyframes locatePulse {
  0%, 100% { filter: drop-shadow(0 0 0 rgba(37,99,235,0.4)); }
  50% { filter: drop-shadow(0 0 8px rgba(37,99,235,0.6)); }
}

/* Follow-up pipeline badges */
.badge-status {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-status-new { background: #f1f5f9; color: #64748b; }
.badge-status-contacted { background: #dbeafe; color: #1d4ed8; }
.badge-status-meeting { background: #ffedd5; color: #c2410c; }
.badge-status-in_progress { background: #ffedd5; color: #c2410c; }
.badge-status-won { background: #d1fae5; color: #047857; }
.badge-status-converted { background: #d1fae5; color: #047857; }
.badge-status-lost { background: #fee2e2; color: #b91c1c; }
.badge-status-archived { background: #f1f5f9; color: #94a3b8; }
.badge-overdue {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  text-transform: uppercase;
  background: #dc2626;
  color: #fff;
  letter-spacing: 0.5px;
}
.follow-up-date {
  font-size: 11px;
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: 4px;
}
.follow-up-date.overdue { color: #dc2626; font-weight: 600; }
.overdue-section {
  padding: 8px 12px;
  background: #fef2f2;
  border-bottom: 1px solid #fecaca;
}
.overdue-section-title {
  font-size: 11px;
  font-weight: 700;
  color: #dc2626;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

/* Follow-up controls in detail panel */
.follow-up-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}
.follow-up-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  outline: none;
}
.follow-up-input:focus { border-color: var(--accent); }

/* Pipeline status dropdown */
.pipeline-select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  outline: none;
  cursor: pointer;
}
.pipeline-select:focus { border-color: var(--accent); }

/* Schedule fields */
.schedule-row { display: flex; gap: 8px; }
.schedule-field { flex: 1; }
.schedule-label { display: block; font-size: 10px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; font-weight: 600; }
.multiselect-wrap { position: relative; }
.multiselect-selected {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  cursor: pointer;
  min-height: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.multiselect-selected:empty::after,
.multiselect-selected.placeholder { color: var(--text2); }
.multiselect-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 100;
  padding: 6px 0;
  margin-top: 2px;
}
.multiselect-dropdown.open { display: block; }
.multiselect-dropdown label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.multiselect-dropdown label:hover { background: var(--bg3); }
.multiselect-dropdown input[type="checkbox"] { accent-color: var(--accent); }

/* Route schedule filters */
.route-filter-select {
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  color: var(--text);
  background: var(--bg);
  cursor: pointer;
  outline: none;
}
.route-filter-select:focus { border-color: var(--accent); }
.route-schedule-filters { display: none; }

/* Smart Call List */
.smart-list-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: linear-gradient(135deg, #7c3aed 0%, #2563eb 100%);
  color: #fff;
  border: none;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 32px;
  box-shadow: 0 2px 8px rgba(124,58,237,0.25);
  transition: all 0.15s;
}
.smart-list-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.smart-list-btn:active { transform: scale(0.97); }
.smart-list-btn svg { width: 14px; height: 14px; }

.smart-list-header {
  display: none;
  padding: 8px 12px;
  background: linear-gradient(135deg, #ede9fe 0%, #eff6ff 100%);
  border-bottom: 1px solid #c4b5fd;
  align-items: center;
  justify-content: space-between;
}
.smart-list-header.visible { display: flex; }
.smart-list-label { font-size: 13px; font-weight: 700; color: #6d28d9; }
.smart-list-exit {
  padding: 4px 10px;
  background: #fff;
  border: 1px solid #c4b5fd;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #6d28d9;
  cursor: pointer;
}
.smart-list-exit:hover { background: #f5f3ff; }
.score-badge {
  font-size: 11px;
  font-weight: 700;
  color: #6d28d9;
  background: #ede9fe;
  border: 1px solid #c4b5fd;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

/* Territory Briefing */
.territory-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 11px;
  color: var(--text2);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 32px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: all 0.15s;
}
.territory-btn:hover { border-color: var(--accent); color: var(--accent); }
.territory-btn svg { flex-shrink: 0; }
/* Desktop: hide floating intel button */
@media (min-width: 769px) {
  .territory-btn-wrap { display: none !important; }
}

.territory-panel {
  display: none;
  position: absolute;
  bottom: 60px;
  right: 12px;
  z-index: 950;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  min-width: 280px;
  max-width: 340px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  animation: fadeIn 0.2s ease;
}
.territory-panel.visible { display: block; }
.territory-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.territory-panel-title { font-size: 14px; font-weight: 700; color: var(--text); }
.territory-panel-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text2);
  cursor: pointer;
  padding: 2px 6px;
}
.territory-stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.territory-stat {
  background: var(--bg3);
  border-radius: 8px;
  padding: 10px;
}
.territory-stat-val { font-size: 20px; font-weight: 700; color: var(--text); }
.territory-stat-label { font-size: 11px; color: var(--text2); margin-top: 2px; }
.territory-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 12px;
}
.territory-bar-label { flex: 1; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.territory-bar-count { color: var(--text2); font-weight: 600; font-size: 11px; flex-shrink: 0; }
.territory-bar-track { width: 60px; height: 6px; background: var(--bg3); border-radius: 3px; flex-shrink: 0; overflow: hidden; }
.territory-bar-fill { height: 100%; border-radius: 3px; background: var(--accent); }
.territory-section-title { font-size: 11px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; margin: 10px 0 6px; }

/* Mobile territory panel — bottom sheet style */
@media (max-width: 768px) {
  .territory-panel {
    position: fixed;
    bottom: 80px;
    left: 0;
    right: 0;
    border-radius: 16px 16px 0 0;
    max-width: none;
    min-width: auto;
    padding: 20px 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
    max-height: 60vh;
    overflow-y: auto;
  }
  .territory-panel::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto 12px;
  }
  .smart-list-btn { min-height: 38px; padding: 8px 16px; font-size: 13px; }
}

/* Lead search */
.lead-search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg);
  outline: none;
  box-sizing: border-box;
}
.lead-search-input:focus { border-color: var(--blue); }

/* Quick action buttons */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.quick-action-btn {
  padding: 6px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}
.quick-action-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.quick-action-btn:active { transform: scale(0.95); }

/* Voice note */
.note-input-row { display: flex; gap: 6px; align-items: center; }
.note-text-input { flex: 1; }
.mic-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}
.mic-btn:hover { border-color: var(--blue); }
.mic-btn.recording { background: #fee2e2; border-color: #ef4444; animation: pulse-mic 1.5s infinite; }
.mic-btn.recording svg { stroke: #ef4444; }
@keyframes pulse-mic { 0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.3); } 50% { box-shadow: 0 0 0 8px rgba(239,68,68,0); } }

.voice-status {
  font-size: 11px;
  color: #ef4444;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
}
.voice-dot {
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: 50%;
  animation: pulse-mic 1.5s infinite;
}

/* Notes timeline */
.notes-timeline { margin-top: 8px; }
.note-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.note-item:last-child { border-bottom: none; }
.note-content { line-height: 1.4; }
.note-meta {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text2);
  margin-top: 3px;
}
.note-type-quick { color: var(--blue); font-weight: 600; }
.note-type-voice { color: #ef4444; font-weight: 600; }

/* Leads tab */
.leads-list { flex: 1; overflow-y: auto; }

.lead-card {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
  border-left: 3px solid transparent;
  position: relative;
}
.lead-remove { position:absolute; top:8px; right:8px; background:none; border:none; color:var(--text3); font-size:16px; cursor:pointer; padding:2px 6px; border-radius:4px; }
.lead-remove:hover { background:#fee2e2; color:#dc2626; }
.detail-remove-btn { width:100%; padding:10px; background:none; border:1.5px solid #dc2626; color:#dc2626; font-size:13px; font-weight:600; border-radius:8px; cursor:pointer; transition:all 0.15s; }
.detail-remove-btn:hover { background:#dc2626; color:#fff; }
.lead-card:hover { background: var(--bg3); }
.lead-card[data-status="new"] { border-left-color: #60a5fa; }
.lead-card[data-status="contacted"] { border-left-color: var(--orange); }
.lead-card[data-status="in_progress"] { border-left-color: #a78bfa; }
.lead-card[data-status="converted"] { border-left-color: var(--accent2); }
.lead-card[data-status="archived"] { border-left-color: #9ca3af; opacity: 0.7; }
.lead-card.needs-attention { border-left-color: #f59e0b !important; }
.lead-card.unread .result-name { font-weight: 800; }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; flex-shrink: 0; margin-right: 4px; }
.source-badge { font-size: 10px; padding: 1px 5px; border-radius: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
.source-badge-license { background: #dbeafe; color: #1d4ed8; }
.source-badge-google { background: #fef3c7; color: #92400e; }
.source-badge-ttb { background: #ede9fe; color: #6d28d9; }
.source-badge-manual { background: #f3f4f6; color: #6b7280; }
.source-badge-customer { background: #fee2e2; color: #dc2626; }
.tab-badge { background: #ef4444; color: #fff; font-size: 10px; padding: 1px 5px; border-radius: 10px; margin-left: 4px; font-weight: 700; }
.detail-archive-btn { width:100%; padding:10px; background:none; border:1.5px solid #9ca3af; color:#6b7280; font-size:13px; font-weight:600; border-radius:8px; cursor:pointer; transition:all 0.15s; margin-bottom:8px; }
.detail-archive-btn:hover { background:#f3f4f6; }
.attention-header { padding: 6px 12px; font-size: 11px; font-weight: 700; color: #f59e0b; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); background: #fffbeb; }
.duplicate-banner { background: #fef3c7; border: 1px solid #f59e0b; color: #92400e; padding: 8px 12px; font-size: 12px; display: flex; align-items: center; gap: 8px; border-radius: 6px; margin: 8px 12px; }
.duplicate-banner button { font-size: 11px; padding: 4px 8px; border-radius: 4px; cursor: pointer; border: 1px solid #f59e0b; background: #fff; color: #92400e; font-weight: 600; white-space: nowrap; }
.duplicate-banner button:hover { background: #fef3c7; }

.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text2);
  font-size: 14px;
}

/* Custom SVG pin markers */
.custom-pin {
  width: 22px;
  height: 40px;
}
.custom-pin.category-pin {
  width: 36px;
  height: 36px;
  transition: transform 0.15s;
}
.custom-pin.category-pin:hover {
  transform: scale(1.15);
  z-index: 9999 !important;
}
.lead-marker {
  background: var(--accent2);
  border: 2px solid #fff;
  border-radius: 50%;
  width: 14px;
  height: 14px;
}
.route-marker-icon {
  width: 28px;
  height: 28px;
  background: #84cc16;
  border: 2px solid #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  color: #000;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* Popup */
/* Push Leaflet zoom controls below the filter bar */
.leaflet-top.leaflet-right { top: 60px; }
@media (max-width: 768px) {
  .leaflet-top.leaflet-right { top: calc(env(safe-area-inset-top, 0px) + 72px); }
}

.leaflet-popup-content-wrapper {
  background: var(--bg2) !important;
  color: var(--text) !important;
  border-radius: var(--radius) !important;
  border: 1px solid var(--border) !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12) !important;
  max-width: none;
}
.leaflet-popup-tip { background: var(--bg2) !important; }
.leaflet-popup-content { margin: 12px !important; }
.popup-name { font-size: 15px; font-weight: 700; margin-bottom: 2px; }
.popup-dba { font-size: 11px; color: var(--text2); margin-bottom: 4px; font-style: italic; }
.popup-addr { font-size: 12px; color: var(--text2); margin-bottom: 2px; }
.popup-phone { font-size: 12px; margin-bottom: 6px; }
.popup-phone a { color: var(--accent); text-decoration: none; }
.popup-badges { margin-bottom: 8px; display: flex; gap: 4px; flex-wrap: wrap; }
/* Popup icon action bar */
.popup-icon-bar {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  width: 100%;
}
.pib-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 44px;
  min-width: 44px;
  padding: 6px 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg3);
  cursor: pointer;
  font-size: 11px;
  color: var(--text2);
  text-decoration: none;
  line-height: 1.2;
  transition: opacity 0.15s;
}
.pib-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.pib-btn:hover:not(:disabled) { opacity: 0.8; }
.pib-btn:disabled { opacity: 0.5; cursor: default; }
.pib-btn.pib-call { color: var(--accent); border-color: var(--accent); }
.pib-btn.pib-nav { color: var(--accent); }
.pib-btn.pib-save { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; }
.pib-btn.pib-save svg { stroke: #fff; }
.pib-btn.pib-saved { background: #d1fae5; color: #047857; border-color: #6ee7b7; }
.pib-btn.pib-route { color: #fff; background: #65a30d; border-color: #65a30d; font-weight: 700; }
.pib-btn.pib-routed { background: #fef9c3; color: #854d0e; border-color: #fbbf24; }
.pib-btn.pib-customer { color: #dc2626; border-color: #dc2626; }
.pib-btn.pib-customer-saved { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }

/* Map legend */
.map-legend {
  position: absolute;
  bottom: 160px;
  right: 12px;
  z-index: 900;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 11px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.legend-item:last-child { margin-bottom: 0; }
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Auth screen */
#auth-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  color-scheme: light;
}
#auth-screen.hidden { display: none; }
.auth-card {
  width: 100%;
  max-width: 440px;
  padding: 32px 24px;
  animation: fadeIn 0.4s ease;
}
.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 24px;
}
.auth-logo img { height: 40px; }
.auth-logo span { font-size: 18px; font-weight: 800; color: #1e293b; letter-spacing: -0.02em; }
.auth-title {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 4px;
}
.auth-subtitle {
  text-align: center;
  font-size: 14px;
  color: #475569;
  margin-bottom: 24px;
  line-height: 1.5;
  max-width: 360px;
}
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 16px 0;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #cbd5e1;
}
.auth-demo-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 20px;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #334155;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.auth-signin-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px 20px;
  background: #2563eb;
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.auth-signin-btn:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}
.auth-demo-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  transform: translateY(-1px);
}
.auth-demo-hint {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 6px;
}
.auth-trust {
  display: flex;
  gap: 20px;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid #cbd5e1;
}
.auth-trust-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #64748b;
  white-space: nowrap;
}
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-row { display: flex; gap: 10px; }
.auth-row > .auth-field { flex: 1; }
.auth-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 4px;
}
.auth-field input, .auth-field select {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #1e293b;
  outline: none;
  box-sizing: border-box;
}
.auth-field input::placeholder { color: #94a3b8; }
.auth-field input:focus, .auth-field select:focus { border-color: var(--accent); }
.auth-field select option { background: #fff; color: #1e293b; }
.auth-state-label {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 8px;
}
.auth-state-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  padding: 2px;
}
.auth-state-chip {
  padding: 8px 4px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.auth-state-chip:hover { border-color: #94a3b8; color: #1e293b; }
.auth-state-chip.selected { background: var(--accent); border-color: var(--accent); color: #fff; }
.auth-state-chip .chip-count { display: block; font-size: 10px; font-weight: 400; color: #64748b; margin-top: 2px; }
.auth-state-chip.selected .chip-count { color: rgba(255,255,255,0.7); }
.auth-all-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  color: #475569;
  font-size: 13px;
}
.auth-all-toggle input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }
.auth-submit {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 4px;
}
.auth-submit:hover { background: #1d4ed8; }
.auth-submit:disabled { opacity: 0.5; cursor: not-allowed; }
.auth-switch {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: #64748b;
}
.auth-switch a {
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
  font-weight: 600;
}
.auth-switch a:hover { text-decoration: underline; }
.auth-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 8px;
  display: none;
}
.auth-error.visible { display: block; }
/* Check-email state */
.auth-check-email {
  text-align: center;
  color: #f1f5f9;
}
.auth-check-email .email-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  background: rgba(37, 99, 235, 0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #60a5fa;
}
.auth-check-email h2 { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.auth-check-email p { font-size: 14px; color: #94a3b8; line-height: 1.5; }
.auth-check-email .email-highlight { color: #f1f5f9; font-weight: 600; }
.auth-resend { color: var(--accent); cursor: pointer; background: none; border: none; font-size: 13px; font-weight: 600; margin-top: 16px; }
.auth-resend:hover { text-decoration: underline; }

/* Onboarding overlay */
#onboarding {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}
#onboarding.hidden { display: none; }
.onboarding-slide {
  display: none;
  width: 100%;
  max-width: 520px;
  padding: 24px;
  animation: fadeIn 0.4s ease;
}
.onboarding-slide.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.onboarding-content {
  text-align: center;
  color: #f1f5f9;
}
.onboarding-logo {
  height: 48px;
  margin-bottom: 16px;
  filter: brightness(1.1);
}
.onboarding-content h1 {
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}
.onboarding-content h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 24px;
  letter-spacing: -0.01em;
}
.onboarding-tagline {
  font-size: 15px;
  color: #94a3b8;
  margin-bottom: 28px;
}
.onboarding-value {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 32px;
}
.value-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.value-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(37, 99, 235, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #60a5fa;
}
.value-item strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 2px;
}
.value-item span {
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.4;
}
.onboarding-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
}
.onboarding-btn:hover { background: #1d4ed8; }
.onboarding-dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 20px;
}
.onboarding-dots .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
}
.onboarding-dots .dot.active {
  background: var(--accent);
}
.feature-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  text-align: left;
  margin-bottom: 32px;
}
.feature-card {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 16px;
}
.feature-num {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}
.feature-card strong {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
}
.feature-card span {
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.4;
}

/* Walkthrough tour */
#walkthrough-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: none;
  pointer-events: none;
}
#walkthrough-overlay.active { display: block; }
.wt-spotlight {
  position: fixed;
  z-index: 9999;
  border-radius: 8px;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.5);
  transition: all 0.35s cubic-bezier(.4,0,.2,1);
  pointer-events: none;
  background: transparent;
}
.wt-tooltip {
  position: fixed;
  z-index: 10000;
  background: #fff;
  border-radius: 14px;
  padding: 18px 20px;
  max-width: 280px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  transition: all 0.35s cubic-bezier(.4,0,.2,1);
  pointer-events: auto;
}
/* Mobile: bottom-sheet walkthrough with dim overlay */
@media (max-width: 600px) {
  #walkthrough-overlay.active {
    background: rgba(15, 23, 42, 0.6) !important;
    pointer-events: auto !important;
  }
  .wt-spotlight {
    box-shadow: none !important;
    background: transparent !important;
    pointer-events: none !important;
    z-index: -1 !important;
    display: none !important;
  }
  .wt-pulse { display: none !important; }
  .wt-tooltip {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 80px !important;
    top: auto !important;
    max-width: none !important;
    width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    box-shadow: 0 -8px 40px rgba(0,0,0,0.25) !important;
    padding: 24px 20px calc(env(safe-area-inset-bottom, 20px) + 20px) !important;
    z-index: 10000 !important;
  }
  .wt-tooltip h3 { font-size: 18px !important; margin-bottom: 6px !important; }
  .wt-tooltip p { font-size: 15px !important; line-height: 1.6 !important; margin-bottom: 18px !important; }
  .wt-steps { font-size: 13px !important; }
  .wt-skip { font-size: 15px !important; padding: 10px 16px !important; }
  .wt-next { font-size: 15px !important; padding: 10px 24px !important; border-radius: 10px !important; }
  /* Bottom sheet drag handle */
  .wt-tooltip::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: #cbd5e1;
    border-radius: 2px;
    margin: 0 auto 14px;
  }
}
.wt-tooltip h3 {
  font-size: 15px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 4px;
}
.wt-tooltip p {
  font-size: 13px;
  color: #64748b;
  line-height: 1.5;
  margin-bottom: 14px;
}
.wt-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.wt-steps {
  font-size: 12px;
  color: #94a3b8;
  font-weight: 600;
}
.wt-actions {
  display: flex;
  gap: 8px;
}
.wt-skip {
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 8px;
}
.wt-skip:hover { background: #f1f5f9; }
.wt-next {
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.wt-next:hover { background: #1d4ed8; }
.wt-pulse {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: wtPulse 1.5s ease-out infinite;
}
@keyframes wtPulse {
  0% { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* ===== FIELD KPI DASHBOARD ===== */
#kpi-dashboard-overlay {
  position: fixed; inset: 0; z-index: 9997;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px;
  animation: ldFadeIn 0.2s;
}
@keyframes ldFadeIn { from { opacity: 0; } to { opacity: 1; } }
.ld-container {
  background: var(--bg); border-radius: 20px;
  box-shadow: 0 24px 48px rgba(0,0,0,0.2);
  width: 100%; max-width: 900px;
  animation: ldScaleIn 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  overflow: hidden;
}
@keyframes ldScaleIn { from { opacity: 0; transform: scale(0.95) translateY(12px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.ld-header {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.ld-header h2 { margin: 0; font-size: 20px; font-weight: 700; }

/* kpi sticky header — combines title + filters into one fixed bar */
.kpi-sticky-header {
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px 16px 8px; position: sticky; top: 0; z-index: 2;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.kpi-title-row {
  display: flex; align-items: center; gap: 8px; width: 100%;
}
.kpi-title-row h2 { margin: 0; font-size: 18px; font-weight: 700; flex: 1; }
.kpi-title-row .back-btn { font-size: 20px; }
.kpi-email-btn {
  padding: 5px 12px; border-radius: 8px; font-size: 12px; font-weight: 600;
  background: #3b82f6; color: #fff; border: none; cursor: pointer;
  white-space: nowrap; transition: background 0.15s;
}
.kpi-email-btn:hover { background: #2563eb; }
.kpi-email-btn:disabled { opacity: 0.5; cursor: default; }
.kpi-filter-row {
  display: flex; align-items: center; gap: 6px; width: 100%;
}
.kpi-filter-row select {
  padding: 5px 8px; border-radius: 8px; font-size: 12px;
  border: 1px solid var(--border); background: var(--bg2); color: var(--text);
  margin-left: auto; max-width: 140px;
}
.ld-close {
  background: var(--bg3); border: none; width: 32px; height: 32px;
  border-radius: 50%; font-size: 18px; color: var(--text2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.ld-close:hover { background: var(--border); color: var(--text); }
.ld-body { padding: 16px; }
.ld-metrics { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 16px; }
.ld-metric-card {
  background: var(--bg2); border-radius: 12px; padding: 12px;
  border: 1px solid var(--border); text-align: center;
}
.ld-metric-val { font-size: 28px; font-weight: 700; color: var(--text); }
.ld-metric-label { font-size: 11px; color: var(--text2); margin-top: 4px; }

/* kpi filter controls */
.kpi-filters { margin-bottom: 0; display: flex; flex-direction: column; gap: 4px; width: 100%; }
.kpi-view-toggle, .kpi-time-toggle { display: flex; gap: 4px; flex-shrink: 0; }
.kpi-pill {
  padding: 6px 14px; border-radius: 20px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border); background: var(--bg2); color: var(--text2);
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.kpi-pill:hover { background: var(--bg3); color: var(--text); }
.kpi-pill.active { background: #3b82f6; color: #fff; border-color: #3b82f6; }
/* kpi-supplier-row kept for backwards compat */
.kpi-supplier-row { margin-left: auto; }
.kpi-supplier-row select {
  padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg2); color: var(--text);
  font-size: 12px;
}

/* kpi section headers */
.kpi-section-header {
  font-size: 12px; font-weight: 700; color: var(--text2);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 8px; padding-bottom: 4px;
  border-bottom: 2px solid var(--border);
}

/* kpi tasting list */
.kpi-tasting-list {
  background: var(--bg2); border-radius: 12px; border: 1px solid var(--border);
  margin-bottom: 16px; overflow: hidden;
}
.kpi-tasting-item {
  padding: 8px 12px; border-bottom: 1px solid var(--border);
}
.kpi-tasting-item:last-child { border-bottom: none; }
.kpi-tasting-product { font-size: 13px; font-weight: 600; }
.kpi-tasting-notes { font-size: 12px; color: var(--text2); margin-top: 2px; }
.kpi-tasting-account { font-size: 11px; color: var(--text3, #999); margin-top: 2px; font-style: italic; }

/* mobile responsive */
@media (max-width: 768px) {
  #kpi-dashboard-overlay { padding: 0; }
  #kpi-dashboard-overlay .ld-container { max-width: 100%; border-radius: 0; overflow: visible !important; flex-shrink: 0; }
  .ld-metrics { grid-template-columns: 1fr 1fr !important; }
  .ld-metric-val { font-size: 24px; }
  .kpi-filters { gap: 6px; }
  .kpi-pill { padding: 5px 10px; font-size: 11px; }
  .kpi-sticky-header { padding: 10px 12px; }
  .kpi-filter-row { gap: 6px; }
  .kpi-filter-row select { font-size: 11px; padding: 4px 6px; max-width: 120px; }
  .kpi-title-row h2 { font-size: 16px; }
  .ld-body { padding: 16px; }
}

#mobile-dashboard-btn { display: none; }

/* Desktop filters row — unused, kept for backwards compat */
.desktop-filters { display: none; }

/* Desktop: map-top (2/3) + bottom-panel columns layout */
@media (min-width: 769px) {
  #app {
    flex-direction: column !important;
  }
  #map-container {
    order: 1;
    flex: 2 !important;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  #map-container #fb-bar {
    position: relative;
    top: auto; left: auto; right: auto;
    border-radius: 0;
    box-shadow: none;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  #map-container #map {
    flex: 1;
    min-height: 0;
  }
  #sidebar {
    order: 2;
    width: 100% !important;
    height: 34vh !important;
    flex: none !important;
    min-height: 0;
    border-right: none !important;
    border-top: 2px solid var(--accent);
    display: flex !important;
    flex-direction: column !important;
  }
  /* Hide sidebar header and tabs on desktop — replaced by column layout */
  .sidebar-header { display: none !important; }
  #main-tabs { display: none !important; }
  /* Show all panels as side-by-side columns */
  .tab-panel { display: none !important; }
  /* The column container replaces tabs */
  .desktop-columns {
    display: grid !important;
    grid-template-columns: repeat(5, 1fr);
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }
  .desktop-col {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    min-height: 0;
    overflow: hidden;
  }
  .desktop-col:last-child { border-right: none; }
  .desktop-col-header {
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .desktop-col-header .col-badge {
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 700;
  }
  .desktop-col-body {
    flex: 1;
    overflow-y: auto;
    font-size: 12px;
  }
  /* Compact intel stats inside desktop column */
  .desktop-col-body .territory-stat-grid { gap: 4px; margin-bottom: 6px; }
  .desktop-col-body .territory-stat { padding: 6px; border-radius: 6px; }
  .desktop-col-body .territory-stat-val { font-size: 14px; }
  .desktop-col-body .territory-section-title { font-size: 11px; margin: 4px 0 2px; }
  .desktop-col-body .territory-bar-row { font-size: 11px; padding: 2px 0; }
  .desktop-col-body .territory-bar-track { width: 40px; height: 4px; }
  /* Detail panel — full screen overlay on desktop */
  #detail-panel.active {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 9999;
    background: var(--bg2);
  }
  #detail-panel .detail-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
  }
  #detail-panel .back-btn {
    font-size: 22px;
    padding: 6px 12px;
    background: var(--bg3);
    border-radius: 8px;
    cursor: pointer;
  }
  /* Hide floating overlays — content is in columns */
  .route-panel { display: none !important; }
  .stops-bar { display: none !important; }
  .territory-panel { display: none !important; }
  /* Route action bar — hidden, replaced by header icons */
  .desktop-route-actions { display: none !important; }
  /* Route header icon buttons */
  .dra-icon {
    width: 26px; height: 26px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: 6px;
    background: var(--bg3); color: var(--text2);
    cursor: pointer; transition: background 0.15s, color 0.15s;
    padding: 0;
  }
  .dra-icon:first-child { background: var(--accent); color: #fff; border-color: var(--accent); }
  .dra-icon:first-child:hover { opacity: 0.85; }
  .dra-icon:hover { background: var(--border); color: var(--text); }
  .dra-icon-clear:hover { color: var(--red); }
}
/* Hide desktop-only elements by default (mobile) */
.desktop-columns { display: none; }
.desktop-route-actions { display: none; }
.desktop-brand-bar { display: none; }
#mobile-brand-bar { display: none; }
#mobile-back-btn { display: none; }
@media (min-width: 769px) {
  .desktop-brand-bar {
    display: flex !important;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    background: var(--bg);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    font-size: 12px;
  }
  .desktop-brand-bar img { opacity: 0.8; }
  .dbb-name { font-weight: 700; color: var(--text); font-size: 13px; }
  .dbb-sub { color: var(--text2); font-size: 11px; }
  .dbb-sep { width: 1px; height: 14px; background: var(--border); margin: 0 4px; }
  .dbb-disclaimer { color: var(--text2); font-size: 10px; opacity: 0.7; }
  .dbb-dashboard-btn {
    margin-left: auto;
    padding: 3px 10px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.15s;
  }
  .dbb-dashboard-btn:hover { opacity: 0.85; }
  .dbb-version { color: var(--text2); font-size: 10px; opacity: 0.5; }
}

/* Responsive: mobile */
@media (max-width: 768px) {
  :root { --sidebar-w: 100vw; }
  #app { display: block; position: relative; height: 100vh; height: 100dvh; overflow: hidden; }
  #map-container { position: absolute; top: 0; left: 0; right: 0; bottom: 0; height: 100vh; height: 100dvh; padding-bottom: 80px; }
  #sidebar {
    position: absolute;
    left: 0; right: 0; bottom: 80px;
    width: 100%;
    height: auto;
    max-height: calc(85vh - 80px); max-height: calc(85dvh - 80px);
    border-right: none;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
    z-index: 1100;
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  /* Bottom sheet drag handle */
  .sidebar-header::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    background: var(--border);
    border-radius: 4px;
  }
  .sidebar-header { position: relative; padding-top: 16px; touch-action: none; }

  /* Hide sidebar brand/settings on mobile — use bottom tab bar instead */
  .sidebar-header img,
  .sidebar-header .brand-text,
  .sidebar-header > span,
  #settings-btn, #clerk-user-button, #logout-btn { display: none !important; }

  /* Show help and bell in mobile sidebar header, right-aligned with 44px touch targets */
  #help-btn { margin-left: auto; min-width: 44px; min-height: 44px; justify-content: center; }
  #alert-bell { min-width: 44px; min-height: 44px; justify-content: center; }

  /* Bottom sheet states via transform — collapsed = just drag handle (~60px) */
  #sidebar.mobile-collapsed {
    transform: translateY(calc(100% + 100px));
    pointer-events: none;
  }
  #sidebar.mobile-peek {
    transform: translateY(calc(100% - 320px));
  }
  #sidebar.mobile-full {
    transform: translateY(0);
  }

  /* Hide sidebar search on mobile — replaced by fb-bar */
  #sidebar .search-bar { display: none; }
  /* Hide desktop state selector in sidebar on mobile — replaced by fb-bar */
  .state-selector { display: none; }
  /* Hide desktop tabs on mobile — replaced by bottom tab bar */
  #main-tabs { display: none; }

  /* Filter row — horizontal scroll strip */
  .filter-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 8px;
  }
  .filter-row::-webkit-scrollbar { display: none; }
  .filter-pill { min-height: 36px; display: flex; align-items: center; padding: 6px 12px; font-size: 12px; }
  .filter-select { min-height: 36px; font-size: 12px; }

  /* Results list — scrollable within bottom sheet */
  #results-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .result-card { padding: 14px 12px; }
  .result-name { font-size: 15px; }

  /* Save/route buttons — bigger tap targets */
  .save-btn { padding: 8px 14px; font-size: 12px; min-height: 36px; }
  .route-btn { padding: 8px 12px; font-size: 12px; min-height: 36px; }

  /* Detail panel — full screen slide-up on mobile */
  #detail-panel.active {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1200;
    background: var(--bg2);
    border-radius: 0;
  }
  .detail-header { padding: 16px 12px; padding-top: calc(env(safe-area-inset-top, 16px) + 8px); }
  .back-btn { font-size: 22px; padding: 8px; min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; }
  .status-pill { padding: 8px 14px; font-size: 13px; min-height: 40px; }
  .quick-action-btn { min-height: 40px; padding: 8px 12px; }

  /* Map count badge — move above bottom sheet handle */
  .map-count { bottom: 130px; }
  .list-toggle-btn { display: none; }

  /* Route panel — hidden on mobile, Route tab handles this */
  .route-panel { display: none !important; }

  /* Onboarding + auth */
  .onboarding-slide { max-width: 100%; padding: 20px 16px; }
  .onboarding-content h1 { font-size: 22px; }
  .feature-grid { grid-template-columns: 1fr; gap: 10px; }
  .wt-tooltip { max-width: 240px; padding: 14px 16px; }
  .auth-card { padding: 24px 16px; }
  .auth-row { flex-direction: column; gap: 12px; }
  .auth-state-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); max-height: 180px; }

  /* Hide static map legend on mobile — use fb-bar legend button */
  .map-legend { display: none; }

  /* CRM mode (leads tab) — full screen list above tab bar */
  #app.crm-mode #sidebar {
    transform: translateY(0) !important;
    top: 0; bottom: 80px;
    max-height: none;
    height: auto;
    border-radius: 0;
    box-shadow: none;
  }
  #app.crm-mode .sidebar-header { display: none; }
  #app.crm-mode #main-tabs { display: none; }

  /* ===== MOBILE BACK BUTTON ===== */
  #mobile-back-btn {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 10px 14px 8px 10px;
    background: var(--bg2);
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    color: var(--accent);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    padding-top: calc(env(safe-area-inset-top, 0px) + 10px);
  }
  #mobile-back-btn svg { width: 18px; height: 18px; }

  /* ===== MOBILE BRANDING BAR ===== */
  #mobile-brand-bar {
    display: flex !important;
    position: fixed;
    bottom: 56px; left: 0; right: 0;
    height: 36px;
    align-items: center;
    gap: 6px;
    padding: 0 12px;
    background: var(--bg);
    border-top: 1px solid var(--border);
    z-index: 1199;
  }
  #mobile-brand-bar img { opacity: 0.7; height: 16px; }
  .mbb-name { font-weight: 700; color: var(--text); font-size: 11px; }
  .mbb-sep { width: 1px; height: 10px; background: var(--border); }
  .mbb-disclaimer { color: var(--text2); font-size: 9px; opacity: 0.7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* ===== MOBILE BOTTOM TAB BAR ===== */
  #mobile-tab-bar {
    display: flex !important;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 56px;
    background: var(--bg2);
    border-top: 1px solid var(--border);
    z-index: 1200;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
  }
  .mtab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    background: none;
    border: none;
    color: var(--text2);
    font-size: 9px;
    font-weight: 600;
    cursor: pointer;
    padding: 3px 0;
    position: relative;
    -webkit-tap-highlight-color: transparent;
  }
  .mtab svg { width: 18px; height: 18px; }
  .mtab.active { color: var(--accent); }
  .mtab .mtab-badge {
    position: absolute;
    top: 2px;
    right: calc(50% - 16px);
    background: #ef4444;
    color: #fff;
    font-size: 9px;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    padding: 0 4px;
  }

  /* ===== MOBILE 2-ROW FILTER BAR ===== */
  #fb-bar {
    flex-wrap: wrap !important;
    gap: 4px !important;
    padding: 6px 8px !important;
  }
  /* Row 1: state + search fill the width */
  .fb-row-1 {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    order: 1;
  }
  .fb-row-1 .fb-search-wrap { flex: 1; }
  /* Row 2: filter pills scroll horizontally */
  .fb-row-2 {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    order: 2;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .fb-row-2::-webkit-scrollbar { display: none; }
  /* Hide the separators on mobile (rows handle grouping) */
  #fb-bar > .fb-sep { display: none; }
  /* Hide standalone items that are now inside row wrappers */
  #fb-bar > .fb-state-btn,
  #fb-bar > .fb-pill,
  #fb-bar > .fb-select,
  #fb-bar > .fb-search-wrap,
  #fb-bar > .fb-legend-btn,
  #fb-bar > .fb-legend-pill,
  #fb-bar > .fb-intel-pill,
  #fb-bar > .fb-refresh-btn,
  #fb-bar > #fb-new-pill { display: none !important; }

  /* Mobile info card — sit above tab bar */
  .mobile-info-card { bottom: 80px; }

  /* ===== MOBILE ROUTE MODE — split screen: map top, list bottom ===== */
  #app.route-mode #map-container {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 45%;
    bottom: auto;
    padding-bottom: 0;
  }
  #app.route-mode #sidebar {
    position: absolute;
    top: 45%; left: 0; right: 0; bottom: 80px;
    height: auto;
    max-height: none;
    transform: none !important;
    border-radius: 0;
    box-shadow: 0 -1px 0 var(--border);
    transition: none;
  }
  #app.route-mode .sidebar-header { display: none; }
  #app.route-mode #fb-bar { display: none; }
  #app.route-mode .map-count { display: none; }
  #app.route-mode .map-legend { display: none; }
  /* Hide license chrome in route mode — only show the route stops list */
  #app.route-mode #results-header { display: none; }
  .results-header { display: none !important; }
  #app.route-mode #brand-input-row { display: none !important; }
  #app.route-mode #target-banner { display: none !important; }
  #app.route-mode #stops-bar { display: none !important; }
  #app.route-mode .leaflet-control-zoom { display: block; }
  #app.route-mode .leaflet-top.leaflet-right { top: 8px !important; }

  /* ===== MOBILE LEADS — match license list format ===== */
  .lead-card {
    padding: 10px 12px;
    border-left-width: 3px;
  }
  .lead-card .result-name { font-size: 14px; }
  .lead-card .result-meta { font-size: 12px; }
  .lead-card .lead-remove { top: 6px; right: 6px; font-size: 14px; padding: 4px 6px; }
  .lead-card .badge, .lead-card .source-badge { font-size: 10px; }
  /* Hide the attention header search/filters on mobile for cleaner look */
  #panel-leads .lead-search-input { font-size: 14px; min-height: 44px; }
  #panel-leads .filter-pill { font-size: 11px; padding: 4px 10px; min-height: 36px; }

  #mobile-dashboard-btn {
    display: block; position: sticky; bottom: 0; z-index: 10;
    width: calc(100% - 24px); margin: 0 12px 12px;
    padding: 14px; background: #3b82f6; color: #fff;
    border: none; border-radius: 12px; font-size: 15px; font-weight: 600;
    cursor: pointer; text-align: center;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
  }
  #mobile-dashboard-btn:active { background: #2563eb; }

  /* ===== MOBILE SETTINGS ACTION SHEET ===== */
  #mobile-settings-sheet {
    position: fixed;
    inset: 0;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .mss-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: mssFadeIn 0.2s;
  }
  @keyframes mssFadeIn { from { opacity: 0; } to { opacity: 1; } }
  @keyframes mssScaleIn { from { opacity: 0; transform: scale(0.95) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
  .mss-panel {
    position: relative;
    z-index: 1;
    background: var(--bg2);
    border-radius: 20px;
    padding: 32px 28px 24px;
    animation: mssScaleIn 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    max-height: 80vh;
    overflow-y: auto;
    width: 380px;
    max-width: calc(100vw - 32px);
    box-shadow: 0 24px 48px rgba(0,0,0,0.2), 0 0 0 1px rgba(255,255,255,0.05);
  }
  .mss-handle { display: none; }
  .mss-close-btn {
    position: absolute;
    top: 12px; right: 12px;
    width: 32px; height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--bg3);
    color: var(--text2);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
  }
  .mss-close-btn:hover { background: var(--border); color: var(--text); }
  .mss-user {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 0 0 20px;
    border-bottom: none;
    margin-bottom: 0;
  }
  .mss-avatar {
    width: 64px; height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; font-weight: 700; color: #fff;
    margin-bottom: 12px;
    box-shadow: 0 4px 12px rgba(37,99,235,0.3);
  }
  .mss-user-name { font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
  .mss-user-email { color: var(--text2); font-size: 13px; margin-top: 2px; }
  .mss-user-role {
    font-size: 11px; color: var(--accent); text-transform: uppercase;
    letter-spacing: 0.5px; font-weight: 600; margin-top: 6px;
    background: rgba(37,99,235,0.08); padding: 3px 10px; border-radius: 20px;
  }
  .mss-actions {
    display: flex; flex-direction: column; gap: 2px;
    background: var(--bg3); border-radius: 14px;
    padding: 4px; margin-top: 16px;
  }
  .mss-action {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    background: none;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
  }
  .mss-action:hover { background: var(--bg2); }
  .mss-action:active { background: var(--bg2); }
  .mss-action svg { color: var(--text2); flex-shrink: 0; }
  .mss-action:hover svg { color: var(--accent); }
  .mss-danger { color: #dc2626; }
  .mss-danger svg { color: #dc2626; }
  .mss-danger:hover svg { color: #dc2626; }
  .mss-divider {
    height: 1px;
    background: var(--border);
    margin: 2px 8px;
    opacity: 0.5;
  }
  .mss-version {
    text-align: center;
    font-size: 11px;
    color: var(--text2);
    padding: 16px 0 0;
    opacity: 0.6;
  }
  /* Mobile override: bottom sheet */
  @media (max-width: 768px) {
    #mobile-settings-sheet { align-items: flex-end; }
    .mss-panel {
      width: 100%; max-width: 100%;
      border-radius: 20px 20px 0 0;
      padding: 8px 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
      animation: mssSlideUp 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    }
    @keyframes mssSlideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
    .mss-handle { display: block; width: 36px; height: 4px; background: var(--border); border-radius: 4px; margin: 0 auto 12px; }
    .mss-close-btn { display: none; }
    .mss-avatar { width: 48px; height: 48px; font-size: 18px; }
  }
}

/* App version footer (desktop sidebar) */
.app-version-footer {
  text-align: center;
  font-size: 11px;
  color: var(--text2);
  padding: 8px 0;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Mobile info card — replaces Leaflet popup on phones */
.mobile-info-card {
  display: none;
  position: fixed;
  left: 8px; right: 8px;
  bottom: 140px;
  z-index: 1150;
  background: var(--bg2);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.18);
  padding: 14px 14px 10px;
  touch-action: pan-x;
}
.mobile-info-card.active { display: block; }
.mobile-info-card .mic-name { font-size: 16px; font-weight: 700; margin-bottom: 2px; padding-right: 30px; }
.mobile-info-card .mic-addr { font-size: 12px; color: var(--text2); margin-bottom: 4px; }
.mobile-info-card .mic-phone { font-size: 12px; margin-bottom: 6px; }
.mobile-info-card .mic-phone a { color: var(--accent); text-decoration: none; }
.mobile-info-card .mic-meta { font-size: 11px; margin-bottom: 8px; display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.mobile-info-card .mic-actions { display: flex; gap: 6px; }
.mobile-info-card .mic-actions button,
.mobile-info-card .mic-actions a {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 10px 8px;
  border: none; border-radius: 8px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; min-height: 44px;
  text-decoration: none; text-align: center;
}
.mobile-info-card .mic-close {
  position: absolute; top: 10px; right: 10px;
  background: none; border: none;
  font-size: 20px; color: var(--text2); cursor: pointer;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
}
.mobile-info-card .mic-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 50%; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--text); cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.mobile-info-card .mic-nav.prev { left: -12px; }
.mobile-info-card .mic-nav.next { right: -12px; }
.mobile-info-card .mic-counter { font-size: 10px; color: var(--text2); text-align: center; margin-top: 6px; }

/* Quick-save toast (legacy) */
.quick-toast {
  position: fixed; bottom: 80px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #059669; color: #fff;
  padding: 10px 20px; border-radius: 24px;
  font-size: 13px; font-weight: 600;
  z-index: 9999; opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none; white-space: nowrap;
}
.quick-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== TOAST NOTIFICATION SYSTEM ===== */
#toast-container {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10001;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}
.toast-notification {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  pointer-events: auto;
  animation: toastSlideIn 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast-notification.toast-out {
  animation: toastSlideOut 0.25s cubic-bezier(0.55, 0.06, 0.68, 0.19) forwards;
}
.toast-notification.toast-success { background: #059669; }
.toast-notification.toast-error { background: #dc2626; }
.toast-notification.toast-info { background: #2563eb; }
.toast-notification svg { flex-shrink: 0; width: 16px; height: 16px; }
@keyframes toastSlideIn {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastSlideOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(16px) scale(0.9); }
}
@media (max-width: 768px) {
  #toast-container { bottom: 140px; }
}

/* ===== TOOLTIPS (desktop hover + mobile info icon) ===== */
.tooltip-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.tooltip-wrap .tooltip-text {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 8px;
  white-space: nowrap;
  max-width: 260px;
  white-space: normal;
  line-height: 1.4;
  z-index: 10002;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.tooltip-wrap .tooltip-text::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1e293b;
}
/* Desktop: show on hover */
@media (min-width: 769px) {
  .tooltip-wrap:hover .tooltip-text { display: block; }
  .tooltip-info-btn { display: none !important; }
}
/* Mobile: (i) button toggles tooltip */
.tooltip-info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 3px;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}
.tooltip-info-btn:active { background: var(--border); }
@media (max-width: 768px) {
  .tooltip-wrap .tooltip-text.mobile-visible {
    display: block;
    position: fixed;
    bottom: auto;
    top: auto;
    left: 16px;
    right: 16px;
    transform: none;
    max-width: none;
    text-align: center;
    z-index: 10003;
    animation: toastSlideIn 0.2s ease;
  }
  .tooltip-wrap .tooltip-text.mobile-visible::after { display: none; }
}

/* ===== STATE SELECTION MODAL ===== */
#state-welcome-modal {
  position: fixed;
  inset: 0;
  z-index: 10005;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}
#state-welcome-modal.hidden { display: none; }
.swm-card {
  background: #fff;
  border-radius: 20px;
  padding: 32px 28px;
  max-width: 420px;
  width: calc(100vw - 32px);
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 24px 48px rgba(0,0,0,0.2);
  animation: mssScaleIn 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  text-align: center;
}
.swm-logo { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 16px; }
.swm-logo img { height: 36px; }
.swm-logo span { font-size: 17px; font-weight: 800; color: var(--text); }
.swm-title { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.swm-subtitle { font-size: 14px; color: var(--text2); margin-bottom: 24px; line-height: 1.4; }
.swm-select {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 600;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
  min-height: 52px;
}
.swm-select:focus { border-color: var(--accent); }
.swm-go-btn {
  width: 100%;
  padding: 14px;
  margin-top: 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  min-height: 52px;
  transition: background 0.15s;
}
.swm-go-btn:hover { background: #1d4ed8; }
.swm-go-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.swm-skip {
  display: inline-block;
  margin-top: 12px;
  background: none;
  border: none;
  color: var(--text2);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
}
.swm-skip:hover { color: var(--text); }
@media (max-width: 768px) {
  .swm-card { padding: 28px 20px; border-radius: 16px; }
  .swm-select { font-size: 18px; min-height: 56px; }
  .swm-go-btn { font-size: 18px; min-height: 56px; }
}

/* Route stop drag handle + reorder buttons (mobile) */
.route-drag-handle {
  display: none;
  color: var(--text2); font-size: 14px;
  cursor: grab; padding: 4px; touch-action: none;
  user-select: none; -webkit-user-select: none;
}
.route-reorder-btns { display: none; }
@media (max-width: 768px) {
  .route-drag-handle { display: flex; align-items: center; }
  .route-reorder-btns {
    display: flex; flex-direction: column; gap: 1px;
  }
  .route-reorder-btn {
    background: none; border: none;
    color: var(--text2); font-size: 12px;
    padding: 2px 4px; cursor: pointer;
    min-width: 28px; min-height: 22px;
    display: flex; align-items: center; justify-content: center;
  }
  .route-reorder-btn:active { color: var(--accent); }
  .route-stop { min-height: 44px; padding: 8px 0; }
  .route-stop-remove { min-width: 36px; min-height: 36px; font-size: 18px; }
}

/* =========================================================================
   Zillow-style filter bar
   ========================================================================= */
#fb-bar {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  z-index: 1050;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg2);
  border-radius: 12px;
  padding: 6px 10px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.15);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#fb-bar::-webkit-scrollbar { display: none; }

.fb-state-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  min-height: 36px;
  flex-shrink: 0;
}
.fb-state-btn:hover { opacity: 0.9; }
.fb-state-arrow { font-size: 10px; opacity: 0.8; }
.fb-state-icon { flex-shrink: 0; opacity: 0.85; display: none; }

.fb-sep {
  width: 1px;
  height: 22px;
  background: var(--border);
  flex-shrink: 0;
}

.fb-pill {
  padding: 5px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 32px;
  line-height: 1;
}
.fb-pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.fb-pill:hover:not(.active) { border-color: var(--text2); }
.fb-nearme-pill.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.fb-nearme-pill.loading { opacity: 0.6; pointer-events: none; }
.fb-new-count { display: none; background: #c2410c; color: #fff; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 10px; margin-left: 3px; min-width: 18px; text-align: center; }
.fb-new-count:not(:empty) { display: inline-block; }

/* pulsing blue dot for user location */
@keyframes location-pulse {
  0% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.5); }
  70% { box-shadow: 0 0 0 12px rgba(37, 99, 235, 0); }
  100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}
.user-location-dot {
  background: #2563eb;
  border: 2px solid #fff;
  border-radius: 50%;
  animation: location-pulse 2s ease-out infinite;
}

.fb-select {
  padding: 5px 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  outline: none;
  flex-shrink: 0;
  min-height: 32px;
  white-space: nowrap;
}

.fb-search-wrap {
  display: flex;
  align-items: center;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px;
  gap: 6px;
  flex-shrink: 0;
  min-width: 140px;
  min-height: 32px;
}
.fb-search-wrap svg { color: var(--text2); flex-shrink: 0; }
#fb-search-input {
  border: none;
  background: none;
  outline: none;
  font-size: 12px;
  color: var(--text);
  width: 100%;
}

.fb-legend-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 11px;
  color: var(--text2);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 32px;
}
.fb-legend-btn:hover { border-color: var(--text2); color: var(--text); }
.fb-legend-btn svg { flex-shrink: 0; }

.fb-legend-popup {
  display: none;
  position: absolute;
  top: calc(8px + 52px);
  right: 8px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  z-index: 2000;
  padding: 10px 14px;
  min-width: 140px;
}
.fb-legend-popup.visible { display: block; }
.fb-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
  padding: 3px 0;
  white-space: nowrap;
}
.fb-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.1);
}

/* Filter bar state dropdown */
#fb-state-dropdown {
  position: absolute;
  top: calc(8px + 52px);
  left: 8px;
  min-width: 220px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 2000;
  padding: 4px;
  display: none;
}
#fb-state-dropdown.open { display: block; }

/* Mobile: larger touch targets, 2-row filter bar, safe area */
@media (max-width: 768px) {
  #fb-bar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    border-radius: 0 !important;
    padding-top: calc(env(safe-area-inset-top, 0px) + 6px) !important;
    box-shadow: 0 1px 6px rgba(0,0,0,0.1) !important;
  }
  #map-container {
    padding-top: 90px;
  }
  .fb-row-1 .fb-state-btn {
    min-height: 32px;
    padding: 4px 10px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0;
    box-shadow: 0 1px 4px rgba(37, 99, 235, 0.3);
    gap: 4px;
  }
  .fb-row-1 .fb-state-icon { display: inline-block; }
  .fb-row-2 .fb-pill { min-height: 28px; padding: 3px 8px; font-size: 11px; }
  .fb-row-2 .fb-select { min-height: 28px; padding: 2px 4px; font-size: 11px; }
  .fb-row-1 .fb-search-wrap {
    flex: 1;
    min-height: 32px;
    min-width: 0;
    max-width: 150px;
    padding: 4px 10px;
    background: var(--bg3) !important;
    border: 1px solid var(--border) !important;
    border-radius: 20px !important;
    gap: 6px;
  }
  .fb-row-1 .fb-search-wrap input {
    border: none !important;
    background: none !important;
    outline: none !important;
    font-size: 13px;
    color: var(--text2);
    width: 100%;
    box-shadow: none !important;
  }
  #fb-state-dropdown {
    top: calc(env(safe-area-inset-top, 0px) + 110px);
    left: 8px;
    right: 8px;
    min-width: auto;
  }
  .fb-row-1 .fb-legend-btn { min-height: 32px; padding: 4px 8px; font-size: 11px; }
  .fb-legend-popup {
    top: calc(env(safe-area-inset-top, 0px) + 110px);
    right: 8px;
    left: auto;
  }
  /* Existing mobile filter pills — increase for touch */
  .filter-pill { min-height: 44px !important; display: flex; align-items: center; }
  .filter-select { min-height: 44px !important; }
  /* Save/route/customer buttons — 44px on mobile */
  .save-btn, .route-btn, .customer-btn { min-height: 44px; padding: 8px 14px; }
  /* Body text minimum 14px on mobile */
  .result-meta { font-size: 14px; }
  /* Leaflet zoom controls below 2-row bar */
  .leaflet-top.leaflet-right { top: calc(env(safe-area-inset-top, 0px) + 120px) !important; }
}
/* Issue date badges (RUB-259) */
.badge-new-license { background: #22c55e; color: white; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-recent-license { background: #3b82f6; color: white; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.issue-date-muted { font-size: 11px; color: var(--text2); }

/* Alert bell icon (RUB-265) */
.alert-bell { position: relative; cursor: pointer; padding: 6px; background: none; border: none; color: var(--text2); display: flex; align-items: center; border-radius: 6px; }
.alert-bell:hover { color: var(--text); }
.alert-badge { position: absolute; top: 0; right: 0; background: #ef4444; color: white; font-size: 10px; font-weight: 700; border-radius: 50%; min-width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; }

/* Help button (RUB-261) */
.help-btn { background: none; border: none; color: var(--text2); cursor: pointer; padding: 6px; border-radius: 6px; display: flex; align-items: center; }
.help-btn:hover { color: var(--text); }
.help-overlay { position: fixed; inset: 0; z-index: 9999; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; }
.help-modal { background: #fff; border-radius: 12px; padding: 24px; max-width: 400px; width: 90%; box-shadow: 0 20px 60px rgba(0,0,0,0.15); }
.help-modal h2 { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 16px; }
.help-tip { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.help-tip:last-of-type { border-bottom: none; }
.help-tip-icon { font-size: 18px; flex-shrink: 0; width: 28px; text-align: center; }
.help-tip-text { font-size: 13px; color: var(--text); line-height: 1.4; }
.help-tip-text strong { display: block; font-size: 14px; margin-bottom: 2px; }
.help-close-btn { margin-top: 16px; width: 100%; padding: 10px; background: var(--accent); color: #fff; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.help-close-btn:hover { opacity: 0.9; }

/* Enhanced empty state (RUB-263) */
.empty-state h3 { margin: 16px 0 8px; color: #334155; font-size: 16px; font-weight: 600; }
.empty-state p { font-size: 14px; color: #64748b; }
.empty-state-clear-btn {
  margin-top: 16px;
  padding: 8px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.empty-state-clear-btn:hover { opacity: 0.85; }

/* New This Week prominent pill (RUB-262) */
.new-week-pill { display: inline-flex; align-items: center; gap: 5px; padding: 6px 14px; background: linear-gradient(135deg, #fff7ed 0%, #fff1e6 100%); border: 1.5px solid #fb923c; border-radius: 20px; font-size: 12px; font-weight: 700; color: #c2410c; cursor: pointer; transition: all 0.2s; white-space: nowrap; }
.new-week-pill:hover { background: linear-gradient(135deg, #ffedd5 0%, #ffe4cc 100%); border-color: #f97316; }
.new-week-pill.active { background: #f97316; color: #fff; border-color: #f97316; }
.new-week-pill .nw-dot { width: 8px; height: 8px; background: #f97316; border-radius: 50%; animation: freshPulse 2s ease-in-out infinite; }
.new-week-pill.active .nw-dot { background: #fff; }
.new-week-pill .nw-count { display: inline-block; background: #c2410c; color: #fff; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 10px; min-width: 18px; text-align: center; }
.new-week-pill.active .nw-count { background: rgba(255,255,255,0.3); color: #fff; }
.new-week-pill.has-count { animation: pillGlow 3s ease-in-out infinite; }
.new-week-pill.active.has-count { animation: none; }
@keyframes pillGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(249,115,22,0); }
  50% { box-shadow: 0 0 0 4px rgba(249,115,22,0.25); }
}

/* ===== LASSO CONTROL — separate from zoom buttons ===== */
.leaflet-control-lasso {
  margin-top: 20px !important;
}

/* ===== WAREHOUSE PINS ===== */
.warehouse-pin {
  background: none !important;
  border: none !important;
}

/* ===== REFRESH BUTTON ===== */
.fb-refresh-btn {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  flex-shrink: 0;
  color: var(--text2);
  font-size: 16px;
  display: flex;
  align-items: center;
}

/* ===== MAP CORNER LEGEND ===== */
.map-corner-legend {
  position: absolute;
  bottom: 140px;
  left: 10px;
  z-index: 500;
  background: var(--bg2);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  font-size: 11px;
  cursor: pointer;
  overflow: hidden;
}
.mcl-toggle {
  padding: 6px 10px;
  font-weight: 600;
  color: var(--text2);
  text-align: center;
}
.mcl-items {
  display: none;
  padding: 4px 10px 8px;
}
.map-corner-legend.expanded .mcl-items { display: block; }
.map-corner-legend.expanded .mcl-toggle::after { content: ''; }

/* ===== COLLAPSIBLE SECTIONS ===== */
.collapsible-header {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.collapsible-chevron {
  font-size: 14px;
  color: var(--text2);
  transition: transform 0.2s;
}
.collapsible-section.open .collapsible-chevron {
  transform: rotate(90deg);
}
.collapsible-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
}

/* ===== ORDER ENTRY ===== */
.oe-toggle {
  display: flex;
  gap: 0;
  background: var(--bg3);
  border-radius: 10px;
  padding: 3px;
}
.oe-toggle-btn {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: var(--text2);
  transition: all 0.15s;
}
.oe-toggle-btn.active {
  background: var(--bg2);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.oe-send-btn {
  padding: 6px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.oe-send-btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}
.oe-add-line-btn {
  width: 100%;
  padding: 10px;
  background: var(--bg3);
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  margin-top: 8px;
}
.oe-add-line-btn:active { background: #e2e8f0; }
.oe-line {
  background: var(--bg2);
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
}
.oe-line-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.oe-line-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--text2);
}
.oe-line-delete {
  background: none;
  border: none;
  font-size: 18px;
  color: #94a3b8;
  cursor: pointer;
  padding: 0 4px;
}
.oe-line-delete:hover { color: #ef4444; }
.oe-field { margin-bottom: 8px; }
.oe-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}
.oe-field input, .oe-field textarea {
  width: 100%;
  padding: 8px 10px;
  font-size: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  box-sizing: border-box;
}
.oe-field input:focus, .oe-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}
/* hide spinner arrows on number inputs in order entry */
.oe-field input[type="number"]::-webkit-inner-spin-button,
.oe-field input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.oe-field input[type="number"] {
  -moz-appearance: textfield;
}
.oe-field-row {
  display: flex;
  gap: 8px;
}
.oe-product-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg2);
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  max-height: 160px;
  overflow-y: auto;
  margin-top: 2px;
}
.oe-dropdown-item {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  border-bottom: 1px solid #f1f5f9;
}
.oe-dropdown-item:last-child { border-bottom: none; }
.oe-dropdown-item:hover { background: #f1f5f9; }
.oe-dropdown-meta { font-size: 11px; color: #999; white-space: nowrap; margin-left: 8px; }
.oe-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.oe-popup {
  background: var(--bg2);
  border-radius: 16px;
  padding: 24px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 24px 48px rgba(0,0,0,0.2);
}
.oe-popup h3 { margin: 0 0 16px; font-size: 18px; }
.oe-popup textarea {
  width: 100%;
  padding: 8px 10px;
  font-size: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  resize: vertical;
  box-sizing: border-box;
}
.oe-popup-cancel {
  flex: 1;
  padding: 10px;
  background: var(--bg3);
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text2);
}
.oe-popup-submit {
  flex: 1;
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* ===== PRODUCT SUGGESTIONS DROPDOWN ===== */
.product-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 40px;
  z-index: 100;
  background: var(--bg2);
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  max-height: 200px;
  overflow-y: auto;
  margin-top: 2px;
}
.product-suggestion-item {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  border-bottom: 1px solid #f1f5f9;
}
.product-suggestion-item:last-child { border-bottom: none; }
.product-suggestion-item:hover { background: #f1f5f9; }
.psi-name { font-weight: 500; color: var(--text); }
.psi-supplier { font-size: 11px; color: var(--text2); }

/* ===== PRODUCTS MANAGER ===== */
#products-manager,
#territory-manager,
#warehouse-manager {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.pm-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg2);
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.pm-header h2 {
  flex: 1;
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.pm-back {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--accent);
  display: flex;
  align-items: center;
}
.pm-add-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.pm-add-btn:active { opacity: 0.8; }
.pm-search {
  padding: 8px 12px 0;
}
.pm-search input {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: var(--bg2);
  color: var(--text);
  box-sizing: border-box;
}
.pm-search input:focus {
  outline: none;
  border-color: var(--accent);
}
.pm-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pm-empty {
  text-align: center;
  color: var(--text2);
  font-size: 14px;
  padding: 40px 20px;
}
.pm-card {
  background: var(--bg2);
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  overflow: visible;
}
.pm-list-row {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
}
.pm-list-row:active { background: #f1f5f9; }
.pm-list-name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pm-list-meta {
  font-size: 12px;
  color: var(--text2);
  margin-top: 2px;
}
.pm-list-supplier {
  font-size: 11px;
  color: var(--text2);
  white-space: nowrap;
  margin-left: 8px;
}
.pm-list-actions {
  display: flex;
  gap: 4px;
  margin-left: 8px;
  flex-shrink: 0;
}
.pm-action-btn {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  background: #eef2ff;
  color: #4f46e5;
  cursor: pointer;
  white-space: nowrap;
}
.pm-action-btn:active { background: #dbeafe; }
.pm-done-btn {
  flex: 1;
  padding: 7px;
  background: var(--bg3);
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text2);
}
.pm-type-toggle {
  display: flex;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  overflow: hidden;
}
.pm-type-btn {
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 600;
  border: none;
  background: var(--bg);
  color: var(--text2);
  cursor: pointer;
}
.pm-type-btn.active {
  background: #eef2ff;
  color: #4f46e5;
}
.pm-delete-btn {
  padding: 7px 14px;
  background: none;
  border: 1px solid #fecaca;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: #dc2626;
}
.pm-list-arrow {
  display: none;
  font-size: 20px;
  color: #cbd5e1;
  margin-left: 8px;
  font-weight: 300;
}
.pm-edit-form {
  border-top: 1px solid #e2e8f0;
}
.pm-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg3);
  border-bottom: 1px solid #e2e8f0;
}
.pm-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.pm-card-delete {
  background: none;
  border: none;
  font-size: 20px;
  color: #94a3b8;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.pm-card-delete:hover { color: #ef4444; }
.pm-card-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 8px 12px;
}
.pm-card-fields .pm-field-full {
  grid-column: 1 / -1;
}
.pm-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}
.pm-field input {
  width: 100%;
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  box-sizing: border-box;
}
.pm-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}

/* user manager panel — tab styles (reuses pm-* for header/body/cards) */
#user-manager {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.um-tabs {
  display: flex;
  border-bottom: 1px solid #e2e8f0;
  background: var(--bg2);
  padding: 0 12px;
}
.um-tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  margin-bottom: -1px;
}
.um-tab-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
#um-users-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
#um-company-products-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* user manager inline edit panel */
.um-edit-panel {
  padding: 12px 16px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}
.um-edit-section {
  margin-bottom: 14px;
}
.um-edit-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.um-edit-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 4px;
}
.um-edit-row {
  margin-bottom: 8px;
}
.um-edit-input {
  width: 100%;
  max-width: 280px;
  padding: 6px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  background: #fff;
  outline: none;
}
.um-edit-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}

/* state/city chip grid */
.um-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 120px;
  overflow-y: auto;
}
.um-chip {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  background: #e2e8f0;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, color 0.15s;
}
.um-chip:hover {
  background: #cbd5e1;
}
.um-chip-selected {
  background: var(--accent);
  color: #fff;
}
.um-chip-selected:hover {
  background: #1d4ed8;
}

/* toggle switch */
.um-toggle-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  max-width: 280px;
}
.um-toggle-label input[type="checkbox"] {
  position: relative;
  width: 36px;
  height: 20px;
  appearance: none;
  -webkit-appearance: none;
  background: #cbd5e1;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
  margin-left: 12px;
}
.um-toggle-label input[type="checkbox"]:checked {
  background: var(--accent);
}
.um-toggle-label input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}
.um-toggle-label input[type="checkbox"]:checked::after {
  transform: translateX(16px);
}

/* add user form grid */
.um-add-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.um-add-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 2px;
}
.um-add-field .um-edit-input {
  max-width: none;
}

/* ===== PWA INSTALL BANNER ===== */
.pwa-install-banner {
  position: fixed;
  bottom: -120px;
  left: 0;
  right: 0;
  z-index: 9998;
  padding: 0 12px 12px;
  transition: bottom 0.3s ease-out;
  pointer-events: none;
}
.pwa-install-banner.pwa-banner-visible {
  bottom: 12px;
  pointer-events: auto;
}
.pwa-banner-content {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 480px;
  margin: 0 auto;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
}
.pwa-banner-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  flex-shrink: 0;
}
.pwa-banner-text {
  flex: 1;
  min-width: 0;
}
.pwa-banner-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}
.pwa-banner-desc {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.4;
  margin-top: 2px;
}
.pwa-banner-desc strong {
  color: var(--text);
}
.pwa-share-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  vertical-align: -2px;
  color: var(--accent);
}
.pwa-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.pwa-banner-install {
  padding: 8px 18px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.pwa-banner-install:active {
  opacity: 0.85;
}
.pwa-banner-dismiss {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}
.pwa-banner-dismiss:hover {
  color: var(--text);
}

/* on mobile, bump banner above the tab bar */
@media (max-width: 768px) {
  .pwa-install-banner.pwa-banner-visible {
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  }
}
