@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg: #050508; --bg2: #0a0a10; --bg3: #10101a; --bg4: #161622;
  --border: #1a1a2e; --border2: #252545;
  --lime: #a3ff00; --lime-dim: rgba(163,255,0,0.08); --lime-glow: rgba(163,255,0,0.15);
  --azure: #00aaff; --azure-dim: rgba(0,170,255,0.08);
  --thermal: #ff6600; --thermal-red: #ff2244;
  --red: #ff3344; --red-dim: rgba(255,51,68,0.08);
  --warn: #ffaa00; --warn-dim: rgba(255,170,0,0.08);
  --purple: #bb66ff; --purple-dim: rgba(187,102,255,0.08);
  --pink: #ff44aa; --ok: #a3ff00;
  --text: #d0d0e0; --text2: #5555aa; --text3: #3a3a6a;
  --font: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  --radius: 6px; --radius-sm: 4px;
  --shadow: 0 2px 16px rgba(0,0,0,0.6);
  --glow-lime: 0 0 12px rgba(163,255,0,0.2);
  --glow-azure: 0 0 12px rgba(0,170,255,0.2);
  --glow-red: 0 0 12px rgba(255,51,68,0.2);
}

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

/* ═══ ANIMATED GRID ═══ */
body {
  background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 12px; min-height: 100vh; overflow-x: hidden; position: relative;
}
body::before {
  content: ''; position: fixed; top:0; left:0; right:0; bottom:0;
  background: linear-gradient(rgba(163,255,0,0.025) 1px, transparent 1px),
              linear-gradient(90deg, rgba(163,255,0,0.025) 1px, transparent 1px);
  background-size: 48px 48px; animation: gridScroll 20s linear infinite;
  pointer-events: none; z-index: 0;
}
@keyframes gridScroll { 0% { background-position:0 0 } 100% { background-position:48px 48px } }

/* ═══ SCANLINES ═══ */
body::after {
  content: ''; position: fixed; top:0; left:0; right:0; bottom:0;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(163,255,0,0.006) 2px, rgba(163,255,0,0.006) 4px);
  pointer-events: none; z-index: 9999;
}

.vignette {
  position: fixed; top:0; left:0; right:0; bottom:0;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(5,5,8,0.7) 100%);
  pointer-events: none; z-index: 9998;
}

/* ═══ HEADER ═══ */
.header {
  background: linear-gradient(135deg, var(--bg2), var(--bg3));
  border-bottom: 1px solid var(--border); padding: 8px 20px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100; backdrop-filter: blur(12px);
}
.header::after {
  content: ''; position: absolute; bottom: -1px; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--lime), transparent); opacity: 0.3;
}
.header-left { display: flex; align-items: center; gap: 14px; }
.logo {
  font-size: 16px; font-weight: 800; color: var(--lime);
  text-shadow: 0 0 20px rgba(163,255,0,0.3), 0 0 40px rgba(163,255,0,0.08);
  letter-spacing: 4px; user-select: none; cursor: default;
}
.logo em { font-style: normal; color: var(--azure); text-shadow: 0 0 20px rgba(0,170,255,0.3); }
.separator { width: 1px; height: 20px; background: var(--border2); }
.status-cluster { display: flex; align-items: center; gap: 8px; }
.status-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--lime);
  box-shadow: 0 0 6px var(--lime), 0 0 12px rgba(163,255,0,0.2);
  animation: pulse 2.5s ease-in-out infinite;
}
.status-dot.off { background: var(--red); box-shadow: 0 0 6px var(--red); animation: none; }
.status-dot.warn { background: var(--warn); box-shadow: 0 0 6px var(--warn); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity:1; transform:scale(1) } 50% { opacity:0.4; transform:scale(0.8) } }
#connText { font-size: 9px; color: var(--text2); text-transform: uppercase; letter-spacing: 1.5px; font-weight: 500; }
.header-right { display: flex; align-items: center; gap: 16px; }
.header-stat { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.header-stat .value { font-size: 13px; color: var(--lime); font-weight: 700; letter-spacing: 0.5px; text-shadow: 0 0 8px rgba(163,255,0,0.15); }
.header-stat .label { font-size: 8px; color: var(--text3); text-transform: uppercase; letter-spacing: 1px; }

/* ═══ LAYOUT ═══ */
.layout { display: flex; min-height: calc(100vh - 44px); position: relative; z-index: 1; }

/* ═══ SIDEBAR ═══ */
.sidebar {
  width: 200px; min-width: 200px; background: var(--bg2);
  border-right: 1px solid var(--border); padding: 4px 0;
  position: sticky; top: 44px; height: calc(100vh - 44px);
  overflow-y: auto; transition: width 0.25s ease, min-width 0.25s ease;
}
.sidebar.collapsed { width: 44px; min-width: 44px; }
.sidebar.collapsed .nav-label, .sidebar.collapsed .nav-section-title, .sidebar.collapsed .nav-badge { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 9px 0; border-left: none; }
.sidebar.collapsed .nav-icon { margin: 0; }
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.nav-section-title { padding: 10px 14px 3px; font-size: 8px; text-transform: uppercase; letter-spacing: 2.5px; color: var(--text3); font-weight: 600; margin-top: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 14px;
  cursor: pointer; transition: all 0.12s ease; border-left: 3px solid transparent;
  color: var(--text); text-decoration: none; font-size: 11px; position: relative; font-weight: 400;
}
.nav-item:hover { background: var(--bg3); color: var(--lime); }
.nav-item.active {
  background: linear-gradient(90deg, var(--lime-dim), transparent);
  border-left-color: var(--lime); color: var(--lime); font-weight: 500;
}
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%; background: var(--lime); box-shadow: 0 0 8px var(--lime); border-radius: 0 2px 2px 0;
}
.nav-icon { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }
.nav-label { flex: 1; white-space: nowrap; overflow: hidden; }
.nav-badge { font-size: 7px; padding: 1px 5px; border-radius: 6px; background: var(--red); color: #fff; font-weight: 700; letter-spacing: 0.5px; animation: pulse 1.2s infinite; }
.nav-badge.lime { background: var(--lime); color: #000; }

/* ═══ MAIN ═══ */
.main { flex: 1; padding: 12px 16px; overflow-y: auto; min-width: 0; }
.page { display: none; animation: fadeIn 0.15s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity:0; transform:translateY(4px) } to { opacity:1; transform:translateY(0) } }

/* ═══ CARDS ═══ */
.card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 10px; overflow: hidden; box-shadow: var(--shadow); transition: border-color 0.2s;
}
.card:hover { border-color: var(--border2); }
.card-header {
  padding: 8px 12px; background: linear-gradient(135deg, var(--bg3), var(--bg2));
  border-bottom: 1px solid var(--border); font-size: 11px; font-weight: 600;
  color: var(--lime); display: flex; align-items: center; justify-content: space-between; letter-spacing: 0.5px;
}
.card-header .header-actions { display: flex; gap: 4px; }
.card-body { padding: 12px; }

/* ═══ GRID ═══ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media(max-width:1200px) { .grid-4 { grid-template-columns: 1fr 1fr } }
@media(max-width:1000px) { .grid-3 { grid-template-columns: 1fr 1fr } }
@media(max-width:800px) { .grid-2,.grid-3,.grid-4 { grid-template-columns:1fr } .sidebar { width:44px;min-width:44px } .nav-label,.nav-section-title,.nav-badge { display:none } .nav-item { justify-content:center;padding:9px 0;border-left:none } .nav-icon { margin:0 } }

/* ═══ BUTTONS ═══ */
.btn {
  display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg3);
  color: var(--text); font-family: var(--font); font-size: 10px; cursor: pointer;
  transition: all 0.12s ease; text-decoration: none; white-space: nowrap;
  user-select: none; position: relative; overflow: hidden; font-weight: 500; letter-spacing: 0.3px;
}
.btn:hover { border-color: var(--lime); color: var(--lime); background: var(--lime-dim); box-shadow: var(--glow-lime); }
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--lime-dim); border-color: rgba(163,255,0,0.25); color: var(--lime); }
.btn-primary:hover { background: rgba(163,255,0,0.15); border-color: var(--lime); box-shadow: 0 0 10px rgba(163,255,0,0.12); }
.btn-azure { background: var(--azure-dim); border-color: rgba(0,170,255,0.25); color: var(--azure); }
.btn-azure:hover { background: rgba(0,170,255,0.15); border-color: var(--azure); box-shadow: var(--glow-azure); }
.btn-danger { background: var(--red-dim); border-color: rgba(255,51,68,0.25); color: var(--red); }
.btn-danger:hover { background: rgba(255,51,68,0.15); border-color: var(--red); box-shadow: var(--glow-red); }
.btn-warn { background: var(--warn-dim); border-color: rgba(255,170,0,0.25); color: var(--warn); }
.btn-warn:hover { background: rgba(255,170,0,0.15); border-color: var(--warn); }
.btn-purple { background: var(--purple-dim); border-color: rgba(187,102,255,0.25); color: var(--purple); }
.btn-purple:hover { background: rgba(187,102,255,0.15); border-color: var(--purple); }
.btn-active { animation: btnPulse 1.5s ease-in-out infinite; }
@keyframes btnPulse { 0%,100% { box-shadow:0 0 4px rgba(163,255,0,0.15) } 50% { box-shadow:0 0 16px rgba(163,255,0,0.3) } }
.btn-sm { padding: 3px 8px; font-size: 9px; }
.btn-xs { padding: 2px 5px; font-size: 8px; }
.btn-group { display: flex; flex-wrap: wrap; gap: 4px; }

/* ═══ FORMS ═══ */
.input {
  width: 100%; padding: 5px 8px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-family: var(--font);
  font-size: 11px; outline: none; transition: border-color 0.12s, box-shadow 0.12s;
}
.input:focus { border-color: var(--lime); box-shadow: 0 0 0 2px rgba(163,255,0,0.08); }
.input-sm { padding: 3px 6px; font-size: 10px; }
label { display: block; font-size: 9px; color: var(--text2); margin-bottom: 3px; text-transform: uppercase; letter-spacing: 0.8px; font-weight: 500; }
.form-row { display: flex; gap: 6px; align-items: flex-end; margin-bottom: 6px; }
.form-row > div { flex: 1; }
select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%235555aa'%3E%3Cpath d='M5 7L1 3h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 6px center; padding-right: 20px;
}

/* ═══ TABLES ═══ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 10px; }
th { text-align: left; padding: 6px 8px; background: var(--bg3); color: var(--text2); font-size: 8px; text-transform: uppercase; letter-spacing: 1.2px; border-bottom: 2px solid var(--border); font-weight: 600; position: sticky; top: 0; }
td { padding: 5px 8px; border-bottom: 1px solid rgba(26,26,46,0.5); transition: background 0.08s; }
tr:hover td { background: var(--lime-dim); }

/* ═══ BADGES ═══ */
.badge { display: inline-block; padding: 1px 6px; border-radius: 3px; font-size: 8px; font-weight: 700; letter-spacing: 0.5px; }
.badge-lime { background: var(--lime-dim); color: var(--lime); border: 1px solid rgba(163,255,0,0.2); }
.badge-azure { background: var(--azure-dim); color: var(--azure); border: 1px solid rgba(0,170,255,0.2); }
.badge-red { background: var(--red-dim); color: var(--red); border: 1px solid rgba(255,51,68,0.2); }
.badge-orange { background: var(--warn-dim); color: var(--warn); border: 1px solid rgba(255,170,0,0.2); }
.badge-purple { background: var(--purple-dim); color: var(--purple); border: 1px solid rgba(187,102,255,0.2); }
.badge-gray { background: rgba(85,85,170,0.1); color: var(--text2); border: 1px solid rgba(85,85,170,0.15); }

/* ═══ CONSOLE ═══ */
.console {
  background: #020204; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px; height: 260px; overflow-y: auto; font-size: 10px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-all; position: relative; font-family: var(--font);
}
.console::-webkit-scrollbar { width: 3px; }
.console::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.console-line { display: flex; gap: 5px; padding: 0; border-bottom: 1px solid rgba(26,26,46,0.2); animation: lineIn 0.1s ease; }
@keyframes lineIn { from { opacity:0; transform:translateX(-3px) } to { opacity:1; transform:translateX(0) } }
.log-time { color: var(--text3); min-width: 52px; flex-shrink: 0; }
.log-tag { min-width: 34px; font-weight: 700; flex-shrink: 0; }
.log-msg { flex: 1; }
.log-inf { color: var(--azure); } .log-wrn { color: var(--warn); } .log-err { color: var(--red); }
.log-ok { color: var(--lime); } .log-cmd { color: var(--purple); } .log-sys { color: var(--text2); }

/* ═══ STATS ═══ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 6px; }
.stat-box {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 8px; text-align: center; transition: border-color 0.2s, transform 0.12s;
  position: relative; overflow: hidden;
}
.stat-box::before { content: ''; position: absolute; top:0; left:0; right:0; height:1px; background:linear-gradient(90deg,transparent,var(--lime),transparent); opacity:0; transition:opacity 0.2s; }
.stat-box:hover { border-color: var(--border2); transform: translateY(-1px); }
.stat-box:hover::before { opacity: 0.4; }
.stat-value { font-size: 18px; font-weight: 700; color: var(--lime); text-shadow: 0 0 8px rgba(163,255,0,0.12); transition: color 0.3s; letter-spacing: 0.5px; }
.stat-value.warn { color: var(--warn); text-shadow: 0 0 8px rgba(255,170,0,0.12); }
.stat-value.danger { color: var(--red); text-shadow: 0 0 8px rgba(255,51,68,0.12); }
.stat-value.azure { color: var(--azure); text-shadow: 0 0 8px rgba(0,170,255,0.12); }
.stat-label { font-size: 8px; color: var(--text2); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.8px; font-weight: 500; }

/* ═══ SIGNAL BARS ═══ */
.signal { display: inline-flex; align-items: flex-end; gap: 1px; height: 12px; }
.signal .bar { width: 3px; background: var(--border); border-radius: 1px; transition: background 0.2s; }
.signal .bar:nth-child(1) { height: 3px; } .signal .bar:nth-child(2) { height: 5px; }
.signal .bar:nth-child(3) { height: 8px; } .signal .bar:nth-child(4) { height: 12px; }
.signal.s4 .bar { background: var(--lime); box-shadow: 0 0 3px rgba(163,255,0,0.3); }
.signal.s3 .bar:nth-child(-n+3) { background: var(--azure); } .signal.s3 .bar:nth-child(4) { background: var(--border); }
.signal.s2 .bar:nth-child(-n+2) { background: var(--warn); } .signal.s2 .bar:nth-child(n+3) { background: var(--border); }
.signal.s1 .bar:nth-child(1) { background: var(--red); } .signal.s1 .bar:nth-child(n+2) { background: var(--border); }

/* ═══ RSSI GAUGE ═══ */
.rssi-gauge { position: relative; width: 100%; height: 60px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 6px; }
.rssi-gauge canvas { width: 100%; height: 100%; }
.rssi-value { position: absolute; bottom: 4px; right: 6px; font-size: 14px; font-weight: 700; color: var(--lime); text-shadow: 0 0 8px rgba(163,255,0,0.2); }

/* ═══ WATERFALL ═══ */
.waterfall { width: 100%; height: 120px; background: #020204; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; position: relative; }
.waterfall canvas { width: 100%; height: 100%; }

/* ═══ PROGRESS ═══ */
.progress { width: 100%; height: 4px; background: var(--bg); border-radius: 2px; overflow: hidden; margin-top: 4px; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--lime), var(--azure)); border-radius: 2px; transition: width 0.3s ease; position: relative; }
.progress-bar::after { content: ''; position: absolute; top:0; left:0; right:0; bottom:0; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent); animation: shimmer 2s infinite; }
@keyframes shimmer { 0% { transform:translateX(-100%) } 100% { transform:translateX(100%) } }

/* ═══ TOAST ═══ */
#toast-container { position: fixed; bottom: 12px; right: 12px; z-index: 10000; display: flex; flex-direction: column; gap: 4px; max-width: 320px; pointer-events: none; }
.toast { padding: 8px 12px; border-radius: var(--radius-sm); font-size: 10px; animation: slideIn 0.2s ease; border: 1px solid; display: flex; align-items: center; gap: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.5); backdrop-filter: blur(8px); pointer-events: auto; font-weight: 500; }
.toast-inf { background: rgba(0,170,255,0.06); border-color: rgba(0,170,255,0.25); color: var(--azure); }
.toast-ok { background: rgba(163,255,0,0.06); border-color: rgba(163,255,0,0.25); color: var(--lime); }
.toast-err { background: rgba(255,51,68,0.06); border-color: rgba(255,51,68,0.25); color: var(--red); }
.toast-wrn { background: rgba(255,170,0,0.06); border-color: rgba(255,170,0,0.25); color: var(--warn); }
.toast-icon { font-size: 12px; flex-shrink: 0; }
@keyframes slideIn { from { transform:translateX(100%);opacity:0 } to { transform:translateX(0);opacity:1 } }
@keyframes fadeOut { from { opacity:1 } to { opacity:0 } }

/* ═══ SPINNER ═══ */
.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--border); border-top-color: var(--lime); border-radius: 50%; animation: spin 0.5s linear infinite; }
@keyframes spin { to { transform:rotate(360deg) } }

/* ═══ SCROLLBAR ═══ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ═══ MONITOR OVERLAY ═══ */
.monitor-overlay { position: fixed; right: 12px; bottom: 12px; width: min(540px, calc(100vw - 24px)); max-height: 55vh; background: #020204; border: 1px solid var(--lime); border-radius: var(--radius); box-shadow: 0 0 24px rgba(163,255,0,0.1), 0 8px 32px rgba(0,0,0,0.6); z-index: 10001; display: none; overflow: hidden; }
.monitor-overlay.open { display: block; animation: fadeIn 0.15s ease; }
.monitor-header { height: 30px; background: var(--bg3); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 10px; color: var(--lime); font-size: 10px; font-weight: 600; letter-spacing: 0.5px; }
.monitor-body { height: calc(55vh - 30px); min-height: 160px; overflow-y: auto; padding: 8px; font-size: 10px; line-height: 1.6; white-space: pre-wrap; word-break: break-all; }
.monitor-body::-webkit-scrollbar { width: 3px; }
.monitor-body::-webkit-scrollbar-thumb { background: var(--border); }

/* ═══ KBD ═══ */
.kbd { display: inline-block; padding: 1px 4px; background: var(--bg3); border: 1px solid var(--border); border-radius: 2px; font-size: 8px; color: var(--text2); font-family: var(--font); }

/* ═══ GLOW BORDER ═══ */
.glow-border { position: relative; }
.glow-border::after { content: ''; position: absolute; inset: -1px; border-radius: inherit; padding: 1px; background: linear-gradient(135deg, var(--lime), transparent, var(--azure)); -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); -webkit-mask-composite: xor; mask-composite: exclude; opacity: 0.15; pointer-events: none; }

/* ═══ UTILITY ═══ */
.text-lime { color: var(--lime); } .text-azure { color: var(--azure); }
.text-warn { color: var(--warn); } .text-danger { color: var(--red); }
.text-purple { color: var(--purple); } .text-muted { color: var(--text2); }
.text-dim { color: var(--text3); } .text-pink { color: var(--pink); }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-sm { gap: 3px; }
