body {
  min-height: 100vh;
  background: var(--bg);
  overflow-x: hidden;
}

.gateway-shell {
  display: grid;
  grid-template-columns: minmax(0, 310px) minmax(0, 1fr);
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

.gateway-sidebar {
  border-right: 1px solid var(--border);
  background: var(--surface-1);
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.gateway-main {
  padding: 24px 28px 46px;
  min-width: 0;
  overflow-x: hidden;
}

.gateway-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.gateway-brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--primary-bg);
  color: var(--primary);
}

.gateway-brand-title {
  font-size: 15px;
  font-weight: 600;
}

.gateway-brand-sub {
  font-size: 12px;
  color: var(--fg-muted);
}

.gateway-meta {
  margin-bottom: 24px;
  padding: 16px;
}

.gateway-meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--fg-muted);
}

.gateway-meta-row + .gateway-meta-row {
  margin-top: 10px;
}

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

.service-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: var(--surface-2);
}

.service-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
}

.service-detail {
  font-size: 11px;
  color: var(--fg-muted);
  margin-top: 7px;
  word-break: break-word;
}

.sidebar-logout {
  width: 100%;
  justify-content: center;
  margin-top: 20px;
}

.gateway-head {
  padding-top: 0;
}

.gateway-stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

.gateway-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 18px;
}

.gateway-main .card,
.gateway-main .stat-card,
.gateway-main .code,
.gateway-main .code pre,
.gateway-control,
.gateway-control > *,
.gateway-grid > *,
.gateway-stats > * {
  min-width: 0;
}

.gateway-main .code {
  max-width: 100%;
}

.gateway-main .code pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.gateway-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  margin-bottom: 18px;
}

.model-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  width: min(360px, 100%);
  min-width: 0;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-1);
}

.model-option {
  min-height: 58px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 9px 12px;
  color: var(--fg-muted);
  text-align: left;
}

.model-option span {
  display: block;
  font-size: 13px;
  font-weight: 650;
  color: var(--fg);
}

.model-option small {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  color: var(--fg-muted);
}

.model-option.active {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.web-search-status {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.small-stat {
  font-size: 17px;
  line-height: 1.3;
  padding-top: 7px;
}

.copy-btn {
  color: var(--fg-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
}

.copy-btn:hover {
  color: var(--fg);
  border-color: var(--border-strong);
  background: hsl(0 0% 100% / 0.04);
}

.request-table-wrap {
  max-height: 460px;
  overflow: auto;
}

.login-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: hsl(240 5% 4% / 0.82);
  backdrop-filter: blur(18px);
}

.login-modal.visible {
  display: flex;
}

.login-card {
  width: min(440px, 100%);
}

.login-card h2 {
  font-size: 25px;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.login-form {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.input-text {
  width: 100%;
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  color: var(--fg);
  border-radius: 9px;
  padding: 11px 12px;
  font: inherit;
  outline: none;
}

.input-text:focus {
  border-color: var(--primary-dim);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.login-btn {
  white-space: nowrap;
}

.login-error {
  margin-top: 12px;
  color: var(--red);
  font-size: 12px;
  min-height: 18px;
}

@media (max-width: 960px) {
  .gateway-shell {
    grid-template-columns: 1fr;
    max-width: none;
  }

  .gateway-sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .gateway-control {
    grid-template-columns: 1fr;
  }

  .model-toggle {
    width: 100%;
  }
}

@media (max-width: 620px) {
  .gateway-main {
    padding: 20px 16px 34px;
  }

  .login-form {
    flex-direction: column;
  }
}
