:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-2: #243044;
  --border: #2d3a4f;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 10px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  font-family: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at top, #1a2740 0%, var(--bg) 55%);
  color: var(--text);
}

.hidden { display: none !important; }

.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.gate-card { width: min(420px, 100%); }

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 20px;
}

.brand.compact { margin: 0; }

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 18px;
}

.brand-name { font-weight: 600; font-size: 15px; }

h1 { margin: 0; font-size: 22px; }
h2 { margin: 0; font-size: 20px; }
h3 { margin: 0 0 16px; font-size: 15px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

.muted { color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); margin: 12px 0 0; }

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(26, 35, 50, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.tabs { display: flex; gap: 6px; flex: 1; }

.tab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--text); background: var(--surface-2); }

.content { padding: 24px; max-width: 1200px; margin: 0 auto; }

.panel { display: none; }
.panel.active { display: block; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
  flex-wrap: wrap;
}

.grid-2 {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  align-items: start;
}

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card.stretch { min-height: 360px; }
.card.narrow { max-width: 480px; }

.form { display: flex; flex-direction: column; gap: 14px; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.field span { color: var(--muted); }

input, select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
}

input:focus, select:focus {
  outline: 2px solid rgba(59, 130, 246, 0.45);
  border-color: var(--primary);
}

.filter { min-width: 200px; }

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
}

.btn.primary { background: var(--primary); color: white; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn.ghost:hover:not(:disabled) { color: var(--text); border-color: var(--muted); }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 600;
  position: sticky;
  top: 0;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255, 255, 255, 0.02); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge.active, .badge.grant, .badge.commit { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.badge.suspended, .badge.reserve, .badge.pending { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge.closed, .badge.revoked, .badge.cancelled, .badge.expired { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

.pager {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
}

.secret-box, .result-box {
  margin-top: 16px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.35);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  word-break: break-all;
  line-height: 1.5;
}

.toast {
  position: fixed;
  top: 72px;
  right: 24px;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 100;
  max-width: 360px;
  font-size: 13px;
}

.toast.error { border-color: rgba(239, 68, 68, 0.5); color: #fecaca; }
.toast.success { border-color: rgba(34, 197, 94, 0.5); color: #bbf7d0; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 32px;
}

.detail-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
  max-width: 420px;
  white-space: normal;
  word-break: break-all;
}
