* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
#app { min-height: 100vh; display: flex; flex-direction: column; }

.header {
  padding: 0.75rem 1rem;
  background: #1e293b;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.header-right { display: flex; align-items: center; gap: 0.75rem; }
.link-office { font-size: 0.85rem; color: #93c5fd; }
#title { margin: 0; font-size: 1.25rem; font-weight: 700; }
.status {
  font-size: 0.8rem;
  color: #94a3b8;
}
.status.online { color: #22c55e; }
.status.offline { color: #f59e0b; }

.driver-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.map-container {
  flex: 1;
  min-height: 200px;
  background: #1e293b;
}
.controls {
  padding: 1rem;
  background: #1e293b;
  border-top: 1px solid #334155;
}
.time-display {
  font-size: 2rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
  margin-bottom: 0.25rem;
}
.trip-summary {
  text-align: center;
  font-size: 0.8rem;
  color: #94a3b8;
  margin: 0 0 0.5rem;
}
.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.telemetry-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}
.telemetry-label { font-size: 0.7rem; color: #64748b; text-transform: uppercase; }
.telemetry-value { font-size: 0.95rem; font-variant-numeric: tabular-nums; color: #e2e8f0; }
.telemetry-value.muted { color: #64748b; }
@media (max-width: 380px) {
  .telemetry-grid { grid-template-columns: repeat(2, 1fr); }
}
.buttons { display: flex; gap: 0.75rem; }
.btn {
  flex: 1;
  padding: 1rem 1.25rem;
  font-size: 1.1rem;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-start {
  background: #22c55e;
  color: #fff;
}
.btn-stop {
  background: #ef4444;
  color: #fff;
}
.btn-sync {
  background: #3b82f6;
  color: #fff;
  width: 100%;
}
.gps-status, .sync-status {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: #94a3b8;
}
.hint { font-size: 0.75rem; color: #64748b; margin: 0.5rem 0 0; }
.hint-background { background: #1e3a5f; padding: 0.6rem; border-radius: 8px; margin-top: 0.75rem; color: #93c5fd; font-size: 0.8rem; line-height: 1.4; }
.hint-background strong { color: #e0f2fe; }

.android-panel {
  background: #422006;
  border: 1px solid #ca8a04;
  color: #fef3c7;
  padding: 0.65rem;
  border-radius: 8px;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  line-height: 1.45;
}
.android-panel strong { color: #fde047; }
.android-panel-p { margin: 0.35rem 0; }
.android-steps { margin: 0.35rem 0 0.5rem 1.1rem; padding: 0; }
.android-steps li { margin-bottom: 0.25rem; }
.android-btns { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.5rem 0; }
.btn-android {
  padding: 0.45rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  background: #78350f;
  color: #fef3c7;
  border: 1px solid #ca8a04;
  border-radius: 6px;
  cursor: pointer;
}
.btn-android:active { background: #92400e; }
.btn-android-primary { background: #ca8a04; color: #1c1917; border-color: #fde047; }
.android-panel-small { font-size: 0.72rem; color: #fcd34d; margin: 0.35rem 0 0; }

.android-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.android-modal-inner {
  background: #1e293b;
  border: 2px solid #ca8a04;
  border-radius: 12px;
  padding: 1.25rem;
  max-width: 22rem;
  color: #e2e8f0;
}
.android-modal-inner h2 { margin: 0 0 0.5rem; font-size: 1.1rem; color: #fde047; }
.android-modal-inner p { font-size: 0.85rem; line-height: 1.45; margin: 0 0 1rem; }
.android-modal-allow { width: 100%; margin-bottom: 0.5rem; }
.android-modal .btn-android { width: 100%; margin-bottom: 0.35rem; }
.android-modal-dismiss { width: 100%; margin-top: 0.5rem; background: transparent; border: none; color: #94a3b8; font-size: 0.85rem; cursor: pointer; }

/* Office view */
.office-view {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 280px;
  grid-template-rows: 1fr;
  min-height: 0;
}
.office-view .map-container { min-height: 0; }
.sidebar {
  overflow-y: auto;
  padding: 1rem;
  background: #1e293b;
  border-left: 1px solid #334155;
}
.sidebar h2 { font-size: 1rem; margin: 0 0 0.5rem; color: #94a3b8; }
#live-trips { margin-bottom: 1rem; }
#trip-list { list-style: none; padding: 0; margin: 0; }
#trip-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid #334155;
  font-size: 0.9rem;
  cursor: pointer;
}
#trip-list li:hover { background: #334155; }

.toast {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.75rem 1.25rem;
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 8px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 9999;
}
.toast.show { opacity: 1; }

@media (max-width: 640px) {
  .office-view {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }
  .sidebar { max-height: 200px; }
}

/* Leaflet overrides for dark */
.leaflet-container { background: #1e293b; font: inherit; }
.leaflet-popup-content-wrapper { background: #1e293b; color: #e2e8f0; }
.leaflet-control-zoom a { background: #1e293b !important; color: #e2e8f0; }
.live-marker { background: #22c55e; border-radius: 50%; }
