:root {
  color-scheme: dark;
  --bg: #111214;
  --surface: #181a1d;
  --surface-raised: #1e2024;
  --line: #2c2f34;
  --text: #eceef0;
  --muted: #969ba3;
  --accent: #a78bfa;
  --good: #80c99a;
  --bad: #e18a8a;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
html { background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, system-ui, sans-serif;
}
button, input { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

/* Sign-in */
.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate-card {
  width: min(420px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}
.brand-lockup { display: inline-flex; align-items: center; margin-bottom: 28px; }
.brand-word { font-size: 16px; font-weight: 700; letter-spacing: .06em; }
.brand-period, .heading-period { color: var(--accent); }
.brand-symbol { display: none; }
.eyebrow, .workspace-label, .nav-caption, .stat-k,
.quick label, .row label, .t th, .modal-eyebrow {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .075em;
}
.gate .eyebrow { margin-bottom: 10px; }
.gate h1 { margin: 0; font-size: 29px; line-height: 1.2; letter-spacing: -.04em; }
.gate h1 span { color: var(--muted); }
.gate-copy, .gate-help { color: var(--muted); font-size: 13px; line-height: 1.7; }
.btn-discord, .btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 39px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  background: var(--accent);
  color: #17131f;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn-discord { width: 100%; margin: 14px 0 17px; }
.btn-discord svg { width: 18px; height: 18px; }
.btn-arrow { margin-left: auto; }
.gate-foot { padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.gate-help { margin-bottom: 0; font-size: 11px; }

/* Main application frame */
.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 228px;
  padding: 22px 15px 15px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: #151719;
}
.sidebar-brand { margin: 0 0 28px 7px; }
.workspace-label { padding: 0 8px 10px; }
.nav { display: grid; gap: 3px; margin-top: 9px; }
.nav-caption { padding: 13px 8px 6px; }
.tab {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 37px;
  padding: 0 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #b9bdc4;
  text-align: left;
  font-size: 12px;
  cursor: pointer;
}
.tab:hover { background: #202327; color: var(--text); }
.tab.active { background: #29252f; color: #eee7ff; }
.sidebar-bottom { display: grid; gap: 14px; margin-top: 24px; }
.system-status {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.system-status > span:nth-child(2) { display: grid; flex: 1; min-width: 0; }
.system-status b { font-size: 11px; font-weight: 600; }
.system-status small { color: var(--muted); font-size: 10px; }
.system-status small.dead { color: var(--bad); }
.system-status i { color: var(--good); font-size: 9px; font-style: normal; }
.pulse, .status-dot { display: inline-block; width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: var(--good); }
.profile { display: flex; align-items: center; gap: 9px; padding-top: 12px; border-top: 1px solid var(--line); }
.profile img { width: 31px; height: 31px; flex: 0 0 31px; border-radius: 50%; background: var(--surface-raised); object-fit: cover; }
.profile-info { min-width: 0; flex: 1; }
.who-name { overflow: hidden; font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.who-id { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; }
.logout {
  width: 30px; height: 30px; flex: 0 0 30px;
  border: 1px solid var(--line); border-radius: 5px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.main-view { min-height: 100vh; min-width: 0; margin-left: 228px; }
.topbar {
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
  background: #151719;
}
.topbar-context { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.topbar-context span:first-child { color: var(--text); font-weight: 700; letter-spacing: .05em; }
.topbar-context b { color: #555b63; font-weight: 400; }
.topbar-right { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 10px; letter-spacing: .06em; }
.secure-label { display: flex; align-items: center; gap: 7px; }
.topbar-divider { width: 1px; height: 15px; background: var(--line); }
.view-content { width: 100%; max-width: 1480px; margin: 0 auto; padding: 30px 32px 42px; }
.pane { display: none; min-width: 0; }
.pane.active { display: block; }
.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}
.page-heading h1 { margin: 5px 0 0; font-size: 26px; line-height: 1.25; font-weight: 650; letter-spacing: -.04em; }
.page-description { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.heading-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; color: var(--muted); font-size: 10px; letter-spacing: .05em; white-space: nowrap; }

/* Overview */
.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat {
  min-width: 0;
  padding: 16px 17px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat-v { margin-top: 11px; font-size: 26px; line-height: 1.2; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat-sub { margin-top: 5px; color: var(--muted); font-size: 11px; }
.stat-sub span { color: var(--text); }
.split {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, .85fr);
  align-items: stretch;
  gap: 13px;
  margin-top: 14px;
}
.card, .table-wrap { min-width: 0; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.card { padding: 17px; }
.card-head, .table-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--line);
}
.card-head h3, .table-title h3 { margin: 3px 0 0; font-size: 14px; font-weight: 600; letter-spacing: -.015em; }
.count-chip { color: var(--muted); font-size: 10px; white-space: nowrap; }
.card-description { margin: 12px 0; color: var(--muted); font-size: 12px; }
.quick { display: grid; grid-template-columns: 1fr; gap: 7px; }
.quick label, .row label { margin-top: 5px; }
.quick label span { float: right; color: var(--muted); font-weight: 400; }
.quick input, .row input, .search {
  display: block;
  width: 100%;
  min-width: 0;
  height: 37px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  outline: none;
  background: #121416;
  color: var(--text);
  font-size: 12px;
}
.quick input:focus, .row input:focus, .search:focus { border-color: #8d78ce; }
input::placeholder { color: #6f747c; }
.btn-primary { min-height: 37px; margin-top: 7px; }
.btn-primary:hover, .btn-discord:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: .55; cursor: wait; }
.qc-out {
  max-width: 100%;
  overflow: auto;
  margin: 9px 0 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #121416;
  color: var(--text);
  font: 11px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Activity and audit rows (created dynamically by app.js) */
.feed { min-height: 140px; max-height: 430px; overflow: auto; padding-top: 5px; }
.feed:empty::after { display: block; padding: 25px 5px; color: var(--muted); text-align: center; font-size: 12px; content: "No recent activity."; }
.feed-row {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr) minmax(90px, .75fr);
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 10px 2px;
  border-bottom: 1px solid #292c30;
  font-size: 11px;
}
.feed-row:last-child { border-bottom: 0; }
.feed-time { color: #858b94; font-size: 10px; white-space: nowrap; }
.feed-row > div { min-width: 0; overflow-wrap: anywhere; }
.feed-action {
  display: inline-block;
  margin-right: 5px;
  padding: 2px 5px;
  border-radius: 3px;
  background: #29252f;
  color: #c9b8ff;
  font-size: 10px;
  font-weight: 600;
}
.feed-action.good { background: #1d3026; color: var(--good); }
.feed-action.danger { background: #382326; color: var(--bad); }
.feed-detail { color: var(--muted); font-size: 10px; }
.feed-target { color: var(--text); }
.feed.big { min-height: 360px; max-height: calc(100vh - 270px); }

/* Tables */
.search { max-width: 270px; }
.table-wrap { overflow: hidden; }
.table-title { padding: 16px 17px; }
.t { width: 100%; border-collapse: collapse; text-align: left; }
.t th { padding: 11px 13px; background: #1d2023; white-space: nowrap; }
.t td { padding: 11px 13px; border-top: 1px solid var(--line); color: #d2d5d9; font-size: 12px; vertical-align: middle; }
.t tbody tr:hover { background: #1d2023; }
.t td:last-child { min-width: 150px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px !important; overflow-wrap: anywhere; }
.dim { color: var(--muted) !important; }
.pill { display: inline-flex; align-items: center; padding: 3px 7px; border-radius: 4px; background: #292d32; color: #cbd0d6; font-size: 10px; white-space: nowrap; }
.pill.ok { background: #1d3026; color: var(--good); }
.pill.banned, .pill.revoked, .pill.expired { background: #382326; color: var(--bad); }
.pill.unbound { background: #292d32; color: var(--muted); }
.btn-row-ghost, .btn-danger-ghost {
  min-height: 27px;
  margin: 2px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  color: #c5c9cf;
  font-size: 10px;
  cursor: pointer;
}
.btn-row-ghost:hover { border-color: #777e88; background: #25282d; }
.btn-danger-ghost { color: var(--bad); }
.btn-danger-ghost:hover { border-color: var(--bad); background: #302124; }
.table-mark { color: var(--muted); font-size: 10px; letter-spacing: .06em; }

/* Modal and notifications */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 18px; }
.modal-backdrop { position: absolute; inset: 0; background: #000a; }
.modal-card { position: relative; width: min(430px, 100%); padding: 22px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.modal-card h3 { margin: 6px 0; font-size: 20px; font-weight: 650; }
.modal-description { margin: 7px 0 16px; color: var(--muted); font-size: 12px; }
.row { display: grid; gap: 6px; margin: 12px 0; }
.row-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.btn-ghost { min-height: 37px; padding: 0 13px; border: 1px solid var(--line); border-radius: 5px; background: transparent; color: var(--text); font-size: 12px; cursor: pointer; }
.toast {
  position: fixed; right: 18px; bottom: 18px; z-index: 30;
  max-width: min(400px, calc(100% - 36px));
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-raised);
  color: var(--text);
  font-size: 12px;
}
.toast.err { border-color: #754348; color: #f0b4b4; }
.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0 32px;
  padding: 13px 0 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .06em;
}
.app-footer i { display: inline-block; width: 6px; height: 6px; margin-left: 5px; border-radius: 50%; background: var(--good); }

/* Responsive */
@media (max-width: 1100px) {
  .sidebar { width: 205px; }
  .main-view { margin-left: 205px; }
  .view-content { padding-right: 22px; padding-left: 22px; }
  .topbar { padding-right: 22px; padding-left: 22px; }
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 700px) {
  .sidebar { position: relative; width: 100%; height: auto; padding: 12px 14px; overflow: visible; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-top { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
  .sidebar-brand { margin: 0 10px 0 0; }
  .workspace-label, .sidebar-bottom, .nav-caption { display: none; }
  .nav { display: flex; flex: 1 1 100%; gap: 4px; margin: 0; }
  .tab { flex: 1; justify-content: center; width: auto; min-height: 34px; padding: 0 6px; font-size: 11px; }
  .main-view { margin-left: 0; }
  .topbar { height: 46px; padding: 0 15px; }
  .topbar-right { font-size: 9px; }
  .view-content { padding: 22px 14px 30px; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 10px; margin-bottom: 18px; }
  .page-heading h1 { font-size: 24px; }
  .compact-heading { align-items: stretch; }
  .search { max-width: none; }
  .stat-row { gap: 8px; }
  .stat { padding: 13px; }
  .stat-v { font-size: 23px; }
  .split { gap: 9px; }
  .card { padding: 14px; }
  .feed-row { grid-template-columns: 54px minmax(0, 1fr); gap: 8px; }
  .feed-row > .feed-detail { grid-column: 2; }
  .feed.big { max-height: 65vh; }
  .table-wrap { overflow-x: auto; }
  .t { min-width: 720px; }
  .app-footer { flex-direction: column; margin: 0 14px; }
}
@media (max-width: 390px) {
  .topbar-right { display: none; }
  .stat-row { grid-template-columns: minmax(0, 1fr); }
  .nav { flex-wrap: wrap; }
  .tab { min-width: calc(50% - 4px); }
  .gate-card { padding: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
