* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --card: #334155;
  --border: #475569;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --blue: #3b82f6;
}

/* Light mode overrides */
.light {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --card: #e2e8f0;
  --border: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
}
.light .reg-input { background: #fbbf24; color: #000; border-color: #000; }
.light .vehicle-reg { background: #fbbf24; color: #000; }
.light .header { background: #ffffff; border-bottom-color: #e2e8f0; }
.light .header h1 { color: #0f172a; }
.light .logo-inner { fill: #ffffff; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  transition: background 0.3s, color 0.3s;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.header h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.header h1 span { color: var(--green); }

.header-status {
  font-size: 12px;
  color: var(--muted);
}

/* Steps */
.step {
  display: none;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.step.active { display: block; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.step-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.step-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}

/* Reg plate input */
.reg-input-wrap {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.reg-input {
  flex: 1;
  background: #fbbf24;
  color: #000;
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 3px;
  text-transform: uppercase;
  padding: 14px 16px;
  border: 3px solid #000;
  border-radius: 8px;
  outline: none;
  font-family: 'UKNumberPlate', monospace;
}

.reg-input::placeholder {
  color: #92400e;
  font-weight: 400;
  letter-spacing: 1px;
  font-size: 16px;
}

/* Buttons */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--green); color: #000; }
.btn-secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn-nav { background: var(--blue); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-small { padding: 10px; font-size: 14px; }

/* Vehicle card */
.vehicle-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}

.vehicle-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.vehicle-make {
  font-size: 18px;
  font-weight: 700;
}

.vehicle-reg {
  background: #fbbf24;
  color: #000;
  font-weight: 700;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 4px;
  letter-spacing: 1px;
}

.dims-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.dim-box {
  background: var(--card);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}

.dim-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--green);
}

.dim-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dim-edit {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  width: 100%;
  padding: 4px;
  border-radius: 4px;
  outline: none;
}

.dim-edit:focus { border-color: var(--green); }

.vehicle-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
}

.vehicle-meta span { display: flex; align-items: center; gap: 4px; }

/* Map */
#map {
  width: 100%;
  height: 50vh;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 12px;
}

.location-inputs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.loc-input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  width: 100%;
}

.loc-input:focus { border-color: var(--green); }
.loc-input::placeholder { color: var(--muted); }

/* Results */
.verdict-banner {
  padding: 16px;
  border-radius: 12px;
  text-align: center;
  margin-bottom: 16px;
  font-size: 20px;
  font-weight: 700;
}

.verdict-green { background: rgba(34,197,94,0.15); color: var(--green); border: 2px solid var(--green); }
.verdict-red { background: rgba(239,68,68,0.15); color: var(--red); border: 2px solid var(--red); }
.verdict-amber { background: rgba(245,158,11,0.15); color: var(--amber); border: 2px solid var(--amber); }

.restriction-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.restriction-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  border-left: 4px solid var(--red);
}

.restriction-item.ltn { border-left-color: var(--amber); }
.restriction-item.school { border-left-color: var(--blue); }
.restriction-item.buslane { border-left-color: #a855f7; }
.restriction-item.camera { border-left-color: #f97316; }

.restriction-road { font-weight: 600; font-size: 15px; }
.restriction-detail { font-size: 13px; color: var(--muted); margin-top: 2px; }
.restriction-meta { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; gap: 12px; }

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 2000;
  font-size: 15px;
}

.hidden { display: none !important; }

/* Nav buttons at bottom */
.nav-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 3000;
  animation: fadeIn 0.2s ease;
  border: 1px solid var(--border);
}

/* Smart alert banners */
.alert-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 10px 16px;
  z-index: 4000;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  animation: alertSlideIn 0.4s ease, alertSlideOut 0.5s ease 6s forwards;
  pointer-events: none;
}
@keyframes alertSlideIn { from { transform: translateY(-100%); } to { transform: translateY(0); } }
@keyframes alertSlideOut { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-100%); opacity: 0; } }

.alert-banner.alert-green {
  background: rgba(34, 197, 94, 0.95);
  color: #000;
}
.alert-banner.alert-red {
  background: rgba(239, 68, 68, 0.95);
  color: #fff;
}
.alert-banner.alert-amber {
  background: rgba(245, 158, 11, 0.95);
  color: #000;
}
.alert-banner .alert-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.alert-green .alert-dot { background: #000; }
.alert-red .alert-dot { background: #fff; animation: pulse 0.6s ease 3; }
.alert-amber .alert-dot { background: #000; }
.alert-banner .alert-road {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.alert-banner .alert-dist {
  font-size: 12px;
  opacity: 0.8;
  flex-shrink: 0;
}

/* Suggestions dropdown */
.suggestions {
  position: absolute;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 1100;
}

.suggestion-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
  border-bottom: 1px solid var(--card);
}

.suggestion-item:hover, .suggestion-item:active {
  background: var(--card);
}

.loc-wrap { position: relative; }

/* Recent regs */
.recent-regs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.recent-regs:empty { display: none; }
.recent-regs-label {
  width: 100%;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.recent-reg-chip {
  background: #fbbf24;
  color: #000;
  font-weight: 700;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
  letter-spacing: 1px;
  cursor: pointer;
  border: none;
  font-family: monospace;
}
.recent-reg-chip:active { opacity: 0.8; }

/* Recent addresses */
.recent-addrs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}
.recent-addrs:empty { display: none; }
.recent-addr-chip {
  background: var(--card);
  color: var(--text);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
.recent-addr-chip:active { border-color: var(--green); }

/* Chip remove buttons */
.recent-reg-wrap, .recent-addr-wrap {
  display: inline-flex;
  align-items: center;
  position: relative;
}
.chip-remove {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: -6px;
  padding: 0;
  position: relative;
  z-index: 1;
}
.chip-remove:active { color: var(--red); border-color: var(--red); }

/* Saved van bar */
.saved-van-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.saved-van-info { flex: 1; }
.saved-van-reg {
  background: #fbbf24;
  color: #000;
  font-weight: 700;
  font-size: 14px;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 1px;
  font-family: monospace;
}
.saved-van-dims {
  font-size: 12px;
  color: var(--muted);
  margin-left: 8px;
}
.saved-van-change {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
}

/* Save van checkbox */
.save-van-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}
.save-van-check input { accent-color: var(--green); }

/* Settings divider */
.settings-divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

/* Disclaimer */
.disclaimer {
  margin-top: 16px;
  padding: 10px 12px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
  text-align: center;
  border-top: 1px solid var(--card);
}

/* Gear button */
.gear-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
}
.gear-btn:hover svg path { stroke: var(--green); }

/* Alert tracking bar */
.alert-tracking-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: rgba(34, 197, 94, 0.1);
  border-bottom: 1px solid rgba(34, 197, 94, 0.3);
}
.alert-bar-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--green);
}
.alert-pulse {
  width: 8px;
  height: 8px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 1.5s ease infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.3); }
}
.alert-stop-btn {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* Alert settings overlay */
.alert-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1500;
}
.alert-settings {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  padding: 20px 16px 32px;
  z-index: 1600;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  max-height: 80vh;
  overflow-y: auto;
}
.alert-settings.visible {
  transform: translateY(0);
}
.alert-settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.alert-close-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  padding: 0 4px;
}
.alert-toggle-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
}
.alert-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--card);
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
}
.alert-toggle.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.alert-cat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.alert-toggle-text {
  flex: 1;
  font-size: 14px;
}
.alert-toggle-text small {
  color: var(--muted);
  font-size: 11px;
}
/* Hide native checkbox */
.alert-toggle input[type="checkbox"] {
  display: none;
}
/* Toggle slider */
.toggle-slider {
  width: 44px;
  height: 24px;
  background: var(--border);
  border-radius: 12px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.alert-toggle input:checked + .toggle-slider {
  background: var(--green);
}
.alert-toggle input:checked + .toggle-slider::after {
  transform: translateX(20px);
}
.alert-distance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: var(--card);
  border-radius: 8px;
  font-size: 14px;
}
.alert-distance-row select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 14px;
}
