/* ==========================================================
   HoaMai Driver App V2 — Mobile-First Stylesheet
   ========================================================== */

:root {
  --primary:      #00b14f;
  --primary-dk:   #009040;
  --accent:       #ff6b2b;
  --accent-dk:    #e55a1f;
  --bg:           #f5f7fa;
  --surface:      #ffffff;
  --text:         #1a1a2e;
  --text2:        #6b7280;
  --text3:        #9ca3af;
  --border:       #e8eaed;
  --danger:       #ef4444;
  --danger-bg:    #fef2f2;
  --success:      #22c55e;
  --warning:      #f59e0b;
  --info:         #3b82f6;
  --shadow:       0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.12);
  --radius:       8px;
  --radius-sm:    6px;
  --sidebar-w:    320px;
  --topbar-h:     52px;
  --bottom-btn-h: 56px;
  --transition:   0.25s cubic-bezier(0.4,0,0.2,1);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 18px; color: var(--text);
  background: var(--bg); overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Login Page ---------- */
.login-body {
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
}
.login-container {
  width: 100%; max-width: 360px; padding: 24px;
}
.login-logo {
  text-align: center; margin-bottom: 32px;
}
.login-logo i {
  font-size: 56px; color: var(--primary); display: block; margin-bottom: 12px;
}
.login-logo h1 {
  font-size: 24px; font-weight: 700; color: var(--text);
}
.version-tag {
  display: inline-block; background: var(--primary); color: #fff;
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px;
  margin-top: 6px;
}
.login-form .form-group {
  margin-bottom: 16px;
}
.login-form label {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 6px;
}
.login-form input {
  width: 100%; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 15px; outline: none; background: var(--bg);
  transition: border-color var(--transition);
}
.login-form input:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,177,79,0.12);
}
.btn-login {
  width: 100%; background: var(--primary); color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 14px; font-size: 16px; font-weight: 600;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background var(--transition), transform 0.1s;
}
.btn-login:active { transform: scale(0.98); }
.login-error {
  margin-top: 12px; background: var(--danger-bg); color: var(--danger);
  padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500;
}

/* ---------- Top Bar ---------- */
#topBar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  background: rgba(255,255,255,0.95); backdrop-filter: blur(10px);
  z-index: 1000; display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px; border-bottom: 1px solid var(--border); box-shadow: var(--shadow);
}
.top-btn {
  background: none; border: none; width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
  color: var(--text); cursor: pointer; transition: background var(--transition);
  flex-shrink: 0;
}
.top-btn:hover, .top-btn:active { background: var(--bg); }
#topTitle {
  font-size: 16px; font-weight: 700; color: var(--text); position: absolute;
  left: 50%; transform: translateX(-50%); pointer-events: none;
  text-align: center; line-height: 1.2;
}
#topTitleSub {
  font-size: 16px; font-weight: 500; color: var(--primary); opacity: 0.85;
  white-space: nowrap;
}
.top-actions { display: flex; gap: 4px; }
.top-actions-left { display: flex; gap: 4px; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--surface); z-index: 1100; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); transform: translateX(-100%);
  transition: transform var(--transition);
  touch-action: pan-y;
}
.sidebar.open { transform: translateX(0); }
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 8px; font-size: 19.5px; font-weight: 700; color: var(--primary);
}
.sidebar-brand i { font-size: 22px; }
.sidebar-body {
  flex: 1; overflow-y: auto; padding: 12px; -webkit-overflow-scrolling: touch;
}
.sidebar-footer {
  border-top: 1px solid var(--border); padding: 12px; flex-shrink: 0; background: var(--bg);
}
.driver-info {
  font-size: 15.6px; color: var(--text2); margin-bottom: 10px; text-align: center;
}
.sidebar-menu { display: flex; flex-direction: column; gap: 6px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); font-size: 18.2px; font-weight: 500;
  color: var(--text); cursor: pointer; transition: background var(--transition);
}
.menu-item:hover { background: var(--bg); }
.menu-item i { font-size: 18px; color: var(--primary); }
.menu-item.danger i { color: var(--danger); }

.sidebar-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35);
  z-index: 1050; opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.sidebar-overlay.show { opacity: 1; pointer-events: auto; }

/* ---------- Trip List Items ---------- */
#tripList { display: flex; flex-direction: column; gap: 6px; }
.trip-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px; cursor: pointer; transition: box-shadow var(--transition), transform 0.1s;
  position: relative; overflow: hidden;
}
.trip-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--primary); border-radius: var(--radius) 0 0 var(--radius);
}
.trip-card:active { transform: scale(0.995); }
.trip-card:hover { box-shadow: var(--shadow); }
.trip-card.selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(0,177,79,0.15); }
.trip-route {
  font-size: 18.2px; font-weight: 700; color: var(--text); margin-bottom: 2px;
  display: flex; align-items: center; gap: 4px;
}
.trip-route i { color: var(--primary); }
.trip-time {
  font-size: 15.6px; color: var(--text2); margin-bottom: 4px;
}
.trip-stats {
  display: flex; flex-wrap: wrap; gap: 4px;
}
.trip-stat {
  background: var(--bg); border-radius: 20px; padding: 3px 8px;
  font-size: 14.3px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 2px;
  white-space: nowrap;
}
.trip-stat i { font-size: 15.6px; }
.trip-stat .money { color: var(--danger); }

.empty-state {
  text-align: center; padding: 40px 16px; color: var(--text2);
}
.empty-state i { font-size: 40px; margin-bottom: 10px; display: block; }

/* ---------- Map ---------- */
#map {
  position: fixed;
  top: var(--topbar-h, 52px);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 0;
}
.leaflet-control-zoom { display: none !important; }
.leaflet-control-attribution {
  font-size: 9px !important; background: rgba(255,255,255,0.7) !important;
  backdrop-filter: blur(4px); border-radius: 4px !important; padding: 1px 4px !important;
}

/* ---------- Map FABs ---------- */
#mapFabs {
  position: fixed; right: 14px; bottom: 80px; z-index: 500;
  display: flex; flex-direction: column; gap: 8px;
}
#mapFabs button {
  width: 44px; height: 44px; background: var(--surface); border: none;
  border-radius: 12px; box-shadow: var(--shadow); font-size: 18px; color: var(--text);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
#mapFabs button:hover { background: var(--bg); }

/* ---------- Bottom Sheet ---------- */
.bottom-sheet {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 600;
  background: var(--surface); border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.12); transform: translateY(0);
  transition: transform var(--transition); padding-bottom: env(safe-area-inset-bottom);
  max-height: 25vh;
}
.bottom-sheet.compact { max-height: 15vh; }
.bottom-sheet.hidden { transform: translateY(100%); }
.bottom-sheet-header {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 4px 12px;
  min-height: 24px;
}
.bottom-sheet-handle {
  width: 32px; height: 4px; background: var(--border); border-radius: 4px;
  cursor: grab; touch-action: none;
}
.bottom-sheet-handle:active { cursor: grabbing; }
.btn-close-sheet {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text2);
  cursor: pointer;
  transition: background var(--transition);
}
.btn-close-sheet:hover, .btn-close-sheet:active { background: var(--bg); }
.bottom-sheet.swiping { transition: none; }
.bottom-sheet.swiped-away { transform: translateY(100%) !important; transition: transform var(--transition); }
.bottom-sheet-content { padding: 0 12px 12px; overflow-y: auto; }
.bottom-sheet.compact .trip-summary { display: none; }
.bottom-sheet.compact .stop-progress { display: none; }
.bottom-sheet.compact #phaseLabel { display: none; }
.bottom-sheet.compact .btn-row { margin-top: 0; }

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin-top: 6px;
}
.btn-action-sm {
  border: none; border-radius: 8px; padding: 8px 4px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  transition: background var(--transition), transform 0.1s;
  white-space: nowrap; min-width: 0;
}
.btn-action-sm:active { transform: scale(0.96); }
.btn-action-sm.primary { background: var(--primary); color: #fff; }
.btn-action-sm.success { background: var(--success); color: #fff; }
.btn-action-sm.secondary { background: var(--bg); color: var(--text2); border: 1px solid var(--border); }
.btn-action-sm.suggest { box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.35); animation: hmPulse 1.1s ease-in-out infinite; }
.btn-action-sm.suggest::after { content: ' 🎯'; }
.btn-action-sm .text-muted { color: #9ca3af; }

/* Drive mode badge — float dưới topBar (kiểu Google Drive mode) */
#driveBadge {
  position: fixed; top: calc(var(--topbar-h, 52px) + 6px); left: 50%; transform: translateX(-50%);
  z-index: 550;
  background: rgba(0,177,79,0.85); backdrop-filter: blur(6px);
  color: #fff; font-size: 12px; font-weight: 600;
  padding: 6px 14px; display: none; align-items: center; gap: 12px;
  border-radius: 999px; box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  white-space: nowrap; pointer-events: none;
  opacity: 0.8; max-width: 90vw;
}
#driveBadge .badge-sep { opacity: 0.4; }
#driveBadge .badge-dest { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trip-summary {
  display: flex; gap: 12px; align-items: center; margin-bottom: 12px;
}
.stop-progress {
  display: flex; align-items: center; gap: 6px; margin-bottom: 10px; overflow-x: auto;
  -webkit-overflow-scrolling: touch; scrollbar-width: none; padding: 4px;
}
.stop-progress::-webkit-scrollbar { display: none; }
.stop-dot {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0;
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  cursor: pointer;
}
.stop-dot.pickup { background: var(--primary); }
.stop-dot.dropoff { background: var(--accent); border-radius: 50%; }
.stop-dot.done { background: var(--text2); opacity: 0.5; }
.stop-dot.active { box-shadow: 0 0 0 3px rgba(0,177,79,0.3); transform: scale(1.1); }
.stop-connector {
  width: 20px; height: 3px; background: var(--border); flex-shrink: 0;
  border-radius: 2px;
}
.stop-connector.done { background: var(--success); }
.stop-connector.active { background: var(--primary); }

/* ---------- Action Buttons ---------- */
.btn-action {
  width: 100%; border: none; border-radius: var(--radius-sm); padding: 14px;
  font-size: 15px; font-weight: 600; cursor: pointer; display: flex;
  align-items: center; justify-content: center; gap: 8px;
  transition: background var(--transition), transform 0.1s; margin-top: 8px;
}
.btn-action:active { transform: scale(0.98); }
.btn-action.primary { background: var(--primary); color: #fff; }
.btn-action.primary:hover { background: var(--primary-dk); }
.btn-action.success { background: var(--success); color: #fff; }
.btn-action.secondary { background: var(--bg); color: var(--text2); border: 1px solid var(--border); }
.btn-action.suggest { box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.35); animation: hmPulse 1.1s ease-in-out infinite; }
@keyframes hmPulse { 0% { box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.15); } 50% { box-shadow: 0 0 0 7px rgba(245, 158, 11, 0.35); } 100% { box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.15); } }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 2000; display: flex;
  align-items: flex-end; justify-content: center;
}
.modal-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,0.35);
}
.modal-content {
  position: relative; background: var(--surface); border-radius: var(--radius) var(--radius) 0 0;
  width: 100%; max-height: 85vh; z-index: 1;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.15); animation: slideUp 0.25s ease;
  display: flex; flex-direction: column; min-height: 0;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 13px; font-weight: 700; }
.modal-close {
  background: none; border: none; font-size: 14px; color: var(--text2);
  cursor: pointer; width: 26px; height: 26px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--bg); }
.modal-body { padding: 10px; overflow-y: auto; flex: 1; min-height: 0; }

.modal-footer { display: none; }

/* ---------- Stop Ticket Card (new layout) ---------- */
.stop-ticket-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--surface);
}
.stop-ticket-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.stop-ticket-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stop-ticket-name i { color: var(--primary); margin-right: 3px; font-size: 13px; }
.stop-phone-group {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}
.stop-phone-text {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
}
.stop-phone-text:hover { color: #1a5ea8; }
.stop-phone-icon {
  font-size: 12px;
  color: var(--success);
  cursor: pointer;
  padding: 3px;
  border-radius: 50%;
  background: #e8f5e9;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.stop-phone-icon:hover { background: #c8e6c9; }
.stop-ticket-money {
  font-size: 14px;
  font-weight: 700;
  color: var(--danger);
  flex-shrink: 0;
  white-space: nowrap;
}
.stop-ticket-sub {
  font-size: 13px;
  color: var(--text2);
  margin-top: 1px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.stop-ticket-addr {
  font-size: 13px;
  color: var(--text);
  margin-top: 1px;
  padding: 1px 0;
}
.stop-tc-row {
  background: #fff9e6;
  border-radius: 6px;
  padding: 4px 6px;
  margin-top: 3px;
  font-size: 13px;
  color: #92400e;
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
}
.stop-call-txtc {
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  white-space: nowrap;
}
.stop-call-txtc:hover { color: #1a5ea8; }
.stop-payment {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  flex-wrap: wrap;
  align-items: center;
}
/* TC badge in stop list */
.slp-tc {
  font-size: 10px;
  color: #92400e;
  background: #fff9e6;
  border-radius: 4px;
  padding: 0 4px;
  display: inline-block;
  margin-top: 1px;
}

.stop-detail-row {
  display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px;
}
.stop-detail-row .icon {
  width: 32px; height: 32px; border-radius: 50%; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: var(--primary); flex-shrink: 0;
}
.stop-detail-row .content { flex: 1; }
.stop-detail-row .label { font-size: 12px; color: var(--text2); margin-bottom: 2px; }
.stop-detail-row .value { font-size: 14px; font-weight: 600; color: var(--text); }
.stop-detail-row .money { color: var(--danger); }

/* Call buttons in modal */
.call-btn {
  flex: 1; padding: 12px; border-radius: var(--radius-sm); border: none;
  font-size: 14px; font-weight: 600; cursor: pointer; display: flex;
  align-items: center; justify-content: center; gap: 6px;
}
.call-btn-sm {
  flex: 1; padding: 8px 10px; border-radius: var(--radius-sm); border: none;
  font-size: 12px; font-weight: 500; cursor: pointer; display: flex;
  align-items: center; justify-content: center; gap: 4px;
}
.call-btn.primary, .call-btn-sm.primary { background: var(--primary); color: #fff; }
.call-btn.secondary, .call-btn-sm.secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }

/* Stop modal select (matches app style) */
.stop-select {
  font-size: 12px; font-weight: 500; padding: 6px 22px 6px 8px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b7280'/%3E%3C/svg%3E") no-repeat right 8px center;
  color: var(--text); appearance: none; cursor: pointer;
  outline: none; min-width: 0;
}
.stop-select:focus { border-color: var(--primary); }

/* ---------- Toast ---------- */
.toast-container {
  position: fixed; top: 110px; left: 50%; transform: translateX(-50%);
  z-index: 3000; display: flex; flex-direction: column; gap: 8px;
  width: 90%; max-width: 360px; pointer-events: none;
}
.toast {
  background: rgba(26,26,46,0.92); color: #fff; backdrop-filter: blur(8px);
  border-radius: 12px; padding: 12px 16px; font-size: 13px; font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25); display: flex; align-items: center; gap: 10px;
  pointer-events: auto; animation: toastIn 0.3s ease;
}
.toast.error { background: rgba(239,68,68,0.95); }
.toast.success { background: rgba(34,197,94,0.95); }
.toast.warning { background: rgba(245,158,11,0.95); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Loading ---------- */
.loading-overlay {
  position: fixed; inset: 0; z-index: 2500;
  background: rgba(255,255,255,0.85); backdrop-filter: blur(4px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
}
.loading-overlay .spinner {
  width: 40px; height: 40px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.loading-overlay p { font-size: 14px; color: var(--text2); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Generic spinner (reuses animation) */
.spinner {
  display: inline-block; width: 36px; height: 36px;
  border: 3px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
#sidebarLoading .spinner { margin: 0 auto 8px; }

/* Monitor button loading state */
#monitorBtn.loading i { animation: spin 0.7s linear infinite; display: inline-block; transform-origin: center; }

/* ---------- Legacy Page ---------- */
#legacyPageContainer {
  position: fixed; inset: 0; z-index: 900; background: var(--bg); overflow-y: auto;
}
.legacy-header {
  position: sticky; top: 0; z-index: 10;
  height: var(--topbar-h); background: rgba(255,255,255,0.95); backdrop-filter: blur(10px);
  display: flex; align-items: center; padding: 0 12px; gap: 12px;
  border-bottom: 1px solid var(--border); box-shadow: var(--shadow);
}
.legacy-header span { font-size: 16px; font-weight: 700; }
#legacyPageContent { padding: 16px; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ---------- Utility ---------- */
.spin { animation: spin 1s linear infinite; display: inline-block; }
.hidden { display: none !important; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text2); }
.fw-bold { font-weight: 700; }

/* ---------- Responsive ---------- */
@media (min-width: 768px) {
  :root { --sidebar-w: 380px; }
  .modal-content { border-radius: var(--radius); max-width: 480px; margin-bottom: 40px; }
}

/* ---------- Trip Cau Badge ---------- */
.trip-bridge { margin-bottom: 2px; }
.trip-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  color: #fff;
  margin-left: 6px;
  vertical-align: middle;
}

/* ---------- Admin Monitor ---------- */
#monitorBtn.active { color: var(--primary); }
.monitor-panel {
  position: fixed; top: var(--topbar-h, 52px); right: 0; bottom: 0; z-index: 900;
  width: 280px; background: var(--surface);
  display: flex; flex-direction: column;
  max-height: calc(100vh - var(--topbar-h, 52px));
  box-shadow: -2px 0 20px rgba(0,0,0,0.1);
  animation: slideInRight 0.2s ease;
}
@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
.monitor-body { flex: 1; min-height: 0; overflow: hidden; padding: 8px; display: flex; flex-direction: column; }
.monitor-body .tab-content.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  max-height: calc(100vh - var(--topbar-h, 52px) - 16px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.monitor-body .section-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text2); margin-bottom: 8px;
  display: flex; align-items: center; justify-content: space-between;
}
.monitor-body .btn-demo {
  background: none; border: 1.5px solid var(--primary); color: var(--primary);
  border-radius: 8px; padding: 3px 10px; font-size: 11px; font-weight: 600; cursor: pointer;
}
.monitor-body .btn-demo-stop { border-color: #e53935; color: #e53935; }
.monitor-body .driver-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: var(--bg); border-radius: 10px;
  margin-bottom: 8px; cursor: pointer; transition: background var(--transition);
}
.monitor-body .driver-item:hover { background: #e6f9ef; }
.monitor-body .driver-item.dimmed { opacity: 0.5; }
.monitor-body .driver-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; cursor: pointer; overflow: hidden;
}
.monitor-body .driver-avatar svg { width: 28px; height: 42px; }
.monitor-body .driver-info { flex: 1; }
.monitor-body .driver-name { font-size: 13px; font-weight: 600; }
.monitor-body .driver-status { font-size: 11px; color: var(--text2); }
.monitor-body .driver-dest { font-size: 11px; color: var(--primary); }
.monitor-body .driver-badge {
  font-size: 10px; font-weight: 600; padding: 3px 7px; border-radius: 20px;
}
.monitor-body .driver-badge.online { background: #e6f9ef; color: var(--primary); }
.monitor-body .monitor-toggle { font-size: 16px; cursor: pointer; flex-shrink: 0; padding: 4px; }
.monitor-body .ws-status {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 12px; border-radius: 10px;
  font-size: 12px; font-weight: 500;
}
.monitor-body .ws-connected { background: #e6f9ef; color: var(--primary); }
.monitor-body .ws-disconnected { background: var(--bg); color: var(--text2); }
.monitor-body .ws-connecting { background: #fff4e6; color: #f59e0b; }
.monitor-body .text-muted { color: var(--text2); }
.monitor-body .text-center { text-align: center; }
.monitor-body .py-3 { padding-top: 16px; padding-bottom: 16px; }

/* ---------- Driver Car Icon (SVG marker) ---------- */
.driver-car-icon { transition: transform 0.3s ease; filter: drop-shadow(0 3px 6px rgba(0,0,0,0.25)); }

/* ---------- Driver Marker (admin monitor) ---------- */
.driver-marker {
  display: block;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  overflow: visible;
}

.driver-vehicle-badge {
  position: absolute;
  left: 37px;
  top: 28px;
  transform: translateY(-50%);
  padding: 2px 8px;
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  border: 2px solid rgba(255,255,255,0.92);
  box-shadow: 0 2px 10px rgba(0,0,0,0.22);
  pointer-events: none;
}

/* ---------- Route Editor (CRUD Lite) ---------- */
.re-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 10px; background: var(--bg);
  margin-bottom: 6px; font-size: 12px;
}
.re-num {
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.re-name { flex: 1; font-weight: 600; color: var(--text); }
.re-type { font-size: 11px; color: var(--text2); width: 30px; }
.re-actions { display: flex; gap: 2px; flex-shrink: 0; }
.re-btn {
  width: 32px; height: 32px; border: none; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; cursor: pointer; background: none; color: var(--text2);
}
.re-btn:hover { background: #e8eaed; }
.re-btn:disabled { opacity: .3; cursor: not-allowed; }
.re-up:hover { color: var(--primary); }
.re-down:hover { color: var(--info); }
.re-pin:hover { color: #e53935; }

/* ---------- Stop List Panel ---------- */
.stop-list-panel {
  position: fixed;
  top: calc(var(--topbar-h, 52px) + 10px);
  left: 10px;
  z-index: 600;
  width: 320px;
  max-height: calc(100vh - var(--topbar-h, 52px) - 120px);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.25s ease;
}
.stop-list-panel.collapsed {
  display: none;
}
.stop-list-panel.collapsed #stopListContent {
  display: none;
}
#stopListContent {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  margin-top: 4px;
}
.tc-toggle-bar {
  display: flex;
  gap: 4px;
  padding: 4px 8px 0;
  margin-bottom: 4px;
}
.tc-toggle-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 5px 0;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  color: #555;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.tc-toggle-btn.active {
  background: #f0fdf4;
  border-color: #00b14f;
  color: #00b14f;
  font-weight: 600;
}
.tc-toggle-btn.active:last-child {
  background: #fff7f0;
  border-color: #ff6b2b;
  color: #ff6b2b;
}
.slp-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 13px;
}
.slp-item:hover { background: var(--bg); }
.slp-item.active { background: #e6f9ef; }
.slp-item.done { opacity: 0.4; filter: grayscale(0.6); transition: opacity 0.4s ease, filter 0.4s ease; }
.slp-badge {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.slp-info { flex: 1; min-width: 0; }
.slp-name { font-weight: 600; font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slp-meta { font-size: 13px; color: var(--text2); }

/* ---------- Pin Mode Search Bar ---------- */
.pin-search-bar {
  position: fixed;
  top: var(--topbar-h, 52px);
  left: 0;
  right: 0;
  z-index: 1100;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 8px 12px;
  box-sizing: border-box;
}
.pin-search-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 10px;
}
.pin-search-inner i {
  color: var(--primary);
  font-size: 16px;
}
.pin-search-inner input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  padding: 10px 0;
  color: var(--text);
  min-width: 0;
}
.pin-search-inner input::placeholder { color: var(--text3); }
.pin-search-clear {
  background: none;
  border: none;
  color: var(--text3);
  font-size: 14px;
  cursor: pointer;
  padding: 4px;
}
.pin-search-results {
  max-height: 200px;
  overflow-y: auto;
}
.pin-search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.pin-search-result-item:last-child { border-bottom: none; }
.pin-search-result-item:hover,
.pin-search-result-item:active { background: var(--bg); }
.pin-search-result-item i { color: var(--text3); font-size: 14px; flex-shrink: 0; }

/* ---------- Edit Mode Bar ---------- */
.edit-mode-bar {
  position: fixed;
  top: var(--topbar-h, 52px);
  left: 0; right: 0;
  z-index: 1200;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 8px 12px;
}
.edit-bar-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.edit-bar-body input {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}
.edit-bar-body input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,177,79,0.12);
}
.edit-bar-body .edit-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

@media (max-width: 640px) {
  .edit-mode-bar {
    padding: 6px 10px;
  }
}

/* Map popup tweak */
.mapboxgl-popup-content, .maplibregl-popup-content, .trackasiagl-popup-content { border-radius: var(--radius-sm) !important; padding: 10px 12px !important; font-size: 13px; }
.mapboxgl-popup-close-button, .maplibregl-popup-close-button, .trackasiagl-popup-close-button { font-size: 16px; padding: 4px 8px; }


.slp-item.editing::after {
  content: ' ✏️';
  font-size: 10px; position: absolute; right: 8px; top: 4px; opacity: 0.6;
}
.slp-item.pending-edit {
  box-shadow: 0 0 0 2px #f59e0b;
  border-radius: 8px;
}