:root {
  --bg: #0a0d13;
  --panel: #10141d;
  --panel2: #161b27;
  --border: #1f2634;
  --text: #e8ecf4;
  --muted: #8b94a7;
  --dim: #5b6376;
  --accent: #6c7cff;
  --red: #ff4d5e;
  --red-bg: rgba(255, 77, 94, .12);
  --yellow: #ffb224;
  --yellow-bg: rgba(255, 178, 36, .12);
  --green: #2dd4a7;
  --green-bg: rgba(45, 212, 167, .12);
  --blue: #4da3ff;
  --teal: #2dd4d4;
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Manrope", system-ui, sans-serif;
  font-size: 14px;
  display: grid;
  grid-template-columns: 220px 1fr;
}

/* --- sidebar --- */
.sidebar {
  border-right: 1px solid var(--border);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: sticky; top: 0; height: 100vh;
}
.logo { font-weight: 800; font-size: 16px; line-height: 1.15; display: flex; gap: 9px; align-items: center; }
.logo.big { font-size: 20px; justify-content: center; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a {
  color: var(--muted); text-decoration: none; padding: 10px 12px;
  border-radius: 10px; font-weight: 600; display: flex; gap: 10px; align-items: center;
  transition: background .15s, color .15s;
}
.sidebar nav a:hover { color: var(--text); background: var(--panel2); }
.sidebar nav a.active { color: var(--text); background: var(--panel2); box-shadow: inset 2px 0 0 var(--accent); }
.ico { width: 18px; text-align: center; opacity: .9; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
#nodes-mini { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
#nodes-mini .nd { display: flex; align-items: center; gap: 7px; }

/* --- main --- */
main { padding: 26px 30px; max-width: 1300px; width: 100%; }
.loading { color: var(--dim); padding: 60px; text-align: center; }
h1 { font-size: 21px; font-weight: 800; margin-bottom: 4px; }
.sub { color: var(--muted); margin-bottom: 22px; font-size: 13px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* --- cards --- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 22px; }
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
}
.card .k { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .3px; }
.card .v { font-size: 28px; font-weight: 800; margin-top: 6px; }
.card .v small { font-size: 13px; color: var(--dim); font-weight: 600; }
.card.red .v { color: var(--red); }
.card.yellow .v { color: var(--yellow); }
.card.green .v { color: var(--green); }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.panel h2 { font-size: 14px; font-weight: 700; margin-bottom: 14px; color: var(--text); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 1100px) { .grid2 { grid-template-columns: 1fr; } }

/* --- table --- */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr.click { cursor: pointer; transition: background .12s; }
tr.click:hover { background: var(--panel2); }
.num { font-variant-numeric: tabular-nums; }

/* --- user cell --- */
.ucell { display: flex; align-items: center; gap: 11px; }
.avatar {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; color: #fff;
}
.uname { font-weight: 700; }
.usub { color: var(--dim); font-size: 12px; margin-top: 1px; }

/* --- badges / pills --- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700;
}
.pill.red { background: var(--red-bg); color: var(--red); }
.pill.yellow { background: var(--yellow-bg); color: var(--yellow); }
.pill.green { background: var(--green-bg); color: var(--green); }
.pill.gray { background: var(--panel2); color: var(--muted); }
.pill.demo { background: var(--yellow-bg); color: var(--yellow); justify-content: center; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dot.on { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot.off { background: var(--dim); }
.dot.red { background: var(--red); }
.dot.yellow { background: var(--yellow); }

/* --- score bar --- */
.score { display: flex; align-items: center; gap: 10px; min-width: 130px; }
.score .sv { font-weight: 800; width: 28px; text-align: right; }
.sbar { flex: 1; height: 6px; border-radius: 4px; background: var(--panel2); overflow: hidden; }
.sbar i { display: block; height: 100%; border-radius: 4px; }

/* --- filters --- */
.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
input[type=text], input[type=password], select {
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 9px 13px; font: inherit; outline: none; min-width: 220px;
}
input:focus { border-color: var(--accent); }
.chip {
  padding: 7px 14px; border-radius: 99px; border: 1px solid var(--border);
  background: var(--panel); color: var(--muted); cursor: pointer; font: inherit; font-weight: 700; font-size: 12px;
}
.chip.active { color: var(--text); border-color: var(--accent); background: rgba(108,124,255,.12); }

/* --- buttons --- */
.btn {
  background: var(--panel2); color: var(--text); border: 1px solid var(--border);
  padding: 9px 15px; border-radius: 10px; cursor: pointer; font: inherit; font-weight: 700; font-size: 13px;
  transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(1.2); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn.danger { background: var(--red-bg); color: var(--red); border-color: transparent; }
.btn.ok { background: var(--green-bg); color: var(--green); border-color: transparent; }
.btn.warn { background: var(--yellow-bg); color: var(--yellow); border-color: transparent; }
.btn-row { display: flex; gap: 9px; flex-wrap: wrap; }

/* --- breakdown --- */
.bd-row { display: grid; grid-template-columns: 200px 1fr 44px; align-items: center; gap: 12px; padding: 7px 0; }
.bd-row .bl { color: var(--muted); font-weight: 600; font-size: 13px; }
.bd-row .bv { text-align: right; font-weight: 800; }
.bd-bar { height: 7px; background: var(--panel2); border-radius: 4px; overflow: hidden; }
.bd-bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

/* --- timeline --- */
.tl-wrap { overflow-x: auto; }
.tl-row { display: grid; grid-template-columns: 230px 1fr; gap: 10px; align-items: center; padding: 5px 0; }
.tl-label { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-label .city { color: var(--dim); }
.tl-track { position: relative; height: 18px; background: var(--panel2); border-radius: 5px; }
.tl-seg { position: absolute; top: 3px; bottom: 3px; border-radius: 3px; min-width: 2px; }
.tl-seg.home { background: var(--blue); }
.tl-seg.mobile { background: var(--teal); }
.tl-seg.hosting { background: var(--red); }
.tl-axis { display: grid; grid-template-columns: 230px 1fr; gap: 10px; margin-top: 6px; }
.tl-days { position: relative; height: 16px; font-size: 11px; color: var(--dim); }
.tl-days span { position: absolute; transform: translateX(-50%); }
.legend { display: flex; gap: 16px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 6px; vertical-align: -1px; }

/* --- misc --- */
.flag { font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 6px; }
.flag.mob { background: rgba(45,212,212,.13); color: var(--teal); }
.flag.host { background: var(--red-bg); color: var(--red); }
.mono { font-family: ui-monospace, "SF Mono", monospace; font-size: 13px; }
.empty { color: var(--dim); text-align: center; padding: 26px; }
.hidden { display: none !important; }
.spark { width: 100%; height: 56px; }
.hist-chart { width: 100%; height: 120px; }
.back { color: var(--muted); text-decoration: none; font-weight: 700; font-size: 13px; }
.back:hover { color: var(--text); }
.hwid-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.hwid-card { background: var(--panel2); border-radius: 10px; padding: 11px 13px; }
.hwid-card .m { font-weight: 700; }
.hwid-card .o { color: var(--dim); font-size: 12px; margin-top: 2px; }
.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--panel2);
  border: 1px solid var(--border); border-radius: 12px; padding: 13px 18px;
  font-weight: 700; z-index: 60; animation: pop .2s ease;
}
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* --- login --- */
.login-overlay {
  position: fixed; inset: 0; background: var(--bg); z-index: 50;
  display: flex; align-items: center; justify-content: center;
}
.login-card { display: flex; flex-direction: column; gap: 14px; width: 300px; }
.login-err { color: var(--red); font-size: 13px; min-height: 16px; text-align: center; }

@media (max-width: 800px) {
  body { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; }
  .sidebar nav { flex-direction: row; }
  .sidebar-foot { display: none; }
  main { padding: 18px; }
}
