:root {
  --bg:        #0f0f1a;
  --bg2:       #1a1a2e;
  --bg3:       #22223a;
  --border:    #2e2e4a;
  --accent:    #0078d4;
  --accent2:   #00b4d8;
  --text:      #e0e0f0;
  --text-dim:  #8888aa;
  --online:    #22c55e;
  --offline:   #ef4444;
  --warn:      #f59e0b;
  --radius:    10px;
}

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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Top bar ── */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 56px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.topbar-brand { display: flex; align-items: baseline; gap: 10px; }
.brand-name   { font-size: 18px; font-weight: 700; color: var(--text); }
.brand-sub    { font-size: 12px; color: var(--text-dim); }
.topbar-stats { display: flex; gap: 10px; margin-left: auto; }
.stat-pill {
  display: flex; flex-direction: column; align-items: center;
  padding: 4px 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  min-width: 70px;
}
.stat-pill.online  { border-color: var(--online);  }
.stat-pill.offline { border-color: var(--offline); }
.stat-val   { font-size: 18px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; }
.stat-pill.online  .stat-val { color: var(--online);  }
.stat-pill.offline .stat-val { color: var(--offline); }
.topbar-refresh { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-dim); }
.topbar-refresh button {
  background: var(--accent); color: #fff; border: none;
  padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: 12px;
}
.topbar-refresh button:hover { background: var(--accent2); }

/* ── Layout ── */
.layout { display: flex; flex: 1; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
  width: 300px;
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-search { padding: 12px; border-bottom: 1px solid var(--border); }
.sidebar-search input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 13px;
}
.sidebar-search input:focus { outline: none; border-color: var(--accent); }
.device-list { overflow-y: auto; flex: 1; }

.device-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
}
.device-item:hover   { background: var(--bg3); }
.device-item.active  { background: var(--bg3); border-left: 3px solid var(--accent); }
.device-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.device-dot.online  { background: var(--online);  box-shadow: 0 0 6px var(--online); }
.device-dot.offline { background: var(--offline); }
.device-dot.unknown { background: var(--text-dim); }
.device-info { flex: 1; min-width: 0; }
.device-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-meta { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.device-cpu  {
  font-size: 11px; font-weight: 700; padding: 2px 7px;
  border-radius: 10px; background: var(--bg); border: 1px solid var(--border);
}

.loading { padding: 24px; text-align: center; color: var(--text-dim); font-size: 13px; }

/* ── Map ── */
.main {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#map {
  flex: 1;
  background: #1a1a2e;
}
.leaflet-container { background: #1a1a2e !important; }
.leaflet-tile-pane { filter: brightness(0.85) saturate(0.7) hue-rotate(180deg); }

/* ── Detail panel ── */
.detail-panel {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 16px 20px;
  max-height: 280px;
  overflow-y: auto;
}
.detail-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.detail-header h2 { font-size: 16px; font-weight: 700; }
.detail-mac { font-size: 11px; color: var(--text-dim); }
.detail-status {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 10px;
}
.detail-status.online  { background: rgba(34,197,94,.15);  color: var(--online);  border: 1px solid var(--online); }
.detail-status.offline { background: rgba(239,68,68,.15);  color: var(--offline); border: 1px solid var(--offline); }
.close-btn { background: none; border: none; color: var(--text-dim); font-size: 18px; cursor: pointer; padding: 0 4px; }
.close-btn:hover { color: var(--text); }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.detail-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
}
.dc-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.dc-val   { font-size: 14px; font-weight: 600; }

.charts-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.chart-wrap {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
}
.chart-label { font-size: 11px; color: var(--text-dim); margin-bottom: 6px; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
