/* 全局设计变量：极简现代松石青云原生风格 */
:root {
  --bg: #f5f7fa;
  --paper: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --subtle: #94a3b8;
  --line: #e8ecf2;
  --brand: #0d9488;
  --brand-hover: #0f766e;
  --brand-soft: #f0fdfa;
  --green: #10b981;
  --green-soft: #ecfdf5;
  --amber: #f59e0b;
  --amber-soft: #fffbeb;
  --red: #ef4444;
  --red-soft: #fef2f2;
  --radius: 16px;
  --shadow: 0 8px 28px rgba(15, 23, 42, 0.04);
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

a {
  color: inherit;
  text-decoration: none;
}

h1, h2, h3, p {
  margin: 0;
}

h1 {
  font-size: 28px;
  letter-spacing: -0.6px;
  font-weight: 650;
  line-height: 1.4;
}

h2 {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
}

h3 {
  font-size: 13px;
  font-weight: 600;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

button svg {
  pointer-events: none;
}

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

.small {
  font-size: 12px;
}

.mono {
  font-family: "JetBrains Mono", Consolas, monospace;
}

.eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.6px;
  color: var(--brand);
  margin-bottom: 6px;
}

/* 品牌标志与通用按钮 */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.3px;
  white-space: nowrap;
}

.brand b {
  font-weight: 700;
  color: var(--brand);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, #0d9488, #0284c7);
  border-radius: 10px;
  color: #fff;
  font-size: 20px;
  font-weight: 750;
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.22);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 8px 15px;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.16s, border-color 0.16s, transform 0.12s;
  white-space: nowrap;
}

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

.button.primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 10px rgba(13, 148, 136, 0.16);
}

.button.primary:hover {
  background: var(--brand-hover);
}

.button.secondary {
  background: #fff;
  border-color: #dce2ec;
  color: #475569;
}

.button.secondary:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.button.danger {
  background: var(--red-soft);
  color: var(--red);
}

.button.danger:hover {
  background: #fee2e2;
}

.button.wide {
  width: 100%;
}

.button.tiny {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 7px;
}

.icon-button {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  flex-shrink: 0;
}

.icon-button:hover {
  background: #eef2f6;
  color: var(--ink);
}

.text-button {
  border: 0;
  background: none;
  padding: 0;
  color: var(--brand);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.text-button:hover {
  color: var(--brand-hover);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
  flex-shrink: 0;
}

.badge {
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  background: #f1f5f9;
  color: var(--muted);
}

.badge.success {
  background: var(--green-soft);
  color: var(--green);
}

.badge.warning {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge.danger {
  background: var(--red-soft);
  color: var(--red);
}

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

.card {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.card-heading p {
  margin-top: 3px;
}

.soft-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 10px;
  flex-shrink: 0;
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(13, 148, 136, 0.2);
  border-top-color: var(--brand);
  display: inline-block;
  animation: spin 0.8s linear infinite;
}

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

.boot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  height: 100vh;
}

/* 登录页布局 */
.auth-view {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1.08fr 1fr;
  background: #fff;
}

.auth-visual {
  position: relative;
  background: #0f172a;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

.visual-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(50px);
  opacity: 0.45;
}

.glow-a {
  width: 420px;
  height: 420px;
  background: #0d9488;
  top: -80px;
  left: -60px;
}

.glow-b {
  width: 380px;
  height: 380px;
  background: #0284c7;
  bottom: -80px;
  right: -60px;
}

.visual-glass {
  position: relative;
  z-index: 1;
  max-width: 440px;
  padding: 42px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(16px);
  color: #f8fafc;
}

.visual-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #5eead4;
  display: block;
  margin-bottom: 14px;
}

.visual-glass h2 {
  font-size: 30px;
  line-height: 1.35;
  font-weight: 650;
  margin-bottom: 14px;
}

.visual-glass p {
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.7;
}

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 32px;
}

.auth-card {
  width: 340px;
  max-width: 100%;
}

.auth-card .brand {
  margin-bottom: 48px;
}

.auth-card h1 {
  margin-bottom: 6px;
}

.auth-card > .muted {
  font-size: 12px;
  margin-bottom: 28px;
}

.auth-card label {
  margin-top: 18px;
}

.auth-card .button {
  margin-top: 24px;
  min-height: 42px;
}

/* 左侧边栏与主布局框架 */
.app {
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  padding: 28px 16px 18px;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 30;
}

.sidebar > .brand {
  padding: 0 10px;
}

.nav-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--subtle);
  margin: 34px 12px 10px;
  letter-spacing: 1px;
}

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

.nav-item {
  width: 100%;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  text-align: left;
  transition: background 0.16s, color 0.16s;
}

.nav-item:hover {
  background: #f8fafc;
  color: var(--ink);
}

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

.sidebar-bottom {
  margin-top: auto;
}

.status-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.status-box .badge {
  margin-left: auto;
  font-size: 10px;
  padding: 2px 6px;
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 12px;
  padding: 10px 8px 4px;
  border: 0;
  border-top: 1px solid var(--line);
  width: 100%;
  background: transparent;
  font-size: 12px;
  color: var(--muted);
}

.user-bar:hover {
  color: var(--ink);
}

.user-bar > [data-icon] {
  margin-left: auto;
  display: flex;
}

.avatar {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
}

.main-wrap {
  margin-left: 220px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 64px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 36px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.breadcrumb-root {
  color: var(--subtle);
}

.breadcrumb-sep {
  color: #cbd5e1;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.online-hint {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 7px;
}

main {
  padding: 32px 36px 48px;
  max-width: 1480px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
}

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-heading .muted {
  font-size: 12.5px;
  margin-top: 5px;
}

.heading-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* 顶部 4 卡片指标格 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.stat-card {
  padding: 20px;
}

.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}

.stat-value {
  font-size: 28px;
  font-weight: 650;
  letter-spacing: -0.6px;
  margin: 12px 0 6px;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.stat-foot {
  font-size: 11.5px;
  color: var(--subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

/* 概览双栏 */
.overview-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr);
  gap: 20px;
}

.activity-card {
  padding: 22px 22px 8px;
}

.activity-card .card-heading {
  margin-bottom: 12px;
}

.recent-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  cursor: pointer;
}

.recent-row:hover .recent-prompt {
  color: var(--brand);
}

.recent-copy {
  min-width: 0;
  flex: 1;
}

.recent-prompt {
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-info {
  font-size: 11px;
  color: var(--subtle);
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.connect-card {
  padding: 22px;
}

.endpoint-label {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 16px;
}

.copy-field {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 8px;
  margin-top: 6px;
  padding: 5px 7px 5px 11px;
  gap: 6px;
}

.copy-field code {
  font-size: 11.5px;
  color: #475569;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.connection-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
}

.connection-foot .text-button {
  margin-left: auto;
}

/* ==================== 账号池：卡片网格设计 ==================== */
.accounts-filter-bar {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.status-pills-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.status-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: #fafbfc;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s ease;
}

.status-pill-btn span {
  background: #e2e8f0;
  color: #475569;
  border-radius: 999px;
  padding: 1px 6px;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

.status-pill-btn:hover {
  border-color: #cbd5e1;
  color: var(--ink);
}

.status-pill-btn.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.status-pill-btn.active span {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.filter-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.filter-right select {
  width: 130px;
  min-height: 34px;
  padding: 6px 10px;
  font-size: 12px;
}

.account-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 18px;
}

.account-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  transition: border-color 0.16s, box-shadow 0.16s;
}

.account-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.06);
}

.account-card.is-disabled {
  opacity: 0.72;
}

.acc-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.acc-title-wrap {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.acc-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
  font-size: 14px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.acc-title-text {
  min-width: 0;
}

.acc-name {
  font-size: 14px;
  font-weight: 650;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.acc-project {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.acc-head-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.acc-email-line {
  font-size: 11.5px;
  color: var(--subtle);
  background: #f8fafc;
  padding: 7px 10px;
  border-radius: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 账号卡片：左侧绿色余额圆环 + 右侧金额/RPM/TPM */
.acc-balance-row {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: #fafbfc;
  border-radius: 12px;
}

.acc-ring-box {
  position: relative;
  width: 76px;
  height: 76px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}

.acc-ring-svg {
  width: 76px;
  height: 76px;
  transform: rotate(-90deg);
}

.acc-ring-track {
  fill: none;
  stroke: #e2e8f0;
  stroke-width: 7.5;
}

.acc-ring-progress {
  fill: none;
  stroke: #10b981;
  stroke-width: 7.5;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.35s ease;
}

.acc-ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.15;
}

.acc-ring-pct {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.acc-ring-caption {
  font-size: 10px;
  color: var(--subtle);
}

.acc-info-strip {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.acc-info-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.acc-info-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

.acc-info-val {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.acc-info-sub {
  font-size: 10.5px;
  color: var(--subtle);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 实时数据统计大屏网格 */
.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--green-soft);
  color: var(--green);
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

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

.rt-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rt-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.rt-card-val {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.8px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.rt-card-val small {
  font-size: 15px;
  font-weight: 600;
  color: var(--brand);
  margin-left: 4px;
}

.rt-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--subtle);
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

/* 生图记录缩略图 */
.log-thumb-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.log-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: #f8fafc;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  color: var(--subtle);
}

.stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border: 1px solid #dce2ec;
  border-radius: 7px;
  height: 30px;
  overflow: hidden;
}

.stepper button {
  border: 0;
  background: transparent;
  width: 28px;
  height: 100%;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.stepper button:hover {
  background: var(--brand-soft);
  color: var(--brand);
}

.stepper span {
  font-size: 12.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.acc-error-alert {
  font-size: 11.5px;
  color: var(--red);
  background: var(--red-soft);
  padding: 7px 10px;
  border-radius: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.acc-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  margin-top: auto;
}

.acc-metrics {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.acc-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 拨杆开关 */
input[type="checkbox"].switch,
.switch {
  appearance: none;
  -webkit-appearance: none;
  width: 38px !important;
  height: 22px !important;
  background: #cbd5e1;
  border-radius: 999px !important;
  position: relative;
  cursor: pointer;
  border: 0 !important;
  padding: 0 !important;
  margin: 0;
  flex-shrink: 0;
  transition: background 0.18s ease;
  box-shadow: none !important;
}

input[type="checkbox"].switch::after,
.switch::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

input[type="checkbox"].switch:checked,
.switch:checked {
  background: var(--brand);
}

input[type="checkbox"].switch:checked::after,
.switch:checked::after {
  transform: translateX(16px);
}

/* ==================== 工作台布局 ==================== */
.studio-layout {
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.studio-controls {
  padding: 22px;
}

.studio-controls .card-heading {
  margin-bottom: 20px;
}

.studio-controls label {
  margin-top: 16px;
}

.studio-controls .field-grid {
  margin-top: 16px;
}

.studio-controls .field-grid label {
  margin-top: 0;
}

.studio-controls .button.wide {
  margin-top: 20px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 12px;
  color: #475569;
  font-weight: 500;
}

input:not([type="checkbox"]), select, textarea {
  width: 100%;
  border: 1px solid #dce2ec;
  background: #fff;
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--ink);
  font-size: 12.5px;
  transition: border-color 0.16s, box-shadow 0.16s;
}

input:not([type="checkbox"]):focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}

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

.field-label {
  font-size: 12px;
  font-weight: 500;
  color: #475569;
}

.reference-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 0 8px;
}

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

.reference-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.reference-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.reference-item button {
  position: absolute;
  right: 3px;
  top: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 0;
  background: rgba(15, 23, 42, 0.7);
  color: #fff;
  font-size: 12px;
}

.upload-area {
  margin-top: 8px !important;
  border: 1px dashed #cbd5e1;
  background: #fafbfc;
  align-items: center;
  justify-content: center;
  padding: 16px 10px;
  border-radius: 10px;
  cursor: pointer;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.upload-area:hover, .upload-area.dragover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-soft);
}

.studio-canvas {
  min-height: 580px;
  display: flex;
  flex-direction: column;
}

.canvas-heading {
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  font-weight: 600;
}

.canvas-meta-right {
  display: flex;
  align-items: center;
  gap: 14px;
  font-weight: 400;
}

.generation-output {
  flex: 1;
  padding: 24px;
  background: #fafbfc;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.canvas-empty {
  text-align: center;
  padding: 48px 0;
}

.canvas-symbol {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
  margin: 0 auto 16px;
  border-radius: 16px;
}

.pg-response-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  margin-bottom: auto;
}

.pg-text-output {
  white-space: pre-wrap;
  line-height: 1.7;
  font-size: 13.5px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
}

.pg-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.pg-image-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.pg-image-item img {
  width: 100%;
  display: block;
  object-fit: contain;
  max-height: 460px;
  background: #f8fafc;
}

.pg-image-foot {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

/* ==================== 数据统计与图表 ==================== */
.segmented-bar {
  display: inline-flex;
  background: #eef2f6;
  border-radius: 9px;
  padding: 3px;
  gap: 3px;
}

.seg-item {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 13px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 7px;
}

.seg-item.active {
  background: #fff;
  color: var(--brand);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
}

.charts-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 22px;
}

.chart-card {
  padding: 20px 22px;
}

.chart-box {
  height: 200px;
  margin-top: 14px;
}

.chart-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* ==================== 列表、表格与设置 ==================== */
.list-toolbar {
  padding: 16px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.search-field {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 340px;
  width: 100%;
  color: var(--subtle);
}

.search-field input {
  border: 0;
  box-shadow: none;
  padding: 4px 0;
  background: none;
  font-size: 12.5px;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toolbar-actions select {
  width: 115px;
  min-height: 32px;
  padding: 5px 10px;
  font-size: 12px;
}

.table-scroll {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
  text-align: left;
}

.data-table th {
  font-size: 11px;
  color: var(--subtle);
  font-weight: 600;
  padding: 13px 20px;
  background: #fafbfc;
  border-bottom: 1px solid var(--line);
}

.data-table td {
  padding: 15px 20px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 12.5px;
  color: #475569;
}

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

.data-table tbody tr:hover {
  background: #fafbfc;
}

.align-right {
  text-align: right !important;
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

/* 设置分页导航与面板 */
.settings-tabs-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #eef2f6;
  padding: 5px;
  border-radius: 12px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.settings-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.16s;
}

.settings-tab-btn svg {
  width: 16px;
  height: 16px;
}

.settings-tab-btn:hover {
  color: var(--ink);
}

.settings-tab-btn.active {
  background: #fff;
  color: var(--brand);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.settings-tab-container {
  max-width: 1080px;
}

.settings-two-cards {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 20px;
  align-items: start;
}

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

.toggle-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.apikey-list-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.setting-card {
  padding: 26px;
}

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

.card-heading .setting-heading {
  margin-bottom: 0;
}

.setting-card > label {
  margin-top: 16px;
}

.input-unit {
  position: relative;
}

.input-unit input {
  padding-right: 48px;
}

.input-unit span {
  position: absolute;
  right: 11px;
  top: 10px;
  font-size: 11px;
  color: var(--subtle);
  pointer-events: none;
}

.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.toggle-item {
  display: flex;
  flex-direction: row !important;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafbfc;
  cursor: pointer;
}

.toggle-item strong {
  display: block;
  font-size: 13px;
  color: var(--ink);
  margin-bottom: 2px;
}

/* 代理节点精简列表 */
.proxy-list-box {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.proxy-row-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafbfc;
  flex-wrap: wrap;
}

.proxy-info {
  min-width: 180px;
  flex: 1;
}

.proxy-info strong {
  font-size: 13px;
  display: block;
}

.proxy-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.setting-divider {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 16px;
}

.apikey-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.form-error {
  font-size: 12px;
  color: var(--red);
  background: var(--red-soft);
  padding: 10px 12px;
  border-radius: 8px;
  margin-top: 14px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 44px 20px;
  color: var(--subtle);
  gap: 8px;
  text-align: center;
}

/* 弹窗与抽屉 */
.modal {
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 24px 72px rgba(15, 23, 42, 0.18);
  padding: 26px;
  width: 540px;
  max-width: calc(100vw - 32px);
  color: var(--ink);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(3px);
}

.modal-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}

.modal-heading h2 {
  font-size: 19px;
}

.modal label {
  margin-top: 14px;
}

.modal .field-grid label {
  margin-top: 0;
}

.modal .field-grid {
  margin-top: 14px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.drawer-scrim {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.3);
  z-index: 45;
  backdrop-filter: blur(2px);
}

.drawer {
  position: fixed;
  right: 0;
  top: 0;
  height: 100dvh;
  width: 560px;
  max-width: 100vw;
  background: #fff;
  z-index: 50;
  box-shadow: -10px 0 40px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
}

.drawer-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 26px;
  border-bottom: 1px solid var(--line);
}

.drawer-body {
  overflow-y: auto;
  padding: 24px 26px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.code-block {
  font-family: Consolas, monospace;
  font-size: 11.5px;
  background: #f8fafc;
  border: 1px solid var(--line);
  color: #334155;
  padding: 12px;
  border-radius: 9px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 260px;
  overflow-y: auto;
}

.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.12);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 12.5px;
  color: var(--ink);
  font-weight: 500;
}

@media (max-width: 1100px) {
  .stats-grid, .realtime-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .overview-columns, .charts-row, .studio-layout, .settings-two-cards, .field-grid-3, .toggle-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .sidebar {
    display: none;
  }
  .main-wrap {
    margin-left: 0;
  }
  main, .topbar {
    padding-left: 20px;
    padding-right: 20px;
  }
  .auth-view {
    grid-template-columns: 1fr;
  }
  .auth-visual {
    display: none;
  }
}
