:root {
  --bg: #0b0f17;
  --surface: #121826;
  --surface-2: #192235;
  --border: #243047;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --mono: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sans: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.mono-val {
  font-family: var(--mono);
}

/* Auth Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at top, #141e33 0%, #0b0f17 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.auth-logo {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 10px;
  letter-spacing: 0.05em;
}

.auth-subtitle {
  color: var(--muted);
  margin-bottom: 20px;
}

.auth-card form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-card input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 14px;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 14px;
}

.auth-card input:focus {
  outline: none;
  border-color: var(--accent);
}

.auth-error {
  margin-top: 12px;
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
}

/* Buttons */
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 16px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--sans);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #06131f;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-start {
  background: var(--green);
  color: #052e16;
}

.btn-start:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-stop {
  background: var(--red);
  color: #fff;
}

.btn-stop:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-ghost {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--accent);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

/* Topbar */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

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

.brand-icon {
  font-size: 22px;
  color: var(--accent);
}

.brand-title {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.04em;
}

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

.topbar-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

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

.badge {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.badge-online {
  background: rgba(34, 197, 94, 0.14);
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.35);
}

.badge-offline {
  background: rgba(239, 68, 68, 0.14);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.35);
}

.badge-muted {
  background: var(--surface-2);
  color: var(--text);
}

.badge-root {
  background: rgba(245, 158, 11, 0.16);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.4);
}

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

/* Alert Banner */
.alert-banner {
  background: rgba(239, 68, 68, 0.16);
  border-bottom: 1px solid rgba(239, 68, 68, 0.4);
  color: #fecaca;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
}

.btn-icon {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 16px;
}

/* Controls Bar */
.controls-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background: #0f1522;
  border-bottom: 1px solid var(--border);
}

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

.control-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
}

.toggle-chip input {
  accent-color: var(--accent);
}

.inline-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.inline-select select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
}

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
  padding: 16px 20px 24px;
  max-width: 1600px;
  margin: 0 auto;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-media { grid-column: span 5; }
.card-gps { grid-column: span 7; }
.card-compass { grid-column: span 4; }
.card-sensors { grid-column: span 8; }
.card-terminal { grid-column: span 12; }

@media (max-width: 1024px) {
  .card-media, .card-gps, .card-compass, .card-sensors {
    grid-column: span 12;
  }
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-header h2 {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.pill {
  font-family: var(--mono);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--accent);
}

.link-sm {
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
}

.link-sm:hover {
  text-decoration: underline;
}

/* Camera & Mic */
.camera-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #070a10;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.camera-slot {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.secondary-slot {
  border-left: 1px solid var(--border);
}

.slot-tag {
  position: absolute;
  top: 6px;
  left: 6px;
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(11, 15, 23, 0.8);
  color: var(--accent);
  border: 1px solid var(--border);
}

.camera-view {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  text-align: center;
  padding: 16px;
}

.camera-placeholder small {
  font-size: 12px;
  opacity: 0.75;
}

.cam-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.cam-control-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cam-control-item input[type="range"] {
  flex: 1;
  max-width: 62%;
  accent-color: var(--accent);
}

.cam-control-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.mini-select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
}

.btn-flash-on {
  background: rgba(245, 158, 11, 0.22);
  border-color: rgba(245, 158, 11, 0.65);
  color: #fde68a;
}

.btn-audio-on {
  background: rgba(34, 197, 94, 0.2);
  border-color: rgba(34, 197, 94, 0.55);
  color: #86efac;
}

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

.mic-label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
}

.mic-meter {
  flex: 1;
  height: 10px;
  background: #070a10;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.mic-level-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #22c55e 0%, #f59e0b 75%, #ef4444 100%);
  transition: width 0.1s linear;
}

/* Map */
.map-box {
  width: 100%;
  height: 250px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #070a10;
  z-index: 1;
}

/* Metrics */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}

.metric {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

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

.metric-val {
  font-size: 14px;
  font-weight: 600;
}

/* Compass */
.compass-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 4px 0;
}

.compass-svg {
  width: 170px;
  height: 170px;
}

/* Barometer */
.big-stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.big-stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.big-num {
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
  margin-top: 4px;
}

.big-num small {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.divider {
  height: 1px;
  background: var(--border);
}

/* Terminal */
.terminal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle-mini {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.terminal-output {
  background: #06090f;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  height: 220px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
}

.log-line {
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 3px;
}

.log-ts { color: #64748b; }
.log-device { color: #38bdf8; }
.log-status { color: #4ade80; }
.log-command { color: #c084fc; }
.log-alert { color: #f87171; font-weight: 700; }
.log-telemetry { color: #94a3b8; }
.log-error { color: #fb923c; }
