:root {
  --bg: #02050d;
  --panel: rgba(10, 18, 34, 0.72);
  --panel-border: rgba(56, 189, 248, 0.14);
  --panel-border-hover: rgba(56, 189, 248, 0.4);
  --text: #e2e8f0;
  --text-muted: #64748b;
  --text-dim: #475569;
  --accent: #22d3ee;
  --accent-glow: rgba(34, 211, 238, 0.4);
  --danger: #ff3b5c;
  --danger-glow: rgba(255, 59, 92, 0.5);
  --missile: #ff8c42;
  --ballistic: #c084fc;
  --artillery: #fbbf24;
  --safe: #34d399;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); overflow: hidden; }
body {
  height: 100dvh; display: flex; flex-direction: column; position: relative;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(14, 165, 233, 0.08), transparent 70%),
    radial-gradient(ellipse 60% 50% at 50% 100%, rgba(34, 211, 238, 0.06), transparent 70%),
    linear-gradient(180deg, #02050d 0%, #030812 100%);
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(rgba(56, 189, 248, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 100% 100% at 50% 50%, #000 30%, transparent 90%);
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* HEADER */
header {
  position: relative; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 28px;
  background: rgba(3, 7, 18, 0.6);
  border-bottom: 1px solid var(--panel-border);
  backdrop-filter: blur(20px) saturate(180%);
}
.logo { display: flex; align-items: center; gap: 14px; }
.logo svg {
  width: 38px; height: 38px; stroke: var(--accent);
  filter: drop-shadow(0 0 12px var(--accent-glow));
  animation: logoPulse 3s ease-in-out infinite;
}
@keyframes logoPulse {
  0%, 100% { filter: drop-shadow(0 0 8px var(--accent-glow)); }
  50% { filter: drop-shadow(0 0 20px var(--accent-glow)); }
}
.logo-text h1 {
  margin: 0; font-size: 20px; font-weight: 800;
  letter-spacing: 0.08em; color: #fff;
  text-shadow: 0 0 20px rgba(34, 211, 238, 0.3);
}
.logo-text h1 span { color: var(--accent); font-weight: 900; }
.logo-text p { margin: 0; font-size: 9px; color: var(--text-muted); letter-spacing: 0.3em; text-transform: uppercase; font-weight: 600; }
.header-center { display: flex; gap: 12px; }
.header-widget {
  display: flex; align-items: center; gap: 12px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--panel-border);
  padding: 8px 18px; border-radius: 40px;
  backdrop-filter: blur(10px);
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative; overflow: hidden;
}
.header-widget::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(34, 211, 238, 0.06), transparent);
  transform: translateX(-100%); transition: transform 0.6s;
}
.header-widget:hover::before { transform: translateX(100%); }
.header-widget svg { width: 18px; height: 18px; color: var(--accent); }
.header-widget-text { display: flex; flex-direction: column; line-height: 1.2; }
.header-widget-text span:first-child { font-size: 12px; font-weight: 700; color: #fff; font-family: var(--mono); }
.header-widget-text span:last-child { font-size: 9.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.header-widget.status-safe { border-color: rgba(52, 211, 153, 0.3); background: rgba(52, 211, 153, 0.06); }
.header-widget.status-safe svg { color: var(--safe); }
.header-widget.status-danger {
  border-color: rgba(255, 59, 92, 0.5);
  background: rgba(255, 59, 92, 0.08);
  animation: dangerPulse 2s ease-in-out infinite;
}
.header-widget.status-danger svg { color: var(--danger); }
@keyframes dangerPulse {
  0%, 100% { box-shadow: 0 0 16px rgba(255, 59, 92, 0.2); }
  50% { box-shadow: 0 0 32px rgba(255, 59, 92, 0.5); }
}
#authBtn {
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.1), rgba(14, 165, 233, 0.1));
  border: 1px solid rgba(34, 211, 238, 0.3);
  padding: 9px 20px; border-radius: 40px;
  font-size: 12.5px; font-weight: 700;
  transition: all 0.25s;
  font-family: var(--mono);
}
#authBtn:hover {
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.2), rgba(14, 165, 233, 0.2));
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
  transform: translateY(-1px);
}
#userAvatar { width: 26px; height: 26px; border-radius: 50%; display: none; border: 2px solid var(--accent); }

/* MAIN */
.main-container { display: flex; flex: 1; overflow: hidden; position: relative; z-index: 1; }
.sidebar { width: 340px; padding: 20px; display: flex; flex-direction: column; gap: 14px; z-index: 10; pointer-events: none; overflow-y: auto; scrollbar-width: none; }
.sidebar::-webkit-scrollbar { display: none; }
.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px; padding: 18px;
  backdrop-filter: blur(24px) saturate(150%);
  pointer-events: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.04);
  transition: border-color 0.3s, transform 0.3s;
  animation: cardIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}
.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.1s; }
.card:nth-child(3) { animation-delay: 0.15s; }
@keyframes cardIn { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
.card:hover { border-color: var(--panel-border-hover); }
.card-status { position: relative; overflow: hidden; }
.status-glow { position: absolute; top: -60px; left: -60px; width: 180px; height: 180px; filter: blur(70px); border-radius: 50%; opacity: 0.25; transition: background 0.5s; }
.status-glow.safe { background: var(--safe); }
.status-glow.hot { background: var(--danger); }
.card-title { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.15em; margin-bottom: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; font-family: var(--mono); }
.card-title svg { color: var(--accent); opacity: 0.8; }
.status-title { display: flex; align-items: center; gap: 12px; font-size: 26px; font-weight: 800; margin-bottom: 6px; letter-spacing: -0.02em; position: relative; }
.status-title.safe { color: var(--safe); text-shadow: 0 0 30px rgba(52,211,153,0.4); }
.status-title.hot { color: var(--danger); text-shadow: 0 0 30px var(--danger-glow); }
.status-title svg { animation: shieldPulse 2.5s ease-in-out infinite; }
@keyframes shieldPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.status-subtitle { font-size: 12.5px; color: var(--text-muted); margin-bottom: 14px; }
.status-time { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-dim); border-top: 1px solid rgba(255,255,255,0.06); padding-top: 14px; font-family: var(--mono); }
.status-time svg { width: 13px; height: 13px; color: var(--accent); }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-box {
  background: rgba(2,6,16,0.6);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 12px; padding: 12px;
  display: flex; align-items: center; gap: 12px;
  transition: all 0.25s; position: relative; overflow: hidden;
}
.stat-box:hover { border-color: rgba(34,211,238,0.3); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.4); }
.stat-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; transition: transform 0.3s; }
.stat-box:hover .stat-icon { transform: scale(1.1) rotate(-5deg); }
.stat-icon.danger { background: rgba(255,59,92,0.15); color: var(--danger); box-shadow: inset 0 0 12px rgba(255,59,92,0.2); }
.stat-icon.safe { background: rgba(52,211,153,0.15); color: var(--safe); box-shadow: inset 0 0 12px rgba(52,211,153,0.2); }
.stat-icon.info { background: rgba(34,211,238,0.15); color: var(--accent); box-shadow: inset 0 0 12px rgba(34,211,238,0.2); }
.stat-icon.muted { background: rgba(100,116,139,0.15); color: var(--text-muted); }
.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 18px; font-weight: 800; color: #fff; font-family: var(--mono); line-height: 1; }
.stat-label { font-size: 9.5px; color: var(--text-muted); margin-top: 3px; text-transform: uppercase; letter-spacing: 0.05em; }
.event-list { display: flex; flex-direction: column; gap: 4px; }
.event-item { display: flex; align-items: center; justify-content: space-between; font-size: 12px; padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,0.04); animation: slideIn 0.3s ease-out; }
@keyframes slideIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
.event-item:last-child { border: none; }
.event-time { color: var(--accent); width: 44px; font-family: var(--mono); font-size: 11px; opacity: 0.8; }
.event-name { flex: 1; color: #e2e8f0; font-weight: 500; }
.event-status { font-size: 10px; color: var(--text-muted); }
.event-status.safe { color: var(--safe); }
.search-box { margin-top: auto; display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--panel-border); padding: 11px 16px; border-radius: 14px; pointer-events: auto; backdrop-filter: blur(10px); transition: all 0.3s; }
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34,211,238,0.1), 0 0 24px rgba(34,211,238,0.15); }
.search-box svg { color: var(--text-muted); width: 16px; height: 16px; }
.search-box input { background: none; border: none; outline: none; color: #fff; flex: 1; font-size: 12.5px; font-family: var(--font); }
.search-box input::placeholder { color: var(--text-dim); }
.search-box kbd { background: rgba(255,255,255,0.06); padding: 2px 7px; border-radius: 5px; font-size: 10px; color: var(--text-muted); font-family: var(--mono); border: 1px solid rgba(255,255,255,0.05); }

/* MAP */
#map { flex: 1; position: relative; background: radial-gradient(ellipse at center, rgba(10,25,45,0.5) 0%, transparent 75%); }
#svg { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; position: relative; z-index: 2; }
#svg text { font-weight: 600; font-size: 11px; fill: #cbd5e1; letter-spacing: 0.02em; pointer-events: none; text-shadow: 0 1px 4px rgba(0,0,0,0.9); font-family: var(--font); }
#svg .lbl-glow { filter: drop-shadow(0 1px 3px rgba(0,0,0,0.9)); }
#svg .p { animation: alertPulse 1.8s ease-in-out infinite; stroke-dasharray: 4 3; }
@keyframes alertPulse { 0%,100% { filter: drop-shadow(0 0 6px currentColor); } 50% { filter: drop-shadow(0 0 20px currentColor); } }

/* RIGHT CONTROLS */
#rc { position: absolute; right: 22px; top: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 10; }
.rb { width: 46px; height: 46px; border-radius: 14px; background: var(--panel); border: 1px solid var(--panel-border); display: grid; place-items: center; position: relative; transition: all 0.25s cubic-bezier(0.4,0,0.2,1); color: var(--accent); backdrop-filter: blur(15px); box-shadow: 0 4px 16px rgba(0,0,0,0.4); }
.rb:hover { background: rgba(34,211,238,0.1); border-color: var(--accent); box-shadow: 0 0 24px var(--accent-glow); transform: translateY(-2px); }
.rb:active { transform: scale(0.94); }
#snd.on { background: rgba(52,211,153,0.15); color: var(--safe); border-color: rgba(52,211,153,0.5); box-shadow: 0 0 20px rgba(52,211,153,0.3); }
#drone.on { background: rgba(251,191,36,0.15); color: var(--artillery); border-color: rgba(251,191,36,0.5); }
#cnt { position: absolute; top: -7px; right: -7px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: linear-gradient(135deg, #ff3b5c, #ff6b3d); color: #fff; font-size: 10px; font-weight: 800; display: none; place-items: center; box-shadow: 0 0 14px var(--danger-glow); font-family: var(--mono); }

/* DOCK */
#dock { position: absolute; left: 50%; transform: translateX(-50%); bottom: 22px; display: flex; gap: 6px; padding: 8px 12px; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 20px; box-shadow: 0 12px 40px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.05); z-index: 10; backdrop-filter: blur(24px); transition: opacity 0.3s; }
.dk { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 6px 14px; border-radius: 12px; transition: all 0.25s cubic-bezier(0.4,0,0.2,1); }
.dk .ring { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: rgba(255,255,255,0.03); color: var(--c); transition: all 0.25s; border: 1px solid transparent; }
.dk:hover .ring { background: rgba(255,255,255,0.08); transform: translateY(-2px); border-color: var(--c); box-shadow: 0 0 20px color-mix(in srgb, var(--c) 40%, transparent); }
.dk:active .ring { transform: scale(0.92); }
.dk em { font-style: normal; font-size: 10px; color: var(--text-muted); font-weight: 600; transition: color 0.2s; text-transform: uppercase; letter-spacing: 0.05em; }
.dk:hover em { color: #fff; }

/* HINT */
#hint { position: absolute; left: 50%; transform: translateX(-50%); top: 22px; background: rgba(10,18,34,0.95); border: 1px solid var(--accent); color: #fff; padding: 11px 22px; border-radius: 12px; font-size: 13px; display: none; max-width: 80%; text-align: center; box-shadow: 0 0 30px var(--accent-glow), 0 8px 24px rgba(0,0,0,0.6); z-index: 30; backdrop-filter: blur(15px); font-weight: 500; }
#hint.show { display: block; animation: hintIn 0.25s ease-out; }
@keyframes hintIn { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* DRONE CARD */
#dronecard { position: absolute; left: 50%; transform: translateX(-50%); bottom: 96px; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 14px; padding: 12px 22px; display: none; align-items: center; gap: 18px; box-shadow: 0 12px 40px rgba(0,0,0,0.6); z-index: 10; backdrop-filter: blur(20px); }
#dronecard.show { display: flex; animation: hintIn 0.3s ease-out; }
#dronecard label { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 12.5px; }
#dronecard input[type=range] { accent-color: var(--artillery); width: 120px; }
.pill { padding: 7px 14px; border-radius: 8px; background: rgba(255,255,255,0.05); border: 1px solid var(--panel-border); font-size: 12px; font-weight: 600; transition: 0.2s; }
.pill:hover { background: rgba(255,255,255,0.1); color: #fff; border-color: var(--accent); }

/* DRAWER */
#drawer { position: absolute; right: 22px; top: 84px; width: 320px; max-height: calc(100% - 110px); overflow-y: auto; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 16px; padding: 20px; box-shadow: 0 12px 40px rgba(0,0,0,0.6); display: none; z-index: 15; backdrop-filter: blur(24px); }
#drawer.open { display: block; animation: hintIn 0.3s ease-out; }
#drawer h3 { margin: 0 0 14px; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.12em; display: flex; justify-content: space-between; align-items: center; font-family: var(--mono); }
#list .it { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 11px 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
#list .it:last-child { border-bottom: 0; }
#list .it .n { flex: 1; min-width: 100px; font-weight: 600; font-size: 13px; }
.chip { border: 1px solid; border-radius: 8px; padding: 4px 9px; font-size: 10.5px; font-weight: 700; background: transparent; cursor: pointer; transition: all 0.2s; font-family: var(--mono); }
.chip:hover { background: rgba(255,255,255,0.05); transform: scale(1.05); }
.empty { color: var(--text-muted); font-size: 13px; padding: 16px 0; font-style: italic; text-align: center; }
#log { font-size: 12px; line-height: 1.7; color: var(--text-muted); margin-top: 10px; font-family: var(--mono); }
#log div:first-child { color: var(--accent); }
.note { color: var(--text-muted); font-size: 11px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--panel-border); }

/* ZOOM */
.zoom-controls { position: absolute; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 8px; z-index: 10; }
.zoom-controls button { width: 42px; height: 42px; border-radius: 12px; background: var(--panel); border: 1px solid var(--panel-border); color: #fff; font-size: 20px; font-weight: 300; display: grid; place-items: center; backdrop-filter: blur(15px); transition: 0.2s; box-shadow: 0 4px 16px rgba(0,0,0,0.4); }
.zoom-controls button:hover { background: rgba(34,211,238,0.1); border-color: var(--accent); color: var(--accent); }

.clock-colon { animation: blink 1s step-end infinite; color: var(--accent); font-weight: 700; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

@media (max-width: 800px) {
  .sidebar { display: none; }
  .header-center { display: none; }
  #dock { bottom: 10px; padding: 6px; }
  .dk { padding: 6px 10px; }
  .dk em { display: none; }
}