/* ── Reset & base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f172a;
  --surface:   #1e293b;
  --surface2:  #273549;
  --border:    #334155;
  --text:      #e2e8f0;
  --muted:     #94a3b8;
  --blue:      #3b82f6;
  --blue-dim:  #1d4ed8;
  --green:     #22c55e;
  --amber:     #f59e0b;
  --red:       #ef4444;
  --topbar-h:  48px;
}

html, body { height: 100%; overflow: hidden; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
       background: var(--bg); color: var(--text); font-size: 13px; }

/* ── Top bar ────────────────────────────────────────────────────────────────── */
#topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 1000;
  position: relative;
}
.brand { font-size: 15px; font-weight: 600; color: var(--text); white-space: nowrap; }
.brand strong { color: var(--blue); }
.topbar-mid { flex: 1; display: flex; align-items: center; gap: 8px; }
.topbar-right { display: flex; align-items: center; gap: 8px; color: var(--muted);
                font-size: 12px; white-space: nowrap; }
.pipe { color: var(--border); }
#updated-time { color: var(--text); }

/* status dot */
.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dot.offline  { background: var(--border); }
.dot.live     { background: var(--green);
                box-shadow: 0 0 0 3px rgba(34,197,94,.25);
                animation: pulse 2s infinite; }
.dot.stale    { background: var(--amber); }
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 3px rgba(34,197,94,.25); }
  50%      { box-shadow: 0 0 0 6px rgba(34,197,94,.08); }
}

.icon-btn {
  background: none; border: 1px solid var(--border); color: var(--muted);
  border-radius: 6px; width: 28px; height: 28px; cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.icon-btn:hover { background: var(--surface2); color: var(--text); }

/* ── Layout ──────────────────────────────────────────────────────────────────── */
#layout {
  display: flex;
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────────── */
#sidebar {
  width: 340px;
  min-width: 300px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── Cards ───────────────────────────────────────────────────────────────────── */
.card { border-bottom: 1px solid var(--border); }
.card-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; cursor: pointer; user-select: none;
  font-weight: 600; font-size: 12px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
}
.card-header:hover { background: var(--surface2); }
.chevron { font-size: 10px; transition: transform .2s; }
.card-body { padding: 12px 14px; }
.card-body.collapsed { display: none; }

/* ── CSV drop zone ───────────────────────────────────────────────────────────── */
.drop-zone {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; padding: 20px 12px;
  border: 1.5px dashed var(--border); border-radius: 8px;
  cursor: pointer; text-align: center;
  transition: border-color .15s, background .15s;
  -webkit-tap-highlight-color: rgba(59,130,246,.2);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--blue); background: rgba(59,130,246,.07);
}
.drop-zone:active { background: rgba(59,130,246,.1); }
.drop-zone:focus  { outline: 2px solid var(--blue); outline-offset: 2px; }

/* Hide file input visually but keep it in the layout and clickable.
   display:none/hidden can prevent input.click() from opening the iOS picker. */
.csv-file-input {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.drop-icon { font-size: 22px; }
#drop-label { font-weight: 500; font-size: 13px; }
#drop-sub { color: var(--muted); font-size: 11px; }

.csv-info {
  margin-top: 10px; padding: 8px 12px;
  background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.3);
  border-radius: 6px; font-size: 12px; color: var(--green);
}

/* ── Filter bar ──────────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.chk-label { display: flex; align-items: center; gap: 6px;
             cursor: pointer; font-size: 12px; color: var(--muted); white-space: nowrap; }
.chk-label input { accent-color: var(--blue); cursor: pointer; }
#sort-by {
  margin-left: auto; background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); padding: 4px 8px; border-radius: 6px; font-size: 12px;
  cursor: pointer; outline: none;
}

.list-stats {
  padding: 6px 14px; font-size: 11px; color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.list-stats strong { color: var(--text); }

/* ── Bus cards ───────────────────────────────────────────────────────────────── */
#bus-list { flex: 1; }

.bus-card {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .12s;
  position: relative;
}
.bus-card:hover { background: var(--surface2); }
.bus-card.selected { background: rgba(59,130,246,.12);
                     border-left: 3px solid var(--blue); padding-left: 11px; }
.bus-card.photo-flag { border-left: 3px solid var(--amber); padding-left: 11px; }
.bus-card.photo-flag.selected { border-left: 3px solid var(--blue); }

.bc-row1 { display: flex; align-items: baseline; gap: 6px; margin-bottom: 3px; }
.bc-rank { font-size: 11px; color: var(--muted); min-width: 18px; }
.bc-id { font-weight: 700; font-size: 14px; color: var(--text); }
.bc-dist { margin-left: auto; font-size: 13px; font-weight: 600;
           color: var(--blue); white-space: nowrap; }

.bc-photo-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 700; color: var(--amber);
  background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.3);
  border-radius: 4px; padding: 1px 6px; margin-bottom: 4px;
  text-transform: uppercase; letter-spacing: .04em;
}

.bc-route { font-size: 12px; color: var(--text); margin-bottom: 2px;
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-dir   { font-size: 11px; color: var(--muted); }
.bc-sched { font-size: 11px; }
.sched-behind { color: var(--red); }
.sched-ahead  { color: var(--green); }
.sched-waiting { color: var(--amber); }
.bc-loc { font-size: 11px; color: var(--muted); margin-top: 2px;
          white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Off-route list ──────────────────────────────────────────────────────────── */
.off-row { display: flex; gap: 8px; align-items: center;
           padding: 5px 0; font-size: 12px; }
.off-id { font-weight: 600; color: var(--muted); width: 64px; flex-shrink: 0; }
.off-label { color: var(--muted); font-style: italic; }

/* ── Map ─────────────────────────────────────────────────────────────────────── */
#map { flex: 1; z-index: 1; }

/* Leaflet overrides */
.leaflet-container { background: #1a2332; }

/* Custom bus marker */
.bus-marker {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; border: 2.5px solid rgba(255,255,255,.35);
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
  font-family: -apple-system, sans-serif; cursor: pointer;
  line-height: 1;
}
.bus-marker-num { font-size: 9px; font-weight: 800; color: #fff; }
.bus-marker-dir { font-size: 11px; color: rgba(255,255,255,.9); }

.ref-marker {
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 3px solid var(--blue);
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
}

/* ── Detail panel ────────────────────────────────────────────────────────────── */
#detail-panel {
  position: fixed; top: var(--topbar-h); right: 0; bottom: 0;
  width: 300px; background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 900; overflow-y: auto;
  box-shadow: -4px 0 20px rgba(0,0,0,.4);
  transition: transform .25s ease;
}
#detail-panel.hidden { display: none; }

.detail-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 15px; position: sticky; top: 0;
  background: var(--surface); z-index: 1;
}
#detail-close {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 18px; line-height: 1; padding: 2px 6px; border-radius: 4px;
}
#detail-close:hover { color: var(--text); background: var(--surface2); }
#detail-content { padding: 16px; }

.det-row {
  display: flex; gap: 8px; margin-bottom: 10px; align-items: flex-start;
}
.det-label { color: var(--muted); font-size: 11px; min-width: 80px;
             padding-top: 1px; text-transform: uppercase; letter-spacing: .03em; }
.det-val { color: var(--text); font-size: 13px; flex: 1; }
.det-val.mono { font-family: monospace; font-size: 12px; }

.det-section { font-size: 11px; font-weight: 700; color: var(--muted);
               text-transform: uppercase; letter-spacing: .05em;
               margin: 14px 0 8px; padding-bottom: 4px;
               border-bottom: 1px solid var(--border); }

.status-badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
}
.status-active   { background: rgba(34,197,94,.15); color: var(--green); }
.status-inactive { background: rgba(148,163,184,.1); color: var(--muted); }

/* ── Empty / loading states ──────────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; padding: 40px 20px; color: var(--muted); text-align: center;
}
.empty-state .em-icon { font-size: 36px; }
.empty-state .em-title { font-size: 14px; font-weight: 600; color: var(--text); }
.empty-state .em-sub { font-size: 12px; line-height: 1.5; }

/* ── Leaflet popup ───────────────────────────────────────────────────────────── */
.leaflet-popup-content-wrapper {
  background: var(--surface2) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: 10px !important;
  box-shadow: 0 4px 20px rgba(0,0,0,.5) !important;
}
.leaflet-popup-tip { background: var(--surface2) !important; }
.leaflet-popup-content { margin: 12px 14px !important; }
.popup-bus { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.popup-route { font-size: 12px; margin-bottom: 2px; }
.popup-sched { font-size: 11px; color: var(--muted); }

/* ── Capture feature ────────────────────────────────────────────────────── */
.capture-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  margin: 8px 0;
  background: linear-gradient(180deg, #1a2236 0%, #131a2a 100%);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  flex-wrap: wrap;
}
.capture-bar .cap-stat {
  display: flex; flex-direction: column; min-width: 56px;
}
.capture-bar .cap-stat #cap-count {
  font-size: 18px; font-weight: 700; color: #22c55e; line-height: 1;
}
.capture-bar .cap-label {
  font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px;
}
.cap-progress-wrap {
  flex: 1; height: 6px; background: rgba(255,255,255,0.07); border-radius: 999px; overflow: hidden;
  min-width: 60px;
}
.cap-progress {
  height: 100%; background: linear-gradient(90deg,#22c55e,#16a34a);
  width: 0%; transition: width 300ms ease;
}
.cap-btn {
  font-size: 11px; padding: 6px 10px; border: none; border-radius: 6px;
  cursor: pointer; font-weight: 600; white-space: nowrap;
}
.cap-btn.primary   { background: #2563eb; color: white; }
.cap-btn.primary:hover   { background: #1d4ed8; }
.cap-btn.secondary { background: rgba(255,255,255,0.06); color: var(--muted); }
.cap-btn.secondary:hover { background: rgba(255,255,255,0.1); color: white; }

/* Bus card with capture checkbox */
.bus-card { display: flex; gap: 10px; align-items: flex-start; }
.bus-card .bc-main { flex: 1; min-width: 0; }
.bc-capture {
  flex-shrink: 0;
  width: 24px; height: 24px; margin-top: 2px;
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  background: transparent;
  color: white; font-size: 14px; font-weight: 800;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 150ms ease;
}
.bc-capture:hover { border-color: #22c55e; background: rgba(34,197,94,0.1); }
.bc-capture.checked {
  background: #16a34a; border-color: #16a34a; color: white;
  box-shadow: 0 0 0 3px rgba(34,197,94,0.18);
}
.bus-card.captured {
  opacity: 0.62;
  background: linear-gradient(180deg, rgba(22,163,74,0.07) 0%, transparent 100%);
  border-left: 3px solid #16a34a;
}
.bus-card.captured .bc-id,
.bus-card.captured .bc-route { text-decoration: line-through; text-decoration-thickness: 1px; }

.bc-badges { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0; }
.bc-cap-badge {
  display: inline-block;
  font-size: 10px; padding: 2px 8px;
  background: rgba(34,197,94,0.15); color: #22c55e;
  border: 1px solid rgba(34,197,94,0.3);
  border-radius: 999px; font-weight: 600;
}

/* ── LYNX stops on map ──────────────────────────────────────────────────── */
.stops-toggle {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--muted); cursor: pointer;
  user-select: none; padding: 4px 8px; border-radius: 6px;
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.06);
}
.stops-toggle:hover { background: rgba(255,255,255,0.08); color: white; }
.stops-toggle input { margin-right: 2px; }
.stops-toggle.loading { opacity: 0.6; }
.stops-toggle.loading::after { content: '…'; margin-left: 4px; }

.stop-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #fbbf24;
  border: 2px solid #1a2236;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4);
}

/* Stop popup */
.popup-stop { font-family: inherit; min-width: 180px; }
.popup-stop .ps-name { font-size: 13px; margin-bottom: 4px; color: #f8fafc; }
.popup-stop .ps-meta { font-size: 11px; color: #94a3b8; line-height: 1.4; }
.popup-stop .ps-meta code { color: #fbbf24; background: rgba(251,191,36,0.1); padding: 1px 4px; border-radius: 3px; }

/* Marker cluster styling — match dark theme */
.marker-cluster-small  { background: rgba(59,130,246,0.4); }
.marker-cluster-small div  { background: rgba(59,130,246,0.8); color: white; font-weight: 700; }
.marker-cluster-medium { background: rgba(245,158,11,0.4); }
.marker-cluster-medium div { background: rgba(245,158,11,0.85); color: white; font-weight: 700; }
.marker-cluster-large  { background: rgba(239,68,68,0.4); }
.marker-cluster-large div  { background: rgba(239,68,68,0.85); color: white; font-weight: 700; }

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE LAYOUT
   ═══════════════════════════════════════════════════════════════════════════ */

/* Hide mobile-only elements on desktop */
.mobile-only { display: none !important; }

/* Bottom tab nav (built into layout but hidden on desktop) */
#bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: calc(56px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 1100;
  box-shadow: 0 -2px 10px rgba(0,0,0,.3);
}
.bn-btn {
  flex: 1; background: none; border: none; color: var(--muted);
  font-family: inherit; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 6px 4px; position: relative;
  -webkit-tap-highlight-color: rgba(59,130,246,.2);
  transition: color .15s;
}
.bn-btn .bn-icon { font-size: 20px; line-height: 1; }
.bn-btn .bn-label { font-size: 10px; font-weight: 600; }
.bn-btn.active { color: var(--blue); }
.bn-btn.active::before {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 32px; height: 3px; background: var(--blue);
  border-radius: 0 0 3px 3px;
}
.bn-badge {
  position: absolute; top: 4px; right: 28%;
  background: var(--green); color: white;
  font-size: 9px; font-weight: 700;
  padding: 1px 5px; border-radius: 999px;
  min-width: 16px; text-align: center; line-height: 1.3;
}
.bn-badge:empty { display: none; }

/* ───── Phones & narrow tablets (< 768px) ───── */
@media (max-width: 767px) {
  :root { --topbar-h: 52px; }

  html, body { overflow: hidden; }
  body { font-size: 14px; }

  /* Reveal the mobile bottom nav */
  .mobile-only { display: flex !important; }
  .hide-mobile { display: none !important; }

  /* Compact topbar */
  #topbar {
    padding: 0 12px; gap: 8px;
    padding-top: env(safe-area-inset-top);
    height: calc(var(--topbar-h) + env(safe-area-inset-top));
  }
  .brand { font-size: 14px; }
  .brand-suffix { display: none; }
  .topbar-mid { flex: 1; font-size: 12px; min-width: 0; overflow: hidden; }
  #status-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
                   font-size: 12px; }
  .topbar-right { gap: 6px; }
  .stops-toggle { padding: 6px 8px; }
  .stops-toggle .stops-label { display: none; }
  .icon-btn { width: 34px; height: 34px; font-size: 18px; }

  /* Stack layout: sidebar OR map, never both */
  #layout {
    display: block; position: relative;
    height: calc(100vh - var(--topbar-h) - 56px - env(safe-area-inset-bottom));
  }

  /* Sidebar takes the whole content area in "list" view */
  #sidebar {
    width: 100%; min-width: 0;
    border-right: none;
    height: 100%;
    position: absolute; inset: 0;
  }

  /* Map takes the whole content area in "map" view */
  #map {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
  }

  /* View switching driven by body class */
  body[data-view="list"] #map     { display: none; }
  body[data-view="map"]  #sidebar { display: none; }
  body[data-view="capture"] #map  { display: none; }
  body[data-view="capture"] #sidebar > .card,
  body[data-view="capture"] #sidebar > .filter-bar,
  body[data-view="capture"] #sidebar > .list-stats { display: none; }
  body[data-view="capture"] #sidebar { display: flex; }
  body[data-view="capture"] #bus-list { padding-top: 6px; }
  body[data-view="capture"] #bus-list .bus-card:not(.photo-flag):not(.captured) { display: none; }

  /* Larger tap targets on bus cards */
  .bus-card {
    padding: 14px 14px;
    gap: 14px;
    min-height: 60px;
  }
  .bc-id { font-size: 16px; }
  .bc-dist { font-size: 15px; }
  .bc-route { font-size: 13px; white-space: normal; }
  .bc-dir, .bc-sched, .bc-loc { font-size: 12px; }

  /* Bigger capture checkbox on touch */
  .bc-capture {
    width: 36px; height: 36px;
    font-size: 20px;
    margin-top: 0;
    border-width: 2px;
  }

  /* Filter bar wraps cleanly */
  .filter-bar {
    flex-wrap: wrap; row-gap: 8px;
    padding: 12px 14px;
  }
  #sort-by { padding: 8px 10px; font-size: 14px; }
  .chk-label { font-size: 13px; }
  .chk-label input { width: 18px; height: 18px; }

  /* Capture bar reflows */
  .capture-bar {
    margin: 8px 14px;
    padding: 12px;
  }
  .cap-btn { padding: 10px 14px; font-size: 13px; }
  .capture-bar .cap-stat #cap-count { font-size: 20px; }

  /* Detail panel becomes a bottom sheet */
  #detail-panel {
    position: fixed; top: auto; right: 0; left: 0; bottom: 0;
    width: 100%; height: 78vh; max-height: 78vh;
    border-left: none; border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 30px rgba(0,0,0,.6);
    transform: translateY(0);
    z-index: 1200;
    padding-bottom: env(safe-area-inset-bottom);
  }
  #detail-panel.hidden { transform: translateY(100%); display: block; pointer-events: none; }
  .detail-header { padding: 14px 18px; font-size: 16px; }
  #detail-close { font-size: 24px; padding: 4px 10px; }
  .det-label { min-width: 90px; font-size: 12px; }
  .det-val { font-size: 14px; }
  /* Grab handle on bottom sheet */
  .detail-header::before {
    content: ''; position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
    width: 40px; height: 4px; border-radius: 2px;
    background: var(--border);
  }
  .detail-header { padding-top: 18px; }

  /* CSV drop zone needs less padding on mobile */
  .drop-zone { padding: 16px 12px; }
  .drop-icon { font-size: 28px; }

  /* Card headers more tappable */
  .card-header { padding: 14px; font-size: 13px; }
  .card-body  { padding: 14px; }

  /* Off-route list pill style */
  .off-row { padding: 8px 0; font-size: 13px; }

  /* Leaflet controls scale up */
  .leaflet-touch .leaflet-control-zoom a { width: 36px !important; height: 36px !important;
                                            line-height: 36px !important; font-size: 20px !important; }

  /* Bus markers slightly bigger for touch */
  .bus-marker { width: 40px; height: 40px; border-width: 3px; }
  .bus-marker-num { font-size: 10px; }
  .bus-marker-dir { font-size: 12px; }
}

/* ───── Small phones (< 380px) ───── */
@media (max-width: 380px) {
  .brand { font-size: 13px; }
  .topbar-mid { font-size: 11px; }
  #status-label { font-size: 11px; }
  .stops-toggle { padding: 6px; }
  .stops-toggle input { width: 16px; height: 16px; }
  .filter-bar { padding: 10px; }
  .capture-bar { padding: 10px; gap: 6px; }
  .cap-btn { padding: 8px 10px; font-size: 12px; }
}

/* ───── Landscape phones — compact topbar, side-by-side back ───── */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
  :root { --topbar-h: 44px; }
  #bottomnav { height: calc(46px + env(safe-area-inset-bottom)); }
  .bn-btn .bn-icon { font-size: 16px; }
  .bn-btn .bn-label { font-size: 9px; }
}

/* ── Agency switch ──────────────────────────────────────────────────────── */
.agency-switch {
  display: inline-flex; background: rgba(0,0,0,0.25);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 2px; gap: 2px;
}
.ag-btn {
  background: transparent; border: none; color: var(--muted);
  font: inherit; font-size: 12px; font-weight: 600;
  padding: 5px 12px; border-radius: 6px; cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}
.ag-btn:hover { color: var(--text); }
.ag-btn.active { background: var(--blue); color: white; }
.ag-btn[data-agency="citrus"].active { background: #ea580c; }

/* Citrus-themed stop dot (orange) */
.stop-dot.citrus { background: #fb923c; }

/* Citrus textarea input */
.citrus-input { margin-top: 10px; font-size: 12px; }
.citrus-input summary { color: var(--muted); cursor: pointer; padding: 6px 0;
                       user-select: none; }
.citrus-input summary:hover { color: var(--text); }
.citrus-input textarea {
  width: 100%; min-height: 60px;
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 8px; font-size: 12px; font-family: inherit;
  resize: vertical;
}

/* Mobile: agency switch sits at top of topbar */
@media (max-width: 767px) {
  .agency-switch { padding: 1px; }
  .ag-btn { padding: 5px 10px; font-size: 11px; }
}

/* ── CSV upload — visibility per breakpoint ──────────────────────────────── */
.csv-pick-btn  { display: none; width: 100%; margin-top: 8px; }
.paste-fallback { margin-top: 10px; font-size: 12px; color: var(--muted); }
.paste-fallback summary { cursor: pointer; padding: 6px 0; }
.paste-fallback summary:hover { color: var(--text); }
.paste-fallback textarea {
  width: 100%; min-height: 90px;
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 8px; font-size: 12px; font-family: monospace;
  resize: vertical;
}
@media (max-width: 767px) {
  .csv-pick-btn { display: block; }   /* show the big button on phones */
  /* The dashed drop-zone still works as a tap target — keep it visible too. */
  .drop-zone { min-height: 92px; }
}
