/* ==========================================================================
   DigitalPlat 自动续期 · 控制台样式表
   --------------------------------------------------------------------------
   结构：1. Design Token  2. 基础重置  3. 布局骨架  4. 组件
        5. 深色模式  6. 响应式（≤900 / ≤640）  7. 工具类
   约定：
   · 颜色/间距/圆角/字号/阴影一律走 token，不写裸色值 —— 深色模式只改变量
   · 控件高度统一三档（--h-sm 28 / --h 34 / --h-lg 40），用 min-height 而非 padding
     堆叠，避免字号不同的按钮高度参差
   · 二维码区（.qr-box）恒为白底深码，深色模式也不改，否则扫不出来
   ========================================================================== */

/* ------------------------------- 1. Token ------------------------------- */
:root {
  color-scheme: light dark;

  /* 背景层次：底 → 面 → 次级块 → 下沉块 */
  --bg: #f4f6fa;
  --panel: #ffffff;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --surface-hover: #f7faff;

  /* 描边 */
  --border: #e3e8f0;
  --border-strong: #cfd8e6;

  /* 文字：主 / 次 / 弱 */
  --text: #131a26;
  --text-2: #46536a;
  --muted: #6b7688;

  /* 主色 */
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-weak: #eef4ff;
  --primary-ring: rgba(37, 99, 235, 0.18);

  /* 语义色：正色 + 弱底 + 描边 */
  --success: #15803d;
  --success-weak: #ecfdf5;
  --success-border: #a7f3d0;
  --warning: #b45309;
  --warning-weak: #fffbeb;
  --warning-border: #fde68a;
  --danger: #dc2626;
  --danger-weak: #fef2f2;
  --danger-border: #fecaca;
  --info: #1d4ed8;
  --info-weak: #eff6ff;
  --info-border: #bfdbfe;

  /* 圆角 */
  --r-xs: 6px;
  --r-sm: 8px;
  --r: 10px;
  --radius: 12px;
  --r-lg: 14px;
  --r-full: 999px;

  /* 间距（4 的倍数） */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;

  /* 字号 */
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs: 14px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --fs-xl: 20px;
  --fs-2xl: 27px;

  /* 阴影 */
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 4px 14px rgba(16, 24, 40, 0.045);
  --shadow-lg: 0 2px 8px rgba(16, 24, 40, 0.06), 0 14px 36px rgba(16, 24, 40, 0.1);
  --shadow-xl: 0 24px 68px rgba(9, 17, 32, 0.22);

  /* 控件高度 */
  --h-sm: 28px;
  --h: 34px;
  --h-lg: 40px;

  /* 动效 */
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
  --dur: 0.16s;
}

/* ------------------------------ 2. 基础重置 ------------------------------ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto,
    "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--primary);
  text-decoration: none;
  border-radius: var(--r-xs);
}
a:hover {
  text-decoration: underline;
}
a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

::selection {
  background: var(--primary-weak);
  color: var(--primary-dark);
}

b,
strong {
  font-weight: 600;
}

/* 滚动条：细一点，避免打断卡片边缘 */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

/* ------------------------------ 3. 布局骨架 ------------------------------ */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px var(--sp-6);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 1px 0 rgba(16, 24, 40, 0.02);
}

.brand {
  font-size: var(--fs-lg);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  letter-spacing: -0.2px;
  white-space: nowrap;
}
.brand .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-weak);
  flex: none;
}

/* 通用弹性占位：把右侧内容推到行尾（顶栏、面板头部、分页栏共用） */
.spacer {
  flex: 1 1 auto;
  min-width: 0;
}

/* 顶栏右侧操作区：4 个动作按钮 + 账号区 */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

/* 顶栏右上角账号区：当前登录用户 + 退出登录 */
.acct {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding-left: var(--sp-3);
  margin-left: var(--sp-1);
  border-left: 1px solid var(--border);
}
.acct-name {
  font-size: var(--fs-sm);
  color: var(--muted);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.acct-name b {
  color: var(--text);
  font-weight: 600;
}

/* 分段控件式页签 */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--surface-3);
  padding: 3px;
  border-radius: var(--r);
  border: 1px solid transparent;
}
.tabs button {
  border: 0;
  background: transparent;
  padding: 6px 13px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: var(--fs);
  font-family: inherit;
  color: var(--muted);
  font-weight: 500;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
  white-space: nowrap;
}
.tabs button:hover {
  color: var(--text);
}
.tabs button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.1);
}

.wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: var(--sp-6);
}

h2.section-title {
  font-size: var(--fs-md);
  margin: 0 0 var(--sp-3);
  font-weight: 600;
}

/* -------------------------------- 4. 组件 -------------------------------- */

/* ---------- 4.1 指标卡 ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-4) var(--sp-4);
  box-shadow: var(--shadow);
}
.stat .label {
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 500;
}
.stat .value {
  font-size: var(--fs-2xl);
  font-weight: 700;
  margin-top: 2px;
  letter-spacing: -0.6px;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}
.stat.danger .value {
  color: var(--danger);
}
.stat.warning .value {
  color: var(--warning);
}
.stat.success .value {
  color: var(--success);
}

/* ---------- 4.2 面板 ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: var(--sp-4);
  overflow: hidden;
}
.panel-head {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  min-height: 52px;
}
.panel-head h3 {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: 600;
  white-space: nowrap;
}
/* 面板头里的筛选控件不抢占整行宽度（全局 input 是 100%） */
.panel-head select,
.panel-head input[type="text"] {
  width: auto;
  min-width: 130px;
}
.panel-body {
  padding: var(--sp-4);
}
.panel-body.flush {
  padding: 0;
}

/* ---------- 4.3 表格 ---------- */
/* 横向溢出可滚。刻意不做 max-height 内部滚动：页面级滚动才能让
   ui-smoke 的「整块重建会跳回顶部」防回归断言保持稳定 */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-sm);
}
th,
td {
  padding: 10px var(--sp-3);
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th {
  color: var(--muted);
  font-weight: 600;
  font-size: var(--fs-xs);
  background: var(--surface-3);
  position: sticky;
  top: 0;
  z-index: 2;
  letter-spacing: 0.01em;
}
tbody tr:last-child td {
  border-bottom: 0;
}
tbody tr {
  transition: background var(--dur) var(--ease);
}
tbody tr:hover {
  background: var(--surface-hover);
}
td .sub {
  color: var(--muted);
  font-size: var(--fs-xs);
}
.domain-name {
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}
.ns-list {
  white-space: normal;
  color: var(--muted);
  font-size: var(--fs-xs);
  font-family: ui-monospace, Menlo, monospace;
  line-height: 1.5;
}

/* ---------- 4.4 徽章与标签 ---------- */
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: 600;
  border: 1px solid transparent;
  line-height: 1.6;
  white-space: nowrap;
}
.badge.ok {
  background: var(--success-weak);
  color: var(--success);
  border-color: var(--success-border);
}
.badge.warn {
  background: var(--warning-weak);
  color: var(--warning);
  border-color: var(--warning-border);
}
.badge.danger {
  background: var(--danger-weak);
  color: var(--danger);
  border-color: var(--danger-border);
}
.badge.muted {
  background: var(--surface-3);
  color: var(--text-2);
  border-color: var(--border);
}
.badge.info {
  background: var(--info-weak);
  color: var(--info);
  border-color: var(--info-border);
}

/* 角色徽标 /「你」标记 */
.tag {
  display: inline-block;
  padding: 0 7px;
  border-radius: var(--r-full);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.7;
  background: var(--primary-weak);
  color: var(--primary);
  vertical-align: 1px;
  white-space: nowrap;
}

/* ---------- 4.5 表单 ---------- */
.field {
  margin-bottom: var(--sp-3);
}
.field > label {
  display: block;
  font-size: var(--fs-xs);
  color: var(--muted);
  margin-bottom: 5px;
  font-weight: 500;
}
/* 复选框/开关类 label 必须是 inline-flex ——
   `.field > label` 的特异性(0,1,1)压过 `.check`(0,1,0)，不显式提高就会退回 block，
   复选框和文字的基线随之错位 */
.field > label.check {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs);
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0;
  cursor: pointer;
}

input:not([type]),
input[type="text"],
input[type="email"],
input[type="url"],
input[type="tel"],
input[type="search"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  min-height: var(--h);
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: var(--fs);
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.75;
}
input:hover:not(:disabled),
select:hover:not(:disabled),
textarea:hover:not(:disabled) {
  border-color: var(--border-strong);
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
input:disabled,
select:disabled,
textarea:disabled {
  background: var(--surface-2);
  color: var(--muted);
  cursor: not-allowed;
}
select {
  cursor: pointer;
}
textarea {
  min-height: 78px;
  resize: vertical;
  font-family: ui-monospace, Menlo, monospace;
  font-size: var(--fs-sm);
  line-height: 1.6;
}

input[type="checkbox"],
input[type="radio"] {
  width: 15px;
  height: 15px;
  flex: none;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.hint {
  font-size: var(--fs-xs);
  color: var(--muted);
  margin-top: 5px;
  line-height: 1.6;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  color: var(--text);
  cursor: pointer;
}
/* 复选框组的栅格排布：宽屏 4-5 列、窄屏自动减列，替代「一项一行」的纵列 */
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 7px var(--sp-3);
}
.check-grid .check {
  margin-right: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 开关（18 项事件那种长列表用栅格，单个布尔值用开关） */
.switch {
  position: relative;
  width: 46px;
  height: 24px;
  flex: none;
  display: inline-block;
  vertical-align: middle;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
}
.switch span {
  position: absolute;
  inset: 0;
  background: var(--border-strong);
  border-radius: var(--r-full);
  transition: background var(--dur) var(--ease);
  cursor: pointer;
}
.switch span::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 2px;
  top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--dur) var(--ease);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
}
.switch input:checked + span {
  background: var(--primary);
}
.switch input:checked + span::before {
  transform: translateX(22px);
}
.switch input:focus-visible + span {
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.row {
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
}
.row > * {
  flex: 1 1 200px;
  min-width: 0;
}
/* 行内按钮不该被拉成等宽巨条 */
.row > .btn {
  flex: 0 0 auto;
}
.row.tight {
  gap: var(--sp-2);
}

/* 说明文字与表单分组（弹窗长表单、设置页说明共用） */
.meta {
  color: var(--muted);
  font-size: var(--fs-xs);
  line-height: 1.65;
}
.meta b {
  color: var(--text);
  font-weight: 600;
}
.meta.warn {
  background: var(--warning-weak);
  border: 1px solid var(--warning-border);
  color: var(--warning);
  border-radius: var(--r-sm);
  padding: var(--sp-2) var(--sp-3);
}
.meta.warn b {
  color: inherit;
}
.modal-body > .meta {
  margin: -6px 0 var(--sp-3);
}
.form-sec {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text);
  margin: var(--sp-4) 0 var(--sp-3);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.form-sec::before {
  content: "";
  width: 3px;
  height: 12px;
  border-radius: 2px;
  background: var(--primary);
  flex: none;
}
.form-sec:first-child {
  margin-top: 0;
}
.form-sec .tip {
  font-weight: 400;
  color: var(--muted);
  font-size: var(--fs-xs);
}
.checks {
  border: 1px dashed var(--border-strong);
  background: var(--surface-2);
  border-radius: var(--r);
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.checks .check input {
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* ---------- 4.6 按钮 ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  min-height: var(--h);
  padding: 0 13px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 13.5px;
  font-family: inherit;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease);
  white-space: nowrap;
}
.btn:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: var(--border-strong);
}
.btn:active:not(:disabled) {
  transform: translateY(0.5px);
}
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-ring);
  border-color: var(--primary);
}
.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.24);
}
.btn.primary:hover:not(:disabled) {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}
.btn.danger {
  color: var(--danger);
  border-color: var(--danger-border);
  background: var(--danger-weak);
}
.btn.danger:hover:not(:disabled) {
  background: var(--danger-weak);
  border-color: var(--danger);
}
.btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}
.btn.ghost:hover:not(:disabled) {
  background: var(--surface-3);
  color: var(--text);
}
.btn.sm {
  min-height: var(--h-sm);
  padding: 0 10px;
  font-size: var(--fs-xs);
  border-radius: var(--r-xs);
}
.btn.lg {
  min-height: var(--h-lg);
  font-size: var(--fs);
}
/* 整行按钮（登录 / 注册 / 弹窗主操作） */
.btn.block {
  width: 100%;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
/* 次要小字动作按钮：表格操作列用，避免视觉噪音 */
.actions {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  align-items: center;
}
/* 表格内的操作列不换行：防止表格自动布局把该列压成竖排（宁可横向滚动） */
td .actions {
  flex-wrap: nowrap;
}

/* ---------- 4.7 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px var(--sp-4);
  z-index: 50;
  overflow: auto;
  animation: fade var(--dur) var(--ease);
}
.modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-xl);
  animation: pop 0.2s var(--ease);
  margin-bottom: 40px;
}
.modal-head {
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: var(--fs-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
}
.at-title {
  font-weight: 600;
}
.modal-body {
  padding: var(--sp-5);
}
.modal-foot {
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-2);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.close-x {
  border: 0;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 2px 6px;
  border-radius: var(--r-xs);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.close-x:hover {
  background: var(--surface-3);
  color: var(--text);
}

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

/* 弹窗内「测试连接」结果面板 */
.tm-test {
  margin-top: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface-2);
  overflow: hidden;
}
.tm-test[hidden] {
  display: none;
}
.tm-test-head {
  padding: 9px var(--sp-3);
  font-size: var(--fs-xs);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.tm-test.good .tm-test-head {
  background: var(--success-weak);
  color: var(--success);
  border-bottom: 1px solid var(--success-border);
}
.tm-test.bad .tm-test-head {
  background: var(--danger-weak);
  color: var(--danger);
  border-bottom: 1px solid var(--danger-border);
}
.tm-test.testing .tm-test-head {
  color: var(--muted);
}
.tm-test-steps {
  padding: 7px var(--sp-3) 9px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.tm-test-step {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  line-height: 1.55;
}
.tm-test-step .n {
  flex: none;
  width: 12px;
  text-align: center;
}
.tm-test-step.ok .n {
  color: var(--success);
}
.tm-test-step.no .n {
  color: var(--danger);
}
.tm-test-step .ms {
  flex: none;
  color: var(--muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.tm-test-step .d {
  color: var(--muted);
  word-break: break-word;
}
.tm-test-step.no .d {
  color: var(--danger);
}
.tm-test-msg {
  padding: 10px var(--sp-3) 11px;
  font-size: var(--fs-xs);
  line-height: 1.6;
  color: var(--danger);
  word-break: break-word;
}
.tm-test-tip {
  padding: 0 var(--sp-3) 10px;
  font-size: var(--fs-xs);
  line-height: 1.6;
  color: var(--muted);
}
.tm-test-tip b {
  color: var(--text);
}

/* ---------- 4.8 提示条 ---------- */
.toasts {
  position: fixed;
  right: var(--sp-5);
  bottom: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  z-index: 100;
  max-width: min(380px, calc(100vw - 32px));
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  padding: 11px var(--sp-4);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  max-width: 380px;
  font-size: 13.5px;
  animation: slide 0.2s var(--ease);
}
.toast.success {
  border-left-color: var(--success);
}
.toast.error {
  border-left-color: var(--danger);
}
@keyframes slide {
  from {
    transform: translateY(10px);
    opacity: 0;
  }
}

/* ---------- 4.9 登录 / 注册 ---------- */
.login-mask {
  position: fixed;
  inset: 0;
  background: radial-gradient(1100px 620px at 50% -10%, var(--primary-weak), transparent 62%), var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: var(--sp-4);
  overflow: auto;
}
.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-6) 26px;
  width: 100%;
  max-width: 392px;
  box-shadow: var(--shadow-lg);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.3px;
  margin-bottom: var(--sp-4);
}
.login-brand .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-weak);
}
.login-box h1 {
  font-size: var(--fs-xl);
  margin: 0 0 6px;
  letter-spacing: -0.3px;
}
.login-box p {
  color: var(--muted);
  margin: 0 0 var(--sp-4);
  font-size: var(--fs-sm);
  line-height: 1.6;
}
/* 提示行不吃副标题的下边距，否则按钮和「返回登录」之间会撑出大空隙 */
.login-box p.hint {
  margin-bottom: 0;
}
/* 登录卡片内相邻按钮之间统一留 8px（Passkey 按钮显隐不改变间距节奏） */
.login-box .btn.block + .btn.block,
.login-box .btn.block + .btn {
  margin-top: var(--sp-2);
}

/* ---------- 4.10 空态 ---------- */
.empty {
  padding: 34px var(--sp-4);
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

/* ---------- 4.11 运行状态横幅 ---------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  border: 1px solid;
  border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-4);
  box-shadow: var(--shadow);
  font-size: 13.5px;
}
.alert .ic {
  flex: none;
  font-size: var(--fs-lg);
  line-height: 1.25;
}
.alert .body {
  flex: 1;
  min-width: 0;
}
.alert .body b {
  display: block;
  margin-bottom: 2px;
  font-weight: 600;
}
.alert .body span {
  display: block;
  line-height: 1.6;
}
.alert .body .meta {
  color: inherit;
  opacity: 0.82;
  margin-top: 3px;
}
.alert .btn {
  flex: none;
  align-self: center;
}
.alert.warn {
  background: var(--warning-weak);
  border-color: var(--warning-border);
  color: var(--warning);
}
.alert.danger {
  background: var(--danger-weak);
  border-color: var(--danger-border);
  color: var(--danger);
}

/* ---------- 4.12 分页栏 ---------- */
.pager {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border);
  font-size: var(--fs-sm);
  color: var(--muted);
  background: var(--surface-2);
}
.pager button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  min-height: var(--h-sm);
  padding: 0 11px;
  border-radius: var(--r-xs);
  cursor: pointer;
  font-size: var(--fs-sm);
  font-family: inherit;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.pager button:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}
.pager button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.pager input {
  width: 58px;
  text-align: center;
  padding: 3px 6px;
  min-height: var(--h-sm);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  font-size: var(--fs-sm);
  color: var(--text);
  background: var(--surface);
}
/* 页码输入框的自定义 spinner：▲=上一页 / ▼=下一页（与原生数字框方向相反） */
.pager-spin {
  display: inline-flex;
  align-items: stretch;
}
.pager-spin input {
  border-radius: var(--r-xs) 0 0 var(--r-xs);
  border-right: 0;
  width: 52px;
}
.pager-spin .spin-btns {
  display: inline-flex;
  flex-direction: column;
}
.pager-spin .spin-btns button {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 7px;
  line-height: 1;
  padding: 0 4px;
  min-width: 16px;
  min-height: 0; /* 覆盖 .pager button 的整行高，否则上下钮各占满输入框高度 */
  cursor: pointer;
  font-family: inherit;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.pager-spin .spin-btns button:first-child {
  border-radius: 0 var(--r-xs) 0 0;
}
.pager-spin .spin-btns button:last-child {
  border-radius: 0 0 var(--r-xs) 0;
  border-top: 0;
}
.pager-spin .spin-btns button:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}
.pager-spin .spin-btns button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.pager select {
  width: auto;
  min-height: var(--h-sm);
  padding: 3px 8px;
  border-radius: var(--r-xs);
  font-size: var(--fs-sm);
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
}
.pager-info {
  white-space: nowrap;
}
.pager-spacer {
  flex: 1;
}

/* ---------- 4.13 卡片网格 ---------- */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--sp-3);
}
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-4);
  background: var(--surface);
}
.card h4 {
  margin: 0 0 6px;
  font-size: 14.5px;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.card .meta {
  color: var(--muted);
  font-size: var(--fs-xs);
}
.card input[type="checkbox"] {
  cursor: pointer;
}
.footer-note {
  color: var(--muted);
  font-size: var(--fs-xs);
  text-align: center;
  padding: var(--sp-2) 0 30px;
}
/* 批量操作条 */
.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  padding: 10px var(--sp-3);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.bulk-bar .check {
  margin-right: var(--sp-1);
  font-size: var(--fs-sm);
}

/* 批量测试浮层：状态列允许换行，完整消息独立成行展示 */
.at-st {
  white-space: normal;
  word-break: break-word;
}
.at-msg {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: var(--fs-xs);
  line-height: 1.55;
}
.test-hint {
  font-size: var(--fs-xs);
  color: var(--muted);
  align-self: center;
  overflow-wrap: anywhere;
}
.test-hint.good {
  color: var(--success);
}
.test-hint.bad {
  color: var(--danger);
}

/* ---------- 4.14 运行实况（本地续期 / 线上巡检共用） ---------- */
.run-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}
.run-head .metrics {
  display: flex;
  gap: var(--sp-4);
  flex-wrap: wrap;
  color: var(--muted);
  font-size: var(--fs-xs);
}
.run-head .metrics b {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.run-actions {
  margin-left: auto;
  display: flex;
  gap: var(--sp-2);
}
.run-steps {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  margin: var(--sp-3) 0 10px;
}
.run-step {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  color: var(--muted);
  padding: 2px 0;
}
.run-step .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-strong);
  flex: none;
}
.run-step.done .dot {
  background: var(--success);
}
.run-step.active .dot {
  background: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.run-step.done {
  color: var(--success);
}
.run-step.active {
  color: var(--text);
  font-weight: 600;
}
.run-step .line {
  width: 16px;
  height: 1px;
  background: var(--border);
  margin: 0 6px;
}
.run-current {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px var(--sp-3);
  font-size: var(--fs-sm);
  margin-bottom: 10px;
  color: var(--text);
  overflow-wrap: anywhere;
}
.run-current .k {
  color: var(--muted);
}
.run-tools {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: var(--sp-2);
}
.run-tools select,
.run-tools input[type="text"] {
  width: auto;
  min-height: var(--h-sm);
  padding: 3px 9px;
  font-size: var(--fs-xs);
}
.run-tools input[type="text"] {
  min-width: 150px;
}
.run-tools .count {
  color: var(--muted);
  font-size: var(--fs-xs);
  margin-left: auto;
}
/* 终端日志区：深浅模式下都保持深底亮字（这是终端语义，不跟随主题反转） */
.run-log {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: var(--r);
  padding: 10px var(--sp-3);
  max-height: 420px;
  overflow: auto;
  font-family: ui-monospace, Menlo, monospace;
  font-size: var(--fs-xs);
  line-height: 1.65;
}
.run-line {
  display: flex;
  gap: var(--sp-2);
  white-space: pre-wrap;
  word-break: break-all;
}
.run-line .t {
  color: #94a3b8;
  flex: none;
  font-variant-numeric: tabular-nums;
}
.run-line .p {
  flex: none;
  color: #93c5fd;
  min-width: 52px;
}
.run-line .m {
  color: #e2e8f0;
}
.run-line.ok .m {
  color: #86efac;
}
.run-line.err .m {
  color: #fca5a5;
}
.run-line.warn .m {
  color: #fcd34d;
}
.run-log .empty-line {
  color: #64748b;
}

/* ---------- 4.15 登录安全（2FA / Passkey） ---------- */
/* 二维码恒为白底：深色模式也必须是浅底深码，否则相机/扫码器读不出来 */
.qr-box {
  display: flex;
  justify-content: center;
  padding: var(--sp-3);
  margin: 6px 0 var(--sp-3);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.qr-box svg {
  display: block;
  width: 188px;
  height: 188px;
}
.secret-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.secret-line span {
  letter-spacing: 0.06em;
  word-break: break-all;
}
.recovery-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}
.recovery-grid code {
  display: block;
  padding: var(--sp-2) 10px;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-sm);
  font-family: ui-monospace, Menlo, monospace;
  font-size: 13.5px;
  letter-spacing: 0.08em;
  text-align: center;
  user-select: all;
}

/* ------------------------------ 5. 深色模式 ------------------------------ */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1119;
    --panel: #141b26;
    --surface: #141b26;
    --surface-2: #19212e;
    --surface-3: #1e2734;
    --surface-hover: #1a2331;

    --border: #26303f;
    --border-strong: #38455a;

    --text: #e9eef6;
    --text-2: #b3bdcc;
    --muted: #8b96a8;

    --primary: #4f83f7;
    --primary-dark: #3f74ec;
    --primary-weak: #16233c;
    --primary-ring: rgba(79, 131, 247, 0.26);

    --success: #34d399;
    --success-weak: #10241c;
    --success-border: #1e5c45;
    --warning: #fbbf24;
    --warning-weak: #2a1f0c;
    --warning-border: #6b4c11;
    --danger: #f87171;
    --danger-weak: #2a1416;
    --danger-border: #6d2a2a;
    --info: #7aa2ff;
    --info-weak: #16233c;
    --info-border: #2c4470;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.26);
    --shadow-lg: 0 2px 10px rgba(0, 0, 0, 0.4), 0 16px 40px rgba(0, 0, 0, 0.42);
    --shadow-xl: 0 26px 72px rgba(0, 0, 0, 0.66);
  }

  /* 深色下按钮主色文字保持高对比 */
  .btn.primary {
    color: #08101f;
    font-weight: 600;
    box-shadow: none;
  }
  .btn.primary:hover:not(:disabled) {
    color: #030812;
  }
  .login-mask {
    background: radial-gradient(1100px 620px at 50% -10%, rgba(79, 131, 247, 0.16), transparent 62%), var(--bg);
  }
  .modal-mask {
    background: rgba(2, 6, 13, 0.66);
  }
  /* 二维码外框在白底上，边框用浅灰，避免深色模式下边框"消失" */
  .qr-box {
    border-color: #d7dee9;
  }
}

/* ------------------------------ 6. 响应式 ------------------------------ */

/* ---- 平板 / 窄桌面 ---- */
@media (max-width: 900px) {
  .wrap {
    padding: var(--sp-4);
  }
  .topbar {
    padding: 10px var(--sp-4);
    gap: var(--sp-2);
  }
  .topbar-actions {
    order: 3;
    width: 100%;
    justify-content: flex-start;
  }
  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .panel-head {
    row-gap: 6px;
  }
  .grid-cards {
    grid-template-columns: 1fr;
  }
}

/* ---- 手机 ---- */
@media (max-width: 640px) {
  :root {
    --fs-2xl: 23px;
    --fs-xl: 18px;
  }

  body {
    /* iOS Safari 在输入框字号 <16px 时会自动放大整页 */
    font-size: 14px;
  }

  .wrap {
    padding: var(--sp-3) 10px;
  }
  .topbar {
    padding: 8px 10px;
    gap: 8px;
    position: static; /* 小屏顶栏太高，粘住会吃掉半个屏幕 */
  }
  .brand {
    font-size: var(--fs-md);
  }
  /* 顶栏重排：第一行「品牌 —— 账号」，第二行页签，第三行动作按钮（各自横向滚动） */
  .acct {
    order: 1;
    margin-left: 0;
    padding-left: 0;
    border-left: 0;
  }
  .acct-name {
    max-width: 92px;
  }
  .tabs {
    order: 2;
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar {
    display: none;
  }
  .topbar-actions {
    order: 3;
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .topbar-actions::-webkit-scrollbar {
    display: none;
  }
  .topbar-actions .btn {
    flex: none;
  }
  .acct .btn {
    min-height: 30px;
    padding: 0 10px;
    font-size: var(--fs-xs);
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-2);
    margin-bottom: var(--sp-4);
  }
  .stat {
    padding: var(--sp-3);
  }

  .panel {
    border-radius: var(--r);
    margin-bottom: var(--sp-3);
  }
  .panel-head {
    padding: 10px var(--sp-3);
    min-height: 0;
  }
  .panel-head h3 {
    font-size: var(--fs);
    width: 100%;
  }
  /* 筛选控件在窄屏各占一行，别挤成一条 */
  .panel-head select,
  .panel-head input[type="text"] {
    width: 100%;
    max-width: none !important;
    min-width: 0;
  }
  .panel-head .spacer {
    display: none;
  }
  .panel-body {
    padding: var(--sp-3);
  }

  /* 表格：保持横滚，首列吸附，压缩内边距 */
  th,
  td {
    padding: 9px 10px;
    font-size: var(--fs-xs);
  }
  .table-scroll th:first-child,
  .table-scroll td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--surface);
  }
  .table-scroll th:first-child {
    z-index: 3;
    background: var(--surface-3);
  }
  .table-scroll tr:hover td:first-child {
    background: var(--surface-hover);
  }
  .domain-name {
    font-size: var(--fs-xs);
  }

  /* 触控热区：按钮至少 36px，小按钮也跟着放大 */
  .btn {
    min-height: 36px;
    font-size: 13.5px;
  }
  .btn.sm {
    min-height: 32px;
    font-size: var(--fs-xs);
  }
  td .actions {
    flex-wrap: nowrap;
  }

  /* 输入框提到 16px，阻止 iOS 聚焦时整页放大 */
  input:not([type]),
  input[type="text"],
  input[type="email"],
  input[type="url"],
  input[type="tel"],
  input[type="search"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  select,
  textarea {
    font-size: 16px;
    min-height: 38px;
  }
  .pager input,
  .run-tools input[type="text"],
  .run-tools select,
  .pager select {
    font-size: 14px;
  }

  /* 表单行改单列 */
  .row > * {
    flex-basis: 100%;
  }
  .row > .btn {
    flex: 1 1 auto;
  }
  .check-grid {
    grid-template-columns: 1fr 1fr;
    gap: 6px 10px;
  }

  /* 弹窗改底部抽屉：从下往上，占满宽度，圆角只留顶部 */
  .modal-mask {
    align-items: flex-end;
    padding: 0;
  }
  .modal {
    max-width: 100% !important;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    margin-bottom: 0;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    animation: sheet 0.22s var(--ease);
  }
  .modal-head,
  .modal-foot {
    flex: none;
  }
  .modal-body {
    padding: var(--sp-4) var(--sp-3);
    overflow: auto;
    flex: 1;
  }
  .modal-foot {
    padding: var(--sp-3);
    gap: 8px;
  }
  .modal-foot .btn {
    flex: 1;
  }

  .login-mask {
    padding: 0;
    align-items: stretch;
  }
  .login-box {
    max-width: 100%;
    border-radius: 0;
    border: 0;
    box-shadow: none;
    margin: auto;
    padding: var(--sp-6) var(--sp-5);
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100%;
  }

  .toasts {
    left: 10px;
    right: 10px;
    bottom: 10px;
    max-width: none;
  }
  .toast {
    max-width: none;
  }

  .recovery-grid {
    grid-template-columns: 1fr;
  }
  .run-actions {
    margin-left: 0;
    width: 100%;
  }
  .run-head .metrics {
    gap: var(--sp-3);
  }
  .run-log {
    max-height: 300px;
    font-size: 11.5px;
  }
  .footer-note {
    padding-bottom: 24px;
  }
  .alert {
    flex-wrap: wrap;
    padding: var(--sp-3);
  }
  .alert .btn {
    width: 100%;
  }
}

@keyframes sheet {
  from {
    transform: translateY(24px);
    opacity: 0.6;
  }
}

/* 尊重系统「减弱动态效果」 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ------------------------------- 7. 工具类 ------------------------------- */
/* 垂直节奏：把原先散落的 style="margin-top:Npx" 收成几档 */
.mt4 {
  margin-top: 4px;
}
.mt6 {
  margin-top: 6px;
}
.mt8 {
  margin-top: 8px;
}
.mt10 {
  margin-top: 10px;
}
.mt12 {
  margin-top: 12px;
}
.mt16 {
  margin-top: 16px;
}
.mb0 {
  margin-bottom: 0;
}
.mb8 {
  margin-bottom: 8px;
}
.mb10 {
  margin-bottom: 10px;
}
.mb12 {
  margin-bottom: 12px;
}
.my12 {
  margin: 12px 0;
}
.pb0 {
  padding-bottom: 0;
}
.lh-loose {
  line-height: 1.9;
}

/* 「续期助手」里的 6 位动态码：等宽大字号，方便边看边往官网粘 */
.totp-code {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 3px;
  font-variant-numeric: tabular-nums;
}

.flex1 {
  flex: 1;
  min-width: 0;
}
.row-end {
  margin-left: auto;
}
.nowrap {
  white-space: nowrap;
}
.flex-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
/* 弹窗内滚动长列表（批量测试结果之类） */
.scroll-y-sm {
  max-height: 320px;
  overflow: auto;
}
.scroll-y-md {
  max-height: 340px;
  overflow: auto;
}

.maxw-640 {
  max-width: 640px;
}
.maxw-660 {
  max-width: 660px;
}
.maxw-720 {
  max-width: 720px;
}
.maxw-760 {
  max-width: 760px;
}
.maxw-900 {
  max-width: 900px;
}

.muted-text {
  color: var(--muted);
  font-size: var(--fs-xs);
}
.danger-text {
  color: var(--danger);
}
.warn-text {
  color: var(--warning);
}

.mono {
  font-family: ui-monospace, Menlo, monospace;
  font-size: var(--fs-xs);
}
.hidden {
  display: none !important;
}
