:root {
  --bg-main: #090d16;
  --bg-card: #111827;
  --bg-card-hover: #1f293d;
  --bg-input: #0b1120;
  --border-color: #1e293b;
  --border-glow: rgba(56, 189, 248, 0.3);
  
  --primary: #38bdf8;
  --primary-glow: rgba(56, 189, 248, 0.5);
  --primary-hover: #0284c7;

  --success: #22c55e;
  --success-glow: rgba(34, 197, 94, 0.4);
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.4);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --font-main: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, sans-serif;
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  user-select: none;
}

/* App Wrapper */
.app-container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at top, #131d33 0%, #090d16 100%);
  position: relative;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-wrap img {
  width: 32px;
  height: 32px;
  filter: drop-shadow(0 0 8px var(--primary-glow));
}

.logo-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--primary);
  text-transform: uppercase;
}

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

.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  background: #1e293b;
  border: 1px solid #334155;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
}

.status-badge.online .status-dot {
  background: var(--success);
  box-shadow: 0 0 10px var(--success-glow);
  animation: pulse-dot 2s infinite;
}

.status-badge.offline .status-dot {
  background: var(--danger);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.btn-icon {
  background: #1e293b;
  border: 1px solid #334155;
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

/* Device Switcher Bar */
.car-selector-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgba(15, 23, 42, 0.6);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.car-name-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.car-sub-info {
  font-size: 12px;
  color: var(--text-muted);
}

.btn-add-car {
  font-size: 12px;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid var(--primary);
  color: var(--primary);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-add-car:active {
  transform: scale(0.95);
  background: var(--primary);
  color: #000;
}

/* Main Content Views */
.main-content {
  flex: 1;
  padding: 16px 20px 80px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Car Visual Stage */
.car-visual-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.car-silhouette-wrap {
  width: 140px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin: 10px 0;
}

.car-silhouette-img {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 15px rgba(56, 189, 248, 0.2));
  transition: transform 0.5s ease;
}

.car-indicator-glow {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.15) 0%, transparent 70%);
}

.car-state-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
  margin-top: 10px;
}

.badge-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  background: #1e293b;
  border: 1px solid #334155;
  color: var(--text-muted);
}

.badge-item.active {
  background: rgba(34, 197, 94, 0.15);
  border-color: var(--success);
  color: var(--success);
}

.badge-item.warning {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--danger);
  color: var(--danger);
}

/* Control Buttons Grid (Tactile Remote) */
.controls-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.btn-ctrl {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  overflow: hidden;
}

.btn-ctrl:active {
  transform: scale(0.93);
  border-color: var(--primary);
  background: var(--bg-card-hover);
}

.btn-ctrl .icon {
  font-size: 24px;
}

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

.btn-ctrl.lock {
  border-color: rgba(56, 189, 248, 0.3);
}
.btn-ctrl.lock:active {
  border-color: var(--primary);
  box-shadow: 0 0 15px var(--primary-glow);
}

.btn-ctrl.unlock {
  border-color: rgba(245, 158, 11, 0.3);
}
.btn-ctrl.unlock:active {
  border-color: var(--warning);
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.5);
}

.btn-ctrl.engine {
  grid-column: span 3;
  padding: 18px;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid #38bdf8;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.2);
  flex-direction: row;
  gap: 12px;
}

.btn-ctrl.engine.running {
  border-color: var(--success);
  box-shadow: 0 0 25px var(--success-glow);
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.2) 0%, #0f172a 100%);
}

.btn-ctrl.engine .label {
  font-size: 14px;
  color: var(--text-main);
}

/* Telemetry Dashboard Cards */
.telemetry-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

.stat-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.stat-unit {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
}

.battery-bar {
  width: 100%;
  height: 6px;
  background: #1e293b;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}

.battery-fill {
  height: 100%;
  background: var(--success);
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* Interactive Map Card */
.map-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.map-card-header {
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  background: #111827;
}

.map-card-title {
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.map-actions {
  display: flex;
  gap: 8px;
}

.map-container {
  width: 100%;
  height: 240px;
  background: #0b1120;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  padding: 8px 12px 12px;
  z-index: 99;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  background: none;
  border: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.nav-item.active, .nav-item:active {
  color: var(--primary);
}

.nav-item .icon {
  font-size: 20px;
}

/* Modal Popup Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

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

.modal-sheet {
  background: #111827;
  border-top: 1px solid var(--border-color);
  border-radius: 24px 24px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.open .modal-sheet {
  transform: translateY(0);
}

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

.modal-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
}

/* Form Styles */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.form-input {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

.btn-primary {
  background: var(--primary);
  color: #000;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  box-shadow: 0 4px 15px rgba(56, 189, 248, 0.3);
}

.btn-primary:active {
  transform: scale(0.97);
  background: var(--primary-hover);
}

.btn-secondary {
  background: #1e293b;
  color: var(--text-main);
  border: 1px solid #334155;
  border-radius: var(--radius-md);
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}

.btn-secondary:active {
  background: #334155;
}

/* Step list for 00581# Instructions */
.steps-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: var(--radius-md);
  padding: 16px;
}

.step-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 13px;
  line-height: 1.4;
}

.step-num {
  background: var(--primary);
  color: #000;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  flex-shrink: 0;
}

.code-pill {
  background: #1e293b;
  border: 1px solid #38bdf8;
  color: #38bdf8;
  font-family: monospace;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

/* Toast Notifications */
.toast-box {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: #1e293b;
  border: 1px solid var(--primary);
  color: var(--text-main);
  padding: 12px 20px;
  border-radius: var(--radius-full);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  font-size: 14px;
  font-weight: 600;
  z-index: 999;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 90%;
  text-align: center;
}

.toast-box.show {
  transform: translateX(-50%) translateY(0);
}

.toast-box.error {
  border-color: var(--danger);
  background: #2a1215;
}

.toast-box.success {
  border-color: var(--success);
  background: #0e2a1b;
}

/* Auth Screens */
.auth-wrapper {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 90vh;
  gap: 20px;
}

.auth-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.auth-header img {
  width: 56px;
  height: 56px;
  filter: drop-shadow(0 0 12px var(--primary-glow));
}

.auth-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 1px;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--text-muted);
}

.captcha-wrap {
  display: flex;
  gap: 10px;
  align-items: center;
}

.captcha-img {
  height: 48px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #111827;
  cursor: pointer;
}

/* Event List Items */
.event-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.event-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.event-time {
  font-size: 11px;
  color: var(--text-dim);
}
