:root {
  --bg: #f4f6f4;
  --surface: #ffffff;
  --surface-soft: #f8faf8;
  --ink: #182420;
  --ink-soft: #3d4a45;
  --muted: #6d7a74;
  --line: #e2e7e3;
  --line-strong: #cfd8d2;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --accent-soft: #e7f3f0;
  --danger: #b83a32;
  --warn: #a96b16;
  --ok: #15803d;
  --bar: #12211f;
  --radius: 10px;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13.5px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

button {
  font: inherit;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  padding: 7px 13px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
button:hover { background: var(--surface-soft); border-color: #b9c6bf; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
button.ghost { background: transparent; }
button.danger { color: var(--danger); }
button.danger:hover { background: #fcf2f1; border-color: #e7c3bf; }
button.small { padding: 4px 9px; font-size: 13.5px; }
button.big { padding: 9px 18px; font-size: 15px; }
button[disabled] { opacity: .55; cursor: not-allowed; }

input, select, textarea {
  font: inherit;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .12);
}
input::placeholder { color: #9aa6a0; }
textarea { resize: vertical; font-family: var(--mono); font-size: 14px; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(760px 420px at 10% -10%, #e3efeb 0%, transparent 60%),
    var(--bg);
}
.login-shell {
  width: 100%;
  max-width: 880px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 70px rgba(18, 33, 31, .12);
}
.login-aside {
  background: var(--bar);
  color: #e8efec;
  padding: 38px 34px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background-image:
    linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px);
  background-size: 26px 26px;
}
.brand-mark { font-size: 20px; font-weight: 700; letter-spacing: .2px; display: flex; align-items: center; gap: 10px; }
.brand-icon { width: 44px; height: 44px; flex: none; object-fit: contain; }
.brand-mark span, .brand span { color: #5ecbbd; }
.login-mobile-brand { display: none; }
.login-aside h1 { font-size: 26px; line-height: 1.3; margin: 26px 0 10px; font-weight: 650; }
.login-aside p { color: #a9b9b3; font-size: 14px; margin: 0 0 22px; max-width: 30ch; }
.login-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 14px; color: #cfdcd6; }
.login-points li::before { content: ""; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: #5ecbbd; margin-right: 9px; vertical-align: 2px; }

.login-main { padding: 38px 36px 34px; }
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.tab {
  border: none;
  background: transparent;
  border-radius: 0;
  padding: 9px 4px;
  margin-right: 18px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
}
.tab:hover { background: transparent; color: var(--ink); border-color: transparent; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.form { display: flex; flex-direction: column; gap: 13px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; color: var(--ink-soft); }
.code-row { display: flex; gap: 8px; }
.code-row input { flex: 1; min-width: 0; }
.code-row button { flex: none; white-space: nowrap; }
.range-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.msg { margin-top: 14px; padding: 9px 11px; border-radius: 8px; font-size: 14px; background: #eef5ff; color: #2b5bb8; }
.msg.error { background: #fcf2f1; color: var(--danger); }
.msg.ok { background: #edf7f1; color: var(--ok); }

/* ---------- 顶栏 / 布局 ---------- */
.topbar {
  height: 58px;
  background: var(--bar);
  color: #eef4f1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
}
.brand { font-size: 17px; font-weight: 700; letter-spacing: .2px; display: flex; align-items: center; gap: 9px; }
.brand-logo { width: 40px; height: 40px; flex: none; object-fit: contain; }
.top-right { display: flex; align-items: center; gap: 10px; }
.top-btn { background: transparent; color: #d6e1dc; border-color: #2b3a36; padding: 5px 11px; font-size: 13.5px; }
.top-btn:hover { background: #1b2d2a; border-color: #3a4d48; }
.top-btn.user-btn { color: #eaf3ef; border-color: #3a514b; font-weight: 600; }

.layout { display: flex; min-height: calc(100vh - 58px); }
.sidebar {
  width: 242px;
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 16px 12px;
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px 10px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
}
.device-list { list-style: none; margin: 0; padding: 0; }
.device-list li {
  padding: 9px 11px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 3px;
  border: 1px solid transparent;
}
.device-list li:hover { background: var(--surface-soft); }
.device-list li.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.device-list .d-name { font-weight: 600; font-size: 14.5px; display: flex; align-items: center; gap: 8px; }
.device-list .d-id { font-size: 12.5px; color: var(--muted); font-family: var(--mono); word-break: break-all; margin-top: 1px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #b3bdb8; flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(21, 128, 61, .14); }
.empty { color: var(--muted); text-align: center; padding: 22px 8px; font-size: 13.5px; }

.main { flex: 1; padding: 22px 26px 44px; min-width: 0; }

/* ---------- 设备头部 ---------- */
.dev-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 14px; }
.dev-title { display: flex; align-items: center; gap: 12px; }
.dev-actions { display: flex; gap: 8px; }
.dev-actions button:disabled { opacity: .45; cursor: not-allowed; }
.form label.check-line { flex-direction: row; align-items: center; gap: 8px; cursor: pointer; }
.form label.check-line input { width: auto; }
.dev-title h2 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -.2px; }
.badge { padding: 3px 9px; border-radius: 999px; font-size: 12.5px; background: #eef1ee; color: var(--muted); }
.badge.on { background: #e6f5ec; color: var(--ok); }

.device-info {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}
.info-item { padding: 10px 14px; border-left: 1px solid var(--line); min-width: 0; }
.info-item:first-child { border-left: none; }
.info-item .k { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.info-item .v { display: block; font-size: 13.5px; font-weight: 550; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.info-item .v.mono { font-family: var(--mono); font-size: 13px; }

/* ---------- 空状态 ---------- */
.onboard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 58px 24px;
  text-align: center;
}
.onboard.small { padding: 28px 20px; margin-bottom: 16px; }
.onboard-icon { width: 34px; height: 34px; color: var(--accent); margin-bottom: 12px; }
.onboard h2 { margin: 0 0 6px; font-size: 20px; font-weight: 650; }
.onboard h3 { margin: 0 0 5px; font-size: 16px; font-weight: 600; }
.onboard p { margin: 0 0 16px; color: var(--muted); font-size: 14px; }

/* ---------- 表格 ---------- */
.split { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 10px;
  margin-bottom: 16px;
  min-width: 0;
}
.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}
.count {
  font-style: normal;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 6px;
  margin-left: 4px;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13.5px; }
th, td {
  text-align: left;
  padding: 8px 7px;
  border-bottom: 1px solid #eef2ef;
  vertical-align: middle;
  word-break: break-word;
  overflow-wrap: anywhere;
}
th { color: var(--muted); font-weight: 500; font-size: 12.5px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafcfb; }

.sensor-table th:nth-child(1), .sensor-table td:nth-child(1) { width: 27%; }
.sensor-table th:nth-child(2), .sensor-table td:nth-child(2) { width: 14%; }
.sensor-table th:nth-child(3), .sensor-table td:nth-child(3) { width: 21%; }
.sensor-table th:nth-child(4), .sensor-table td:nth-child(4) { width: 23%; }
.sensor-table th:nth-child(5), .sensor-table td:nth-child(5) { width: 15%; }
.actuator-table th:nth-child(1), .actuator-table td:nth-child(1) { width: 24%; }
.actuator-table th:nth-child(2), .actuator-table td:nth-child(2) { width: 16%; }
.actuator-table th:nth-child(3), .actuator-table td:nth-child(3) { width: 16%; }
.actuator-table th:nth-child(4), .actuator-table td:nth-child(4) { width: 30%; }
.actuator-table th:nth-child(5), .actuator-table td:nth-child(5) { width: 14%; }

.f-name { font-weight: 600; font-size: 13.5px; }
.code {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 4px;
  margin-top: 1px;
}
.value-box {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-height: 26px;
  min-width: 54px;
  max-width: 100%;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  font-family: var(--mono);
  font-size: 13px;
  word-break: break-all;
}
.value-box small { color: var(--muted); font-size: 11.5px; }
.row-actions { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.tag { padding: 0 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 11.5px; }
.bad { color: var(--danger); }
.warn { color: var(--warn); }
td.ok { color: var(--ok); }
td.bad { color: var(--danger); }
td.warn { color: var(--warn); }
.cmd-table th:nth-child(1), .cmd-table td:nth-child(1) { width: 138px; }
.cmd-table th:nth-child(2), .cmd-table td:nth-child(2) { width: 110px; }
.cmd-table th:nth-child(3), .cmd-table td:nth-child(3) { width: 76px; }

.panel-actions { display: flex; gap: 10px; margin-bottom: 12px; }

/* ---------- OTA ---------- */
.ota-upload-card {
  display: grid;
  grid-template-columns: 128px 190px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  margin-bottom: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.ota-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ota-field-label { font-size: 12px; color: var(--muted); padding-left: 2px; }
.ota-upload-btn { min-height: 38px; white-space: nowrap; }
.file-pick {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13.5px;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .15s, color .15s;
}
.file-pick:hover { border-color: var(--accent); color: var(--accent); }
.file-pick input { display: none; }
.file-pick > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-pick.has-file { border-style: solid; color: var(--ink); }
.ota-empty {
  padding: 28px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--muted);
  text-align: center;
  font-size: 13.5px;
}
.ota-dev-table th:nth-child(1), .ota-dev-table td:nth-child(1) { width: 22%; }
.ota-dev-table th:nth-child(2), .ota-dev-table td:nth-child(2) { width: 9%; }
.ota-dev-table th:nth-child(3), .ota-dev-table td:nth-child(3) { width: 8%; }
.ota-dev-table th:nth-child(4), .ota-dev-table td:nth-child(4) { width: 12%; }
.ota-dev-table th:nth-child(5), .ota-dev-table td:nth-child(5) { width: 19%; }
.ota-dev-table th:nth-child(6), .ota-dev-table td:nth-child(6) { width: 16%; }
.ota-dev-table th:nth-child(7), .ota-dev-table td:nth-child(7) { width: 14%; }
.ota-dev-table select { padding: 4px 6px; font-size: 12.5px; }
@media (max-width: 860px) {
  .ota-upload-card { grid-template-columns: 1fr 1fr; }
  .ota-field.grow { grid-column: 1 / -1; }
  .ota-upload-btn { grid-column: 1 / -1; }
}

/* ---------- 执行器控件 ---------- */
.toggle {
  width: 40px; height: 22px; padding: 0; flex: none;
  border: none; border-radius: 999px; background: #d9e0dc; position: relative;
}
.toggle:hover { background: #cbd5cf; }
.toggle::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .22);
  transition: left .16s;
}
.toggle.on { background: var(--accent); }
.toggle.on::after { left: 21px; }
.toggle[disabled] { opacity: .55; cursor: wait; }

.segment { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 7px; overflow: hidden; }
.segment button {
  border: none; border-left: 1px solid var(--line); border-radius: 0;
  padding: 3px 8px; font-size: 12.5px; background: var(--surface);
}
.segment button:first-child { border-left: none; }
.segment button:hover { background: var(--accent-soft); color: var(--accent); }
.range-row, .input-row { display: flex; align-items: center; gap: 5px; }
.range-row input[type=range] { width: 76px; padding: 0; border: none; box-shadow: none; accent-color: var(--accent); background: transparent; }
.range-val { font-family: var(--mono); font-size: 12.5px; color: var(--ink-soft); min-width: 26px; text-align: right; }
.input-row input { width: 72px; padding: 4px 6px; font-size: 12.5px; }
.range-row button, .input-row button { padding: 3px 7px; font-size: 12.5px; }

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; background: rgba(18, 33, 31, .45); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal-box {
  width: 100%; max-width: 540px; max-height: 90vh; overflow: auto;
  background: var(--surface); border-radius: 12px; padding: 22px;
  box-shadow: 0 24px 70px rgba(18, 33, 31, .3);
}
.modal-box h3 { margin: 0 0 14px; font-size: 17px; font-weight: 650; }
.modal-box.wide { max-width: 920px; }
.history-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.history-bar select { width: auto; padding: 4px 8px; font-size: 13.5px; }
.segment button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.history-note { margin: 10px 0 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.modal-inline-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.cred {
  background: #12211f; color: #dbe9e4; border-radius: 8px;
  padding: 13px; font-family: var(--mono); font-size: 13px;
  white-space: pre-wrap; word-break: break-all;
}
.preset { border-top: 1px solid var(--line); padding: 13px 0 2px; margin-top: 14px; }
.preset-head { font-weight: 600; margin-bottom: 6px; font-size: 13.5px; color: var(--ink-soft); }
.added-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed #eef2ef; font-size: 13.5px; }
.users-table { min-width: 720px; }
.users-table th:nth-child(1), .users-table td:nth-child(1) { width: 15%; }
.users-table th:nth-child(2), .users-table td:nth-child(2) { width: 9%; }
.users-table th:nth-child(3), .users-table td:nth-child(3) { width: 17%; }
.users-table th:nth-child(4), .users-table td:nth-child(4) { width: 17%; }
.users-table th:nth-child(5), .users-table td:nth-child(5) { width: 15%; }
.users-table th:nth-child(6), .users-table td:nth-child(6) { width: 7%; }
.users-table th:nth-child(7), .users-table td:nth-child(7) { width: 16%; }

/* ---------- 轻提示 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--bar); color: #eef4f1; padding: 9px 16px; border-radius: 8px;
  font-size: 14px; box-shadow: 0 8px 26px rgba(18, 33, 31, .25); z-index: 100;
  max-width: 80vw;
}
.toast.error { background: #8f2f28; }
.toast.warn { background: #8a5a16; }

@media (max-width: 1080px) {
  .device-info { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .info-item:nth-child(4) { border-left: none; }
  .info-item:nth-child(n+4) { border-top: 1px solid var(--line); }
}
@media (max-width: 960px) {
  .split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .login-shell { grid-template-columns: 1fr; max-width: 420px; }
  .login-aside { display: none; }
  .login-mobile-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 21px;
    font-weight: 700;
    letter-spacing: .2px;
    color: var(--ink);
    margin-bottom: 6px;
  }
  .login-mobile-brand span { color: var(--accent); }
  .login-mobile-brand .brand-icon { width: 38px; height: 38px; }
  .sidebar { width: 200px; }
  .main { padding: 18px 16px 36px; }
}
@media (max-width: 680px) {
  .layout { flex-direction: column; }
  .sidebar { width: auto; border-right: none; border-bottom: 1px solid var(--line); max-height: 210px; overflow: auto; }
  .device-info { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .info-item:nth-child(odd) { border-left: none; }
  .info-item:nth-child(n+3) { border-top: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- 文档 / 历史 全屏页 ---------- */
.docs-view {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 60;
  background: #edf2ef; overflow: auto; scroll-padding-top: 80px;
}
.page-head {
  position: sticky; top: 0; z-index: 5;
  background: var(--bar); border-bottom: 1px solid #263f39;
}
.page-head-inner {
  max-width: 1180px; margin: 0 auto;
  display: flex; align-items: center; gap: 18px;
  padding: 12px 28px;
}
.page-back {
  flex: none; display: inline-flex; align-items: center;
  background: transparent; border: 1px solid #2f403b; border-radius: 8px;
  color: #cfe0da; font-size: 14px; line-height: 1.2; padding: 7px 14px;
}
.page-back:hover { background: #1b2d2a; border-color: #3a4d48; color: #eef4f1; }
.head-logo { width: 36px; height: 36px; flex: none; object-fit: contain; }
.page-head-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.page-kicker {
  flex: none; color: #8fb5a9; font-size: 14px; font-weight: 500; letter-spacing: .02em;
}
.page-head h1 {
  margin: 0; color: #f0f6f3; font-size: 16px; font-weight: 600; letter-spacing: .2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.page-shell {
  max-width: 1180px; margin: 0 auto; padding: 36px 28px 80px;
  display: grid; grid-template-columns: 196px minmax(0, 1fr); gap: 40px;
  align-items: start;
}
.page-shell.single { max-width: 1020px; grid-template-columns: minmax(0, 1fr); }
.page-main { min-width: 0; }

/* 目录：每个条目标独立成行，参考新大陆的卡片式目录 */
.page-toc {
  position: sticky; top: 96px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(18, 33, 31, .04);
}
.toc-title {
  margin: 0; padding: 12px 16px;
  font-size: 15px; font-weight: 650; color: var(--ink);
  background: #f3f8f5; border-bottom: 1px solid var(--line);
}
.page-toc a {
  display: block; padding: 10px 16px; margin: 0;
  font-size: 13.5px; color: var(--ink-soft); text-decoration: none;
  border-top: 1px solid #eef2ef;
}
.page-toc a:first-of-type { border-top: none; }
.page-toc a:hover { background: #eaf3ef; color: var(--accent-dark); }
.page-toc a.active { background: #e3efe9; color: var(--accent-dark); font-weight: 600; }

.page-lead {
  margin: 0 0 44px; padding: 18px 22px;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--accent); border-radius: 0 10px 10px 0;
  font-size: 14.5px; line-height: 1.85; color: var(--ink-soft);
}

.doc-section { margin-top: 36px; padding-top: 36px; border-top: 1px solid #dbe4df; scroll-margin-top: 88px; }
.doc-section:first-of-type { margin-top: 0; padding-top: 0; border-top: none; }
/* 目录按篇切换时，单节独立显示，不再显示分节线 */
.docs-view.separated .doc-section { margin-top: 0; padding-top: 0; border-top: none; }
.doc-h2 {
  display: flex; align-items: center; gap: 13px;
  margin: 0 0 18px; font-size: 23px; font-weight: 700; letter-spacing: -.3px;
}
.doc-index {
  font-family: var(--mono); font-size: 13px; font-weight: 500; line-height: 1.6;
  color: var(--accent-dark); background: var(--accent-soft);
  border: 1px solid #cfe5df; border-radius: 6px; padding: 1px 8px;
}
.doc-sub {
  display: flex; align-items: center; gap: 9px;
  margin: 26px 0 10px; font-size: 14px; font-weight: 650; color: var(--ink-soft);
}
.doc-sub::before { content: ""; flex: none; width: 3px; height: 3px; border-radius: 50%; background: var(--accent); }
.doc-section p { margin: 10px 0; font-size: 14.5px; line-height: 1.85; color: var(--ink-soft); }
.doc-section code {
  font-family: var(--mono); font-size: 13px;
  background: #e6f0ec; color: var(--accent-dark);
  border: 1px solid #d3e4dd; border-radius: 5px; padding: 1px 6px;
}
.doc-section .doc-note {
  padding: 11px 15px; background: #e7efeb; border-radius: 8px;
  font-size: 13.5px; color: var(--muted);
}
.doc-section .doc-list {
  margin: 0; padding-left: 20px;
  font-size: 14px; line-height: 1.9; color: var(--ink-soft);
}
.doc-section .doc-list li::marker { color: var(--accent); }

.doc-section .codeblock code {
  background: transparent; border: 0; border-radius: 0;
  padding: 0; color: inherit; font-size: inherit;
}

.codeblock {
  position: relative; margin: 12px 0 20px;
  padding: 36px 18px 16px;
  background: #0c1b18; color: #d3e7e1;
  border: 1px solid #1d352f; border-radius: 12px;
  font-family: var(--mono); font-size: 13.5px; line-height: 1.75;
  overflow-x: auto; white-space: pre; tab-size: 2;
}
.codeblock .tok-com { color: #6f9d92; font-style: italic; }
.codeblock .tok-key { color: #8fd0e8; }
.codeblock .tok-str { color: #b7e2a9; }
.codeblock .tok-num { color: #f0c98a; }
.codeblock .tok-kw { color: #e9a4b8; }
.codeblock .tok-pre { color: #c9b3f0; }
.codeblock::after {
  content: attr(data-lang);
  position: absolute; top: 11px; left: 18px;
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .08em;
  color: #6f9d92;
}
.code-copy {
  position: absolute; top: 8px; right: 9px;
  padding: 3px 9px; font-family: inherit; font-size: 12px;
  background: #162a26; color: #9dc4ba; border-color: #24403a;
}
.code-copy:hover { background: #1d342f; color: #d6ece5; border-color: #35534c; }

.docs-table {
  width: 100%; table-layout: auto; border-collapse: separate; border-spacing: 0;
  margin: 10px 0 18px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
}
.docs-table thead th { background: #f3f8f5; color: var(--ink-soft); font-size: 12.5px; font-weight: 600; }
.docs-table th, .docs-table td {
  padding: 9px 14px; border-bottom: 1px solid #edf2ef;
  font-size: 14px; text-align: left; vertical-align: top;
}
.docs-table tbody tr:last-child td { border-bottom: none; }
.docs-table tbody tr:hover td { background: #fbfdfc; }
.docs-table tbody td:first-child { width: 128px; color: var(--muted); }

/* ---------- 历史页 ---------- */
.history-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
.hist-fields { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hist-field { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.hist-field select { width: auto; padding: 7px 12px; font-size: 14px; background: var(--surface); }
.history-meta { margin: 0; font-family: var(--mono); font-size: 12.5px; color: var(--muted); }

.history-body { overflow-x: auto; }
.hist-pager {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; margin-top: 14px;
}
.hist-pager button { padding: 6px 14px; font-size: 13.5px; }
.hist-page { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.hist-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(18, 33, 31, .04);
}
.hist-table { width: 100%; table-layout: auto; border-collapse: collapse; font-size: 13.5px; }
.hist-table thead th {
  background: #f3f8f5; color: var(--ink-soft);
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.hist-table thead th.num-col { text-align: right; }
.hist-table th, .hist-table td { padding: 9px 14px; border-bottom: 1px solid #edf2ef; }
.hist-table tbody tr:last-child td { border-bottom: none; }
.hist-table tbody tr:hover td { background: #fbfdfc; }
.hist-time { font-family: var(--mono); font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.hist-num { font-family: var(--mono); font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
.hist-json { font-family: var(--mono); font-size: 12.5px; color: var(--muted); word-break: break-all; }
.hist-type {
  display: inline-block; padding: 1px 7px; border-radius: 5px;
  font-family: var(--mono); font-size: 12.5px;
  color: var(--accent-dark); background: var(--accent-soft);
}

.pill {
  display: inline-block; padding: 1px 9px; border-radius: 999px;
  font-size: 12.5px; line-height: 1.7; white-space: nowrap;
  border: 1px solid transparent;
}
.pill.ok { background: #e6f5ec; color: var(--ok); border-color: #cdead9; }
.pill.bad { background: #fcf2f1; color: var(--danger); border-color: #f0d5d2; }
.pill.warn { background: #fdf4e7; color: var(--warn); border-color: #f0e1c8; }
.pill.flat { background: #eef2ef; color: var(--ink-soft); border-color: #e0e7e3; }

.hist-empty {
  background: var(--surface); border: 1px dashed var(--line-strong);
  border-radius: 12px; padding: 56px 20px; text-align: center;
}
.hist-empty svg { width: 32px; height: 32px; color: #a3b4ad; }
.hist-empty p { margin: 14px 0 4px; font-size: 15px; font-weight: 600; color: var(--ink-soft); }
.hist-empty span { font-size: 13.5px; color: var(--muted); }

/* ---------- 用户设置 ---------- */
.settings-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 0 26px 28px;
  box-shadow: 0 1px 2px rgba(18, 33, 31, .04);
}
.settings-tabs {
  display: flex; gap: 4px; margin: 0 -26px 24px;
  padding: 0 26px; border-bottom: 1px solid var(--line);
}
.settings-tab {
  background: transparent; border: none; border-bottom: 2px solid transparent;
  border-radius: 0; padding: 14px 16px 12px;
  font-size: 14px; color: var(--muted);
}
.settings-tab:hover { color: var(--accent-dark); background: transparent; }
.settings-tab.active { color: var(--accent-dark); border-bottom-color: var(--accent); font-weight: 600; }
.settings-pane { max-width: 760px; margin: 0 auto; }
.settings-pane.wide { max-width: none; }
.settings-h3 { margin: 0 0 12px; font-size: 15px; font-weight: 650; color: var(--ink); }
.settings-summary {
  display: flex; flex-wrap: nowrap; align-items: flex-start;
  gap: 16px; margin-bottom: 22px; padding: 16px 18px;
  background: #f6faf8; border: 1px solid var(--line); border-radius: 10px;
}
.settings-item { flex: 1 1 0; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.settings-item span { font-size: 12.5px; color: var(--muted); }
.settings-item strong { font-size: 13px; font-weight: 600; color: var(--ink); word-break: break-all; }
.settings-form { gap: 14px; }
.settings-actions { display: flex; gap: 10px; margin-top: 4px; }
.settings-divider { height: 1px; background: var(--line); margin: 26px 0 22px; }
.settings-note { margin: 0 0 16px; font-size: 13px; line-height: 1.8; color: var(--muted); }
.settings-note code {
  font-family: var(--mono); font-size: 12.5px;
  background: #eef2ef; border-radius: 4px; padding: 1px 5px; color: var(--ink-soft);
}
.settings-inline { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.settings-inline-label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-soft); }
.settings-inline-label.grow { flex: 1 1 260px; min-width: 220px; }
.settings-inline select { width: 150px; }
.settings-label { margin: 0 0 8px; font-size: 13px; color: var(--ink-soft); }
.key-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; margin-bottom: 20px; border-radius: 8px;
  background: #12211f;
}
.key-value {
  flex: 1; min-width: 0; font-family: var(--mono); font-size: 13px;
  color: #dbe9e4; background: transparent; border: 0; padding: 0;
  word-break: break-all; line-height: 1.6;
}
.key-row button {
  flex: none; background: transparent; color: #cfe0da;
  border-color: #354a44; font-size: 12.5px; padding: 4px 10px;
}
.key-row button:hover { background: #1b2d2a; border-color: #4a635c; color: #fff; }

@media (max-width: 900px) {
  .page-shell { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 24px 18px 64px; }
  .page-toc { position: static; margin-bottom: 14px; }
  .toc-title { display: block; padding: 10px 14px; font-size: 14px; }
  .page-toc a { display: block; margin: 0; padding: 9px 14px; border-radius: 0; background: transparent; }
  .page-lead { margin-bottom: 30px; }
  .doc-section { margin-top: 28px; padding-top: 28px; }
  .settings-pane { max-width: none; }
  .settings-summary { flex-wrap: wrap; }
}
@media (max-width: 680px) {
  .page-head-inner { padding: 10px 14px; gap: 12px; }
  .page-kicker { display: none; }
  .page-head h1 { font-size: 17px; }
  .page-back { padding: 5px 9px; }
  .doc-h2 { font-size: 20px; }
  .doc-index { font-size: 12px; }
}
