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

:root {
  --bg:         #0c110e;
  --bg-panel:   #111a14;
  --bg-hover:   #1a2b1e;
  --border:     #1e3024;
  --green-dim:  #2a5c38;
  --green-mid:  #3a8c50;
  --green-hi:   #4ec96a;
  --green-live: #00ff6a;
  --text:       #c8d8cc;
  --text-dim:   #5a7a60;
  --text-muted: #3a5040;
  --orange:     #e67e22;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Roboto', sans-serif;
  font-size: 13px;
  line-height: 1.5;
}

/* ── Layout ── */
#app {
  display: grid;
  grid-template-rows: 44px 42px 1fr;
  grid-template-columns: 220px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ── Topbar ── */
#topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
}
#topbar .title {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--green-hi);
  text-transform: uppercase;
}
#topbar .sep { color: var(--text-muted); }
#topbar .build-info {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
#live-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  margin-left: auto;
  transition: background 0.3s;
}
#live-dot.alive { background: var(--green-live); box-shadow: 0 0 6px var(--green-live); }
#live-label {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}
#live-dot.alive + #live-label { color: var(--green-hi); }

/* ── Navbar ── */
#navbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: stretch;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  gap: 4px;
}

.tab-btn {
  font-family: 'Roboto', sans-serif;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 0 18px;
  cursor: pointer;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--text-dim); }
.tab-btn.active {
  color: var(--green-hi);
  border-bottom-color: var(--green-hi);
}

/* ── Sidebar ── */
#sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg-panel);
  overflow-y: auto;
  padding: 12px 0;
}
.sidebar-section {
  padding: 0 14px;
  margin-bottom: 20px;
}
.sidebar-label {
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  color: var(--text-dim);
  font-size: 11px;
  padding: 2px 0;
}
.stat-row span:last-child { color: var(--text); }

#node-list { padding: 0; }
.node-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}
.node-item:hover { background: var(--bg-hover); }
.node-item.active {
  background: var(--bg-hover);
  border-left-color: var(--green-hi);
}
.node-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.node-dot.online  { background: var(--green-live); box-shadow: 0 0 4px var(--green-live); }
.node-dot.offline { background: var(--text-muted); }
.node-info { flex: 1; min-width: 0; }
.node-name {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.node-meta {
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.node-count {
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.node-hb {
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

/* ── Main content ── */
#main {
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.view { display: none; flex-direction: column; gap: 16px; }
.view.active { display: flex; }

/* ── Back button ── */
#back-btn, .back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 11px;
  color: var(--text-dim);
  background: none;
  border: 1px solid var(--border);
  padding: 5px 12px;
  cursor: pointer;
  letter-spacing: 0.05em;
  align-self: flex-start;
  transition: color 0.15s, border-color 0.15s;
}
#back-btn:hover, .back-btn:hover { color: var(--green-hi); border-color: var(--green-dim); }

/* ── RSSI chart ── */
#rssi-chart {
  width: 100%;
  display: block;
  background: var(--bg-panel);
  border: 1px solid var(--border);
}
#chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-swatch { width: 24px; height: 2px; flex-shrink: 0; }

.range-btns { display: flex; gap: 4px; }
.range-btn {
  font-family: 'Roboto', sans-serif;
  font-size: 10px;
  letter-spacing: 0.08em;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 3px 10px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.range-btn:hover  { color: var(--text-dim); border-color: var(--green-dim); }
.range-btn.active { color: var(--green-hi); border-color: var(--green-dim); }

.chart-btn {
  font-family: 'Roboto', sans-serif;
  font-size: 10px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 2px 8px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.chart-btn:hover { color: var(--green-hi); border-color: var(--green-dim); }

/* ── Section header ── */
.section-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.section-title {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.section-count { font-size: 10px; color: var(--text-muted); }

/* ── Node detail stats ── */
#detail-stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.stat-outer {
  border-radius: 8px;
  padding: 1px;
  background: radial-gradient(circle 120px at 0% 0%, var(--green-mid), var(--bg));
  position: relative;
  min-height: 90px;
}

.stat-dot {
  width: 4px;
  aspect-ratio: 1;
  position: absolute;
  background: var(--green-live);
  box-shadow: 0 0 7px var(--green-live);
  border-radius: 50%;
  z-index: 2;
  right: 10%;
  top: 10%;
  animation: statDotMove 30s linear infinite;
}
.stat-outer:nth-child(1)  .stat-dot { animation-delay:  0s; }
.stat-outer:nth-child(2)  .stat-dot { animation-delay: -1s; }
.stat-outer:nth-child(3)  .stat-dot { animation-delay: -2s; }
.stat-outer:nth-child(4)  .stat-dot { animation-delay: -3s; }
.stat-outer:nth-child(5)  .stat-dot { animation-delay: -4s; }
.stat-outer:nth-child(6)  .stat-dot { animation-delay: -5s; }
.stat-outer:nth-child(7)  .stat-dot { animation-delay: -6s; }
.stat-outer:nth-child(8)  .stat-dot { animation-delay: -7s; }
.stat-outer:nth-child(9)  .stat-dot { animation-delay: -8s; }
.stat-outer:nth-child(10) .stat-dot { animation-delay: -9s; }

@keyframes statDotMove {
  0%,  100% { top: 10%;                    right: 10%; }
  25%        { top: 10%;                    right: calc(100% - 18px); }
  50%        { top: calc(100% - 14px);     right: calc(100% - 18px); }
  75%        { top: calc(100% - 14px);     right: 10%; }
}

.stat-card {
  z-index: 1;
  width: 100%;
  height: 100%;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: radial-gradient(circle 140px at 0% 0%, #152019, var(--bg));
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 12px 14px;
  position: relative;
  overflow: hidden;
}

.stat-ray {
  width: 100px;
  height: 28px;
  border-radius: 100px;
  position: absolute;
  background: var(--green-mid);
  opacity: 0.2;
  box-shadow: 0 0 40px var(--green-hi);
  filter: blur(8px);
  top: 0;
  left: 0;
  transform: rotate(35deg);
  transform-origin: 10%;
  pointer-events: none;
}

.stat-card .label {
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 6px;
  position: relative;
  z-index: 1;
}
.stat-card .value {
  font-size: 20px;
  font-weight: 500;
  color: var(--green-hi);
  position: relative;
  z-index: 1;
}
.stat-card .value-sm { font-size: 11px; }
.stat-card .sub { font-size: 10px; color: var(--text-dim); margin-top: 3px; position: relative; z-index: 1; }

.stat-card .line {
  position: absolute;
  background-color: var(--border);
}
.stat-card .topl {
  top: 12%; width: 100%; height: 1px;
  background: linear-gradient(90deg, var(--green-dim) 20%, transparent 80%);
}
.stat-card .bottoml {
  bottom: 12%; width: 100%; height: 1px;
  background: linear-gradient(90deg, transparent 20%, var(--border) 80%);
}
.stat-card .leftl {
  left: 8%; width: 1px; height: 100%;
  background: linear-gradient(180deg, var(--green-dim) 20%, transparent 80%);
}
.stat-card .rightl {
  right: 8%; width: 1px; height: 100%;
  background: linear-gradient(180deg, transparent 20%, var(--border) 80%);
}

/* ── Table ── */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead th {
  text-align: left;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  font-weight: 400;
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
tbody tr:hover { background: var(--bg-hover); }
tbody tr.new-row { animation: fadeIn 0.4s ease; }
@keyframes fadeIn {
  from { background: var(--green-dim); }
  to   { background: transparent; }
}
td {
  padding: 6px 10px;
  color: var(--text);
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}
td.dim   { color: var(--text-dim); }
td.muted { color: var(--text-muted); }

/* ── Badges ── */
.badge { display: inline-block; padding: 1px 6px; font-size: 10px; letter-spacing: 0.04em; }
.badge.high   { color: var(--green-live); border: 1px solid var(--green-dim); }
.badge.normal { color: var(--text-dim);   border: 1px solid var(--border); }
.badge.low    { color: var(--text-muted); border: 1px solid var(--text-muted); }

/* ── RSSI colours ── */
.rssi-hi  { color: var(--green-hi); }
.rssi-mid { color: var(--text); }
.rssi-low { color: var(--text-muted); }

/* ── Sortable headers ── */
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--text-dim); }
thead th.sort-active { color: var(--green-hi); }
thead th.sort-active::after { content: ' ' attr(data-arrow); }

/* ── Enc / node colours ── */
.enc-open    { color: var(--orange); }
.nodes-multi { color: var(--green-hi); }

/* ── Cross-node cells ── */
.cn-best { color: var(--green-hi); font-weight: 500; }
.cn-none { color: var(--text-muted); font-style: italic; }

/* ── Empty state ── */
.empty {
  padding: 40px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 0.06em;
}

/* ── Presence ── */
.presence-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.presence-sub {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: auto;
}
.presence-sub-label {
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

/* ── Deauth heatmap ── */
#deauth-heatmap {
  display: block;
  background: var(--bg-panel);
  border: 1px solid var(--border);
}
.reason-normal     { color: var(--text-dim); }
.reason-suspicious { color: var(--orange); }
.reason-attack     { color: #e74c3c; font-weight: 500; }

/* ── Alerts ── */
.alerts-summary {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
}
.alerts-summary .stat { display: flex; flex-direction: column; gap: 2px; }
.alerts-summary .stat .val { font-size: 18px; font-weight: 500; color: var(--text); }
.alerts-summary .stat.alert .val { color: #e74c3c; }
.burst-row { background: rgba(231,76,60,0.07); }
.burst-row:hover { background: rgba(231,76,60,0.14) !important; }
.burst-multi { color: #e74c3c; font-weight: 500; }
td.deauth-type { color: #e74c3c; }
td.disassoc-type { color: var(--orange); }

/* ── Search ── */
.search-bar {
  display: flex;
  gap: 8px;
}
.search-input {
  flex: 1;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: 'Roboto', sans-serif;
  font-size: 13px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--green-dim); }
.search-input::placeholder { color: var(--text-muted); }
.search-btn {
  font-family: 'Roboto', sans-serif;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: none;
  border: 1px solid var(--green-dim);
  color: var(--green-hi);
  padding: 8px 20px;
  cursor: pointer;
  transition: background 0.15s;
}
.search-btn:hover { background: var(--bg-hover); }
.search-section { display: flex; flex-direction: column; gap: 8px; }
.search-section-label {
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--green-dim); }
