:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e6e8ec;
  --text: #1b1f24;
  --text-2: #5b6472;
  --text-3: #909aa8;
  --primary: #1f6feb;
  --primary-soft: #eaf2fe;
  --green: #1a7f4b;
  --green-soft: #e8f6ee;
  --amber: #9a6700;
  --amber-soft: #fff6e0;
  --red: #b42318;
  --red-soft: #fdecea;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13.5px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 17px; }
h2 { font-size: 14px; }
h3 { font-size: 13px; }

.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 208px; flex: 0 0 208px; background: var(--surface);
  border-right: 1px solid var(--border); padding: 16px 12px;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 6px 18px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--primary);
  color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 600; letter-spacing: .5px;
}
.brand-title { font-size: 13px; font-weight: 600; }
.brand-sub { font-size: 10.5px; color: var(--text-3); margin-top: 1px; }
nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px;
  border-radius: 8px; color: var(--text-2); font-size: 13px;
}
.nav-item:hover { background: #f2f4f7; color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 500; }
.nav-item.muted { color: var(--text-3); }
.nowrap { white-space: nowrap; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.hint { font-size: 11px; color: var(--text-3); padding: 4px 10px; }

.main { flex: 1; min-width: 0; padding: 18px 24px 40px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.topbar-meta { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.dot-live { width: 6px; height: 6px; border-radius: 50%; background: var(--green); display: inline-block; }

.flash { padding: 9px 12px; border-radius: 8px; margin-bottom: 14px; font-size: 12.5px; }
.flash.ok { background: var(--green-soft); color: var(--green); }
.flash.bad { background: var(--red-soft); color: var(--red); }

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-title { font-size: 12.5px; color: var(--text-2); }
.card-value { font-size: 21px; font-weight: 600; letter-spacing: -.3px; }
.card-sub { font-size: 11.5px; color: var(--text-3); margin-top: 6px; }

.badge { font-size: 11px; padding: 2px 7px; border-radius: 20px; display: inline-block; white-space: nowrap; }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.bad { background: var(--red-soft); color: var(--red); }
.badge.warn { background: var(--amber-soft); color: var(--amber); }
.badge.idle { background: #f1f3f6; color: var(--text-2); }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.panel-body { padding: 14px 16px; }
.panel-body.tight { padding: 0; }

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table-wrap { overflow-x: auto; }
.table-wrap table { min-width: 700px; }
table.compact th, table.compact td { padding: 8px 10px; }
.op-col { position: sticky; right: 0; background: var(--surface); box-shadow: -8px 0 10px -10px rgba(16,24,40,.25); }
tbody tr:hover .op-col { background: #fbfcfd; }
th { text-align: left; color: var(--text-3); font-weight: 500; padding: 9px 12px; background: #fafbfc; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 9px 12px; border-bottom: 1px solid #f2f3f5; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fbfcfd; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; }
.muted { color: var(--text-3); }
.nowrap { white-space: nowrap; }
.strong { font-weight: 500; }

.grid-2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 14px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.btn {
  display: inline-flex; align-items: center; gap: 5px; padding: 6px 11px;
  border-radius: 7px; border: 1px solid var(--border); background: #fff;
  color: var(--text); font-size: 12.5px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #cfd6e0; background: #fafbfc; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #1a5fd0; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.danger { color: var(--red); border-color: #f3c9c4; }
form.inline { display: inline; }

input[type=text], input[type=password], input[type=date], input[type=number], select, textarea {
  border: 1px solid var(--border); border-radius: 7px; padding: 6px 9px;
  font-size: 12.5px; font-family: inherit; background: #fff; color: var(--text); outline: none;
}
input:focus, select:focus { border-color: #9fc3f7; box-shadow: 0 0 0 3px rgba(31,111,235,.08); }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text-2); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.data-filters {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px 12px; align-items: end;
}
.data-filters .field { min-width: 0; }
.data-filters .field input, .data-filters .field select { width: 100% !important; }
.data-filters .field > span { width: 100%; }
.data-filters .btn, .data-filters > a.btn { height: 31px; justify-content: center; }
.data-table td, .data-table th { white-space: nowrap; }
.data-table td.settle-cell { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }

.progress { height: 5px; border-radius: 4px; background: #eef0f3; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); }
.progress.warn > span { background: #d29922; }
.progress.bad > span { background: #d9534f; }

.tabs { display: flex; gap: 4px; padding: 4px; background: #f2f4f7; border-radius: 9px; width: fit-content; margin-bottom: 12px; }
.tabs a { padding: 6px 13px; border-radius: 7px; font-size: 12.5px; color: var(--text-2); }
.tabs a.active { background: #fff; color: var(--text); font-weight: 500; box-shadow: 0 1px 2px rgba(16,24,40,.06); }

.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; padding: 10px 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-2); }

.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--bg); }
.login-card { width: 340px; background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 26px 24px; }
.login-card h1 { font-size: 16px; margin-bottom: 4px; }
.login-card p { font-size: 12px; color: var(--text-3); margin: 0 0 18px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 14px; padding: 9px; }

.stat-row { display: flex; gap: 18px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; gap: 3px; }
.stat .k { font-size: 11.5px; color: var(--text-3); }
.stat .v { font-size: 16px; font-weight: 600; }

.log-line { display: flex; gap: 10px; padding: 7px 14px; border-bottom: 1px solid #f4f5f7; font-size: 12px; align-items: baseline; }
.log-line:last-child { border-bottom: none; }
.log-time { color: var(--text-3); font-family: ui-monospace, Menlo, monospace; font-size: 11px; white-space: nowrap; }
.lv { font-size: 10.5px; padding: 1px 6px; border-radius: 4px; font-weight: 500; }
.lv.info { background: #eef4ff; color: #1f5fc4; }
.lv.debug { background: #f2f3f5; color: var(--text-2); }
.lv.warn { background: var(--amber-soft); color: var(--amber); }
.lv.error { background: var(--red-soft); color: var(--red); }

.empty { padding: 26px; text-align: center; color: var(--text-3); font-size: 12.5px; }

/* ---------- 批量执行 ---------- */
.run-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 20px; }
.run-label { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.mini-acts { display: flex; gap: 10px; font-size: 11.5px; }
.mini-acts a { color: var(--primary); }
.mini-acts a.on { font-weight: 600; text-decoration: underline; }
.mini-acts a:hover { text-decoration: underline; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
  font-size: 12.5px; cursor: pointer; user-select: none;
}
.chip:hover { border-color: #cfd6e0; background: #fafbfc; }
.chip em { font-style: normal; font-size: 10.5px; color: var(--text-3); }
.chip input { margin: 0; accent-color: var(--primary); }
.chip:has(input:checked) { border-color: #9fc3f7; background: var(--primary-soft); color: var(--primary); }
.chip:has(input:checked) em { color: #5b8fd6; }

.date-row { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.plan-hint { margin-top: 10px; font-size: 12px; color: var(--text-2); background: #fafbfc; border: 1px dashed var(--border); border-radius: 8px; padding: 7px 10px; }
.plan-hint b { color: var(--primary); font-size: 13px; }

.run-actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.run-msg { margin-top: 8px; font-size: 12px; min-height: 17px; line-height: 1.5; }
.run-actions .btn.primary { padding: 7px 16px; }

.progress-box { margin-top: 14px; border: 1px solid var(--border); border-radius: 9px; padding: 12px 14px; background: #fcfdfe; }
.progress-meta { display: flex; align-items: center; gap: 10px; margin: 9px 0 8px; font-size: 12px; }
.run-items { max-height: 236px; overflow: auto; margin-top: 4px; }
.run-item { display: flex; align-items: center; gap: 9px; padding: 5px 2px; border-bottom: 1px solid #f3f5f7; font-size: 12px; flex-wrap: wrap; }
.run-item:last-child { border-bottom: none; }
.run-item-err { flex-basis: 100%; color: var(--red); font-size: 11.5px; padding-left: 4px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 14px);
  background: #1b1f24; color: #fff; padding: 9px 16px; border-radius: 9px;
  font-size: 12.5px; opacity: 0; pointer-events: none; transition: .22s ease; z-index: 99;
  box-shadow: 0 8px 24px rgba(16,24,40,.18); max-width: 70vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: #146c43; }
.toast.bad { background: #9f2d20; }

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

@media (max-width: 980px) {
  .cards, .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .sidebar { width: 64px; flex-basis: 64px; padding: 14px 8px; }
  .brand > div:last-child, .nav-item span, .hint, .sidebar-foot .nav-item span { display: none; }
  .nav-item { justify-content: center; }
  .main { padding: 14px; }
}

/* ================= 数据接口 / 文档 ================= */
.key-cell { display: flex; align-items: center; gap: 5px; flex-wrap: nowrap; }
.key-text { font-family: ui-monospace, Menlo, monospace; font-size: 11px; background: #f5f7fa; border: 1px solid var(--border); padding: 3px 6px; border-radius: 5px; color: var(--text-2); }

.code-block {
  background: #0f172a; color: #e6edf7; border-radius: 9px; padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; line-height: 1.65;
  overflow: auto; margin: 0 0 10px; white-space: pre;
}
.doc-view .code-block { margin: 10px 0 16px; }

/* 抽屉 */
.drawer-mask {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .38);
  display: flex; justify-content: flex-end; z-index: 60; backdrop-filter: blur(1px);
}
.drawer-mask[hidden] { display: none; }
.drawer {
  width: min(680px, 94vw); height: 100%; background: var(--surface);
  display: flex; flex-direction: column; box-shadow: -12px 0 40px rgba(16,24,40,.18);
  animation: slideIn .18s ease-out;
}
@keyframes slideIn { from { transform: translateX(18px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.drawer-body { padding: 16px 18px 28px; overflow: auto; flex: 1; }
.drawer-foot { display: flex; gap: 8px; padding-top: 16px; margin-top: 18px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); }
.drawer-title { font-size: 12.5px; margin: 18px 0 8px; padding-top: 14px; border-top: 1px dashed var(--border); }
.drawer-tools { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.chip-grid { display: flex; flex-wrap: wrap; gap: 6px; max-height: 260px; overflow: auto; padding: 2px; }
.fields-grid { max-height: 320px; }
.no-scroll { overflow: hidden; }

/* 记录详情 */
.rec-drawer { width: min(760px, 96vw); }
.rec-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.rec-cell { border-bottom: 1px solid #f2f3f5; padding-bottom: 7px; min-width: 0; }
.rec-cell.wide { grid-column: 1 / -1; }
.rec-k { font-size: 11px; color: var(--text-3); margin-bottom: 3px; }
.rec-k em { font-style: normal; font-family: ui-monospace, Menlo, monospace; font-size: 10px; color: #b0b8c4; margin-left: 4px; }
.rec-v { font-size: 12.5px; word-break: break-all; white-space: pre-wrap; }

/* 数据浏览表格可点 */
.data-table tbody tr.row-click { cursor: pointer; }
.data-table tbody tr.row-click:hover { background: #f4f8ff; }
.data-table tbody tr.row-click:hover td:first-child { box-shadow: inset 3px 0 0 var(--primary); }

/* 接口文档 */
.doc-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 12px; position: sticky; top: 0; z-index: 20;
  box-shadow: 0 2px 8px rgba(16,24,40,.04);
}
.doc-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.switch input { accent-color: var(--primary); }
.doc-view {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px 26px 30px; font-size: 13px; line-height: 1.75; color: var(--text);
}
.doc-view h1 { font-size: 21px; margin: 0 0 10px; }
.doc-view h2 { font-size: 16px; margin: 26px 0 8px; padding-top: 14px; border-top: 1px solid var(--border); scroll-margin-top: 80px; }
.doc-view h3 { font-size: 13.5px; margin: 18px 0 6px; color: var(--text); }
.doc-view p { margin: 8px 0; }
.doc-view ul, .doc-view ol { margin: 8px 0 8px 20px; padding: 0; }
.doc-view li { margin: 3px 0; }
.doc-view blockquote { margin: 10px 0; padding: 8px 12px; background: var(--primary-soft); border-left: 3px solid var(--primary); color: var(--text-2); border-radius: 0 6px 6px 0; font-size: 12.5px; }
.doc-view code { background: #f4f6f9; border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; }
.doc-view .code-block code { background: none; border: none; padding: 0; color: inherit; }
.md-table-wrap { overflow-x: auto; margin: 10px 0 14px; }
.md-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.md-table th, .md-table td { border: 1px solid var(--border); padding: 6px 9px; text-align: left; vertical-align: top; }
.md-table th { background: #fafbfc; color: var(--text-2); font-weight: 500; white-space: nowrap; }
.md-table td:first-child { white-space: nowrap; }
.md-table tr:nth-child(even) td { background: #fcfdfe; }
.flash-hl { animation: hl 1.8s ease; }
@keyframes hl { 0%, 40% { background: #fff8e5; } 100% { background: transparent; } }

/* ================= 进度动画 ================= */
.progress { position: relative; }
.progress.live > span {
  background-image: linear-gradient(90deg, var(--primary) 0%, #4f9bff 50%, var(--primary) 100%);
  background-size: 200% 100%;
  animation: barFlow 1.4s linear infinite;
  transition: width .5s cubic-bezier(.4, 0, .2, 1);
}
@keyframes barFlow { from { background-position: 0 0; } to { background-position: -200% 0; } }
.progress.live::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent);
  animation: shine 1.6s ease-in-out infinite;
}
@keyframes shine { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
.spinner {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid #d7e3f7; border-top-color: var(--primary);
  display: inline-block; animation: spin .8s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); display: inline-block; animation: pulse 1.6s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(26,127,75,.45); } 70% { box-shadow: 0 0 0 7px rgba(26,127,75,0); } 100% { box-shadow: 0 0 0 0 rgba(26,127,75,0); } }
.run-item.is-running { background: #f6faff; border-radius: 6px; }
.fade-in { animation: fadeIn .25s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* 接口卡片 */
.api-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.api-card { border: 1px solid var(--border); border-radius: 10px; padding: 13px 14px; background: #fff; display: flex; flex-direction: column; gap: 10px; }
.api-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.api-badges { display: flex; flex-wrap: wrap; gap: 5px; }
.api-key-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.api-key-row .key-text { flex: 0 1 auto; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.api-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding-top: 9px; border-top: 1px dashed var(--border); }
