/* AI 网关子页 · 对齐 PNG 01/07（Ant Design 风浅蓝 SaaS） */

body.gateway-page {
  background: var(--bg-muted);
}

body.gateway-page .bg-grid {
  background:
    radial-gradient(ellipse 70% 40% at 10% 0%, rgba(219, 234, 254, 0.55), transparent 55%),
    linear-gradient(180deg, #f4f7f9 0%, #f8fafc 100%);
}

body.gateway-page main {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 64px;
}

body.gateway-page .nav {
  position: relative;
  max-width: 1200px;
}

/* 排行：视口最左侧空白区，与居中子窗口分离 */
.gateway-rank-panel {
  position: fixed;
  top: 88px;
  left: 16px;
  width: min(300px, calc((100vw - 1200px) / 2 - 24px));
  max-height: calc(100vh - 100px);
  overflow: auto;
  z-index: 1;
  pointer-events: auto;
}

/* 网关子窗口：并入主页文档流，随页面滚动（不 sticky） */
.gateway-shell {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 1200px;
  margin: 0 auto;
  padding-top: 8px;
  align-items: stretch;
  width: 100%;
}

@media (max-width: 1320px) {
  .gateway-rank-panel {
    display: none;
  }
}

.gateway-traffic-card {
  padding: 22px 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 40px rgba(37, 99, 235, 0.12);
}

.gateway-traffic-eyebrow {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.6px;
  color: var(--accent-deep);
}

.gateway-traffic-title {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}

.gateway-traffic-note {
  margin: 0 0 16px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.gateway-traffic-kpi {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.gateway-traffic-kpi div {
  padding: 12px 10px;
  border-radius: 12px;
  background: linear-gradient(180deg, #eff6ff 0%, #f8fafc 100%);
  border: 1px solid var(--accent-border);
  text-align: center;
}

.gateway-traffic-kpi strong {
  display: block;
  font-size: 24px;
  font-weight: 700;
  color: var(--chart-blue);
  line-height: 1.1;
}

.gateway-traffic-kpi span {
  font-size: 11px;
  color: var(--muted);
}

.gateway-traffic-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.gateway-traffic-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 6px 0;
}

.gateway-traffic-item:last-child {
  margin-bottom: 0;
}

.gateway-traffic-item.is-idle .gateway-traffic-name {
  color: var(--muted);
}

.gateway-traffic-item.is-idle .gateway-traffic-bar::after {
  background: #cbd5e1;
}

.gateway-traffic-rank {
  width: 18px;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
  text-align: center;
}

.gateway-traffic-logo {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  padding: 5px;
  border-radius: 12px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.1);
}

.gateway-traffic-meta {
  flex: 1;
  min-width: 0;
}

.gateway-traffic-name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

.gateway-traffic-bar {
  display: block;
  height: 6px;
  border-radius: 999px;
  background: #e2e8f0;
  position: relative;
  overflow: hidden;
}

.gateway-traffic-bar::after {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--pct, 6%);
  border-radius: inherit;
  background: linear-gradient(90deg, #1890ff, #722ed1);
}

.gateway-traffic-count {
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-deep);
  min-width: 28px;
  text-align: right;
}

.gateway-traffic-item.is-idle .gateway-traffic-count {
  color: var(--muted);
  font-weight: 600;
}

.gateway-traffic-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--chart-blue);
  text-decoration: none;
}

.gateway-traffic-link:hover { text-decoration: underline; }

.gateway-traffic-foot {
  margin: 10px 0 0;
  font-size: 10px;
  color: var(--muted);
  line-height: 1.4;
}

.gw-sidebar {
  width: 100%;
  flex-shrink: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
  position: static;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

body.gateway-page .gw-sidebar-label {
  margin: 0;
  flex-shrink: 0;
}

body.gateway-page .gw-sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
}

body.gateway-page .gw-sidebar-nav a {
  display: inline-block;
  border-left: none;
  border-bottom: 3px solid transparent;
}

body.gateway-page .gw-sidebar-nav a.is-active {
  border-left: none;
  border-bottom-color: var(--chart-blue);
  padding-left: 12px;
}

body.gateway-page .gw-sidebar-note {
  width: 100%;
  margin: 4px 0 0;
  flex-basis: 100%;
}

.gw-sidebar-label {
  margin: 0 0 12px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--muted);
  text-transform: uppercase;
}

.gw-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.gw-sidebar-nav a {
  display: block;
  padding: 9px 12px 9px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  transition: background 0.12s, color 0.12s;
  border-left: 3px solid transparent;
}

.gw-sidebar-nav a:hover {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.gw-sidebar-nav a.is-active {
  background: #e6f7ff;
  color: var(--chart-blue);
  font-weight: 600;
  border-left: 3px solid var(--chart-blue);
  padding-left: 9px;
}

.gw-sidebar-note {
  margin: 16px 8px 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}

.gateway-main {
  flex: 1;
  min-width: 0;
  width: 100%;
}

.gw-page-head {
  margin-bottom: 20px;
}

.gw-page-head h1 {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}

.gw-page-head p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.gw-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.gw-kpi {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.gw-kpi-label {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--muted);
}

.gw-kpi-value {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}

.gw-kpi-row .gw-kpi:nth-child(1) .gw-kpi-value { color: var(--chart-blue); }
.gw-kpi-row .gw-kpi:nth-child(2) .gw-kpi-value { color: var(--chart-green); }
.gw-kpi-row .gw-kpi:nth-child(3) .gw-kpi-value { color: var(--accent-deep); }
.gw-kpi-row .gw-kpi:nth-child(4) .gw-kpi-value { color: var(--chart-purple); }

.gw-kpi-sub {
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--muted);
}

.gw-panel {
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.gw-panel h2 {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.gw-panel h3 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-deep);
}

.gw-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.gw-toolbar label {
  font-size: 13px;
  color: var(--muted);
}

.gw-select,
.gw-input {
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}

.gw-input-mono {
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

.gw-input-wide { width: 100%; max-width: 480px; }

.gw-token-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.gw-token-display {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px;
  border: 1px dashed var(--accent-border);
  border-radius: 8px;
  background: var(--accent-soft);
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  color: var(--text-secondary);
  word-break: break-all;
}

.gw-btn-sm {
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 8px;
}

.gw-table-wrap {
  overflow-x: auto;
}

.gw-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.gw-table th,
.gw-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.gw-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
}

.gw-table td { color: var(--text-secondary); }

.gw-table tr:last-child td { border-bottom: none; }

.gw-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.gw-badge-ok {
  background: #f6ffed;
  color: #389e0d;
}

.gw-badge-off {
  background: var(--accent-soft);
  color: var(--muted);
}

.gw-badge-warn {
  background: #fff7e6;
  color: #d46b08;
}

.gw-link {
  color: var(--accent-deep);
  text-decoration: none;
  font-size: 13px;
}

.gw-link:hover { text-decoration: underline; }

.gw-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.gw-center-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  text-align: left;
  width: 100%;
  font: inherit;
}

.gw-center-card.is-local {
  border-style: dashed;
  background: linear-gradient(135deg, #ecfdf5 0%, var(--bg-soft) 100%);
}

.gw-grid-centers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.gw-center-logo {
  display: block;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  margin-bottom: 4px;
}

.gw-center-logo-lg {
  display: block;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  flex-shrink: 0;
}

.gw-center-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.gw-center-head h2 {
  margin: 4px 0 0;
}

.gw-breadcrumb {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.gw-note {
  margin: 0 0 14px;
  font-size: 12px;
  color: var(--muted);
}

.gw-toolbar-wrap {
  flex-wrap: wrap;
}

.gw-input-grow {
  flex: 1;
  min-width: 200px;
}

.gw-input-saved::placeholder {
  color: var(--muted);
  opacity: 1;
}

.gw-cred-row {
  margin-bottom: 12px;
}

.gw-field-hint-status {
  color: #047857;
  font-size: 12px;
}

.gw-mask-block {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 0;
  padding: 8px 12px;
  border-radius: 8px;
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
}

.gw-mask-display {
  flex: 1;
  min-width: 160px;
  border: 1px dashed #10b981 !important;
  background: #fff !important;
  color: #065f46 !important;
  font-weight: 600;
  cursor: not-allowed;
}

.gw-api-banner {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
  font-size: 13px;
}

.gw-mask-hint {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 8px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  font-size: 13px;
}

.gw-mask-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #0284c7;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

.gw-mask-code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
  color: #0c4a6e;
  word-break: break-all;
}

.gw-panel-detail {
  margin-top: 4px;
}

.gw-center-card:hover,
.gw-center-card.is-selected {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.gw-center-card h3 {
  margin: 8px 0 4px;
  font-size: 15px;
  color: var(--text);
}

.gw-center-card p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.gw-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.gw-tab {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.gw-tab.is-active {
  border-color: var(--chart-blue);
  background: #e6f7ff;
  color: var(--chart-blue);
  font-weight: 600;
}

.gw-tabs-interactive .gw-tab {
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
  font: inherit;
}

.gw-model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.gw-model-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.gw-model-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.gw-model-card-head h3 {
  margin: 0;
  font-size: 14px;
}

.gw-model-kind {
  display: inline-block;
  margin-bottom: 2px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.gw-model-card[data-model-kind="asr"] .gw-model-kind {
  color: #0369a1;
  background: rgba(14, 165, 233, 0.1);
  border-color: rgba(14, 165, 233, 0.25);
}

.gw-model-card[data-model-kind="tts"] .gw-model-kind {
  color: #b45309;
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.25);
}

.gw-model-logo {
  display: block;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
}

.gw-model-card label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  flex-wrap: wrap;
}

.gw-model-card .gw-select {
  flex: 1;
  min-width: 0;
  max-width: 100%;
}

.gw-chart-box {
  min-height: 0;
  padding: 4px 0 0;
  overflow: visible;
}

.gw-chart-box svg.gw-chart-svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  overflow: visible;
}

.gw-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 10px;
  padding: 0 2px 4px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-secondary);
}

.gw-chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
}

.gw-chart-legend-swatch {
  flex-shrink: 0;
  width: 16px;
  height: 3px;
  border-radius: 2px;
}

.gw-chart-legend-swatch--dash {
  background: repeating-linear-gradient(
    90deg,
    #9ca3af 0,
    #9ca3af 4px,
    transparent 4px,
    transparent 7px
  ) !important;
  height: 2px;
}

.gw-donut-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
}

.gw-donut-wrap .gw-chart-svg {
  width: 160px;
  max-width: 100%;
  flex-shrink: 0;
}

.gw-donut-wrap .gw-chart-legend {
  flex: 1;
  min-width: 140px;
  margin-top: 0;
}

.gw-chart-box--trend {
  min-height: 0;
}

.gw-chart-box--bar,
.gw-chart-box--donut {
  min-height: 160px;
}

.gw-chart-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 768px) {
  .gateway-shell { flex-direction: column; }
  .gw-sidebar {
    width: 100%;
    position: static;
  }
  .gw-sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .gw-chart-split { grid-template-columns: 1fr; }
}

.gw-disclaimer {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--bg-soft);
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
}

.gw-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  max-width: min(92vw, 520px);
  padding: 12px 18px;
  border-radius: 8px;
  background: var(--text);
  color: var(--panel);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.gw-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.gw-toast.is-error {
  background: #991b1b;
  color: #fff;
}

.gw-test-result {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid transparent;
  min-height: 44px;
}

.gw-test-result[hidden] {
  display: none !important;
}

.gw-test-result.is-pending {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1e40af;
}

.gw-test-result.is-ok {
  background: #ecfdf5;
  border-color: #6ee7b7;
  color: #065f46;
}

.gw-test-result.is-fail {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
}

.gw-test-result strong {
  display: block;
  margin-bottom: 4px;
}

.gw-test-result p {
  margin: 0;
  word-break: break-word;
}

.gw-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}

.gw-form-row {
  margin-bottom: 14px;
}

.gw-form-row label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
}

.gw-field-hint {
  margin: -2px 0 8px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.gw-chain {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-soft);
  margin-bottom: 10px;
}

.gw-chain-title {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.gw-chain-items {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.gw-chain-arrow { color: var(--muted); }

.gw-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
  font-size: 14px;
}
