/* ==========================================================================
   瑞科验证 · Cloudflare 网关控制台
   纯静态样式，无外部字体 / CDN 依赖。
   ========================================================================== */

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-active: #3730a3;
  --primary-soft: #eef2ff;
  --primary-border: #c7d2fe;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --text: #0f172a;
  --text-secondary: #334155;
  --muted: #64748b;
  --muted-light: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --success: #15803d;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --warning: #b45309;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  --info: #0369a1;
  --info-bg: #f0f9ff;
  --info-border: #bae6fd;
  --radius-lg: 14px;
  --radius-md: 11px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.06);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", "Courier New", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

code,
kbd,
pre,
samp {
  font-family: var(--font-mono);
}

code {
  color: var(--text-secondary);
}

a {
  color: var(--primary);
}

::selection {
  background: rgba(79, 70, 229, 0.18);
}

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

.skip-link {
  position: absolute;
  top: -60px;
  left: 16px;
  z-index: 200;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

/* --------------------------------------------------------------------------
   顶部
   -------------------------------------------------------------------------- */

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 17px 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.brand-mark {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 43px;
  height: 43px;
  border-radius: 11px;
  background: var(--primary);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.3px;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.2);
}

.brand-copy {
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.2px;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.gateway-indicator {
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 58%;
  padding: 6px 8px 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-muted);
}

.indicator-label {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.indicator-url {
  overflow: hidden;
  max-width: 340px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.indicator-arrow {
  flex: 0 0 auto;
  color: var(--muted-light);
  font-size: 12px;
}

.status-pill {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-pill.is-unconfigured {
  border-color: var(--border);
  background: #fff;
  color: var(--muted);
}

.status-pill.is-configured {
  border-color: var(--success-border);
  background: var(--success-bg);
  color: var(--success);
}

.status-pill.is-failed {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger);
}

.status-pill.is-checking {
  border-color: var(--info-border);
  background: var(--info-bg);
  color: var(--info);
}

.status-pill.is-checking .status-dot {
  animation: status-pulse 1.1s ease-in-out infinite;
}

@keyframes status-pulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

/* --------------------------------------------------------------------------
   页面布局
   -------------------------------------------------------------------------- */

.page {
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 22px 24px 36px;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.config-card,
.session-card,
.endpoint-group,
.logs-card,
.call-card {
  padding: 22px 24px;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.section-kicker {
  margin: 0 0 3px;
  color: var(--primary);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.9px;
  line-height: 1.4;
  text-transform: uppercase;
}

.card-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.45;
}

.card-header .section-desc {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
}

.header-side {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
}

.badge-primary {
  border-color: var(--primary-border);
  background: var(--primary-soft);
  color: var(--primary);
}

.badge-success {
  border-color: var(--success-border);
  background: var(--success-bg);
  color: var(--success);
}

.badge-neutral {
  color: var(--muted);
}

.auto-save {
  min-height: 18px;
  color: var(--muted-light);
  font-size: 11.5px;
  text-align: right;
}

/* --------------------------------------------------------------------------
   表单
   -------------------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-label,
.field > span {
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.45;
}

.field-label .optional {
  color: var(--muted-light);
  font-weight: 400;
}

.input,
.textarea,
.select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.45;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input,
.select {
  height: 38px;
  padding: 8px 11px;
}

.textarea {
  min-height: 76px;
  padding: 9px 11px;
  resize: vertical;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--muted-light);
}

.input:hover,
.textarea:hover {
  border-color: #b6c2d2;
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.input:disabled,
.textarea:disabled {
  background: var(--surface-muted);
  color: var(--muted);
  cursor: not-allowed;
}

.input-mono,
.textarea-mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.input-mono::placeholder,
.textarea-mono::placeholder {
  font-family: var(--font-mono);
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.hint strong {
  color: var(--text-secondary);
}

.hint code {
  padding: 1px 4px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-muted);
  font-size: 10.5px;
}

.input-group {
  position: relative;
  display: flex;
}

.input-group .input {
  padding-right: 66px;
}

.input-group .input-action {
  position: absolute;
  top: 50%;
  right: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 30px;
  padding: 0 8px;
  transform: translateY(-50%);
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--primary);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}

.input-group .input-action:hover {
  background: var(--primary-soft);
}

.input-group .input-action:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.form-grid .field-full {
  grid-column: 1 / -1;
}

/* --------------------------------------------------------------------------
   按钮
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px 15px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    color 0.15s ease, box-shadow 0.15s ease;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.18);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
}

.btn-primary:active:not(:disabled) {
  background: var(--primary-active);
}

.btn-outline {
  border-color: var(--border-strong);
  background: #fff;
  color: var(--text-secondary);
}

.btn-outline:hover:not(:disabled) {
  border-color: #aebccd;
  background: var(--surface-muted);
}

.btn-soft {
  border-color: var(--primary-border);
  background: var(--primary-soft);
  color: var(--primary);
}

.btn-soft:hover:not(:disabled) {
  background: #e0e7ff;
}

.btn-danger-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--danger);
}

.btn-danger-ghost:hover:not(:disabled) {
  background: var(--danger-bg);
}

.btn-quiet {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.btn-quiet:hover:not(:disabled) {
  background: var(--surface-muted);
  color: var(--text-secondary);
}

.btn-sm {
  min-height: 31px;
  padding: 6px 10px;
  font-size: 12px;
}

.btn-xs {
  min-height: 26px;
  padding: 4px 8px;
  font-size: 11px;
}

.btn-block {
  width: 100%;
}

/* --------------------------------------------------------------------------
   配置区
   -------------------------------------------------------------------------- */

.config-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 15px 16px;
  margin-top: 18px;
}

.field-url {
  grid-column: span 5;
}

.field-client-id {
  grid-column: span 2;
}

.field-secret {
  grid-column: span 3;
}

.field-maccode {
  grid-column: span 2;
}

.config-actions {
  display: flex;
  grid-column: 1 / -1;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  padding-top: 2px;
}

.config-actions .hint {
  margin-left: 4px;
}

.privacy-bar {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 16px;
  padding: 10px 12px;
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-sm);
  background: var(--warning-bg);
  color: #92400e;
  font-size: 11.5px;
  line-height: 1.55;
}

.privacy-mark {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  margin-top: 1px;
  border-radius: 50%;
  background: #f59e0b;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.privacy-bar strong {
  color: #78350f;
}

.health-box {
  margin-top: 16px;
  padding: 15px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.health-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.health-head h3 {
  margin: 0;
  font-size: 12.5px;
  font-weight: 700;
}

.health-meta {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
}

.health-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.spinner {
  width: 13px;
  height: 13px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.health-facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.health-fact {
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
}

.health-fact-key {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9.5px;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.health-fact-value {
  display: block;
  overflow-wrap: anywhere;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.5;
}

.health-error {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.health-error-title {
  color: var(--danger);
  font-size: 12.5px;
  font-weight: 700;
}

.health-error-text {
  margin: 0;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.health-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

/* --------------------------------------------------------------------------
   会话
   -------------------------------------------------------------------------- */

.session-card {
  margin-top: 20px;
}

.session-login-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 17px;
}

.login-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.login-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.login-panel h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

.login-panel .hint {
  margin-top: -2px;
}

.login-submit-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 1px;
}

.session-current {
  margin-top: 18px;
  padding-top: 17px;
  border-top: 1px solid var(--border);
}

.session-current-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.session-current-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
}

.session-empty {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.session-empty-mark {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: #fff;
  color: var(--muted-light);
  font-family: var(--font-mono);
  font-size: 12px;
}

.session-details {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.session-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px 16px;
}

.session-item {
  min-width: 0;
}

.session-item-label {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.5;
}

.session-item-value {
  display: block;
  overflow-wrap: anywhere;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.55;
}

.session-item-value.is-empty {
  color: var(--muted-light);
}

.session-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid var(--border);
}

/* --------------------------------------------------------------------------
   接口速查
   -------------------------------------------------------------------------- */

.console-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(350px, 405px);
  gap: 20px;
  align-items: start;
  margin-top: 20px;
}

.endpoints-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.endpoint-group {
  min-width: 0;
}

.endpoint-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
  margin-top: 16px;
}

.endpoint-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.endpoint-card:hover {
  border-color: var(--border-strong);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.035);
}

.endpoint-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.endpoint-head-main {
  min-width: 0;
}

.endpoint-head h3 {
  margin: 0;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.45;
}

.endpoint-path {
  display: block;
  overflow: hidden;
  margin-top: 1px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9.5px;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-tag {
  flex: 0 0 auto;
  padding: 2px 6px;
  border: 1px solid var(--primary-border);
  border-radius: 4px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 9px;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
}

.endpoint-desc {
  margin: -3px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.endpoint-card .field {
  gap: 4px;
}

.endpoint-card .field-label,
.endpoint-card .field > span {
  font-size: 11.5px;
}

.endpoint-card .input,
.endpoint-card .textarea {
  font-size: 12.5px;
}

.endpoint-card .input {
  height: 35px;
  padding: 7px 9px;
}

.endpoint-card .textarea {
  min-height: 58px;
  padding: 8px 9px;
}

.endpoint-action {
  display: flex;
  justify-content: flex-end;
  margin-top: auto;
  padding-top: 2px;
}

.endpoint-action .btn {
  min-height: 33px;
  padding: 6px 11px;
  font-size: 12px;
}

.call-card {
  margin-top: 0;
}

.call-form {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px 14px;
  margin-top: 16px;
}

.call-biz {
  min-width: 0;
}

.call-args {
  min-width: 0;
}

.call-args .textarea {
  min-height: 150px;
}

.call-footer {
  display: flex;
  grid-column: 1 / -1;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 2px;
}

.call-footer .hint {
  flex: 1 1 260px;
}

/* --------------------------------------------------------------------------
   日志
   -------------------------------------------------------------------------- */

.logs-column {
  position: sticky;
  top: 18px;
  min-width: 0;
}

.logs-card {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 36px);
}

.logs-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--border);
}

.logs-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logs-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.log-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
}

.logs-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
}

.log-scroll {
  flex: 1 1 auto;
  min-height: 300px;
  max-height: calc(100vh - 205px);
  margin: 0 -5px 0 0;
  padding: 12px 5px 0 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.log-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 250px;
  padding: 30px 18px;
  color: var(--muted);
  text-align: center;
}

.log-empty-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  margin-bottom: 11px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface-muted);
  color: var(--muted-light);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
}

.log-empty strong {
  color: var(--text-secondary);
  font-size: 12.5px;
}

.log-empty p {
  max-width: 250px;
  margin: 4px 0 0;
  font-size: 11px;
  line-height: 1.6;
}

.log-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.log-entry {
  overflow: hidden;
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted-light);
  border-radius: var(--radius-sm);
  background: #fff;
}

.log-entry.is-success {
  border-left-color: var(--success);
}

.log-entry.is-error {
  border-left-color: var(--danger);
}

.log-entry.is-pending {
  border-left-color: var(--info);
}

.log-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.log-summary::-webkit-details-marker {
  display: none;
}

.log-summary::before {
  content: "›";
  flex: 0 0 auto;
  color: var(--muted-light);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1;
  transform: rotate(0deg);
  transition: transform 0.15s ease;
}

.log-entry[open] > .log-summary::before {
  transform: rotate(90deg);
}

.log-summary:hover {
  background: var(--surface-muted);
}

.log-time {
  flex: 0 0 auto;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9.5px;
}

.log-route {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.log-method {
  flex: 0 0 auto;
  color: var(--primary);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 800;
}

.log-path {
  overflow: hidden;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-stats {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
}

.log-badge {
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-muted);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  line-height: 1.6;
  white-space: nowrap;
}

.log-badge.is-good {
  border-color: var(--success-border);
  background: var(--success-bg);
  color: var(--success);
}

.log-badge.is-bad {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger);
}

.log-duration {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9.5px;
  white-space: nowrap;
}

.log-detail {
  padding: 10px 11px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface-muted);
}

.log-error {
  margin-bottom: 10px;
  padding: 8px 9px;
  border: 1px solid var(--danger-border);
  border-radius: 6px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 11px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.log-block {
  margin-top: 9px;
}

.log-block:first-child {
  margin-top: 0;
}

.log-block h4 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  line-height: 1.5;
}

.log-block h4 span {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0;
}

.logs-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  color: var(--muted-light);
  font-size: 10px;
  line-height: 1.5;
}

.logs-footer code {
  font-size: 9.5px;
}

/* 代码 / JSON 展示 */
.code-block,
.json-view {
  max-width: 100%;
  margin: 0;
  padding: 9px 10px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.6;
  tab-size: 2;
  white-space: pre;
}

.code-block {
  max-height: 230px;
}

.json-view {
  max-height: 280px;
}

.json-key {
  color: #4338ca;
}

.json-string {
  color: #047857;
}

.json-number {
  color: #b45309;
}

.json-boolean {
  color: #7e22ce;
}

.json-null {
  color: var(--muted);
}

.json-view.is-raw {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------------------------
   签名说明
   -------------------------------------------------------------------------- */

.docs-card {
  margin-top: 20px;
  overflow: hidden;
}

.docs-card > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.docs-card > summary::-webkit-details-marker {
  display: none;
}

.docs-card > summary:hover {
  background: var(--surface-muted);
}

.docs-summary-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.docs-summary-title {
  color: var(--text);
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.5;
}

.docs-summary-desc {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.docs-summary-hint {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11.5px;
}

.docs-card[open] .docs-summary-hint {
  font-size: 0;
}

.docs-card[open] .docs-summary-hint::after {
  content: "收起";
  font-size: 11.5px;
}

.docs-content {
  padding: 0 22px 22px;
  border-top: 1px solid var(--border);
}

.docs-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 24px;
  padding-top: 18px;
}

.docs-content h3 {
  margin: 0 0 8px;
  font-size: 12.5px;
  font-weight: 700;
}

.docs-content p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.65;
}

.docs-content p:last-child {
  margin-bottom: 0;
}

.header-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 10.5px;
  overflow: hidden;
}

.header-table th,
.header-table td {
  padding: 7px 9px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.header-table tr:last-child th,
.header-table tr:last-child td {
  border-bottom: 0;
}

.header-table th {
  width: 108px;
  background: var(--surface-muted);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-weight: 700;
  white-space: nowrap;
}

.header-table td {
  color: var(--muted);
  line-height: 1.55;
}

.doc-code {
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.7;
  white-space: pre;
}

.cors-note {
  margin-top: 18px;
  padding: 11px 13px;
  border: 1px solid var(--info-border);
  border-radius: var(--radius-sm);
  background: var(--info-bg);
  color: #075985;
  font-size: 11.5px;
  line-height: 1.65;
}

.cors-note strong {
  color: #0c4a6e;
}

.cors-note code {
  padding: 1px 4px;
  border: 1px solid var(--info-border);
  border-radius: 4px;
  background: #fff;
  font-size: 10px;
  color: #0c4a6e;
}

.page-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  margin-top: 25px;
  padding: 0 2px;
  color: var(--muted-light);
  font-size: 10.5px;
  line-height: 1.55;
}

.page-footer code {
  font-size: 10px;
}

/* --------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */

.toast-host {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 9px;
  width: min(390px, calc(100vw - 36px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--muted);
  border-radius: var(--radius-sm);
  background: #fff;
  box-shadow: var(--shadow-md);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.55;
  pointer-events: auto;
  animation: toast-in 0.18s ease-out;
}

.toast.is-success {
  border-left-color: var(--success);
  background: var(--success-bg);
}

.toast.is-error {
  border-left-color: var(--danger);
  background: var(--danger-bg);
}

.toast.is-warning {
  border-left-color: var(--warning);
  background: var(--warning-bg);
}

.toast.is-info {
  border-left-color: var(--info);
  background: var(--info-bg);
}

.toast-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.toast-close {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin: -1px -2px 0 0;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font-size: 15px;
  line-height: 1;
  opacity: 0.6;
  cursor: pointer;
}

.toast-close:hover {
  background: rgba(15, 23, 42, 0.06);
  opacity: 0.9;
}

@keyframes toast-in {
  from {
    transform: translateY(5px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* --------------------------------------------------------------------------
   响应式
   -------------------------------------------------------------------------- */

@media (max-width: 1240px) {
  .config-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .field-url {
    grid-column: 1 / -1;
  }

  .field-client-id,
  .field-secret,
  .field-maccode {
    grid-column: auto;
  }

  .field-maccode {
    grid-column: 1 / -1;
  }

  .console-layout {
    grid-template-columns: minmax(0, 1fr) 360px;
  }

  .gateway-indicator {
    max-width: 52%;
  }

  .indicator-url {
    max-width: 220px;
  }
}

@media (max-width: 1040px) {
  .console-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .logs-column {
    position: static;
    order: 2;
  }

  .endpoints-column {
    order: 1;
  }

  .logs-card {
    max-height: none;
  }

  .log-scroll {
    max-height: 60vh;
  }

  .gateway-indicator {
    max-width: 48%;
  }

  .indicator-label {
    display: none;
  }

  .session-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .header-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .gateway-indicator {
    align-self: flex-start;
    max-width: 100%;
    width: 100%;
  }

  .indicator-url {
    flex: 1 1 auto;
    max-width: none;
  }

  .page {
    padding: 16px 16px 28px;
  }

  .config-card,
  .session-card,
  .endpoint-group,
  .logs-card,
  .call-card {
    padding: 17px;
  }

  .config-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 13px;
  }

  .field-url,
  .field-client-id,
  .field-secret,
  .field-maccode,
  .config-actions {
    grid-column: 1 / -1;
  }

  .session-login-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .endpoint-grid {
    grid-template-columns: minmax(0, 1fr);
  }

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

  .call-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .call-footer {
    grid-column: 1 / -1;
  }

  .docs-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
  }

  .docs-card > summary {
    padding: 16px 17px;
  }

  .docs-content {
    padding: 0 17px 17px;
  }

  .header-table th {
    width: 96px;
  }

  .logs-card {
    padding-bottom: 14px;
  }

  .log-scroll {
    min-height: 220px;
    max-height: 55vh;
  }

  .auto-save {
    text-align: left;
  }
}

@media (max-width: 560px) {
  .brand h1 {
    font-size: 17px;
  }

  .brand p {
    font-size: 11px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 9px;
    font-size: 13px;
  }

  .indicator-url {
    font-size: 10.5px;
  }

  .card-header {
    flex-direction: column;
    gap: 9px;
  }

  .header-side {
    justify-content: flex-start;
  }

  .session-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .session-actions .btn {
    flex: 1 1 auto;
  }

  .config-actions .btn {
    flex: 1 1 calc(50% - 6px);
  }

  .config-actions .hint {
    flex-basis: 100%;
    margin-left: 0;
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .log-summary {
    flex-wrap: wrap;
    gap: 5px 8px;
  }

  .log-route {
    flex-basis: calc(100% - 65px);
  }

  .log-stats {
    margin-left: auto;
  }

  .toast-host {
    right: 12px;
    bottom: 12px;
    width: calc(100vw - 24px);
  }

  .docs-card > summary {
    align-items: flex-start;
  }

  .docs-summary-hint {
    padding-top: 1px;
  }

  .header-table th {
    width: 90px;
  }

  .header-table th,
  .header-table td {
    padding: 6px 7px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --------------------------------------------------------------------------
   hidden 兜底
   .session-empty / .log-empty 等用了 display:flex，会覆盖浏览器默认的
   [hidden] { display: none }，这里显式声明一次，保证 JS 用 hidden 属性可控。
   -------------------------------------------------------------------------- */
[hidden] {
  display: none !important;
}

