/* ==========================================================================
   Vehicle & GCS Dashboard Design System
   Technical Cockpit / Industrial High-Density Architecture
   Complies with vehicle-gcs-dashboard-design SKILL.md
   ========================================================================== */

/* ── 1. CSS Design Tokens ─────────────────────────────────────────────── */
:root {
  /* Surface & Background */
  --bg: #eef0f3;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --surface-hover: #edf2f9;
  --line: #d3d8e0;
  --line-strong: #aeb6c2;

  /* Typography Colors */
  --text: #14181f;       /* Đen than: chữ chính, tiêu đề */
  --text-2: #4d5766;     /* Xám thép: nhãn, phụ đề */
  --text-3: #7d8795;     /* Xám nhạt: ghi chú, đơn vị đo */

  /* Primary Accent: Navy Hải quân chỉ huy */
  --primary: #1a4d8f;
  --primary-hover: #153e73;
  --primary-ink: #ffffff;

  /* Semantic Status Colors (Aviation & GCS standard) */
  --ok: #157a3a;          /* Xanh lục: Hoạt động bình thường, GPS Fix */
  --ok-bg: #e2f3e8;
  --warn: #b25e00;        /* Cam cháy: Cảnh báo, ARMED, Waypoint hiện tại */
  --warn-bg: #fff1dc;
  --danger: #b42318;      /* Đỏ đô: Khẩn cấp, Failsafe, Mất tín hiệu */
  --danger-bg: #fde7e5;
  --info: #0284c7;        /* Xanh da trời: Lộ trình, Điểm rẽ, Thông tin */
  --info-bg: #e0f2fe;

  /* Lớp bản đồ Vệ tinh: Tương phản cao trên nền vệ tinh */
  --sat-route: #00e5ff;
  --sat-street-route: #38bdf8;
  --sat-track: #00e676;

  /* Typography Tokens */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: "JetBrains Mono", Consolas, monospace;

  /* Layout Dimensions */
  --sidebar-w: 210px;
  --topbar-h: 48px;
  --radius: 4px;
  --radius-sm: 4px;
  --shadow-sm: 0 1px 2px rgba(20, 24, 31, 0.06);
  --shadow-md: 0 4px 12px rgba(20, 24, 31, 0.12);

  /* Vietnam Flag dynamic zoom variables (updated via JS on zoom) */
  --vn-flag-w: 48px;
  --vn-flag-h: 32px;
  --vn-flag-font: 11px;
}

/* ── 2. Reset & Core Base ─────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Tabular numbers for all telemetry and counters */
.tabular-num,
.metric-value,
.stat-value,
.sensor-val,
.pill-value,
.clock-text {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

/* ── 3. Application Shell & Grid ──────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ── Sidebar (210px fixed) ────────────────────────────────────────────── */
.app-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 200;
}

.sidebar-header {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.brand-badge {
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  background: var(--primary);
  color: var(--primary-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 12px;
  letter-spacing: 0.05em;
  box-shadow: 0 2px 4px rgba(26, 77, 143, 0.25);
}

.brand-titles {
  display: flex;
  flex-direction: column;
}

.brand-main {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text);
  line-height: 1.1;
}

.brand-sub {
  font-size: 9px;
  color: var(--text-3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  color: var(--text-2);
  text-decoration: none;
  font-weight: 600;
  font-size: 12px;
  transition: background-color 0.15s, color 0.15s;
}

.nav-link svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.nav-link:hover {
  background: var(--surface-hover);
  color: var(--primary);
}

.nav-link.active {
  background: var(--primary);
  color: var(--primary-ink);
  box-shadow: var(--shadow-sm);
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-copyright {
  font-size: 9.5px;
  color: var(--text-3);
  text-align: center;
  padding-top: 6px;
  letter-spacing: 0.02em;
  border-top: 1px dashed var(--line);
  user-select: none;
}
.sidebar-copyright strong {
  color: var(--primary);
  font-weight: 700;
}

.mode-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.mode-tag {
  padding: 2px 6px;
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.mode-tag.mode-auto { background: var(--ok-bg); color: var(--ok); border: 1px solid rgba(21, 122, 58, 0.3); }
.mode-tag.mode-guided { background: var(--info-bg); color: var(--info); border: 1px solid rgba(2, 132, 199, 0.3); }
.mode-tag.mode-hold { background: var(--warn-bg); color: var(--warn); border: 1px solid rgba(178, 94, 0, 0.3); }
.mode-tag.mode-manual { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line-strong); }
.mode-tag.mode-rtl { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(180, 35, 24, 0.3); }
.mode-tag.mode-takeoff { background: #e0f2fe; color: #0284c7; border: 1px solid rgba(2, 132, 199, 0.4); }
.mode-tag.mode-running { background: #dcfce7; color: #15803d; border: 1px solid rgba(22, 163, 74, 0.4); }
.mode-tag.mode-landing { background: #fef3c7; color: #b45309; border: 1px solid rgba(217, 119, 6, 0.4); }
.mode-tag.mode-idle { background: var(--surface-2); color: var(--text-3); border: 1px solid var(--line); }

/* ── 4. Main Canvas & TopBar (48px fixed) ──────────────────────────────── */
.main-canvas {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

.topbar-cockpit {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.station-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar-lab-badge {
  font-family: var(--font-display);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  background: rgba(26, 77, 143, 0.08);
  color: var(--primary);
  border: 1px solid rgba(26, 77, 143, 0.22);
  padding: 1px 7px;
  border-radius: 4px;
  margin-left: 6px;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
}

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

/* Status Pills */
.cockpit-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
  transition: all 0.2s ease;
}

.pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line-strong);
}

.pulse-led {
  animation: pulse-heartbeat 2s infinite ease-in-out;
}

@keyframes pulse-heartbeat {
  0% { transform: scale(0.95); opacity: 0.7; }
  50% { transform: scale(1.15); opacity: 1; filter: drop-shadow(0 0 4px currentColor); }
  100% { transform: scale(0.95); opacity: 0.7; }
}

/* Armed / Disarmed Pill */
.cockpit-pill.arm-pill.armed {
  background: var(--warn-bg);
  border-color: rgba(178, 94, 0, 0.4);
  color: var(--warn);
}
.cockpit-pill.arm-pill.armed .pill-dot {
  background: var(--warn);
  box-shadow: 0 0 6px var(--warn);
}
.cockpit-pill.arm-pill.disarmed {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--text-3);
}
.cockpit-pill.arm-pill.disarmed .pill-dot {
  background: var(--text-3);
}

/* GPS Pill */
.cockpit-pill.gps-pill {
  color: var(--primary);
  border-color: rgba(26, 77, 143, 0.25);
  background: #f0f4fa;
}
.cockpit-pill.gps-pill .pill-dot {
  background: var(--primary);
}

/* Battery Pill */
.cockpit-pill.battery-pill {
  font-family: var(--mono);
}
.battery-pill.ok { color: var(--ok); border-color: rgba(21, 122, 58, 0.3); background: var(--ok-bg); }
.battery-pill.warn { color: var(--warn); border-color: rgba(178, 94, 0, 0.3); background: var(--warn-bg); }
.battery-pill.crit { color: var(--danger); border-color: rgba(180, 35, 24, 0.3); background: var(--danger-bg); animation: flash-crit 1s infinite alternate; }

@keyframes flash-crit {
  from { background: var(--danger-bg); }
  to { background: #ffc9c6; }
}

/* Live Clock */
.clock-display {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
  padding: 0 8px;
  border-left: 1px solid var(--line);
}

/* ── 5. Cockpit Workspace Views ───────────────────────────────────────── */
.canvas-body {
  flex: 1;
  overflow: hidden;
  position: relative;
  display: flex;
}

/* Mission Planner Grid: Map (Left) + Cockpit Panel (Right: 350px) */
.mission-viewport {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 360px;
  height: calc(100vh - var(--topbar-h));
  position: relative;
  overflow: hidden;
}

.map-container-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  background: #dce3eb;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#map {
  width: 100%;
  flex: 1;
  min-height: 0;
  z-index: 1;
}

/* ── Realtime Altitude Telemetry Chart (Bottom Docked) ────────────────── */
.altitude-chart-panel {
  width: 100%;
  background: #ffffff;
  border-top: 1px solid var(--line);
  box-shadow: 0 -2px 8px rgba(20, 24, 31, 0.06);
  z-index: 800;
  display: flex;
  flex-direction: column;
  transition: all 0.25s ease-in-out;
  flex-shrink: 0;
}

.altitude-chart-panel.collapsed .alt-chart-body {
  display: none;
}

/* Top bar: Tabs + Points + Hide/Show */
.alt-chart-header {
  height: 32px;
  background: #ffffff;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
}

.alt-chart-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
}

.alt-tab-btn {
  background: transparent;
  border: none;
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 700;
  color: #64748b;
  padding: 4px 10px;
  border-radius: 2px;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: all 0.15s;
}

.alt-tab-btn:hover {
  color: var(--text);
}

.alt-tab-btn.active {
  background: #02457a;
  color: #ffffff;
  font-weight: 800;
}

.alt-chart-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.alt-pts-counter {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
}

.alt-toggle-btn {
  background: transparent;
  border: 1px solid transparent;
  font-family: var(--font);
  font-size: 10.5px;
  font-weight: 700;
  color: #64748b;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 3px;
  transition: all 0.15s;
}

.alt-toggle-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--line);
}

/* Body: Subbar + Canvas */
.alt-chart-body {
  display: flex;
  flex-direction: column;
}

.alt-chart-subbar {
  height: 24px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 10px;
}

.alt-axes-label {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
  color: #64748b;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.alt-chart-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font);
  font-size: 10.5px;
  font-weight: 600;
}

.alt-chart-legend .legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.alt-chart-legend .legend-item.target {
  color: #0284c7;
}

.alt-chart-legend .legend-item.target .legend-dash {
  font-family: var(--mono);
  font-weight: 900;
  letter-spacing: -1px;
}

.alt-chart-legend .legend-item.actual {
  color: #157a3a;
}

.alt-chart-legend .legend-item.actual .legend-line {
  font-family: var(--mono);
  font-weight: 900;
}

.alt-chart-legend .legend-item.terrain {
  color: #b45309;
}

.alt-chart-legend .legend-item.terrain .legend-line {
  font-family: var(--mono);
  font-weight: 900;
}

.alt-canvas-wrap {
  position: relative;
  width: 100%;
  height: 120px;
  background: #ffffff;
}

#altitude-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Flight state pills */
.flight-state-pill {
  font-family: var(--mono);
  font-weight: 700;
}
.flight-state-pill.takeoff { background: #e0f2fe; color: #0284c7; border-color: #0284c7; }
.flight-state-pill.running { background: #dcfce7; color: #15803d; border-color: #16a34a; }
.flight-state-pill.hold { background: #fef3c7; color: #b45309; border-color: #d97706; }
.flight-state-pill.landing { background: #fae8ff; color: #9333ea; border-color: #a855f7; }
.flight-state-pill.idle { background: var(--surface-2); color: var(--text-3); border-color: var(--line); }

/* Map Controls Floating Bar */
.map-floating-bar {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  padding: 4px 6px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}

.layer-btn {
  padding: 4px 10px;
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
}

.layer-btn:hover {
  background: var(--surface-hover);
  color: var(--primary);
}

.layer-btn.active {
  background: var(--primary);
  color: var(--primary-ink);
  border-color: var(--primary-hover);
}

/* ── 6. Precision Needle Waypoint Pin & Sovereign Markers ─────────────── */
.wp-pin-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  cursor: pointer;
  user-select: none;
}

.wp-name-badge {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  background: rgba(20, 24, 31, 0.85);
  color: #fff;
  border-radius: 2px;
  margin-bottom: 2px;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}

.wp-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: 2px solid #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s, background-color 0.2s;
}

.wp-pin-container:hover .wp-icon {
  transform: scale(1.15);
}

.wp-pin-container.active-target .wp-icon {
  background: var(--warn);
  border-color: #ffe0b2;
  box-shadow: 0 0 10px var(--warn);
}

.wp-pin-tip {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid var(--primary);
  margin-top: -1px;
}

.wp-pin-container.active-target .wp-pin-tip {
  border-top-color: var(--warn);
}

/* Quần Đảo Hoàng Sa & Trường Sa Dynamic Sovereign Markers */
.sovereign-territory-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: transform 0.2s;
}

.sovereign-territory-marker:hover {
  transform: scale(1.08);
}

.sovereign-flag-box {
  width: var(--vn-flag-w, 48px);
  height: var(--vn-flag-h, 32px);
  border: 2px solid #ffcc00;
  border-radius: 2px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
  background: #da251d;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.sovereign-flag-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sovereign-badge {
  background: #b42318;
  color: #ffcc00;
  font-family: var(--font-display);
  font-size: var(--vn-flag-font, 11px);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 10px;
  border-radius: 14px;
  margin-top: 4px;
  border: 1px solid #ffcc00;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.sovereign-badge.truong-sa {
  background: linear-gradient(135deg, #057a44 0%, #035c33 100%);
  border-color: #ffcc00;
}

/* ── 7. Cockpit Right Panel (Compact & High-Density) ──────────────────── */
.mission-viewport {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 340px;
  height: calc(100vh - var(--topbar-h));
  position: relative;
  overflow: hidden;
}

.cockpit-panel {
  width: 340px;
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  gap: 8px;
  padding: 8px;
  box-shadow: -1px 0 6px rgba(20, 24, 31, 0.04);
}

/* Dual Attitude & Compass Instruments */
.cockpit-instruments-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.instrument-card {
  background: #ffffff;
  border: 1px solid #d3d8e0;
  border-radius: 6px;
  padding: 8px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.instrument-title {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 800;
  color: #1a4d8f;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.instrument-dial-wrap {
  width: 86px;
  height: 86px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dial-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.instrument-subtext {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  color: #14181f;
  margin-top: 6px;
  letter-spacing: 0.02em;
}

.compass-pill {
  margin-top: 5px;
  padding: 2px 10px;
  border: 1px solid #d3d8e0;
  border-radius: 4px;
  background: #f8fafc;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  color: #14181f;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 62px;
}

/* Compact Flight Status Bar (4 cells) */
.flight-mini-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 6px;
}

.flight-mini-cell {
  text-align: center;
}

.flight-mini-lbl {
  font-size: 8.5px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  display: block;
}

.flight-mini-val {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 800;
  color: var(--text);
}

/* Altitude Configuration */
.cockpit-alt-config {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 5px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.alt-config-lbl {
  font-size: 8.5px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.alt-config-badge {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 800;
  color: #0284c7;
}

.alt-config-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.alt-input-box {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  overflow: hidden;
  height: 25px;
}

.alt-btn-step {
  width: 22px;
  height: 100%;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  padding: 0;
}

.alt-btn-step:hover {
  background: var(--surface-2);
  color: var(--text);
}

.alt-input-box input {
  width: 38px;
  height: 100%;
  border: none;
  background: transparent;
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  padding: 0;
  -moz-appearance: textfield;
}

.alt-input-box input::-webkit-outer-spin-button,
.alt-input-box input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.alt-presets {
  display: flex;
  gap: 4px;
  flex: 1;
}

.alt-preset-chip {
  flex: 1;
  height: 25px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  padding: 0;
}

.alt-preset-chip:hover {
  border-color: #0284c7;
  color: #0284c7;
}

.alt-preset-chip.active {
  background: #0284c7;
  border-color: #0284c7;
  color: #ffffff;
  font-weight: 700;
}

/* Altitude Stepper Component */
.cockpit-altitude-stepper {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stepper-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.stepper-label {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-2);
}
.stepper-target-badge {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 800;
  color: var(--primary);
  background: rgba(26, 77, 143, 0.08);
  padding: 1px 6px;
  border-radius: 3px;
}
.stepper-row {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
}
.stepper-btn {
  flex: 1;
  height: 28px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.stepper-btn:hover {
  background: var(--surface-hover);
  border-color: var(--primary);
  color: var(--primary);
}
.stepper-btn:active {
  transform: translateY(1px);
}
.stepper-val-display {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  height: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 4px;
}
.stepper-val-display input {
  width: 32px;
  border: none;
  background: transparent;
  text-align: center;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 800;
  color: var(--primary);
  padding: 0;
  outline: none;
  -moz-appearance: textfield;
}
.stepper-val-display input::-webkit-outer-spin-button,
.stepper-val-display input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.stepper-unit {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  margin-left: 2px;
}

/* ==========================================================================
   COCKPIT FLIGHT CONTROL CARD (Industrial GCS Console)
   ========================================================================== */
.cockpit-flight-ctrl-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

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

.control-card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.control-card-title svg {
  color: var(--primary);
}

.ctrl-mode-badge {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 3px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  transition: all 0.2s ease;
}
.ctrl-mode-badge.standby {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}
.ctrl-mode-badge.armed {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}
.ctrl-mode-badge.flying {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}
.ctrl-mode-badge.measuring {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

/* Stepper inside Flight Card */
.control-stepper-box {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

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

.control-stepper-box .stepper-label {
  font-family: var(--font-display);
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-2);
}

.control-stepper-box .stepper-target-badge {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 800;
  color: var(--primary);
  background: #ffffff;
  border: 1px solid var(--line);
  padding: 0 5px;
  border-radius: 3px;
}

/* Flight Action Container & Multi-Row Grid Layouts */
.flight-actions-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.flight-actions-row {
  display: grid;
  gap: 6px;
  width: 100%;
}

.flight-row-3 {
  grid-template-columns: repeat(3, 1fr);
}

.flight-row-2 {
  grid-template-columns: repeat(2, 1fr);
}

/* Legacy fallback grid */
.flight-actions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: 100%;
}

.btn-ctrl {
  width: 100%;
  height: 31px;
  padding: 0 4px;
  border-radius: 4px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
  box-sizing: border-box;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-ctrl:active {
  transform: translateY(1px);
}

.btn-ctrl svg {
  flex-shrink: 0;
}

.btn-ctrl.btn-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(40%);
}

.btn-ctrl.btn-locked-high {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(50%);
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #94a3b8;
}

/* Button 1: Bắt đầu (Start Mission) - Green Accent */
.btn-ctrl-start {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}
.btn-ctrl-start:hover {
  background: #d1fae5;
  color: #065f46;
  border-color: #6ee7b7;
}

/* Button 2: Cất cánh (Takeoff) - Blue Aviation Accent */
.btn-ctrl-takeoff {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}
.btn-ctrl-takeoff:hover {
  background: #dbeafe;
  color: #1e40af;
  border-color: #93c5fd;
}

/* Button 3: Hạ cánh (Land / RTL) - Red Emergency Accent */
.btn-ctrl-land {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}
.btn-ctrl-land:hover {
  background: #fee2e2;
  color: #991b1b;
  border-color: #f87171;
}

/* Button 4: Bật motor (Arm) - Amber / Emerald Safety Accent */
.btn-ctrl-arm {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}
.btn-ctrl-arm:hover {
  background: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
}
.btn-ctrl-arm.is-armed {
  background: #ecfdf5;
  color: #047857;
  border-color: #6ee7b7;
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.25);
}

/* Button 5: Tắt motor (Disarm) - Red Urgent Safety Accent */
.btn-ctrl-disarm {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}
.btn-ctrl-disarm:hover {
  background: #fee2e2;
  color: #991b1b;
  border-color: #f87171;
}
.btn-ctrl-disarm.is-active {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fca5a5;
  font-weight: 800;
}

/* Button 6: Nạp điểm (Upload Waypoints) - Steel Neutral */
.btn-ctrl-upload {
  background: #f8fafc;
  color: #334155;
  border: 1px solid #cbd5e1;
}
.btn-ctrl-upload:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #94a3b8;
}

/* Button 7: Xóa điểm (Clear Waypoints) - Slate Ghost */
.btn-ctrl-clear {
  background: #f8fafc;
  color: #64748b;
  border: 1px solid #e2e8f0;
}
.btn-ctrl-clear:hover {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
}

/* Fallback for table actions */
.btn-cockpit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  border: 1px solid var(--line);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn-cockpit.btn-primary {
  background: #f0fdf4;
  color: #15803d;
  border-color: #bbf7d0;
}
.btn-cockpit.btn-outline {
  background: #ffffff;
  color: #64748b;
  border-color: #e2e8f0;
}

/* Waypoint Measurement Popup (Clean, High Scannability) */
.wp-measurement-popup {
  font-family: var(--font);
  color: #1e293b;
  min-width: 220px;
  padding: 4px;
}

.wp-popup-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 4px;
}

.wp-popup-name {
  font-weight: 700;
  font-size: 12px;
  color: #0f172a;
}

.wp-badge-status {
  font-size: 9.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}
.wp-badge-status.done {
  background: #dcfce7;
  color: #166534;
}
.wp-badge-status.measuring {
  background: #fef3c7;
  color: #92400e;
}
.wp-badge-status.pending {
  background: #f1f5f9;
  color: #64748b;
}

.wp-popup-aqi-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 4px 8px;
  margin-bottom: 6px;
}

.wp-aqi-score {
  font-family: var(--mono);
  font-weight: 800;
  font-size: 13px;
}

.wp-aqi-text {
  font-weight: 700;
  font-size: 11px;
}

.wp-popup-metrics-table {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 6px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 6px 8px;
}

.wp-metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10.5px;
}

.wp-metric-row .lbl {
  color: #64748b;
}

.wp-metric-row .val {
  font-family: var(--mono);
  font-weight: 700;
  color: #0f172a;
}

.wp-popup-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 9.5px;
  color: #94a3b8;
  font-family: var(--mono);
}

/* Waypoint List Items in Sidebar */
.wp-compact-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.wp-compact-item:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.wp-compact-item.current-target {
  border-color: #0284c7;
  background: #f0f9ff;
}

.wp-compact-item.visited {
  border-color: #86efac;
  background: #f0fdf4;
}

.wp-status-chip {
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
}

.wp-status-chip.done {
  background: #dcfce7;
  color: #15803d;
}

.wp-status-chip.active {
  background: #fef3c7;
  color: #b45309;
}

.wp-status-chip.pending {
  background: #f1f5f9;
  color: #94a3b8;
}

/* Air Quality Section - Clean & Non-Cluttered */
.cockpit-sensor-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

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

.sensor-section-title {
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-2);
  letter-spacing: 0.04em;
}

.aqi-compact-tag {
  padding: 1px 7px;
  border-radius: 12px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 800;
  border: 1px solid currentColor;
}

/* 4x2 Clean Grid */
.sensors-compact-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.sensor-chip {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 5px;
  display: flex;
  flex-direction: column;
}

.chip-lbl {
  font-size: 8.5px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  line-height: 1;
  margin-bottom: 2px;
}

.chip-val-row {
  display: flex;
  align-items: baseline;
  gap: 2px;
}

.chip-val {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
}

.chip-unit {
  font-size: 8px;
  color: var(--text-3);
  font-weight: 600;
}

/* Holding Bar: Thin & Snug */
.holding-bar-wrap {
  display: none;
  background: var(--warn-bg);
  border: 1px solid rgba(178, 94, 0, 0.3);
  border-radius: 4px;
  padding: 4px 6px;
}

.holding-bar-wrap.active {
  display: block;
}

.holding-bar-header {
  display: flex;
  justify-content: space-between;
  font-size: 9.5px;
  font-weight: 700;
  color: var(--warn);
  margin-bottom: 3px;
}

.holding-bar-line {
  height: 4px;
  background: rgba(178, 94, 0, 0.2);
  border-radius: 2px;
  overflow: hidden;
}

.holding-bar-fill {
  height: 100%;
  background: var(--warn);
  width: 0%;
  transition: width 0.3s ease;
}

/* Tabs for Waypoint & Data Log */
.cockpit-tabs-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 160px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.tabs-header {
  display: flex;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

.tab-btn {
  flex: 1;
  height: 28px;
  border: none;
  background: transparent;
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--surface);
  font-weight: 800;
}

.tab-content {
  flex: 1;
  padding: 6px;
  overflow-y: auto;
  display: none;
}

.tab-content.active {
  display: block;
}

/* Waypoint List Items */
.wp-compact-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.wp-compact-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 10.5px;
}

.wp-compact-item.current-target {
  background: var(--warn-bg);
  border-color: rgba(178, 94, 0, 0.4);
  font-weight: 700;
}

.wp-compact-item.visited {
  background: var(--ok-bg);
  border-color: rgba(21, 122, 58, 0.3);
  color: var(--ok);
}

.wp-del-btn {
  border: none;
  background: none;
  color: var(--danger);
  font-weight: 800;
  cursor: pointer;
  padding: 0 4px;
  font-size: 13px;
}

/* ── 10. Air Quality Analytics View (dashboard.html) ─────────────────── */
.analytics-viewport {
  flex: 1;
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.charts-row-2col {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.chart-cockpit-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow-sm);
}

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

.chart-header h3 {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-2);
  letter-spacing: 0.04em;
}

.chart-canvas-box {
  height: 220px;
  position: relative;
}

/* ── 11. Stream / Camera Full View (stream.html) ──────────────────────── */
.stream-layout {
  flex: 1;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 14px;
  padding: 14px;
  overflow: hidden;
  background: var(--bg);
}

.video-container {
  display: flex;
  flex-direction: column;
  background: #0f141d;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.video-wrapper {
  flex: 1;
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.video-controls {
  padding: 10px 14px;
  background: #141b27;
  border-top: 1px solid #233149;
  display: flex;
  gap: 8px;
  align-items: center;
}

.stream-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

/* ── 12. Dashboard & Telemetry Container (dashboard.html) ──────────────── */
.telemetry-container {
  flex: 1;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--bg);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}

.card-label {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-2);
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary-hover); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-hover); border-color: var(--line-strong); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warn { background: var(--warn); color: #fff; }
.btn-sm { padding: 4px 8px; font-size: 10px; }

/* ── 13. Utility & Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--surface-2);
}
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-3);
}