/* Route map widget — in-chat preview */
.route-widget {
  margin: 6px 0;
  border: 1px solid var(--border);
  background: white;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.route-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 6px;
  gap: 10px;
}
.route-title { font-weight: 600; font-size: 14px; }
.route-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.route-open {
  background: var(--brand-soft);
  border: 1px solid rgba(15,122,77,0.25);
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.route-open:hover { background: #d9ebe2; }
.route-open:active { transform: scale(0.97); }

.route-map {
  height: 220px;
  width: 100%;
  background: #eaecee;
}
.route-map-error {
  padding: 20px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* Route mini-list is now the *full* list */
.route-mini-list {
  padding: 6px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.route-row {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.route-row:first-child { border-top: none; padding-top: 6px; }
.route-row-gutter { display: flex; justify-content: center; padding-top: 3px; }
.route-row-num {
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: white;
  background: var(--muted);
}
.route-row-pri-high .route-row-num,
.route-row-pri-recovery .route-row-num { background: #d94040; }
.route-row-pri-medium .route-row-num { background: #f7b500; }

.route-row-main { min-width: 0; }
.route-row-top { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.route-row-eta {
  font-weight: 700; font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: #1a1a1a;
  min-width: 46px;
}
.route-row-name { font-weight: 600; font-size: 14px; color: #1a1a1a; }
.route-row-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.route-row-badges {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: 6px;
}
.route-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f6f7f8;
  color: #374151;
  border: 1px solid var(--border);
}
.route-badge-appt { background: #fff7e1; color: #92721a; border-color: #f2d98b; }
.route-badge-adhoc { background: #eef2ff; color: #4338ca; border-color: #c7d2fe; }
.route-row-pri-high .route-badge:first-of-type,
.route-row-pri-recovery .route-badge:first-of-type {
  background: #ffe9e9; color: #b53030; border-color: #f3c9c9;
}

.route-row-stats {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-top: 6px;
  font-size: 12px;
  color: #475569;
}
.route-stat { font-variant-numeric: tabular-nums; }
.route-stat.stat-down { color: var(--danger); font-weight: 600; }
.route-stat.stat-up { color: var(--brand); font-weight: 600; }

/* Leaflet marker customization */
.route-stop-icon, .route-start-icon {
  background: transparent !important;
  border: none !important;
}
.stop-marker {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: white;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.start-marker {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--brand);
  border: 3px solid white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* Full-screen report overlay */
#report-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: grid;
  place-items: stretch;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

.report-modal {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
@media (min-width: 900px) {
  .report-modal {
    position: relative;
    inset: auto;
    margin: 4vh auto;
    max-width: 960px;
    max-height: 92vh;
    border-radius: 16px;
    box-shadow: 0 30px 90px rgba(0,0,0,0.35);
  }
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }

.report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: white;
}
.report-title { font-weight: 700; font-size: 18px; }
.report-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.report-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 8px;
}
.report-close:active { background: var(--border); }

.report-map {
  height: 40vh;
  min-height: 260px;
  width: 100%;
  background: #eaecee;
  flex-shrink: 0;
}
@media (min-width: 900px) {
  .report-map { height: 360px; }
}

.report-actions {
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: white;
  display: flex;
  gap: 8px;
}
.report-action-btn {
  background: var(--brand);
  color: white;
  border: none;
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
}
.report-action-btn:active { transform: scale(0.97); }

.report-timeline {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 24px;
  -webkit-overflow-scrolling: touch;
}

.timeline-item {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
.timeline-gutter {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.timeline-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--muted);
  color: white;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}
.timeline-item.priority-high .timeline-number,
.timeline-item.priority-recovery .timeline-number { background: #d94040; }
.timeline-item.priority-medium .timeline-number { background: #f7b500; }
.timeline-line {
  width: 2px;
  flex: 1;
  background: var(--border);
  margin-top: 4px;
  min-height: 12px;
}
.timeline-item:last-child .timeline-line { display: none; }

.timeline-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.timeline-row1 {
  display: flex;
  gap: 10px;
  align-items: baseline;
}
.timeline-eta {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  color: #1a1a1a;
  min-width: 50px;
}
.timeline-name { font-weight: 600; font-size: 15px; flex: 1; }
.timeline-row2 { font-size: 12px; color: var(--muted); margin-top: 2px; }
.timeline-row3 {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 6px;
  font-size: 12px;
  color: #334155;
  flex-wrap: wrap;
}
.timeline-revenue { font-weight: 500; }
.timeline-badges {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.badge {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f6f7f8;
  color: #374151;
}
.badge-appt { background: #fff7e1; color: #92721a; border-color: #f2d98b; }
.badge-scen { background: var(--brand-soft); color: var(--brand-dark); border-color: rgba(15,122,77,0.25); }
.badge-adhoc { background: #eef2ff; color: #4338ca; border-color: #c7d2fe; }

/* Visit card — appended to chat after a voice recording */
.visit-widget {
  margin: 6px 0;
  border: 1px solid var(--border);
  background: white;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.visit-widget-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px 8px;
}
.visit-icon {
  font-size: 22px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand-soft);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.visit-meta { flex: 1; min-width: 0; }
.visit-title { font-weight: 600; font-size: 14px; color: #1a1a1a; }
.visit-sub { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.visit-status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: #fff7e1;
  color: #92721a;
  border: 1px solid #f2d98b;
}
.visit-status-pill[data-status="saved"] {
  background: var(--brand-soft);
  color: var(--brand-dark);
  border-color: rgba(15,122,77,0.25);
}
.visit-status-pill[data-status="exported"] {
  background: #eef2ff;
  color: #4338ca;
  border-color: #c7d2fe;
}
.visit-summary {
  padding: 0 14px 8px;
  font-size: 13px;
  color: #1a1a1a;
  line-height: 1.45;
}
.visit-tags {
  padding: 0 14px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.visit-tag {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  border: 1px solid rgba(15,122,77,0.15);
}
.visit-tag-warn { background: #fff2f2; color: var(--danger); border-color: #f3c9c9; }
.visit-tag-order { background: #eef9f3; color: var(--brand-dark); }
.visit-actions {
  display: flex;
  gap: 6px;
  padding: 0 14px 12px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 4px;
}
.visit-btn {
  flex: 1;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: white;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.visit-btn:hover { background: #f6f7f8; }
.visit-btn:active { transform: scale(0.97); }
.visit-btn.primary { background: var(--brand); color: white; border-color: var(--brand); }
.visit-btn.primary:hover { background: var(--brand-dark); }
.visit-btn.subtle { color: var(--muted); }
.visit-btn[disabled] { opacity: 0.5; cursor: default; }
