:root {
  --bg: #09090b;
  --surface: #111115;
  --surface-2: #18181e;
  --border: #272730;
  --text: #fafafa;
  --muted: #a1a1aa;
  --accent: #10b981;
  --accent-dim: rgba(16, 185, 129, 0.14);
  --warn: #f59e0b;
  --danger: #ef4444;
  --danger-dim: rgba(239, 68, 68, 0.14);
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
code { font-family: var(--mono); font-size: 0.9em; color: #d4d4d8; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.accent { color: var(--accent); }
.small { font-size: 0.85rem; }
.hidden { display: none !important; }
.full { width: 100%; }

.container {
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
  padding: 0 24px;
}

.row { display: flex; align-items: center; }
.between { justify-content: space-between; }
.gap-sm { gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(9, 9, 11, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}
.nav-links { display: flex; gap: 20px; font-size: 0.9rem; color: var(--muted); }
.nav-links a:hover { color: var(--text); }

.health-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.pulse.ok { background: var(--accent); }
.pulse.err { background: var(--danger); }

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.badge-version { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(16, 185, 129, 0.35); }
.badge-secure { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge-secure.connected { background: var(--accent-dim); color: var(--accent); border-color: rgba(16, 185, 129, 0.4); }
.badge-muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge-warn { background: rgba(245, 158, 11, 0.14); color: var(--warn); border: 1px solid rgba(245, 158, 11, 0.35); }
.badge-danger { background: var(--danger-dim); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.35); }

.hero {
  display: grid;
  grid-template-columns: 1.35fr 0.85fr;
  gap: 28px;
  padding: 48px 0 32px;
  align-items: start;
}
.eyebrow {
  margin: 0 0 8px;
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}
h1 { margin: 0 0 14px; font-size: 2.35rem; line-height: 1.12; letter-spacing: -0.025em; }
h2 { margin: 0; font-size: 1.45rem; letter-spacing: -0.015em; }
h3 { margin: 0; font-size: 1.05rem; }
.lead { margin: 0 0 22px; color: #d4d4d8; font-size: 1.02rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 24px; }

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
}
.kpi-val { font-family: var(--mono); font-size: 1.1rem; font-weight: 700; color: var(--text); }
.kpi-lbl { font-size: 0.76rem; color: var(--muted); }

.card, .session-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.session-meta {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.meta-row { display: flex; justify-content: space-between; font-size: 0.85rem; }
.meta-row span { color: var(--muted); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn-sm { padding: 6px 10px; font-size: 0.78rem; }
.btn-primary { background: var(--accent); color: #052e1e; }
.btn-primary:hover { background: #34d399; }
.btn-ghost { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: #52525b; }
.btn-danger { background: var(--danger-dim); color: #fca5a5; border-color: rgba(239, 68, 68, 0.4); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.25); }

.field-label { display: block; font-size: 0.78rem; font-weight: 600; color: #d4d4d8; margin-bottom: 4px; }
.input, .textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.88rem;
}
.input:focus, .textarea:focus { outline: none; border-color: var(--accent); }
.error-text { color: #fca5a5; font-size: 0.82rem; margin: 6px 0 0; }
.divider { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }

.section { padding: 28px 0; }
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tab {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.tab.active { background: var(--accent-dim); color: var(--accent); border-color: rgba(16, 185, 129, 0.45); }

.code-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.code-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.code-block {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.5;
  color: #e4e4e7;
  background: #0c0c10;
}

.vault-grid { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 20px; align-items: start; }
.template-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tpl-card {
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  color: var(--text);
}
.tpl-card:hover { border-color: #52525b; }
.tpl-card.selected { border-color: var(--accent); background: rgba(16, 185, 129, 0.08); }
.tpl-title { font-weight: 700; font-size: 0.86rem; margin-bottom: 4px; display: flex; justify-content: space-between; gap: 6px; }
.tpl-desc { font-size: 0.76rem; color: var(--muted); }

.scope-matrix {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 6px;
}
.scope-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border-radius: 7px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.76rem;
}
.scope-item.locked {
  opacity: 0.45;
  border-style: dashed;
  border-color: rgba(239, 68, 68, 0.45);
}

.keys-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.key-row {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.key-row.revoked { opacity: 0.55; }
.empty-state {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
  border: 1px dashed var(--border);
  border-radius: 10px;
}

.explorer-grid { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: 20px; align-items: start; }
.endpoint-list { display: flex; flex-direction: column; gap: 6px; max-height: 540px; overflow-y: auto; }
.ep-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 0.82rem;
}
.ep-btn:hover { background: var(--surface-2); }
.ep-btn.active { background: var(--surface-2); border-color: var(--accent); }
.method-pill {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
  min-width: 52px;
  text-align: center;
  background: var(--accent-dim);
  color: var(--accent);
}
.method-pill.POST { background: rgba(59, 130, 246, 0.16); color: #93c5fd; }
.method-pill.PUT { background: rgba(245, 158, 11, 0.16); color: #fcd34d; }
.method-pill.PATCH { background: rgba(168, 85, 247, 0.16); color: #d8b4fe; }
.method-pill.DELETE { background: var(--danger-dim); color: #fca5a5; }
.pg-output { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }

.verify-box {
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-family: var(--mono);
  font-size: 0.82rem;
}
.verify-box.valid { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.verify-box.invalid { border-color: var(--danger); color: #fca5a5; background: var(--danger-dim); }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 20px;
}
.modal-card {
  width: 100%;
  max-width: 600px;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 14px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.secret-box {
  background: #070709;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  word-break: break-all;
  font-size: 0.9rem;
  color: var(--accent);
}

.footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  margin-top: 32px;
}

@media (max-width: 960px) {
  .hero, .vault-grid, .explorer-grid, .grid-2, .grid-3, .kpi-strip, .template-grid, .scope-matrix {
    grid-template-columns: 1fr;
  }
  .nav-links { display: none; }
}
