:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --text: #1b1f24;
  --muted: #6b7280;
  --line: #e6e8ec;
  --accent: #0f766e;
  --accent-soft: #e6f4f1;
  --accent-ink: #ffffff;
  --ok: #0f7b46;
  --ok-soft: #e7f6ee;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --warn: #b45309;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 10px 28px rgba(16, 24, 40, .05);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --panel: #161b21;
    --text: #e6e9ee;
    --muted: #9aa4b2;
    --line: #252c35;
    --accent: #2dd4bf;
    --accent-soft: #10302b;
    --accent-ink: #04201d;
    --ok: #34d399;
    --ok-soft: #0f2b21;
    --bad: #f97066;
    --bad-soft: #2c1614;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.bar {
  max-width: 1060px; margin: 0 auto; padding: 12px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 650; color: var(--text); font-size: 16px;
  min-width: 0;
}
.brand:hover { text-decoration: none; }
.logo {
  display: grid; place-items: center;
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); font-size: 14px;
}
.nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 14px; }
.nav a { color: var(--text); opacity: .72; }
.nav a:hover { color: var(--text); text-decoration: none; }
.nav .btn { color: var(--accent-ink); }
.inline { display: inline; margin: 0; }

/* ---------- 布局 ---------- */

.wrap { max-width: 1060px; margin: 0 auto; padding: 26px 18px 60px; }

.page-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 18px;
}
h1 { font-size: 24px; margin: 0; letter-spacing: -.01em; }
h3 { font-size: 16px; margin: 0 0 10px; }
h4 { font-size: 14px; margin: 18px 0 8px; color: var(--muted); font-weight: 600; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mt { margin-top: 14px; }

.grid { display: grid; gap: 14px; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.grid.stats { grid-template-columns: repeat(3, 1fr); margin-bottom: 14px; }
.grid.form2 { grid-template-columns: 1fr 1fr; }

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

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
}
.card > h3:first-child { margin-top: 0; }

/* ---------- 首页 ---------- */

.hero { padding: 18px 0 26px; }
.hero h1 { font-size: 34px; line-height: 1.2; margin-bottom: 12px; }
.lead { font-size: 17px; color: var(--muted); max-width: 620px; margin: 0 0 20px; }
.cta { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- 统计 ---------- */

.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat strong { font-size: 26px; font-weight: 650; letter-spacing: -.02em; }
.stat .sub { color: var(--muted); font-size: 13px; }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 9px 16px; border: 1px solid transparent;
  border-radius: 10px; background: var(--accent); color: var(--accent-ink);
  font-size: 14px; font-weight: 550; cursor: pointer; line-height: 1.2;
}
.btn:hover { filter: brightness(1.05); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }

.linkbtn {
  background: none; border: 0; padding: 2px 0; margin: 0;
  color: var(--accent); font: inherit; font-size: 13px; cursor: pointer;
}
.linkbtn.danger { color: var(--bad); }

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

label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text); font: inherit; font-size: 14px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
textarea { resize: vertical; }
label.check { flex-direction: row; align-items: center; gap: 8px; }
label.check input { width: auto; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack.tight { gap: 8px; margin: 10px 0; min-width: 220px; }
.form-actions { grid-column: 1 / -1; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters input, .filters select { width: auto; min-width: 140px; }

.auth {
  max-width: 420px; margin: 40px auto;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px;
}
.auth h1 { margin-bottom: 18px; }

.captcha-row { display: flex; gap: 10px; align-items: stretch; }
.captcha-row input { flex: 1; }
.captcha-row img {
  height: 44px; width: 125px; object-fit: cover; flex: none;
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer; background: #f4f6f9;
}

/* ---------- 提示 ---------- */

.flash, .notice {
  padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 14px;
}
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.err { background: var(--bad-soft); color: var(--bad); }
.notice { background: var(--accent-soft); color: var(--accent); white-space: pre-wrap; }
.newkey code {
  display: block; margin: 10px 0; padding: 10px;
  background: var(--bg); border-radius: 8px; word-break: break-all;
  font-family: var(--mono); font-size: 13px; color: var(--text);
}

/* ---------- 进度 / 图表 ---------- */

.progress {
  height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; margin: 10px 0 8px;
}
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.progress i.warn { background: var(--bad); }

.chart { display: flex; align-items: flex-end; gap: 8px; height: 150px; padding-top: 6px; }
.bar-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.bar-track { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.bar {
  width: 100%; min-height: 0; border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 55%, transparent));
}
.bar-label { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ---------- 表格 ---------- */

.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 550; font-size: 12.5px; }
tr:last-child td { border-bottom: 0; }
td.actions { display: flex; gap: 10px; }
td.actions form { margin: 0; }
.kv th { width: 110px; vertical-align: top; }
.errtext { max-width: 260px; overflow: hidden; text-overflow: ellipsis; color: var(--bad); font-size: 12px; }

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; background: var(--line); color: var(--muted);
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }

.pager { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }

/* ---------- 其他 ---------- */

pre.code {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px; overflow-x: auto; font-family: var(--mono); font-size: 12.5px;
  line-height: 1.55; color: var(--text); margin: 8px 0 0;
}
code { font-family: var(--mono); font-size: .92em; background: var(--bg); padding: 1px 5px; border-radius: 5px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 4px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: 13px;
}

details > summary {
  cursor: pointer; color: var(--muted); font-size: 13px; padding: 4px 0;
}
details[open] > summary { margin-bottom: 8px; }

.faq { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
.faq li { margin-bottom: 6px; }

.provider h3 { display: flex; align-items: center; gap: 8px; }

.model-card .kv { margin: 10px 0; }
.model-card .kv th { width: 80px; }
.model-card .chips { margin: 10px 0; }
.model-card .row { align-items: flex-start; }

.rule-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.rule-row input { width: 140px; }
.rule-row select { width: 100px; }

.footer {
  max-width: 1060px; margin: 0 auto; padding: 20px 18px 40px;
  font-size: 12.5px; color: var(--muted); display: flex; gap: 6px;
}

/* ---------- 手机 ---------- */

@media (max-width: 720px) {
  .wrap { padding: 18px 12px 50px; }
  .grid.three, .grid.stats, .grid.form2 { grid-template-columns: 1fr; }
  .hero h1 { font-size: 27px; }
  .bar { padding: 10px 12px; }
  .nav { gap: 10px; font-size: 13px; }
  .brand { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 48vw; }
  .card { padding: 14px; }
  .stat strong { font-size: 22px; }
  h1 { font-size: 21px; }
}
