/* ============================================================
   wxapiproxy — Design System v2
   Theme: Dark / Developer-grade / Authoritative
   Fonts: Geist + Geist Mono (Google Fonts)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700;800&family=Geist+Mono:wght@400;500;600&display=swap');

/* ── Design Tokens ────────────────────────────────────────── */
:root {
  color-scheme: dark;

  /* Spacing scale — 4pt base */
  --space-2xs: 4px;
  --space-xs:  8px;
  --space-sm:  12px;
  --space-md:  16px;
  --space-lg:  24px;
  --space-xl:  32px;
  --space-2xl: 48px;
  --space-3xl: 72px;

  /* Core palette — OKLCH, blue-black tinted neutrals */
  --bg:          oklch(10.5% 0.018 258);
  --surface:     oklch(13.5% 0.020 258);
  --surface-2:   oklch(16.5% 0.022 256);
  --surface-3:   oklch(19.5% 0.026 254);
  --surface-4:   oklch(23%   0.028 252);

  --text:        oklch(93%  0.010 240);
  --text-2:      oklch(72%  0.018 248);
  --muted:       oklch(52%  0.022 252);

  --border:      oklch(22%  0.024 256);
  --border-2:    oklch(27%  0.026 252);

  /* WeChat green accent */
  --accent:        oklch(60%  0.160 158);
  --accent-strong: oklch(50%  0.155 158);
  --accent-dim:    oklch(40%  0.130 158);
  --accent-glow:   oklch(60%  0.160 158 / 18%);
  --accent-surface:oklch(16%  0.028 175);

  /* Status colors */
  --green:    oklch(60% 0.15 158);
  --amber:    oklch(72% 0.16 78);
  --red:      oklch(57% 0.20 27);
  --blue:     oklch(62% 0.16 236);

  --green-dim:  oklch(20% 0.06 170);
  --amber-dim:  oklch(20% 0.06 80);
  --red-dim:    oklch(20% 0.08 27);

  /* Shadows */
  --shadow-sm: 0 1px 3px oklch(4% 0.02 258 / 60%);
  --shadow:    0 4px 16px oklch(4% 0.02 258 / 70%);
  --shadow-lg: 0 12px 40px oklch(4% 0.02 258 / 80%);
  --shadow-xl: 0 24px 64px oklch(4% 0.02 258 / 85%);

  /* Radius */
  --radius-sm: 6px;
  --radius:    8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Z-index */
  --z-modal: 100;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background: var(--bg);
  font-family: 'Geist', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  /* Subtle grid overlay */
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, oklch(18% 0.04 200 / 40%), transparent),
    linear-gradient(oklch(13% 0.024 258 / 100%) 1px, transparent 1px),
    linear-gradient(90deg, oklch(13% 0.024 258 / 100%) 1px, transparent 1px);
  background-size: 100% 100%, 48px 48px, 48px 48px;
}

::selection {
  color: var(--text);
  background: oklch(60% 0.16 158 / 30%);
}

a {
  color: inherit;
  text-decoration: none;
}

h1, h2, h3, h4 {
  margin-top: 0;
  font-family: 'Geist', 'PingFang SC', sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

p {
  margin-top: 0;
  color: var(--text-2);
  line-height: 1.65;
}

h1 { margin-bottom: var(--space-sm); font-size: 40px; line-height: 1.08; }
h2 { margin-bottom: var(--space-md); font-size: 22px; }
h3 { margin-bottom: var(--space-sm); font-size: 16px; }

code, pre {
  font-family: 'Geist Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
}

code {
  display: block;
  min-width: 0;
}

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  min-height: 60px;
  padding: 0 max(24px, calc((100vw - 1280px) / 2));
  background: oklch(12% 0.020 258 / 85%);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand,
.topnav,
.topnav form {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.brand {
  text-decoration: none;
  font-weight: 700;
  font-size: 15px;
  gap: 12px;
  color: var(--text);
  letter-spacing: -0.01em;
}

.brand-context {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
}

.brand-context::before {
  content: '';
  width: 1px;
  height: 16px;
  background: var(--border-2);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.04em;
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  border-radius: var(--radius-sm);
  box-shadow: 0 0 0 1px oklch(60% 0.16 158 / 35%),
              0 4px 16px oklch(60% 0.16 158 / 30%);
}

.topnav a,
.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  transition: color 140ms ease, background 140ms ease;
}

.link-button {
  padding: 0 10px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
}

.topnav form { margin: 0; }

.topnav a:hover,
.link-button:hover {
  color: var(--text);
  background: var(--surface-2);
}

.nav-notification-center {
  position: relative;
}

.nav-notification-center > summary {
  display: grid;
  place-items: center;
  width: 34px;
  min-height: 34px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  list-style: none;
  transition: background 140ms ease;
}

.nav-notification-center > summary::-webkit-details-marker {
  display: none;
}

.nav-notification-center > summary:hover,
.nav-notification-center[open] > summary {
  background: var(--surface-2);
}

.nav-notification-center > summary span {
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  color: #fff;
  background: var(--red);
  box-shadow: 0 0 0 3px var(--red-dim),
              0 6px 18px oklch(57% 0.20 27 / 35%);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.nav-notification-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 80;
  width: min(360px, calc(100vw - 32px));
  padding: 16px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  background: oklch(13% 0.022 258 / 98%);
  box-shadow: var(--shadow-xl);
}

.nav-notification-popover::before {
  content: '';
  position: absolute;
  top: -6px;
  right: 14px;
  width: 10px;
  height: 10px;
  border-top: 1px solid var(--border-2);
  border-left: 1px solid var(--border-2);
  background: oklch(13% 0.022 258 / 98%);
  transform: rotate(45deg);
}

.nav-notification-popover h3 {
  margin: 4px 0 6px;
  font-size: 17px;
}

.nav-notification-list {
  display: grid;
  gap: 12px;
}

.nav-notification-item {
  display: grid;
  gap: 10px;
}

.nav-notification-item strong {
  color: var(--text);
  font-size: 14px;
}

.nav-notification-item p {
  margin-bottom: 0;
  color: var(--text-2);
  font-size: 13px;
}

.nav-permission-chips {
  margin-bottom: 14px;
}

.nav-notification-popover .button {
  width: 100%;
  min-height: 38px;
  padding: 0 14px;
  color: #fff;
}

/* ── Page Layout ──────────────────────────────────────────── */
.page {
  width: min(1280px, calc(100vw - 40px));
  margin: 36px auto 80px;
  min-width: 0;
}

/* ── Panel / Card ─────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  min-width: 0;
  padding: var(--space-lg);
}

.stretch { min-width: 0; }

/* ── Eyebrow ──────────────────────────────────────────────── */
.eyebrow {
  display: block;
  margin-bottom: var(--space-xs);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

/* ── Muted / Empty ────────────────────────────────────────── */
.muted { color: var(--muted); }
.empty {
  padding: var(--space-xl);
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

/* ── Divider ──────────────────────────────────────────────── */
.divider {
  height: 1px;
  margin: var(--space-lg) 0;
  background: var(--border);
}

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  margin: 0 0 var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius);
  font-size: 13px;
  color: oklch(75% 0.12 158);
  background: oklch(16% 0.03 175 / 80%);
  border: 1px solid oklch(30% 0.07 165);
}

.alert::before {
  content: '✓';
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  margin-top: 1px;
  color: var(--accent);
}

.alert.error {
  color: oklch(70% 0.14 27);
  background: oklch(15% 0.04 27 / 80%);
  border-color: oklch(30% 0.08 27);
}

.alert.error::before {
  content: '!';
  color: var(--red);
}

.alert.warning {
  color: oklch(75% 0.12 78);
  background: oklch(15% 0.04 78 / 80%);
  border-color: oklch(30% 0.08 78);
}

.alert.warning::before {
  content: '⚠';
  color: var(--amber);
}

/* ── Forms & Inputs ───────────────────────────────────────── */
.form {
  display: grid;
  gap: var(--space-md);
}

label,
.field-block label {
  display: grid;
  gap: var(--space-xs);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.02em;
}

input {
  width: 100%;
  min-height: 42px;
  padding: 10px 14px;
  color: var(--text);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  background: var(--surface-2);
  font: inherit;
  font-size: 14px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input::placeholder { color: var(--muted); }

input:disabled {
  color: var(--muted);
  background: var(--surface);
  opacity: 0.7;
}

input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px oklch(60% 0.16 158 / 18%);
}

/* ── Buttons ──────────────────────────────────────────────── */
button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  min-height: 40px;
  padding: 0 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition:
    transform 140ms var(--ease-out),
    background 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    color 160ms ease;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

button:hover,
.button:hover {
  transform: translateY(-1px);
}

button:active,
.button:active {
  transform: translateY(0);
}

.primary {
  color: #fff;
  background: linear-gradient(160deg, var(--accent), var(--accent-strong));
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 1px oklch(60% 0.16 158 / 25%),
              0 6px 20px oklch(60% 0.16 158 / 30%);
}

.primary:hover {
  background: linear-gradient(160deg, oklch(63% 0.16 158), var(--accent));
  box-shadow: 0 0 0 1px oklch(60% 0.16 158 / 35%),
              0 8px 28px oklch(60% 0.16 158 / 40%);
}

.secondary {
  color: var(--text-2);
  background: var(--surface-3);
  border-color: var(--border-2);
}

.secondary:hover {
  color: var(--text);
  background: var(--surface-4);
  border-color: oklch(35% 0.030 252);
}

.full  { width: 100%; }
.compact { min-height: 34px; padding: 0 12px; font-size: 12px; }
.disabled { pointer-events: none; opacity: 0.45; }

/* Icon close button */
.icon-button {
  width: 32px;
  min-height: 32px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border-color: transparent;
  border-radius: var(--radius-sm);
  font-size: 18px;
  line-height: 1;
}

.icon-button:hover {
  color: var(--text);
  background: var(--surface-3);
  border-color: var(--border);
}

/* ── Status Badges ────────────────────────────────────────── */
.status {
  align-self: start;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--surface-3);
  color: var(--muted);
  border: 1px solid var(--border);
}

.status.authorized {
  background: var(--green-dim);
  color: var(--green);
  border-color: oklch(35% 0.09 158);
}

.status.unauthorized {
  background: var(--red-dim);
  color: var(--red);
  border-color: oklch(30% 0.09 27);
}

.status.warning {
  background: var(--amber-dim);
  color: var(--amber);
  border-color: oklch(32% 0.08 78);
}

/* ── Code Blocks ──────────────────────────────────────────── */
.copy-field code,
.token-line code,
.catalog-rule code,
.dashboard-head code,
.invite-code-cell code {
  overflow-x: auto;
  max-width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: oklch(9% 0.018 258);
  border: 1px solid var(--border);
  color: oklch(82% 0.08 200);
  font-size: 13px;
}

/* ── Section helpers ──────────────────────────────────────── */
.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.section-row h3 { margin-bottom: 0; }

.section-title {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--space-lg);
  min-width: 0;
}

.section-title h2 { margin-bottom: 4px; }
.section-title > div { min-width: 0; }

/* ── Copy Field ───────────────────────────────────────────── */
.copy-field {
  display: grid;
  gap: var(--space-xs);
}

.copy-field > span {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.copy-field > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-xs);
  min-width: 0;
}

/* ── Copy Button ──────────────────────────────────────────── */
.copy-button {
  min-width: 60px;
  font-size: 12px;
}

/* ── Login Page ───────────────────────────────────────────── */
.login-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: var(--space-2xl);
  align-items: center;
  min-height: calc(100vh - 120px);
  min-width: 0;
}

.intro {
  padding: var(--space-2xl) 0;
  min-width: 0;
}

.intro h1 {
  font-size: 48px;
  line-height: 1.06;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: var(--space-md);
}

.intro h1 span {
  color: var(--accent);
}

.intro > p {
  max-width: 52ch;
  font-size: 16px;
  color: var(--text-2);
  line-height: 1.7;
}

.callback-list {
  display: grid;
  gap: var(--space-md);
  margin-top: var(--space-2xl);
  padding: var(--space-lg);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.callback-list h2 {
  margin-bottom: var(--space-xs);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.invite-auth-form {
  padding: var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

/* Login panel styling */
.panel h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

/* ── Dashboard Head ───────────────────────────────────────── */
.dashboard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: 28px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.dashboard-head h1 {
  margin-bottom: 8px;
  font-size: 34px;
  font-weight: 800;
  line-height: 1.06;
}

.dashboard-head p {
  max-width: 56ch;
  margin-bottom: 0;
  font-size: 15px;
  color: var(--muted);
}

.dashboard-tools {
  display: grid;
  justify-items: end;
  gap: var(--space-sm);
  min-width: min(240px, 100%);
}

/* ── System Health ────────────────────────────────────────── */
.system-health {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  min-width: 220px;
  padding: 8px 14px;
  border: 1px solid var(--border-2);
  border-radius: 999px;
  background: var(--surface-2);
  box-shadow: var(--shadow-sm);
}

.system-health.ok {
  border-color: oklch(30% 0.08 158);
  background: oklch(15% 0.03 175 / 60%);
}

.system-health.warning {
  border-color: oklch(30% 0.08 78);
  background: oklch(15% 0.03 78 / 60%);
}

.system-health-head {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.health-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 6px var(--amber);
}

.system-health.ok .health-dot {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}

.system-health p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

/* ── Admin Grid (Console sidebar layout) ──────────────────── */
.admin-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  min-width: 0;
}

/* ── Sidebar Panel ────────────────────────────────────────── */
.sidebar-panel {
  position: sticky;
  top: 84px;
  padding: 20px;
  overflow: hidden;
}

.sidebar-panel h2,
.authorizer-panel h2 {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

/* ── Authorizer List ──────────────────────────────────────── */
.authorizer-list {
  display: grid;
  gap: 6px;
}

.authorizer-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: 12px 14px;
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  min-width: 0;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    transform 150ms ease;
}

.authorizer-row:hover {
  background: var(--surface-3);
  border-color: var(--border-2);
  transform: translateX(2px);
}

.authorizer-row.selected {
  background: var(--accent-surface);
  border-color: oklch(30% 0.09 162);
}

.authorizer-row span:first-child {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.authorizer-row small {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 11px;
  font-family: 'Geist Mono', monospace;
}

.authorizer-row strong {
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 600;
}

/* ── Sidebar Section (credential) ─────────────────────────── */
.sidebar-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.account-summary {
  display: grid;
  gap: var(--space-md);
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.account-summary h3 { margin-bottom: 4px; font-size: 14px; }
.account-summary p  { margin-bottom: 0; font-size: 13px; line-height: 1.5; }
.account-summary strong { color: var(--text); }
.account-summary button { width: 100%; }

/* ── Authorizer Panel ─────────────────────────────────────── */
.authorizer-panel {
  overflow: hidden;
  padding: 0;
}

.authorizer-panel > .section-title {
  margin: 0;
  padding: 28px 30px 24px;
  background: linear-gradient(
    135deg,
    oklch(18% 0.04 175 / 50%) 0%,
    transparent 60%
  ),
  var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.authorizer-panel > .section-title h2 {
  margin-bottom: 4px;
  font-size: 22px;
}

.section-title p {
  color: var(--muted);
  font-size: 13px;
  font-family: 'Geist Mono', monospace;
  margin-bottom: 0;
}

.empty-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  text-align: center;
}

.empty-panel h2 { font-size: 18px; color: var(--text-2); }
.empty-panel p  { color: var(--muted); }

/* ── Field Block (Token area) ─────────────────────────────── */
.field-block {
  display: grid;
  gap: var(--space-sm);
  margin: 0;
  padding: 24px 30px;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}

.field-block label {
  color: var(--text-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.token-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px;
  gap: var(--space-sm);
  align-items: start;
  min-width: 0;
}

.token-line code {
  overflow-wrap: anywhere;
  min-height: 42px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

.token-reset-trigger {
  width: max-content;
}

.token-reset-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.token-reset-options legend {
  grid-column: 1 / -1;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.token-reset-choice {
  position: relative;
  display: block;
  gap: var(--space-xs);
  min-width: 0;
  cursor: pointer;
}

.token-reset-choice input {
  position: absolute;
  inset: 0;
  width: 1px;
  height: 1px;
  min-height: 0;
  padding: 0;
  margin: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
  appearance: none;
}

.token-reset-choice span {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-content: center;
  column-gap: var(--space-xs);
  gap: 1px;
  min-width: 0;
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px transparent;
  contain: layout paint;
}

.token-reset-choice span::before {
  content: '';
  grid-column: 1;
  grid-row: 1 / 3;
  align-self: center;
  width: 12px;
  height: 12px;
  border: 1px solid var(--border-2);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: inset 0 0 0 3px var(--surface);
}

.token-reset-choice input:checked + span {
  background: var(--accent-surface);
  box-shadow: inset 0 0 0 1px oklch(30% 0.09 162);
}

.token-reset-choice input:checked + span::before {
  border-color: var(--accent);
  background: var(--accent);
}

.token-reset-choice strong {
  grid-column: 2;
  color: var(--text);
  font-size: 12px;
  line-height: 1.25;
}

.token-reset-choice small {
  grid-column: 2;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.token-reset-warning {
  margin-bottom: var(--space-sm);
  padding: 10px 12px;
  border: 1px solid oklch(32% 0.08 78);
  border-radius: var(--radius);
  color: var(--text-2);
  background: var(--amber-dim);
  font-size: 12px;
}

/* ── API Catalog ──────────────────────────────────────────── */
.api-catalog {
  display: grid;
  gap: var(--space-md);
  padding: 26px 30px 32px;
  min-width: 0;
}

.catalog-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: var(--space-lg);
  align-items: start;
  margin-bottom: 8px;
}

.catalog-head h3 {
  margin-bottom: 8px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.catalog-head p {
  max-width: 62ch;
  margin-bottom: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}

.catalog-rule {
  display: grid;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: oklch(9% 0.018 258);
  min-width: 0;
}

.catalog-rule span,
.sample-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.catalog-rule code {
  overflow-x: auto;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--accent);
  font-size: 12px;
}

.catalog-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.reauthorize-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-lg);
  align-items: center;
  padding: 18px 20px;
  border: 1px solid oklch(32% 0.08 78);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 88% 20%, oklch(72% 0.16 78 / 10%), transparent 42%),
    oklch(14% 0.035 78);
  box-shadow: var(--shadow-sm);
}

.reauthorize-card h4 {
  margin-bottom: 6px;
  font-size: 17px;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.reauthorize-card p {
  max-width: 64ch;
  margin-bottom: 12px;
  color: var(--text-2);
  font-size: 13px;
}

.reauthorize-card .button {
  white-space: nowrap;
}

.reauthorize-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  min-width: 128px;
}

.reauthorize-actions form {
  display: contents;
}

.reauthorize-actions button,
.reauthorize-actions .button {
  justify-content: center;
}

.permission-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.permission-chip-list span {
  padding: 4px 9px;
  border: 1px solid oklch(32% 0.08 78);
  border-radius: 999px;
  color: var(--amber);
  background: var(--amber-dim);
  font-size: 11px;
  font-weight: 650;
}

/* ── API Group & Item (accordion) ─────────────────────────── */
.api-group,
.api-item {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.api-group > summary,
.api-item > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  min-width: 0;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.api-group > summary::-webkit-details-marker,
.api-item > summary::-webkit-details-marker {
  display: none;
}

/* API Group Summary */
.api-group > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content 24px;
  column-gap: 16px;
  min-height: 64px;
  padding: 14px 18px 14px 20px;
  background: var(--surface-2);
  border-bottom: 1px solid transparent;
  transition: background 140ms ease;
}

.api-group > summary::after {
  content: "";
  width: 8px;
  height: 8px;
  justify-self: center;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 200ms var(--ease-out), border-color 140ms ease;
}

.api-group[open] > summary {
  border-bottom-color: var(--border);
}

.api-group[open] > summary::after {
  transform: rotate(225deg) translate(-2px, -2px);
  border-color: var(--accent);
}

.api-group > summary:hover,
.api-item > summary:hover {
  background: var(--surface-3);
}

.api-group > summary span:first-child,
.api-title {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.api-group > summary strong {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.api-group > summary small,
.api-title small {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.api-list {
  display: grid;
  gap: 6px;
  padding: 12px;
  background: oklch(11% 0.018 258);
}

/* API Item */
.api-item {
  background: var(--surface);
}

.api-item > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  column-gap: 14px;
  min-height: 56px;
  padding: 12px 14px;
}

.api-title strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.api-detail {
  display: grid;
  gap: var(--space-sm);
  padding: 0 14px 14px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.api-detail pre {
  margin: 0;
  max-width: 100%;
  overflow-x: auto;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: oklch(8.5% 0.016 258);
  box-shadow: inset 0 1px 0 oklch(100% 0 0 / 4%);
}

.api-detail code {
  min-width: max-content;
  white-space: pre;
  color: oklch(78% 0.07 180);
  font-size: 12px;
  line-height: 1.7;
}

.api-sample pre {
  margin: 0 0 12px;
  white-space: pre-wrap;
}

/* ── Badges ───────────────────────────────────────────────── */
.count-badge,
.method-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.count-badge {
  justify-self: end;
  min-width: 32px;
  padding: 3px 9px;
  text-align: center;
  color: var(--accent);
  background: var(--accent-surface);
  border: 1px solid oklch(28% 0.07 162);
}

.method-badge {
  justify-self: end;
  min-width: 44px;
  padding: 3px 8px;
  text-align: center;
  color: var(--text-2);
  background: var(--surface-3);
  border: 1px solid var(--border);
}

.method-badge.post {
  color: oklch(75% 0.14 68);
  background: oklch(16% 0.05 72);
  border-color: oklch(30% 0.09 70);
}

.method-badge.get {
  color: var(--accent);
  background: var(--accent-surface);
  border-color: oklch(28% 0.07 162);
}

/* ── Admin Login ──────────────────────────────────────────── */
.admin-login-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 430px);
  gap: clamp(40px, 8vw, 100px);
  align-items: center;
  min-height: calc(100vh - 120px);
}

.admin-login-copy {
  display: grid;
  gap: 20px;
  max-width: 680px;
  min-width: 0;
}

.admin-login-copy h1 {
  max-width: 12ch;
  margin-bottom: 0;
  font-size: 58px;
  line-height: 0.98;
  letter-spacing: -0.04em;
}

.admin-login-copy p {
  max-width: 54ch;
  margin-bottom: 0;
  font-size: 16px;
  color: var(--text-2);
  line-height: 1.7;
}

.admin-login-points {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.admin-login-points span {
  padding: 6px 14px;
  border: 1px solid var(--border-2);
  border-radius: 999px;
  color: var(--text-2);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.admin-login-card {
  display: grid;
  gap: 20px;
  padding: 28px;
}

.admin-login-card h2 {
  margin-bottom: 0;
  font-size: 26px;
}

/* ── Admin Hero ───────────────────────────────────────────── */
.admin-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 400px);
  gap: 20px;
  align-items: stretch;
  margin-bottom: 20px;
}

.admin-hero.solo {
  grid-template-columns: 1fr;
}

.admin-hero-copy {
  display: grid;
  align-content: end;
  gap: 10px;
  min-height: 200px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, oklch(18% 0.04 175 / 40%) 0%, transparent 60%),
    var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}

.admin-hero-copy::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at 30% 60%,
    oklch(60% 0.16 158 / 8%) 0%,
    transparent 60%
  );
  pointer-events: none;
}

.admin-hero-copy h1 {
  max-width: 14ch;
  margin-bottom: 0;
  font-size: 42px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
  position: relative;
}

.admin-hero-copy p {
  max-width: 62ch;
  margin-bottom: 0;
  color: var(--text-2);
  font-size: 14px;
  position: relative;
}

.admin-worklist {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 24px;
  border: 1px solid oklch(28% 0.07 78 / 60%);
  border-radius: var(--radius-lg);
  background: oklch(13.5% 0.025 82 / 80%);
  box-shadow: var(--shadow);
}

.admin-worklist strong {
  color: var(--text);
  font-size: 48px;
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.04em;
}

.admin-worklist ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.admin-worklist li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.5;
}

.admin-worklist li::before {
  content: '·';
  color: var(--accent);
  font-weight: 900;
  margin-top: 1px;
  flex-shrink: 0;
}

/* ── Overview Stats Grid ──────────────────────────────────── */
.admin-overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  display: grid;
  gap: 6px;
  min-height: 110px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform 150ms ease, border-color 150ms ease;
}

.stat-card:hover {
  transform: translateY(-1px);
  border-color: var(--border-2);
}

.stat-card.good {
  background: var(--accent-surface);
  border-color: oklch(26% 0.06 165);
}

.stat-card.warn {
  background: oklch(14% 0.025 80);
  border-color: oklch(28% 0.07 78);
}

.stat-card span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.stat-card strong {
  color: var(--text);
  font-size: 36px;
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.04em;
}

.stat-card.good strong { color: var(--accent); }
.stat-card.warn strong { color: var(--amber); }

.stat-card small {
  max-width: 22ch;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

/* ── Admin Table ──────────────────────────────────────────── */
.admin-table-panel {
  overflow: hidden;
  padding: 0;
}

.admin-table-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  align-items: end;
  gap: 20px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.admin-table-head h2,
.admin-table-head p { margin-bottom: 0; }
.admin-table-head h2 { font-size: 22px; letter-spacing: -0.02em; }
.admin-table-head p  { font-size: 13px; color: var(--muted); }

.admin-search {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.admin-search input {
  min-height: 38px;
  font-size: 13px;
  background: var(--surface-3);
}

.table-scroll {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  min-width: 1040px;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--text);
}

.admin-table th,
.admin-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.admin-table th {
  color: var(--muted);
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
}

.admin-table tbody tr {
  transition: background 120ms ease;
}

.admin-table tbody tr:hover {
  background: var(--surface-2);
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

.admin-table td:first-child {
  min-width: 260px;
}

.admin-table td:nth-child(5) {
  min-width: 160px;
  color: var(--muted);
  font-size: 12px;
  font-family: 'Geist Mono', monospace;
  white-space: nowrap;
}

.admin-account-cell,
.admin-status-cell {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.admin-account-cell strong,
.admin-status-cell strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.admin-account-cell small,
.admin-status-cell small {
  color: var(--muted);
  overflow-wrap: anywhere;
  font-size: 11px;
  font-family: 'Geist Mono', monospace;
  line-height: 1.4;
}

.admin-status-cell .status {
  justify-self: start;
}

.admin-table form {
  margin: 0;
}

.admin-table-head form {
  justify-self: end;
}

.inline-form {
  display: inline-flex;
}

.invite-code-cell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-xs);
  align-items: center;
  min-width: 0;
}

.invite-code-cell code {
  min-height: 38px;
  color: var(--accent);
  font-weight: 650;
  letter-spacing: 0.02em;
}

.invite-table {
  min-width: 980px;
}

/* ── Empty States ─────────────────────────────────────────── */
.admin-empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 56px 24px;
  text-align: center;
}

.admin-empty-state strong {
  font-size: 17px;
  color: var(--text-2);
}

.admin-empty-state p {
  max-width: 44ch;
  margin-bottom: 0;
  font-size: 13px;
}

.admin-filter-empty {
  padding: 20px 24px 26px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* ── Modal ────────────────────────────────────────────────── */
.modal {
  width: min(500px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: var(--radius-xl);
  color: var(--text);
  background: transparent;
  z-index: var(--z-modal);
}

.modal::backdrop {
  background: oklch(5% 0.015 258 / 80%);
  backdrop-filter: blur(4px);
}

.modal-surface {
  padding: var(--space-lg);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border);
}

.modal-head h3 {
  margin-bottom: 6px;
  font-size: 18px;
  font-weight: 700;
}

.modal-head p {
  margin-bottom: 0;
  font-size: 13px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  margin-top: var(--space-xs);
}

/* ── Section Row helpers ──────────────────────────────────── */
.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

/* ── Responsive Breakpoints ───────────────────────────────── */
@media (max-width: 920px) {
  .topbar {
    padding: 0 var(--space-md);
    min-height: 56px;
  }

  .topnav {
    flex-wrap: wrap;
    justify-content: flex-end;
    row-gap: var(--space-xs);
  }

  h1 { font-size: 30px; }

  .page {
    width: min(720px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    margin-top: 24px;
  }

  .login-grid,
  .admin-grid,
  .admin-login-shell,
  .admin-hero,
  .admin-table-head {
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 100%;
  }

  .login-grid {
    min-height: 0;
    align-items: start;
    gap: var(--space-lg);
    padding: var(--space-lg) 0;
  }

  .dashboard-head,
  .section-title,
  .token-line,
  .catalog-head,
  .copy-field > div,
  .section-row {
    grid-template-columns: 1fr;
    display: grid;
  }

  .dashboard-tools,
  .system-health {
    justify-items: stretch;
    min-width: 0;
    width: 100%;
  }

  .system-health {
    justify-content: flex-start;
    border-radius: var(--radius);
  }

  .sidebar-panel {
    position: static;
    padding: 18px;
  }

  .admin-login-shell {
    min-height: 0;
    align-items: start;
    gap: var(--space-lg);
  }

  .admin-login-copy h1,
  .admin-hero-copy h1 {
    max-width: 100%;
    font-size: 38px;
  }

  .admin-hero-copy { min-height: 0; padding: 22px; }

  .admin-worklist,
  .admin-login-card { padding: 22px; }

  .admin-table-head {
    align-items: start;
    gap: 16px;
    padding: 20px;
  }

  .admin-table-head form,
  .admin-table-head form button {
    width: 100%;
  }

  .admin-search { width: 100%; }

  .authorizer-panel > .section-title,
  .authorizer-panel > .field-block,
  .api-catalog {
    padding-right: 20px;
    padding-left: 20px;
  }

  .authorizer-panel > .section-title {
    padding-top: 22px;
    padding-bottom: 20px;
  }

  .catalog-head { gap: var(--space-md); }

  .reauthorize-card {
    grid-template-columns: 1fr;
    gap: var(--space-md);
    padding: 16px;
  }

  .reauthorize-card .button,
  .reauthorize-actions button {
    width: 100%;
  }

  .authorizer-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .token-line > button,
  .token-line > form,
  .token-line > form button { width: 100%; }

  .token-reset-options {
    grid-template-columns: 1fr;
  }

  .token-reset-trigger {
    width: 100%;
  }

  .api-group > summary { min-height: 0; padding: 14px 16px; }
  .api-list { padding: 10px; }

  .admin-overview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    align-content: center;
    min-height: 80px;
    padding: 12px var(--space-md);
  }

  .topnav { justify-content: flex-start; }

  .nav-notification-popover {
    right: auto;
    left: 0;
  }

  .nav-notification-popover::before {
    right: auto;
    left: 12px;
  }

  .page { width: calc(100vw - 24px); }

  .panel,
  .authorizer-panel,
  .sidebar-panel {
    width: 100%;
    max-width: 100%;
  }

  .admin-overview-grid { grid-template-columns: 1fr; }

  .admin-login-copy h1,
  .admin-hero-copy h1 { font-size: 32px; }

  .admin-login-points { display: grid; }

  .stat-card { min-height: 0; }

  .intro h1 { font-size: 34px; }
}
