:root {
  --bg: #0d1117;
  --panel: #151b23;
  --panel-2: #1c232d;
  --line: #263040;
  --text: #e6edf3;
  --muted: #8b98a9;
  --accent: #3fb950;
  --warn: #d29922;
  --down: #f85149;
  --blue: #58a6ff;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}
h1, h2, h3 { margin: 0; font-weight: 600; }

/* ---------- login ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh; }
.login-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 32px; width: min(360px, 92vw); display: flex; flex-direction: column; gap: 14px;
}
.login-card .sub { color: var(--muted); margin: -6px 0 6px; font-size: 13px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; color: var(--text); font-size: 14px;
}
.login-card input:focus { outline: none; border-color: var(--blue); }
.login-card button {
  margin-top: 6px; background: var(--blue); color: #05121f; border: 0;
  border-radius: 8px; padding: 11px; font-weight: 600; font-size: 14px; cursor: pointer;
}
.login-card .host { text-align: center; color: var(--muted); font-size: 12px; margin: 4px 0 0; }
.err { background: rgba(248,81,73,.12); border: 1px solid rgba(248,81,73,.4);
       color: #ffa198; padding: 8px 10px; border-radius: 8px; margin: 0; font-size: 13px; }
.logo { display: flex; align-items: center; gap: 10px; }

/* ---------- chrome ---------- */
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent);
       box-shadow: 0 0 10px var(--accent); display: inline-block; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--panel);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.updated { color: var(--muted); font-size: 12px; }
.ghost {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 12px; font-size: 13px; cursor: pointer;
}
.ghost:hover { border-color: var(--blue); color: var(--blue); }
main { padding: 20px 24px 60px; display: flex; flex-direction: column; gap: 20px; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px;
}
.stat .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 28px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat.online .v { color: var(--accent); }
.stat.stale .v { color: var(--warn); }
.stat.offline .v { color: var(--down); }

/* ---------- panels & tables ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.panel-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.panel-head h2 { font-size: 15px; }
.hint { color: var(--muted); font-size: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; padding: 10px 14px; color: var(--muted); font-weight: 500;
  font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 11px 14px; border-bottom: 1px solid rgba(38,48,64,.5); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(88,166,255,.05); }
.empty { color: var(--muted); text-align: center; padding: 28px; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.badge.online { color: var(--accent); } .badge.online::before { background: var(--accent); }
.badge.stale  { color: var(--warn); }   .badge.stale::before  { background: var(--warn); }
.badge.offline{ color: var(--down); }   .badge.offline::before{ background: var(--down); }

.bar { position: relative; width: 74px; height: 6px; background: var(--panel-2);
       border-radius: 3px; overflow: hidden; display: inline-block; vertical-align: middle; }
.bar span { position: absolute; inset: 0 auto 0 0; background: var(--blue); border-radius: 3px; }
.bar.hot span { background: var(--down); }
.num { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; margin-left: 8px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; }
.tag { background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px;
       padding: 2px 7px; font-size: 11px; color: var(--muted); }
.tag.internal { color: var(--blue); border-color: rgba(88,166,255,.4); }

/* ---------- graph ---------- */
.graph-wrap { padding: 10px; border-bottom: 1px solid var(--line); }
#graph { width: 100%; height: auto; display: block; }
#graph text { fill: var(--text); font-size: 12px; }
#graph .lbl-sub { fill: var(--muted); font-size: 10px; }
#graph .edge { stroke: var(--blue); opacity: .5; }
#graph .node-c { fill: var(--panel-2); stroke: var(--line); }
#graph .node-c.online { stroke: var(--accent); }
#graph .node-c.stale { stroke: var(--warn); }
#graph .node-c.offline { stroke: var(--down); }
#graph .hub-c { fill: rgba(88,166,255,.12); stroke: var(--blue); stroke-width: 2; }

/* ---------- segmented ---------- */
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { background: transparent; border: 0; color: var(--muted);
              padding: 6px 12px; font-size: 12px; cursor: pointer; }
.seg button.on { background: var(--panel-2); color: var(--blue); }

/* ---------- events ---------- */
.events { list-style: none; margin: 0; padding: 6px 0; max-height: 300px; overflow-y: auto; }
.events li { padding: 9px 18px; border-bottom: 1px solid rgba(38,48,64,.5);
             display: flex; gap: 12px; align-items: baseline; font-size: 13px; }
.events li:last-child { border-bottom: 0; }
.events time { color: var(--muted); font-size: 12px; min-width: 130px; }
.kind { font-size: 11px; padding: 1px 7px; border-radius: 5px; background: var(--panel-2); }
.kind.enroll { color: var(--blue); } .kind.online { color: var(--accent); }
.kind.revoke, .kind.offline { color: var(--down); }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 10; }
.modal[hidden] { display: none; }   /* the class rule would otherwise beat the hidden attribute */
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
              padding: 24px; width: min(640px, 92vw); display: flex; flex-direction: column; gap: 12px; }
.modal-card pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
                  padding: 14px; overflow-x: auto; font-size: 12px; margin: 0;
                  font-family: ui-monospace, Menlo, monospace; white-space: pre-wrap; word-break: break-all; }
.modal-card button { align-self: flex-start; }
