:root {
  --bg: #0b1020;
  --panel: #101827;
  --panel2: #0f172a;
  --line: #233045;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --good: #10b981;
  --warn: #f59e0b;
  --bad: #ef4444;
  --accent: #60a5fa;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: linear-gradient(180deg, #08111f, #0b1020 30%, #0b1020);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  max-width: 1600px;
  margin: 0 auto;
  padding: 12px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.title { font-size: 26px; font-weight: 800; letter-spacing: 0.01em; }
.sub { color: var(--muted); margin-top: 4px; font-size: 13px; }
.toolbar { display: flex; align-items: end; gap: 8px; flex-wrap: wrap; }
.field { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.field select {
  min-width: 180px;
  background: #0b1220;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
}
.btn {
  border: 1px solid var(--line);
  background: #172033;
  color: var(--text);
  border-radius: 8px;
  padding: 9px 12px;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }

.status-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.stat-card, .panel {
  background: rgba(16, 24, 39, 0.92);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.stat-card { padding: 12px; }
.stat-label { color: var(--muted); font-size: 12px; }
.stat-value { font-size: 18px; font-weight: 800; margin-top: 8px; }
.stat-good { color: var(--good); }
.stat-warn { color: var(--warn); }
.stat-bad { color: var(--bad); }

.grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 10px;
  align-items: start;
}
.panel-row {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
}
.panel-row-split {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.panel-row-panel {
  min-width: 0;
}
.panel { padding: 11px; min-width: 0; }
.panel-wide { grid-column: 1 / -1; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.panel-toggle {
  border: 1px solid rgba(148,163,184,0.24);
  background: rgba(15, 23, 42, 0.8);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.panel-toggle:hover { border-color: var(--accent); }
.panel-toggle:disabled,
.panel-toggle[hidden] { display: none; }
.panel-title { font-size: 16px; font-weight: 800; }
.panel-sub, .panel-meta { color: var(--muted); font-size: 12px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  text-align: left;
  padding: 8px 7px;
  border-bottom: 1px solid rgba(148,163,184,0.14);
  font-size: 13px;
  vertical-align: top;
}
.table th { color: var(--muted); font-size: 12px; font-weight: 700; }
.table tbody tr:hover { background: rgba(255,255,255,0.02); }
.compact th, .compact td { padding-top: 7px; padding-bottom: 7px; }
#bansTable { table-layout: fixed; }
#bansTable th:nth-child(1), #bansTable td:nth-child(1) { width: 10rem; white-space: nowrap; }
#bansTable th:nth-child(2), #bansTable td:nth-child(2) { width: 9rem; white-space: nowrap; }
#bansTable th:nth-child(3), #bansTable td:nth-child(3) { width: 42%; }
#bansTable th:nth-child(4), #bansTable td:nth-child(4) { width: 10rem; white-space: nowrap; }
#bansTable th:nth-child(5), #bansTable td:nth-child(5) { width: auto; }
.reason-cell {
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
}
code { color: #bfdbfe; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
}
.badge.good { background: rgba(16,185,129,0.14); color: #6ee7b7; }
.badge.warn { background: rgba(245,158,11,0.14); color: #fcd34d; }
.badge.bad { background: rgba(239,68,68,0.14); color: #fca5a5; }
.badge.gray { background: rgba(148,163,184,0.14); color: #cbd5e1; }

.nodes-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}
.node-card {
  border: 1px solid rgba(148,163,184,0.18);
  background: rgba(2, 6, 23, 0.42);
  border-radius: 12px;
  padding: 8px;
}
.node-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: start;
}
.node-title { font-weight: 800; }
.node-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.node-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  margin-top: 6px;
}
.kpi {
  border: 1px solid rgba(148,163,184,0.12);
  border-radius: 10px;
  padding: 6px;
  background: rgba(15, 23, 42, 0.55);
}
.kpi-label { color: var(--muted); font-size: 11px; }
.kpi-value { font-weight: 800; margin-top: 4px; font-size: 12px; line-height: 1.2; }
.kpi-value-command {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.node-events {
  margin-top: 6px;
  display: grid;
  gap: 4px;
  max-height: 180px;
  overflow: auto;
}
.event-row {
  display: grid;
  grid-template-columns: 78px 58px 1fr;
  gap: 8px;
  padding: 5px 6px;
  border: 1px solid rgba(148,163,184,0.12);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.55);
  font-size: 12px;
}
.event-kind { font-weight: 800; }
.event-kind.ssh { color: #c4b5fd; }
.event-kind.http { color: #67e8f9; }
.event-time { color: var(--muted); }
.event-msg { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { color: var(--muted); font-size: 13px; }

@media (max-width: 1200px) {
  .status-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid { grid-template-columns: 1fr; }
  .panel-wide, .panel-row { grid-column: auto; }
  .panel-row-split { grid-template-columns: 1fr; }
  .nodes-grid { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .topbar { align-items: start; flex-direction: column; }
  .status-row { grid-template-columns: 1fr; }
  .field select { min-width: 100%; width: 100%; }
  .toolbar { width: 100%; }
  .btn { width: 100%; }
  .node-top { flex-direction: column; }
  .node-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .event-row { grid-template-columns: 1fr; }
  .panel-row-split { grid-template-columns: 1fr; }
}

/* ── Fleet board: node status dots ── */
.node-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.node-dot.online { background: var(--good); box-shadow: 0 0 6px rgba(16,185,129,0.5); }
.node-dot.offline { background: var(--bad); }
.node-dot.degraded { background: var(--warn); }

/* ── Fleet board: node cards ── */
.node-card { cursor: pointer; transition: border-color 0.15s; }
.node-card:hover { border-color: var(--accent); }
.node-card.online { border-color: rgba(16,185,129,0.3); }
.node-card.offline { border-color: rgba(239,68,68,0.3); }
.node-card.degraded { border-color: rgba(245,158,11,0.3); }

.node-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.node-name { font-weight: 800; font-size: 14px; }
.node-region {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  background: rgba(148,163,184,0.1);
  padding: 2px 8px;
  border-radius: 999px;
}

.node-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.node-stats .label { color: var(--muted); font-size: 11px; display: block; }
.node-stats .value { font-weight: 700; font-size: 13px; }
.node-stats .value.warn { color: var(--warn); }

/* ── Fleet board: node detail ── */
.node-detail { min-height: 120px; }
.node-detail-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.node-detail-name { font-weight: 800; font-size: 16px; }
.node-detail-region {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  background: rgba(148,163,184,0.1);
  padding: 2px 8px;
  border-radius: 999px;
}
.node-detail-table { width: 100%; }
.node-detail-table td { padding: 6px 8px; font-size: 13px; }
.node-detail-table td:first-child { color: var(--muted); width: 40%; }

/* ── Fleet board: badges ── */
.badge.node-badge { background: rgba(96,165,250,0.14); color: #93c5fd; }
.badge.type-ssh_brute { color: #c4b5fd; }
.badge.type-port_scan { color: #67e8f9; }
.badge.type-recon { color: #fcd34d; }
.badge.type-cve_attempt { color: #fca5a5; }
.badge.type-scanner { color: #67e8f9; }
.badge.type-payload_drop { color: #fca5a5; }
.badge.type-lateral_move { color: #fca5a5; }

.empty-state { color: var(--muted); font-size: 13px; padding: 16px; text-align: center; }
.wrap { white-space: normal; word-break: break-word; }
