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

:root {
  /* Risk tier colors */
  --color-high:     #DC2626;
  --color-moderate: #F59E0B;
  --color-low:      #16A34A;
  --color-nodata:   #9CA3AF;

  /* Legacy aliases kept for compatibility */
  --color-poor:    #DC2626;
  --color-good:    #16A34A;
  --color-unknown: #9CA3AF;

  /* Layout */
  --color-header:  #1E3A8A;
  --color-border:  #E5E7EB;
  --color-bg:      #FFFFFF;
  --sidebar-width: 280px;
  --panel-width:   360px;
  --header-height: 56px;
  --footer-height: 32px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
  font-family: var(--font);
  font-size: 14px;
  background: var(--color-bg);
  color: #111827;
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ────────────────────────────────────────────────────────────────── */
#header {
  height: var(--header-height);
  background: var(--color-header);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  z-index: 1000;
  box-shadow: 0 2px 4px rgba(0,0,0,0.25);
}

#header h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

#header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

#search-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

#search-input {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font);
  width: 200px;
  outline: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
}

#search-input::placeholder { color: rgba(255,255,255,0.55); }
#search-input:focus { background: rgba(255,255,255,0.25); }

#search-btn {
  padding: 6px 14px;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 6px;
  color: #fff;
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s;
}
#search-btn:hover { background: rgba(255,255,255,0.28); }

/* Field crew button in header */
.crew-btn {
  padding: 7px 16px;
  background: rgba(255,255,255,0.12);
  border: 1.5px solid rgba(255,255,255,0.45);
  border-radius: 6px;
  color: #fff;
  font-size: 13px;
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.crew-btn:hover { background: rgba(255,255,255,0.22); }
.crew-btn.active {
  background: #92400E;
  border-color: #92400E;
  box-shadow: 0 0 0 2px rgba(245,158,11,0.5);
}

/* ── Body layout ───────────────────────────────────────────────────────────── */
#body {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--color-bg);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-section {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--color-border);
}

.sidebar-section:last-child { border-bottom: none; }

.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6B7280;
  margin-bottom: 12px;
}

/* ── Legend ── */
.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 9px;
  font-size: 13px;
  color: #374151;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1.5px solid rgba(0,0,0,0.12);
}

.legend-dot.high     { background: var(--color-high); }
.legend-dot.moderate { background: var(--color-moderate); }
.legend-dot.low      { background: var(--color-low); }
.legend-dot.nodata   { background: var(--color-nodata); }

/* Legacy aliases */
.legend-dot.poor    { background: var(--color-poor); }
.legend-dot.good    { background: var(--color-good); }
.legend-dot.unknown { background: var(--color-unknown); }

.legend-caption {
  font-size: 11px;
  color: #6B7280;
  margin-top: 6px;
  font-style: italic;
}

/* ── Stats ── */
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
  font-size: 13px;
  color: #374151;
}

.stat-value {
  font-weight: 700;
  font-size: 15px;
  color: #111827;
}

.stat-sub {
  font-size: 11px;
  color: #6B7280;
  margin-left: 4px;
}

.stat-warn .stat-value {
  color: var(--color-moderate);
}

/* ── Filters ── */
.filter-item {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 10px;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
  user-select: none;
}

.filter-item input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--color-header);
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Action button (Top 100) ── */
.action-btn {
  width: 100%;
  padding: 10px;
  background: var(--color-header);
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 13px;
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  text-align: center;
}
.action-btn:hover { background: #1e40af; }

/* ── Map container ─────────────────────────────────────────────────────────── */
#map-container {
  position: relative;
  flex: 1;
  overflow: hidden;
}

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

/* ── Map toolbar ───────────────────────────────────────────────────────────── */
#map-toolbar {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1000;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn-group {
  display: flex;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--color-border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.btn-group .toolbar-btn {
  border: none;
  border-radius: 0;
  box-shadow: none;
  border-right: 1px solid var(--color-border);
}
.btn-group .toolbar-btn:last-child { border-right: none; }

.toolbar-btn {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  transition: background 0.12s;
  white-space: nowrap;
}
.toolbar-btn:hover { background: #F3F4F6; }
.toolbar-btn.active {
  background: var(--color-header);
  color: #fff;
  border-color: var(--color-header);
}

/* ── Detail panel ──────────────────────────────────────────────────────────── */
#detail-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: var(--panel-width);
  height: 100%;
  background: white;
  border-left: 1px solid var(--color-border);
  box-shadow: -4px 0 16px rgba(0,0,0,0.12);
  z-index: 500;
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform 0.25s ease;
  overflow: hidden;
}

#detail-panel.hidden {
  transform: translateX(100%);
}

#panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
  background: #F9FAFB;
  flex-shrink: 0;
}

#panel-pole-id {
  font-size: 15px;
  font-weight: 700;
  color: #111827;
  font-family: monospace;
}

#panel-close {
  background: none;
  border: none;
  font-size: 20px;
  color: #6B7280;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
  transition: color 0.12s;
}
#panel-close:hover { color: #111827; }

#panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 16px;
}

.panel-section {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--color-border);
}

.panel-section:last-child { border-bottom: none; }

.panel-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #6B7280;
  margin-bottom: 10px;
}

/* Score row */
#panel-score-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Risk badge (large score number) */
.risk-badge {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
}
.risk-badge.high     { background: var(--color-high); }
.risk-badge.moderate { background: var(--color-moderate); }
.risk-badge.low      { background: var(--color-low); }
.risk-badge.nodata   { background: var(--color-nodata); }

#panel-score-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tier-label {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.05em;
}
.tier-label.high     { color: var(--color-high); }
.tier-label.moderate { color: var(--color-moderate); }
.tier-label.low      { color: var(--color-low); }

.panel-score-sub {
  font-size: 12px;
  color: #6B7280;
}

/* Recommended action - container is transparent so inner .rec-base / .rec-overlay
   carry their own styling. */
.panel-action-text {
  font-size: 13px;
  color: #374151;
  line-height: 1.5;
}

/* Breakdown bars */
.factor-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
}

.factor-label {
  width: 170px;
  flex-shrink: 0;
  color: #374151;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.factor-bar-track {
  background: #F3F4F6;
  border-radius: 4px;
  height: 6px;
  flex: 1;
  min-width: 40px;
}

.factor-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--color-high);
  transition: width 0.3s ease;
}

.factor-pts {
  width: 40px;
  text-align: right;
  font-weight: 600;
  color: #111827;
  font-size: 11px;
  flex-shrink: 0;
}

/* ── Image Analysis panel section ─────────────────────────────────────────── */
#panel-image-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.image-empty {
  font-size: 13px;
  color: #6B7280;
  font-style: italic;
  padding: 6px 10px;
  background: #F9FAFB;
  border-radius: 6px;
  border-left: 3px solid var(--color-nodata);
}

.image-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #374151;
}

.image-meta-label {
  color: #6B7280;
  font-size: 12px;
}

.image-meta-val {
  font-weight: 600;
  color: #111827;
}

.image-meta-sub {
  font-size: 11px;
  color: #6B7280;
  font-style: italic;
  margin-top: -2px;
}

.quality-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #fff;
  text-transform: uppercase;
}
.quality-chip.quality-low      { background: var(--color-low); }
.quality-chip.quality-moderate { background: var(--color-moderate); }
.quality-chip.quality-high     { background: var(--color-high); }
.quality-chip.quality-nodata   { background: var(--color-nodata); }

.image-defects-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6B7280;
  margin-top: 6px;
}

.defect-list {
  list-style: none;
  padding: 0;
  margin: 2px 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.defect-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #111827;
}

.defect-bullet {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-high);
  flex-shrink: 0;
}

.defect-none {
  font-size: 12px;
  color: #6B7280;
  font-style: italic;
}

/* ── Recommendation overlay (image-evidence rules) ────────────────────────── */
.rec-overlay {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.rec-item {
  padding: 8px 10px;
  border-radius: 6px;
  border-left: 3px solid var(--color-high);
  background: #FEF2F2;
}

.rec-item.rec-high {
  border-left-color: var(--color-high);
  background: #FEF2F2;
}

.rec-text {
  font-size: 13px;
  font-weight: 600;
  color: #991B1B;
  line-height: 1.35;
}

.rec-cite {
  font-size: 11px;
  color: #6B7280;
  margin-top: 3px;
  font-style: italic;
}

.rec-base {
  font-size: 13px;
  color: #374151;
  line-height: 1.45;
  background: #FFFBEB;
  border-left: 3px solid var(--color-moderate);
  padding: 10px 12px;
  border-radius: 0 6px 6px 0;
}

/* Environmental data grid */
.env-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
}

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

.env-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6B7280;
}

.env-val {
  font-size: 13px;
  font-weight: 600;
  color: #111827;
}

/* Action buttons in panel */
.popup-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.popup-btn {
  width: 100%;
  padding: 10px 0;
  border: none;
  border-radius: 7px;
  font-size: 13px;
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.popup-btn:hover { opacity: 0.85; }

.popup-btn.primary {
  background: var(--color-header);
  color: #fff;
}

.popup-btn.secondary {
  background: #F3F4F6;
  color: #374151;
  border: 1px solid var(--color-border);
}

.popup-btn.danger {
  background: var(--color-high);
  color: #fff;
}

/* ── Top 100 pulsing animation ─────────────────────────────────────────────── */
/* Targets SVG path elements on Leaflet circleMarkers */
.top-risk-pulse {
  animation: pulse-ring 1.5s ease-out infinite;
}

@keyframes pulse-ring {
  0%   { stroke-width: 1.5px; stroke-opacity: 1; }
  70%  { stroke-width: 8px;   stroke-opacity: 0; }
  100% { stroke-width: 1.5px; stroke-opacity: 1; }
}

/* ── Field crew mode ────────────────────────────────────────────────────────── */
body.field-crew-mode #sidebar {
  display: none;
}

body.field-crew-mode .popup-btn {
  padding: 14px 0;
  font-size: 15px;
}

body.field-crew-mode #header {
  background: #92400E;
}

/* ── Loading overlay ───────────────────────────────────────────────────────── */
#loading {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  gap: 14px;
  font-size: 15px;
  color: #374151;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #E5E7EB;
  border-top-color: var(--color-header);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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

#loading.hidden { display: none; }

/* ── Leaflet popup overrides (kept for compatibility) ──────────────────────── */
.leaflet-popup-content-wrapper {
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  border: 1px solid var(--color-border);
  font-family: var(--font);
  font-size: 13px;
  min-width: 220px;
}

.leaflet-popup-content { margin: 14px 16px; }
.leaflet-popup-tip-container { display: none; }

.popup-title {
  font-size: 15px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
}

.popup-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  color: #374151;
}

.popup-label { color: #6B7280; }

.popup-status-poor    { color: var(--color-poor);    font-weight: 600; }
.popup-status-good    { color: var(--color-good);    font-weight: 600; }
.popup-status-unknown { color: var(--color-unknown); font-weight: 600; }

/* ── Data sources footer strip ─────────────────────────────────────────────── */
#data-sources {
  height: var(--footer-height);
  background: #F9FAFB;
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  font-size: 11px;
  color: #6B7280;
  flex-shrink: 0;
  overflow-x: auto;
}

.ds-label {
  font-weight: 700;
  color: #374151;
  white-space: nowrap;
}

.ds-item::before {
  content: '\2022';
  margin-right: 4px;
}

.ds-item {
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Work Queue page
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Header: brand + nav tabs (shared with map page) ─────────────────────── */
#header-brand {
  display: flex;
  align-items: center;
  gap: 22px;
}

#page-nav {
  display: flex;
  gap: 4px;
}

.page-nav-tab {
  display: inline-block;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.78);
  text-decoration: none;
  border-radius: 6px;
  border: 1.5px solid transparent;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.page-nav-tab:hover { background: rgba(255,255,255,0.10); color: #fff; }
.page-nav-tab.active {
  background: rgba(255,255,255,0.18);
  color: #fff;
  border-color: rgba(255,255,255,0.35);
}

/* ── Queue body container ────────────────────────────────────────────────── */
body.queue-page {
  overflow: auto;
  background: #F9FAFB;
}

#queue-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 24px 48px;
  gap: 20px;
}

/* ── Page title strip ────────────────────────────────────────────────────── */
#queue-title-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.queue-title {
  font-size: 22px;
  font-weight: 700;
  color: #111827;
  letter-spacing: -0.01em;
}

.queue-subtitle {
  font-size: 13px;
  color: #6B7280;
  margin-top: 2px;
}

/* ── Summary strip ───────────────────────────────────────────────────────── */
#queue-summary-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

.summary-card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.summary-num {
  font-size: 24px;
  font-weight: 800;
  color: #111827;
  line-height: 1.1;
}

.summary-lbl {
  font-size: 11px;
  font-weight: 600;
  color: #6B7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Filter bar ──────────────────────────────────────────────────────────── */
#queue-filter-bar {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6B7280;
}

.filter-select {
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font);
  background: #fff;
  color: #111827;
  cursor: pointer;
  min-width: 110px;
}

.filter-select:focus { outline: 2px solid rgba(30, 58, 138, 0.4); outline-offset: -1px; }

.filter-sort { margin-left: auto; }

.filter-count {
  font-size: 12px;
  color: #6B7280;
  margin-left: 6px;
  white-space: nowrap;
}

/* ── Cards container ─────────────────────────────────────────────────────── */
#queue-cards {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.queue-empty {
  background: #fff;
  border: 1px dashed var(--color-border);
  border-radius: 10px;
  padding: 28px;
  text-align: center;
  color: #6B7280;
  font-size: 13px;
}

#queue-pager {
  display: flex;
  justify-content: center;
  padding-top: 8px;
}

#load-more-btn {
  max-width: 320px;
}

/* ── Pole card ───────────────────────────────────────────────────────────── */
.queue-card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-nodata);
  border-radius: 10px;
  padding: 16px 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  transition: box-shadow 0.15s, opacity 0.15s;
}
.queue-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.07); }

.queue-card-critical { border-left-color: #B91C1C; border-left-width: 5px; }
.queue-card-high     { border-left-color: var(--color-high); }
.queue-card-medium   { border-left-color: var(--color-moderate); }
.queue-card-low      { border-left-color: var(--color-low); }

.queue-card-dispatched { opacity: 0.78; }
.queue-card-completed  { opacity: 0.65; }

.card-flash {
  outline: 3px solid rgba(30, 58, 138, 0.5);
  outline-offset: 2px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.card-head-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-rank {
  font-size: 12px;
  font-weight: 700;
  color: #6B7280;
  background: #F3F4F6;
  padding: 3px 8px;
  border-radius: 5px;
  font-variant-numeric: tabular-nums;
}

.risk-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #fff;
}
.risk-pill-critical { background: #B91C1C; }
.risk-pill-high     { background: var(--color-high); }
.risk-pill-medium   { background: var(--color-moderate); }
.risk-pill-low      { background: var(--color-low); }

.status-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.status-dispatched { background: #DBEAFE; color: #1E40AF; }
.status-completed  { background: #DCFCE7; color: #166534; }

.card-score {
  font-size: 13px;
  font-weight: 700;
  color: #111827;
  font-variant-numeric: tabular-nums;
}

.card-title-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.card-pole-id {
  font-size: 16px;
  font-weight: 700;
  color: #111827;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.card-subtitle {
  font-size: 12px;
  color: #6B7280;
}

/* ── Card sections ───────────────────────────────────────────────────────── */
.card-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-section-title {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6B7280;
}

/* Drivers */
.driver-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.driver-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #111827;
  cursor: help;
}

.driver-bullet {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-high);
  flex-shrink: 0;
}

.driver-label {
  flex: 1;
  min-width: 0;
}

.driver-pts {
  font-weight: 700;
  color: #111827;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.driver-empty {
  font-size: 12px;
  color: #6B7280;
  font-style: italic;
}

/* Action block */
.card-action {
  font-size: 13px;
  color: #111827;
  font-weight: 600;
  background: #FFFBEB;
  border-left: 3px solid var(--color-moderate);
  padding: 8px 12px;
  border-radius: 0 6px 6px 0;
}

.card-action-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 12px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 12px;
  background: #F3F4F6;
  color: #374151;
  font-weight: 600;
}

.meta-symbol {
  font-weight: 800;
  color: #6B7280;
}

.urgency-critical { background: #FEE2E2; color: #991B1B; }
.urgency-high     { background: #FEF3C7; color: #92400E; }
.urgency-medium   { background: #DBEAFE; color: #1E40AF; }
.urgency-low      { background: #DCFCE7; color: #166534; }
.urgency-none     { background: #F3F4F6; color: #6B7280; }

/* Contractors */
.contractor-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.contractor-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #111827;
}

.contractor-check {
  color: var(--color-low);
  font-weight: 800;
}

.contractor-name { font-weight: 600; }

.contractor-fit { color: #6B7280; font-size: 12px; }

.contractor-empty {
  font-size: 12px;
  color: #6B7280;
  font-style: italic;
}

/* Impact */
.card-impact .impact-row {
  font-size: 13px;
  color: #374151;
}

.impact-critical {
  color: #B91C1C;
  font-weight: 700;
}

/* Card footer */
.card-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--color-border);
}

.card-footer .popup-btn {
  width: auto;
  padding: 7px 14px;
  font-size: 13px;
}

.popup-btn.link {
  background: transparent;
  border: none;
  color: var(--color-header);
  padding: 7px 6px;
}
.popup-btn.link:hover { background: #F3F4F6; }

.footer-confirmed {
  color: #1E40AF;
  font-weight: 600;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.card-footer-dispatched {
  background: #F0F9FF;
  margin: 4px -20px -14px;
  padding: 10px 20px;
  border-top: 1px solid #BFDBFE;
  border-radius: 0 0 10px 10px;
  justify-content: space-between;
}

/* Card details (expand) */
.card-details {
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px dashed var(--color-border);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 3px 0;
  border-bottom: 1px dotted #E5E7EB;
}

.detail-key   { color: #374151; }
.detail-val   { color: #111827; font-weight: 600; font-variant-numeric: tabular-nums; }

.detail-trigger-list {
  list-style: disc;
  padding-left: 18px;
  margin: 4px 0 0;
  font-size: 12px;
  color: #374151;
}
.detail-trigger-list li { margin-bottom: 3px; }

/* ── Dispatch modal ──────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
}

.modal-panel {
  position: relative;
  background: #fff;
  border-radius: 12px;
  width: 540px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
  overflow: hidden;
}

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

.modal-title {
  font-size: 15px;
  font-weight: 700;
  color: #111827;
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: #6B7280;
  cursor: pointer;
  padding: 0 4px;
}
.modal-close:hover { color: #111827; }

.modal-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px 18px 4px;
}

.modal-section {
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}
.modal-section:last-child { border-bottom: none; }

.modal-section-title {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6B7280;
  margin-bottom: 8px;
}

.dispatch-scope-list {
  list-style: disc;
  padding-left: 20px;
  margin: 0;
  font-size: 13px;
  color: #111827;
}
.dispatch-scope-list li { margin-bottom: 4px; }

.dispatch-contractor-block {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #FAFAFA;
}

.dispatch-contractor-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
}

.dispatch-contractor-tag {
  font-size: 11px;
  color: #6B7280;
  text-transform: lowercase;
}

.dispatch-contractor-meta {
  font-size: 12px;
  color: #374151;
  margin-top: 3px;
}

.dispatch-fit { color: #6B7280; font-style: italic; }

.dispatch-include {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}
.dispatch-include input { accent-color: var(--color-header); }

.dispatch-extras {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dispatch-extra-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
}

.dispatch-totals { display: flex; flex-direction: column; gap: 4px; }

.dispatch-total-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}
.dispatch-total-row span:first-child { color: #6B7280; }
.dispatch-total-row span:last-child  { font-weight: 700; color: #111827; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--color-border);
  background: #F9FAFB;
}

.modal-footer .popup-btn {
  width: auto;
  padding: 8px 18px;
}

body.modal-open { overflow: hidden; }

/* ── Toast ──────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #111827;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.3);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  max-width: 480px;
}

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

/* ── Queue page: mobile ─────────────────────────────────────────────────── */
@media (max-width: 767px) {
  body.queue-page #header { flex-wrap: wrap; height: auto; padding: 8px 12px; }
  #header-brand { flex-wrap: wrap; }
  #queue-summary-strip { grid-template-columns: repeat(2, 1fr); }
  #queue-filter-bar    { flex-direction: column; align-items: flex-start; }
  .filter-sort         { margin-left: 0; width: 100%; }
  .filter-select       { width: 100%; }
  .detail-grid         { grid-template-columns: 1fr; }
}

/* ── Marker cluster overrides ──────────────────────────────────────────────── */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background-color: rgba(30, 58, 138, 0.18);
}
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background-color: rgba(30, 58, 138, 0.7);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  font-family: var(--font);
}

/* ── Mobile responsive ─────────────────────────────────────────────────────── */
@media (max-width: 767px) {
  body { overflow: auto; }

  #body {
    flex-direction: column;
    overflow: visible;
  }

  #sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    flex-direction: row;
    overflow-x: auto;
    overflow-y: visible;
    flex-wrap: nowrap;
    max-height: none;
  }

  .sidebar-section {
    min-width: 200px;
    border-bottom: none;
    border-right: 1px solid var(--color-border);
    flex-shrink: 0;
  }

  #map-container {
    height: calc(100vh - var(--header-height) - var(--footer-height) - 180px);
    min-height: 300px;
  }

  #detail-panel {
    width: 100%;
    height: 60vh;
    top: auto;
    bottom: 0;
    right: 0;
    transform: translateY(0);
    border-left: none;
    border-top: 1px solid var(--color-border);
  }

  #detail-panel.hidden {
    transform: translateY(100%);
  }

  #map-toolbar {
    bottom: 12px;
    top: auto;
    right: 12px;
  }

  #search-input { width: 130px; }

  .env-grid { grid-template-columns: 1fr; }
}
