/* ============ 按钮 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--dense-control-h);
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-label);
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
    box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease-spring);
}
.btn svg {
  width: 15px; height: 15px;
  transition: transform var(--dur-slow) var(--ease-spring);
}
.btn:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.btn:hover svg { transform: scale(1.12); }
.btn:active { transform: translateY(0) scale(0.98); box-shadow: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
  box-shadow: 0 1px 2px color-mix(in srgb, var(--brand) 25%, transparent);
}
.btn-primary:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
  box-shadow: 0 6px 16px -4px color-mix(in srgb, var(--brand) 50%, transparent);
}

/* 幽灵按钮：不画盒子，做成品牌色文字按钮——三级动作里最轻的一档。
   原先半透明白底落在灰页上完全没有边界，读者分不清是按钮还是普通文字；
   改成纯文字 + 品牌色后，它靠颜色表明「可点」，而不是靠一层几乎看不出的底色 */
.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--brand);
  padding-left: var(--sp-2);
  padding-right: var(--sp-2);
}
.btn-ghost:hover {
  background: var(--brand-soft);
  border-color: transparent;
  color: var(--brand-hover);
  box-shadow: none;
  transform: none;
}

.btn-danger { color: var(--danger); border-color: var(--border-strong); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
/* 确认弹窗里的主操作：实心危险色，避免误点 */
.modal-foot .btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--on-brand);
  box-shadow: 0 2px 8px -2px color-mix(in srgb, var(--danger) 45%, transparent);
}
.modal-foot .btn-danger:hover {
  background: var(--danger-active);
  border-color: var(--danger-active);
}
.confirm-icon {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--warning-soft);
  color: var(--warning);
}
.confirm-icon svg { width: 17px; height: 17px; }
/* 普通操作（启动、保存、切换等）走品牌色，与删除类高风险操作区分 */
.confirm-icon.tone-primary { background: var(--brand-soft); color: var(--brand); }

.btn-sm { height: var(--dense-btn-sm-h); padding: 0 10px; font-size: var(--fs-sm); border-radius: var(--radius-xs); }
.btn-sm svg { width: 14px; height: 14px; }
/* 纯图标按钮：定宽不收缩，保证始终是正方形 */
.btn-icon { width: var(--dense-control-h); flex-shrink: 0; padding: 0; }
.btn-icon.btn-sm { width: var(--dense-btn-sm-h); }
/* 纯图标按钮：hover 时图标轻微旋转，提示「可刷新 / 可操作」 */
.btn-icon:hover svg { transform: rotate(90deg); }
/* 动效跟着语义走：旋转只适合 refresh/rotate 这类「转一圈」的图标；
   play / power 是开关语义，转了会变成别的形状（→ ↑），改成轻微下沉表示「按下去」 */
.btn-icon[data-icon-motion="press"]:hover svg { transform: scale(0.84); }
/* 有新清单时在按钮右上角点一颗红点：略出边框，用页面底色描一圈，
   避免和按钮描边糊在一起；位置与侧栏更新圆点同规格（7px / --c-red）。 */
.btn-dot-host { position: relative; }
.btn-dot {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 7px;
  height: 7px;
  border-radius: var(--radius-pill);
  background: var(--c-red);
  box-shadow: 0 0 0 2px var(--bg);
}

.theme-toggle {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur) var(--ease);
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text); }
.theme-toggle:hover svg { transform: rotate(24deg); }
.theme-toggle svg { width: 17px; height: 17px; transition: transform var(--dur-slow) var(--ease-spring); }

/* ============ 渲染隔离 ============ */
/* 长列表页（日志、进程表、审计记录）滚动时，浏览器默认会把整页纳入重排范围。
   下面几条把「内容多、更新频繁」的容器声明为独立渲染边界：
   - contain: layout paint 让容器内部的布局与绘制不外溢，父级尺寸变化时不必重算内部
   - content-visibility: auto 让视口外的行跳过渲染，长列表首屏只算可见部分
   - contain-intrinsic-size 给出估算高度，滚动条长度不会因为跳过渲染而剧烈跳动
   不用 contain: size —— 那会让容器高度塌成 0，卡片与表格会直接不可见。 */
.log-view,
.table-wrap,
.timeline {
  contain: layout paint style;
}
.log-row {
  content-visibility: auto;
  contain-intrinsic-size: auto 40px;
}
/* 表格行不参与 content-visibility：display:table-row 不支持布局隔离，
   写了也不生效，反而让「为什么没效果」变成一个坑。表格的隔离靠 .table-wrap 承担。 */
html[data-compact="on"] .log-row {
  contain-intrinsic-size: auto 30px;
}

/* ============ 卡片 ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  min-width: 0;
  overflow: hidden;
  animation: cardIn var(--dur-enter) var(--ease) backwards;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: var(--dense-card-head-y) var(--dense-card-x);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}
.card-body { padding: var(--dense-card-y); }
.card-footer {
  padding: var(--dense-card-foot-y) var(--dense-card-x);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* 统计卡 */
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--dense-stat-y) var(--dense-stat-x);
  box-shadow: var(--shadow-sm);
  animation: cardIn var(--dur-enter) var(--ease) backwards;
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.stat:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-label {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--fs-sm); color: var(--text-2); font-weight: var(--fw-medium);
  margin-bottom: var(--dense-stat-label-gap);
}
.stat-label svg { width: 15px; height: 15px; color: var(--text-3); }
.stat-value {
  font-size: var(--dense-stat-fs);
  font-weight: var(--fw-bold);
  letter-spacing: -0.02em;
  line-height: var(--lh-display);
  font-variant-numeric: var(--num-variant, tabular-nums);
}
.stat-value .unit { font-size: var(--fs-body); font-weight: var(--fw-medium); color: var(--text-3); margin-left: 3px; }
.stat-foot { display: flex; align-items: center; gap: 5px; font-size: var(--fs-xs); color: var(--text-3); margin-top: var(--dense-stat-foot-gap); }
.stat-foot svg { width: 13px; height: 13px; }
.trend-up { color: var(--success); }
.trend-down { color: var(--danger); }

/* ============ 网格 ============ */
.grid { display: grid; gap: var(--dense-grid-gap); }
.grid > * { min-width: 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main-side { grid-template-columns: minmax(0, 1.62fr) minmax(0, 1fr); }

/* ============ 徽标 ============ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: var(--dense-badge-h);
  padding: 0 var(--sp-2);
  border-radius: var(--radius-xs);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  white-space: nowrap;
}
.badge-dot {
  width: 5px; height: 5px;
  border-radius: var(--radius-pill);
  background: currentColor;
  flex-shrink: 0;
}
/* 运行中状态点：呼吸灯（纯 CSS 关键帧，不占用 JS 主线程） */
.badge-success .badge-dot {
  animation: breathe var(--dur-loop) var(--ease-soft) infinite;
}
@keyframes breathe {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 currentColor; }
  50% { opacity: 0.65; box-shadow: 0 0 0 3px transparent; }
}
/* 五种 tone 统一带同色系描边：只加底色时徽标在浅色底上几乎看不出边界，
   描边取各自主色的 28% 透明度，保证与底色、与页面底色都有清晰轮廓 */
.badge-success {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid color-mix(in srgb, var(--success) 28%, transparent);
}
.badge-warning {
  background: var(--warning-soft);
  color: var(--warning);
  border: 1px solid color-mix(in srgb, var(--warning) 28%, transparent);
}
.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 28%, transparent);
}
.badge-idle {
  background: var(--idle-soft);
  color: var(--idle);
  border: 1px solid color-mix(in srgb, var(--idle) 26%, transparent);
}
.badge-brand {
  background: var(--brand-soft);
  color: var(--brand);
  border: 1px solid color-mix(in srgb, var(--brand) 28%, transparent);
}

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 10px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
}

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
/* 表头：用比卡片面深一档的实底与下方强分隔线划出表头区，
   原先的 --surface-2 与卡片白、页面灰都太接近，表头几乎浮不起来 */
.table thead th {
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-2);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: var(--dense-th-y) 16px;
  border-bottom: 1px solid var(--border-strong);
  background: var(--surface-3);
  white-space: nowrap;
}
/* @Table 的 Align 参数输出的是 .ta-r / .ta-c（特异性 0,1,0），压不过上面
   .table thead th 的 (0,2,1)：于是「操作」这类右对齐列的标题一直留在左边，
   跟下方靠 .row-actions 右对齐的按钮组错开一整列。这里按同样的前缀提权，
   让 Align 真正生效——改一处，全站 15 个用了 Align 的表格都跟着对齐。 */
.table thead th.ta-r { text-align: right; }
.table thead th.ta-c { text-align: center; }
.table tbody td {
  padding: var(--dense-row-y) 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}
.table tbody td.wrap { white-space: normal; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color var(--dur-fast) var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table .row-actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.table .row-sep { width: 1px; height: 16px; background: var(--border); margin: 0 1px; flex-shrink: 0; }
.btn-icon-danger { color: var(--text-3); }
.btn-icon-danger:hover {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: var(--danger-border);
}
.table .cell-main { font-weight: 550; }
/* 进程名可能是整条命令行：允许换行，固定布局把剩余宽度全留给名称列 */
#proc-table .table { table-layout: fixed; }
#proc-table td.wrap { white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
/* 进程表是高频扫读列表：行高比普通表格再紧一档，操作按钮同步缩到 26px */
#proc-table .table tbody td { padding-top: var(--sp-1); padding-bottom: var(--sp-1); }
#proc-table .row-actions .btn { width: 26px; height: 26px; }
.table .cell-sub { font-size: var(--fs-xs); color: var(--text-3); margin-top: 2px; }
/* 表格内的主名称可点击进入详情：默认继承文字色，hover 变品牌色 */
.table .cell-link { color: inherit; text-decoration: none; transition: color var(--dur-fast) var(--ease); }
.table .cell-link:hover { color: var(--brand); }
/* 表格内的图标需要显式尺寸：Icon 模板只带 viewBox，否则会被撑满或塌成 0 */
.table td svg { width: 14px; height: 14px; flex-shrink: 0; vertical-align: -2px; }

/* 列表项（非表格的紧凑列表） */
.list { display: flex; flex-direction: column; }
.list-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--dense-list-y) var(--dense-list-x);
  border-bottom: 1px solid var(--border);
  transition: background-color var(--dur-fast) var(--ease);
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: var(--surface-2); }

/* ============ 表单 ============ */
.field { margin-bottom: 15px; }
.field:last-child { margin-bottom: 0; }
/* 分段面板（本地部署 / 远程接入）后面再接独立字段时补一段间距：
   面板内的 .field 有自己的下间距，出了面板就没有了，grid gap 也传不出来，
   间距只能在样式层补，模板不该为这一处去记类名。 */
.modal-body [data-seg-panel] + .field { margin-top: 15px; }
/* 只认直接子级 label：字段标题是「标题 + 右侧帮助」两端对齐，
   但字段内部的单选行 / 复选行也是 label，用后代选择器会把它们
   一起拉成两端对齐（选项在左、文字甩到最右）。 */
.field > label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: var(--fs-sm);
  font-weight: 550;
  color: var(--text-2);
  margin-bottom: 6px;
}
.field label a { font-size: var(--fs-xs); color: var(--brand); font-weight: 500; }
.field .help { font-size: var(--fs-xs); color: var(--text-3); margin-top: 5px; }
/* 标题右侧的行内提示（如「按 Enter 添加多个域名」）：跟标签同一行，不再占输入框上方一行 */
.field label .help { margin-top: 0; font-weight: 400; }
/* 表单校验：出错字段红边 + 下方就地提示，配一次轻微抖动把视线拉过去 */
.field .field-error {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: var(--fs-xs);
  color: var(--danger);
  margin-top: 5px;
}
.field .field-error::before {
  content: "";
  width: 12px; height: 12px;
  flex-shrink: 0;
  border-radius: var(--radius-circle);
  background: var(--danger);
  mask: radial-gradient(circle at 50% 30%, #000 1.5px, transparent 1.6px),
        linear-gradient(#000, #000) 50% 72% / 2px 6px no-repeat;
  -webkit-mask: radial-gradient(circle at 50% 30%, #000 1.5px, transparent 1.6px),
                linear-gradient(#000, #000) 50% 72% / 2px 6px no-repeat;
}
.field .input.invalid,
.field .select.invalid {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 4%, var(--surface));
}
.field .input.invalid:focus,
.field .select.invalid:focus {
  box-shadow: var(--ring-danger);
}
.field.shake { animation: fieldShake var(--dur-slow) var(--ease); }
@keyframes fieldShake {
  0%, 100% { transform: translateX(0); }
  22% { transform: translateX(-4px); }
  55% { transform: translateX(4px); }
  80% { transform: translateX(-2px); }
}
.input, .select, textarea.input {
  width: 100%;
  height: var(--dense-control-h);
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-sm);
  font-family: inherit;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
textarea.input { height: auto; padding: 9px 11px; resize: vertical; line-height: 1.6; }
.input:focus, .select:focus, textarea.input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
}
.input::placeholder { color: var(--text-3); }
/* 文件选择：原生「选择文件」按钮跟面板按钮不同源，单独把按钮和文件名排进同一条控件里 */
.input[type="file"] {
  padding: 3px 6px;
  color: var(--text-2);
  cursor: pointer;
  line-height: 1.3;
}
.input[type="file"]::file-selector-button {
  height: calc(var(--dense-control-h) - 10px);
  margin-right: 10px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  vertical-align: middle;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.input[type="file"]::file-selector-button:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
}
.input[type="file"]:focus { border-color: var(--brand); box-shadow: var(--ring); }
/* 只读回显：与可编辑输入框同尺寸，用底色和默认光标表明改不了，
   用于「由系统决定、用户不能改」的值（如分类），避免做成下拉让人误以为可选 */
.input[readonly] {
  background: var(--surface-2);
  cursor: default;
}
.input[readonly]:focus { border-color: var(--border-strong); box-shadow: none; }

.input-group { display: flex; gap: var(--sp-2); align-items: center; }

/* 手机号输入：+86 前缀与号码共用一层边框，聚焦态由容器统一给出 */
.phone-field {
  display: flex;
  align-items: center;
  min-height: 46px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.phone-field:focus-within { border-color: var(--brand); box-shadow: var(--ring); }
.phone-field:has(.input.invalid) { border-color: var(--danger); }
.phone-prefix {
  display: inline-flex;
  align-items: center;
  align-self: stretch;
  padding: 0 var(--sp-3);
  border-right: 1px solid var(--border);
  color: var(--text-2);
  font-size: var(--fs-body);
}
.phone-field .input {
  flex: 1;
  min-width: 0;
  height: 44px;
  border: 0;
  background: transparent;
  box-shadow: none;
  /* 比占位符略大但不脱离基线：字号差太大会让 15px 占位符看起来偏低 */
  font-size: var(--fs-title);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.phone-field .input::placeholder {
  font-size: var(--fs-body);
  font-weight: 400;
  letter-spacing: 0;
}
.phone-field .input:focus { border: 0; box-shadow: none; }

/* 访问地址：协议用两段按钮选，域名只填主机部分，整组共用一层边框 */
.url-field {
  display: flex;
  align-items: center;
  height: var(--dense-control-h);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.url-field:focus-within { border-color: var(--brand); box-shadow: var(--ring); }
.url-scheme {
  display: inline-flex;
  align-items: center;
  align-self: stretch;
  gap: 2px;
  padding: 0 3px 0 4px;
  border-right: 1px solid var(--border);
}
.url-scheme button {
  height: calc(100% - 8px);
  padding: 0 7px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-3);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.url-scheme button:hover { color: var(--text); }
.url-scheme button.active { background: var(--brand-soft); color: var(--brand); }
.url-field .url-host {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 11px 0 8px;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.url-field .url-host:focus { border: 0; box-shadow: none; }
.url-field .url-host:not(:placeholder-shown) { color: var(--brand); font-weight: 600; }

/* 短信验证码：6 个单格输入，等宽等距，输入时只保留数字 */
.otp-hint { margin-bottom: 10px; font-size: var(--fs-sm); color: var(--text-2); }
.otp-hint b { color: var(--text); font-weight: 600; }
.otp-edit {
  margin-left: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand);
  font-family: inherit;
  font-size: var(--fs-sm);
  cursor: pointer;
}
.otp-edit:hover { color: var(--brand-hover); }
.otp-boxes { display: flex; gap: var(--sp-2); }
.otp-box {
  flex: 1;
  min-width: 0;
  height: 46px;
  padding: 0;
  text-align: center;
  font-family: var(--font-num);
  font-size: var(--fs-lg);
  font-weight: 600;
}
.otp-box.invalid { border-color: var(--danger); }
.otp-box.invalid:focus { box-shadow: var(--ring-danger); }
.otp-resend-row { margin-top: 10px; font-size: var(--fs-sm); color: var(--text-3); }
.otp-resend {
  margin-left: var(--sp-1);
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand);
  font-family: inherit;
  font-size: var(--fs-sm);
  cursor: pointer;
}
.otp-resend:disabled { color: var(--text-3); cursor: default; }

/* 注册弹窗：入口取 Logo 圆点的青绿，弹窗内的输入聚焦与主按钮同色系。
   只在 #modal-register 内覆盖，全站主操作仍是 --brand 蓝；
   无效态仍用 danger，必须排在聚焦规则之后。 */
#modal-register .input:focus,
#modal-register .select:focus,
#modal-register textarea.input:focus,
#modal-register .phone-field:focus-within {
  border-color: var(--brand-dot-ink);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-dot) 30%, transparent);
}
#modal-register .phone-field .input:focus { border: 0; box-shadow: none; }
#modal-register .input.invalid:focus,
#modal-register .otp-box.invalid:focus,
#modal-register .phone-field:has(.input.invalid):focus-within {
  border-color: var(--danger);
  box-shadow: var(--ring-danger);
}
#modal-register .btn-primary {
  background: var(--brand-dot-btn);
  border-color: var(--brand-dot-btn);
  color: var(--on-brand-dot);
  box-shadow: 0 1px 2px color-mix(in srgb, var(--brand-dot) 25%, transparent);
}
#modal-register .btn-primary:hover {
  background: var(--brand-dot-btn-hover);
  border-color: var(--brand-dot-btn-hover);
  box-shadow: 0 6px 16px -4px color-mix(in srgb, var(--brand-dot) 45%, transparent);
}
#modal-register .btn-primary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-dot) 35%, transparent);
}
#modal-register .otp-edit,
#modal-register .otp-resend { color: var(--brand-dot-ink); }
#modal-register .otp-edit:hover {
  color: color-mix(in srgb, var(--brand-dot-ink) 80%, var(--text));
  text-decoration: underline;
  text-underline-offset: 2px;
}
#modal-register .otp-resend:disabled { color: var(--text-3); }

/* 已绑定：注册成功后同弹窗展示账号摘要，不再重复走表单 */
.register-done { padding: 6px 0 2px; text-align: center; }
.register-done-ico {
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  border-radius: var(--radius-pill);
  background: var(--success-soft);
  color: var(--success);
}
.register-done-ico svg { width: 23px; height: 23px; }
.register-done-title { font-size: var(--fs-title); font-weight: 600; }
.register-done-phone {
  margin-top: 6px;
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.register-done .help { margin-top: var(--sp-2); }
.register-done-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: var(--sp-3);
  border-top: 1px dashed var(--border);
  font-size: var(--fs-sm);
  color: var(--text-3);
}

/* 胶囊输入：回车把输入框里的值变成一枚可删胶囊，值用逗号回写隐藏字段。
   用于域名、标签这类「一个字段装多个值」的场景：比逗号分隔看得见边界，
   删错其中一个不用重打整串。外观与 .input 同高同边，可直接放进 .field。 */
.tag-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: var(--dense-control-h);
  padding: var(--sp-1) var(--sp-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: text;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.tag-input:focus-within { border-color: var(--brand); box-shadow: var(--ring); }
.tag-input .tag {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  max-width: 100%;
  /* 浅品牌底 + 品牌字：一眼区分「这是一枚可删的输入值」与正文里的普通 .tag */
  background: var(--brand-soft);
  border-color: color-mix(in srgb, var(--brand) 30%, transparent);
  color: var(--brand);
  font-weight: 550;
}
.tag-input .tag > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-input input {
  flex: 1 1 120px;
  min-width: 100px;
  height: 26px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: var(--fs-sm);
}
.tag-input input::placeholder { color: var(--text-3); }
/* 胶囊里的删除按钮：默认弱化，hover 才显红，一排 × 不抢注意力 */
.tag-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-circle);
  background: transparent;
  color: color-mix(in srgb, var(--brand) 72%, transparent);
  font-size: var(--fs-sm);
  line-height: 1;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.tag-x:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }

/* 键帽：把要按的物理键画成一枚凸起小键，用在操作提示里指代 Enter / Esc / Backspace。
   底边比另外三边厚 1px，是唯一的立体手段，不额外加渐变或阴影。 */
.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 19px;
  padding: 0 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1;
  vertical-align: 1px;
}

/* 搜索框 */
.search {
  position: relative;
  display: flex;
  align-items: center;
  width: 250px;
}
.search svg {
  position: absolute;
  left: 11px;
  width: 15px; height: 15px;
  color: var(--text-3);
  pointer-events: none;
  transition: color var(--dur-fast) var(--ease);
}
.search input {
  width: 100%;
  height: var(--dense-control-h);
  padding: 0 11px 0 34px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-sm);
  font-family: inherit;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.search input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
}
.search:focus-within svg { color: var(--brand); }

/* 分段控件 / 筛选 */
.segmented {
  position: relative;
  display: inline-flex;
  gap: 2px;
  padding: var(--dense-seg-pad);
  background: var(--seg-track);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  max-width: 100%;
  overflow-x: auto;
  /* 滑块用弹簧曲线滑动，会先冲过头约 10px；一旦溢出到可滚动区域，
     classic 滚动条出现会把整行撑高，同一行的搜索框就跟着上下跳。
     隐藏滚动条（仍可滚），高度就只由按钮决定 */
  overflow-y: hidden;
  scrollbar-width: none;
  box-shadow: inset 0 0 0 1px var(--border);
}
.segmented::-webkit-scrollbar { display: none; }
/* 滑块：一枚白色实体块在轨道上平滑滑动，选中项只是文字变色 */
.segmented .seg-thumb {
  position: absolute;
  left: 0;
  top: var(--dense-seg-pad);
  height: var(--dense-seg-h);
  border-radius: var(--radius-xs);
  background: var(--surface);
  box-shadow: 0 1px 2px rgb(var(--shadow-rgb) / 0.1), 0 2px 8px -2px rgb(var(--shadow-rgb) / 0.16);
  opacity: 0;
  pointer-events: none;
  z-index: 0;
  transition: transform var(--dur-slow) var(--ease-spring), width var(--dur-slow) var(--ease-spring),
    opacity var(--dur) var(--ease);
}
.segmented button {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  height: var(--dense-seg-h);
  padding: 0 var(--sp-3);
  white-space: nowrap;
  border: 0;
  background: transparent;
  border-radius: var(--radius-xs);
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 550;
  font-family: inherit;
  cursor: pointer;
  transition: color var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
}
.segmented button:hover { color: var(--text); }
.segmented button:active { transform: scale(0.96); }
/* 选中态只改颜色：不改字重，否则按钮变宽会把同一行的搜索框顶走 */
.segmented button.active {
  background: transparent;
  color: var(--brand);
  box-shadow: none;
}
/* 暗色下白色滑块换成高一档的灰面，靠亮度差区分，不刺眼 */
[data-theme="dark"] .segmented { box-shadow: inset 0 0 0 1px var(--border); }
[data-theme="dark"] .segmented .seg-thumb {
  background: var(--surface-3);
  box-shadow: 0 1px 2px rgb(var(--shadow-rgb) / 0.5), inset 0 0 0 1px var(--border-strong);
}

/* 开关 */
/* hidden 必须永远生效：组件里的 display:flex / grid 会盖掉浏览器默认的 display:none，
   开关联动的整块字段一旦 hidden 却仍占位，弹窗里就会留下一片空白。 */
[hidden] { display: none !important; }
.switch {
  position: relative;
  width: 40px; height: 23px;
  border-radius: var(--radius-pill);
  background: var(--border-strong);
  border: 0;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color var(--dur) var(--ease);
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 19px; height: 19px;
  border-radius: var(--radius-pill);
  background: var(--knob);
  box-shadow: 0 1px 2px rgb(var(--shadow-rgb) / 0.2);
  transition: transform var(--dur) var(--ease-spring);
}
.switch.on { background: var(--brand); }
.switch.on::after { transform: translateX(17px); }

.setting-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-6);
  padding: var(--dense-setting-y) 0;
  border-bottom: 1px solid var(--border);
}
.setting-row > * { min-width: 0; }
.setting-row > :first-child { flex: 1 1 auto; }
.setting-row > :last-child { flex-shrink: 0; }
.setting-row .segmented { flex-shrink: 0; max-width: none; }
.setting-row .segmented button { white-space: nowrap; }
.setting-row:first-child { padding-top: 0; }
.setting-row:last-child { border-bottom: 0; padding-bottom: 0; }
.setting-row .s-title { font-size: var(--fs-sm); font-weight: 550; margin-bottom: 2px; }
.setting-row .s-desc { font-size: var(--fs-xs); color: var(--text-3); max-width: 460px; }
/* 版本更新说明紧跟来源说明，颜色抬一档，避免两行灰字糊成一段 */
.setting-row .s-desc + .s-desc { margin-top: var(--sp-1); color: var(--text-2); }
/* 区块型设置项：标题在上、控件在下，用于密度选择这类不能用左右排布的内容 */
.setting-block { padding: var(--dense-setting-y) 0; border-bottom: 1px solid var(--border); }
.setting-block .s-title { font-size: var(--fs-sm); font-weight: 550; margin-bottom: 2px; }
.setting-block .s-desc { font-size: var(--fs-xs); color: var(--text-3); max-width: 620px; }
/* 账号行右侧是「状态 + 操作」胶囊组；栏宽不足时整组换行，避免标题被挤成竖排 */
.setting-row.account-row { flex-wrap: wrap; }
.setting-row.account-row > :first-child { flex: 1 1 220px; }
.setting-row.account-row > :last-child { white-space: nowrap; }
/* 端口这类短输入框：桌面定宽，窄屏整行占满，避免说明被挤成一字一行 */
.setting-row .port-input { width: 110px; flex-shrink: 0; }
/* 设置页的端口行曾误用端口编辑器的 .port-row，被 92px 栅格压成窄条；
   改用独立类，并在卡片被两列栅格压窄时让输入框换到下一行 */
.setting-row.setting-port-row { flex-wrap: wrap; row-gap: var(--sp-2); }
.setting-row.setting-port-row > :first-child { flex: 1 1 240px; }
/* 版本行的「可升级 / 已是最新」胶囊与旁边按钮同高、同圆角，放一排才齐平 */
.setting-row.update-row .badge {
  height: var(--dense-btn-sm-h);
  padding: 0 var(--sp-3);
  border-radius: var(--radius-pill);
  font-size: var(--fs-sm);
  gap: 6px;
}

/* 两个同权重的小开关并排：各占一行会显得表单很散 */
.setting-row.duo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-6);
}
.setting-row.duo > .setting-cell {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  min-width: 0;
}
.setting-row.duo .s-desc { max-width: none; }
@media (max-width: 620px) {
  .setting-row.duo { grid-template-columns: 1fr; gap: var(--sp-4); }
  /* 带分段控件的设置项改为上下排列：分段本身不收缩，
     与标题并排会把标题和说明挤成一字一行 */
  .setting-row:has(.segmented) { flex-direction: column; align-items: stretch; gap: 10px; }
  .setting-row.setting-port-row { flex-direction: column; align-items: stretch; gap: var(--sp-2); }
  .setting-row.setting-port-row > :first-child { flex: 0 0 auto; }
  .setting-row .port-input { width: 100%; }
  /* 版本行右侧是「徽标 + 按钮」，窄屏并排会把左侧说明挤成一字一行 */
  .setting-row.update-row { flex-direction: column; align-items: stretch; gap: var(--sp-3); }
  .setting-row.update-row > .flex { flex-wrap: wrap; }
}

/* ============ 进度条 ============ */
.progress {
  height: 7px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--brand);
  /* 打开页面时从 0 生长到目标宽度，纯 CSS 实现 */
  animation: barGrow var(--dur-grow) var(--ease) backwards;
  transition: width var(--dur-slow) var(--ease);
}
/* 用裁剪揭示代替 scaleX：横向缩放会把 999px 的圆角压成尖角，62% 这类中间值尤其明显 */
@keyframes barGrow {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}
.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger { background: var(--danger); }

/* 迷你条形图（占比可视化） */
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; }
.bar-row:last-child { margin-bottom: 0; }
/* label 可能是模型名这类长文本：最短 66px，超出按内容撑宽（不超过半行）并单行省略，不折行 */
.bar-row .bar-label {
  flex: 0 0 auto;
  min-width: 66px;
  max-width: 45%;
  font-size: var(--fs-sm);
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-row .bar-track { flex: 1; height: 7px; border-radius: var(--radius-pill); background: var(--surface-3); overflow: hidden; }
.bar-row .bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--brand);
  animation: barGrow var(--dur-grow) var(--ease) backwards;
}
.bar-row .bar-fill.success { background: var(--success); }
.bar-row .bar-fill.warning { background: var(--warning); }
.bar-row .bar-fill.danger { background: var(--danger); }
.bar-row .bar-value { width: 52px; text-align: right; font-size: var(--fs-xs); color: var(--text-3); font-variant-numeric: var(--num-variant, tabular-nums); }

/* ============ 空状态 ============ */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: var(--dense-empty-pad);
  text-align: center;
}
.empty .empty-icon {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-3);
}
.empty .empty-icon svg { width: 20px; height: 20px; }
.empty .empty-icon .spinner { width: 20px; height: 20px; }
.empty .empty-title { font-size: var(--fs-body); font-weight: 600; }
.empty .empty-desc { font-size: var(--fs-sm); color: var(--text-3); max-width: 320px; }
/* 表格空态行：去掉单元格自身的边框与内边距，让 Empty 的留白接管 */
.empty-row > td { padding: 0; border-bottom: 0; }
.empty-row .empty { padding: 40px var(--sp-5); }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed;
  inset: 0;
  background: var(--mask);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--dense-mask-pad);
  z-index: var(--z-modal);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur) var(--ease), visibility var(--dur) var(--ease);
}
.modal-mask.open { opacity: 1; visibility: visible; }
.modal {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  transform: translateY(8px) scale(0.985);
  opacity: 0;
  transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
}
.modal-mask.open .modal { transform: none; opacity: 1; }
/* 尺寸档位必须写在 .modal 之后：同权重，靠后者生效 */
.modal-sm { max-width: 430px; }
.modal-lg { max-width: 620px; }
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--dense-modal-head);
}
.modal-head h3 { font-size: var(--fs-title); font-weight: var(--fw-bold); }
.modal-head p { margin: 3px 0 0; font-size: var(--fs-xs); color: var(--text-3); }
.modal-body { padding: var(--dense-modal-body); overflow-y: auto; overflow-x: hidden; }
/* 连接信息：长 DSN 与操作按钮各自可换行，不能把弹窗撑出横向滚动 */
.db-dsn-row { display: flex; flex-direction: column; align-items: stretch; gap: var(--sp-2); }
.db-dsn-row > .mono, .db-dsn-row [data-db-dsn] { min-width: 0; overflow-wrap: anywhere; word-break: break-all; }
.db-dsn-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.db-account-row { flex-wrap: wrap; }
.db-account-row > :first-child { flex: 1 1 220px; min-width: 0; }
.db-account-row > :last-child { flex-shrink: 0; }
/* 弹窗里的页签面板互斥显示，一屏只看得到一块：
   区块间距（.dk-sec 的 margin-bottom）在这里没人接，只会在底部堆出一段空白 */
.modal-body [data-tab-panel-group] > .dk-sec { margin-bottom: 0; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--dense-modal-foot-y) 20px;
  border-top: 1px solid var(--border);
  margin-top: 14px;
}
.modal-close {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; border-radius: var(--radius-xs);
  color: var(--text-3); cursor: pointer; flex-shrink: 0;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-close svg { width: 16px; height: 16px; }

/* ============ 任务进度弹窗 ============ */
.task-modal { max-width: 452px; }
.task-head {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--dense-modal-head);
}
.task-icon {
  width: 34px; height: 34px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-soft);
  color: var(--brand);
}
.task-icon svg { width: 17px; height: 17px; }
/* 执行中图标持续旋转，给出「正在跑」的即时感知 */
.task-modal.running .task-icon svg { animation: taskSpin var(--dur-grow) linear infinite; }
@keyframes taskSpin { to { transform: rotate(360deg); } }
.task-modal.done .task-icon { background: var(--success-soft); color: var(--success); }
.task-modal.failed .task-icon { background: var(--danger-soft); color: var(--danger); }
.task-head-text { flex: 1; min-width: 0; }
.task-head-text h3 { font-size: var(--fs-body); font-weight: 650; }
.task-head-text p { margin: 3px 0 0; font-size: var(--fs-xs); color: var(--text-3); }

.task-progress {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-5) 14px;
}
.task-bar {
  flex: 1;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  overflow: hidden;
}
.task-bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: var(--radius-pill);
  background: var(--brand);
  transition: width var(--dur-enter) var(--ease), background-color var(--dur-slow) var(--ease);
}
.task-modal.done .task-bar span { background: var(--success); }
.task-modal.failed .task-bar span { background: var(--danger); }
.task-pct {
  width: 40px;
  text-align: right;
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.task-steps {
  padding: var(--dense-task-steps);
  max-height: 268px;
  overflow-y: auto;
}
.task-step {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: var(--dense-task-step-y) 0;
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.task-step-ico {
  width: 16px; height: 16px;
  flex-shrink: 0;
  margin-top: 1px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
}
.task-step-ico svg { width: 15px; height: 15px; }
.task-step-text { flex: 1; min-width: 0; line-height: 1.5; }
.task-step-meta {
  flex-shrink: 0;
  font-size: var(--fs-2xs);
  color: var(--text-3);
  font-variant-numeric: var(--num-variant, tabular-nums);
  padding-top: 2px;
}
/* 待执行：灰点 */
.task-step[data-state="pending"] .task-step-ico::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: var(--radius-circle);
  background: var(--border-strong);
}
/* 执行中：旋转环 + 高亮文字 */
.task-step[data-state="running"] { color: var(--text); }
.task-step[data-state="running"] .task-step-ico { color: var(--brand); }
.task-step[data-state="running"] .task-step-ico svg { animation: taskSpin var(--dur-grow) linear infinite; }
.task-step[data-state="running"] .task-step-text::after {
  content: "…";
  display: inline-block;
  margin-left: 1px;
  animation: taskPulse var(--dur-pulse) var(--ease-soft) infinite;
}
@keyframes taskPulse {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}
/* 完成：绿色对勾，文字回到次级色 */
.task-step[data-state="done"] .task-step-ico { color: var(--success); }
.task-step[data-state="done"] .task-step-meta { color: var(--success); }
/* 失败：红色，文字加粗提示 */
.task-step[data-state="failed"] { color: var(--danger); font-weight: 500; }
.task-step[data-state="failed"] .task-step-ico { color: var(--danger); }
/* 跳过：整体淡化 */
.task-step[data-state="skip"] { color: var(--text-3); }
.task-step[data-state="skip"] .task-step-ico { color: var(--text-3); }
.task-step[data-state="skip"] .task-step-text { text-decoration: line-through; }

/* 新步骤入场：轻微上移淡入，形成逐条滚动的节奏感 */
.task-step.enter { animation: stepIn var(--dur-slow) var(--ease) backwards; }
@keyframes stepIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.task-foot {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--sp-3);
  padding: 14px var(--sp-5) var(--sp-4);
  margin-top: var(--sp-3);
  border-top: 1px solid var(--border);
}
.task-foot > .btn { align-self: flex-end; }
.task-foot:empty { display: none; }
.task-summary {
  flex: none;
  min-width: 0;
  font-size: var(--fs-xs);
  color: var(--text-3);
  line-height: 1.5;
}
.task-summary b { color: var(--text); font-weight: 600; }
.task-modal.done .task-summary b { color: var(--success); }
.task-modal.failed .task-summary b { color: var(--danger); }
/* 启停完成后的资源账：单独一块，比摘要更醒目一点 */
.task-res {
  margin-top: var(--sp-2);
  padding: var(--sp-2) 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--text-2);
  line-height: 1.6;
}
.task-res b { color: var(--text); font-weight: 600; font-family: var(--num-font); font-variant-numeric: var(--num-variant, tabular-nums); }
/* 一次性密码：结果里直接给出可复制的内容，避免「已重置」却拿不到密码 */
.task-secret { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.task-secret code {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-secret .btn { height: 32px; padding: 0 10px; font-size: var(--fs-xs); }
.task-secret-note { margin-top: 6px; font-size: var(--fs-xs); color: var(--text-3); }

/* ============ 登录页 ============ */
/* 单卡片居中：品牌在卡上方，页面底只留一层静态品牌光晕，不做动效 */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-7) var(--sp-5);
  background:
    radial-gradient(720px 420px at 50% -8%, color-mix(in srgb, var(--brand) 8%, transparent), transparent 72%),
    var(--bg);
}
.login-shell {
  width: 100%;
  max-width: 368px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.login-wrap .login-brand {
  display: flex;
  align-items: center;
  padding: 0;
  margin-bottom: 28px;
  color: var(--text);
}
.login-card {
  width: 100%;
  padding: 30px 30px var(--sp-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
}
.login-card h1 { font-size: var(--fs-xl); font-weight: 650; letter-spacing: -0.02em; margin-bottom: 6px; }
.login-card .login-sub { font-size: var(--fs-sm); color: var(--text-2); margin-bottom: var(--sp-6); }
.login-card .btn-primary { width: 100%; height: 40px; font-size: var(--fs-sm); }
.login-tip {
  display: flex; gap: var(--sp-2);
  margin-top: 18px;
  padding: 10px var(--sp-3);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--text-2);
}
.login-tip svg { width: 14px; height: 14px; color: var(--text-3); flex-shrink: 0; margin-top: 1px; }
.login-foot { margin-top: var(--sp-5); font-size: var(--fs-xs); color: var(--text-3); }

/* ============ 图表 ============ */
.chart-wrap { position: relative; padding: var(--sp-1) 0 0; }
.chart-svg { width: 100%; height: 150px; display: block; overflow: visible; }
.chart-legend { display: flex; gap: var(--sp-4); font-size: var(--fs-xs); color: var(--text-2); }
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.chart-legend i { width: 8px; height: 8px; border-radius: var(--radius-3xs); display: inline-block; }

/* 图表悬停：圆点吸附到最近的采样点，落在曲线上，不画竖线干扰图形。
   外圈用卡片底色描边，两条曲线挨得近时也能分清各自的点。 */
.chart-dot {
  position: absolute;
  z-index: 2;
  width: 7px;
  height: 7px;
  margin: -3.5px 0 0 -3.5px;
  border-radius: var(--radius-circle);
  background: var(--dot);
  box-shadow: 0 0 0 2px var(--surface);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
}
.chart-dot.show { opacity: 1; }
.chart-tip {
  position: absolute;
  z-index: var(--z-popover);
  min-width: 124px;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--surface);
  font-size: var(--fs-2xs);
  line-height: 1.5;
  box-shadow: var(--shadow-md);
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
}
.chart-tip.show { visibility: visible; opacity: 1; }
.chart-tip-time {
  margin-bottom: 3px;
  color: color-mix(in srgb, var(--surface) 62%, transparent);
  font-family: var(--num-font);
  font-variant-numeric: var(--num-variant, tabular-nums);
}
.chart-tip-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  white-space: nowrap;
}
.chart-tip-row > span { display: flex; align-items: center; gap: 5px; }
.chart-tip-row i {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-3xs);
  display: inline-block;
}
.chart-tip-row b { font-weight: 600; font-family: var(--num-font); font-variant-numeric: var(--num-variant, tabular-nums); }
.chart-tip-unit { font-weight: 400; opacity: 0.6; }

/* 日志查看器（行样式见文件末尾「日志」区块） */
.log-line { display: flex; gap: 10px; white-space: pre-wrap; }
.log-line .log-time { color: var(--text-3); flex-shrink: 0; }
.log-line .log-tag { flex-shrink: 0; font-weight: 600; }
.log-line .log-tag.info { color: var(--brand); }
.log-line .log-tag.warn { color: var(--warning); }
.log-line .log-tag.err { color: var(--danger); }
.log-line .log-tag.ok { color: var(--success); }

/* 时间轴 */
.timeline { position: relative; padding-left: var(--dense-timeline-x); }
.timeline::before {
  content: "";
  position: absolute;
  left: 5px; top: 6px; bottom: 6px;
  width: 1px;
  background: var(--border);
}
.tl-item { position: relative; padding-bottom: var(--dense-tl-gap); }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: "";
  position: absolute;
  left: var(--dense-tl-dot); top: 5px;
  width: 7px; height: 7px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
}
.tl-item.active::before { border-color: var(--brand); background: var(--brand); }
.tl-item .tl-title { font-size: var(--fs-sm); font-weight: 550; }
.tl-item .tl-desc { font-size: var(--fs-xs); color: var(--text-3); }

/* 键值对展示 */
.kv { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: var(--dense-kv-y) var(--dense-kv-x); font-size: var(--fs-sm); }
/* 标签用 --text-3 时 13px 中文在白底上偏虚，提到 --text-2 后笔画更实 */
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; color: var(--text); min-width: 0; }

/* 复制按钮 */
.copy-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border: 0; background: transparent; border-radius: var(--radius-2xs);
  color: var(--text-3); cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.copy-btn:hover { background: var(--surface-3); color: var(--text); }
.copy-btn svg { width: 13px; height: 13px; }

/* 密码显隐：闭眼 / 睁眼两个图标都在 DOM 里，只切显示，避免 JS 去拼 svg */
.ico-masked, .ico-plain { display: flex; align-items: center; }
.ico-plain { display: none; }
[data-secret][data-shown="1"] .ico-masked { display: none; }
[data-secret][data-shown="1"] .ico-plain { display: flex; }

/* 提示气泡 */
.tip {
  display: flex;
  gap: 9px;
  padding: var(--dense-tip-pad);
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  line-height: 1.6;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
}
.tip svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; }
.tip-info { background: var(--brand-soft); border-color: var(--brand-border); color: var(--text-2); }
.tip-info svg { color: var(--brand); }
.tip-success { background: var(--success-soft); border-color: var(--success-border); color: var(--text-2); }
.tip-success svg { color: var(--success); }
.tip-warn { background: var(--warning-soft); border-color: var(--warning-border); color: var(--text-2); }
.tip-warn svg { color: var(--warning); }
.tip-danger { background: var(--danger-soft); border-color: var(--danger-border); color: var(--text-2); }
.tip-danger svg { color: var(--danger); }
/* 面板里的纵向节奏统一放到样式层，模板不再逐处手写 mb-*：
   1) 两张卡片相邻（多数是「grid 包一组卡片」后面再跟一张）留 20px；
   2) 提示条前面只要有内容（键值行、表单、help 文案、按钮）就留 12px。
   以前靠每个面板记得加类，漏一处就贴在一起——这类回归已经出现过四次。 */
.dk-sec > .card + .card,
.dk-sec > .card + .grid,
.dk-sec > .grid + .card { margin-top: var(--sp-5); }

.dk-sec .tip:not(:first-child) { margin-top: var(--sp-3); }

/* 页面级提示条不在 .dk-sec 里，模板也没有逐处补类：
   后面接网格 / 卡片 / 页签时在这里统一留 16px，否则会直接贴边。 */
.content > .tip:not(:last-child) { margin-bottom: var(--sp-4); }

/* 弹窗正文沿用同一套节奏。上面那条只写在 .dk-sec 作用域里，
   弹窗中的「提示 + 表格」就一直贴在一起——间距交回样式层管，模板不逐处补类。 */
.modal-body .tip { margin-bottom: var(--sp-3); }
.modal-body .tip:not(:first-child) { margin-top: var(--sp-3); }
.modal-body .tip:last-child { margin-bottom: 0; }

/* 图标提示气泡：悬停 / 键盘聚焦时浮在图标上方，深底亮字，替代原生 title。
   原生 title 有约 1 秒延迟、样式不可控、暗色下被系统渲染成浅灰底，与设计系统脱节。
   JS 只负责定位与显隐，外观全部在这里；配色同 .toast（--text 深底 + --surface 亮字），
   暗色主题下自动反过来，不会出现一块突兀的黑条。 */
.tip-pop {
  position: fixed;
  z-index: var(--z-popover);
  max-width: 240px;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--surface);
  font-family: var(--font);
  font-size: var(--fs-2xs);
  line-height: 1.5;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  pointer-events: none;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.tip-pop.show { opacity: 1; transform: translateY(0); }

/* ============ 服务器状态：环形图 / 指标 / 网络 ============ */
.metric { display: flex; align-items: center; gap: var(--sp-4); }
/* 外壳固定 1440 后四列卡只有约 270px，环形图收一档，右侧三行数值才不挤出卡片 */
.metric .donut { width: 96px; height: 96px; }
.metric-rows { display: flex; flex-direction: column; gap: 9px; min-width: 0; }
.metric-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: var(--fs-sm);
  padding-bottom: var(--sp-2);
  border-bottom: 1px dashed var(--border);
}
.metric-row:last-child { padding-bottom: 0; border-bottom: 0; }
.metric-row .k { color: var(--text-3); white-space: nowrap; }
/* 路径、入口地址和动作说明会比卡片宽：允许在值里换行，不再整行溢出后被卡边裁掉。 */
.metric-row .v {
  min-width: 0;
  font-weight: 600;
  font-variant-numeric: var(--num-variant, tabular-nums);
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: right;
}
/* 概览资源卡：右侧三行指标收紧到最小档，与圆环高度对齐，不再被行距撑高 */
.metric .metric-rows { gap: var(--sp-1); }
.metric .metric-row { padding-bottom: var(--sp-1); }
/* 资源卡内的可选行：点一下把同一张卡的环形图切到这一项（多块盘 / 多张卡），再点回到合计 */
.metric-row.metric-pick {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.metric-row.metric-pick:hover .k,
.metric-row.metric-pick.active .k { color: var(--text); }
.metric-row.metric-pick.active .v { color: var(--brand); }

.donut { position: relative; width: 108px; height: 108px; flex-shrink: 0; }
.donut svg { width: 100%; height: 100%; display: block; }
.donut-track {
  fill: none;
  stroke: var(--surface-3);
  stroke-width: 9;
}
.donut-ring {
  fill: none;
  stroke-width: 9;
  stroke-linecap: round;
  transition: stroke-dasharray var(--dur-enter) var(--ease);
  /* 打开页面时环从起点生长，纯 CSS 关键帧，无 JS 开销 */
  animation: donutDraw var(--dur-grow) var(--ease) backwards;
}
@keyframes donutDraw {
  from { stroke-dashoffset: 264; }
  to { stroke-dashoffset: 0; }
}
.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.15;
}
.donut-value {
  font-size: var(--fs-xl);
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: var(--num-variant, tabular-nums);
}
.donut-unit { font-size: var(--fs-2xs); color: var(--text-3); }

.net-stats { display: flex; gap: 28px; flex-wrap: wrap; margin-bottom: var(--sp-4); }
.net-stat .ns-label {
  display: flex; align-items: center; gap: 5px;
  font-size: var(--fs-sm); color: var(--text-3); margin-bottom: 3px;
}
.net-stat .ns-label svg { width: 14px; height: 14px; }
.net-stat .ns-value {
  font-size: var(--fs-lg); font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: var(--num-variant, tabular-nums);
}
.net-stat .ns-unit { font-size: var(--fs-xs); font-weight: 500; color: var(--text-3); margin-left: 3px; }

/* 网络卡下半部分：连接数是独立维度，与流量共用 24h 口径。
   用细分隔线分段，紧凑图不再画坐标，避免和上面的流量图抢视线。 */
.conn-block {
  margin-top: var(--sp-4);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
}
.conn-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-3);
  margin-bottom: var(--sp-1);
}
.conn-title {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.conn-title svg { width: 14px; height: 14px; color: var(--text-3); }
.conn-meta {
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-variant-numeric: var(--num-variant, tabular-nums);
}
.conn-meta b { font-size: var(--fs-sm); color: var(--text); }
.conn-svg { width: 100%; height: 56px; display: block; overflow: visible; }

/* 负载：三格数值 + 每条负载的横向进度图示 */
.load-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.load-item {
  text-align: center;
  padding: 11px var(--sp-2);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.load-item:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.load-item .l-value {
  font-size: var(--fs-lg); font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: var(--num-variant, tabular-nums);
}
.load-item .l-label { font-size: var(--fs-xs); color: var(--text-3); margin-top: 1px; }
.load-item .l-track {
  height: 7px;
  margin-top: var(--sp-2);
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
}
.load-item .l-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--c-blue);
  animation: barGrow var(--dur-grow) var(--ease) backwards;
}
.load-item .l-fill.warn { background: var(--c-amber); }
.load-item .l-fill.danger { background: var(--danger); }

/* 负载说明条：数值 + 文字结论 */
.load-note {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: 14px;
  padding: 9px var(--sp-3);
  border-radius: var(--radius-sm);
  background: var(--success-soft);
  border: 1px solid var(--success-border);
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.load-note svg { width: 15px; height: 15px; color: var(--success); flex-shrink: 0; }
.load-note.warn { background: var(--warning-soft); border-color: var(--warning-border); }
.load-note.warn svg { color: var(--warning); }
.load-note.danger { background: var(--danger-soft); border-color: var(--danger-border); }
.load-note.danger svg { color: var(--danger); }


/* 数据库页：窄屏表格横向滚动时固定库名与操作列，
   滚动提示只在需要横向滚动的宽度出现，不与桌面端的完整表格重复。 */
.table-scroll-hint { display: none; }
.link { color: var(--brand); text-decoration: none; }
.link:hover { text-decoration: underline; }
@media (max-width: 900px) {
  .table-scroll-hint { display: block; padding: 0 0 var(--sp-2); }
  #db-table .col-check { display: none; }
  #db-table th:nth-child(2),
  #db-table td:nth-child(2),
  #db-inst-table th:nth-child(1),
  #db-inst-table td:nth-child(1),
  #backup-table th:nth-child(1),
  #backup-table td:nth-child(1) {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--surface);
    box-shadow: 1px 0 0 var(--border);
  }
  #db-table th:last-child,
  #db-table td:last-child,
  #db-inst-table th:last-child,
  #db-inst-table td:last-child,
  #backup-table th:last-child,
  #backup-table td:last-child {
    position: sticky;
    right: 0;
    z-index: 2;
    background: var(--surface);
    box-shadow: -1px 0 0 var(--border);
  }
  #db-table tbody tr:hover td:nth-child(2),
  #db-table tbody tr:hover td:last-child,
  #db-inst-table tbody tr:hover td:first-child,
  #db-inst-table tbody tr:hover td:last-child,
  #backup-table tbody tr:hover td:first-child,
  #backup-table tbody tr:hover td:last-child {
    background: var(--surface-2);
  }
}

@media (max-width: 900px) {
  .db-sec-actions { flex: 1 0 100%; flex-wrap: wrap; width: 100%; min-width: 100%; }
  .db-sec-actions .segmented { width: 100%; }
  .db-sec-actions .segmented button { flex: 1 1 0; min-width: 0; padding: 0 var(--sp-1); font-size: var(--fs-2xs); overflow: hidden; text-overflow: ellipsis; }
  .db-backup-actions { flex-wrap: wrap; }
  #db-table th:nth-child(2), #db-table td:nth-child(2) { min-width: 180px; max-width: 210px; }
  #db-table td:nth-child(2) .cell-sub { white-space: normal; line-height: 1.45; }
}

.db-mobile-meta { display: none; }
@media (max-width: 900px) {
  /* 窄屏不再依赖横向滚动：只留「名称 + 操作」两列，
     被隐藏的实例、大小、状态补到名称下方的一行小字里。 */
  .table-scroll-hint { display: none; }
  #db-table th:nth-child(n+3):not(:last-child),
  #db-table td:nth-child(n+3):not(:last-child),
  #db-inst-table th:nth-child(n+2):not(:last-child),
  #db-inst-table td:nth-child(n+2):not(:last-child),
  #backup-table th:nth-child(n+2):not(:last-child),
  #backup-table td:nth-child(n+2):not(:last-child) { display: none; }
  #db-table th:nth-child(2), #db-table td:nth-child(2) { min-width: 0; max-width: none; }
  .db-mobile-meta { display: block; margin-top: 3px; }
}

@media (max-width: 900px) {
  .grid.db-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
  .db-stats .stat { padding: 14px; }
  .db-stats .stat-value { font-size: var(--fs-xl); }
  .db-stats .stat-foot { font-size: var(--fs-2xs); line-height: 1.4; }
  .table .row-actions { gap: 3px; }
  .table .row-actions .btn-icon.btn-sm { width: 24px; height: 24px; }
  #db-table table, #db-inst-table table, #backup-table table { table-layout: fixed; }
  #db-table th:first-child, #db-table td:first-child,
  #db-inst-table th:first-child, #db-inst-table td:first-child,
  #backup-table th:first-child, #backup-table td:first-child { white-space: normal; }
  #db-table th:last-child, #db-table td:last-child { width: 120px; }
  #db-inst-table th:last-child, #db-inst-table td:last-child { width: 140px; }
  [data-db-row-restart] { display: none; }
  #backup-table th:last-child, #backup-table td:last-child { width: 110px; }
  #backup-table td:first-child { white-space: normal; overflow-wrap: anywhere; word-break: break-all; }
  #db-inst-table td:first-child .cell-main { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .db-inst-icon { display: none; }
}

/* 库名列的长备注与风险标签不再把表格撑出卡片；
   窄屏下这一列改为两行小字，桌面端则限制宽度并允许副标题换行。 */
@media (min-width: 901px) {
  #db-table th:nth-child(2), #db-table td:nth-child(2) { width: 240px; max-width: 240px; }
  #db-table td:nth-child(2) .cell-sub { white-space: normal; }
}

/* 窄屏弹窗里的键值对改为上下排列：长连接串能拿到整行宽度，标签也不会被挤成两行。 */
@media (max-width: 620px) {
  .modal .kv { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .modal .kv dt { margin-top: 10px; font-size: var(--fs-xs); }
  .modal .kv dt:first-child { margin-top: 0; }
  .modal .kv dd + dt { margin-top: 10px; }
}

/* 实例配置在窄屏改成参数卡片：三列放进 330px 会逼出横向滚动，
   说明文字也会被推到屏幕外。 */
@media (max-width: 620px) {
  #modal-inst-config .table-wrap { overflow: visible; }
  #modal-inst-config .table { min-width: 0; }
  #modal-inst-config .table,
  #modal-inst-config .table tbody,
  #modal-inst-config .table tr,
  #modal-inst-config .table td { display: block; width: 100%; }
  #modal-inst-config .table thead { display: none; }
  #modal-inst-config .table tr { padding: 10px 0; border-bottom: 1px solid var(--border); }
  #modal-inst-config .table tr:last-child { border-bottom: 0; }
  #modal-inst-config .table td { padding: 0; border: 0; }
  #modal-inst-config .table td:first-child { font-size: var(--fs-sm); }
  #modal-inst-config .table td:nth-child(2) { margin-top: 2px; }
  #modal-inst-config .table td:nth-child(3) { margin-top: var(--sp-1); color: var(--text-3); font-size: var(--fs-xs); }
}
