:root {
  color-scheme: light;
  --ink: #142b3d;
  --muted: #52697a;
  --navy: #123a5a;
  --navy-deep: #0d2e49;
  --blue: #1769aa;
  --blue-hover: #0d568f;
  --line: #d7e0e7;
  --canvas: #f2f5f7;
  --surface: #ffffff;
  --soft-blue: #eaf3f9;
  --success: #227243;
  --success-bg: #e7f4eb;
  --warning: #8a5b08;
  --warning-bg: #fff4d8;
  --danger: #a92c35;
  --danger-bg: #fff0f0;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  accent-color: var(--blue);
  caret-color: var(--blue);
  scrollbar-color: #9fb3c2 #edf1f4;
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; background: var(--canvas); }
body { margin: 0; min-height: 100vh; }
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { outline-offset: 3px; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid #4e9bd1; }
a { color: var(--blue); text-underline-offset: 3px; }
::selection { color: #fff; background: #1769aa; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, #e8eff4, #f7f9fa 55%, #e7f0f6); }
.login-panel { width: min(100%, 430px); padding: 34px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 14px 34px rgb(0 0 0 / 10%); }
.brand-lockup { display: inline-flex; align-items: center; gap: 11px; color: #fff; font-weight: 700; letter-spacing: .01em; text-decoration: none; }
.login-panel .brand-lockup { color: var(--navy); }
.brand-mark { display: inline-grid; width: 36px; height: 36px; place-items: center; border-radius: 8px; color: #fff; background: #16689f; font-size: 13px; font-weight: 800; letter-spacing: -.04em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-size: 1.65rem; font-weight: 700; letter-spacing: -.02em; }
h2 { margin-bottom: 5px; font-size: 1.15rem; font-weight: 700; }
h3 { margin-bottom: 8px; font-size: 1rem; }
.login-panel h1 { margin-top: 31px; }
.muted, .breadcrumb, .auth-note, .login-footnote, .page-footer { color: var(--muted); }
.login-panel .muted { line-height: 1.6; }
#login-form { display: grid; gap: 10px; margin-top: 25px; }
label, legend, .field-label { font-weight: 600; }
input:not([type="checkbox"]), textarea, select { width: 100%; min-height: 42px; border: 1px solid #aebdca; border-radius: 6px; padding: 9px 11px; color: var(--ink); background: #fff; }
input::placeholder, textarea::placeholder { color: #536a7a; opacity: 1; }
textarea { min-height: 94px; resize: vertical; }
input:disabled, textarea:disabled, select:disabled { color: #647782; background: #eef2f4; }
.button { min-height: 40px; border: 1px solid transparent; border-radius: 6px; padding: 8px 15px; font-weight: 650; cursor: pointer; transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease; }
.button:active { transform: translateY(1px); }
.button:disabled { cursor: wait; opacity: .65; }
.button-primary { color: #fff; background: var(--blue); }
.button-primary:hover:not(:disabled) { background: var(--blue-hover); }
.button-secondary { border-color: #9aafbe; color: var(--navy); background: #fff; }
.button-secondary:hover:not(:disabled) { border-color: var(--blue); background: var(--soft-blue); }
.button-wide { width: 100%; margin-top: 8px; }
.login-footnote { margin: 18px 0 0; font-size: .85rem; line-height: 1.55; }
.form-message { min-height: 1.45em; margin: 9px 0 0; color: var(--danger); font-size: .92rem; }
.form-message.success { color: var(--success); }

.app-shell { display: grid; grid-template-columns: 245px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; display: flex; flex-direction: column; height: 100vh; padding: 24px 16px 18px; color: #eaf3f8; background: var(--navy-deep); }
.sidebar .brand-lockup { padding: 2px 7px 25px; font-size: .96rem; }
.sidebar .brand-mark { color: var(--navy-deep); background: #fff; }
.nav-caption { margin: 8px 10px 10px; color: #b8cbd8; font-size: .8rem; font-weight: 650; }
.primary-nav { display: grid; gap: 5px; }
.primary-nav a { padding: 11px 12px; border-radius: 6px; color: #eaf3f8; text-decoration: none; font-weight: 550; }
.primary-nav a:hover { background: #224a68; }
.primary-nav a[aria-current="page"] { border: 1px solid #8fd3f4; padding: 10px 11px; color: #fff; background: #27628b; }
.sidebar-bottom { display: grid; grid-template-columns: 9px 1fr; gap: 7px 9px; align-items: center; margin-top: auto; padding: 13px 9px 2px; border-top: 1px solid #3a5a72; color: #d5e3ec; font-size: .82rem; }
.connection-dot { width: 8px; height: 8px; border-radius: 50%; background: #d1a341; }
.connection-dot.connected { background: #57c57a; }
.text-button { grid-column: 2; justify-self: start; border: 0; padding: 3px 0; color: #e1edf4; background: transparent; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.workspace { width: min(100%, 1440px); padding: 28px clamp(18px, 3.4vw, 48px) 20px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.breadcrumb { margin: 0 0 5px; font-size: .88rem; }
.topbar h1 { margin: 0; color: #173c59; }
.auth-strip, .query-panel, .keys-panel { margin-top: 20px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.auth-strip { padding: 18px 20px 14px; }
.auth-strip-heading, .section-heading, .result-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.auth-strip-heading h2, .section-heading h2, .result-heading h3 { margin: 0; }
.status-badge { padding: 5px 9px; border-radius: 99px; font-size: .79rem; font-weight: 700; }
.status-neutral { color: #475d6d; background: #e9eef1; }
.status-good { color: var(--success); background: var(--success-bg); }
.status-warn { color: var(--warning); background: var(--warning-bg); }
.status-bad { color: var(--danger); background: var(--danger-bg); }
.auth-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-top: 17px; }
.auth-grid > div { display: grid; gap: 6px; min-width: 0; }
.detail-label { color: var(--muted); font-size: .82rem; }
.auth-grid strong { overflow-wrap: anywhere; font-size: .94rem; font-weight: 650; }
.auth-note { margin: 15px 0 8px; font-size: .8rem; line-height: 1.5; }
.cookie-list { display: flex; flex-wrap: wrap; gap: 6px; }
.cookie-chip { padding: 4px 8px; border: 1px solid #ccdae3; border-radius: 5px; color: #36566d; background: #f5f8fa; font-size: .78rem; }
.role-config { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 11px; }
.role-config > summary { cursor: pointer; color: var(--navy); font-weight: 650; }
.role-config > summary span { margin-left: 8px; color: var(--muted); font-size: .84rem; font-weight: 400; }
.role-form { max-width: 760px; margin-top: 13px; }
.role-form > label { display: block; margin-bottom: 6px; font-size: .88rem; font-weight: 600; }
.role-form-row { display: flex; align-items: center; gap: 10px; }
.role-form-row input { flex: 1; min-width: 160px; }
.redirect-list { margin-top: 13px; border-top: 1px solid #e2e9ee; padding-top: 12px; }
.redirect-list ol { display: grid; gap: 5px; margin: 0; padding-left: 22px; color: #36566d; font-size: .82rem; }
.query-panel, .keys-panel { padding: 20px; }
.section-heading { align-items: flex-start; margin-bottom: 17px; }
.section-heading .muted { margin: 5px 0 0; line-height: 1.5; }
.query-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px 15px; align-items: end; }
.form-field { display: grid; gap: 6px; min-width: 0; }
.form-field label { font-size: .88rem; }
.form-field textarea { grid-column: 1 / -1; }
.field-wide { grid-column: 1 / -1; }
.advanced-query { border: 1px solid var(--line); border-radius: 6px; padding: 11px 13px; background: #f8fafb; }
.advanced-query summary { color: var(--navy); font-weight: 650; cursor: pointer; }
.advanced-query[open] summary { margin-bottom: 14px; }
.advanced-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px 15px; }
.advanced-query .muted { margin: 12px 0 0; font-size: .82rem; line-height: 1.55; }
.query-form .button { justify-self: start; min-width: 132px; }
.result-panel { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 16px; }
.result-heading { margin-bottom: 10px; color: var(--navy); }
.result-heading span { color: var(--muted); font-size: .85rem; }
.query-criteria, .query-request-panel, .query-warning-panel { margin: 0 0 12px; border: 1px solid #d9e2e8; border-radius: 6px; padding: 11px 13px; background: #f8fafb; }
.query-criteria h4, .result-subheading h4, .query-warning-panel h4 { margin: 0; color: var(--navy); font-size: .88rem; }
.query-criteria dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 16px; margin: 10px 0 0; }
.query-criteria dl > div { min-width: 0; }
.query-criteria dt { color: var(--muted); font-size: .76rem; }
.query-criteria dd { margin: 2px 0 0; overflow-wrap: anywhere; font-size: .84rem; }
.result-subheading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.result-subheading span { color: var(--muted); font-size: .78rem; }
.query-request-panel ol, .query-warning-panel ul { display: grid; gap: 5px; margin: 9px 0 0; padding-left: 22px; color: #36566d; font-size: .8rem; overflow-wrap: anywhere; }
.query-warning-panel { border-color: #ead9a5; background: var(--warning-bg); }
.query-warning-panel h4 { color: #684c0d; }
.result-content { max-height: 560px; overflow: auto; border: 1px solid #d9e2e8; border-radius: 6px; background: #fbfcfd; }
.result-table-section + .result-table-section { margin-top: 14px; }
.result-table-section h4 { margin: 0; padding: 10px 11px; color: var(--navy); background: #f2f6f8; font-size: .86rem; }
.result-table { width: 100%; border-collapse: collapse; font-size: .83rem; }
.result-table th, .result-table td { min-width: 105px; border-bottom: 1px solid #e1e8ed; padding: 9px 10px; text-align: left; vertical-align: top; }
.result-table th { position: sticky; top: 0; color: #234b67; background: #eaf2f7; }
.result-table td { overflow-wrap: anywhere; }
.result-json { margin: 0; padding: 14px; color: #203a4f; white-space: pre-wrap; overflow-wrap: anywhere; font: .82rem/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; }
.key-form { display: grid; grid-template-columns: minmax(180px, 1fr) auto auto; gap: 12px; align-items: end; }
.key-form fieldset { display: flex; gap: 12px; min-height: 42px; align-items: center; margin: 0; border: 1px solid #c5d2dc; border-radius: 6px; padding: 4px 10px 7px; }
.key-form legend { padding: 0 4px; color: var(--muted); font-size: .75rem; }
.check-row { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 500; white-space: nowrap; }
.check-row input { width: 16px; height: 16px; }
.one-time-key { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 14px; border: 1px solid #d9c88e; border-radius: 6px; padding: 12px; background: #fff9e8; }
.one-time-key > div { display: grid; gap: 8px; min-width: 0; }
.one-time-key strong { color: #684c0d; font-size: .86rem; }
.one-time-key code { overflow-wrap: anywhere; color: #183a55; }
.key-table-wrap { overflow-x: auto; margin-top: 17px; }
.key-table { width: 100%; border-collapse: collapse; font-size: .84rem; text-align: left; }
.key-table th, .key-table td { border-bottom: 1px solid #e0e7ec; padding: 10px 8px; vertical-align: top; }
.key-table th { color: #425e72; font-size: .78rem; font-weight: 700; }
.key-table td { overflow-wrap: anywhere; }
.key-table .text-button { grid-column: auto; color: var(--danger); }
.api-guidance { margin: 14px 0 0; color: var(--muted); font-size: .82rem; line-height: 1.55; }
.api-guidance code { color: #183e5b; }
.page-footer { padding: 18px 0 4px; font-size: .8rem; text-align: center; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 205px minmax(0, 1fr); }
  .workspace { padding-right: 20px; padding-left: 20px; }
  .auth-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .query-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .advanced-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .key-form { grid-template-columns: 1fr 1fr; }
  .key-form .field-label, .key-form > input { grid-column: 1; }
  .key-form fieldset { grid-column: 2; grid-row: 1 / span 2; }
  .key-form button { grid-column: 1; }
  .query-criteria dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .app-shell { display: block; }
  .sidebar { position: static; height: auto; padding: 12px 14px 10px; }
  .sidebar .brand-lockup { padding: 0 2px 11px; }
  .nav-caption, .sidebar-bottom { display: none; }
  .primary-nav { display: flex; overflow-x: auto; gap: 3px; margin: 0 -3px; }
  .primary-nav a { flex: 0 0 auto; padding: 9px 11px; font-size: .86rem; }
  .primary-nav a[aria-current="page"] { border: 0; border-bottom: 3px solid #8fd3f4; padding-left: 11px; }
  .workspace { padding: 18px 13px 16px; }
  .topbar { align-items: flex-start; padding-bottom: 15px; }
  .topbar h1 { font-size: 1.35rem; }
  .topbar .button { max-width: 124px; min-height: 38px; padding: 7px 9px; font-size: .8rem; }
  .auth-strip, .query-panel, .keys-panel { margin-top: 13px; padding: 15px 13px; }
  .auth-grid { gap: 13px 9px; }
  .auth-grid strong { font-size: .86rem; }
  .auth-note { font-size: .76rem; }
  .role-form-row { align-items: stretch; flex-direction: column; }
  .query-form { grid-template-columns: 1fr; }
  .advanced-fields { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .key-form { grid-template-columns: 1fr; }
  .key-form .field-label, .key-form > input, .key-form fieldset, .key-form button { grid-column: 1; grid-row: auto; }
  .key-form fieldset { justify-content: flex-start; }
  .one-time-key { align-items: flex-start; flex-direction: column; }
  .query-criteria dl { grid-template-columns: 1fr; }
  .login-panel { padding: 25px 21px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
