:root {
  --bg-color: #071026;
  --surface-color: #0B1B3D;
  --surface-border: #162C5B;
  --text-primary: #FFFFFF;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  
  --safe-green: #00E676;
  --safe-glow: rgba(0, 230, 118, 0.25);
  --approaching-amber: #FFD600;
  --approaching-glow: rgba(255, 214, 0, 0.25);
  --exceeded-red: #FF3D00;
  --exceeded-glow: rgba(255, 61, 0, 0.35);

  --accent-cyan: #00E5FF;
  --ghana-gold: #FCD116;
  --ghana-green: #006B3F;
  --ghana-red: #CE1126;

  --card-radius: 16px;
  --btn-radius: 14px;
}

[data-theme="light"] {
  --bg-color: #F1F5F9;
  --surface-color: #FFFFFF;
  --surface-border: #CBD5E1;
  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;

  --safe-glow: rgba(0, 230, 118, 0.15);
  --approaching-glow: rgba(255, 214, 0, 0.15);
  --exceeded-glow: rgba(255, 61, 0, 0.2);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: background-color 0.25s ease, color 0.25s ease;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom, 24px);
}

.app-container {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 12px 16px 24px 16px;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.brand-text h1 {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  color: var(--text-primary);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: all 0.2s ease;
}

.icon-btn:active {
  transform: scale(0.92);
}

/* Status Badge */
.status-badge-container {
  display: flex;
  justify-content: center;
  margin: 10px 0;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  transition: all 0.3s ease;
}

.status-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #64748B;
}

.status-badge.active {
  background: var(--safe-glow);
  border-color: var(--safe-green);
  color: var(--safe-green);
}
.status-badge.active .dot {
  background: var(--safe-green);
  box-shadow: 0 0 8px var(--safe-green);
}

.status-badge.approaching {
  background: var(--approaching-glow);
  border-color: var(--approaching-amber);
  color: var(--approaching-amber);
}
.status-badge.approaching .dot {
  background: var(--approaching-amber);
  box-shadow: 0 0 8px var(--approaching-amber);
}

.status-badge.exceeded {
  background: var(--exceeded-glow);
  border-color: var(--exceeded-red);
  color: var(--exceeded-red);
  animation: pulse-border 1.2s infinite;
}
.status-badge.exceeded .dot {
  background: var(--exceeded-red);
  box-shadow: 0 0 10px var(--exceeded-red);
}

@keyframes pulse-border {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

/* Auto-Detect Radar Card */
.radar-card {
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  border-radius: var(--card-radius);
  padding: 12px 14px;
  margin-bottom: 12px;
  transition: all 0.25s ease;
}

.radar-card.auto-active {
  background: rgba(0, 229, 255, 0.08);
  border-color: rgba(0, 229, 255, 0.4);
}

.radar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.radar-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.radar-icon {
  font-size: 18px;
  color: var(--accent-cyan);
}

.radar-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #334155;
  transition: .3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--safe-green);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

.radar-status-text {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
  line-height: 1.35;
}

.radar-status-text strong {
  color: var(--accent-cyan);
}

/* Speedometer Gauge Area (Electric Cockpit Redesign) */
.speedometer-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  margin: 4px 0 2px 0;
  padding: 4px 0 8px 0;
  width: 100%;
}

.ambient-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 230, 118, 0.16) 0%, rgba(0, 230, 118, 0.03) 60%, transparent 75%);
  pointer-events: none;
  filter: blur(24px);
  transition: all 0.4s ease;
  z-index: 1;
}

.gauge-svg {
  width: 100%;
  max-width: 320px;
  height: 195px;
  overflow: visible;
  position: relative;
  z-index: 2;
}

.gauge-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 14;
  stroke-linecap: round;
}

[data-theme="light"] .gauge-track {
  stroke: rgba(0, 0, 0, 0.07);
}

.gauge-progress {
  fill: none;
  stroke: url(#safeGrad);
  stroke-width: 14;
  stroke-linecap: round;
  stroke-dasharray: 330;
  stroke-dashoffset: 330;
  transition: stroke-dashoffset 0.35s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.3s ease;
  filter: drop-shadow(0 0 14px var(--safe-glow));
}

.speed-digital-display {
  position: absolute;
  top: 42px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 3;
}

.speed-number {
  font-size: 72px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -2px;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  transition: color 0.25s ease;
  max-width: 220px;
  text-align: center;
}

.speed-unit {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-secondary);
  letter-spacing: 2.5px;
  margin-top: 2px;
}

.speed-motion-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 2px;
  transition: color 0.2s ease;
}

.speed-motion-tag.driving {
  color: var(--safe-green);
}

/* Authentic Ghana Road Speed Sign Badge (White circular disk with red ring) */
.ghana-road-sign-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 6px;
  padding: 3px 10px 3px 4px;
  border-radius: 20px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

[data-theme="light"] .ghana-road-sign-badge {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(0, 0, 0, 0.12);
}

.ghana-sign-disk {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 3px solid #EF3340;
  background: #FFFFFF;
  color: #0F172A;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: -0.5px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.ghana-sign-text {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--text-primary);
}

/* Early Warning Notification Info Pill */
.warning-pill {
  width: 100%;
  max-width: 380px;
  margin: 6px auto 10px auto;
  padding: 6px 14px;
  border-radius: 14px;
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  color: var(--text-secondary);
  transition: all 0.3s ease;
}

.warning-pill.approaching {
  color: var(--approaching-amber);
  border-color: rgba(255, 214, 0, 0.4);
  background: rgba(255, 214, 0, 0.08);
}

.warning-pill.exceeded {
  color: var(--exceeded-red);
  border-color: rgba(255, 61, 0, 0.4);
  background: rgba(255, 61, 0, 0.1);
  font-weight: 700;
}

/* Speed Limit Presets */
.preset-section {
  margin: 8px 0;
}

.preset-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-btn {
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  color: var(--text-primary);
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chip-btn:active {
  transform: scale(0.94);
}

.chip-btn.selected {
  background: var(--safe-green);
  border-color: var(--safe-green);
  color: #000000;
  font-weight: 800;
  box-shadow: 0 2px 10px var(--safe-glow);
}

.chip-btn.custom-chip {
  border-style: dashed;
}

/* Modern Trip Stats Glass Card */
.stats-glass-card {
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  border-radius: 18px;
  padding: 12px 8px;
  margin: 10px 0 16px 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.stat-col {
  flex: 1;
  text-align: center;
}

.stat-divider {
  width: 1px;
  height: 28px;
  background: rgba(255, 255, 255, 0.12);
}

[data-theme="light"] .stat-divider {
  background: rgba(0, 0, 0, 0.12);
}

.stat-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.stat-value {
  font-size: 18px;
  font-weight: 900;
  margin-top: 3px;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.stat-unit {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

/* Big Action Button (Ignition Style) */
.main-action-btn {
  width: 100%;
  padding: 16px;
  border-radius: 20px;
  border: none;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.2s ease;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.main-action-btn:active {
  transform: scale(0.97);
}

.main-action-btn.start-btn {
  background: linear-gradient(135deg, #00E676, #00E5FF);
  color: #0F172A;
  box-shadow: 0 6px 20px rgba(0, 230, 118, 0.28);
}

.main-action-btn.stop-btn {
  background: linear-gradient(135deg, #FF3D00, #D50000);
  color: #FFFFFF;
  box-shadow: 0 6px 20px rgba(255, 61, 0, 0.35);
}

.btn-indicator-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #FFFFFF;
  animation: pulse-dot 1s infinite alternate;
}

@keyframes pulse-dot {
  from { opacity: 0.4; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1.1); }
}

/* iOS Installation Banner */
.ios-banner {
  background: linear-gradient(135deg, rgba(252, 209, 22, 0.15), rgba(0, 229, 255, 0.15));
  border: 1px solid rgba(252, 209, 22, 0.35);
  border-radius: var(--card-radius);
  padding: 12px 14px;
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  line-height: 1.4;
}

.ios-banner .icon {
  font-size: 20px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  border-radius: 20px;
  width: 100%;
  max-width: 440px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--surface-border);
}

.modal-header h2 {
  font-size: 17px;
  font-weight: 800;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
}

.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.modal-body h3 {
  font-size: 14px;
  color: var(--text-primary);
  margin: 14px 0 6px 0;
}

.modal-body ul {
  padding-left: 18px;
  margin-bottom: 10px;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--surface-border);
}

.setting-info {
  flex: 1;
  padding-right: 12px;
}

.setting-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.setting-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.modal-btn {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--surface-border);
  background: var(--surface-color);
  color: var(--text-primary);
  font-weight: 700;
  cursor: pointer;
  margin-top: 10px;
}

.modal-btn.primary {
  background: var(--safe-green);
  color: #000;
  border: none;
}

/* Permission Modal & Help Callouts */
.permission-icon-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(0, 230, 118, 0.15);
  border: 2px solid var(--safe-green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  margin: 0 auto 14px auto;
}

.permission-text {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 16px;
}

.permission-help-card {
  background: rgba(255, 61, 0, 0.08);
  border: 1px solid rgba(255, 61, 0, 0.35);
  border-radius: 12px;
  padding: 12px 14px;
  margin-top: 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-primary);
}

.permission-help-card strong {
  color: var(--exceeded-red);
}

.permission-help-card ol {
  padding-left: 20px;
  margin-top: 6px;
}

.permission-help-card li {
  margin-bottom: 4px;
}

/* Alert Mode Chips */
.alert-mode-chips {
  display: flex;
  gap: 6px;
}

.mode-chip {
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-chip.selected {
  background: var(--safe-green);
  border-color: var(--safe-green);
  color: #0F172A;
}

/* Camera Zone List in Guide */
.camera-zone-list {
  list-style: none;
  padding: 0 !important;
  margin: 6px 0 10px 0;
}

.camera-zone-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  margin-bottom: 4px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  font-size: 12px;
}

[data-theme="light"] .camera-zone-item {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.06);
}

.camera-zone-item .cam-name {
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.camera-zone-item .cam-limit {
  font-weight: 800;
  color: var(--safe-green);
  background: rgba(0, 230, 118, 0.12);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 11px;
}

/* History / Evidence Logs */
.history-logs-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 55vh;
  overflow-y: auto;
}

.log-entry-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  transition: all 0.2s ease;
}

[data-theme="light"] .log-entry-card {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}

.log-entry-card.approaching {
  border-left: 4px solid var(--approaching-amber);
}

.log-entry-card.exceeded {
  border-left: 4px solid var(--exceeded-red);
}

.log-main-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.log-road-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.log-time-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.log-speed-badge {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.log-speed-num {
  font-size: 16px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.log-speed-badge.approaching .log-speed-num {
  color: var(--approaching-amber);
}

.log-speed-badge.exceeded .log-speed-num {
  color: var(--exceeded-red);
}

.log-limit-info {
  font-size: 10px;
  color: var(--text-secondary);
  font-weight: 600;
}
