:root {
  --ink: #111827;
  --ink-2: #1f2937;
  --mist: #f9fafb;
  --card: #ffffff;
  --line: #e5e7eb;
  --line-soft: #f3f4f6;
  --muted: #6b7280;
  --faint: #9ca3af;
  --accent: #0f766e;
  --accent-soft: #e7f4f2;
  --pos: #10b981;
  --pos-ink: #047857;
  --warn: #f59e0b;
  --warn-ink: #b45309;
  --neg: #ef4444;
  --neg-ink: #b91c1c;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.06);
  --shadow-hover: 0 4px 12px rgba(17, 24, 39, 0.08);
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', 'Microsoft YaHei', sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--mist);
  -webkit-font-smoothing: antialiased;
}

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

button, input, select, textarea { font-family: inherit; font-size: inherit; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; }

p { margin: 0; }

.mono { font-family: var(--mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }

.muted { color: var(--muted); }
.faint { color: var(--faint); }

/* ---------------- layout ---------------- */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex: 0 0 240px;
  background: var(--ink);
  color: #fff;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; color: #fff; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; background: #fff; color: var(--ink);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; letter-spacing: -0.02em;
}
.brand-logo { width: 30px; height: 30px; object-fit: contain; flex: 0 0 30px; filter: drop-shadow(0 2px 4px rgba(0,0,0,.28)); }
.site-nav .brand-logo { width: 26px; height: 26px; flex-basis: 26px; filter: none; }
.auth-brand .brand-logo { width: 34px; height: 34px; flex-basis: 34px; filter: none; }
.brand-name { display: block; font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em; }
.brand-sub { display: block; font-size: 10.5px; color: rgba(255,255,255,.42); margin-top: 1px; }

.nav-group { margin-top: 18px; }
.nav-label {
  font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  color: rgba(255,255,255,.36); padding: 0 10px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px;
  border-radius: var(--radius-sm); color: rgba(255,255,255,.72); font-size: 13px;
}
.nav-item svg { width: 16px; height: 16px; flex: 0 0 16px; opacity: .8; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.1); color: #fff; }
.nav-item.active svg { opacity: 1; }

.sidebar-foot {
  margin-top: auto; padding: 12px 8px 4px; border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: #374151; overflow: hidden;
  display: grid; place-items: center; font-size: 11px; color: #fff; flex: 0 0 28px;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-foot .who { min-width: 0; }
.sidebar-foot .who b { display: block; font-size: 12.5px; font-weight: 500; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot .who span { display: block; font-size: 11px; color: rgba(255,255,255,.4); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 56px; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 24px; position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.topbar .actions { display: flex; align-items: center; gap: 8px; }

.content { padding: 24px; width: 100%; max-width: 1600px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.page-head h2 { font-size: 20px; letter-spacing: -0.01em; }
.page-head p { color: var(--muted); margin-top: 4px; }

/* ---------------- cards / kpi ---------------- */

.card {
  background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head {
  padding: 14px 20px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-head h3 { font-size: 13.5px; font-weight: 600; }
.card-head .sub { color: var(--faint); font-size: 11.5px; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi {
  background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 16px 20px; box-shadow: var(--shadow); transition: box-shadow .15s, background .15s;
}
.kpi:hover { background: var(--mist); box-shadow: var(--shadow-hover); }
.kpi .name { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; justify-content: space-between; }
.kpi .num { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 6px; }
.kpi .foot { font-size: 11px; color: var(--faint); margin-top: 4px; }

/* ---------------- table ---------------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; font-weight: 500;
  color: var(--muted); text-align: left; background: var(--mist);
  height: 36px; padding: 0 16px; border-bottom: 1px solid var(--line-soft); white-space: nowrap;
}
td { height: 44px; padding: 0 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--mist); }
td.right, th.right { text-align: right; }
.cell-main { font-weight: 500; }
.cell-sub { color: var(--faint); font-size: 11.5px; margin-top: 1px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------------- chips ---------------- */

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px;
  border-radius: 6px; font-size: 11px; font-weight: 500; white-space: nowrap;
}
.chip .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.chip-ok { background: rgba(16,185,129,.1); color: var(--pos-ink); }
.chip-wait { background: rgba(245,158,11,.12); color: var(--warn-ink); }
.chip-err { background: rgba(239,68,68,.1); color: var(--neg-ink); }
.chip-off { background: var(--line-soft); color: var(--muted); }

.badge {
  display: inline-block; padding: 1px 6px; border-radius: 5px; background: var(--line-soft);
  color: var(--muted); font-size: 10.5px; font-weight: 500;
}

/* ---------------- buttons / inputs ---------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 13px; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: var(--ink); color: #fff; font-size: 12.5px; font-weight: 500; cursor: pointer;
  white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--ink-2); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.secondary { background: var(--card); border-color: var(--line); color: var(--ink); }
.btn.secondary:hover { background: var(--mist); }
.btn.ghost { background: transparent; color: var(--muted); border-color: transparent; }
.btn.ghost:hover { background: var(--line-soft); color: var(--ink); }
.btn.danger { background: var(--card); border-color: #fecaca; color: var(--neg-ink); }
.btn.danger:hover { background: #fef2f2; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 500; margin-bottom: 6px; }
.field .hint { font-size: 11.5px; color: var(--faint); margin-top: 5px; }
.input, select.input, textarea.input {
  width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--card); color: var(--ink); outline: none;
}
textarea.input { height: 72px; padding: 8px 10px; resize: vertical; }
.input:focus, select.input:focus, textarea.input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(17,24,39,.08); }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group .suffix {
  display: flex; align-items: center; padding: 0 10px; border: 1px solid var(--line);
  border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--mist); color: var(--muted); font-size: 12.5px; white-space: nowrap;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

/* ---------------- alerts / flash ---------------- */

.flash {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 12.5px; margin-bottom: 16px; border: 1px solid transparent;
}
.flash.ok { background: rgba(16,185,129,.08); border-color: rgba(16,185,129,.2); color: var(--pos-ink); }
.flash.err { background: rgba(239,68,68,.07); border-color: rgba(239,68,68,.2); color: var(--neg-ink); }

.note {
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--mist); color: var(--muted); font-size: 12px;
}

/* ---------------- dialogs ---------------- */

dialog {
  border: 0; padding: 0; border-radius: var(--radius); width: 480px; max-width: calc(100vw - 32px);
  box-shadow: 0 24px 64px rgba(17,24,39,.24);
}
dialog::backdrop { background: rgba(17,24,39,.42); }
.dialog-head { padding: 16px 20px 0; }
.dialog-head h3 { font-size: 15px; }
.dialog-head p { color: var(--muted); margin-top: 4px; font-size: 12px; }
.dialog-body { padding: 16px 20px; }
.dialog-foot { padding: 14px 20px; border-top: 1px solid var(--line-soft); display: flex; justify-content: flex-end; gap: 8px; }
.dialog-close { position: absolute; top: 10px; right: 10px; }

.code-box {
  background: var(--ink); color: #e5e7eb; border-radius: var(--radius-sm);
  padding: 12px 14px; font-family: var(--mono); font-size: 12px; line-height: 1.6;
  overflow-x: auto; white-space: pre-wrap; word-break: break-all;
}

.kv { display: grid; grid-template-columns: 92px 1fr; gap: 10px 12px; font-size: 12.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------------- auth ---------------- */

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; background: var(--mist); }
.auth-card {
  width: 400px; max-width: 100%; background: var(--card); border: 1px solid var(--line-soft);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px;
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-brand .brand-mark { background: var(--ink); color: #fff; }
.auth-card h1 { font-size: 18px; letter-spacing: -0.01em; }
.auth-card .lead { color: var(--muted); font-size: 12.5px; margin-top: 6px; }

.oauth-row { display: grid; gap: 8px; margin-top: 18px; }
.oauth-btn {
  display: flex; align-items: center; justify-content: center; gap: 9px; height: 38px;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--card);
  font-size: 13px; font-weight: 500; cursor: pointer; color: var(--ink);
}
.oauth-btn:hover { background: var(--mist); }
.oauth-btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.oauth-btn.dark:hover { background: var(--ink-2); }
.oauth-btn[disabled] { opacity: .55; cursor: not-allowed; }
.oauth-btn.is-disabled { opacity: .55; cursor: not-allowed; }
.oauth-btn svg { width: 17px; height: 17px; }

.divider { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 11px; margin: 18px 0; }
.divider::before, .divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }

.auth-foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; }
.auth-foot a { color: var(--accent); font-weight: 500; }
.form-error { color: var(--neg-ink); font-size: 12px; margin-bottom: 12px; }

/* ---------------- site (public) ---------------- */

.site-nav {
  height: 64px; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 28px; padding: 0 32px;
  position: sticky; top: 0; z-index: 20;
}
.site-nav .brand { padding: 0; color: var(--ink); }
.site-nav .brand .brand-mark { background: var(--ink); color: #fff; }
.site-nav .links { display: flex; gap: 22px; margin-left: 8px; }
.site-nav .links a { color: var(--muted); font-size: 13px; }
.site-nav .links a:hover { color: var(--ink); }
.site-nav .spacer { flex: 1; }
.site-nav .auth { display: flex; align-items: center; gap: 8px; }

.hero { display: grid; grid-template-columns: 1.05fr .95fr; gap: 56px; align-items: center; padding: 72px 0 64px; }
.overline { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); font-weight: 500; }
.hero h1 { font-size: 42px; line-height: 1.12; letter-spacing: -0.03em; margin: 14px 0 16px; font-weight: 700; }
.hero .lead { font-size: 14.5px; color: var(--muted); max-width: 44ch; line-height: 1.7; }
.hero-actions { display: flex; gap: 10px; margin-top: 26px; }

.preview { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: 0 12px 32px rgba(17,24,39,.08); overflow: hidden; }
.preview-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.preview-host { font-family: var(--mono); font-size: 12.5px; font-weight: 500; }
.preview-body { padding: 6px 16px 10px; }
.preview-row { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px dashed var(--line-soft); font-size: 12px; }
.preview-row:last-child { border-bottom: 0; }
.preview-row span:first-child { color: var(--muted); }
.preview-row code { font-family: var(--mono); font-size: 11.5px; }
.preview-foot { padding: 10px 16px; background: var(--mist); border-top: 1px solid var(--line-soft); color: var(--faint); font-size: 11px; }

.section { padding: 56px 0; border-top: 1px solid var(--line); }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.section-head h2 { font-size: 22px; letter-spacing: -0.02em; }
.section-head p { color: var(--muted); font-size: 13px; max-width: 52ch; }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.step { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.step .num { font-family: var(--mono); font-size: 11px; color: var(--faint); letter-spacing: .06em; }
.step h3 { font-size: 14px; margin: 10px 0 6px; }
.step p { color: var(--muted); font-size: 12.5px; line-height: 1.65; }

.feature-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.feature { background: var(--card); padding: 20px 22px; }
.feature h3 { font-size: 13.5px; margin-bottom: 6px; }
.feature p { color: var(--muted); font-size: 12.5px; line-height: 1.65; }

.cta-band {
  background: var(--ink); color: #fff; border-radius: var(--radius); padding: 36px 40px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px; margin: 48px 0;
}
.cta-band h2 { font-size: 20px; letter-spacing: -0.01em; }
.cta-band p { color: rgba(255,255,255,.6); margin-top: 6px; font-size: 13px; }
.cta-band .btn { background: #fff; color: var(--ink); }
.cta-band .btn:hover { background: #e5e7eb; }

.site-foot { border-top: 1px solid var(--line); padding: 28px 0 40px; color: var(--faint); font-size: 12px; display: flex; justify-content: space-between; gap: 16px; }
.site-foot .links { display: flex; gap: 18px; }
.site-foot a:hover { color: var(--ink); }

.container { max-width: 1180px; margin: 0 auto; padding: 0 32px; }

/* docs */

.docs { display: grid; grid-template-columns: 200px 1fr; gap: 48px; padding: 40px 0 64px; }
.docs-nav { position: sticky; top: 96px; align-self: start; }
.docs-nav a { display: block; padding: 6px 10px; border-radius: 6px; color: var(--muted); font-size: 12.5px; }
.docs-nav a:hover { background: var(--line-soft); color: var(--ink); }
.docs-body h2 { font-size: 18px; margin: 32px 0 10px; }
.docs-body h2:first-child { margin-top: 0; }
.docs-body p { color: var(--muted); margin: 8px 0; line-height: 1.75; }
.docs-body li { color: var(--muted); margin: 6px 0; line-height: 1.7; }
.docs-body code { background: var(--line-soft); padding: 1px 5px; border-radius: 4px; font-family: var(--mono); font-size: 11.5px; }
.docs-body pre { background: var(--ink); color: #e5e7eb; padding: 14px 16px; border-radius: var(--radius-sm); overflow-x: auto; font-family: var(--mono); font-size: 12px; line-height: 1.65; }
.docs-body h3 { font-size: 13.5px; margin: 18px 0 6px; }

/* empty state */

.empty { padding: 48px 20px; text-align: center; }
.empty h3 { font-size: 13.5px; }
.empty p { color: var(--muted); margin: 6px 0 16px; font-size: 12.5px; }

/* error page */

.error-page { min-height: 100vh; display: grid; place-items: center; text-align: center; padding: 24px; }
.error-page h1 { font-size: 22px; margin-bottom: 8px; }
.error-page p { color: var(--muted); margin-bottom: 18px; }

/* mobile */

.menu-btn { display: none; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { grid-template-columns: 1fr; gap: 36px; padding: 48px 0; }
  .hero h1 { font-size: 34px; }
  .steps { grid-template-columns: 1fr; }
  .docs { grid-template-columns: 1fr; gap: 20px; }
  .docs-nav { position: static; display: flex; flex-wrap: wrap; gap: 4px; }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed; z-index: 40; left: -260px; transition: left .18s ease;
  }
  .sidebar.open { left: 0; }
  .menu-btn {
    display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
    border: 1px solid var(--line); background: var(--card); border-radius: 7px; cursor: pointer; margin-right: 10px;
  }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .site-nav { padding: 0 18px; gap: 14px; }
  .site-nav .links { display: none; }
  .container { padding: 0 18px; }
  .hero h1 { font-size: 30px; }
  .feature-grid { grid-template-columns: 1fr; }
  .cta-band { flex-direction: column; align-items: flex-start; padding: 26px; }
  .site-foot { flex-direction: column; gap: 8px; }
}

@media (max-width: 640px) {
  .kpis { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .topbar h1 { font-size: 13px; }
  th, td { padding: 0 12px; }
  .cell-sub { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
