  * { margin: 0; padding: 0; box-sizing: border-box; }
  body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; overflow: hidden; }
  #map { width: 100vw; height: 100vh; }

  /* Marker clusters — Site layer (default): all blue */
  .marker-cluster-small,
  .marker-cluster-medium,
  .marker-cluster-large       { background-color: rgba(59, 130, 246, 0.3); }
  .marker-cluster-small  div,
  .marker-cluster-medium div,
  .marker-cluster-large  div  { background-color: rgba(59, 130, 246, 0.6); color: #fff; }

  /* Marker clusters — Machine layer: all yellow */
  body.machine-mode .marker-cluster-small,
  body.machine-mode .marker-cluster-medium,
  body.machine-mode .marker-cluster-large       { background-color: rgba(234, 179, 8, 0.3); }
  body.machine-mode .marker-cluster-small  div,
  body.machine-mode .marker-cluster-medium div,
  body.machine-mode .marker-cluster-large  div  { background-color: rgba(234, 179, 8, 0.85); color: #fff; }

  .panel {
    position: absolute;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.12), 0 1px 4px rgba(0,0,0,0.08);
    z-index: 1000;
    overflow: hidden;
    border: 1px solid #e5e7eb;
  }

  .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 600;
    font-size: 14px;
    color: #1e293b;
  }

  .panel-close {
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 16px;
    transition: all 0.15s;
  }
  .panel-close:hover { background: #f1f5f9; color: #1e293b; }

  .panel-header-clear {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 6px;
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    white-space: nowrap;
    line-height: 1.4;
  }
  .panel-header-clear:hover  { background: #93c5fd; color: #1e3a8a; border-color: #60a5fa; }
  .panel-header-clear:active { background: #60a5fa; color: #ffffff; border-color: #3b82f6; }

  /* Export / Exclude header buttons (directions panel) — layer-dependent palette */
  body.machine-mode #dir-export-btn,
  body.machine-mode #dir-exclude-btn {
    background: #fef3c7; color: #92400e; border-color: #fcd34d;
  }
  body.machine-mode #dir-export-btn:hover,
  body.machine-mode #dir-exclude-btn:hover {
    background: #fcd34d; color: #78350f; border-color: #f59e0b;
  }
  body.machine-mode #dir-export-btn:active,
  body.machine-mode #dir-exclude-btn:active {
    background: #f59e0b; color: #ffffff; border-color: #d97706;
  }

  /* Clear / Clear All buttons — always red, not layer-dependent */
  body #dir-clear-btn,
  body #search-clear-btn,
  body #clear-filters,
  body #clear-attr-filters,
  body #excluded-clear-btn,
  body #custom-data-clear-btn,
  body #btn-clear-filters {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
  }
  body #dir-clear-btn:hover,
  body #search-clear-btn:hover,
  body #clear-filters:hover,
  body #clear-attr-filters:hover,
  body #excluded-clear-btn:hover,
  body #btn-clear-filters:hover {
    background: #fecaca; color: #991b1b; border-color: #fca5a5;
  }
  body #dir-clear-btn:active,
  body #search-clear-btn:active,
  body #clear-filters:active,
  body #clear-attr-filters:active,
  body #excluded-clear-btn:active,
  body #btn-clear-filters:active {
    background: #ef4444; color: #ffffff; border-color: #dc2626;
  }

  .panel-body {
    padding: 12px 16px;
    overflow-y: auto;
  }

  /* Search Panel - Top Right (Blue) */
  #search-panel {
    top: 16px;
    right: 16px;
    width: 300px;
    border-color: #bfdbfe;
  }
  #search-panel .panel-header { background: #eff6ff; color: #1e40af; border-bottom-color: #bfdbfe; }
  #search-panel .panel-body { padding: 12px 16px; }
  #search-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    color: #1e293b;
    transition: border-color 0.15s;
  }
  #search-input:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
  #search-input::placeholder { color: #94a3b8; }

  /* Site Filter Panel - Right (Amber) */
  /* Clear-filters button between Search and Site Filter panels */
  #btn-clear-filters {
    position: absolute;
    top: 122px;
    right: 16px;
    width: 300px;
    height: 34px;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #dbeafe;        /* pastel blue */
    color: #1e40af;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: background 0.15s, color 0.15s, border-color 0.15s;
  }
  #btn-clear-filters:hover  { background: #93c5fd; color: #1e3a8a; border-color: #60a5fa; }
  #btn-clear-filters:active { background: #60a5fa; color: #ffffff; border-color: #3b82f6; }

  #filter-panel {
    top: 164px;
    right: 16px;
    width: 300px;
    height: auto;
    display: flex;
    flex-direction: column;
    border-color: #fde68a;
  }
  #filter-panel .panel-header { background: #fffbeb; color: #92400e; border-bottom-color: #fde68a; flex-shrink: 0; }
  #filter-panel .panel-body { flex: 1; overflow-y: auto; }

  /* Attributes Filter Panel - Right (Indigo) */
  #attr-filter-panel {
    /* top set dynamically by JS based on site filter height */
    bottom: 16px;
    right: 16px;
    width: 300px;
    display: flex;
    flex-direction: column;
    border-color: #c7d2fe;
  }
  #attr-filter-panel .panel-header { background: #eef2ff; color: #3730a3; border-bottom-color: #c7d2fe; flex-shrink: 0; }
  #attr-filter-panel .panel-body { flex: 1; overflow-y: auto; }
  .filter-group {
    margin-bottom: 4px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    overflow: hidden;
  }
  .filter-group:last-child { margin-bottom: 0; }
  .filter-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f8fafc;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
  }
  .filter-toggle:hover { background: #f1f5f9; }
  .filter-toggle-label {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  .filter-toggle-right {
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .filter-toggle-count {
    font-size: 10px;
    background: #3b82f6;
    color: #fff;
    border-radius: 8px;
    padding: 1px 6px;
    font-weight: 600;
    display: none;
  }
  .filter-toggle-arrow {
    font-size: 10px;
    color: #94a3b8;
    transition: transform 0.2s;
  }
  .filter-group.open .filter-toggle-arrow { transform: rotate(180deg); }
  .filter-collapse-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
  }
  .filter-group.open .filter-collapse-body {
    max-height: 300px;
    overflow-y: auto;
  }
  .filter-collapse-body::-webkit-scrollbar { width: 4px; }
  .filter-collapse-body::-webkit-scrollbar-track { background: transparent; }
  .filter-collapse-body::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }
  .filter-actions {
    display: flex;
    gap: 4px;
    padding: 6px 12px 2px;
    border-bottom: 1px solid #f1f5f9;
    margin-bottom: 2px;
  }
  .filter-action-btn {
    flex: 1;
    padding: 4px 0;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #f8fafc;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s;
  }
  .filter-action-btn:hover { background: #e2e8f0; color: #1e293b; }
  .filter-checkbox-list {
    padding: 6px 12px 8px;
  }
  .filter-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    cursor: pointer;
    font-size: 13px;
    color: #334155;
    transition: color 0.1s;
  }
  .filter-checkbox-item:hover { color: #1e293b; }
  .filter-checkbox-item input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: #3b82f6;
    cursor: pointer;
    flex-shrink: 0;
  }
  .active-filter-count {
    display: inline-block;
    background: #3b82f6;
    color: white;
    border-radius: 10px;
    padding: 1px 8px;
    font-size: 11px;
    margin-left: 6px;
    font-weight: 600;
  }

  /* Search Results Panel - Left Side (Emerald) */
  #results-panel {
    top: 66px;
    left: 16px;
    width: 340px;
    max-height: calc(100vh - 82px);
    display: none;
    border-color: #a7f3d0;
  }
  #results-panel .panel-header { background: #ecfdf5; color: #065f46; border-bottom-color: #a7f3d0; }
  #results-panel .panel-body { max-height: calc(100vh - 130px); }
  .result-item {
    padding: 10px 12px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    border-radius: 8px;
    margin-bottom: 4px;
    transition: background 0.15s;
  }
  .result-item:hover { background: #f8fafc; }
  .result-item:last-child { border-bottom: none; margin-bottom: 0; }
  .result-name {
    font-weight: 600;
    font-size: 14px;
    color: #1e293b;
    margin-bottom: 2px;
  }
  .result-address {
    font-size: 12px;
    color: #64748b;
    line-height: 1.4;
  }
  .result-meta {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
  }
  .result-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 500;
  }
  .badge-state { background: #dbeafe; color: #1d4ed8; }
  .badge-machines { background: #dcfce7; color: #15803d; }
  .badge-type { background: #fef3c7; color: #92400e; }
  .result-count {
    font-size: 12px;
    color: #64748b;
    padding: 4px 0 8px 0;
    border-bottom: 1px solid #f1f5f9;
    margin-bottom: 4px;
  }
  .result-add-dir-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    background: #dcfce7;
    color: #166534;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
  }
  .result-add-dir-btn:hover  { background: #86efac; color: #14532d; border-color: #4ade80; }
  .result-add-dir-btn:active { background: #22c55e; color: #ffffff; border-color: #16a34a; }
  .result-add-dir-btn.added  { background: #f0fdfa; border-color: #0d9488; color: #0d9488; } /* keep teal for 'Added' state */
  .site-add-dir-btn {
    width: 100%;
    justify-content: center;
    padding: 8px 12px;
    font-size: 12px;
    margin-top: 10px;
    margin-bottom: 4px;
  }
  .result-exclude-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    margin-left: 6px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid #fecaca;
    border-radius: 6px;
    background: #fef2f2;
    color: #b91c1c;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
  }
  .result-exclude-btn:hover  { background: #fecaca; color: #991b1b; border-color: #fca5a5; }
  .result-exclude-btn:active { background: #ef4444; color: #ffffff; border-color: #dc2626; }
  .site-exclude-btn {
    width: 100%;
    justify-content: center;
    margin-left: 0;
    padding: 8px 12px;
    font-size: 12px;
    margin-top: 6px;
    margin-bottom: 4px;
  }

  /* Site Info Panel - Top Center (Violet) */
  #site-panel {
    top: 76px; /* clears the 44px toolbar at top:16px with a 16px gap */
    left: 50%;
    transform: translateX(-50%);
    width: 480px;
    max-height: calc(100vh - 92px);
    display: none;
    border-color: #c4b5fd;
  }
  #site-panel .panel-header { background: #f5f3ff; color: #5b21b6; border-bottom-color: #c4b5fd; }
  #site-panel .panel-body { max-height: calc(100vh - 142px); }
  #site-panel .site-sticky {
    position: sticky;
    top: -12px;
    z-index: 5;
    background: #ffffff;
    margin: -12px -16px 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #c4b5fd;
  }
  .site-detail {
    margin-bottom: 16px;
  }
  .site-detail-name {
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 4px;
  }
  .site-detail-address {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 8px;
    line-height: 1.4;
  }
  .site-detail-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
  }
  .site-tag {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 500;
  }
  .tag-state { background: #dbeafe; color: #1d4ed8; }
  .tag-area { background: #e0e7ff; color: #4338ca; }
  .tag-type { background: #fef3c7; color: #92400e; }
  .tag-group { background: #fce7f3; color: #be185d; }
  .tag-route { background: #d1fae5; color: #065f46; }
  .site-info-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
  }
  .site-info-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
  }
  .site-info-label {
    flex: 0 0 60px;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.4px;
  }
  .machine-list-header {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #e5e7eb;
  }
  .machine-item {
    padding: 10px 12px;
    background: #f8fafc;
    border-radius: 8px;
    margin-bottom: 6px;
    cursor: pointer;
    border: 1px solid #e5e7eb;
    transition: all 0.15s;
  }
  .machine-item:hover { background: #eef2ff; border-color: #c7d2fe; }
  .machine-name {
    font-weight: 600;
    font-size: 13px;
    color: #1e293b;
  }
  .machine-meta {
    font-size: 12px;
    color: #64748b;
    margin-top: 2px;
  }

  /* Machine Info Panel - Bottom Left (Rose) */
  #machine-panel {
    top: 66px;
    bottom: 16px;
    left: 16px;
    width: 380px;
    max-height: none;
    display: none;
    border-color: #fecdd3;
  }
  #machine-panel .panel-header { background: #fff1f2; color: #9f1239; border-bottom-color: #fecdd3; }
  #machine-panel .panel-body { max-height: calc(100vh - 130px); }
  #machine-panel .machine-sticky {
    position: sticky;
    top: -12px;
    z-index: 5;
    background: #ffffff;
    margin: -12px -16px 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #fecdd3;
  }
  .machine-detail-name {
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 8px;
  }
  .machine-detail-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
  }
  /* Service tag controls in Machine Info panel */
  .machine-tag-row {
    margin-top: 6px;
  }
  .machine-tag-current {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 12px;
    flex-wrap: wrap;
  }
  .machine-tag-current-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #15803d;
  }
  .machine-tag-current-name {
    font-weight: 600;
    color: #14532d;
  }
  .machine-tag-current-min {
    color: #15803d;
    font-variant-numeric: tabular-nums;
  }
  .machine-tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
  }
  .machine-tag-list-readonly {
    margin-top: 6px;
    margin-bottom: 0;
  }
  .machine-tag-chip-readonly {
    padding: 3px 10px;
    font-size: 11px;
  }
  .machine-tag-chip-readonly .machine-tag-chip-name { max-width: 140px; }
  .machine-tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 4px 4px 10px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 999px;
    font-size: 12px;
    color: #14532d;
    max-width: 100%;
  }
  .machine-tag-chip-name {
    font-weight: 600;
    color: #14532d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
  }
  .machine-tag-chip-min {
    color: #15803d;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
  }
  .machine-tag-chip-remove {
    width: 18px;
    height: 18px;
    border: none;
    background: transparent;
    color: #15803d;
    cursor: pointer;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
  }
  .machine-tag-chip-remove svg {
    width: 12px;
    height: 12px;
    display: block;
  }
  .machine-tag-chip-remove:hover {
    background: #fee2e2;
    color: #b91c1c;
  }
  .machine-tag-chip-remove:active {
    background: #ef4444;
    color: #ffffff;
  }

  .machine-tag-actions {
    position: relative;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
  }
  .machine-tag-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 1 1 auto;
    min-width: 0;
    padding: 8px 12px;
    background: #f5f3ff;
    color: #5b21b6;
    border: 1px solid #c4b5fd;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
  }
  .machine-tag-btn:hover  { background: #ddd6fe; color: #4c1d95; border-color: #a78bfa; }
  .machine-tag-btn:active { background: #7c3aed; color: #ffffff; border-color: #6d28d9; }
  .machine-tag-btn-remove {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
  }
  .machine-tag-btn-remove:hover  { background: #fecaca; border-color: #fca5a5; }
  .machine-tag-btn-remove:active { background: #ef4444; color: #ffffff; border-color: #dc2626; }
  .machine-tag-picker {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 20;
    min-width: 220px;
    max-width: 320px;
    max-height: 240px;
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
    padding: 6px;
  }
  .machine-tag-picker.open { display: block; }
  .machine-tag-pick-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    color: #1e293b;
  }
  .machine-tag-pick-btn:hover { background: #f1f5f9; border-color: #e2e8f0; }
  .machine-tag-pick-name { font-weight: 600; }
  .machine-tag-pick-min  { color: #64748b; font-size: 12px; font-variant-numeric: tabular-nums; }
  .machine-tag-empty {
    padding: 10px;
    color: #64748b;
    font-size: 12px;
    font-style: italic;
    text-align: center;
  }
  .attr-section {
    margin-top: 12px;
  }
  .attr-section-title {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #e5e7eb;
  }
  .attr-item {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
  }
  .attr-item:last-child { border-bottom: none; }
  .attr-key {
    color: #64748b;
    font-weight: 500;
  }
  .attr-val {
    color: #1e293b;
    text-align: right;
    max-width: 200px;
    word-break: break-word;
  }
  .attr-group {
    background: #f8fafc;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
    border: 1px solid #e5e7eb;
  }
  .attr-group-name {
    font-weight: 600;
    font-size: 13px;
    color: #3b82f6;
    margin-bottom: 6px;
  }

  /* Custom map marker — site (diamond, rotated 45°) */
  .custom-marker {
    width: 24px;
    height: 24px;
    background: #3b82f6;
    border: 3px solid #fff;
    border-radius: 2px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 11px;
    font-weight: 700;
    transform: rotate(45deg);
    transition: all 0.2s;
  }
  .custom-marker > span {
    display: inline-block;
    transform: rotate(-45deg);
  }
  .custom-marker:hover { transform: rotate(45deg) scale(1.15); }
  .custom-marker.koala { background: #ec4899; }
  .custom-marker.koala.selected { background: #0d9488; } /* selected state still wins */
  .custom-marker.highlight {
    background: #ef4444;
    border-color: #fca5a5;
    transform: rotate(45deg) scale(1.2);
    animation: marker-blink 1s ease-in-out infinite;
  }
  @keyframes marker-blink {
    0%, 100% {
      background: #ef4444;
      box-shadow: 0 0 0 0 rgba(239,68,68,0.7), 0 2px 8px rgba(0,0,0,0.2);
    }
    50% {
      background: #fbbf24;
      box-shadow: 0 0 0 8px rgba(239,68,68,0), 0 2px 8px rgba(0,0,0,0.2);
    }
  }

  /* Machine marker — wrapper provides drop-shadow and supports blinking highlight */
  .machine-marker-wrap svg {
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.35));
    transition: filter 0.2s, transform 0.2s;
  }
  .machine-marker-wrap.highlight svg {
    animation: machine-marker-blink 1s ease-in-out infinite;
  }
  @keyframes machine-marker-blink {
    0%, 100% {
      filter: drop-shadow(0 0 0 rgba(239,68,68,0.0)) drop-shadow(0 1px 3px rgba(0,0,0,0.35));
      transform: scale(1);
    }
    50% {
      filter: drop-shadow(0 0 8px rgba(239,68,68,1)) drop-shadow(0 1px 3px rgba(0,0,0,0.35));
      transform: scale(1.2);
    }
  }

  /* Cluster that contains the currently highlighted site — same blinking pulse */
  .marker-cluster.marker-cluster-highlight {
    animation: cluster-blink 1s ease-in-out infinite;
  }
  .marker-cluster.marker-cluster-highlight div {
    animation: cluster-inner-blink 1s ease-in-out infinite;
  }
  @keyframes cluster-blink {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.7); }
    50%      { box-shadow: 0 0 0 10px rgba(239,68,68,0); }
  }
  @keyframes cluster-inner-blink {
    0%, 100% { background-color: rgba(239,68,68,0.85); color: #fff; }
    50%      { background-color: rgba(251,191,36,0.95); color: #1f2937; }
  }

  /* Toolbar */
  /* Hamburger map-type selector */
  #btn-maptype {
    position: absolute;
    top: 16px;
    left: 52px;
    width: 38px;
    height: 38px;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: background 0.15s, color 0.15s, border-color 0.15s;
  }
  #btn-maptype:hover  { background: #93c5fd; color: #1e3a8a; border-color: #60a5fa; }
  #btn-maptype:active { background: #60a5fa; color: #ffffff; border-color: #3b82f6; }
  #maptype-menu {
    position: absolute;
    top: 60px;
    left: 52px;
    z-index: 1001;
    min-width: 140px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    padding: 4px;
    display: none;
  }
  #maptype-menu.open { display: block; }
  .maptype-item {
    padding: 8px 12px;
    font-size: 13px;
    color: #334155;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s;
  }
  .maptype-item:hover { background: #f1f5f9; }
  .maptype-item.active { background: #dbeafe; color: #1e40af; font-weight: 600; }

  #toolbar {
    position: absolute;
    top: 16px;
    left: 100px;   /* shifted right to make room for hamburger */
    z-index: 1000;
    display: flex;
    gap: 6px;
  }

  /* Data Source dropdown menu */
  #datasource-menu {
    position: absolute;
    top: 44px;
    left: 0;
    z-index: 1001;
    min-width: 220px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    padding: 4px;
    display: none;
  }
  #datasource-menu.open { display: block; }
  .datasource-item {
    padding: 8px 12px;
    font-size: 13px;
    color: #334155;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .datasource-item:hover { background: #f1f5f9; }
  .datasource-item.active { background: #dbeafe; color: #1e40af; font-weight: 600; }
  .datasource-item.disabled { color: #94a3b8; cursor: not-allowed; font-style: italic; }
  .datasource-item.disabled:hover { background: transparent; }
  .datasource-check {
    display: inline-block;
    width: 14px;
    flex-shrink: 0;
    text-align: center;
    font-weight: 700;
    color: #1e40af;
    font-size: 12px;
    line-height: 1;
  }
  body.machine-mode #datasource-menu .datasource-item.active .datasource-check {
    color: #92400e;
  }
  .datasource-label { flex: 1; }
  .datasource-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    flex-shrink: 0;
    line-height: 1;
  }
  .datasource-icon svg { display: block; }
  .datasource-icon-insert { color: #1e40af; }
  .datasource-icon-view   { color: #15803d; }
  .datasource-icon-clear  { color: #b91c1c; }
  .datasource-item.disabled .datasource-icon { color: #94a3b8; }
  body.machine-mode #datasource-menu .datasource-item.active {
    background: #fef3c7; color: #92400e;
  }

  /* Service Tags dropdown menu */
  #service-tags-menu {
    position: absolute;
    top: 44px;
    left: 0;
    z-index: 1001;
    width: 300px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    padding: 4px;
    display: none;
  }
  #service-tags-menu.open { display: block; }
  .service-tags-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px 4px 8px;
    font-size: 11px;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 1px solid #f1f5f9;
    margin-bottom: 4px;
  }
  .service-tags-add-btn {
    background: #1e40af;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    text-transform: none;
    letter-spacing: 0;
  }
  .service-tags-add-btn:hover { background: #1d4ed8; }
  .service-tags-list { max-height: 320px; overflow-y: auto; }
  .service-tag-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 13px;
    color: #334155;
  }
  .service-tag-item:hover { background: #f8fafc; }
  .service-tag-item.is-filter-active { background: #eef6ff; }
  .service-tag-item.is-filter-active:hover { background: #e0efff; }
  .service-tag-filter-toggle {
    background: transparent;
    border: 1px solid #cbd5e1;
    cursor: pointer;
    padding: 3px;
    border-radius: 4px;
    color: #94a3b8;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
  }
  .service-tag-filter-toggle svg { width: 14px; height: 14px; display: block; }
  .service-tag-filter-toggle:hover { background: #e2e8f0; color: #1e40af; border-color: #93c5fd; }
  .service-tag-filter-toggle.is-on {
    background: #1e40af;
    color: #fff;
    border-color: #1e40af;
  }
  .service-tag-filter-toggle.is-on:hover { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
  .service-tag-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
  .service-tag-time { color: #64748b; font-size: 12px; flex-shrink: 0; }
  .service-tag-actions { display: flex; gap: 2px; flex-shrink: 0; }
  .service-tag-icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .service-tag-icon-btn:hover { background: #e2e8f0; color: #1e293b; }
  .service-tag-icon-btn.delete:hover { background: #fee2e2; color: #b91c1c; }
  .service-tag-apply-btn {
    background: #15803d;
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.3px;
  }
  .service-tag-apply-btn:hover { background: #166534; }
  .service-tag-apply-btn:active { background: #14532d; }
  /* Apply is only meaningful in Machine Layer — dim it everywhere else. */
  body:not(.machine-mode) .service-tag-apply-btn {
    background: #e2e8f0;
    color: #94a3b8;
    cursor: not-allowed;
  }
  body:not(.machine-mode) .service-tag-apply-btn:hover,
  body:not(.machine-mode) .service-tag-apply-btn:active {
    background: #e2e8f0;
    color: #94a3b8;
  }
  .service-tag-icon-btn svg { width: 14px; height: 14px; display: block; }
  .service-tag-empty { padding: 16px 8px; text-align: center; font-size: 12px; color: #94a3b8; font-style: italic; }
  .service-tag-edit-row {
    display: flex;
    gap: 6px;
    padding: 6px 8px;
    align-items: center;
  }
  .service-tag-edit-row input[type="text"],
  .service-tag-edit-row input[type="number"] {
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 13px;
    font-family: inherit;
    box-sizing: border-box;
  }
  .service-tag-edit-row input[type="text"] { flex: 1; min-width: 0; }
  .service-tag-edit-row input[type="number"] { width: 64px; }
  .service-tag-name-readonly { padding: 6px 0; color: #1e293b; }
  .service-tag-edit-row input:focus { outline: none; border-color: #1e40af; box-shadow: 0 0 0 2px rgba(30,64,175,0.15); }
  .service-tag-edit-actions { display: flex; gap: 2px; flex-shrink: 0; }
  .service-tag-edit-actions .service-tag-icon-btn.confirm { color: #15803d; }
  .service-tag-edit-actions .service-tag-icon-btn.confirm:hover { background: #dcfce7; color: #166534; }
  .toolbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 10px;
    width: 160px;      /* uniform width across all toolbar buttons */
    height: 44px;      /* taller to fit 2 lines of text */
    background: #dbeafe;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #1e40af;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    user-select: none;
    white-space: nowrap;
  }
  .toolbar-btn:hover  { background: #93c5fd; color: #1e3a8a; border-color: #60a5fa; }
  .toolbar-btn:active,
  .toolbar-btn.active { background: #60a5fa; color: #ffffff; border-color: #3b82f6; }
  .toolbar-btn.disabled { opacity: 0.5; cursor: default; }
  .toolbar-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
  .toolbar-btn-label {
    text-align: center;
    line-height: 1.15;
    white-space: normal;
  }

  /* Custom tooltips for toolbar buttons (and the map-type hamburger / clear-filters button).
     Uses [data-tooltip] so the native title= bubble is avoided. Tooltip appears below the
     button on hover/focus, with a short delay to stop it flickering on quick passes. */
  [data-tooltip] { position: relative; }
  [data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    background: #1e293b;
    color: #f8fafc;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.35;
    padding: 7px 10px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.18);
    white-space: normal;
    width: max-content;
    max-width: 240px;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0.4s;
    transition-delay: 0s, 0s, 0.4s;
    z-index: 1100;
  }
  [data-tooltip]::before {
    content: "";
    position: absolute;
    top: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    border: 6px solid transparent;
    border-bottom-color: #1e293b;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0.4s;
    z-index: 1100;
  }
  [data-tooltip]:hover::after,
  [data-tooltip]:focus-visible::after,
  [data-tooltip]:hover::before,
  [data-tooltip]:focus-visible::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
    transition-delay: 0.4s, 0.4s, 0s;
  }
  /* Hide tooltip while the button is actively pressed so it doesn't sit on top of the menu */
  [data-tooltip]:active::after,
  [data-tooltip]:active::before,
  [data-tooltip].active::after,
  [data-tooltip].active::before {
    opacity: 0;
    visibility: hidden;
    transition-delay: 0s;
  }

  /* Machine Layer mode: recolor every toolbar button orange */
  #toolbar.machine-mode .toolbar-btn {
    background: #fef3c7; color: #92400e; border-color: #fcd34d;
  }
  #toolbar.machine-mode .toolbar-btn:hover {
    background: #fcd34d; color: #78350f; border-color: #f59e0b;
  }
  /* Active/pressed (incl. the layer-toggle button while machine layer is on) */
  #toolbar.machine-mode .toolbar-btn:active,
  #toolbar.machine-mode .toolbar-btn.active {
    background: #f59e0b; color: #ffffff; border-color: #d97706;
  }
  #toolbar.machine-mode .toolbar-btn.active:hover {
    background: #d97706; color: #ffffff; border-color: #b45309;
  }
  /* Toolbar badges (e.g. directions count) — switch to orange palette too */
  #toolbar.machine-mode .toolbar-badge { background: #f59e0b; }

  /* Map-type hamburger — match machine layer palette */
  body.machine-mode #btn-maptype {
    background: #fef3c7; color: #92400e; border-color: #fcd34d;
  }
  body.machine-mode #btn-maptype:hover {
    background: #fcd34d; color: #78350f; border-color: #f59e0b;
  }
  body.machine-mode #btn-maptype:active {
    background: #f59e0b; color: #ffffff; border-color: #d97706;
  }
  /* Map-type dropdown — selected item also picks up the amber accent */
  body.machine-mode #maptype-menu .maptype-item.active {
    background: #fef3c7; color: #92400e;
  }
  .toolbar-badge {
    background: #3b82f6;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 8px;
    padding: 1px 6px;
    min-width: 18px;
    text-align: center;
  }

  /* Directions Panel - left side */
  #directions-panel {
    top: 60px;
    left: 52px;
    width: 340px;
    max-height: calc(100vh - 76px);
    display: none;
    flex-direction: column;
    border-color: #99f6e4;
  }
  #directions-panel .panel-header { background: #f0fdfa; color: #115e59; border-bottom-color: #99f6e4; flex-shrink: 0; }
  #directions-panel .panel-body { flex: 1; overflow-y: auto; min-height: 0; }
  #dir-summary-container { flex-shrink: 0; }
  #dir-summary-container .dir-summary {
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    border-bottom: 1px solid #99f6e4;
  }
  .dir-instructions {
    font-size: 12px;
    color: #64748b;
    padding: 8px 0;
    text-align: center;
    font-style: italic;
  }
  .dir-endpoints {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 10px;
    margin-bottom: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
  }
  .dir-endpoint-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0; /* allow children to shrink within flex parent */
  }
  .dir-endpoint-row label {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    min-width: 56px;
    flex-shrink: 0;
  }
  .dir-endpoint-row select {
    flex: 1 1 0;
    min-width: 0;          /* critical: let select shrink below content width */
    max-width: 100%;       /* never overflow its row */
    width: 100%;
    font-size: 12px;
    padding: 6px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    color: #0f172a;
    cursor: pointer;
    text-overflow: ellipsis; /* trim long option labels in the collapsed view */
    white-space: nowrap;
    overflow: hidden;
  }
  .dir-endpoint-row select:focus {
    outline: none;
    border-color: #0d9488;
  }
  .dir-site-list {
    min-height: 40px;
  }
  .dir-site-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 4px;
    font-size: 13px;
  }
  .dir-site-num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #0d9488;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  .dir-site-info { flex: 1; min-width: 0; cursor: pointer; }
  .dir-site-info:hover .dir-site-name { color: #0d9488; }
  .dir-site-name { font-weight: 600; color: #1e293b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .dir-site-addr { font-size: 11px; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .dir-site-machines { margin-top: 4px; }
  .dir-site-remove {
    width: 22px;
    height: 22px;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 16px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
  }
  .dir-site-remove:hover { background: #fee2e2; color: #dc2626; }
  .dir-site-remove:disabled { opacity: 0.35; cursor: not-allowed; background: transparent; }
  .dir-site-remove:disabled:hover { background: transparent; color: #94a3b8; }
  .dir-site-move {
    display: flex;
    flex-direction: column;
    gap: 0;
    flex-shrink: 0;
  }
  .dir-site-move button {
    border: none;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    font-size: 10px;
    padding: 0 2px;
    line-height: 1;
    transition: color 0.15s;
  }
  .dir-site-move button:hover { color: #1e293b; }
  .dir-actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
  }
  .dir-btn {
    flex: 1;
    padding: 8px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
  }
  .dir-btn-primary { background: #0d9488; color: #fff; }
  .dir-btn-primary:hover { background: #0f766e; }
  .dir-btn-primary:disabled { background: #cbd5e1; cursor: default; }
  .dir-btn-secondary { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
  .dir-btn-secondary:hover { background: #e2e8f0; }
  .dir-summary {
    margin-top: 10px;
    padding: 10px 12px;
    background: #f0fdfa;
    border: 1px solid #99f6e4;
    border-radius: 8px;
    font-size: 13px;
    color: #115e59;
  }
  .dir-summary-row { display: flex; justify-content: space-between; padding: 2px 0; }
  .dir-summary-label { color: #64748b; }
  .dir-summary-val { font-weight: 600; }
  .dir-status {
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .dir-status-loading { background: #f0fdfa; color: #0d9488; border: 1px solid #99f6e4; }
  .dir-status-error { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
  .dir-spinner {
    width: 14px; height: 14px;
    border: 2px solid #99f6e4;
    border-top-color: #0d9488;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }
  .dir-leg {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 12px;
    color: #64748b;
  }
  .dir-leg-line {
    width: 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
  }
  .dir-leg-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #0d9488;
  }
  .dir-leg-dash {
    width: 2px; height: 18px;
    background: repeating-linear-gradient(to bottom, #0d9488 0, #0d9488 3px, transparent 3px, transparent 6px);
  }
  .dir-leg-info { flex: 1; }
  .dir-leg-dist { font-weight: 600; color: #1e293b; }

  /* Turn-by-turn driving steps */
  .dir-leg-toggle {
    cursor: pointer;
    user-select: none;
  }
  .dir-leg-toggle:hover .dir-leg-dist { color: #0d9488; }
  .dir-leg-toggle.active {
    background: rgba(245,158,11,0.12);
    border-radius: 6px;
    padding: 2px 6px;
    margin: 0 -6px;
  }
  .dir-leg-toggle.active .dir-leg-dist { color: #b45309; }
  .dir-leg-expand {
    font-size: 10px;
    color: #94a3b8;
    margin-left: 4px;
    transition: transform 0.2s;
    display: inline-block;
  }
  .dir-leg-toggle.open .dir-leg-expand { transform: rotate(180deg); }
  .dir-steps {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    margin-left: 30px;
  }
  .dir-leg-toggle.open + .dir-steps {
    max-height: 2000px;
    overflow-y: auto;
  }
  .dir-step {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 5px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 12px;
    color: #475569;
  }
  .dir-step:last-child { border-bottom: none; }
  .dir-step-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 12px;
  }
  .dir-step-text { flex: 1; line-height: 1.4; }
  .dir-step-text strong { color: #1e293b; font-weight: 600; }
  .dir-step-dist {
    font-size: 11px;
    color: #94a3b8;
    flex-shrink: 0;
    white-space: nowrap;
  }

  /* Unmatched serials summary (machine-layer import) */
  #dir-unmatched-container .dir-unmatched,
  #custom-data-skipped-container .dir-unmatched {
    margin: 0;
    padding: 10px 12px;
    background: #fef2f2;
    border: none;
    border-bottom: 1px solid #fecaca;
    border-radius: 0;
  }
  #custom-data-skipped-container { flex-shrink: 0; }
  .dir-unmatched-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-weight: 700;
    color: #b91c1c;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    cursor: pointer;
    user-select: none;
  }
  .dir-unmatched-arrow {
    font-size: 10px;
    color: #b91c1c;
    transition: transform 0.2s ease;
  }
  .dir-unmatched.open .dir-unmatched-arrow {
    transform: rotate(180deg);
  }
  .dir-unmatched-collapse {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
  }
  .dir-unmatched.open .dir-unmatched-collapse {
    max-height: 600px;
    margin-top: 8px;
  }
  .dir-unmatched-sub {
    font-size: 11px;
    color: #991b1b;
    margin-bottom: 8px;
    line-height: 1.4;
  }
  .dir-unmatched-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }
  .dir-unmatched-chip {
    display: inline-block;
    padding: 3px 8px;
    background: #fff;
    border: 1px solid #fecaca;
    border-radius: 6px;
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    font-size: 11px;
    color: #991b1b;
    word-break: break-all;
  }

  /* Directions mode cursor */
  #map.directions-mode { cursor: crosshair !important; }
  #map.directions-mode .leaflet-interactive { cursor: crosshair !important; }

  /* Selected marker style */
  .custom-marker.selected {
    background: #0d9488;
    border-color: #99f6e4;
    box-shadow: 0 0 0 3px rgba(13,148,136,0.3), 0 2px 8px rgba(0,0,0,0.2);
  }

  /* Scrollbar styling */
  .panel-body::-webkit-scrollbar { width: 6px; }
  .panel-body::-webkit-scrollbar-track { background: transparent; }
  .panel-body::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
  .panel-body::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

  /* Map legend — sits just above the stats bar, content swaps with active layer */
  #map-legend {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border-radius: 20px;
    padding: 5px 16px;
    z-index: 999;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    border: 1px solid #e5e7eb;
  }
  .legend-row {
    display: none;
    gap: 14px;
    align-items: center;
    font-size: 12px;
    color: #475569;
  }
  /* Default: site layer row visible. Machine mode swaps to machine row. */
  .legend-row.legend-site { display: flex; }
  .legend-row.legend-machine { display: none; }
  body.machine-mode .legend-row.legend-site { display: none; }
  body.machine-mode .legend-row.legend-machine { display: flex; }
  .legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }
  .legend-label { font-weight: 500; }
  .legend-swatch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  }
  /* Diamond — matches site marker (rotated square with white border) */
  .legend-diamond {
    width: 12px;
    height: 12px;
    border: 2px solid #fff;
    border-radius: 1px;
    transform: rotate(45deg);
  }
  .legend-site-default  { background: #3b82f6; }
  .legend-site-koala    { background: #ec4899; }
  .legend-site-selected { background: #0d9488; }
  /* Cluster swatch — two-tone circle to mirror Leaflet.markercluster */
  .legend-cluster {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    box-shadow: none;
    padding: 0;
  }
  .legend-cluster > span {
    display: block;
    width: 10px;
    height: 10px;
    margin: 3px;
    border-radius: 50%;
  }
  .legend-cluster-site         { background: rgba(59, 130, 246, 0.3); }
  .legend-cluster-site > span  { background: rgba(59, 130, 246, 0.6); }
  .legend-cluster-machine        { background: rgba(234, 179, 8, 0.3); }
  .legend-cluster-machine > span { background: rgba(234, 179, 8, 0.85); }
  /* Square — matches machine marker */
  .legend-square {
    width: 14px;
    height: 14px;
    border: 2px solid #fff;
    border-radius: 1px;
  }
  .legend-machine-smart    { background: #ef4444; }
  .legend-machine-other    { background: #6366f1; }
  .legend-machine-none     { background: #9ca3af; }
  .legend-machine-selected { background: #f59e0b; }
  /* Pulsing red — matches the focused/highlight marker animation */
  .legend-pulse { background: #ef4444; animation: legend-pulse 1s ease-in-out infinite; }
  @keyframes legend-pulse {
    0%, 100% { background: #ef4444; box-shadow: 0 0 0 0 rgba(239,68,68,0.7), 0 1px 3px rgba(0,0,0,0.25); }
    50%      { background: #fbbf24; box-shadow: 0 0 0 5px rgba(239,68,68,0),   0 1px 3px rgba(0,0,0,0.25); }
  }

  /* Stats bar */
  #stats-bar {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border-radius: 20px;
    padding: 6px 20px;
    font-size: 12px;
    color: #64748b;
    z-index: 999;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    border: 1px solid #e5e7eb;
    display: flex;
    gap: 16px;
  }
  .stat-item { display: flex; align-items: center; gap: 4px; }
  .stat-val { font-weight: 700; color: #1e293b; }

  /* Login overlay */
  #login-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #2d3436;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  #login-overlay.hidden { display: none; }
  .login-card {
    background: #fff;
    border-radius: 12px;
    padding: 0 32px 32px;
    width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    text-align: center;
  }
  .login-logo {
    margin-bottom: 16px;
  }
  .login-logo img {
    width: 200px;
    height: auto;
    display: block;
    margin: 0 auto;
  }
  .login-title {
    font-size: 18px;
    font-weight: 600;
    color: #334155;
    letter-spacing: 1px;
    margin-bottom: 28px;
  }
  .login-field {
    position: relative;
    margin-bottom: 20px;
  }
  .login-field input {
    width: 100%;
    padding: 14px 44px 14px 16px;
    border: none;
    border-bottom: 2px solid #e2e8f0;
    border-radius: 0;
    font-size: 15px;
    color: #1e293b;
    outline: none;
    background: transparent;
    transition: border-color 0.2s;
  }
  .login-field input:focus {
    border-bottom-color: #22b8cf;
    box-shadow: none;
  }
  .login-field input::placeholder { color: #94a3b8; }
  .login-field-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    display: flex;
    align-items: center;
  }
  .login-toggle-pw { cursor: pointer; }
  .login-toggle-pw:hover { color: #64748b; }
  #login-btn {
    width: 70%;
    padding: 13px;
    margin-top: 24px;
    background: #22b8cf;
    color: #fff;
    border: none;
    border-radius: 24px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 1.5px;
    cursor: pointer;
    transition: background 0.15s;
  }
  #login-btn:hover { background: #1ba3b3; }
  #login-btn:disabled { background: #99e0eb; cursor: default; }
  .login-forgot {
    display: block;
    margin-top: 16px;
    font-size: 13px;
    color: #22b8cf;
    text-decoration: none;
    font-weight: 500;
  }
  .login-forgot:hover { text-decoration: underline; }
  .login-error {
    background: #fef2f2;
    color: #dc2626;
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #fecaca;
    margin-bottom: 16px;
  }

  /* Loading overlay */
  #loading-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.92);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
  }
  #loading-overlay.hidden { display: none; }
  .loading-spinner {
    width: 48px; height: 48px;
    border: 4px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }
  .loading-text {
    font-size: 20px;
    font-weight: 600;
    color: #1e293b;
  }
  .loading-sub {
    font-size: 14px;
    color: #64748b;
    margin-top: -12px;
  }
  .loading-error .loading-text { color: #dc2626; }
  .loading-error .loading-spinner { border-top-color: #dc2626; animation: none; }

  /* Route calculation dialog */
  #route-loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 4000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: rl-fade-in 0.18s ease-out;
  }
  #route-loading-overlay.hidden { display: none; }
  @keyframes rl-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
  }
  .route-loading-card {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    padding: 28px 32px 24px;
    width: min(420px, calc(100vw - 32px));
    text-align: center;
    animation: rl-pop-in 0.22s ease-out;
  }
  @keyframes rl-pop-in {
    from { opacity: 0; transform: translateY(8px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
  }
  .route-loading-spinner {
    width: 44px; height: 44px;
    margin: 0 auto 16px;
    border: 4px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }
  .route-loading-title {
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 6px;
  }
  .route-loading-sub {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 18px;
  }
  .route-loading-steps {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
  }
  .route-loading-steps li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 4px;
    font-size: 13px;
    color: #94a3b8;
    transition: color 0.2s;
  }
  .route-loading-steps li.is-active {
    color: #1e293b;
    font-weight: 500;
  }
  .route-loading-steps li.is-done {
    color: #475569;
  }
  .rl-dot {
    flex: 0 0 auto;
    width: 14px; height: 14px;
    border-radius: 50%;
    border: 2px solid #cbd5e1;
    background: #ffffff;
    position: relative;
  }
  .route-loading-steps li.is-active .rl-dot {
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
    animation: rl-pulse 1.2s ease-in-out infinite;
  }
  @keyframes rl-pulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15); }
    50%      { box-shadow: 0 0 0 7px rgba(59, 130, 246, 0.05); }
  }
  .route-loading-steps li.is-done .rl-dot {
    border-color: #10b981;
    background: #10b981;
  }
  .route-loading-steps li.is-done .rl-dot::after {
    content: '';
    position: absolute;
    left: 3px; top: 0px;
    width: 4px; height: 8px;
    border: solid #ffffff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
  }
  .rl-label { flex: 1 1 auto; }

  /* Excluded Sites/Machines dialog */
  #excluded-overlay,
  #custom-data-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 4000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: rl-fade-in 0.18s ease-out;
  }
  #excluded-overlay.hidden,
  #custom-data-overlay.hidden { display: none; }
  .excluded-card {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    width: min(480px, calc(100vw - 32px));
    max-height: calc(100vh - 64px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: rl-pop-in 0.22s ease-out;
    border: 1px solid #e5e7eb;
  }
  .excluded-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: #eff6ff;
    border-bottom: 1px solid #bfdbfe;
    font-weight: 600;
    font-size: 15px;
    color: #1e40af;
    flex-shrink: 0;
  }
  body.machine-mode .excluded-header {
    background: #fffbeb;
    color: #92400e;
    border-bottom-color: #fde68a;
  }
  .excluded-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
  }
  .excluded-summary {
    display: flex;
    gap: 10px;
    font-size: 12px;
    font-weight: 500;
    color: #1e40af;
  }
  .excluded-summary.hidden { display: none; }
  .excluded-summary-item { display: flex; align-items: center; gap: 4px; }
  .excluded-summary-label { color: #1e3a8a; }
  .excluded-summary-val { font-weight: 700; color: #1e3a8a; }
  /* "Skipped" chip in the View Custom Data dialog summary — distinct color so
     users don't read the count as part of the loaded total. */
  .excluded-summary-item.custom-skipped .excluded-summary-label { color: #92400e; }
  .excluded-summary-item.custom-skipped .excluded-summary-val   { color: #78350f; }
  body.machine-mode .excluded-summary { color: #92400e; }
  body.machine-mode .excluded-summary-label { color: #92400e; }
  body.machine-mode .excluded-summary-val { color: #78350f; }

  .excluded-search-wrap {
    padding: 10px 16px;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
  }
  .excluded-search-wrap.hidden { display: none; }
  #excluded-search,
  #custom-data-search {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    color: #1e293b;
    transition: border-color 0.15s;
  }
  #excluded-search:focus { border-color: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,0.1); }
  #custom-data-search:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
  #excluded-search::placeholder,
  #custom-data-search::placeholder { color: #94a3b8; }
  body.machine-mode #excluded-search:focus,
  body.machine-mode #custom-data-search:focus {
    border-color: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,0.1);
  }

  .excluded-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    min-height: 80px;
  }
  .excluded-empty {
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
    font-style: italic;
    padding: 24px 0;
  }
  .excluded-list-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 6px;
    transition: background 0.15s, border-color 0.15s;
  }
  .excluded-list-item:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
  }
  .excluded-list-item:last-child { margin-bottom: 0; }
  .excluded-item-info {
    flex: 1;
    min-width: 0;
  }
  .excluded-item-name {
    font-weight: 600;
    font-size: 13px;
    color: #1e293b;
    margin-bottom: 2px;
  }
  .excluded-item-addr {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 6px;
    line-height: 1.4;
  }
  .excluded-item-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
  }
  .excluded-item-remove {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 18px;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
  }
  .excluded-item-remove:hover { background: #fee2e2; color: #dc2626; }
  .excluded-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px;
    background: #f8fafc;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
  }
  body.machine-mode .excluded-footer {
    background: #fffbeb;
    border-top-color: #fde68a;
  }
  .excluded-clear-btn {
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 8px;
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
  }
  .excluded-clear-btn:hover { background: #fecaca; color: #991b1b; border-color: #fca5a5; }
  .excluded-clear-btn:active { background: #ef4444; color: #ffffff; border-color: #dc2626; }
  .excluded-close-btn {
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 8px;
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
  }
  .excluded-close-btn:hover { background: #93c5fd; color: #1e3a8a; border-color: #60a5fa; }
  .excluded-close-btn:active { background: #60a5fa; color: #ffffff; border-color: #3b82f6; }
  body.machine-mode .excluded-close-btn {
    background: #fef3c7; color: #92400e; border-color: #fcd34d;
  }
  body.machine-mode .excluded-close-btn:hover {
    background: #fcd34d; color: #78350f; border-color: #f59e0b;
  }
  body.machine-mode .excluded-close-btn:active {
    background: #f59e0b; color: #ffffff; border-color: #d97706;
  }
