:root {
  --bg: #0b0e14;
  --surface: #121722;
  --surface-2: #1a2130;
  --border: #242c3b;
  --text: #e6ebf4;
  --muted: #8a97ad;
  --accent: #4f8cff;
  --accent-ink: #fff;
  --green: #2ecc71;
  --red: #ff5c6c;
  --amber: #f5a623;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}
:root[data-theme="light"] {
  --bg: #f4f6fb; --surface: #fff; --surface-2: #f0f3f9; --border: #e2e7f0;
  --text: #16202e; --muted: #5b6676; --shadow: 0 10px 30px rgba(20,30,50,.08);
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: Inter, system-ui, sans-serif; background: var(--bg);
  color: var(--text); -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }

/* ---- login ---- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-wrap > form { width: 100%; }
input, select { min-width: 0; width: 100%; }
.login-card {
  width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px 28px; box-shadow: var(--shadow); display: grid; gap: 14px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 20px; }
.brand.sm { font-size: 16px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
/* scoped: the negative margin tucks the subtitle under the logo. Unscoped, it
   pulled every other .sub (e.g. the PC's machine line) up over the text above. */
.login-card .sub { margin: -6px 0 8px; color: var(--muted); font-size: 13px; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
input, select {
  font-family: inherit; font-size: 14px; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
button[type="submit"], .primary {
  background: var(--accent); color: var(--accent-ink); border: none; border-radius: 8px;
  padding: 11px 14px; font-weight: 600; font-size: 14px; margin-top: 4px;
}
button[type="submit"]:disabled { opacity: .6; cursor: default; }
.err { color: var(--red); font-size: 13px; }

/* ---- app shell ---- */
.topbar {
  display: flex; align-items: center; gap: 20px; padding: 0 20px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
}
.tabs { display: flex; gap: 4px; margin-right: auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tabs button { flex-shrink: 0; }
.topbar .brand { flex-shrink: 0; }
.tabs button {
  background: transparent; border: none; color: var(--muted); font-size: 14px; font-weight: 500;
  padding: 8px 12px; border-radius: 8px;
}
.tabs button.active { background: var(--surface-2); color: var(--text); }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.badge {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--accent);
}
.badge.admin { color: var(--amber); }
.ghost {
  background: transparent; border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 6px 10px; font-size: 13px;
}
.panel { padding: 24px; max-width: 1040px; margin: 0 auto; }

/* ---- cards & tables ---- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 4px; font-size: 16px; }
.card .hint { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row label { flex: 1; min-width: 150px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
td.mono, .mono { font-family: "JetBrains Mono", monospace; font-size: 12px; }
.pill { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.pill.online { background: rgba(46,204,113,.15); color: var(--green); }
.pill.offline { background: rgba(138,151,173,.15); color: var(--muted); }
.empty { color: var(--muted); font-size: 14px; padding: 24px 0; text-align: center; }

/* ---- token reveal ---- */
.token-box {
  background: var(--surface-2); border: 1px dashed var(--accent); border-radius: 8px;
  padding: 14px; margin-top: 12px; display: grid; gap: 8px;
}
.token-box .val { font-family: "JetBrains Mono", monospace; font-size: 13px; word-break: break-all; color: var(--accent); }
.token-box .warn { color: var(--amber); font-size: 12px; }

/* ---- agent list & detail ---- */
table.clickable tbody tr { cursor: pointer; }
table.clickable tbody tr:hover { background: var(--surface-2); }
.strong { font-weight: 600; }
.sub { color: var(--muted); font-size: 12px; }
td .sub { margin-top: 3px; line-height: 1.3; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.back { margin-bottom: 16px; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.detail-head h1 { margin: 0 0 4px; font-size: 22px; }
.head-right { display: flex; align-items: center; gap: 10px; }
.notice {
  background: var(--surface-2); border: 1px solid var(--border); border-left: 3px solid var(--muted);
  border-radius: 8px; padding: 10px 14px; font-size: 13px; margin-bottom: 16px; color: var(--muted);
}
.notice.warn { border-left-color: var(--amber); color: var(--amber); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.tile-label { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.tile-value { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.controls button { padding: 9px 14px; font-size: 13px; margin-top: 0; }
.controls button:disabled { opacity: .45; cursor: not-allowed; }
.controls .spacer { flex: 1; }
.danger { background: var(--red); color: #fff; border: none; border-radius: 8px; font-weight: 600; }
.danger-text { color: var(--red); border-color: transparent; }
.pill.revoked { background: rgba(255,92,108,.15); color: var(--red); }
.ghost.sm { padding: 5px 9px; font-size: 12px; }
td.actions { white-space: nowrap; text-align: right; }
td.actions button + button { margin-left: 6px; }
.link-btn {
  display: inline-flex; align-items: center; text-decoration: none; color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; font-size: 13px; white-space: nowrap;
}
.more { margin-top: 12px; width: 100%; }
.code-input { font-family: "JetBrains Mono", monospace; font-size: 16px; letter-spacing: .12em; text-transform: uppercase; }
.code-input::placeholder { text-transform: none; letter-spacing: normal; font-family: Inter, system-ui, sans-serif; font-size: 14px; }
.manual-link { display: inline-block; margin: 10px 0 4px; color: var(--muted); }
.manual-link:hover { color: var(--text); }
.card.narrow { max-width: 440px; }
.stack { display: grid; gap: 12px; margin-bottom: 8px; }
.stack button { justify-self: start; }
.card > table { margin-top: 8px; }
.card { overflow-x: auto; }

@media (max-width: 640px) {
  .topbar { padding: 0 12px; gap: 10px; }
  .who #whoName, .who .badge { display: none; }
  .topbar .brand { font-size: 0; gap: 0; }   /* keep just the dot */
  .panel { padding: 16px; }
  th, td { padding: 8px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tile { padding: 10px 12px; }
  .tile-value { font-size: 15px; }
}

/* ---- toast ---- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 12px 18px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; z-index: 120;
}
.toast.err { border-color: var(--red); color: var(--red); }
