*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --primary-light: #e8f0fe;
  --secondary: #0f9d58;
  --secondary-dark: #0b7a44;
  --secondary-light: #e6f4ea;
  --bg: #f0f4f8;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --text: #1f2937;
  --text-secondary: #64748b;
  --text-tertiary: #94a3b8;
  --border: #e2e8f0;
  --error: #dc2626;
  --error-light: #fef2f2;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
html, body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  height: 100%;
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
input, button, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; border: none; background: none; }

/* ── App Shell ── */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  background: var(--surface);
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--border);
}
@media (min-width: 640px) {
  .app-shell { border-radius: var(--radius-lg); height: min(100dvh, 900px); margin: 16px auto; }
  body { padding: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; min-height: 100dvh; }
}
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  min-height: 56px;
  flex-shrink: 0;
  z-index: 10;
}
@media (orientation: landscape) and (max-height: 500px) {
  .app-header { padding: 6px 12px; min-height: 40px; }
  .app-header .brand { font-size: 15px; }
  .app-header .brand .logo-img { width: 22px; height: 22px; }
}
.app-header .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 18px;
  color: var(--primary);
}
.app-header .brand .logo {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
}
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-badge {
  display: flex; align-items: center; gap: 4px;
  background: var(--primary-light);
  color: var(--primary);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

/* ── App Content ── */
.app-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 0 16px 16px;
}
@media (orientation: landscape) and (max-height: 500px) {
  .app-content { padding: 0 12px 8px; }
  .app-content .card { margin-bottom: 6px; padding: 10px 12px; }
  .app-content .section-title { margin: 10px 0 4px; }
}
.section-title {
  font-size: clamp(11px, 3.5vw, 13px);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: clamp(12px, 3vh, 24px) 0 8px;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(12px, 3vw, 20px);
  margin-bottom: clamp(8px, 2vh, 16px);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.card-icon { font-size: 18px; }
.icon { width: 20px; height: 20px; display: inline-block; vertical-align: middle; flex-shrink: 0; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }

/* ── Status Indicator ── */
.status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}
.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--text-tertiary);
  flex-shrink: 0;
  transition: background 0.3s;
}
.status-dot.active { background: var(--secondary); box-shadow: 0 0 0 3px var(--secondary-light); }
.status-dot.initializing { background: var(--primary); animation: pulse 1.5s infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.status-text { font-size: 15px; font-weight: 600; }
.status-sub { font-size: 12px; color: var(--text-tertiary); margin-top: 1px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  transition: all 0.2s;
  min-height: 48px;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:active { background: var(--primary-dark); }
.btn-secondary {
  background: var(--primary-light);
  color: var(--primary);
}
.btn-secondary:active { background: #d2e3fc; }
.btn-secondary.active { background: var(--primary); color: #fff; }
.btn-success {
  background: var(--secondary);
  color: #fff;
}
.btn-success:active { background: var(--secondary-dark); }
.btn-danger {
  background: var(--error);
  color: #fff;
}
.btn-danger:active { background: #b91c1c; }
.btn-ghost {
  color: var(--text-secondary);
  background: transparent;
}
.btn-ghost:active { background: var(--surface-alt); }
.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
  min-height: 36px;
}
.btn-icon {
  width: 40px; height: 40px;
  padding: 0;
  border-radius: 50%;
  font-size: 18px;
}

/* ── Inputs ── */
.input-group { margin-bottom: 10px; }
.input-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.input-field {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.2s;
  outline: none;
  -webkit-appearance: none;
}
.input-field:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.input-field::placeholder { color: var(--text-tertiary); }

/* ── Plate Display ── */
.plate-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.plate-display {
  display: flex;
  align-items: center;
  gap: 12px;
}
.plate-number {
  font-size: clamp(18px, 5vw, 24px);
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--text);
}
.plate-edit {
  color: var(--text-tertiary);
  font-size: 13px;
  padding: 6px;
  border-radius: 6px;
  transition: all 0.2s;
}
.plate-edit:active { background: var(--surface-alt); }

/* ── GPS Info ── */
.gps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}
.gps-item {
  padding: 8px 10px;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
}
.gps-item .label {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
}
.gps-item .value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* ── Live Map ── */
.map-card { padding: 0; overflow: hidden; }
.map-container {
  width: 100%;
  height: 200px;
  min-height: 160px;
  max-height: 40dvh;
  border-radius: var(--radius);
}
@media (min-height: 800px) {
  .map-container { height: 260px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .map-container { height: 140px; min-height: 120px; }
}

/* ── Bottom Bar ── */
.app-bottom {
  position: sticky;
  bottom: 0;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 12px 16px calc(12px + var(--safe-bottom));
  z-index: 20;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
}
@media (orientation: landscape) and (max-height: 500px) {
  .app-bottom { padding: 6px 12px calc(6px + var(--safe-bottom)); }
}
.bottom-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.bottom-row .btn { flex: 1; }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
}
.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
}
.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.modal-actions .btn { flex: 1; }

/* ── Passenger Badge ── */
.passenger-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-light);
  color: var(--primary);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
  white-space: nowrap;
}
.passenger-badge:active { background: #d2e3fc; }

/* ── Passenger Overlay ── */
.overlay-full {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--surface);
  flex-direction: column;
}
.overlay-full.open { display: flex; }
.overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 56px;
}
.overlay-header h2 {
  font-size: 17px;
  font-weight: 700;
}
.overlay-map {
  flex: 1;
  width: 100%;
}

/* ── Route Form ── */
.route-form { display: flex; flex-direction: column; gap: 0; }
.route-row {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}
.route-row + .route-row { margin-top: -1px; }
.route-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid var(--secondary);
}
.route-dot.dest { border-color: var(--error); background: var(--error); }
.route-line {
  position: absolute;
  left: 4px; top: 18px;
  width: 2px; height: 14px;
  background: var(--border);
}
.route-row .input-field { flex: 1; }
.route-save {
  margin-top: 10px;
  align-self: flex-end;
}
.route-status {
  font-size: 13px;
  color: var(--secondary);
  margin-top: 8px;
}

/* ── Toggle Button ── */
.btn-toggle {
  width: 100%;
  padding: clamp(12px, 3vh, 16px);
  font-size: clamp(15px, 4.5vw, 18px);
  font-weight: 700;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  min-height: clamp(44px, 8vh, 56px);
}
.btn-toggle.start { background: var(--secondary); color: #fff; }
.btn-toggle.start:active { background: var(--secondary-dark); }
.btn-toggle.stop { background: var(--error); color: #fff; }
.btn-toggle.stop:active { background: #b91c1c; }
.btn-toggle:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-toggle:disabled:active { transform: none; }

/* ── Passenger Page ── */
.passenger-map {
  flex: 1;
  width: 100%;
}
.passenger-bottom {
  flex-shrink: 0;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
  z-index: 5;
  max-height: min(50vh, 420px);
  display: flex;
  flex-direction: column;
}
.sheet-handle {
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 10px auto 6px;
  flex-shrink: 0;
}
.sheet-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sheet-tab {
  flex: 1;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-align: center;
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.sheet-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.sheet-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px;
  min-height: 0;
}
.sheet-pane { display: none; }
.sheet-pane.active { display: block; }

/* ── Destination Search ── */
.dest-search {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.dest-search .input-field { flex: 1; }
.dest-search .btn { flex-shrink: 0; }
.dest-section {
  margin-bottom: 16px;
}
.dest-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 0 4px;
}
.dest-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  margin: 0 -16px;
  padding: 12px 16px;
}
.dest-item:active { background: var(--primary-light); }
.dest-item-icon {
  width: 36px; height: 36px;
  background: var(--primary-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.dest-item-info { flex: 1; min-width: 0; }
.dest-item-name {
  font-size: 15px;
  font-weight: 600;
}
.dest-item-area {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 1px;
}
.dest-map-mode {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  margin: 0 -16px 12px;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}
.dest-map-mode:active { background: var(--primary-light); }
.dest-map-mode.active { background: var(--primary-light); color: var(--primary); }
.dest-map-mode-icon { font-size: 20px; }
.dest-map-mode-text { font-size: 14px; font-weight: 500; }
.dest-clear {
  display: none;
  align-items: center;
  gap: 4px;
  color: var(--error);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}
.dest-clear:active { background: var(--error-light); }

/* ── Drawer List (Nearby tab) ── */
.drawer-list { padding: 0; }
.drawer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  margin: 0 -16px;
  padding: 12px 16px;
}
.drawer-item:active { background: var(--surface-alt); }
.drawer-item .dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid white;
  box-shadow: var(--shadow-sm);
}
.drawer-item .info { flex: 1; min-width: 0; }
.drawer-item .plate {
  font-size: 15px;
  font-weight: 600;
}
.drawer-item .route {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.drawer-item .distance {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  flex-shrink: 0;
}
.drawer-empty {
  padding: 32px 0;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 14px;
}

/* ── Destination Set Confirmation ── */
.dest-confirm {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--secondary-light);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}
.dest-confirm-icon { font-size: 20px; }
.dest-confirm-text { flex: 1; font-size: 13px; font-weight: 500; color: var(--secondary-dark); }

/* ── Splash Screen ── */
#splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  transition: opacity 0.4s ease;
}
#splash.hide { opacity: 0; pointer-events: none; }
.splash-icon {
  width: 88px; height: 88px;
  border-radius: 22px;
  margin-bottom: 16px;
}
.splash-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 28px;
}
.splash-spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: splash-spin 0.8s linear infinite;
}
@keyframes splash-spin { to { transform: rotate(360deg); } }

/* ── Logo Image ── */
.logo-img {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: block;
}
.logo-landing {
  width: 72px; height: 72px;
  border-radius: 20px;
  display: block;
}

/* ── Collapsible Passenger Bottom ── */
.passenger-bottom.collapsed {
  max-height: 52px;
  overflow: hidden;
  cursor: pointer;
}

/* ── Init/Empty States ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--text-tertiary);
}
.empty-state-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state-title { font-size: 18px; font-weight: 700; color: var(--text-secondary); margin-bottom: 4px; }
.empty-state-desc { font-size: 14px; text-align: center; line-height: 1.4; }

/* ── Loading ── */
.loading-dots::after {
  content: "";
  animation: dots 1.5s infinite;
}
@keyframes dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
}

/* ── Scrollbar ── */
.app-content::-webkit-scrollbar, .sheet-content::-webkit-scrollbar { width: 4px; }
.app-content::-webkit-scrollbar-track, .sheet-content::-webkit-scrollbar-track { background: transparent; }
.app-content::-webkit-scrollbar-thumb, .sheet-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
