:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-soft: #fafafe;
  --surface-tint: #f2f0ff;
  --text: #222432;
  --text-soft: #686b7b;
  --text-faint: #9699a8;
  --line: #e6e7ee;
  --line-strong: #d8dae5;
  --primary: #6759d1;
  --primary-dark: #5446bd;
  --primary-soft: #eeebff;
  --success: #19875d;
  --success-soft: #eaf8f2;
  --warning: #a86413;
  --warning-soft: #fff6e7;
  --danger: #c84949;
  --danger-soft: #fff0f0;
  --info: #2771bf;
  --info-soft: #edf6ff;
  --shadow-sm: 0 1px 2px rgba(33, 35, 52, 0.04), 0 4px 14px rgba(33, 35, 52, 0.04);
  --shadow-md: 0 18px 54px rgba(32, 32, 55, 0.14);
  --radius-sm: 9px;
  --radius: 14px;
  --radius-lg: 20px;
  --sidebar-width: 248px;
  --font: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 80% -10%, rgba(110, 91, 218, 0.08), transparent 28rem),
    var(--bg);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

button,
select,
input[type="checkbox"] {
  cursor: pointer;
}

input,
select {
  min-width: 0;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(103, 89, 209, 0.2);
  outline-offset: 1px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  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;
}

.noscript {
  padding: 14px 20px;
  color: #722;
  background: #fff0f0;
  text-align: center;
}

.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button {
  display: inline-grid;
  width: 36px;
  height: 36px;
  padding: 0;
  place-items: center;
  color: var(--text-soft);
  background: transparent;
  border: 0;
  border-radius: 9px;
}

.icon-button:hover {
  color: var(--text);
  background: var(--surface-soft);
}

.button {
  display: inline-flex;
  min-height: 40px;
  padding: 0 16px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 650;
  line-height: 1;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(40, 42, 64, 0.08);
}

.button:active:not(:disabled) {
  transform: translateY(0);
}

.button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.button .icon {
  width: 18px;
  height: 18px;
}

.button-primary {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 6px 16px rgba(103, 89, 209, 0.18);
}

.button-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.button-quiet {
  color: var(--text-soft);
  background: var(--surface);
  border-color: var(--line);
}

.button-quiet:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--line-strong);
}

.button-danger {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.button-danger:hover:not(:disabled) {
  background: #b43a3a;
}

.button-full {
  width: 100%;
}

.text-button {
  padding: 5px 0;
  color: var(--primary);
  font-weight: 650;
  background: none;
  border: 0;
}

.text-button:hover {
  color: var(--primary-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Login */

.login-view {
  display: grid;
  min-height: 100vh;
  padding: 32px 20px;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 40%, rgba(112, 92, 222, 0.18), transparent 24rem),
    linear-gradient(145deg, #f8f8fc 0%, #f1f1fa 100%);
}

.login-view::before,
.login-view::after {
  position: fixed;
  width: 360px;
  height: 360px;
  content: "";
  border: 1px solid rgba(103, 89, 209, 0.1);
  border-radius: 50%;
  pointer-events: none;
}

.login-view::before {
  top: -210px;
  right: -90px;
  box-shadow: 0 0 0 55px rgba(103, 89, 209, 0.025), 0 0 0 110px rgba(103, 89, 209, 0.018);
}

.login-view::after {
  bottom: -240px;
  left: -110px;
  box-shadow: 0 0 0 55px rgba(103, 89, 209, 0.025), 0 0 0 110px rgba(103, 89, 209, 0.018);
}

.login-card {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  padding: 42px 42px 34px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 24px;
  box-shadow: 0 25px 70px rgba(44, 42, 76, 0.14);
  text-align: center;
  backdrop-filter: blur(18px);
}

.login-brand {
  position: relative;
  display: grid;
  width: 68px;
  height: 68px;
  margin: 0 auto 18px;
  place-items: center;
}

.login-brand-glow {
  position: absolute;
  inset: -10px;
  z-index: -1;
  background: rgba(103, 89, 209, 0.18);
  border-radius: 22px;
  filter: blur(14px);
}

.brand-mark {
  display: inline-grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #7769de, #5547bd);
  border-radius: 12px;
  box-shadow: 0 8px 18px rgba(88, 72, 191, 0.24);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.05em;
}

.brand-mark-large {
  width: 62px;
  height: 62px;
  border-radius: 19px;
  font-size: 28px;
}

.eyebrow,
.section-eyebrow,
.panel-kicker,
.modal-kicker {
  margin: 0;
  color: var(--primary);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.login-card h1 {
  margin: 4px 0 8px;
  font-size: 27px;
  letter-spacing: -0.03em;
}

.login-intro {
  margin: 0 auto 30px;
  color: var(--text-soft);
}

.login-form {
  text-align: left;
}

.login-form > label,
.field > span {
  display: block;
  margin-bottom: 7px;
  color: #474957;
  font-size: 13px;
  font-weight: 650;
}

.login-form .button {
  margin-top: 18px;
}

.password-field {
  position: relative;
}

.password-field input {
  width: 100%;
  padding-right: 46px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="number"],
input[type="search"],
select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input:hover,
select:hover {
  border-color: #c5c7d4;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(103, 89, 209, 0.1);
}

input::placeholder {
  color: #b0b2be;
}

.form-error {
  margin: 8px 0 -8px;
  color: var(--danger);
  font-size: 12px;
}

.login-security {
  display: flex;
  margin-top: 26px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-faint);
  font-size: 11px;
}

.login-security .icon {
  width: 16px;
  height: 16px;
  color: var(--success);
}

/* Application shell */

.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  width: var(--sidebar-width);
  height: 100vh;
  flex-direction: column;
  color: #ecebf5;
  background:
    radial-gradient(circle at 15% 0%, rgba(125, 107, 226, 0.2), transparent 18rem),
    #262532;
  border-right: 1px solid rgba(255, 255, 255, 0.04);
}

.sidebar-brand {
  display: flex;
  min-height: 84px;
  padding: 20px 18px;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand > div {
  min-width: 0;
}

.sidebar-brand strong,
.sidebar-brand small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-brand strong {
  color: #fff;
  font-size: 14px;
}

.sidebar-brand small {
  margin-top: 2px;
  color: #92909f;
  font-size: 10px;
}

.sidebar-close {
  display: none;
  margin-left: auto;
  color: #afadba;
}

.sidebar-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-nav {
  flex: 1;
  padding: 14px 12px;
  overflow-y: auto;
}

.nav-group-label {
  margin: 18px 12px 7px;
  color: #777582;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.nav-group-label:first-child {
  margin-top: 2px;
}

.nav-item {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 43px;
  padding: 0 12px;
  align-items: center;
  gap: 12px;
  color: #aaa8b5;
  background: transparent;
  border: 0;
  border-radius: 10px;
  text-align: left;
  transition: color 120ms ease, background 120ms ease;
}

.nav-item:hover {
  color: #f4f3fa;
  background: rgba(255, 255, 255, 0.055);
}

.nav-item.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(117, 98, 217, 0.3), rgba(117, 98, 217, 0.12));
}

.nav-item.active::before {
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 0;
  width: 3px;
  content: "";
  background: #9184f1;
  border-radius: 0 3px 3px 0;
}

.nav-item .icon {
  width: 19px;
  height: 19px;
}

.sidebar-footer {
  padding: 14px 16px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.service-indicator {
  display: flex;
  padding: 10px 8px;
  align-items: flex-start;
  gap: 10px;
}

.service-indicator strong,
.service-indicator small {
  display: block;
}

.service-indicator strong {
  color: #dcdbe4;
  font-size: 11px;
}

.service-indicator small {
  margin-top: 2px;
  color: #777582;
  font-size: 9px;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-top: 4px;
  flex: 0 0 auto;
  border-radius: 50%;
}

.status-online {
  background: #48c792;
  box-shadow: 0 0 0 4px rgba(72, 199, 146, 0.12);
}

.main-column {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: 84px;
  padding: 14px 30px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.topbar-title {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.topbar-title h1 {
  margin: 0;
  font-size: 19px;
  letter-spacing: -0.02em;
}

.topbar-title p {
  margin: 2px 0 0;
  color: var(--text-faint);
  font-size: 11px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.last-refresh {
  margin-right: 4px;
  color: var(--text-faint);
  font-size: 10px;
}

.mobile-menu {
  display: none;
}

.content {
  width: min(100%, 1440px);
  min-height: calc(100vh - 84px);
  padding: 28px 30px 48px;
}

.page-section {
  display: none;
  animation: page-in 180ms ease;
}

.page-section.active {
  display: block;
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Shared panels */

.panel {
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.panel-heading {
  display: flex;
  margin-bottom: 18px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel-heading h3 {
  margin: 2px 0 0;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.section-toolbar {
  display: flex;
  margin-bottom: 22px;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.section-toolbar h2 {
  margin: 3px 0 4px;
  font-size: 24px;
  letter-spacing: -0.035em;
}

.section-toolbar p:last-child {
  margin: 0;
  color: var(--text-soft);
  font-size: 12px;
}

.hero-card {
  position: relative;
  display: flex;
  min-height: 185px;
  padding: 30px 32px;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(circle at 85% 0%, rgba(255, 255, 255, 0.18), transparent 17rem),
    linear-gradient(125deg, #6557cd, #7a68d7);
  border-radius: var(--radius-lg);
  box-shadow: 0 14px 34px rgba(91, 72, 188, 0.22);
}

.hero-card::after {
  position: absolute;
  right: -58px;
  bottom: -135px;
  width: 280px;
  height: 280px;
  content: "";
  border: 35px solid rgba(255, 255, 255, 0.06);
  border-radius: 50%;
}

.hero-copy,
.hero-endpoint {
  position: relative;
  z-index: 1;
}

.hero-status {
  display: inline-flex;
  padding: 6px 10px;
  align-items: center;
  gap: 7px;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 100px;
  font-size: 10px;
  font-weight: 650;
}

.pulse-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #6ce4ac;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(108, 228, 172, 0.13);
}

.pulse-dot.paused {
  background: #ffd17b;
  box-shadow: 0 0 0 4px rgba(255, 209, 123, 0.14);
}

.hero-copy h3 {
  max-width: 560px;
  margin: 16px 0 7px;
  font-size: clamp(21px, 2.1vw, 30px);
  line-height: 1.3;
  letter-spacing: -0.04em;
}

.hero-copy p {
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

.hero-endpoint {
  width: min(390px, 42%);
  padding: 16px;
  background: rgba(28, 23, 68, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  backdrop-filter: blur(12px);
}

.hero-endpoint > span {
  display: block;
  margin-bottom: 8px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 10px;
  font-weight: 650;
}

.copy-field {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.copy-field code {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  color: #fff;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero-endpoint .icon-button {
  color: rgba(255, 255, 255, 0.8);
}

.hero-endpoint .icon-button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.summary-grid {
  display: grid;
  margin: 18px 0;
  gap: 14px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.summary-card {
  position: relative;
  min-height: 116px;
  padding: 17px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.summary-card::after {
  position: absolute;
  right: -28px;
  bottom: -34px;
  width: 90px;
  height: 90px;
  content: "";
  background: var(--card-accent, var(--primary-soft));
  border-radius: 50%;
  opacity: 0.55;
}

.summary-card > * {
  position: relative;
  z-index: 1;
}

.summary-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.summary-card-label {
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 600;
}

.summary-card-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  color: var(--card-color, var(--primary));
  background: var(--card-accent, var(--primary-soft));
  border-radius: 9px;
}

.summary-card-icon .icon {
  width: 16px;
  height: 16px;
}

.summary-card-value {
  display: block;
  margin-top: 12px;
  font-size: 24px;
  font-weight: 760;
  line-height: 1;
  letter-spacing: -0.04em;
}

.summary-card-meta {
  display: block;
  margin-top: 7px;
  color: var(--text-faint);
  font-size: 9px;
}

.overview-grid {
  display: grid;
  margin-bottom: 18px;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.checklist,
.health-list {
  display: grid;
  gap: 2px;
}

.check-item {
  display: flex;
  min-height: 54px;
  padding: 8px 5px;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.check-item:last-child {
  border-bottom: 0;
}

.check-icon {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--text-faint);
  background: var(--surface-soft);
  border-radius: 50%;
}

.check-icon.complete {
  color: var(--success);
  background: var(--success-soft);
}

.check-icon .icon {
  width: 15px;
  height: 15px;
}

.check-copy {
  min-width: 0;
  flex: 1;
}

.check-copy strong,
.check-copy small {
  display: block;
}

.check-copy strong {
  font-size: 12px;
}

.check-copy small {
  margin-top: 2px;
  color: var(--text-faint);
  font-size: 9px;
}

.check-item .text-button {
  flex: 0 0 auto;
  font-size: 10px;
}

.health-row {
  display: flex;
  min-height: 54px;
  padding: 8px 5px;
  align-items: center;
  gap: 11px;
  border-bottom: 1px solid var(--line);
}

.health-row:last-child {
  border-bottom: 0;
}

.provider-glyph {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 9px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.health-copy {
  min-width: 0;
  flex: 1;
}

.health-copy strong,
.health-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.health-copy strong {
  font-size: 11px;
}

.health-copy small {
  margin-top: 2px;
  color: var(--text-faint);
  font-size: 9px;
}

.status-chip {
  display: inline-flex;
  min-height: 24px;
  padding: 3px 8px;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  border-radius: 100px;
  font-size: 9px;
  font-weight: 700;
}

.status-chip > span {
  width: 6px;
  height: 6px;
  background: currentColor;
  border-radius: 50%;
}

.status-chip-success {
  color: var(--success);
  background: var(--success-soft);
}

.status-chip-muted {
  color: #858896;
  background: #f0f1f5;
}

.status-chip-warning {
  color: var(--warning);
  background: var(--warning-soft);
}

.status-chip-danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.notice {
  display: flex;
  margin-bottom: 18px;
  padding: 13px 15px;
  align-items: flex-start;
  gap: 11px;
  border: 1px solid transparent;
  border-radius: 11px;
}

.notice .icon {
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

.notice strong,
.notice span {
  display: block;
}

.notice strong {
  font-size: 11px;
}

.notice span {
  margin-top: 2px;
  font-size: 10px;
  opacity: 0.82;
}

.notice-safe {
  color: #23664f;
  background: var(--success-soft);
  border-color: #d4eee3;
}

.notice-warning {
  color: #80500f;
  background: var(--warning-soft);
  border-color: #f2dfbb;
}

.notice-compact {
  margin: 18px 0 0;
}

/* Provider cards */

.card-list {
  display: grid;
  gap: 14px;
}

.provider-card {
  display: grid;
  padding: 20px;
  align-items: center;
  gap: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  grid-template-columns: minmax(190px, 1.1fr) minmax(240px, 1.5fr) minmax(120px, 0.7fr) auto;
}

.provider-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 13px;
}

.provider-identity .provider-glyph {
  width: 42px;
  height: 42px;
  font-size: 13px;
}

.provider-identity h3,
.provider-identity p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.provider-identity h3 {
  margin: 0;
  font-size: 14px;
}

.provider-identity p {
  margin: 3px 0 0;
  color: var(--text-faint);
  font-size: 10px;
}

.provider-detail {
  min-width: 0;
}

.provider-detail span,
.provider-detail code {
  display: block;
}

.provider-detail span {
  margin-bottom: 4px;
  color: var(--text-faint);
  font-size: 9px;
  font-weight: 650;
}

.provider-detail code {
  overflow: hidden;
  color: #555767;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.provider-key {
  display: flex;
  align-items: center;
  gap: 7px;
}

.provider-key .icon {
  width: 13px;
  height: 13px;
  color: var(--success);
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}

.action-button {
  display: inline-flex;
  height: 32px;
  padding: 0 9px;
  align-items: center;
  gap: 5px;
  color: var(--text-soft);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 650;
}

.action-button:hover {
  color: var(--text);
  background: var(--surface-soft);
  border-color: var(--line);
}

.action-button.action-danger:hover {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #f2d6d6;
}

.action-button .icon {
  width: 15px;
  height: 15px;
}

.action-button .spinner {
  width: 13px;
  height: 13px;
  border-width: 2px;
  border-top-color: currentColor;
}

/* Tables */

.table-panel {
  padding: 0;
  overflow: hidden;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
}

.data-table th,
.data-table td {
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.data-table th {
  color: var(--text-faint);
  background: var(--surface-soft);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.04em;
}

.data-table td {
  color: #545664;
  font-size: 10px;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover {
  background: #fcfcfe;
}

.data-table .primary-cell {
  color: var(--text);
  font-size: 11px;
  font-weight: 650;
}

.data-table .mono {
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 9px;
}

.data-table .muted {
  color: var(--text-faint);
}

.data-table .error-cell {
  max-width: 270px;
  overflow: hidden;
  color: var(--danger);
  text-overflow: ellipsis;
}

.route-flow {
  display: flex;
  align-items: center;
  gap: 7px;
}

.route-flow .icon {
  width: 14px;
  height: 14px;
  color: var(--text-faint);
}

.route-model {
  padding: 4px 7px;
  color: #5146a0;
  background: var(--primary-soft);
  border-radius: 6px;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 9px;
}

.token-prefix {
  display: inline-block;
  padding: 5px 8px;
  color: #505365;
  background: #f2f3f7;
  border-radius: 6px;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 9px;
}

.limit-stack {
  display: flex;
  gap: 4px;
}

.limit-stack span {
  padding: 3px 6px;
  color: var(--text-soft);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 8px;
}

.usage-meter {
  width: 112px;
}

.usage-labels {
  display: flex;
  margin-bottom: 5px;
  align-items: baseline;
  gap: 3px;
}

.usage-labels span:first-child {
  color: var(--text);
  font-weight: 700;
}

.usage-labels span:last-child {
  color: var(--text-faint);
  font-size: 8px;
}

.usage-track {
  display: block;
  width: 100%;
  height: 4px;
  overflow: hidden;
  background: #ececf2;
  border-radius: 100px;
}

.usage-bar {
  display: block;
  min-width: 2px;
  height: 100%;
  background: var(--primary);
  border-radius: inherit;
}

.usage-warning {
  background: #d18a2a;
}

.usage-danger {
  background: var(--danger);
}

.http-status {
  display: inline-grid;
  min-width: 38px;
  height: 23px;
  padding: 0 7px;
  place-items: center;
  border-radius: 6px;
  font-family: Consolas, monospace;
  font-size: 9px;
  font-weight: 750;
}

.http-success {
  color: var(--success);
  background: var(--success-soft);
}

.http-warning {
  color: var(--warning);
  background: var(--warning-soft);
}

.http-error {
  color: var(--danger);
  background: var(--danger-soft);
}

.protocol-badge,
.capability-badge {
  display: inline-block;
  padding: 4px 7px;
  color: var(--text-soft);
  background: #f2f3f7;
  border-radius: 6px;
  font-size: 8px;
  font-weight: 700;
}

.protocol-openai {
  color: #18745a;
  background: #e8f7f1;
}

.protocol-anthropic {
  color: #7a5339;
  background: #f7eee6;
}

.protocol-google {
  color: #326fb4;
  background: #ebf3fd;
}

.protocol-volcengine {
  color: #6b50c4;
  background: #f0ecff;
}

.filter-bar {
  display: flex;
  margin-bottom: 14px;
  padding: 12px;
  align-items: center;
  gap: 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.filter-bar select {
  width: 130px;
  height: 36px;
  font-size: 10px;
}

.search-field {
  position: relative;
  display: block;
  max-width: 330px;
  flex: 1;
}

.search-field .icon {
  position: absolute;
  top: 50%;
  left: 11px;
  width: 16px;
  height: 16px;
  color: var(--text-faint);
  transform: translateY(-50%);
}

.search-field input {
  height: 36px;
  padding-left: 35px;
  font-size: 10px;
}

.filter-count {
  margin-left: auto;
  color: var(--text-faint);
  font-size: 9px;
}

/* Empty / error states */

.empty-state {
  display: grid;
  min-height: 230px;
  padding: 30px;
  place-items: center;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

.table-panel .empty-state {
  border: 0;
  border-radius: 0;
}

.empty-state-icon {
  display: grid;
  width: 50px;
  height: 50px;
  margin: 0 auto 12px;
  place-items: center;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 15px;
}

.empty-state-icon .icon {
  width: 23px;
  height: 23px;
}

.empty-state h3 {
  margin: 0 0 5px;
  font-size: 14px;
}

.empty-state p {
  max-width: 360px;
  margin: 0;
  color: var(--text-faint);
  font-size: 10px;
}

.empty-state .button {
  margin-top: 16px;
}

.compact-empty {
  min-height: 145px;
  padding: 18px;
}

/* Settings and connection */

.connection-panel {
  margin-bottom: 18px;
}

.connection-list {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.connection-row {
  display: flex;
  min-width: 0;
  padding: 13px 14px;
  align-items: center;
  gap: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.connection-logo {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 9px;
  font-size: 10px;
  font-weight: 800;
}

.connection-copy {
  min-width: 0;
  flex: 1;
}

.connection-copy strong,
.connection-copy code {
  display: block;
}

.connection-copy strong {
  margin-bottom: 2px;
  font-size: 10px;
}

.connection-copy code {
  overflow: hidden;
  color: var(--text-soft);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.onboarding-steps {
  display: grid;
  margin: 22px 0 0;
  padding: 19px 0 0;
  gap: 12px;
  border-top: 1px solid var(--line);
  list-style: none;
  grid-template-columns: repeat(3, 1fr);
}

.onboarding-steps li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.onboarding-steps li > span {
  display: grid;
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 50%;
  font-size: 10px;
  font-weight: 750;
}

.onboarding-steps strong,
.onboarding-steps p {
  display: block;
}

.onboarding-steps strong {
  font-size: 10px;
}

.onboarding-steps p {
  margin: 3px 0 0;
  color: var(--text-faint);
  font-size: 9px;
}

.settings-form {
  max-width: 960px;
}

.form-grid {
  display: grid;
  gap: 17px 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
  display: block;
  min-width: 0;
}

.field-wide {
  grid-column: 1 / -1;
}

.field small {
  display: block;
  margin-top: 6px;
  color: var(--text-faint);
  font-size: 9px;
}

.field small code {
  color: #69667c;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: inherit;
}

.provider-url-warning {
  margin: 0;
}

.input-with-suffix {
  position: relative;
}

.input-with-suffix input {
  padding-right: 48px;
}

.input-with-suffix > span {
  position: absolute;
  top: 50%;
  right: 12px;
  color: var(--text-faint);
  font-size: 10px;
  transform: translateY(-50%);
}

.toggle-list {
  margin-top: 22px;
  border-top: 1px solid var(--line);
}

.toggle-row {
  position: relative;
  display: flex;
  min-height: 64px;
  padding: 12px 2px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.toggle-row strong,
.toggle-row small {
  display: block;
}

.toggle-row strong {
  font-size: 11px;
}

.toggle-row small {
  margin-top: 2px;
  color: var(--text-faint);
  font-size: 9px;
}

.toggle-row-risk {
  margin: 0 -10px;
  padding-right: 10px;
  padding-left: 10px;
  background: linear-gradient(90deg, rgba(255, 246, 231, 0.7), transparent);
}

.risk-badge {
  display: inline-block;
  margin-left: 5px;
  padding: 2px 5px;
  color: var(--warning);
  background: var(--warning-soft);
  border: 1px solid #f0d9ae;
  border-radius: 5px;
  font-size: 8px;
  line-height: 1.2;
  vertical-align: 1px;
}

.toggle-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch {
  position: relative;
  width: 38px;
  height: 22px;
  flex: 0 0 auto;
  background: #cacbd5;
  border-radius: 100px;
  transition: background 140ms ease;
}

.switch::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  content: "";
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  transition: transform 140ms ease;
}

.toggle-row input:checked + .switch {
  background: var(--primary);
}

.toggle-row input:checked + .switch::after {
  transform: translateX(16px);
}

.toggle-row input:focus-visible + .switch {
  outline: 3px solid rgba(103, 89, 209, 0.2);
}

.compact-toggle {
  min-height: 42px;
  padding: 0;
  border: 0;
  align-self: end;
}

.form-actions {
  display: flex;
  margin-top: 20px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.form-actions p {
  margin: 0;
  color: var(--text-faint);
  font-size: 9px;
}

/* Modals */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  padding: 22px;
  place-items: center;
  overflow-y: auto;
  background: rgba(28, 27, 40, 0.48);
  backdrop-filter: blur(5px);
  animation: fade-in 120ms ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  width: min(660px, 100%);
  max-height: calc(100vh - 44px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
  animation: modal-in 150ms ease;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-small {
  width: min(520px, 100%);
}

.modal-header {
  display: flex;
  padding: 21px 24px 17px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 2px 0 0;
  font-size: 19px;
  letter-spacing: -0.03em;
}

.modal-body {
  padding: 22px 24px;
}

.modal-footer {
  display: flex;
  padding: 15px 24px 20px;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  border-top: 1px solid var(--line);
}

.route-explainer {
  display: flex;
  margin-bottom: 20px;
  padding: 11px 13px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #595273;
  background: var(--primary-soft);
  border-radius: 9px;
  font-size: 10px;
  font-weight: 650;
}

.route-explainer .icon {
  width: 15px;
  height: 15px;
  color: var(--primary);
}

.token-limit-grid {
  margin-top: 18px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.token-secret-dialog {
  padding: 30px;
  text-align: center;
}

.success-emblem,
.danger-emblem {
  display: grid;
  width: 52px;
  height: 52px;
  margin: 0 auto 15px;
  place-items: center;
  border-radius: 50%;
}

.success-emblem {
  color: var(--success);
  background: var(--success-soft);
}

.danger-emblem {
  color: var(--danger);
  background: var(--danger-soft);
}

.success-emblem .icon,
.danger-emblem .icon {
  width: 25px;
  height: 25px;
  stroke-width: 2.2;
}

.secret-copy h2 {
  margin: 3px 0 7px;
  font-size: 20px;
}

.secret-copy > p:last-child {
  margin: 0;
  color: var(--text-soft);
  font-size: 10px;
}

.secret-field {
  margin: 22px 0 15px;
  padding: 14px;
  background: #f7f7fb;
  border: 1px solid var(--line);
  border-radius: 11px;
}

.secret-field code {
  display: block;
  margin-bottom: 12px;
  overflow-wrap: anywhere;
  color: #474359;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 11px;
  line-height: 1.6;
  user-select: all;
}

.secret-confirm {
  display: inline-flex;
  margin-bottom: 16px;
  align-items: center;
  gap: 7px;
  color: var(--text-soft);
  font-size: 10px;
}

.secret-confirm input {
  accent-color: var(--primary);
}

.modal-confirm {
  width: min(430px, 100%);
  padding: 28px 28px 0;
  text-align: center;
}

.modal-confirm h2 {
  margin: 0;
  font-size: 19px;
}

.modal-confirm > p {
  margin: 8px auto 23px;
  color: var(--text-soft);
  font-size: 11px;
}

.modal-confirm .modal-footer {
  margin: 0 -28px;
}

body.modal-open {
  overflow: hidden;
}

/* Toasts and loading */

.toast-region {
  position: fixed;
  z-index: 200;
  right: 22px;
  bottom: 22px;
  display: grid;
  width: min(360px, calc(100vw - 44px));
  gap: 9px;
}

.toast {
  display: flex;
  padding: 13px 15px;
  align-items: flex-start;
  gap: 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: 11px;
  box-shadow: 0 12px 34px rgba(31, 31, 46, 0.16);
  animation: toast-in 180ms ease;
}

.toast-success {
  border-left-color: var(--success);
}

.toast-error {
  border-left-color: var(--danger);
}

.toast-warning {
  border-left-color: var(--warning);
}

.toast .icon {
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

.toast-success .icon { color: var(--success); }
.toast-error .icon { color: var(--danger); }
.toast-warning .icon { color: var(--warning); }

.toast strong,
.toast span {
  display: block;
}

.toast strong {
  font-size: 11px;
}

.toast span {
  margin-top: 2px;
  color: var(--text-soft);
  font-size: 9px;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-content: center;
  gap: 12px;
  color: var(--text-soft);
  background: rgba(246, 246, 250, 0.75);
  font-size: 11px;
  text-align: center;
  backdrop-filter: blur(4px);
}

.spinner {
  display: inline-block;
  width: 30px;
  height: 30px;
  margin: 0 auto;
  border: 3px solid rgba(103, 89, 209, 0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.button .spinner {
  width: 16px;
  height: 16px;
  border-width: 2px;
  border-top-color: currentColor;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Responsive */

@media (max-width: 1180px) {
  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .provider-card {
    grid-template-columns: minmax(190px, 1fr) minmax(240px, 1.3fr) auto;
  }

  .provider-card .provider-key {
    display: none;
  }
}

@media (max-width: 920px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-100%);
    transition: transform 180ms ease;
    box-shadow: 18px 0 40px rgba(28, 27, 40, 0.2);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 25;
    display: block;
    background: rgba(25, 24, 35, 0.38);
  }

  .sidebar-close,
  .mobile-menu {
    display: inline-grid;
  }

  .content {
    padding-right: 22px;
    padding-left: 22px;
  }

  .topbar {
    padding-right: 22px;
    padding-left: 18px;
  }

  .hero-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero-endpoint {
    width: min(100%, 500px);
  }

  .provider-card {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .provider-card .provider-detail {
    grid-column: 1 / 2;
  }

  .provider-card .row-actions {
    grid-row: 1 / 3;
    grid-column: 2;
  }
}

@media (max-width: 720px) {
  .topbar {
    min-height: 72px;
  }

  .topbar-title p,
  .last-refresh,
  .topbar-actions .button span {
    display: none;
  }

  .topbar-actions .button {
    width: 38px;
    min-height: 38px;
    padding: 0;
  }

  .content {
    min-height: calc(100vh - 72px);
    padding: 20px 14px 36px;
  }

  .hero-card {
    min-height: 0;
    padding: 24px 20px;
    border-radius: 16px;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .overview-grid {
    grid-template-columns: 1fr;
  }

  .section-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
  }

  .section-toolbar .button {
    align-self: flex-start;
  }

  .section-toolbar h2 {
    font-size: 21px;
  }

  .panel {
    padding: 18px;
  }

  .panel-heading {
    margin-bottom: 14px;
  }

  .panel-heading .text-button {
    font-size: 9px;
  }

  .provider-card {
    padding: 17px;
    gap: 13px;
    grid-template-columns: minmax(0, 1fr);
  }

  .provider-card .provider-detail {
    grid-column: auto;
  }

  .provider-card .row-actions {
    padding-top: 8px;
    justify-content: flex-start;
    border-top: 1px solid var(--line);
    grid-row: auto;
    grid-column: auto;
  }

  .filter-bar {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .search-field {
    width: 100%;
    max-width: none;
    flex-basis: 100%;
  }

  .filter-count {
    align-self: center;
  }

  .connection-list {
    grid-template-columns: 1fr;
  }

  .onboarding-steps {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .field-wide {
    grid-column: auto;
  }

  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .modal-backdrop {
    padding: 12px;
  }

  .modal {
    max-height: calc(100vh - 24px);
  }

  .modal-header {
    padding: 18px 18px 14px;
  }

  .modal-body {
    padding: 18px;
  }

  .modal-footer {
    padding: 14px 18px 18px;
  }

  .token-limit-grid {
    grid-template-columns: 1fr;
  }

  .route-explainer {
    align-items: flex-start;
    flex-direction: column;
  }

  .route-explainer .icon {
    transform: rotate(90deg);
  }

  .table-wrap {
    overflow: visible;
  }

  .data-table,
  .data-table tbody {
    display: block;
    width: 100%;
  }

  .data-table thead {
    display: none;
  }

  .data-table tr {
    display: block;
    margin: 11px;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
  }

  .data-table td {
    display: flex;
    min-height: 35px;
    padding: 7px 0;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--line);
    text-align: right;
    white-space: normal;
  }

  .data-table td:last-child {
    border-bottom: 0;
  }

  .data-table td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--text-faint);
    font-size: 8px;
    font-weight: 700;
  }

  .data-table td[data-label="操作"] {
    justify-content: flex-end;
  }

  .data-table td[data-label="操作"]::before {
    margin-right: auto;
  }

  .data-table .error-cell {
    max-width: none;
    overflow-wrap: anywhere;
    text-overflow: unset;
  }

  .table-panel {
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  .table-panel .empty-state {
    background: var(--surface);
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
  }
}

@media (max-width: 460px) {
  .login-card {
    padding: 34px 24px 28px;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .summary-card {
    min-height: 98px;
  }

  .section-toolbar .button {
    width: 100%;
  }

  .hero-copy h3 {
    font-size: 20px;
  }

  .filter-bar label:not(.search-field) {
    flex: 1;
  }

  .filter-bar select {
    width: 100%;
  }

  .modal-footer .button {
    flex: 1;
  }

  .token-secret-dialog {
    padding: 24px 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
