:root {
  --bg: #f5f8fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f2430;
  --muted: #5d7380;
  --faint: #8aa0aa;
  --line: #dbe7ec;
  --line-strong: #c4d6de;
  --brand: #0f766e;
  --brand-2: #0891b2;
  --brand-soft: #e6f7f8;
  --accent: #f59e0b;
  --danger: #dc2626;
  --code-bg: #0b1520;
  --code-text: #d6e6ee;
  --shadow: 0 20px 45px -24px rgba(15, 45, 60, .35);
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar: 286px;
}

[data-theme="dark"] {
  --bg: #071117;
  --surface: #0d1b23;
  --surface-2: #10232c;
  --text: #e6f2f6;
  --muted: #9db4be;
  --faint: #6f8a94;
  --line: #1c3540;
  --line-strong: #294854;
  --brand: #2dd4bf;
  --brand-2: #38bdf8;
  --brand-soft: #0f2b31;
  --accent: #fbbf24;
  --danger: #f87171;
  --code-bg: #050c12;
  --code-text: #d6e6ee;
  --shadow: 0 24px 50px -26px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", "Microsoft YaHei", "PingFang SC", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, kbd { font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace; }
button { font: inherit; }

/* ---------- layout ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar);
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; z-index: 40;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 22px 22px 18px; border-bottom: 1px solid var(--line);
}
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  background: linear-gradient(135deg, #0f766e, #0891b2 60%, #22d3ee);
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 8px 18px -8px rgba(8, 145, 178, .65);
}
.brand-mark svg { width: 24px; height: 24px; }
.brand-name { font-weight: 800; font-size: 15px; letter-spacing: .01em; line-height: 1.25; }
.brand-sub { font-size: 11px; color: var(--faint); letter-spacing: .16em; text-transform: uppercase; }
.brand-version {
  margin-left: auto; font-size: 10px; font-weight: 700; color: var(--brand);
  background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 22%, transparent);
  padding: 2px 7px; border-radius: 999px; white-space: nowrap;
}
.sidebar-search { padding: 14px 16px 10px; }
.search-box {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--muted); transition: .18s ease;
}
.search-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent); }
.search-box svg { width: 15px; height: 15px; flex-shrink: 0; }
.search-box input {
  border: 0; outline: 0; background: transparent; color: var(--text);
  width: 100%; font-size: 13px;
}
.search-box kbd {
  font-size: 10px; color: var(--faint); border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 5px; background: var(--surface);
}
.nav { padding: 6px 12px 22px; overflow-y: auto; flex: 1; }
.nav-group { margin: 16px 8px 6px; font-size: 10px; font-weight: 800; letter-spacing: .16em; color: var(--faint); text-transform: uppercase; }
.nav-link {
  display: flex; align-items: center; gap: 9px; padding: 7px 11px; margin: 1px 0;
  border-radius: 8px; color: var(--muted); font-size: 13.5px; font-weight: 500;
  border: 1px solid transparent; transition: .15s ease;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--brand-soft); color: var(--brand); border-color: color-mix(in srgb, var(--brand) 18%, transparent); font-weight: 700; }
.nav-link .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .4; }
.nav-link.active .dot { opacity: 1; }
.sidebar-foot { padding: 14px 22px; border-top: 1px solid var(--line); font-size: 11px; color: var(--faint); }

.main { margin-left: var(--sidebar); min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: 60px;
  display: flex; align-items: center; gap: 16px; padding: 0 34px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  border-bottom: 1px solid var(--line); backdrop-filter: blur(14px);
}
.menu-btn { display: none; }
.crumb { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--faint); }
.crumb strong { color: var(--muted); font-weight: 600; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); display: grid; place-items: center;
  cursor: pointer; transition: .15s ease;
}
.icon-btn:hover { color: var(--brand); border-color: var(--brand); }
.icon-btn svg { width: 16px; height: 16px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px;
  border-radius: 9px; border: 1px solid transparent; font-size: 13px; font-weight: 700;
  cursor: pointer; transition: .18s ease; white-space: nowrap;
}
.btn-primary { background: linear-gradient(135deg, #0f766e, #0891b2); color: #fff; box-shadow: 0 10px 20px -12px rgba(8, 145, 178, .8); }
.btn-primary:hover { transform: translateY(-1px); text-decoration: none; }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }

.content { max-width: 1020px; margin: 0 auto; padding: 34px 34px 80px; }

/* ---------- hero ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: 22px; padding: 46px 46px 40px;
  background:
    radial-gradient(900px 380px at 15% -10%, rgba(34, 211, 238, .35), transparent 60%),
    radial-gradient(700px 360px at 100% 0%, rgba(15, 118, 110, .5), transparent 55%),
    linear-gradient(135deg, #0b3b45 0%, #0f766e 55%, #0891b2 100%);
  color: #eaffff; box-shadow: var(--shadow);
}
.hero:after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,.16) 1px, transparent 1px);
  background-size: 22px 22px; opacity: .35;
  mask-image: linear-gradient(180deg, rgba(0,0,0,.55), transparent 75%);
}
.hero > * { position: relative; z-index: 1; }
.hero-badge {
  display: inline-flex; align-items: center; gap: 8px; font-size: 11.5px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase; color: #cffafe;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.22);
  padding: 5px 10px; border-radius: 999px;
}
.hero h1 { margin: 18px 0 10px; font-size: clamp(28px, 3.4vw, 42px); line-height: 1.18; letter-spacing: -.02em; font-weight: 800; }
.hero p { margin: 0; max-width: 660px; color: rgba(234, 255, 255, .82); font-size: 15.5px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.hero .btn-primary { background: #fff; color: #0b3b45; box-shadow: 0 12px 26px -14px rgba(0,0,0,.5); }
.hero .btn-ghost { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.28); color: #eaffff; }
.hero .btn-ghost:hover { background: rgba(255,255,255,.15); color: #fff; }
.hero-code {
  display: flex; align-items: center; gap: 10px; margin-top: 26px; width: fit-content;
  padding: 9px 12px; border-radius: 10px; background: rgba(2, 21, 27, .45);
  border: 1px solid rgba(255,255,255,.16); font-size: 12.5px; color: #b8f3f8;
  max-width: 100%; overflow-x: auto;
}
.hero-code span { color: #6ee7f2; }
.hero-code code { color: #fff; white-space: nowrap; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 22px 0 0; }
.stat-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 18px 16px; box-shadow: 0 10px 24px -20px rgba(15,45,60,.3);
}
.stat-card .k { font-size: 11px; font-weight: 800; letter-spacing: .1em; color: var(--faint); text-transform: uppercase; }
.stat-card .v { margin-top: 6px; font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: -.01em; }
.stat-card .d { margin-top: 2px; font-size: 12px; color: var(--muted); }

/* ---------- content sections ---------- */
.section { padding-top: 54px; scroll-margin-top: 76px; }
.section-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.section-eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .16em; color: var(--brand); text-transform: uppercase; padding-top: 5px; }
.section h2 { margin: 0; font-size: 26px; letter-spacing: -.02em; line-height: 1.25; }
.section .lead { margin: 8px 0 20px; color: var(--muted); max-width: 760px; }
.section h3 { margin: 30px 0 10px; font-size: 17px; letter-spacing: -.01em; }
.section p { margin: 10px 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 34px 0; }

.callout {
  display: flex; gap: 12px; padding: 14px 16px; border-radius: 12px;
  background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 20%, transparent);
  color: var(--text); margin: 16px 0; font-size: 13.5px;
}
.callout svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--brand); margin-top: 2px; }
.callout.warn { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.callout.warn svg { color: var(--accent); }

/* ---------- endpoints ---------- */
.endpoint {
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
  margin: 18px 0; overflow: hidden; box-shadow: 0 12px 30px -26px rgba(15,45,60,.35);
}
.endpoint-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  background: var(--surface-2); border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.method {
  font-size: 10.5px; font-weight: 800; letter-spacing: .06em; padding: 4px 8px;
  border-radius: 6px; color: #fff; min-width: 46px; text-align: center;
}
.method.get { background: #2563eb; }
.method.post { background: #0f9f6e; }
.method.put { background: #d97706; }
.method.delete { background: #dc2626; }
.endpoint-path { font-family: "SFMono-Regular", Consolas, monospace; font-size: 13px; font-weight: 600; color: var(--text); }
.endpoint-title { margin-left: auto; font-size: 12px; color: var(--muted); }
.endpoint-body { padding: 16px; }
.endpoint-body > :first-child { margin-top: 0; }
.endpoint-body > :last-child { margin-bottom: 0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; margin: 12px 0; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--surface-2); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); font-weight: 800; }
tr:last-child td { border-bottom: 0; }
td code, p code, li code, th code { background: var(--surface-2); border: 1px solid var(--line); padding: 1px 5px; border-radius: 5px; font-size: 12px; color: var(--text); }
.required { color: var(--danger); font-weight: 700; }
.type { color: var(--faint); font-size: 12px; }

/* ---------- code ---------- */
.code-card { margin: 14px 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--code-bg); }
.code-tabs { display: flex; align-items: center; gap: 2px; padding: 8px 10px; background: rgba(255,255,255,.04); border-bottom: 1px solid rgba(255,255,255,.08); }
.code-tab {
  border: 0; background: transparent; color: #8fb0bf; font-size: 12px; font-weight: 700;
  padding: 5px 10px; border-radius: 6px; cursor: pointer;
}
.code-tab.active { background: rgba(255,255,255,.1); color: #e8f7fb; }
.code-tab:hover { color: #fff; }
.code-copy { margin-left: auto; }
.code-copy button {
  border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.05); color: #9fc0cd;
  font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 6px; cursor: pointer;
}
.code-copy button:hover { color: #fff; border-color: rgba(255,255,255,.3); }
.code-panel { display: none; }
.code-panel.active { display: block; }
pre { margin: 0; padding: 16px 18px; overflow-x: auto; color: var(--code-text); font-size: 12.5px; line-height: 1.65; }
pre .c { color: #6f9aaa; }
pre .s { color: #a5e8b0; }
pre .k { color: #7dd3fc; }
pre .n { color: #fbbf24; }
pre .m { color: #f9a8d4; }

/* ---------- states / steps ---------- */
.flow {
  display: flex; align-items: stretch; gap: 0; margin: 18px 0; overflow-x: auto; padding-bottom: 4px;
}
.flow-step {
  flex: 1; min-width: 130px; padding: 14px 12px; border: 1px solid var(--line);
  background: var(--surface); position: relative; text-align: center;
}
.flow-step:first-child { border-radius: 12px 0 0 12px; }
.flow-step:last-child { border-radius: 0 12px 12px 0; }
.flow-step + .flow-step { border-left: 0; }
.flow-step .num { font-size: 10px; font-weight: 800; letter-spacing: .12em; color: var(--brand); }
.flow-step .t { margin-top: 4px; font-size: 13px; font-weight: 700; }
.flow-step .d { margin-top: 2px; font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.flow-step:after {
  content: ""; position: absolute; right: -6px; top: 50%; width: 11px; height: 11px;
  border-top: 1px solid var(--line); border-right: 1px solid var(--line);
  background: var(--surface); transform: translateY(-50%) rotate(45deg); z-index: 1;
}
.flow-step:last-child:after { display: none; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.pill.ok { background: #e8f8ef; color: #15803d; }
.pill.warn { background: #fff7e6; color: #b45309; }
.pill.info { background: #e8f4ff; color: #1d4ed8; }
.pill.mute { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
[data-theme="dark"] .pill.ok { background: #0d2f1c; color: #4ade80; }
[data-theme="dark"] .pill.warn { background: #33230a; color: #fbbf24; }
[data-theme="dark"] .pill.info { background: #10243f; color: #60a5fa; }

/* ---------- cards ---------- */
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px; box-shadow: 0 12px 28px -26px rgba(15,45,60,.35);
}
.card h4 { margin: 0 0 6px; font-size: 14px; }
.card p { margin: 0; color: var(--muted); font-size: 13px; }
.card .icon {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); margin-bottom: 10px;
}
.card .icon svg { width: 17px; height: 17px; }

/* ---------- footer ---------- */
.footer { margin-top: 60px; padding-top: 22px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; color: var(--faint); font-size: 12px; }
.footer a { color: var(--muted); }

/* ---------- responsive ---------- */
.sidebar-overlay { display: none; }
@media (max-width: 980px) {
  :root { --sidebar: 0px; }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; width: 286px; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .sidebar-overlay { display: block; position: fixed; inset: 0; background: rgba(4,20,28,.45); z-index: 35; }
  .main { margin-left: 0; }
  .menu-btn { display: grid; }
  .topbar { padding: 0 18px; }
  .content { padding: 24px 18px 60px; }
  .hero { padding: 32px 24px; border-radius: 18px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .hero h1 { font-size: 28px; }
  .stat-grid { grid-template-columns: 1fr; }
  .topbar-actions .btn span { display: none; }
  .endpoint-title { display: none; }
  .table th, .table td { padding: 8px 9px; }
}

/* ---------- login gate ---------- */
body.auth-locked .sidebar,
body.auth-locked .main { display: none; }
.login-gate {
  position: fixed; inset: 0; z-index: 100; display: none;
  align-items: center; justify-content: center; padding: 24px;
  background:
    radial-gradient(900px 420px at 12% 0%, rgba(34, 211, 238, .22), transparent 60%),
    radial-gradient(700px 420px at 100% 100%, rgba(15, 118, 110, .25), transparent 55%),
    var(--bg);
}
body.auth-locked .login-gate { display: flex; }
.login-card {
  width: min(980px, 100%); display: grid; grid-template-columns: 1.05fr .95fr;
  background: var(--surface); border: 1px solid var(--line); border-radius: 24px;
  overflow: hidden; box-shadow: 0 40px 90px -40px rgba(4, 30, 40, .55);
}
.login-brand {
  position: relative; padding: 46px 44px; color: #eaffff;
  background:
    radial-gradient(500px 280px at 0% 0%, rgba(34, 211, 238, .4), transparent 60%),
    linear-gradient(150deg, #0b3b45 0%, #0f766e 58%, #0891b2 100%);
  display: flex; flex-direction: column; justify-content: space-between; gap: 34px;
}
.login-brand:after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,.14) 1px, transparent 1px);
  background-size: 22px 22px; opacity: .3;
  mask-image: linear-gradient(180deg, rgba(0,0,0,.5), transparent 80%);
}
.login-brand > * { position: relative; z-index: 1; }
.login-brand .brand-mark { width: 46px; height: 46px; border-radius: 14px; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.25); box-shadow: none; }
.login-brand h1 { margin: 22px 0 10px; font-size: 30px; line-height: 1.2; letter-spacing: -.02em; }
.login-brand p { margin: 0; color: rgba(234,255,255,.78); font-size: 14px; max-width: 360px; }
.login-brand ul { list-style: none; padding: 0; margin: 22px 0 0; display: flex; flex-direction: column; gap: 10px; }
.login-brand li { display: flex; gap: 9px; align-items: flex-start; font-size: 13px; color: rgba(234,255,255,.86); }
.login-brand li svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 3px; color: #7dd3fc; }
.login-brand .login-foot { font-size: 11px; color: rgba(234,255,255,.45); letter-spacing: .04em; }
.login-form { padding: 46px 44px; display: flex; flex-direction: column; justify-content: center; }
.login-form .eyebrow { font-size: 10.5px; font-weight: 800; letter-spacing: .16em; color: var(--brand); text-transform: uppercase; }
.login-form h2 { margin: 8px 0 6px; font-size: 24px; letter-spacing: -.02em; }
.login-form .sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 11px 13px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font-size: 14px; outline: 0;
  transition: .16s ease;
}
.field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent); background: var(--surface); }
.login-submit {
  width: 100%; margin-top: 6px; padding: 12px 16px; border: 0; border-radius: 10px;
  background: linear-gradient(135deg, #0f766e, #0891b2); color: #fff; font-weight: 800;
  font-size: 14px; cursor: pointer; box-shadow: 0 14px 26px -16px rgba(8,145,178,.75);
  transition: .18s ease;
}
.login-submit:hover { transform: translateY(-1px); }
.login-error { display: none; margin: 10px 0 0; padding: 9px 11px; border-radius: 8px; background: #fef2f2; color: #b91c1c; font-size: 12.5px; border: 1px solid #fecaca; }
.login-error.show { display: block; }
.login-hint { margin-top: 16px; padding: 10px 12px; border-radius: 9px; background: var(--surface-2); border: 1px dashed var(--line-strong); color: var(--muted); font-size: 11.5px; line-height: 1.6; }
.login-hint code { background: var(--surface); border: 1px solid var(--line); padding: 1px 5px; border-radius: 5px; font-size: 11px; }
.login-badge { display: inline-flex; align-items: center; gap: 6px; margin-top: 18px; font-size: 11px; color: var(--faint); }
.login-badge svg { width: 13px; height: 13px; }
@media (max-width: 820px) {
  .login-card { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-form { padding: 34px 26px; }
}

/* ---------- fixes ---------- */
.brand { padding: 20px 18px; gap: 10px; }
.brand > div:nth-child(2) { min-width: 0; }
.brand-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 9.5px; letter-spacing: .12em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .menu-btn { display: none; }
@media (max-width: 980px) {
  .topbar .menu-btn { display: grid; }
}

/* ---------- brand logo ---------- */
.brand-mark { background: transparent; box-shadow: none; }
.brand-logo { width: 44px; height: 44px; object-fit: contain; display: block; }
.login-brand .brand-mark { width: 58px; height: 58px; padding: 9px; background: #fff; border: none; box-shadow: 0 14px 30px -16px rgba(0,0,0,.55); border-radius: 16px; }
.login-brand .brand-mark .brand-logo { width: 100%; height: 100%; }
