:root {
  --primary: #6366F1;
  --primary-light: #818CF8;
  --accent: #F472B6;
  --bg-color: #030712;
  --surface-color: #111827;
  --text-primary: #F9FAFB;
  --text-secondary: #9CA3AF;
  --success: #10B981;
  --danger: #EF4444;
  --font-heading: 'Exo 2', sans-serif;
  --font-body: 'Inter', sans-serif;
  --safe-area-bottom: env(safe-area-inset-bottom, 20px);
}

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

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(64px + var(--safe-area-bottom)); /* Space for bottom nav */
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  margin: 0;
}

h1 { font-size: 28px; }
h2 { font-size: 24px; }
h3 { font-size: 20px; }
p { margin: 0 0 1rem 0; font-size: 16px; }
.text-sm { font-size: 14px; color: var(--text-secondary); }
.text-xs { font-size: 12px; color: var(--text-secondary); }

/* Layout Utilities */
.container {
  padding: 16px;
  max-width: 100%;
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

/* Components: Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: rgba(3, 7, 18, 0.95);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-color);
  border: 2px solid var(--primary);
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  padding: 8px;
  cursor: pointer;
  position: relative;
}

.badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  background-color: var(--accent);
  border-radius: 50%;
}

/* Components: Cards */
.card {
  background-color: var(--surface-color);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.1); /* Cosmic glow */
  border: 1px solid rgba(255,255,255,0.05);
}

/* Components: Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: 0 24px;
  border-radius: 8px;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 16px;
  border: none;
  cursor: pointer;
  width: 100%;
  transition: transform 0.1s;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background-color: var(--primary);
  color: white;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

.btn-accent {
  background-color: var(--accent);
  color: white;
  box-shadow: 0 0 15px rgba(244, 114, 182, 0.4);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
}

/* Components: Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(64px + var(--safe-area-bottom));
  background-color: var(--surface-color);
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  padding-top: 12px;
  padding-bottom: var(--safe-area-bottom);
  border-top: 1px solid rgba(255,255,255,0.05);
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 12px;
  gap: 4px;
  width: 64px;
}

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

.nav-item svg {
  width: 24px;
  height: 24px;
}

/* Screen Specific: Dashboard */
.hero-gauge {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 24px auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.pulse-ring {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: 50%;
  border: 2px solid var(--primary);
  animation: pulse 2s infinite;
  opacity: 0;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.5; }
  100% { transform: scale(1.4); opacity: 0; }
}

.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: rgba(255,255,255,0.1);
}

.timeline-item {
  position: relative;
  margin-bottom: 24px;
}

.timeline-dot {
  position: absolute;
  left: -24px;
  top: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface-color);
  border: 3px solid var(--text-secondary);
  z-index: 2;
}

.timeline-dot.active { border-color: var(--primary); box-shadow: 0 0 10px var(--primary); background: var(--primary); }
.timeline-dot.good { border-color: var(--success); background: var(--success); }
.timeline-dot.bad { border-color: var(--danger); background: var(--danger); }

/* Screen Specific: App Manager */
.app-row {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.app-icon {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: rgba(255,255,255,0.1);
  margin-right: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.toggle-switch {
  width: 50px;
  height: 30px;
  background: #374151;
  border-radius: 15px;
  position: relative;
  transition: 0.3s;
}

.toggle-switch.on {
  background: var(--primary);
}

.toggle-knob {
  width: 26px;
  height: 26px;
  background: white;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: 0.3s;
}

.toggle-switch.on .toggle-knob {
  transform: translateX(20px);
}

/* Screen Specific: Map (Landscape) */
.landscape-body {
  padding-bottom: 0; /* Remove nav padding for immersive view */
  background: #000;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

.map-container {
  width: 100%;
  height: 100%;
  position: relative;
  background: radial-gradient(circle at center, #1e1b4b 0%, #030712 70%);
}

.map-overlay {
  position: absolute;
  top: 16px;
  left: 16px;
  background: rgba(17, 24, 39, 0.8);
  backdrop-filter: blur(8px);
  padding: 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  color: white;
  max-width: 250px;
}

.fab {
  position: absolute;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  color: white;
  border: none;
}

.map-slider-container {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  background: rgba(17, 24, 39, 0.8);
  padding: 12px 24px;
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

input[type=range] {
  width: 100%;
  -webkit-appearance: none;
  background: transparent;
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 20px;
  width: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  margin-top: -8px;
  box-shadow: 0 0 10px var(--accent);
}

input[type=range]::-webkit-slider-runnable-track {
  width: 100%;
  height: 4px;
  cursor: pointer;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
}

/* SVG Helpers */
svg { fill: currentColor; }
