/* Shared Sales Dispatch Board layout. Brand via --sdb-* on :root per folder. */
:root {
  --sdb-header: #0f172a;
  --sdb-accent: #2978cd;
  --sdb-accent-hover: #1f5fa0;
  --sdb-today: #38bdf8;
  --sdb-today-header: #0c4a6e;
  --sdb-rep: #0f172a;
  --sdb-map-border: var(--sdb-accent);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  padding: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #f5f5f5;
  color: #1f2937;
  min-height: 100vh;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--sdb-header);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  gap: 12px;
  flex-wrap: wrap;
}
header .brand { font-weight: 700; font-size: 1.1em; }
header nav { display: flex; gap: 10px; align-items: center; }
header a, header button {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 0.85em;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}
header a:hover, header button:hover { background: rgba(255,255,255,0.28); }
.rep-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85em;
  margin-left: auto;
}
.rep-filter label { white-space: nowrap; }
.rep-filter select {
  background: #fff;
  color: #111827;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 0.9em;
  font-family: inherit;
  min-width: 160px;
}
#status {
  padding: 8px 18px;
  font-size: 0.85em;
  color: #6b7280;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
}
#status.error { color: #c0392b; }
#map-wrap {
  position: relative;
  height: 38vh;
  min-height: 240px;
  border-bottom: 3px solid var(--sdb-map-border);
}
#map { width: 100%; height: 100%; }
#map-legend {
  position: absolute;
  bottom: 12px;
  left: 12px;
  background: rgba(255,255,255,0.95);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.75em;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  max-width: calc(100% - 24px);
}
#map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
#map-legend i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid rgba(0,0,0,0.15);
}
.board {
  display: flex;
  gap: 12px;
  padding: 14px;
  overflow-x: auto;
  align-items: flex-start;
  min-height: 40vh;
}
.board.saving { pointer-events: none; opacity: 0.72; }
.column {
  flex: 1 0 220px;
  min-width: 220px;
  max-width: 320px;
  background: #eeeeee;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(62vh - 40px);
  border: 1px solid #d0d0d0;
}
.column.today {
  border-color: var(--sdb-today);
  box-shadow: 0 0 0 2px var(--sdb-today), 0 6px 16px rgba(15, 23, 42, 0.12);
}
.column.drag-over {
  outline: 2px dashed var(--sdb-accent);
  outline-offset: -2px;
}
.col-header {
  background: var(--sdb-accent);
  color: #fff;
  font-weight: 700;
  padding: 10px 12px;
  font-size: 0.95em;
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 3px solid var(--sdb-today);
  gap: 8px;
}
.column.today .col-header { background: var(--sdb-today-header); }
.today-badge {
  background: #FDE68A;
  color: #78350f;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 0.68em;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.col-count {
  background: rgba(255,255,255,0.25);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.8em;
}
.col-body {
  padding: 10px;
  overflow-y: auto;
  flex: 1;
  min-height: 80px;
}
.empty-state {
  color: #9ca3af;
  font-style: italic;
  font-size: 0.85em;
  padding: 16px 8px;
  text-align: center;
}
.rep-group { margin-bottom: 12px; }
.rep-header {
  background: var(--sdb-rep);
  color: #fff;
  font-size: 0.8em;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 8px;
}
.rep-header .count { opacity: 0.8; font-weight: 400; }
.rep-cards { min-height: 8px; }
.contact-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s;
  cursor: grab;
}
.contact-card:hover,
.contact-card.highlight {
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.18);
  transform: translateY(-1px);
  border-color: var(--sdb-accent);
}
.contact-card.dragging {
  opacity: 0.45;
  cursor: grabbing;
  pointer-events: none;
}
.card-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 4px;
}
.stop-badge {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--sdb-accent);
  color: #fff;
  font-size: 0.72em;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.card-name {
  font-weight: 700;
  font-size: 0.92em;
  color: #111827;
  flex: 1;
}
.card-company {
  font-size: 0.8em;
  color: #4b5563;
  margin-bottom: 4px;
}
.card-address, .card-phone {
  font-size: 0.78em;
  color: #6b7280;
  margin-bottom: 3px;
}
a.card-phone {
  display: inline-block;
  text-decoration: none;
  color: var(--sdb-accent);
  font-weight: 600;
}
a.card-phone:hover { text-decoration: underline; }
.card-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.75em;
  color: var(--sdb-accent);
  text-decoration: none;
  font-weight: 600;
}
.card-link:hover { text-decoration: underline; }
.popup-nav-row,
.card-nav-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.popup-nav-btn {
  flex: 1;
  padding: 5px 6px;
  background-color: #27ae60;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
  display: inline-block;
}
.popup-nav-btn:hover { background-color: #1e8449; color: white; }
.popup-nav-btn.apple { background-color: #555; }
.popup-nav-btn.apple:hover { background-color: #333; }
.loading-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: #6b7280;
  gap: 12px;
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e5e7eb;
  border-top-color: var(--sdb-accent);
  border-radius: 50%;
  animation: sdb-spin 0.8s linear infinite;
}
@keyframes sdb-spin { to { transform: rotate(360deg); } }
.mapboxgl-popup-content {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.85em;
}
.mapboxgl-popup-content strong { display: block; margin-bottom: 4px; }
.popup-edit-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 7px 10px;
  background: var(--sdb-accent);
  color: #fff;
  border: none;
  border-radius: 5px;
  font-size: 0.85em;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
}
.popup-edit-btn:hover { background: var(--sdb-accent-hover); }
.setup-note {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 8px;
  padding: 14px 18px;
  margin: 14px;
  font-size: 0.9em;
  color: #856404;
}
.setup-note code {
  background: rgba(0,0,0,0.06);
  padding: 1px 4px;
  border-radius: 4px;
}
@media (max-width: 700px) {
  #map-wrap { height: 28vh; min-height: 180px; }
  .column { max-height: 50vh; }
  .rep-filter { margin-left: 0; width: 100%; }
  .rep-filter select { flex: 1; }
}
