:root {
  --bg: #0a0d14;
  --bg-glow: radial-gradient(1200px 600px at 15% -10%, rgba(109, 141, 255, 0.16), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(52, 211, 153, 0.08), transparent 55%);
  --panel: #111726;
  --panel-2: #161e30;
  --panel-3: #1c2639;
  --line: #243049;
  --line-soft: #1b2437;
  --text: #e8eef9;
  --muted: #8b99b3;
  --muted-2: #6b7893;
  --accent: #6d8dff;
  --accent-2: #8aa2ff;
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background-color: var(--bg);
  background-image: var(--bg-glow);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

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

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

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
}

/* ───────────────── 登录 ───────────────── */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent), var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 30px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand h1 {
  font-size: 20px;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.brand.small {
  padding: 20px 18px 14px;
}

.brand.small strong {
  display: block;
  font-size: 15px;
}

.brand.small small {
  color: var(--muted-2);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.logo {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #4f74ff, #7c5cff 55%, #3fd6b0);
  color: #fff;
  font-size: 21px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(90, 116, 255, 0.35);
}

.login-error {
  margin: 0;
  min-height: 20px;
  color: var(--red);
  font-size: 13px;
}

/* ───────────────── 框架 ───────────────── */

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: rgba(13, 18, 29, 0.86);
  border-right: 1px solid var(--line-soft);
  backdrop-filter: blur(14px);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  flex: 1;
}

.nav button {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav button i {
  font-style: normal;
  width: 18px;
  text-align: center;
  opacity: 0.85;
}

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

.nav button.active {
  background: linear-gradient(180deg, rgba(109, 141, 255, 0.2), rgba(109, 141, 255, 0.08));
  border-color: rgba(109, 141, 255, 0.35);
  color: #dfe6ff;
}

.sidebar-foot {
  padding: 12px 16px 18px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.api-hint {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted-2);
  word-break: break-all;
}

.main {
  min-width: 0;
  padding: 26px 30px 60px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.topbar h1 {
  font-size: 23px;
}

.topbar p {
  margin: 4px 0 0;
  font-size: 13px;
}

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

.view {
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: fade 0.18s ease;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
}

/* ───────────────── 卡片 / 统计 ───────────────── */

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 45%), var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-head h2 {
  font-size: 15px;
}

.card-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

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

.stat {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 60%), var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 15px 17px;
}

.stat .k {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.02em;
}

.stat .v {
  margin-top: 5px;
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat .s {
  margin-top: 4px;
  color: var(--muted-2);
  font-size: 11.5px;
}

/* ───────────────── 图表 ───────────────── */

.chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 132px;
  padding-top: 8px;
}

.chart-col {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
}

.chart-bar {
  width: 100%;
  max-width: 34px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, var(--accent-2), rgba(79, 108, 240, 0.35));
  box-shadow: 0 0 18px rgba(109, 141, 255, 0.18);
  transition: filter 0.15s ease;
}

.chart-col:hover .chart-bar {
  filter: brightness(1.25);
}

.chart-bar.empty {
  background: var(--panel-3);
  box-shadow: none;
}

.chart-label {
  font-size: 10px;
  color: var(--muted-2);
  font-family: var(--mono);
}

.chart-legend {
  display: flex;
  gap: 14px;
  color: var(--muted-2);
  font-size: 11.5px;
  margin-top: 6px;
}

/* ───────────────── 表格 ───────────────── */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--panel);
}

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

th {
  text-align: left;
  font-weight: 550;
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.015);
}

td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.018);
}

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

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

.nowrap {
  white-space: nowrap;
}

.ellipsis {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ───────────────── 徽章 / 状态 ───────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge.ok {
  color: #7ff0c0;
  background: rgba(52, 211, 153, 0.1);
  border-color: rgba(52, 211, 153, 0.24);
}

.badge.off {
  color: #a3b0c7;
  background: rgba(139, 153, 179, 0.1);
  border-color: rgba(139, 153, 179, 0.22);
}

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

.badge.err {
  color: #ffa3a3;
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.25);
}

.badge.kind {
  color: #b9c6ff;
  background: rgba(109, 141, 255, 0.12);
  border-color: rgba(109, 141, 255, 0.25);
  font-family: var(--mono);
  font-size: 11px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 12px;
  margin: 2px 4px 2px 0;
}

.chip .arrow {
  color: var(--muted-2);
}

/* ───────────────── 进度条 ───────────────── */

.progress {
  height: 5px;
  border-radius: 999px;
  background: var(--panel-3);
  overflow: hidden;
  min-width: 80px;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #46e0b4);
}

.progress.warn > span {
  background: linear-gradient(90deg, #f5a524, #f87171);
}

/* ───────────────── 按钮 / 表单 ───────────────── */

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

.btn:hover {
  background: var(--panel-3);
  border-color: #2f3d5c;
}

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

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn.primary {
  background: linear-gradient(180deg, #6d8dff, #4f6cf0);
  border-color: #6382ff;
  color: #fff;
  box-shadow: 0 8px 20px rgba(79, 108, 240, 0.28);
}

.btn.primary:hover {
  background: linear-gradient(180deg, #7e9bff, #5a76ff);
}

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

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

.btn.danger {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.35);
  color: #ffb4b4;
}

.btn.danger:hover {
  background: rgba(248, 113, 113, 0.2);
}

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

.btn.block {
  width: 100%;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
}

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

.field .hint {
  color: var(--muted-2);
  font-size: 11.5px;
}

input,
select,
textarea {
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #0d1320;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(109, 141, 255, 0.65);
  box-shadow: 0 0 0 3px rgba(109, 141, 255, 0.14);
}

textarea {
  min-height: 90px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
}

select {
  cursor: pointer;
}

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

.form-grid .full {
  grid-column: 1 / -1;
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.check input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}

/* ───────────────── 空状态 ───────────────── */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 44px 20px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.empty strong {
  color: var(--text);
  font-size: 14px;
}

.loading {
  padding: 40px;
  text-align: center;
  color: var(--muted);
}

/* ───────────────── 代码块 ───────────────── */

.code {
  position: relative;
  background: #0a0f1a;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  color: #c7d4ea;
  overflow-x: auto;
  white-space: pre;
}

.code button {
  position: absolute;
  top: 8px;
  right: 8px;
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-top: 4px;
}

.step {
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 13px 15px;
}

.step .n {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: rgba(109, 141, 255, 0.16);
  color: var(--accent-2);
  font-size: 11px;
  font-family: var(--mono);
  margin-bottom: 6px;
}

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

.step p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

/* ───────────────── 模态框 ───────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 12, 0.72);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
  animation: fade 0.14s ease;
}

.modal {
  width: min(560px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  animation: pop 0.16s ease;
}

.modal.wide {
  width: min(760px, 100%);
}

@keyframes pop {
  from {
    transform: translateY(8px) scale(0.99);
    opacity: 0;
  }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 12px;
}

.modal-head h2 {
  font-size: 16px;
}

.modal-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.modal-close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.modal-body {
  padding: 4px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--line-soft);
}

.form-error {
  margin: 0;
  color: var(--red);
  font-size: 12.5px;
  min-height: 18px;
}

/* ───────────────── 提示 ───────────────── */

.toasts {
  position: fixed;
  top: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 80;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 220px;
  max-width: 380px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--panel-3);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: slidein 0.18s ease;
}

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

.toast.err {
  border-color: rgba(248, 113, 113, 0.4);
  color: #ffc4c4;
}

@keyframes slidein {
  from {
    transform: translateX(12px);
    opacity: 0;
  }
}

/* ───────────────── 其他 ───────────────── */

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

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

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.filters .field {
  min-width: 150px;
}

.filters .grow {
  flex: 1;
}

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

.kv {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 6px 14px;
  font-size: 12.5px;
}

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

.kv dd {
  margin: 0;
}

.note {
  border-left: 3px solid rgba(109, 141, 255, 0.5);
  background: rgba(109, 141, 255, 0.06);
  padding: 9px 12px;
  border-radius: 0 8px 8px 0;
  color: var(--muted);
  font-size: 12.5px;
}

.note strong {
  color: var(--text);
}

/* 模型广场 / 产品定价 / 接口文档 */

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

.model-groups {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.model-group .group-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
}

.model-group .group-head h3 {
  font-size: 14.5px;
}

.model-group .group-head .muted {
  font-size: 11.5px;
}

.model-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 18px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.028), transparent 45%), var(--panel);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

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

.mc-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.mc-head strong {
  font-size: 14.5px;
}

.mc-head .mono {
  margin-top: 2px;
  font-size: 11.5px;
}

.mc-desc {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  min-height: 34px;
}

.mc-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  padding: 1px 7px;
  border-radius: 6px;
  font-size: 11px;
  color: #b9c6ff;
  background: rgba(109, 141, 255, 0.1);
  border: 1px solid rgba(109, 141, 255, 0.22);
}

.mc-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 11.5px;
  font-family: var(--mono);
}

.mc-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.calc-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 12px;
  align-items: end;
}

.calc-result {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(109, 141, 255, 0.25);
  background: linear-gradient(135deg, rgba(109, 141, 255, 0.12), rgba(52, 211, 153, 0.07));
}

.calc-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.picker-list {
  max-height: 46vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: #0d1320;
}

.picker-row {
  justify-content: flex-start;
  gap: 10px;
  padding: 5px 6px;
  border-radius: 7px;
  font-size: 12.5px;
}

.picker-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.picker-row .mono {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
}

.doc-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: 0.04em;
}

.doc-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 12.5px;
}

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

  .sidebar {
    position: static;
    height: auto;
    flex-direction: column;
    border-right: none;
    border-bottom: 1px solid var(--line-soft);
  }

  .nav {
    flex-direction: row;
    overflow-x: auto;
    padding: 6px 10px;
  }

  .nav button {
    width: auto;
    white-space: nowrap;
  }

  .brand.small {
    padding: 14px 16px 4px;
  }

  .sidebar-foot {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
  }

  .main {
    padding: 18px 16px 48px;
  }

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

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

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }
}
