/* ── Glassix agent board ─ dark ops-room ─────────────────────────────────────
   Tokens: charcoal-blue field, amber = telemetry/attention, mint = online,
   gray = absent. Type: Bricolage Grotesque (display) / Public Sans (UI) /
   IBM Plex Mono (timestamps, statuses, anything machine-flavored).          */

:root {
  --bg: #0e1116;
  --surface: #161b23;
  --surface-2: #1c2330;
  --line: #242b36;
  --ink: #e8ecf1;
  --muted: #8a94a3;
  --accent: #e8a03d;
  --ok: #5bd08d;
  --warn: #e8a03d;
  --off: #5a6472;
  --danger: #e36d6d;
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Public Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

/* Author display values (grid, inline-flex) beat the UA's [hidden] rule —
   restore hidden's semantics unconditionally. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; margin: 0 0 8px; }
p { margin: 0 0 12px; }
code { font-family: var(--font-mono); font-size: 0.85em; color: var(--accent); }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ── Shared bits ─────────────────────────────────────────────────────────── */

.dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--off);
  flex: none;
}
.dot-accent { background: var(--accent); }

.brand {
  display: flex; align-items: center; gap: 10px;
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.01em;
}
.brand-name em { font-style: normal; color: var(--muted); font-weight: 500; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font: 500 14px var(--font-body);
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 14px;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 600; }
.btn-primary:hover { background: #fff; }
.btn-ghost { background: transparent; }
.btn-wide { width: 100%; padding: 12px 14px; }

.linklike {
  background: none; border: none; padding: 0;
  color: var(--muted); cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
  font-size: 12px;
}
.linklike:hover { color: var(--accent); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

input, select {
  font: 400 14px var(--font-body);
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 12px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }

.fine { color: var(--muted); font-size: 12.5px; }
.empty { color: var(--muted); padding: 28px 0; }

.notice {
  border: 1px solid var(--line);
  border-left: 3px solid var(--warn);
  background: var(--surface);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13.5px;
}

.banner {
  border: 1px solid var(--line);
  border-left: 3px solid var(--warn);
  background: var(--surface);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 0 0 20px;
  font-size: 13.5px;
  color: var(--ink);
}
.banner .mono { color: var(--muted); font-size: 12px; }

/* ── Loading + login ─────────────────────────────────────────────────────── */

.center-wrap {
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: 24px;
}

.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.loading .dot { animation: breathe 1.6s ease-in-out infinite; }

.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px 28px;
}
.login-card .brand { margin-bottom: 26px; }
.login-card h1 { font-size: 27px; line-height: 1.15; letter-spacing: -0.01em; }
.login-card .sub { color: var(--muted); margin-bottom: 22px; }
.login-card .notice { margin-bottom: 18px; }
.login-card .fine { margin: 14px 0 0; text-align: center; }

/* ── Topbar ──────────────────────────────────────────────────────────────── */

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
}
.topbar-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.conn { font-size: 12px; color: var(--muted); letter-spacing: 0.04em; }
.conn.is-live { color: var(--ok); }
.conn.is-warn { color: var(--warn); }

#live-dot.is-live { background: var(--ok); animation: pulse-ring 2.4s ease-out infinite; }
#live-dot.is-warn { background: var(--warn); }

.user-chip { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13.5px; }
.user-chip img { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line); }

/* ── Hero ────────────────────────────────────────────────────────────────── */

.content { max-width: 1100px; margin: 0 auto; padding: 34px 22px 60px; }

.eyebrow {
  color: var(--muted);
  font-size: 12px; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
  margin-bottom: 4px;
}

.count {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(64px, 13vw, 132px);
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  margin: 0 0 10px;
}
.count-total { color: var(--muted); font-weight: 500; font-size: 0.42em; margin-left: 10px; }

.hero-meta { display: flex; align-items: baseline; gap: 14px; color: var(--muted); font-size: 12.5px; }

/* ── Sparkline: the amber filament ───────────────────────────────────────── */

.spark-strip { margin: 26px 0 34px; }
#spark { display: block; width: 100%; height: 72px; }
.spark-legend { color: var(--muted); font-size: 11.5px; margin-top: 8px; display: flex; align-items: center; gap: 8px; }
.key { display: inline-block; width: 18px; height: 0; border-top: 2px solid var(--accent); }
.key-total { border-top-style: dotted; border-top-color: var(--muted); margin-left: 12px; }

/* ── Agent wall ──────────────────────────────────────────────────────────── */

.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
}

.chip {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  min-width: 0;
}

.avatar-badge {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid; place-items: center;
  font: 600 12.5px var(--font-body);
  letter-spacing: 0.03em;
  flex: none;
}
.avatar-badge.s-online  { background: rgba(91, 208, 141, 0.14); color: var(--ok); }
.avatar-badge.s-away    { background: rgba(232, 160, 61, 0.14); color: var(--warn); }
.avatar-badge.s-offline { background: rgba(90, 100, 114, 0.16); color: var(--muted); }

.chip .name {
  font-weight: 600; font-size: 14px;
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.chip .right { display: inline-flex; align-items: center; gap: 7px; flex: none; }
.chip .status { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }

.chip .dot.s-online { background: var(--ok); box-shadow: 0 0 9px rgba(91, 208, 141, 0.55); }
.chip .dot.s-away   { background: var(--warn); }
.chip .dot.s-offline{ background: var(--off); }
.chip.is-offline .name { color: var(--muted); font-weight: 500; }

#offline-wrap { margin-top: 20px; }
#btn-offline { display: inline-block; margin-bottom: 12px; }
.agent-grid.dim .chip { opacity: 0.75; }

/* ── Admin drawer ────────────────────────────────────────────────────────── */

.overlay {
  position: fixed; inset: 0;
  background: rgba(8, 10, 14, 0.6);
  z-index: 20;
}

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(560px, 100%);
  background: var(--surface);
  border-left: 1px solid var(--line);
  transform: translateX(102%);
  transition: transform 0.22s ease;
  z-index: 21;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 22px 40px;
}
.drawer.open { transform: translateX(0); }

.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.drawer-head h2 { margin: 0; font-size: 20px; }

.drawer-section { margin-top: 26px; }
.drawer-section h3 { font-size: 14.5px; margin-bottom: 12px; }

.field-row { display: flex; gap: 8px; margin-bottom: 10px; }
.field-row input { flex: 1; min-width: 0; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-weight: 600; color: var(--muted);
  font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 9px 8px 9px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table .mono { font-size: 12px; color: var(--muted); white-space: nowrap; }

.badge {
  font-family: var(--font-mono); font-size: 10.5px;
  border: 1px solid var(--line); border-radius: 99px;
  padding: 2px 8px; color: var(--muted);
}
.badge.b-active { color: var(--ok); border-color: rgba(91, 208, 141, 0.4); }
.badge.b-used { color: var(--muted); }
.badge.b-expired { color: var(--warn); border-color: rgba(232, 160, 61, 0.35); }
.badge.b-admin { color: var(--accent); border-color: rgba(232, 160, 61, 0.4); }

.select-mini {
  font: 500 12px var(--font-body);
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 8px;
  cursor: pointer;
}
.select-mini:hover { border-color: var(--muted); }

.table td.actions { text-align: right; }
.table td.actions .btn-mini,
.table td.actions .select-mini { margin: 2px 0 2px 6px; }
.table td.cell-member { max-width: 185px; }
.table td.cell-email {
  max-width: 165px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.btn-mini {
  font: 500 12px var(--font-body);
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-mini:hover { border-color: var(--muted); }
.btn-mini.danger { color: var(--danger); border-color: rgba(227, 109, 109, 0.35); background: transparent; }

.btn-revoke {
  background: none; border: none; padding: 0;
  color: var(--danger); cursor: pointer; font-size: 12.5px;
  text-decoration: underline; text-underline-offset: 3px;
}

.member { display: flex; align-items: center; gap: 9px; min-width: 0; }
.member img { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line); flex: none; }
.member .m-id { min-width: 0; flex: 1; }
.member .m-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .m-email { display: block; color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Raw payload dialog ──────────────────────────────────────────────────── */

dialog {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 14px;
  width: min(760px, calc(100% - 32px));
  max-height: 80dvh;
  padding: 18px 20px;
}
dialog::backdrop { background: rgba(8, 10, 14, 0.6); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dialog-head h3 { margin: 0; }
#raw-pre {
  margin: 0;
  font-size: 12px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
  max-height: 60dvh; overflow: auto;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 14px;
}

/* ── Motion ──────────────────────────────────────────────────────────────── */

@keyframes breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(91, 208, 141, 0.45); }
  70%  { box-shadow: 0 0 0 8px rgba(91, 208, 141, 0); }
  100% { box-shadow: 0 0 0 0 rgba(91, 208, 141, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .loading .dot { animation: none; }
  #live-dot.is-live { animation: none; }
  .drawer { transition: none; }
}

@media (max-width: 560px) {
  .topbar { padding: 12px 16px; }
  .content { padding: 26px 16px 48px; }
  .hero-meta { flex-wrap: wrap; }
}
