:root {
  --bg: #080c11;
  --bg-soft: #0b1118;
  --panel: #0e161f;
  --panel-2: #121c27;
  --line: #1d2a37;
  --line-soft: #16222d;
  --text: #e6eef6;
  --text-dim: #8ea3b6;
  --text-faint: #5d7285;
  --accent: #34d399;
  --accent-soft: rgba(52, 211, 153, 0.12);
  --sky: #38bdf8;
  --sky-soft: rgba(56, 189, 248, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --warn: #fbbf24;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, "Courier New", monospace;
  --sans: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(900px 500px at 12% -10%, rgba(52, 211, 153, 0.08), transparent 60%),
    radial-gradient(800px 500px at 90% 0%, rgba(56, 189, 248, 0.07), transparent 55%),
    linear-gradient(180deg, #080c11 0%, #070a0e 100%);
  background-attachment: fixed;
}

a {
  color: var(--sky);
  text-decoration: none;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

::selection {
  background: rgba(52, 211, 153, 0.28);
}

/* ---------------- 启动 / 登录 ---------------- */

.app-root {
  min-height: 100vh;
}

.boot-screen {
  min-height: 100vh;
  display: grid;
  place-content: center;
  gap: 18px;
  text-align: center;
}

.boot-mark {
  width: 64px;
  height: 64px;
  margin: 0 auto;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 1px;
  color: #04110c;
  background: linear-gradient(135deg, var(--accent), var(--sky));
  box-shadow: 0 14px 40px rgba(52, 211, 153, 0.25);
  animation: pulse 2.4s ease-in-out infinite;
}

.boot-text {
  color: var(--text-dim);
  font-size: 13px;
}

@keyframes pulse {
  0%,
  100% {
    transform: translateY(0);
    box-shadow: 0 14px 40px rgba(52, 211, 153, 0.22);
  }
  50% {
    transform: translateY(-4px);
    box-shadow: 0 22px 50px rgba(56, 189, 248, 0.28);
  }
}

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 18px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 34px 32px 30px;
  background: linear-gradient(180deg, rgba(18, 28, 39, 0.96), rgba(11, 17, 24, 0.98));
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: -1px -1px auto;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--sky), transparent);
}

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

.auth-logo {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
  color: #04110c;
  background: linear-gradient(135deg, var(--accent), var(--sky));
}

.auth-brand h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.auth-brand p {
  margin: 2px 0 0;
  color: var(--text-faint);
  font-size: 12px;
}

.auth-card h2 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 600;
}

.auth-card .sub {
  margin: 0 0 22px;
  color: var(--text-dim);
  font-size: 13px;
}

.auth-note {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
  background: rgba(56, 189, 248, 0.05);
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.7;
}

.auth-foot {
  margin-top: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-faint);
  font-size: 12px;
}

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

.field {
  display: block;
  margin-bottom: 14px;
}

.field > span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.3px;
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 10px 12px;
  background: #0a1118;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: rgba(52, 211, 153, 0.55);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.1);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-faint);
}

.textarea {
  resize: vertical;
  min-height: 78px;
  line-height: 1.6;
}

.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  border-color: #2b3d4e;
  background: #16232f;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  border-color: transparent;
  color: #04110c;
  background: linear-gradient(135deg, var(--accent), #5eead4);
  font-weight: 600;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4ade80, #38bdf8);
  border-color: transparent;
}

.btn-ghost {
  background: transparent;
  border-color: var(--line-soft);
  color: var(--text-dim);
}

.btn-ghost:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.btn-danger {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.3);
  background: var(--danger-soft);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 8px;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ---------------- 主框架 ---------------- */

.shell {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px 18px;
  border-right: 1px solid var(--line-soft);
  background: linear-gradient(180deg, rgba(13, 19, 26, 0.92), rgba(8, 12, 17, 0.96));
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 6px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #04110c;
  background: linear-gradient(135deg, var(--accent), var(--sky));
  box-shadow: 0 8px 22px rgba(52, 211, 153, 0.2);
}

.brand-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-faint);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-item svg {
  width: 17px;
  height: 17px;
  flex: none;
}

.nav-item .nav-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-faint);
  font-weight: 400;
}

.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

.sync-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  color: var(--text-faint);
  font-size: 11px;
  background: rgba(255, 255, 255, 0.015);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
  flex: none;
}

.dot.ok {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.12);
}

.dot.warn {
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.12);
}

.dot.bad {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.12);
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(8, 12, 17, 0.82);
  backdrop-filter: blur(10px);
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
}

.topbar-sub {
  color: var(--text-faint);
  font-size: 12px;
  margin-left: 2px;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(52, 211, 153, 0.25);
}

.view {
  padding: 26px 28px 60px;
  max-width: 1220px;
  width: 100%;
  margin: 0 auto;
}

.mobile-nav {
  display: none;
}

/* ---------------- 通用组件 ---------------- */

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 20px;
}

.page-head h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.page-head p {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 13px;
}

.page-head .spacer {
  flex: 1;
}

.card {
  background: linear-gradient(180deg, rgba(17, 26, 36, 0.92), rgba(13, 20, 28, 0.94));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

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

.card-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.card-head .hint {
  color: var(--text-faint);
  font-size: 12px;
}

.card-head .spacer {
  flex: 1;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 16px;
}

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

.stack {
  display: grid;
  gap: 16px;
}

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

.stat {
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(17, 26, 36, 0.9), rgba(12, 18, 25, 0.92));
}

.stat-label {
  color: var(--text-faint);
  font-size: 11px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.stat-value {
  margin-top: 6px;
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.4px;
}

.stat-value small {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 400;
  margin-left: 4px;
}

.stat-note {
  margin-top: 2px;
  color: var(--text-faint);
  font-size: 11px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-dim);
  font-size: 11px;
  line-height: 18px;
  white-space: nowrap;
}

.badge.green {
  color: var(--accent);
  border-color: rgba(52, 211, 153, 0.25);
  background: var(--accent-soft);
}

.badge.sky {
  color: var(--sky);
  border-color: rgba(56, 189, 248, 0.25);
  background: var(--sky-soft);
}

.badge.warn {
  color: var(--warn);
  border-color: rgba(251, 191, 36, 0.25);
  background: rgba(251, 191, 36, 0.1);
}

.badge.red {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.25);
  background: var(--danger-soft);
}

.badge.mono {
  font-family: var(--mono);
  font-size: 10.5px;
}

.code-inline {
  font-family: var(--mono);
  font-size: 12px;
  color: #a7f3d0;
  background: rgba(52, 211, 153, 0.06);
  border: 1px solid rgba(52, 211, 153, 0.14);
  border-radius: 7px;
  padding: 2px 7px;
  word-break: break-all;
}

.code-block {
  position: relative;
  margin: 0;
  padding: 14px 15px;
  background: #070d13;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
  color: #c8e6d9;
  white-space: pre;
}

.code-block::-webkit-scrollbar {
  height: 8px;
  width: 8px;
}

.code-block::-webkit-scrollbar-thumb {
  background: #1e2d3b;
  border-radius: 8px;
}

.copy-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.copy-row .value {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  background: #0a1118;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 8px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-dim);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
  color: var(--accent);
  border-color: rgba(52, 211, 153, 0.3);
}

.icon-btn svg {
  width: 15px;
  height: 15px;
}

.empty {
  padding: 42px 20px;
  text-align: center;
  color: var(--text-faint);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  font-size: 13px;
}

.divider {
  height: 1px;
  background: var(--line-soft);
  margin: 18px 0;
}

.muted {
  color: var(--text-dim);
}

.faint {
  color: var(--text-faint);
}

.tiny {
  font-size: 11px;
}

.mono {
  font-family: var(--mono);
}

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

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.alert {
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.7;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-dim);
}

.alert.warn {
  border-color: rgba(251, 191, 36, 0.25);
  background: rgba(251, 191, 36, 0.07);
  color: #fcd34d;
}

.alert.info {
  border-color: rgba(56, 189, 248, 0.22);
  background: rgba(56, 189, 248, 0.06);
  color: #93c5fd;
}

.alert.error {
  border-color: rgba(248, 113, 113, 0.28);
  background: var(--danger-soft);
  color: #fca5a5;
}

/* ---------------- 总览 ---------------- */

.hero {
  position: relative;
  padding: 24px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background:
    radial-gradient(700px 260px at 88% -30%, rgba(56, 189, 248, 0.14), transparent 70%),
    radial-gradient(500px 240px at 10% 120%, rgba(52, 211, 153, 0.12), transparent 70%),
    linear-gradient(180deg, rgba(18, 28, 39, 0.95), rgba(11, 17, 24, 0.96));
  overflow: hidden;
}

.hero h2 {
  margin: 0 0 6px;
  font-size: 23px;
  letter-spacing: -0.2px;
}

.hero p {
  margin: 0;
  color: var(--text-dim);
  font-size: 13px;
  max-width: 620px;
}

.hero-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.gateway-block {
  display: grid;
  gap: 10px;
}

.gateway-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.gateway-row > label {
  color: var(--text-faint);
  font-size: 12px;
}

.group-list {
  display: grid;
  gap: 8px;
}

.group-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.015);
}

.group-item .name {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
}

.group-item .note {
  color: var(--text-faint);
  font-size: 11px;
}

.group-item .spacer {
  flex: 1;
}

.steps {
  display: grid;
  gap: 10px;
  counter-reset: step;
}

.step {
  display: flex;
  gap: 11px;
  align-items: flex-start;
}

.step-num {
  flex: none;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(52, 211, 153, 0.22);
}

.step-body {
  font-size: 12.5px;
  color: var(--text-dim);
}

.step-body strong {
  color: var(--text);
  font-weight: 500;
}

/* ---------------- 模型 ---------------- */

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

.search {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 420px;
}

.search svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-faint);
}

.search .input {
  padding-left: 34px;
}

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

.model-card {
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: linear-gradient(180deg, rgba(17, 26, 36, 0.88), rgba(12, 18, 25, 0.9));
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.model-card:hover {
  border-color: #26394b;
  transform: translateY(-1px);
}

.model-card.off {
  opacity: 0.62;
}

.model-title {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.model-title .name {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.45;
  word-break: break-word;
}

.model-id {
  margin-top: 3px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  word-break: break-all;
}

.model-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
}

.model-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.model-foot .spacer {
  flex: 1;
}

.load-more {
  display: flex;
  justify-content: center;
  margin-top: 18px;
}

.load-more:empty {
  display: none;
}

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

.client-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.client-list {
  display: grid;
  gap: 3px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(13, 20, 28, 0.9);
  position: sticky;
  top: 84px;
}

.client-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-dim);
  font-size: 12.5px;
  text-align: left;
}

.client-item:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.client-item.active {
  background: var(--sky-soft);
  color: var(--sky);
  font-weight: 600;
}

.client-initial {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line-soft);
  flex: none;
}

.client-item.active .client-initial {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.3);
}

.client-body {
  display: grid;
  gap: 14px;
}

.field-table {
  display: grid;
  gap: 9px;
}

.field-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.field-row > label {
  color: var(--text-faint);
  font-size: 12px;
}

.field-row .value {
  font-family: var(--mono);
  font-size: 12px;
  padding: 7px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #0a1118;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code-wrap {
  position: relative;
}

.code-wrap .code-copy {
  position: absolute;
  top: 8px;
  right: 8px;
}

/* ---------------- 密钥 ---------------- */

.key-list {
  display: grid;
  gap: 10px;
}

.key-card {
  display: grid;
  gap: 10px;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(14, 22, 31, 0.85);
}

.key-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.key-top .name {
  font-size: 13px;
  font-weight: 600;
}

.key-top .spacer {
  flex: 1;
}

.key-secret {
  font-family: var(--mono);
  font-size: 12px;
  color: #a7f3d0;
  word-break: break-all;
  padding: 8px 10px;
  border: 1px dashed rgba(52, 211, 153, 0.2);
  border-radius: 8px;
  background: rgba(52, 211, 153, 0.04);
}

.key-foot {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.key-note {
  flex: 1;
  min-width: 160px;
}

.key-note .input {
  padding: 6px 9px;
  font-size: 12px;
}

.key-date {
  width: 150px;
}

.key-date .input {
  padding: 6px 9px;
  font-size: 12px;
}

/* ---------------- 测速 ---------------- */

.test-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.test-picker {
  max-height: 560px;
  overflow: auto;
  display: grid;
  gap: 2px;
  padding-right: 4px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
}

.check-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.check-row input {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  flex: none;
}

.check-row .label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.result-table th {
  text-align: left;
  color: var(--text-faint);
  font-weight: 500;
  font-size: 11px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.result-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

.result-table tr:last-child td {
  border-bottom: 0;
}

.result-table .model-cell {
  font-family: var(--mono);
  font-size: 11.5px;
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress {
  height: 4px;
  border-radius: 999px;
  background: var(--line-soft);
  overflow: hidden;
  margin-top: 10px;
}

.progress > span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--sky));
  transition: width 0.25s ease;
}

/* ---------------- 聊天 ---------------- */

.chat-layout {
  display: grid;
  grid-template-rows: auto minmax(320px, 1fr) auto;
  gap: 12px;
  height: calc(100vh - 190px);
  min-height: 520px;
}

.chat-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.chat-log {
  overflow: auto;
  padding: 8px 4px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg {
  display: flex;
  gap: 10px;
  max-width: 92%;
}

.msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text-dim);
}

.msg.user .msg-avatar {
  color: var(--sky);
  background: var(--sky-soft);
  border-color: rgba(56, 189, 248, 0.25);
}

.msg-bubble {
  padding: 10px 13px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 13.5px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
  min-width: 0;
}

.msg.user .msg-bubble {
  background: rgba(56, 189, 248, 0.08);
  border-color: rgba(56, 189, 248, 0.2);
}

.msg-bubble.error {
  border-color: rgba(248, 113, 113, 0.3);
  background: var(--danger-soft);
  color: #fca5a5;
  font-size: 12.5px;
}

.msg-bubble .cursor::after {
  content: "▋";
  color: var(--accent);
  animation: blink 1s steps(2) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.chat-composer {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(13, 20, 28, 0.92);
  padding: 10px;
}

.chat-composer .textarea {
  border: 0;
  background: transparent;
  box-shadow: none;
  min-height: 52px;
  max-height: 180px;
  padding: 4px 4px 8px;
  resize: none;
}

.chat-composer .textarea:focus {
  box-shadow: none;
}

.composer-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}

.composer-foot .spacer {
  flex: 1;
}

.chat-empty {
  margin: auto;
  text-align: center;
  color: var(--text-faint);
  display: grid;
  gap: 8px;
  padding: 40px 0;
}

.chat-empty strong {
  color: var(--text-dim);
  font-weight: 500;
}

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

/* ---------------- 设置 ---------------- */

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 16px;
  align-items: start;
}

.setting-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
}

.setting-row:last-child {
  border-bottom: 0;
}

.setting-row .label {
  flex: 1;
  min-width: 0;
}

.setting-row .label strong {
  display: block;
  font-size: 13px;
  font-weight: 500;
}

.setting-row .label span {
  color: var(--text-faint);
  font-size: 11.5px;
}

.danger-zone {
  border-color: rgba(248, 113, 113, 0.22);
}

.danger-zone .card-head h3 {
  color: #fca5a5;
}

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

.toast-root {
  position: fixed;
  z-index: 100;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 15px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #111a24;
  color: var(--text);
  font-size: 12.5px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.2s ease;
}

.toast.ok {
  border-color: rgba(52, 211, 153, 0.35);
  color: #a7f3d0;
}

.toast.bad {
  border-color: rgba(248, 113, 113, 0.35);
  color: #fca5a5;
}

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

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

@media (max-width: 1080px) {
  .grid-2,
  .settings-grid,
  .test-layout,
  .client-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .client-list {
    position: static;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }

  .client-item {
    width: auto;
  }

  .test-picker {
    max-height: 260px;
  }
}

@media (max-width: 860px) {
  .stats {
    grid-template-columns: 1fr 1fr;
  }

  .grid-3 {
    grid-template-columns: 1fr;
  }

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

  .sidebar {
    display: none;
  }

  .topbar {
    padding: 12px 16px;
  }

  .view {
    padding: 18px 16px 92px;
  }

  .chat-layout {
    height: auto;
    min-height: calc(100vh - 220px);
  }

  .mobile-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: flex;
    justify-content: space-around;
    gap: 2px;
    padding: 7px 6px calc(7px + env(safe-area-inset-bottom));
    background: rgba(9, 14, 19, 0.94);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(12px);
  }

  .mobile-nav .nav-item {
    flex-direction: column;
    gap: 3px;
    padding: 5px 4px;
    font-size: 10px;
    text-align: center;
    flex: 1;
  }

  .mobile-nav .nav-item svg {
    width: 18px;
    height: 18px;
  }

  .mobile-nav .nav-count {
    display: none;
  }

  .field-row {
    grid-template-columns: 80px minmax(0, 1fr) auto;
  }

  .gateway-row {
    grid-template-columns: 70px minmax(0, 1fr);
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .toast-root {
    left: 14px;
    right: 14px;
    bottom: 78px;
  }
}

@media (max-width: 520px) {
  .stats {
    grid-template-columns: 1fr 1fr;
  }

  .stat-value {
    font-size: 20px;
  }

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

  .chat-settings {
    grid-template-columns: 1fr;
  }

  .auth-card {
    padding: 26px 20px 22px;
  }
}
