:root {
  color-scheme: dark;
  --bg: #090d1d;
  --bg-soft: #101731;
  --surface: rgba(20, 29, 58, 0.78);
  --surface-strong: #151f3e;
  --border: rgba(176, 194, 255, 0.14);
  --text: #f2f5ff;
  --muted: #a5afd1;
  --subtle: #68739c;
  --primary: #8b7cff;
  --primary-strong: #a296ff;
  --success: #5ce1b6;
  --danger: #ff8194;
  --warning: #ffd17a;
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.32);
  --radius: 16px;
  --radius-sm: 10px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
}
body::before {
  position: fixed;
  z-index: -1;
  top: -15rem;
  left: 28%;
  width: 44rem;
  height: 44rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(104, 89, 255, 0.2), transparent 67%);
  content: "";
  pointer-events: none;
}
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid #c7c1ff; outline-offset: 3px; }

.loading-screen, .auth-shell {
  display: grid;
  min-height: 100vh;
  place-content: center;
  justify-items: center;
  gap: 16px;
  padding: 24px;
}
.loading-screen p { margin: 0; color: var(--muted); }
.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid rgba(215, 211, 255, .58);
  border-radius: 14px;
  color: white;
  background: linear-gradient(135deg, #a594ff, #5543dd);
  box-shadow: 0 10px 32px rgba(105, 86, 255, .35);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .04em;
}

.auth-card {
  width: min(100%, 440px);
  padding: 40px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(18, 27, 55, .78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 36px; }
.auth-brand .brand-mark { width: 38px; height: 38px; border-radius: 11px; font-size: 11px; }
.auth-brand strong { font-size: 18px; }
.eyebrow { margin: 0 0 8px; color: var(--primary-strong); font-size: 13px; font-weight: 700; letter-spacing: .08em; }
h1, h2, h3, p { margin-top: 0; }
.auth-card h1 { margin-bottom: 8px; font-size: 30px; letter-spacing: -.03em; }
.lead { margin-bottom: 28px; color: var(--muted); line-height: 1.6; }
.field { display: grid; gap: 8px; margin-bottom: 18px; }
.field label { color: #dbe0fa; font-size: 14px; font-weight: 650; }
.field input {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: 0;
  color: var(--text);
  background: rgba(8, 13, 31, .72);
}
.field input::placeholder { color: var(--subtle); }
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(139, 124, 255, .18); }
.auth-switch { margin: 18px 0 0; color: var(--muted); font-size: 14px; text-align: center; }
.text-button { padding: 0; border: 0; color: var(--primary-strong); background: transparent; font-weight: 700; }

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: white;
  background: linear-gradient(135deg, #9e90ff, #6b57ed);
  box-shadow: 0 7px 18px rgba(100, 81, 234, .22);
  font-size: 14px;
  font-weight: 750;
  transition: transform .15s ease, filter .15s ease;
}
.button:hover { filter: brightness(1.09); transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.button-full { width: 100%; }
.button-secondary { border-color: var(--border); color: #e8ebff; background: rgba(255, 255, 255, .04); box-shadow: none; }
.button-danger { border-color: rgba(255, 129, 148, .28); color: #ffb1bd; background: rgba(255, 129, 148, .1); box-shadow: none; }
.button-small { min-height: 32px; padding: 0 10px; border-radius: 8px; font-size: 12px; }

.console { display: grid; min-height: 100vh; grid-template-columns: 244px 1fr; }
.sidebar {
  display: flex;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-direction: column;
  padding: 28px 16px 18px;
  border-right: 1px solid var(--border);
  background: rgba(9, 13, 29, .72);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 10px; }
.brand .brand-mark { width: 35px; height: 35px; border-radius: 10px; font-size: 10px; }
.brand-name { font-weight: 800; letter-spacing: -.02em; }
.brand-subtitle { margin-top: 2px; color: var(--subtle); font-size: 11px; }
.nav { display: grid; gap: 4px; margin-top: 48px; }
.nav a { padding: 11px 12px; border-radius: 9px; color: var(--muted); font-size: 14px; text-decoration: none; }
.nav a:hover, .nav a:focus { color: var(--text); background: rgba(255, 255, 255, .06); outline: 0; }
.sidebar-footer { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--border); color: var(--subtle); font-size: 12px; line-height: 1.5; }
.sidebar-footer strong { display: block; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }

.main { width: min(100%, 1320px); padding: 40px 48px 64px; margin: 0 auto; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 38px; }
.topbar h1 { margin: 0; font-size: 30px; letter-spacing: -.04em; }
.topbar .description { margin: 8px 0 0; color: var(--muted); }
.status-dot { display: inline-flex; align-items: center; gap: 7px; color: var(--success); font-size: 13px; font-weight: 650; white-space: nowrap; }
.status-dot::before { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(92, 225, 182, .11); content: ""; }

.hero-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(230px, .7fr); gap: 20px; margin-bottom: 36px; }
.panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: 0 10px 32px rgba(0,0,0,.12); }
.endpoint-panel { padding: 25px; }
.section-label { display: block; margin-bottom: 10px; color: var(--muted); font-size: 13px; font-weight: 650; }
.endpoint { display: flex; overflow: hidden; align-items: center; min-height: 52px; border: 1px solid rgba(161, 146, 255, .24); border-radius: 11px; background: #0a1025; }
.endpoint code { flex: 1; min-width: 0; padding: 0 15px; overflow: hidden; color: #e2e6ff; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.endpoint .button { min-height: 38px; margin-right: 6px; }
.metric-panel { display: grid; align-content: center; padding: 25px; }
.metric-panel strong { margin: 4px 0 7px; font-size: 25px; letter-spacing: -.04em; }
.metric-panel p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }

.section { margin-top: 44px; scroll-margin-top: 24px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-heading h2 { margin: 0; font-size: 20px; letter-spacing: -.025em; }
.section-heading p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.create-key { display: flex; align-items: end; gap: 12px; padding: 20px; }
.keys-table { margin-top: 14px; }
.create-key .field { flex: 1; margin: 0; }
.key-once { margin-top: 14px; padding: 18px; border: 1px solid rgba(92, 225, 182, .28); border-radius: 12px; background: rgba(92, 225, 182, .08); }
.key-once[hidden] { display: none; }
.key-once h3 { margin-bottom: 6px; color: #bdffe7; font-size: 15px; }
.key-once p { margin-bottom: 12px; color: #c3d9d2; font-size: 13px; line-height: 1.55; }
.key-value { display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid rgba(92, 225, 182, .18); border-radius: 9px; background: rgba(2, 28, 24, .48); }
.key-value code { flex: 1; min-width: 0; overflow: auto; color: #d6fff1; font-size: 13px; white-space: nowrap; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--subtle); font-size: 12px; font-weight: 700; text-align: left; }
td { padding: 15px 16px; border-bottom: 1px solid rgba(176, 194, 255, .09); color: #dce1f9; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.key-prefix { color: #e2ddff; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.badge { display: inline-flex; padding: 4px 8px; border-radius: 999px; color: #98f0d0; background: rgba(92, 225, 182, .11); font-size: 12px; font-weight: 700; }
.badge-revoked, .status-failure { color: #ffa5b2; background: rgba(255, 129, 148, .11); }
.status-success { color: #98f0d0; background: rgba(92, 225, 182, .11); }
.empty { padding: 42px 20px; color: var(--muted); text-align: center; }
.empty strong { display: block; margin-bottom: 7px; color: #dce1f9; }
.muted { color: var(--muted); font-size: 13px; }
.toast { position: fixed; z-index: 4; right: 20px; bottom: 20px; max-width: min(390px, calc(100vw - 40px)); padding: 12px 16px; border: 1px solid var(--border); border-radius: 10px; color: white; background: #20294c; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(12px); transition: opacity .18s ease, transform .18s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(255, 129, 148, .45); background: #472638; }

@media (max-width: 820px) {
  .console { display: block; }
  .sidebar { position: static; height: auto; padding: 16px 18px; border-right: 0; border-bottom: 1px solid var(--border); }
  .nav { display: flex; overflow-x: auto; margin: 15px -4px 0; }
  .nav a { white-space: nowrap; }
  .sidebar-footer { display: none; }
  .main { padding: 30px 20px 48px; }
  .hero-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .auth-card { padding: 28px 22px; }
  .topbar, .section-heading { display: block; }
  .topbar .status-dot { margin-top: 18px; }
  .create-key { display: grid; align-items: stretch; }
  .endpoint { align-items: stretch; flex-direction: column; padding: 8px; }
  .endpoint code { padding: 7px; }
  .endpoint .button { width: 100%; margin: 0; }
  th, td { padding: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
