:root {
  color-scheme: light;
  --app-bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8faff;
  --text: #0b1f3a;
  --muted: #64748b;
  --line: #dbe3ef;
  --line-strong: #c7d2e3;
  --primary: #1769ff;
  --primary-strong: #0f54d8;
  --primary-soft: #eaf2ff;
  --cyan: #0ea5e9;
  --success: #16834b;
  --success-soft: #eaf8f0;
  --warning: #b36a00;
  --warning-soft: #fff7e5;
  --danger: #d92d3f;
  --danger-soft: #fff0f2;
  --shadow: 0 12px 38px rgba(18, 43, 78, 0.08);
  --radius: 10px;
  --sidebar: 232px;
  --topbar: 64px;
  font-family: Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--app-bg); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--app-bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

.skip-link {
  position: fixed;
  left: 16px;
  top: -48px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--text);
  color: white;
  text-decoration: none;
}
.skip-link:focus { top: 12px; }

.app-shell { min-height: 100vh; }

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: var(--sidebar);
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 20px 14px;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px 22px;
  text-decoration: none;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--text);
  color: white;
  font-size: 13px;
  letter-spacing: -0.04em;
}

.brand em { color: var(--primary); font-style: normal; }

.nav-label {
  margin: 14px 10px 7px;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.app-nav { display: grid; gap: 4px; }

.app-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 42px;
  padding: 0 11px;
  border-radius: 8px;
  color: #42526a;
  text-decoration: none;
  font-weight: 650;
  transition: background .16s ease, color .16s ease, transform .16s ease;
}

.app-nav a:hover { background: #f2f6fc; color: var(--text); }
.app-nav a:active { transform: translateY(1px); }
.app-nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
.app-nav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.sidebar-foot {
  margin: 30px 8px 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.app-main { min-height: 100vh; padding-left: var(--sidebar); }

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(12px);
}

.mobile-nav-button {
  display: none;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}
.mobile-nav-button svg { width: 20px; height: 20px; }

.topbar-context { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-title { font-size: 15px; font-weight: 750; white-space: nowrap; }
.topbar-divider { width: 1px; height: 20px; background: var(--line); }
.topbar-caption { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }
.api-state { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.api-state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.identity-label { max-width: 180px; overflow: hidden; color: #42526a; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

.page { width: min(1280px, 100%); margin: 0 auto; padding: 30px 30px 64px; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-heading h1 { margin: 0; font-size: clamp(25px, 3vw, 32px); line-height: 1.2; letter-spacing: -0.035em; }
.page-heading p { max-width: 720px; margin: 8px 0 0; color: var(--muted); }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.panel {
  min-width: 0;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(20, 43, 74, .03);
}
.panel-elevated { box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 58px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2, .panel-head h3 { margin: 0; font-size: 15px; letter-spacing: -.01em; }
.panel-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.panel-body { padding: 18px; }

.metric-strip { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); }
.metric { padding: 18px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric-label { color: var(--muted); font-size: 12px; }
.metric-value { margin-top: 5px; font-size: 24px; font-weight: 800; letter-spacing: -.04em; }
.metric-value.good { color: var(--success); }
.metric-value.warn { color: var(--warning); }
.metric-value.bad { color: var(--danger); }

.profile-grid { display: grid; grid-template-columns: minmax(220px, .75fr) 1.25fr; gap: 28px; }
.profile-card { display: flex; align-items: center; gap: 14px; }
.avatar { display: grid; place-items: center; flex: 0 0 auto; width: 48px; height: 48px; border-radius: 50%; background: var(--text); color: white; font-weight: 800; }
.profile-name { font-size: 16px; font-weight: 750; }
.profile-meta { margin-top: 3px; color: var(--muted); font-size: 12px; }
.definition-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 24px; margin: 0; }
.definition-list dt { color: var(--muted); font-size: 11px; }
.definition-list dd { margin: 3px 0 0; overflow-wrap: anywhere; font-weight: 650; }

.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
.field { grid-column: span 6; display: grid; gap: 6px; align-content: start; }
.field.third { grid-column: span 4; }
.field.quarter { grid-column: span 3; }
.field.full { grid-column: 1 / -1; }
.field.compact { gap: 4px; }
.field label, .field-label { color: #42526a; font-size: 12px; font-weight: 700; }
.field small { color: var(--muted); font-size: 11px; }

input, select, textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: 0;
  background: white;
  color: var(--text);
  padding: 9px 11px;
  transition: border-color .16s ease, box-shadow .16s ease;
}
textarea { min-height: 112px; resize: vertical; font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 12px; line-height: 1.6; tab-size: 2; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(23, 105, 255, .12); }
input::placeholder, textarea::placeholder { color: #9aa8bb; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  background: var(--primary);
  color: white;
  font-size: 13px;
  font-weight: 720;
  text-decoration: none;
  white-space: nowrap;
  transition: background .16s ease, border-color .16s ease, transform .16s ease, opacity .16s ease;
}
.button:hover { background: var(--primary-strong); }
.button:active { transform: translateY(1px); }
.button:disabled { cursor: wait; opacity: .58; }
.button.secondary { border-color: var(--line-strong); background: white; color: #334155; }
.button.secondary:hover { border-color: #9db3d0; background: #f8faff; }
.button.danger { background: var(--danger); }
.button.danger:hover { background: #b42334; }
.button.ghost { padding-inline: 9px; border-color: transparent; background: transparent; color: var(--primary); }
.button.ghost:hover { background: var(--primary-soft); }
.button.small { min-height: 30px; padding: 5px 9px; font-size: 11px; }

.button-row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.inline-form { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; }
.inline-form .field { min-width: 180px; flex: 1 1 180px; }
.inline-form .button { margin-bottom: 1px; }

.status { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 3px 8px; border-radius: 999px; background: #eef3f9; color: #4b5e77; font-size: 11px; font-weight: 720; white-space: nowrap; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.good { background: var(--success-soft); color: var(--success); }
.status.warn { background: var(--warning-soft); color: var(--warning); }
.status.bad { background: var(--danger-soft); color: var(--danger); }
.status.info { background: var(--primary-soft); color: var(--primary); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { min-width: 92px; padding: 11px 13px; border-bottom: 1px solid #e8edf5; text-align: left; vertical-align: middle; }
th { background: #f8faff; color: #607089; font-size: 11px; font-weight: 750; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcff; }
.cell-strong { color: var(--text); font-weight: 700; }
.cell-muted { color: var(--muted); }
.cell-actions { display: flex; gap: 4px; min-width: 210px; }
.empty-row { padding: 28px !important; color: var(--muted); text-align: center; }

.response-box { min-height: 96px; max-height: 360px; overflow: auto; margin: 0; padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: #09182d; color: #cfe2ff; font: 12px/1.6 "SFMono-Regular", Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.code-editor { min-height: 240px; color: #a31555; }

.workspace-tabs { display: flex; gap: 4px; margin: 0 0 18px; padding: 4px; overflow-x: auto; border: 1px solid var(--line); border-radius: 9px; background: white; }
.workspace-tabs button { min-height: 36px; padding: 6px 13px; border: 0; border-radius: 7px; cursor: pointer; background: transparent; color: #52657d; font-size: 12px; font-weight: 700; white-space: nowrap; }
.workspace-tabs button:hover { background: #f2f6fc; }
.workspace-tabs button[aria-selected="true"] { background: var(--primary-soft); color: var(--primary); }

.split { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr); gap: 18px; }
.split > *, .stack > * { min-width: 0; }
.stack { display: grid; gap: 18px; align-content: start; }

.auth-stage { min-height: calc(100vh - var(--topbar) - 60px); display: grid; place-items: center; padding: 24px 0 48px; }
.auth-panel { width: min(760px, 100%); overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: white; box-shadow: var(--shadow); }
.auth-layout { display: grid; grid-template-columns: .85fr 1.15fr; }
.auth-aside { padding: 34px; background: #0b1f3a; color: white; }
.auth-aside h1 { margin: 0 0 12px; font-size: 28px; letter-spacing: -.04em; }
.auth-aside p { margin: 0; color: #b9c9de; }
.auth-points { display: grid; gap: 14px; margin-top: 34px; }
.auth-point { display: flex; gap: 10px; color: #dbe8f8; font-size: 12px; }
.auth-point::before { content: ""; flex: 0 0 auto; width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: #49c7ff; }
.auth-content { padding: 34px; }
.auth-content h2 { margin: 0 0 6px; font-size: 20px; }
.auth-content > p { margin: 0 0 22px; color: var(--muted); }
.auth-switch { display: flex; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.auth-switch button { min-height: 38px; padding: 0 14px; border: 0; border-bottom: 2px solid transparent; cursor: pointer; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; }
.auth-switch button[aria-selected="true"] { border-color: var(--primary); color: var(--primary); }
.auth-form { display: grid; gap: 14px; }

.callout { padding: 12px 14px; border: 1px solid #cddfff; border-radius: 8px; background: #f3f7ff; color: #31527f; font-size: 12px; }
.callout.warning { border-color: #f2d9a7; background: var(--warning-soft); color: #7f4e08; }
.callout.danger { border-color: #f6c7cf; background: var(--danger-soft); color: #98283a; }

.toast-region { position: fixed; right: 22px; bottom: 22px; z-index: 90; display: grid; gap: 9px; width: min(360px, calc(100vw - 44px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: white; box-shadow: var(--shadow); animation: toast-in .2s ease both; }
.toast::before { content: ""; width: 9px; height: 9px; margin-top: 5px; border-radius: 50%; background: var(--success); }
.toast.error::before { background: var(--danger); }
.toast-title { font-weight: 750; }
.toast-detail { margin-top: 2px; color: var(--muted); font-size: 11px; word-break: break-word; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.loading-line { height: 2px; overflow: hidden; background: transparent; }
.loading-line::after { content: ""; display: block; width: 38%; height: 100%; transform: translateX(-110%); background: var(--primary); }
body[data-loading="true"] .loading-line::after { animation: loading 1s ease-in-out infinite; }
@keyframes loading { to { transform: translateX(310%); } }

.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

dialog { width: min(520px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 12px; padding: 0; color: var(--text); box-shadow: 0 24px 80px rgba(10, 28, 52, .22); }
dialog::backdrop { background: rgba(10, 28, 52, .42); backdrop-filter: blur(2px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font-size: 16px; }
.dialog-body { padding: 18px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; padding: 14px 18px; border-top: 1px solid var(--line); }

@media (max-width: 1040px) {
  .metric-strip { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n + 2) { border-bottom: 1px solid var(--line); }
  .split { grid-template-columns: 1fr; }
  .profile-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  :root { --sidebar: 250px; }
  .app-sidebar { transform: translateX(-102%); box-shadow: 18px 0 48px rgba(10, 28, 52, .18); transition: transform .2s ease; }
  body[data-nav-open="true"] .app-sidebar { transform: translateX(0); }
  .app-main { padding-left: 0; }
  .mobile-nav-button { display: grid; place-items: center; }
  .app-topbar { padding: 0 16px; }
  .page { padding: 24px 16px 50px; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .auth-layout { grid-template-columns: 1fr; }
  .auth-aside { padding: 26px; }
  .auth-points { display: none; }
  .field, .field.third, .field.quarter { grid-column: 1 / -1; }
  .identity-label { display: none; }
}

@media (max-width: 520px) {
  .page-heading h1 { font-size: 26px; }
  .topbar-caption, .topbar-divider { display: none; }
  .api-state span { display: none; }
  .metric-strip { grid-template-columns: 1fr; }
  .metric { border-right: 0; border-bottom: 1px solid var(--line); }
  .metric:last-child { border-bottom: 0; }
  .definition-list { grid-template-columns: 1fr; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .panel-body { padding: 14px; }
  .auth-content { padding: 26px 20px; }
  .auth-aside { padding: 24px 20px; }
  .button { min-height: 42px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
