/* ─────────────────────────────────────────────────────────────────────────────
   PX4 GCS (Ground Control Station) - Pixel-Perfect Tactical Restored (Phase 16 - V2)
   ───────────────────────────────────────────────────────────────────────────── */

:root {
  --bg-dark: #050a14;
  --bg-card: rgba(10, 20, 38, 0.7);
  --bg-hover: rgba(56, 189, 248, 0.1);
  --border: rgba(255, 255, 255, 0.1);
  --glass-bg: rgba(15, 23, 42, 0.85);
  --text-main: #f8fafc;
  --text-dim: #a1a1aa;
  --accent-blue: #00aaff;
  --accent-cyan: #00e5ff;
  --accent-green: #00ff88;
  --accent-yellow: #fbbf24;
  --accent-red: #ff4d4d;
  --accent-purple: #a78bfa;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  height: 100vh; width: 100vw; overflow: hidden;
}

/* ─── Topbar ─── */
.topbar {
  height: 78px;
  background: #0a1426;
  border-bottom: 1.5px solid #001f3f;
  display: flex;
  flex-direction: column;
  z-index: 1000;
}

.topbar-row-upper, .topbar-row-lower {
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 8px;
}

.topbar-row-upper {
  height: 44px;
  border-bottom: 1px solid #001f3f;
  justify-content: space-between;
}

.topbar-row-lower {
  height: 34px;
  background: rgba(0, 0, 0, 0.2);
  justify-content: space-between;
  overflow: hidden;
}

/* Branding */
.topbar-brand { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.brand-icon {
  width: 30px; height: 30px;
  background: #00aaff;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: #fff;
}
.brand-name { font-weight: 900; font-size: 17px; color: #fff; letter-spacing: 0.2px; line-height: 1; }
.brand-sub { font-size: 8px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1.5px; opacity: 0.6; display: block; margin-top: 2px; }

/* Navigation */
.nav-group { display: flex; gap: 2px; align-items: center; flex-wrap: nowrap; }
.nav-btn {
  background: transparent; border: none; padding: 6px 12px; border-radius: 5px;
  color: var(--text-dim); cursor: pointer; font-weight: 700; font-size: 12px;
  display: flex; align-items: center; gap: 7px; transition: all 0.2s;
  white-space: nowrap; flex-shrink: 0;
}

#primary-nav .nav-btn.active {
  background: #00aaff;
  color: #fff;
  box-shadow: 0 2px 10px rgba(0, 170, 255, 0.3);
}

#secondary-nav .nav-btn.active {
  color: #00aaff;
  background: rgba(0, 170, 255, 0.05);
}

.nav-btn .badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-red); color: #fff; font-size: 9px; font-weight: 800;
  min-width: 16px; height: 16px; border-radius: 8px; padding: 0 4px;
  line-height: 1;
}

/* ─── Compact v3.0 Nav Buttons ─── */
.nav-btn-compact {
  padding: 4px 8px !important;
  font-size: 11px !important;
  gap: 4px !important;
  opacity: 0.8;
}
.nav-btn-compact:hover { opacity: 1; }
.nav-btn-compact.active { opacity: 1; }

.nav-v3-divider {
  width: 1px; height: 16px;
  background: rgba(255,255,255,0.12);
  margin: 0 3px; flex-shrink: 0;
}

.nav-btn-text {
  background: transparent; border: none; color: var(--text-dim);
  font-size: 11px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: color 0.2s;
}
.nav-btn-text:hover { color: #00aaff; }


/* Header Metrics */
.header-metrics { display: flex; align-items: center; gap: 12px; }
.metric-chip { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; color: #fff; white-space: nowrap; }
.metric-icon-blue { color: #00aaff; }
.metric-icon-green { color: #00ff88; }
.metric-clock { font-family: 'JetBrains Mono', monospace; font-size: 14px; color: #00aaff; letter-spacing: 0.5px; }

/* Status chips */
.status-chip {
  display: flex !important; align-items: center !important; gap: 5px !important;
  padding: 3px 8px !important; border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px; color: #9ca3af; font-weight: 700; font-size: 11px;
  white-space: nowrap !important; flex-shrink: 0 !important;
}
.status-chip.disconnected { color:#ff4d4d; border-color: rgba(255,77,77,0.4); }
.dot { width:7px; height:7px; border-radius:50%; display:inline-block; }
.dot-green { background: var(--accent-green); }
.dot-yellow { background: var(--accent-yellow); }
.dot-red { background: var(--accent-red); }

/* ─── Title Bar (Tier 3) ─── */
.title-bar {
  height: 34px;
  background: #081221;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
}


/* ─── Main Content ─── */
.main-content { display: flex; height: calc(100vh - 78px - 34px); overflow: hidden; }

/* Sidebar */
.sidebar { width: 210px; background: #050a14; border-right: 1.5px solid #0d1b33; display: flex; flex-direction: column; padding-bottom: 12px; overflow-y: auto; }
.sidebar-title { padding: 14px 14px 8px; font-size: 10px; font-weight: 800; color: #4b5563; text-transform: uppercase; letter-spacing: 2px; display: flex; justify-content: space-between; align-items: center; }
.sidebar-section { padding: 12px 14px; border-bottom: 1px solid rgba(255,255,255,0.03); }
.sidebar-label { font-size: 10px; font-weight: 800; color: #4b5563; text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 10px; }

.quick-cmds { display: flex; flex-direction: column; gap: 6px; }
.qcmd {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-radius: 8px; border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04); color: var(--text-dim);
  font-size: 12px; font-weight: 700; cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  width: 100%; text-align: left;
}
.qcmd:hover { background: rgba(255,255,255,0.08); }
.qcmd-green { color: var(--accent-green); border-color: rgba(74,222,128,.25); }
.qcmd-green:hover { background: rgba(74,222,128,.1); }
.qcmd-yellow { color: var(--accent-yellow); border-color: rgba(251,191,36,.25); }
.qcmd-yellow:hover { background: rgba(251,191,36,.1); }
.qcmd-red { color: var(--accent-red); border-color: rgba(239,68,68,.25); }
.qcmd-red:hover { background: rgba(239,68,68,.1); }

.sys-stats { display: flex; flex-direction: column; gap: 6px; }
.sys-stat-row { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--text-dim); }
.sys-stat-row span:last-child { font-weight: 700; font-family: 'JetBrains Mono', monospace; }

.drone-list { flex: 1; overflow-y: auto; min-height: 100px; display: block !important; }
.drone-item {
  padding: 9px 14px; display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; border-left: 3px solid transparent; transition: all 0.2s;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.drone-item:hover { background: rgba(0, 170, 255, 0.05); }
.drone-item.active { background: rgba(0, 170, 255, 0.1); border-left-color: #00aaff; }

.drone-info { flex: 1; min-width: 0; }
.drone-name { font-weight: 800; color: #fff; font-size: 13px; margin-bottom: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drone-meta { font-size: 10px; color: #9ca3af; }

.drone-bat-box { text-align: right; flex-shrink: 0; margin-left: 6px; }
.drone-bat { font-weight: 900; font-size: 12px; color: #00ff88; }

/* ─── Dashboard ─── */
.view-area { flex: 1; overflow-y: auto; background: #000; padding: 0; }
#view-dashboard { padding: 12px 14px; }
#view-map, #view-video, #view-sitl, #view-alerts, #view-analysis, #view-pos,
#view-mission, #view-formation, #view-logs, #view-audit, #view-battery,
#view-cop, #view-aar, #view-sandbox { padding: 16px; }
.view-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.view-header h2 { font-size: 16px; font-weight: 800; color: #fff; display: flex; align-items: center; gap: 10px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  margin-bottom: 25px;
}
/* ── old kpi styles overridden by dashboard section below ── */

/* ── overridden below ── */

/* ─── AI FAB Button ─── */
#ai-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 4999;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: linear-gradient(135deg, #6d28d9, #7c3aed);
  color: #fff;
  border: none;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(109,40,217,0.5), 0 0 0 1px rgba(167,139,250,0.3);
  transition: all 0.2s;
  letter-spacing: 0.3px;
}
#ai-fab:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(109,40,217,0.6); }
#ai-fab:active { transform: scale(0.96); }
#ai-fab i { font-size: 15px; }

/* ─── AI Assistant Popup ─── */
.ai-assistant-popup {
  position: fixed;
  bottom: 88px;
  right: 28px;
  width: 400px;
  height: 540px;
  background: rgba(8, 18, 38, 0.98); border-radius: 14px;
  box-shadow: 0 24px 80px rgba(0,0,0,.95), 0 0 0 1px rgba(167,139,250,0.3);
  z-index: 5000; display: flex; flex-direction: column; overflow: hidden;
  transform: translateY(12px) scale(0.97); opacity: 0; pointer-events: none;
  transition: all 0.22s cubic-bezier(0.34,1.56,0.64,1);
  transform-origin: bottom right;
}
.ai-assistant-popup.open { transform: translateY(0) scale(1); opacity: 1; pointer-events: all; }
.ai-popup-header { background: linear-gradient(135deg, #6d28d9, #7c3aed); padding: 13px 18px; color: #fff; font-weight: 900; display: flex; justify-content: space-between; align-items: center; letter-spacing: 0.5px; font-size: 13px; }

.ai-popup-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.ai-popup-body::-webkit-scrollbar { width: 3px; }
.ai-popup-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius:2px; }
.ai-popup-input { padding: 10px 12px; background: rgba(0,0,0,0.3); display: flex; gap: 10px; align-items: center; border-top: 1px solid rgba(255,255,255,0.06); }
.ai-popup-input input { flex: 1; background: transparent; border: none; font-size: 13px; color: #fff; outline: none; }
.ai-popup-input input::placeholder { color: rgba(255,255,255,0.25); }
.chat-bubble { padding: 12px 16px; border-radius: 12px; font-size: 14px; line-height: 1.5; max-width: 85%; }
.bubble-ai { background: #16243d; color: #fff; align-self: flex-start; }
.bubble-user { background: #00aaff; color: #fff; align-self: flex-end; }

.ai-popup-input { padding: 15px; background: #050a14; display: flex; gap: 10px; align-items: center; border-top: 1px solid rgba(255,255,255,0.03); }
.ai-popup-input input { flex: 1; background: transparent; border: none; font-size: 14px; color: #fff; outline: none; }
.ai-send-btn { color: #00aaff; font-size: 22px; cursor: pointer; transition: transform 0.2s; }
.ai-send-btn:hover { transform: scale(1.1); }

/* ─── AI Command blocks ─── */
.ai-cmd-block { background:rgba(0,0,0,0.35); border:1px solid var(--border); border-radius:8px; padding:10px 12px; margin:6px 0; font-size:11px; }
.ai-cmd-confirm { border-color:rgba(239,68,68,0.5)!important; background:rgba(239,68,68,0.05)!important; }
.ai-cmd-header { font-size:10px; font-weight:800; text-transform:uppercase; letter-spacing:.8px; color:var(--text-dim); margin-bottom:8px; }
.ai-cmd-item { display:flex; align-items:center; gap:8px; padding:4px 0; border-bottom:1px solid rgba(255,255,255,0.04); }
.ai-cmd-item:last-child { border-bottom:none; }
.ai-cmd-drone { background:rgba(0,170,255,0.12); color:var(--accent-blue); padding:1px 6px; border-radius:4px; font-size:10px; font-weight:800; white-space:nowrap; }
.ai-cmd-name  { color:var(--accent-green); font-weight:800; font-size:10px; white-space:nowrap; }
.ai-cmd-desc  { color:var(--text-dim); flex:1; font-size:10px; }
@keyframes ai-dot { 0%,100%{opacity:.2} 50%{opacity:1} }
.ai-dot-anim { display:inline-block; animation:ai-dot 1s infinite; font-size:10px; }

/* ─── Mission Planning ─── */
#view-mission { overflow: hidden; }
.mission-layout { display:grid; grid-template-columns:1fr 300px; gap:10px; flex:1; min-height:0; }
.mission-map-area, .mission-list-area { display:flex; flex-direction:column; min-height:0; }
.mission-map-area > .card { flex:1; display:flex; flex-direction:column; padding-bottom:0; min-height:0; }
.mission-list-area > .card { flex:1; display:flex; flex-direction:column; min-height:0; overflow:hidden; }
#mission-plan-map { flex:1; border-radius:8px; overflow:hidden; background:#0a1a2e; }
.mission-list { flex:1; overflow-y:auto; display:flex; flex-direction:column; gap:6px; padding:4px 0; }
.mission-wp-item { display:flex; align-items:center; gap:8px; padding:7px 10px; background:rgba(255,255,255,0.04); border:1px solid var(--border); border-radius:7px; font-size:11px; }
.mission-wp-num  { width:20px; height:20px; border-radius:50%; background:var(--accent-blue); color:#fff; font-size:10px; font-weight:800; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.mission-wp-info { flex:1; }
.mission-wp-lat  { font-size:10px; color:var(--text-dim); font-family:monospace; }
.mission-wp-del  { background:transparent; border:none; color:var(--accent-red); cursor:pointer; font-size:14px; padding:2px 6px; }
.mission-wp-del:hover { color:#ff0000; }
.mission-actions { display:flex; gap:8px; margin-top:10px; flex-wrap:wrap; }

/* View Switching */
.view { display: none; transition: opacity 0.3s; }
.view.active { display: block !important; opacity: 1; }

/* Views that need flex-column + full height */
#view-map.active, #view-video.active, #view-sitl.active,
#view-alerts.active, #view-analysis.active, #view-pos.active,
#view-mission.active, #view-formation.active, #view-logs.active,
#view-audit.active, #view-battery.active, #view-cop.active,
#view-aar.active, #view-sandbox.active {
  display: flex !important;
  flex-direction: column;
  height: 100%;
}

/* 新視圖：直接用 display:block，內部自帶 overflow-y:auto */
#view-sar.active, #view-notifications.active,
#view-ais.active, #view-webhooks.active {
  display: block !important;
  height: 100%;
  overflow-y: auto;
}

/* ═══════════════════════════════════════════════════════════
   PX4 GCS v3.0 — New Feature Styles
   ═══════════════════════════════════════════════════════════ */

/* ─── Sandbox Banner (4.7) ─── */
.sandbox-banner {
  display: none;
  position: fixed; top: 104px; left: 0; right: 0;
  background: linear-gradient(90deg, #ff6a00, #ee0979);
  color: #fff; font-weight: 900; font-size: 13px; letter-spacing: 1.5px;
  text-align: center; padding: 6px 20px; z-index: 2000;
  text-transform: uppercase; animation: pulse-banner 2s infinite;
}
.sandbox-banner.active { display: block; }
@keyframes pulse-banner {
  0%, 100% { opacity: 1; } 50% { opacity: 0.7; }
}

/* ─── GPS Threat Banner (overridden in dashboard section) ─── */
@keyframes flash-threat {
  0%, 100% { border-color: rgba(255,60,60,0.5); }
  50% { border-color: rgba(255,60,60,1); box-shadow: 0 0 15px rgba(255,60,60,0.3); }
}

/* ─── GPS Threat List Items ─── */
.threat-item {
  background: rgba(255,60,60,0.08);
  border-left: 3px solid var(--accent-red);
  border-radius: 4px; padding: 8px 12px;
  margin-bottom: 6px; font-size: 13px;
}
.threat-item h4 { color: var(--accent-red); font-size: 12px; margin-bottom: 3px; }

/* ─── Encryption Lock Icons (4.2) ─── */
.lock-green  { color: var(--accent-green);  }
.lock-yellow { color: var(--accent-yellow); }
.lock-red    { color: var(--accent-red);    }
.enc-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 700; padding: 2px 7px;
  border-radius: 4px; margin-left: 6px;
}
.enc-badge.green  { background: rgba(0,255,136,0.12); color: var(--accent-green); }
.enc-badge.yellow { background: rgba(251,191,36,0.12); color: var(--accent-yellow); }
.enc-badge.red    { background: rgba(255,77,77,0.12); color: var(--accent-red); }

/* ─── Raft Cluster Status Bar (4.10) ─── */
.raft-status-bar {
  display: flex; align-items: center; gap: 12px;
  background: rgba(0,170,255,0.06);
  border: 1px solid rgba(0,170,255,0.15);
  border-radius: 8px; padding: 8px 16px; margin-bottom: 15px;
  font-size: 12px; font-weight: 700;
}
.raft-role-leader { color: var(--accent-green); }
.raft-role-follower { color: var(--accent-yellow); }
.raft-role-candidate { color: var(--accent-red); animation: pulse-banner 1s infinite; }
.raft-token {
  margin-left: auto; font-family: 'JetBrains Mono', monospace;
  font-size: 11px; color: var(--text-dim);
}

/* ─── Audit Chain View (4.4) ─── */
.audit-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.audit-table th { background: #0d1b33; color: var(--text-dim); padding: 8px 12px; text-align: left; font-size: 11px; }
.audit-table td { padding: 8px 12px; border-bottom: 1px solid rgba(255,255,255,0.04); }
.audit-table tr:hover td { background: rgba(0,170,255,0.04); }
.hash-mono { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--text-dim); }
.verify-result {
  padding: 12px 16px; border-radius: 8px; font-weight: 700; margin-top: 12px;
}
.verify-result.valid { background: rgba(0,255,136,0.1); color: var(--accent-green); border: 1px solid rgba(0,255,136,0.3); }
.verify-result.invalid { background: rgba(255,77,77,0.1); color: var(--accent-red); border: 1px solid rgba(255,77,77,0.3); }

/* ─── Battery Scheduler View (4.6) ─── */
.battery-scheduler { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.battery-list { display: flex; flex-direction: column; gap: 8px; }
.battery-item {
  background: #0a1426; border-radius: 8px; padding: 14px 16px;
  border: 1px solid rgba(255,255,255,0.06);
  display: flex; justify-content: space-between; align-items: center;
}
.battery-soh { font-weight: 900; font-size: 22px; }
.soh-good { color: var(--accent-green); }
.soh-warn { color: var(--accent-yellow); }
.soh-crit { color: var(--accent-red); }

.soc-bar-wrap { width: 100%; height: 6px; background: rgba(255,255,255,0.05); border-radius: 3px; margin-top: 6px; }
.soc-bar { height: 100%; border-radius: 3px; transition: width 0.5s; }
.soc-high { background: var(--accent-green); }
.soc-mid  { background: var(--accent-yellow); }
.soc-low  { background: var(--accent-red); }

.charging-stations { display: flex; flex-direction: column; gap: 8px; }
.station-card {
  background: #0a1426; border-radius: 8px; padding: 12px 16px;
  border-left: 3px solid var(--accent-blue);
  display: flex; justify-content: space-between; align-items: center;
}
.station-slots { font-size: 20px; font-weight: 900; color: var(--accent-cyan); }

/* ─── COP View (4.8) ─── */
.cop-map-overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none; z-index: 500;
}
.cop-object {
  background: rgba(0,229,255,0.1); border: 2px dashed var(--accent-cyan);
  border-radius: 50%; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
}
.cop-friendly { border-color: var(--accent-cyan); color: var(--accent-cyan); }
.cop-hostile  { border-color: var(--accent-red); color: var(--accent-red); border-style: solid; }
.cop-object-list { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow-y: auto; }
.cop-obj-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: rgba(255,255,255,0.02);
  border-radius: 6px; font-size: 12px;
}
.cop-obj-type { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 3px; }
.cop-node-list { display: flex; gap: 10px; flex-wrap: wrap; }
.cop-node {
  display: flex; align-items: center; gap: 6px; padding: 6px 12px;
  background: rgba(0,170,255,0.08); border-radius: 6px; font-size: 12px;
}
.cop-node.online { border-left: 3px solid var(--accent-green); }
.cop-node.offline { border-left: 3px solid var(--accent-red); opacity: 0.5; }

/* ─── Formation Control View ─── */
.shape-selector-grid {
  display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px;
}
.shape-card {
  display: flex; flex-direction: column; align-items: center;
  background: var(--bg-card); border: 1.5px solid var(--border);
  border-radius: 10px; padding: 10px 14px; cursor: pointer;
  transition: border-color 0.2s, background 0.2s; min-width: 70px;
}
.shape-card:hover { border-color: var(--accent-blue); background: rgba(56,189,248,.06); }
.shape-card.selected { border-color: var(--accent-cyan); background: rgba(34,211,238,.08); }
.shape-label { font-size: 11px; color: var(--text-dim); margin-top: 4px; font-weight: 600; }

.formation-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 16px; margin-bottom: 10px;
  transition: border-color 0.2s;
}
.formation-card.formation-active { border-color: var(--accent-green); }
.formation-card-header {
  display: flex; align-items: center; gap: 12px;
}
.formation-shape-badge {
  font-size: 22px; width: 36px; height: 36px; display: flex;
  align-items: center; justify-content: center;
  background: rgba(56,189,248,.1); border-radius: 8px;
}
.formation-info { flex: 1; }
.formation-name { font-weight: 800; font-size: 14px; }
.formation-meta { font-size: 11px; color: var(--text-dim); margin-top: 2px; display: flex; gap: 8px; }
.formation-card-actions { display: flex; gap: 6px; }
.formation-drones { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.formation-drone-tag {
  font-size: 11px; padding: 2px 8px; border-radius: 20px;
  background: rgba(255,255,255,.05); border: 1px solid var(--border);
  font-weight: 600;
}
.formation-drone-tag.tag-leader { background: rgba(56,189,248,.12); border-color: var(--accent-cyan); color: var(--accent-cyan); }
.text-green { color: var(--accent-green); }
.text-muted { color: var(--text-dim); }

.drone-check-grid {
  display: flex; flex-direction: column; gap: 4px;
  max-height: 200px; overflow-y: auto; margin-top: 8px;
}
.drone-check-label {
  display: flex; align-items: center; gap: 8px; padding: 8px;
  border-radius: 8px; cursor: pointer; transition: background 0.15s;
}
.drone-check-label:hover { background: rgba(255,255,255,.04); }
.drone-check-label input[type="checkbox"] { accent-color: var(--accent-cyan); width: 15px; height: 15px; }
.drone-check-name { font-weight: 700; font-size: 13px; }
.drone-check-meta { font-size: 11px; color: var(--text-dim); margin-left: auto; }

/* ─── AAR Replay View (4.9) ─── */
.aar-player {
  background: #0a1426; border-radius: 10px; padding: 16px;
  border: 1px solid rgba(255,255,255,0.06);
}
.aar-timeline {
  width: 100%; height: 8px; border-radius: 4px;
  background: rgba(255,255,255,0.05); position: relative; cursor: pointer;
  margin: 12px 0;
}
.aar-timeline-fill {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
  transition: width 0.1s; pointer-events: none;
}
.aar-timeline-input {
  position: absolute; top: -4px; left: 0; right: 0;
  width: 100%; opacity: 0; cursor: pointer; height: 16px;
}
.aar-controls {
  display: flex; align-items: center; gap: 10px; margin-top: 12px;
  justify-content: center;
}
.aar-btn {
  background: rgba(0,170,255,0.1); border: 1px solid rgba(0,170,255,0.3);
  color: var(--accent-blue); border-radius: 6px; padding: 8px 16px;
  cursor: pointer; font-weight: 700; font-size: 13px; transition: all 0.2s;
}
.aar-btn:hover { background: rgba(0,170,255,0.2); }
.aar-btn.active { background: var(--accent-blue); color: #fff; }
.aar-speed {
  display: flex; gap: 6px; align-items: center;
}
.aar-speed-btn {
  background: transparent; border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-dim); border-radius: 4px; padding: 4px 10px;
  cursor: pointer; font-size: 12px; font-weight: 700; transition: all 0.2s;
}
.aar-speed-btn.active { background: var(--accent-purple); color: #fff; border-color: var(--accent-purple); }

.aar-timeline-markers { position: relative; height: 20px; }
.aar-marker {
  position: absolute; top: 2px;
  width: 2px; height: 16px;
  cursor: pointer;
}
.aar-marker.warning { background: var(--accent-yellow); }
.aar-marker.critical { background: var(--accent-red); }
.aar-marker.info { background: var(--accent-blue); }

.aar-event-list { max-height: 200px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.aar-event-item {
  display: flex; gap: 10px; align-items: center;
  padding: 6px 10px; border-radius: 4px; font-size: 12px;
  cursor: pointer;
}
.aar-event-item:hover { background: rgba(255,255,255,0.04); }
.aar-event-time { font-family: 'JetBrains Mono', monospace; color: var(--text-dim); min-width: 60px; }
.aar-session-list { display: flex; flex-direction: column; gap: 8px; }
.aar-session-item {
  background: #0a1426; border-radius: 8px; padding: 12px 16px;
  display: flex; justify-content: space-between; align-items: center;
  border: 1px solid rgba(255,255,255,0.06); cursor: pointer; transition: border-color 0.2s;
}
.aar-session-item:hover { border-color: rgba(0,170,255,0.3); }

/* ─── Motor Health Gauges (4.12) ─── */
.motor-health-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.motor-health-gauge {
  background: #0a1426; border-radius: 10px; padding: 14px;
  border: 1px solid rgba(255,255,255,0.06); text-align: center;
}
.mhg-label { font-size: 11px; color: var(--text-dim); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 1px; }
.mhg-value-wrap { position: relative; display: inline-block; }
.mhg-value { font-size: 28px; font-weight: 900; }
.mhg-pct { font-size: 13px; color: var(--text-dim); }
.mhg-bar { width: 100%; height: 5px; background: rgba(255,255,255,0.05); border-radius: 3px; margin-top: 8px; }
.mhg-fill { height: 100%; border-radius: 3px; transition: width 0.5s; }
.mhg-trend { font-size: 11px; margin-top: 6px; }
.trend-stable   { color: var(--accent-green); }
.trend-degrading { color: var(--accent-red); animation: pulse-banner 1.5s infinite; }

/* ─── V3 Panels General ─── */
.v3-panel {
  height: 100%; overflow-y: auto; padding: 20px;
  display: flex; flex-direction: column; gap: 16px;
}
.v3-section {
  background: #0a1426; border-radius: 10px; padding: 20px;
  border: 1px solid rgba(255,255,255,0.06);
}
.v3-section-title {
  font-size: 13px; font-weight: 800; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 14px;
  display: flex; justify-content: space-between; align-items: center;
}
.v3-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.v3-3col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* ─── Mini Stat Cards ─── */
.mini-stat { background: rgba(0,170,255,0.06); border-radius: 8px; padding: 12px 16px; }
.mini-stat-lbl { font-size: 11px; color: var(--text-dim); margin-bottom: 4px; }
.mini-stat-val { font-size: 24px; font-weight: 900; color: #fff; }

/* ─── Scenario Panel (Sandbox) ─── */
.scenario-list { display: flex; flex-direction: column; gap: 8px; }
.scenario-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: rgba(255,255,255,0.02);
  border-radius: 6px; border: 1px solid rgba(255,255,255,0.05);
}
.scenario-item:hover { border-color: rgba(255,165,0,0.3); background: rgba(255,165,0,0.05); }
.scenario-name { font-weight: 700; font-size: 13px; }
.scenario-desc { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.feasibility-score {
  font-size: 36px; font-weight: 900;
  background: linear-gradient(135deg, var(--accent-green), var(--accent-cyan));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}

/* ─── AI Model Router (4.11) ─── */
.ai-router-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.model-card {
  background: rgba(255,255,255,0.02); border-radius: 8px; padding: 12px;
  border: 1px solid rgba(255,255,255,0.06); cursor: pointer; transition: all 0.2s;
}
.model-card:hover { border-color: rgba(0,170,255,0.3); background: rgba(0,170,255,0.05); }
.model-card.active { border-color: var(--accent-blue); background: rgba(0,170,255,0.1); }
.model-name { font-weight: 800; font-size: 14px; margin-bottom: 4px; }
.model-status { font-size: 11px; color: var(--text-dim); }

/* ─── Side Panels (V3 Unified) ─── */
.side-panel-right {
  position: fixed; top: 120px; right: -420px; width: 400px; height: calc(100vh - 150px);
  background: var(--glass-bg); backdrop-filter: blur(12px); border-radius: 12px 0 0 12px;
  border-left: 1.5px solid var(--accent-blue); box-shadow: -20px 0 60px rgba(0,0,0,0.5);
  z-index: 4000; transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex; flex-direction: column; overflow: hidden;
}
.side-panel-right.active { right: 0; }
.side-panel-right.open { right: 0; }

.panel-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: rgba(0, 170, 255, 0.1); }
.panel-header h3 { font-size: 16px; font-weight: 800; color: #fff; margin: 0; display: flex; align-items: center; gap: 10px; }
.panel-body { flex: 1; overflow-y: auto; padding: 20px; }

.insight-section { margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.insight-section h4 { font-size: 13px; font-weight: 800; color: var(--accent-cyan); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 12px; }
.insight-meta { font-size: 11px; color: var(--text-dim); margin-top: 8px; line-height: 1.4; }

.accuracy-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.acc-item { background: rgba(255,255,255,0.03); padding: 12px; border-radius: 8px; text-align: center; }
.acc-lbl { font-size: 10px; color: var(--text-dim); text-transform: uppercase; display: block; margin-bottom: 4px; }
.acc-val { font-size: 18px; font-weight: 900; color: #fff; }

.btn-icon { background: transparent; border: none; color: var(--text-dim); cursor: pointer; font-size: 18px; transition: color 0.2s; }
.btn-icon:hover { color: #fff; }

/* ─── Map Container & Legend (Patched) ─── */
.map-container {
  flex: 1;
  position: relative;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.map-legend {
  position: absolute;
  bottom: 25px;
  left: 25px;
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.map-toolbar {
  background: var(--glass-bg) !important;
  border: 1px solid var(--border) !important;
  border-radius: 6px !important;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.map-toolbar button {
  background: transparent !important;
  border: none !important;
  border-bottom: 1px solid var(--border) !important;
  color: var(--text-main) !important;
  width: 34px !important;
  height: 34px !important;
  cursor: pointer;
  font-size: 14px !important;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}

.map-toolbar button:last-child { border-bottom: none !important; }
.map-toolbar button:hover { background: var(--bg-hover) !important; }

/* ── Drone Marker (B-upgrade) ───────────────────────────────────────────── */
@keyframes drone-pulse {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.45; }
}

.dmw {
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.55));
}
.dmw svg { pointer-events: all; cursor: pointer; }

.dmw-alert svg {
  animation: drone-pulse 1.1s ease-in-out infinite;
}

.dmw-sel svg {
  filter: drop-shadow(0 0 8px rgba(56,189,248,.7));
}

/* Battery bar */
.dmw-bat {
  display: flex;
  gap: 2px;
  width: 21px;
  height: 5px;
  margin: 1px auto 0;
}
.dmw-bat > div {
  flex: 1;
  border-radius: 1.5px;
  transition: background 0.4s;
}

/* Floating label */
.dmw-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 3px;
  background: rgba(10,14,20,.75);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 5px;
  padding: 2px 7px 3px;
  white-space: nowrap;
  pointer-events: none;
  line-height: 1.3;
}
.dmw-label-sel {
  border-color: rgba(56,189,248,.4);
  background: rgba(10,20,30,.82);
}
.dmw-name {
  font-size: 10px;
  font-weight: 700;
  color: #e2e8f0;
  letter-spacing: 0.4px;
}
.dmw-stats {
  font-size: 9px;
  color: #94a3b8;
  font-family: 'JetBrains Mono', monospace;
}

.map-context-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px;
}

.map-context-menu button {
  background: var(--accent-blue);
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.map-context-menu button:hover {
  background: #0088cc;
}

/* ─── Stream Status Bar ─── */
.stream-status-bar {
  padding: 8px 16px;
  background: rgba(0, 170, 255, 0.06);
  border-bottom: 1px solid rgba(0, 170, 255, 0.15);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.stream-info { font-size: 12px; color: var(--text-dim); line-height: 1.5; }
.stream-info strong { color: var(--accent-blue); }
.stream-info code { background: rgba(0,0,0,0.4); padding: 1px 6px; border-radius: 4px; font-size: 11px; color: var(--accent-cyan); }

/* ─── Video Wall Grid Layouts ─── */
.video-wall {
  display: grid;
  gap: 10px;
  padding: 12px;
  grid-template-columns: repeat(2, 1fr);
  align-content: start;
  flex: 1;
  overflow-y: auto;
}

.video-wall.grid-1 { grid-template-columns: 1fr; }
.video-wall.grid-4 { grid-template-columns: repeat(2, 1fr); }
.video-wall.grid-9 { grid-template-columns: repeat(3, 1fr); }

.grid-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 5px 10px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  transition: all 0.15s;
}
.grid-btn:hover { border-color: var(--accent-blue); color: var(--accent-blue); }
.grid-btn.active {
  background: var(--accent-blue) !important;
  color: #fff !important;
  border-color: var(--accent-blue) !important;
}

/* ─── Video Cell ─── */
.video-cell {
  position: relative;
  background: #060c1a;
  border-radius: 10px;
  overflow: hidden;
  /* 用 padding-top 強制 16:9，避免 flex/grid 高度塌陷問題 */
  padding-top: 56.25%;
  border: 1.5px solid rgba(255, 255, 255, 0.07);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.video-cell:hover { border-color: rgba(0, 170, 255, 0.35); box-shadow: 0 0 0 1px rgba(0, 170, 255, 0.12); }
.video-cell.active { border-color: var(--accent-blue); box-shadow: 0 0 0 2px rgba(0, 170, 255, 0.2), 0 0 20px rgba(0, 170, 255, 0.08); }

.video-el {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  position: absolute;
  top: 0; left: 0;
  z-index: 1;
}

.ai-overlay-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 2;
}
/* Enable canvas clicks when AI tracking is active */
.video-wall.ai-tracking-active .ai-overlay-canvas {
  pointer-events: auto;
  cursor: crosshair;
}

.video-connect-btn {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 170, 255, 0.12);
  border: 1px solid rgba(0, 170, 255, 0.5);
  color: var(--accent-blue);
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  backdrop-filter: blur(4px);
  z-index: 3;
  white-space: nowrap;
}
.video-connect-btn:hover {
  background: rgba(0, 170, 255, 0.28);
  box-shadow: 0 0 20px rgba(0, 170, 255, 0.25);
}

.video-placeholder {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  gap: 8px;
  padding: 16px;
  z-index: 1;
}
.video-placeholder i { font-size: 28px; opacity: 0.2; }
.video-placeholder span { opacity: 0.4; font-weight: 600; font-size: 13px; }

.video-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 10px 12px 8px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.88) 0%, rgba(0, 0, 0, 0.3) 60%, transparent 100%);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  pointer-events: none;
  z-index: 4;
}

.video-drone-name {
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
  letter-spacing: 0.2px;
}
.video-drone-meta {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.55);
  margin-top: 2px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

.video-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.video-bat {
  font-size: 11px;
  font-weight: 900;
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.6);
  letter-spacing: 0.3px;
}
.bat-ok  { color: var(--accent-green); }
.bat-warn { color: var(--accent-yellow); }
.bat-crit { color: var(--accent-red); animation: pulse-bat 0.9s infinite; }
@keyframes pulse-bat { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.stream-state-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.55);
  padding: 2px 7px;
  border-radius: 5px;
}
.stream-state-icon { display: flex; align-items: center; font-size: 9px; }
.stream-state-label { font-size: 9px; font-weight: 800; letter-spacing: 0.3px; }
.text-green  { color: var(--accent-green) !important; }
.text-yellow { color: var(--accent-yellow) !important; }
.text-muted  { color: var(--text-dim) !important; }
.text-blue   { color: var(--accent-blue) !important; }
.text-red    { color: var(--accent-red) !important; }

.video-rec-indicator {
  position: absolute;
  top: 10px; right: 10px;
  background: rgba(220, 38, 38, 0.92);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  padding: 3px 9px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  gap: 5px;
  letter-spacing: 0.8px;
  z-index: 5;
  box-shadow: 0 0 12px rgba(220, 38, 38, 0.5);
}
.rec-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #fff;
  animation: blink-rec 0.9s infinite;
}
@keyframes blink-rec { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* ─── HUD / Pilot Mode ─── */
.video-wall.pilot-mode { gap: 4px; padding: 6px; background: #000; }
.video-wall.pilot-mode .video-cell {
  border-color: rgba(0, 255, 136, 0.2);
  border-radius: 4px;
  aspect-ratio: unset;
}
.video-wall.pilot-mode .video-cell.active { border-color: var(--accent-green); }
.video-wall.pilot-mode .video-drone-name {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  color: var(--accent-green);
  text-shadow: 0 0 8px rgba(0, 255, 136, 0.7);
  font-size: 10px;
}
.video-wall.pilot-mode .video-drone-meta { color: rgba(0, 255, 136, 0.5); }

/* ─── AI Tracking active state ─── */
#ai-track-btn.active, #ai-autofocus-btn.active, #hud-toggle-btn.active {
  background: rgba(167, 139, 250, 0.15);
  border-color: var(--accent-purple);
  color: var(--accent-purple);
}

/* ─── Pulse animation (LIVE dot) ─── */
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.6); }
  50% { box-shadow: 0 0 0 5px rgba(0, 255, 136, 0); }
}

/* ─── Modal System ─── */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.80);
  backdrop-filter: blur(8px);
  z-index: 9999;
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: rgba(10, 20, 40, 0.97);
  border: 1.5px solid rgba(0, 170, 255, 0.45);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.95), 0 0 30px rgba(0, 170, 255, 0.12), inset 0 1px 0 rgba(255,255,255,0.05);
  border-radius: 14px;
  width: 520px;
  max-width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  position: relative;
  animation: modal-enter 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modal-enter {
  from { transform: scale(0.92) translateY(20px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.modal-header h3 { font-size: 18px; font-weight: 900; color: #fff; letter-spacing: 0.4px; display: flex; align-items: center; gap: 10px; }

.modal-close, .close-modal-btn {
  background: transparent; border: none; color: var(--text-dim);
  font-size: 22px; cursor: pointer; line-height: 1; transition: all 0.2s;
  padding: 4px 8px; border-radius: 6px;
}
.modal-close:hover, .close-modal-btn:hover { color: var(--accent-red); background: rgba(255, 77, 77, 0.12); }

.modal-body { color: var(--text-main); }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 11px; color: var(--text-dim); margin-bottom: 8px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.2px; }

.form-group input, .form-group select {
  width: 100%; background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; color: #fff; font-size: 14px; transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus { border-color: var(--accent-blue); outline: none; }

.modal-footer { margin-top: 30px; display: flex; justify-content: flex-end; gap: 12px; }

/* Buttons in modal */
.btn-primary { 
  background: var(--accent-blue); color: #fff; border: none; 
  padding: 12px 24px; border-radius: 8px; font-weight: 800; cursor: pointer;
  transition: transform 0.1s, background 0.2s;
}
.btn-primary:active { transform: scale(0.96); }
.btn-primary:hover { background: #0099ee; }

.btn-secondary { 
  background: rgba(255,255,255,0.05); color: var(--text-dim); border: 1px solid var(--border);
  padding: 12px 24px; border-radius: 8px; font-weight: 800; cursor: pointer;
}
.btn-secondary:hover { color: #fff; background: rgba(255,255,255,0.1); }
.btn-danger { background: rgba(239,68,68,0.15); color: var(--accent-red); border: 1px solid rgba(239,68,68,0.4); padding: 12px 24px; border-radius: 8px; font-weight: 800; cursor: pointer; }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-voice-active { border-color: var(--accent-green) !important; color: var(--accent-green) !important; box-shadow: 0 0 10px rgba(0,255,136,0.25); }

/* Small-size button modifier */
.btn-sm {
  padding: 5px 12px; border-radius: 6px; font-size: 11px; font-weight: 700;
  cursor: pointer; border: 1px solid transparent; transition: all 0.15s;
  display: inline-flex; align-items: center; gap: 5px;
}
.btn-sm.btn-primary  { background: var(--accent-blue); color: #fff; border-color: var(--accent-blue); }
.btn-sm.btn-primary:hover { background: #0099ee; }
.btn-sm.btn-outline  { background: transparent; color: var(--text-dim); border-color: rgba(255,255,255,.15); }
.btn-sm.btn-outline:hover { background: rgba(255,255,255,.07); color: #fff; }
.btn-sm.btn-blue     { background: rgba(56,189,248,.15); color: var(--accent-blue); border-color: rgba(56,189,248,.3); }
.btn-sm.btn-blue:hover { background: rgba(56,189,248,.25); }
.btn-sm.btn-accent   { background: rgba(0,170,255,.15); color: var(--accent-cyan); border-color: rgba(0,170,255,.3); }
.btn-sm.btn-accent:hover { background: rgba(0,170,255,.25); }
.btn-sm.btn-red      { background: rgba(239,68,68,.12); color: var(--accent-red); border-color: rgba(239,68,68,.3); }
.btn-sm.btn-red:hover { background: rgba(239,68,68,.22); }

/* MAVLink panel */
.mavlink-panel { display: flex; flex-direction: column; gap: 8px; }
.mavlink-status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); }
.mavlink-conns  { display: flex; flex-direction: column; gap: 4px; font-size: 11px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* kpi-sub without -val */
.kpi-sub { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

/* ═══════════════════════════════════════════════════════════════════════════
   DASHBOARD ENHANCED LAYOUT
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Card Base ─── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.card-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 7px;
}

/* ─── Controls Bar ─── */
.dash-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.dash-select-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.select-drone {
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: #fff;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}
.select-drone:focus { outline: none; border-color: var(--accent-blue); }
.select-drone option { background: #0d1b2a; }

.arm-status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 800;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  letter-spacing: 0.5px;
}
.arm-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: background 0.3s;
}
.arm-dot.armed { background: var(--accent-green); box-shadow: 0 0 6px rgba(0,255,136,0.6); animation: pulse-dot 1s infinite; }
.arm-dot.disarmed { background: var(--accent-red); }

.dash-swarm-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.ctrl-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-dim);
}
.ctrl-label { font-size: 11px; }
.swarm-msg {
  font-size: 10px;
  color: var(--accent-blue);
  font-weight: 700;
  padding: 3px 8px;
  background: rgba(0,170,255,0.08);
  border-radius: 5px;
  border: 1px solid rgba(0,170,255,0.2);
}
.swarm-badge {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 5px;
  background: rgba(0,255,136,0.08);
  border: 1px solid rgba(0,255,136,0.2);
  color: var(--accent-green);
  font-size: 10px; font-weight: 800;
}

/* ─── Toggle Switch ─── */
.switch { position: relative; display: inline-block; width: 32px; height: 18px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top:0;left:0;right:0;bottom:0;
  background: rgba(255,255,255,0.1); border-radius: 18px; transition: 0.3s; }
.slider:before { content:''; position:absolute; height:12px; width:12px;
  left:3px; bottom:3px; background:#fff; border-radius:50%; transition:0.3s; }
input:checked + .slider { background: var(--accent-green); }
input:checked + .slider:before { transform: translateX(14px); }

/* ─── KPI Row ─── */
.dash-kpi-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}
@media (max-width: 1400px) { .dash-kpi-row { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 900px)  { .dash-kpi-row { grid-template-columns: repeat(2, 1fr); } }

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px 9px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: border-color 0.2s;
  position: relative;
  overflow: hidden;
}
.kpi-card:hover { border-color: rgba(0,170,255,0.4); }
.kpi-health-clickable { cursor: pointer; }
.kpi-health-clickable:hover { border-color: rgba(0,255,136,0.5); background: rgba(0,255,136,0.04); }

.kpi-icon-box {
  width: 28px; height: 28px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  margin-bottom: 4px;
  flex-shrink: 0;
}
.icon-battery { background: rgba(0,170,255,0.12); color: var(--accent-blue); }
.icon-alt     { background: rgba(0,255,136,0.12); color: var(--accent-green); }
.icon-speed   { background: rgba(251,191,36,0.12); color: var(--accent-yellow); }
.icon-gps     { background: rgba(167,139,250,0.12); color: var(--accent-purple); }
.icon-rssi    { background: rgba(0,210,255,0.12); color: var(--accent-cyan); }

.kpi-value {
  font-size: 18px;
  font-weight: 900;
  color: #fff;
  line-height: 1;
  letter-spacing: -0.3px;
}
.kpi-label {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 700;
}
.kpi-sub-val {
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 600;
  margin-top: 2px;
}
#kpi-battery-bar {
  width: 100%;
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 3px;
}
#kpi-battery-fill {
  height: 100%;
  width: 80%;
  background: var(--accent-blue);
  border-radius: 2px;
  transition: width 0.5s, background 0.3s;
}

/* GPS/Signal bars */
.kpi-gps-bars, .kpi-signal-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  margin-top: 4px;
  height: 14px;
}
.kpi-gps-bars i, .kpi-signal-bars i {
  display: block;
  width: 5px;
  background: rgba(255,255,255,0.12);
  border-radius: 1px;
  transition: background 0.3s, height 0.3s;
  font-style: normal;
}
.kpi-gps-bars i:nth-child(1) { height: 3px; }
.kpi-gps-bars i:nth-child(2) { height: 5px; }
.kpi-gps-bars i:nth-child(3) { height: 7px; }
.kpi-gps-bars i:nth-child(4) { height: 9px; }
.kpi-gps-bars i:nth-child(5) { height: 11px; }
.kpi-gps-bars i:nth-child(6) { height: 12px; }
.kpi-gps-bars i:nth-child(7) { height: 13px; }
.kpi-gps-bars i:nth-child(8) { height: 14px; }
.kpi-signal-bars i:nth-child(1) { height: 4px; }
.kpi-signal-bars i:nth-child(2) { height: 6px; }
.kpi-signal-bars i:nth-child(3) { height: 9px; }
.kpi-signal-bars i:nth-child(4) { height: 12px; }
.kpi-signal-bars i:nth-child(5) { height: 14px; }
.kpi-gps-bars i.active { background: var(--accent-purple); }
.kpi-signal-bars i.active { background: var(--accent-cyan); }

/* ─── Main 3-column Grid ─── */
.dash-main-grid {
  display: grid;
  grid-template-columns: 190px 1fr 200px;
  gap: 10px;
  margin-bottom: 10px;
  min-height: 0;
}
@media (max-width: 1100px) {
  .dash-main-grid { grid-template-columns: 1fr 1fr; }
  .dash-col-a { grid-column: 1 / -1; }
}
@media (max-width: 750px) {
  .dash-main-grid { grid-template-columns: 1fr; }
}

.dash-col-a, .dash-col-b, .dash-col-c {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}
.dash-col-b .card:first-child { flex-shrink: 0; }
.dash-col-b .card:last-child { flex: 1; min-height: 0; overflow: auto; }
.dash-col-c .card { flex: 1; display: flex; flex-direction: column; gap: 10px; }

/* Attitude canvas */
.attitude-wrap {
  display: flex;
  justify-content: center;
  padding: 8px 0 4px;
}
#attitude-canvas {
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.12);
  background: #0d1b2a;
  display: block;
  width: 140px; height: 140px;
}
.attitude-values {
  display: flex;
  justify-content: space-around;
  padding: 6px 0 4px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.av-item { text-align: center; }
.av-label { display: block; font-size: 9px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.7px; }
.av-val   { display: block; font-size: 13px; font-weight: 800; color: var(--accent-cyan); font-family: 'JetBrains Mono', monospace; }

/* Compass strip */
.compass-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 8px;
  background: rgba(0,0,0,0.25);
  border-radius: 6px;
  margin-top: 4px;
}
.compass-dir {
  font-size: 14px; font-weight: 900;
  color: var(--accent-yellow);
  min-width: 24px; text-align: center;
}
.compass-arrow-row { display: flex; align-items: center; }
.compass-needle-mini {
  font-size: 14px;
  color: var(--accent-blue);
  transition: transform 0.4s;
  display: inline-block;
}
.compass-hdg {
  font-size: 12px; font-weight: 800;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
  min-width: 34px; text-align: center;
}

/* GPS threat banner */
.gps-threat-banner {
  display: none;
  align-items: center;
  gap: 6px;
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.4);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 10px;
  color: var(--accent-red);
  font-weight: 700;
  margin-top: 4px;
}
.gps-threat-banner.active { display: flex; }

/* ─── Flight Details Grid ─── */
.fi-detail-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.fi-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 11px;
}
.fi-row:last-child { border-bottom: none; }
.fi-lbl { color: var(--text-dim); font-weight: 600; }
.fi-val { color: #fff; font-weight: 700; }
.fi-val.mono { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--accent-cyan); }
.badge-mode {
  background: rgba(0,170,255,0.12);
  color: var(--accent-blue);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

/* ─── Command Panel ─── */
.arm-state-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.cmd-btn-lg {
  padding: 6px 12px;
  border-radius: 7px;
  border: none;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  display: flex; align-items: center; gap: 5px;
  transition: all 0.15s;
}
.cmd-btn-lg:active { transform: scale(0.94); }
.btn-green { background: rgba(0,255,136,0.12); border: 1px solid rgba(0,255,136,0.4); color: var(--accent-green); }
.btn-green:hover { background: rgba(0,255,136,0.22); }
.btn-red   { background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.4); color: var(--accent-red); }
.btn-red:hover { background: rgba(239,68,68,0.22); }

.cmd-grid-2x2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-bottom: 8px;
}
.cmd-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 10px 8px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}
.cmd-tile span { font-size: 12px; font-weight: 800; }
.cmd-tile small { font-size: 9px; color: var(--text-dim); font-weight: 600; letter-spacing: 0.5px; }
.cmd-tile:hover { background: rgba(255,255,255,0.09); border-color: rgba(255,255,255,0.2); transform: translateY(-1px); }
.cmd-tile:active { transform: scale(0.95); }
.cmd-takeoff { border-color: rgba(0,255,136,0.25); color: var(--accent-green); }
.cmd-takeoff:hover { background: rgba(0,255,136,0.10); border-color: rgba(0,255,136,0.5); }
.cmd-rth  { border-color: rgba(251,191,36,0.25); color: var(--accent-yellow); }
.cmd-rth:hover  { background: rgba(251,191,36,0.10); border-color: rgba(251,191,36,0.5); }
.cmd-hold { border-color: rgba(0,170,255,0.25); color: var(--accent-blue); }
.cmd-hold:hover { background: rgba(0,170,255,0.10); border-color: rgba(0,170,255,0.5); }
.cmd-land { border-color: rgba(167,139,250,0.25); color: var(--accent-purple); }
.cmd-land:hover { background: rgba(167,139,250,0.10); border-color: rgba(167,139,250,0.5); }

.cmd-emergency {
  width: 100%;
  padding: 10px;
  background: rgba(239,68,68,0.10);
  border: 1.5px solid rgba(239,68,68,0.5);
  border-radius: 9px;
  color: var(--accent-red);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: all 0.15s;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  margin-bottom: 8px;
}
.cmd-emergency:hover { background: rgba(239,68,68,0.20); box-shadow: 0 0 16px rgba(239,68,68,0.2); }
.cmd-emergency:active { transform: scale(0.97); }

/* Mode Buttons */
.mode-selector { margin-top: 2px; }
.mode-btns {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.mode-btn {
  flex: 1;
  min-width: 38px;
  padding: 5px 4px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  letter-spacing: 0.3px;
}
.mode-btn:hover { background: rgba(0,170,255,0.12); color: var(--accent-blue); border-color: rgba(0,170,255,0.35); }
.mode-btn.active { background: rgba(0,170,255,0.18); color: var(--accent-blue); border-color: var(--accent-blue); }

/* ─── Bottom Row ─── */
.dash-bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 800px) { .dash-bottom-row { grid-template-columns: 1fr; } }

/* Fleet Overview */
.fleet-overview {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 6px 0;
  min-height: 60px;
}
.fleet-empty {
  color: var(--text-dim);
  font-size: 11px;
  padding: 10px 0;
  width: 100%;
  text-align: center;
}
.fleet-drone-mini {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  min-width: 64px;
}
.fleet-drone-mini:hover { border-color: rgba(0,170,255,0.4); background: rgba(0,170,255,0.06); }
.fleet-drone-mini.selected { border-color: var(--accent-blue); background: rgba(0,170,255,0.10); }
.fleet-drone-mini.flying { border-color: rgba(0,255,136,0.35); }
.fdm-icon { font-size: 16px; }
.fdm-name { font-size: 10px; font-weight: 800; color: #fff; max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fdm-bat  { font-size: 9px; font-weight: 700; }
.fdm-status { font-size: 8px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }

.fleet-count-badge {
  margin-left: auto;
  background: rgba(0,170,255,0.12);
  color: var(--accent-blue);
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid rgba(0,170,255,0.25);
}

/* Alert Feed */
.alert-feed {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 140px;
  overflow-y: auto;
  padding: 2px 0;
}
.alert-feed::-webkit-scrollbar { width: 3px; }
.alert-feed::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
.alert-empty { color: var(--text-dim); font-size: 11px; padding: 10px 0; text-align: center; }

.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 7px;
  border-left: 3px solid var(--border);
  background: rgba(255,255,255,0.03);
  font-size: 11px;
}
.alert-item.critical, .alert-item.emergency {
  border-left-color: var(--accent-red);
  background: rgba(239,68,68,0.07);
}
.alert-item.warning { border-left-color: var(--accent-yellow); background: rgba(251,191,36,0.07); }
.alert-item.info    { border-left-color: var(--accent-blue); background: rgba(0,170,255,0.06); }
.alert-dot {
  width: 6px; height: 6px; border-radius: 50%;
  flex-shrink: 0; margin-top: 3px;
}
.alert-item.critical .alert-dot, .alert-item.emergency .alert-dot { background: var(--accent-red); }
.alert-item.warning .alert-dot { background: var(--accent-yellow); }
.alert-item.info .alert-dot    { background: var(--accent-blue); }
.alert-time { color: var(--text-dim); font-size: 9px; white-space: nowrap; flex-shrink: 0; margin-top: 1px; }
.alert-msg  { color: var(--text-main); line-height: 1.4; flex: 1; }
.alert-src  { color: var(--text-dim); font-size: 9px; white-space: nowrap; }

/* ─── Alerts Table View ─── */
.alerts-table-wrap {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.alerts-table {
  width: 100%; border-collapse: collapse;
  font-size: 12px;
}
.alerts-table thead tr {
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid var(--border);
}
.alerts-table th {
  padding: 10px 14px; text-align: left;
  font-size: 11px; font-weight: 700;
  color: var(--text-dim); letter-spacing: .05em; text-transform: uppercase;
}
.alerts-table td {
  padding: 9px 14px; border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
}
.alerts-table tr:last-child td { border-bottom: none; }
.alerts-table tr:hover td { background: rgba(255,255,255,0.025); }
.alerts-table .badge {
  display: inline-block; padding: 2px 8px;
  border-radius: 20px; font-size: 10px; font-weight: 700; text-transform: uppercase;
}
.alerts-table .badge.critical, .alerts-table .badge.emergency {
  background: rgba(239,68,68,0.15); color: var(--accent-red);
}
.alerts-table .badge.warning {
  background: rgba(251,191,36,0.15); color: var(--accent-yellow);
}
.alerts-table .badge.info {
  background: rgba(0,170,255,0.12); color: var(--accent-blue);
}

/* ─── Flight Logs View ─── */
#log-list { display: flex; flex-direction: column; gap: 12px; }
.log-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 18px;
  transition: border-color 0.2s;
}
.log-card:hover { border-color: rgba(56,189,248,.3); }
.log-card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.log-drone-name { font-weight: 800; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.log-entry-count { font-size: 11px; color: var(--text-dim); background: rgba(255,255,255,.05); padding: 2px 10px; border-radius: 20px; }
.log-stats { display: flex; gap: 0; margin-bottom: 12px; }
.log-stat {
  flex: 1; text-align: center; padding: 8px 4px;
  border-right: 1px solid var(--border);
}
.log-stat:last-child { border-right: none; }
.log-stat-val { font-size: 20px; font-weight: 900; color: var(--text-main); line-height: 1.1; }
.log-stat-lbl { font-size: 10px; color: var(--text-dim); margin-top: 3px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.log-meta { font-size: 11px; color: var(--text-dim); margin-bottom: 12px; display: flex; gap: 12px; flex-wrap: wrap; }
.log-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ─── Log Chart Overlay ─── */
.log-chart-overlay {
  display: none; position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  align-items: center; justify-content: center;
}
.log-chart-overlay.open { display: flex; }
.log-chart-panel {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 14px; width: min(900px, 95vw);
  display: flex; flex-direction: column;
  max-height: 85vh; overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
.log-chart-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  font-weight: 800; font-size: 14px;
}
.log-chart-tabs {
  display: flex; gap: 2px; padding: 10px 18px 0;
  border-bottom: 1px solid var(--border);
}
.log-tab {
  padding: 6px 16px; font-size: 12px; font-weight: 700;
  background: transparent; border: none; border-bottom: 2px solid transparent;
  color: var(--text-dim); cursor: pointer; transition: color 0.2s, border-color 0.2s;
}
.log-tab.active { color: var(--accent-cyan); border-bottom-color: var(--accent-cyan); }
.log-chart-body {
  flex: 1; min-height: 0; padding: 18px; position: relative;
  height: 420px;
}
.log-chart-body canvas { width: 100% !important; height: 100% !important; }

/* ─── Mission Analytics Modal ─── */
.detection-tag {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(56,189,248,.1); border: 1px solid rgba(56,189,248,.25);
  border-radius: 20px; padding: 3px 10px; font-size: 11px; font-weight: 700;
}
.detection-tag .cls { color: var(--accent-cyan); }
.detection-tag .cnt { color: var(--text-dim); }
#stat-kpis tr { border-bottom: 1px solid rgba(255,255,255,.04); }
#stat-kpis tr:last-child { border-bottom: none; }
#stat-kpis td { padding: 8px 8px; }
#stat-kpis td:last-child { color: var(--accent-green); font-weight: 700; font-size: 11px; }

/* ─── Playback Overlay ─── */
.playback-overlay {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 9000;
  background: rgba(10,14,23,.92); backdrop-filter: blur(12px);
  border-top: 1px solid rgba(56,189,248,.2);
  display: flex; align-items: center; justify-content: center;
  padding: 8px 16px;
}
.pb-controls {
  display: flex; align-items: center; gap: 10px; width: 100%; max-width: 900px;
}
.pb-btn {
  background: rgba(56,189,248,.12); border: 1px solid rgba(56,189,248,.25);
  color: var(--accent-cyan); border-radius: 6px; padding: 5px 10px;
  cursor: pointer; font-size: 12px; white-space: nowrap;
  transition: background .15s;
}
.pb-btn:hover { background: rgba(56,189,248,.25); }
.pb-btn.pb-close { color: var(--accent-red); border-color: rgba(244,63,94,.3); background: rgba(244,63,94,.1); }
.pb-btn.pb-close:hover { background: rgba(244,63,94,.25); }
.pb-timeline-wrap {
  flex: 1; display: flex; flex-direction: column; gap: 2px;
}
.pb-timeline-wrap input[type=range] { width: 100%; accent-color: var(--accent-cyan); cursor: pointer; }
.pb-time-info { font-size: 10px; color: var(--text-dim); text-align: right; }

/* ─── Insight 面板補充樣式 ─── */
.accuracy-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.acc-item { display: flex; flex-direction: column; gap: 3px; }
.acc-lbl { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .6px; }
.acc-val { font-size: 18px; font-weight: 800; color: var(--accent-cyan); }
.accuracy-status { font-size: 12px; padding: 6px 10px; border-radius: 6px; background: rgba(255,255,255,.03); border: 1px solid var(--border); }
.link-rows { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.link-row { display: flex; justify-content: space-between; align-items: center; font-size: 12px; padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,.04); }
.link-row:last-child { border-bottom: none; }
.link-row span:first-child { color: var(--text-dim); }
.link-row span:last-child { font-weight: 700; font-family: 'JetBrains Mono', monospace; }

/* ═══════════════════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════════════════════════ */
#toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  padding: 10px 16px; border-radius: 8px; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 8px; min-width: 220px; max-width: 360px;
  pointer-events: auto; transition: opacity 0.4s;
  backdrop-filter: blur(8px); border: 1px solid;
  background: rgba(15,23,42,0.92);
}
.toast.success { color: var(--accent-green); border-color: rgba(74,222,128,.35); }
.toast.error,
.toast.danger   { color: var(--accent-red);   border-color: rgba(239,68,68,.35); }
.toast.warn,
.toast.warning  { color: var(--accent-yellow); border-color: rgba(251,191,36,.35); }
.toast.info     { color: var(--accent-blue);   border-color: rgba(56,189,248,.35); }

/* ═══════════════════════════════════════════════════════════════════════════
   EMPTY STATE & MISSION CARDS
   ═══════════════════════════════════════════════════════════════════════════ */
.empty-state {
  padding: 24px; text-align: center; color: var(--text-dim);
  font-size: 12px; font-weight: 600;
}
.mission-card {
  padding: 10px 14px; border-radius: 8px;
  background: rgba(255,255,255,.03); border: 1px solid var(--border);
  margin-bottom: 8px; display: flex; align-items: center; gap: 10px;
}
.mission-name { flex: 1; font-weight: 700; font-size: 13px; }
.mission-alt  { font-size: 11px; color: var(--accent-cyan); font-family: 'JetBrains Mono', monospace; }

/* Alert table */
.alerts-table { width: 100%; border-collapse: collapse; }
.alerts-table th {
  text-align: left; padding: 8px 12px; font-size: 10px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}
.alerts-table td { padding: 8px 12px; font-size: 12px; border-bottom: 1px solid rgba(255,255,255,.03); }
.alerts-table tr:hover td { background: rgba(255,255,255,.02); }

/* ═══════════════════════════════════════════════════════════════════════════
   SITL CONNECTION LIST
   ═══════════════════════════════════════════════════════════════════════════ */
.sitl-conn-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.sitl-conn-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 8px; background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.06);
}
.sitl-conn-icon { color: var(--accent-blue); font-size: 18px; flex-shrink: 0; }
.sitl-conn-info { flex: 1; min-width: 0; }
.sitl-conn-name { font-weight: 800; font-size: 12px; color: #fff; }
.sitl-conn-addr { font-size: 10px; color: var(--text-dim); font-family: 'JetBrains Mono', monospace; margin-top: 2px; }
.sitl-conn-status { font-size: 10px; font-weight: 700; flex-shrink: 0; }
.sitl-no-conn  { color: var(--text-dim); font-size: 11px; padding: 8px 0; text-align: center; }
.sitl-status-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-dim); padding: 4px 0; }

/* ═══════════════════════════════════════════════════════════════════════════
   VOICE OVERLAY
   ═══════════════════════════════════════════════════════════════════════════ */
.voice-overlay {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  z-index: 4000; display: flex; align-items: center; gap: 14px;
  background: rgba(10,20,40,0.92); border: 1px solid rgba(56,189,248,.4);
  border-radius: 40px; padding: 12px 24px; backdrop-filter: blur(12px);
  box-shadow: 0 4px 32px rgba(0,0,0,.5);
}
.voice-pulse {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent-blue); flex-shrink: 0;
  animation: voice-pulse-anim 0.8s ease-in-out infinite;
}
@keyframes voice-pulse-anim {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.4); opacity: 0.7; }
}
.voice-text {
  font-size: 13px; font-weight: 700; color: #fff;
  white-space: nowrap; max-width: 300px;
}

.sitl-status-box {
  background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px; padding: 10px 12px; margin-top: 8px;
}

/* ─── Stream List ─── */
.stream-item {
  display: flex; align-items: flex-start; gap: 10px; justify-content: space-between;
  padding: 10px 12px; background: rgba(255,255,255,.03);
  border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px;
}
.stream-item-info { flex: 1; min-width: 0; }
.stream-item-name { font-weight: 800; font-size: 13px; margin-bottom: 3px; }
.stream-item-url  { font-size: 10px; color: var(--text-dim); font-family: 'JetBrains Mono', monospace; word-break: break-all; }
.stream-item-urls { margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; }
.stream-item-status { display: flex; align-items: center; gap: 8px; flex-shrink: 0; font-size: 11px; }
.url-chip {
  font-size: 10px; padding: 2px 7px; border-radius: 10px;
  background: rgba(0,170,255,.08); border: 1px solid rgba(0,170,255,.2);
  color: var(--accent-blue); font-family: 'JetBrains Mono', monospace;
}
.mono { font-family: 'JetBrains Mono', monospace; }

/* ─── MAVLink Connection List (Sidebar) ─── */
.mav-conn-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 0; font-size: 11px; border-bottom: 1px solid rgba(255,255,255,.04);
}
.mav-conn-item:last-child { border-bottom: none; }
.mav-drone-name { font-weight: 700; color: var(--accent-cyan); }
.mav-addr { color: var(--text-dim); font-family: 'JetBrains Mono', monospace; }

/* ─── Settings Gear Button ─── */
.settings-gear-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text-dim);
  width: 28px; height: 28px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 13px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.settings-gear-btn:hover {
  color: #fff;
  border-color: rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.07);
}
.settings-gear-btn:hover i { animation: spin-slow 1.5s linear infinite; }
@keyframes spin-slow { to { transform: rotate(360deg); } }

/* ─── Settings Modal ─── */
.settings-box {
  width: 480px;
  max-height: 85vh;
  overflow-y: auto;
}
.settings-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 0 4px;
}

/* 預覽區 */
.settings-preview {
  background: #0a1426;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.sp-brand { display: flex; align-items: center; gap: 10px; }
.sp-icon {
  width: 30px; height: 30px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: #fff;
  flex-shrink: 0;
}
.sp-name { font-weight: 900; font-size: 16px; color: #fff; line-height: 1; }
.sp-sub  { font-size: 8px; color: var(--text-dim); text-transform: uppercase;
           letter-spacing: 1.5px; opacity: 0.6; margin-top: 3px; }
.settings-preview-label {
  font-size: 9px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-dim); opacity: 0.5;
}

/* 設定列 */
.settings-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.settings-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.settings-input {
  background: var(--bg-input, #0f1e35);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-main);
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.settings-input:focus { border-color: var(--accent-blue, #38bdf8); }

/* 圖示 Grid */
.settings-icon-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.settings-icon-btn {
  width: 36px; height: 36px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.settings-icon-btn:hover {
  border-color: #38bdf8;
  color: #38bdf8;
}
.settings-icon-btn.selected {
  border-color: #38bdf8;
  background: rgba(56,189,248,0.12);
  color: #38bdf8;
}

/* 色票 */
.settings-color-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.settings-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.settings-swatch {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
  flex-shrink: 0;
}
.settings-swatch:hover  { transform: scale(1.2); }
.settings-swatch.selected {
  border-color: #fff;
  transform: scale(1.15);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.3);
}
.settings-color-picker {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  padding: 0;
  background: none;
  cursor: pointer;
  overflow: hidden;
}

/* 上傳按鈕列 */
.settings-upload-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.settings-upload-btn {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ─── Geofence Polygon Drawing Panel ─── */
.gf-poly-panel {
  position: absolute;
  top: 60px; left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  background: var(--bg-card);
  border: 1.5px solid var(--accent-blue, #38bdf8);
  border-radius: 10px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  font-size: 12px;
  color: var(--text-main);
  pointer-events: all;
}
.gf-poly-count { font-weight: 700; color: #38bdf8; min-width: 60px; }

/* ─── Keyboard Shortcuts Overlay ─── */
.shortcuts-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 9100;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
}
.shortcuts-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 520px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}
.shortcuts-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}
.shortcuts-header button {
  background: none; border: none;
  color: var(--text-dim); cursor: pointer; font-size: 16px;
}
.shortcuts-header button:hover { color: var(--text-main); }
.shortcuts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 14px 20px;
}
.sc-group { margin-bottom: 14px; }
.sc-group-title {
  font-size: 9px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 1.2px; color: var(--text-dim);
  margin-bottom: 6px; opacity: 0.7;
}
.sc-row {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 0;
}
.sc-key {
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 10px; font-family: 'JetBrains Mono', monospace;
  color: var(--text-main);
  min-width: 28px; flex-shrink: 0;
}
.sc-desc { font-size: 11px; color: var(--text-dim); }
.shortcuts-footer {
  text-align: center;
  font-size: 10px; color: var(--text-dim);
  padding: 10px;
  border-top: 1px solid var(--border);
}
.shortcuts-footer kbd {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 3px; padding: 1px 5px;
  font-size: 10px;
}

/* ─── Logs Filter Bar ─── */
.log-filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.log-filter-label {
  font-size: 10px; font-weight: 600;
  color: var(--text-dim); text-transform: uppercase;
  letter-spacing: 0.8px; white-space: nowrap;
}
.log-filter-input {
  background: var(--bg-input, #0f1e35);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-main);
  font-size: 11px;
  padding: 4px 8px;
  outline: none;
  transition: border-color 0.15s;
}
.log-filter-input:focus { border-color: #38bdf8; }
.log-filter-bar.filter-active {
  background: rgba(56,189,248,0.05);
  border-bottom-color: rgba(56,189,248,0.3);
}

/* ── Notification Center (U2) ──────────────────────────────────────────── */
.notif-filter-bar {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.notif-filter {
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-main); border-radius: 6px; padding: 5px 10px; font-size: 12px;
}
.notif-search { flex: 1; min-width: 140px; }
.notif-stat-label { font-size: 11px; color: var(--text-dim); margin-left: 4px; }
.notif-list { display: flex; flex-direction: column; gap: 6px; }
.notif-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-card); transition: opacity .2s;
}
.notif-row.ack { opacity: .5; }
.notif-row.unread { border-left: 3px solid; }
.notif-row.danger.unread  { border-left-color: #ef4444; background: rgba(239,68,68,.04); }
.notif-row.warning.unread { border-left-color: #fb923c; background: rgba(251,146,60,.04); }
.notif-row.info.unread    { border-left-color: #38bdf8; background: rgba(56,189,248,.04); }
.notif-icon { width: 28px; text-align: center; font-size: 14px; flex-shrink: 0; }
.notif-icon-danger  { color: #ef4444; }
.notif-icon-warning { color: #fb923c; }
.notif-icon-info    { color: #38bdf8; }
.notif-body { flex: 1; min-width: 0; }
.notif-msg  { font-size: 13px; color: var(--text-main); line-height: 1.4; }
.notif-meta { display: flex; gap: 8px; margin-top: 3px; flex-wrap: wrap; }
.notif-drone { font-size: 10px; background: rgba(56,189,248,.15); color: #38bdf8; padding: 1px 6px; border-radius: 4px; font-weight: 600; }
.notif-type  { font-size: 10px; color: var(--text-dim); }
.notif-time  { font-size: 10px; color: var(--text-dim); margin-left: auto; }
.notif-ack-btn  { background: rgba(74,222,128,.15); border: 1px solid rgba(74,222,128,.3); color: #4ade80; border-radius: 6px; padding: 4px 8px; cursor: pointer; flex-shrink: 0; }
.notif-ack-done { color: #4ade80; opacity: .4; font-size: 12px; flex-shrink: 0; }
.notif-empty { text-align: center; padding: 40px; color: var(--text-dim); font-size: 14px; }

/* ── SAR Module (R5 + R1) ──────────────────────────────────────────────── */
.sar-panel { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.sar-section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-dim); margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }
.sar-badge { font-size: 11px; background: rgba(239,68,68,.15); color: #ef4444; padding: 2px 8px; border-radius: 10px; font-weight: 600; margin-left: 8px; }
.sar-empty { text-align: center; padding: 32px; color: var(--text-dim); font-size: 14px; }
.sar-result-ok { padding: 10px 14px; background: rgba(74,222,128,.1); border: 1px solid rgba(74,222,128,.3); border-radius: 8px; color: #4ade80; font-size: 13px; }
.sar-drone-checks { display: flex; flex-direction: column; gap: 4px; max-height: 120px; overflow-y: auto; }
.sar-drone-chk-wrap { display: flex; align-items: center; gap: 6px; font-size: 12px; cursor: pointer; }

/* Survivor markers */
@keyframes survivor-pulse {
  0%,100% { transform: scale(1); opacity: .8; }
  50%      { transform: scale(1.7); opacity: 0; }
}
.survivor-marker {
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(239,68,68,.9); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; border: 2px solid #fff; box-shadow: 0 2px 8px rgba(239,68,68,.6);
  position: relative;
}
.survivor-pulse {
  position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid #ef4444;
  animation: survivor-pulse 1.4s ease-out infinite;
}
.survivor-marker.survivor-ack { background: rgba(148,163,184,.6); box-shadow: none; }
.survivor-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-card); margin-bottom: 6px; }
.survivor-item.ack { opacity: .55; }
.si-icon { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; }
.si-alert { background: rgba(239,68,68,.15); color: #ef4444; }
.si-ack   { background: rgba(74,222,128,.12); color: #4ade80; }
.si-body  { flex: 1; min-width: 0; }
.si-name  { font-size: 13px; color: var(--text-main); }
.si-coord { font-size: 11px; color: var(--text-dim); font-family: 'JetBrains Mono', monospace; }
.si-time  { font-size: 10px; color: var(--text-dim); }
.si-actions { display: flex; gap: 4px; }
.btn-icon { background: transparent; border: 1px solid var(--border); color: var(--text-dim); border-radius: 6px; width: 28px; height: 28px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 11px; }
.btn-icon:hover { background: var(--bg-hover); color: var(--text-main); }
.si-ack-btn:hover { color: #4ade80; border-color: rgba(74,222,128,.4); }
.si-del-btn:hover { color: #ef4444; border-color: rgba(239,68,68,.4); }
.survivor-popup { min-width: 200px; }
.sp-title { font-weight: 700; font-size: 13px; color: #ef4444; margin-bottom: 8px; }
.sp-row   { font-size: 12px; margin-bottom: 4px; }
.sp-actions { display: flex; gap: 6px; margin-top: 10px; }

/* ── AIS Module (M1) ───────────────────────────────────────────────────── */
@keyframes ais-pulse {
  0%,100% { transform: scale(1); opacity: .9; }
  50%      { transform: scale(1.5); opacity: 0; }
}
.ais-marker {
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(0,0,0,0.55);
  border: 2px solid var(--ais-color, #94a3b8);
  color: var(--ais-color, #94a3b8);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; position: relative;
  box-shadow: 0 0 6px var(--ais-color, #94a3b8);
}
.ais-pulse {
  position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid #ef4444;
  animation: ais-pulse 1.6s ease-out infinite;
}
.ais-vessel-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-card); margin-bottom: 6px; cursor: pointer; transition: background .15s;
}
.ais-vessel-row:hover { background: var(--bg-hover); }
.ais-suspicious { border-color: rgba(239,68,68,.4); background: rgba(239,68,68,.04); }
.avr-icon { width: 28px; text-align: center; font-size: 16px; flex-shrink: 0; }
.avr-body { flex: 1; min-width: 0; }
.avr-name { font-size: 13px; font-weight: 600; color: var(--text-main); }
.avr-meta { font-size: 11px; color: var(--text-dim); }
.avr-coord{ font-size: 10px; color: var(--text-dim); font-family: 'JetBrains Mono', monospace; flex-shrink: 0; }
.ais-badge-warn { font-size: 9px; background: rgba(239,68,68,.2); color: #ef4444; padding: 1px 5px; border-radius: 4px; margin-left: 6px; }
.ais-empty { text-align: center; padding: 40px; color: var(--text-dim); }
.ais-popup { min-width: 200px; }
.ap-title  { font-weight: 700; font-size: 13px; margin-bottom: 8px; }
.ap-row    { font-size: 12px; margin-bottom: 4px; }
.ap-warn   { font-size: 11px; color: #ef4444; margin-top: 8px; padding: 6px; background: rgba(239,68,68,.1); border-radius: 4px; }

/* ── Webhook Settings (C1) ─────────────────────────────────────────────── */
.wh-add-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.wh-evt { display: flex; align-items: center; gap: 4px; font-size: 12px; cursor: pointer; }
.wh-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-card); margin-bottom: 8px;
}
.wh-row-body { flex: 1; min-width: 0; }
.wh-url-text { font-size: 12px; color: var(--text-main); font-family: 'JetBrains Mono', monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wh-meta { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.wh-status-on  { color: #4ade80; }
.wh-status-off { color: #64748b; }
.wh-empty { text-align: center; padding: 32px; color: var(--text-dim); font-size: 14px; }

/* ─── Rule Engine Cards ───────────────────────────────────────────────── */
.rule-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: border-color .2s;
}
.rule-card:hover { border-color: rgba(56,189,248,.3); }
.rule-card.rule-disabled { opacity: .5; }
.rule-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.rule-name { font-size: 13px; font-weight: 600; color: #e2e8f0; }
.rule-desc { font-size: 11px; color: #64748b; margin-bottom: 10px; }
.rule-condition-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.rule-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
}
.rule-cond { background: rgba(56,189,248,.12); color: #38bdf8; border: 1px solid rgba(56,189,248,.2); }
.rule-arrow { color: #475569; font-size: 11px; }
.rule-action { background: rgba(74,222,128,.1); color: #4ade80; border: 1px solid rgba(74,222,128,.2); }
.rule-action-rtl  { background: rgba(251,146,60,.1); color: #fb923c; border-color: rgba(251,146,60,.2); }
.rule-action-land { background: rgba(168,85,247,.1); color: #c084fc; border-color: rgba(168,85,247,.2); }
.rule-action-hold    { background: rgba(250,204,21,.1); color: #facc15; border-color: rgba(250,204,21,.2); }
.rule-action-arm     { background: rgba(34,197,94,.12); color: #4ade80; border-color: rgba(34,197,94,.25); }
.rule-action-disarm  { background: rgba(239,68,68,.1);  color: #f87171; border-color: rgba(239,68,68,.2); }
.rule-stat { color: #64748b; font-size: 10px; }
.rule-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #475569;
}
.rule-meta button { margin-left: auto; }
.btn-danger-sm {
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.25);
  color: #f87171;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
  transition: background .15s;
}
.btn-danger-sm:hover { background: rgba(239,68,68,.22); }

/* Toggle switch */
.rule-toggle { position: relative; display: inline-block; width: 34px; height: 18px; cursor: pointer; }
.rule-toggle input { opacity: 0; width: 0; height: 0; }
.rule-toggle-slider {
  position: absolute; inset: 0;
  background: #1e293b;
  border-radius: 9px;
  border: 1px solid rgba(255,255,255,.1);
  transition: background .2s;
}
.rule-toggle-slider::before {
  content: '';
  position: absolute;
  width: 12px; height: 12px;
  left: 2px; top: 2px;
  background: #64748b;
  border-radius: 50%;
  transition: transform .2s, background .2s;
}
.rule-toggle input:checked + .rule-toggle-slider { background: rgba(56,189,248,.2); border-color: #38bdf8; }
.rule-toggle input:checked + .rule-toggle-slider::before { transform: translateX(16px); background: #38bdf8; }

/* ─── Rule Builder Visual Editor ─────────────────────────────────────── */
.rule-builder-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(15,23,42,.6);
  border: 1px solid rgba(56,189,248,.2);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  flex-wrap: wrap;
}
.rule-preview-if, .rule-preview-then {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 4px;
}
.rule-preview-if   { background: rgba(56,189,248,.15); color: #38bdf8; }
.rule-preview-then { background: rgba(74,222,128,.12); color: #4ade80; }
.rule-preview-cond {
  color: #e2e8f0;
  font-weight: 600;
}
.rule-preview-act {
  color: #4ade80;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 5px;
  background: rgba(74,222,128,.08);
}
.rule-preview-act-rtl    { color: #fb923c; background: rgba(251,146,60,.1); }
.rule-preview-act-land   { color: #c084fc; background: rgba(168,85,247,.1); }
.rule-preview-act-hold   { color: #facc15; background: rgba(250,204,21,.1); }
.rule-preview-act-arm    { color: #4ade80; background: rgba(34,197,94,.1); }
.rule-preview-act-disarm { color: #f87171; background: rgba(239,68,68,.1); }
.rule-preview-act-alert  { color: #fb923c; background: rgba(251,146,60,.08); }

.rule-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #475569;
  margin-bottom: -6px;
}
.rule-test-btn {
  margin-bottom: 1px;
  white-space: nowrap;
}
.rule-test-result {
  background: rgba(15,23,42,.5);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
}
.rule-test-summary { color: #94a3b8; margin-bottom: 8px; }
.rule-test-rows { display: flex; flex-direction: column; gap: 5px; }
.rule-test-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #64748b;
  font-size: 11px;
}
.rule-test-row.rule-test-match { color: #cbd5e1; }
.rule-test-val { margin-left: auto; color: #94a3b8; }
.rule-test-val strong { color: #e2e8f0; }

/* ─── Weather Module ─────────────────────────────────────────────────── */

/* Header badge */
.weather-header-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.05);
  color: #94a3b8;
  white-space: nowrap;
  transition: background .15s;
}
.weather-header-badge:hover { background: rgba(255,255,255,.1); }
.weather-header-badge.badge-go   { border-color: rgba(74,222,128,.35); color: #4ade80; }
.weather-header-badge.badge-nogo { border-color: rgba(239,68,68,.35);  color: #f87171; }

/* Dashboard weather card wrapper */
.weather-dash-card-wrap {
  padding: 0 16px 12px;
}
.weather-dash-card {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 12px;
  padding: 14px 16px;
  max-width: 860px;
}

/* Card layout */
.weather-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.weather-icon-wrap img { filter: drop-shadow(0 0 6px rgba(56,189,248,.3)); }
.weather-main-info { flex: 1; }
.weather-temp { font-size: 28px; font-weight: 700; color: #e2e8f0; line-height: 1; }
.weather-desc { font-size: 12px; color: #94a3b8; margin: 2px 0; text-transform: capitalize; }
.weather-loc  { font-size: 11px; color: #475569; }

/* GO/NO-GO verdict */
.weather-verdict {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  padding: 8px 14px;
  border-radius: 8px;
  border: 2px solid;
}
.weather-go   { color: #4ade80; border-color: rgba(74,222,128,.4); background: rgba(74,222,128,.08); }
.weather-nogo { color: #f87171; border-color: rgba(239,68,68,.4);  background: rgba(239,68,68,.08);  }
.weather-go i, .weather-nogo i { font-size: 20px; }

/* Metrics strip */
.weather-metrics {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.weather-metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #cbd5e1;
  flex: 1;
  min-width: 60px;
}
.weather-metric i { color: #475569; font-size: 11px; }
.weather-metric small { font-size: 9px; color: #475569; font-weight: 400; }

/* Issues */
.weather-issues, .weather-issues-detail {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 8px;
}
.weather-issues-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #475569;
  margin-bottom: 4px;
}
.weather-issue {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid;
}
.weather-issue-danger  { color: #f87171; background: rgba(239,68,68,.08);  border-color: rgba(239,68,68,.2);  }
.weather-issue-warning { color: #fb923c; background: rgba(251,146,60,.08); border-color: rgba(251,146,60,.2); }
.weather-issue-info    { color: #38bdf8; background: rgba(56,189,248,.08); border-color: rgba(56,189,248,.2); }

.weather-updated {
  font-size: 10px;
  color: #334155;
  margin-top: 8px;
  text-align: right;
}

/* Unavailable state */
.weather-unavailable {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 24px;
  color: #334155;
  font-size: 12px;
}
.weather-unavailable i { font-size: 32px; color: #1e293b; }

/* Detail view */
.weather-detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 12px;
  margin-bottom: 16px;
}
.weather-detail-temp { font-size: 42px; font-weight: 700; color: #e2e8f0; line-height: 1; }
.weather-detail-desc { font-size: 14px; color: #94a3b8; text-transform: capitalize; }
.weather-detail-loc  { font-size: 12px; color: #475569; margin-top: 4px; }

.weather-verdict-large {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 20px;
  border-radius: 10px;
  border: 2px solid;
  font-weight: 800;
  font-size: 13px;
}
.weather-verdict-large i { font-size: 28px; }

.weather-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.weather-detail-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 10px;
  padding: 10px 14px;
}
.weather-detail-item > i { font-size: 18px; color: #475569; width: 22px; text-align: center; }
.wdi-val   { font-size: 15px; font-weight: 700; color: #e2e8f0; }
.wdi-label { font-size: 10px; color: #475569; margin-top: 2px; }

/* ─── AI Advisor Panel ────────────────────────────────────────────────── */
#advisor-popup.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: all;
}
.advisor-tip {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.advisor-tip-critical { border-left: 3px solid #f87171; }
.advisor-tip-warning  { border-left: 3px solid #fbbf24; }
.advisor-tip-info     { border-left: 3px solid #38bdf8; }
.advisor-tip-ok       { border-left: 3px solid #4ade80; }
.advisor-tip-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.advisor-icon { font-size: 14px; }
.advisor-title { font-size: 12px; font-weight: 600; color: #e2e8f0; flex: 1; }
.advisor-level-tag {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255,255,255,.08);
  color: #94a3b8;
}
.advisor-body { font-size: 11px; color: #94a3b8; line-height: 1.5; }
.advisor-empty { text-align: center; color: #475569; font-size: 12px; padding: 20px 0; }

/* ─── Stats KPI cards ─────────────────────────────────────────────────── */
.v3-kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
  transition: border-color .2s;
}
.v3-kpi-card:hover { border-color: rgba(56,189,248,.3); }
.v3-kpi-val {
  font-size: 24px;
  font-weight: 700;
  color: #f1f5f9;
  font-variant-numeric: tabular-nums;
  margin-bottom: 4px;
}
.v3-kpi-lbl {
  font-size: 11px;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

/* ── Phase 8 A3：飛前安全檢查清單 ───────────────────────────────────────── */
/* 不使用 backdrop-filter，避免背景 DOM 頻繁更新時重新計算模糊 */
.preflight-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.preflight-overlay[style*="flex"] { display: flex; }
.preflight-box    { width: 500px; max-width: 96vw; max-height: 82vh; display: flex; flex-direction: column; }
.pf-drone-label   { font-size: 11px; color: var(--text-dim); padding: 0 0 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.preflight-list   { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 8px 0; }
.pf-item          { display: flex; align-items: center; gap: 10px; padding: 9px 12px;
                    border-radius: 8px; background: rgba(255,255,255,0.03);
                    border: 1px solid var(--border, rgba(255,255,255,0.08)); transition: border-color .2s; }
.pf-item.pass     { border-color: rgba(74,222,128,.35); background: rgba(74,222,128,.04); }
.pf-item.fail     { border-color: rgba(239,68,68,.35);  background: rgba(239,68,68,.04); }
.pf-item.pending  { border-color: rgba(148,163,184,.15); }
.pf-icon          { font-size: 15px; flex-shrink: 0; width: 20px; text-align: center; }
.pf-body          { flex: 1; min-width: 0; }
.pf-label         { font-size: 13px; color: var(--text-main, #f1f5f9); font-weight: 500; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pf-value         { font-size: 11px; color: var(--text-dim, #64748b); margin-top: 2px; }
.pf-note          { font-size: 10px; color: #f87171; margin-top: 2px; }
.pf-critical      { font-size: 9px; background: rgba(239,68,68,.15); color: #ef4444;
                    border-radius: 3px; padding: 1px 5px; font-weight: 700; text-transform: uppercase; white-space: nowrap; }
.pf-actions       { display: flex; gap: 5px; flex-shrink: 0; }
.pf-status-ok      { text-align: center; color: #4ade80; font-weight: 700; font-size: 13px; padding: 10px 0 4px; }
.pf-status-pending { text-align: center; color: #fbbf24; font-size: 13px; padding: 10px 0 4px; }
.btn-danger { background: rgba(239,68,68,.2); color: #f87171; border: 1px solid rgba(239,68,68,.3); border-radius: 5px; padding: 3px 8px; cursor: pointer; font-size: 11px; }
.btn-danger:hover { background: rgba(239,68,68,.35); }
.btn-success { background: rgba(74,222,128,.15); color: #4ade80; border: 1px solid rgba(74,222,128,.35); border-radius: 5px; padding: 3px 8px; cursor: pointer; font-size: 11px; }
.btn-success:hover { background: rgba(74,222,128,.28); }
.btn-sm.btn-success { background: rgba(74,222,128,.15); color: #4ade80; border-color: rgba(74,222,128,.4); }
.btn-sm.btn-success:hover { background: rgba(74,222,128,.28); }
.btn-sm.btn-danger  { background: rgba(239,68,68,.15); color: #f87171; border-color: rgba(239,68,68,.4); }
.btn-sm.btn-danger:hover  { background: rgba(239,68,68,.28); }

/* ── Phase 8 A4：多機廣播指令面板 ────────────────────────────────────────── */
.fc-drone-row:hover { background: rgba(255,255,255,.07) !important; }

/* ── Phase 8 A1：任務規劃編輯器 ─────────────────────────────────────────── */
.mission-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-card, #0f172a);
  border-radius: 8px;
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  flex-wrap: wrap;
  margin-top: 6px;
}
.mission-editor-toolbar .map-tool-btn {
  width: 32px; height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border, rgba(255,255,255,0.1));
  background: rgba(255,255,255,0.04);
  color: var(--text-dim, #94a3b8);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.mission-editor-toolbar .map-tool-btn:hover { background: rgba(56,189,248,0.15); color: #38bdf8; }
.mission-editor-toolbar .map-tool-btn.active { background: rgba(56,189,248,0.2); color: #38bdf8; border-color: rgba(56,189,248,0.4); }
.me-divider { width: 1px; height: 20px; background: var(--border, rgba(255,255,255,0.08)); flex-shrink: 0; }
.me-stat    { font-size: 11px; color: var(--text-dim, #64748b); white-space: nowrap; }

/* 航點標記 */
.wp-marker {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent-blue, #0ea5e9);
  color: #fff;
  font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid rgba(255,255,255,0.75);
  box-shadow: 0 2px 8px rgba(0,0,0,0.55);
  cursor: pointer;
  transition: transform 0.12s;
}
.wp-marker:hover { transform: scale(1.18); }

/* 航點詳情面板 */
.wp-detail-panel {
  position: absolute;
  top: 12px; right: 12px;
  z-index: 1000;
  width: 220px;
  background: var(--bg-card, #0f172a);
  border: 1px solid var(--border, rgba(255,255,255,0.1));
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}
.wp-detail-header {
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 700; margin-bottom: 10px;
  color: var(--accent-blue, #38bdf8);
  font-size: 13px;
}
.wp-detail-body label {
  display: block; font-size: 10px;
  color: var(--text-dim, #64748b);
  text-transform: uppercase; letter-spacing: .4px;
  margin: 8px 0 3px;
}
.wp-detail-body input,
.wp-detail-body select {
  width: 100%; box-sizing: border-box;
  background: var(--bg-input, rgba(255,255,255,0.06));
  border: 1px solid var(--border, rgba(255,255,255,0.1));
  color: var(--text-main, #f1f5f9);
  padding: 5px 8px;
  border-radius: 5px;
  font-size: 12px;
  outline: none;
}
.wp-detail-body input:focus,
.wp-detail-body select:focus { border-color: rgba(56,189,248,0.5); }

/* 上傳任務摘要 */
.mission-summary {
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(56,189,248,0.07);
  border: 1px solid rgba(56,189,248,0.15);
  border-radius: 7px;
  font-size: 12px;
  color: var(--text-dim, #94a3b8);
  line-height: 1.6;
}
.mission-summary strong { color: var(--text-main, #f1f5f9); }
