/* 通用组件。选择器都只用一个类，避免互相压优先级。 */

/* ---- 卡片 ---- */

.card {
  background: var(--surface);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
}

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

.btn {
  --spin: var(--text-2);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 16px;
  border-radius: var(--r-pill);
  background: var(--fill);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  user-select: none;
  transition:
    background var(--dur-fast) ease,
    color var(--dur-fast) ease,
    opacity var(--dur-fast) ease,
    transform var(--dur-spring) var(--spring);
}

.btn:active {
  transform: scale(0.96);
  transition-duration: var(--dur-fast), var(--dur-fast), var(--dur-fast), 90ms;
}

.btn:disabled {
  opacity: 0.38;
  pointer-events: none;
}

.btn-primary {
  --spin: var(--on-accent);
  background: var(--accent);
  color: var(--on-accent);
}

.btn-tinted {
  --spin: var(--accent);
  background: var(--accent-tint);
  color: var(--accent);
}

.btn-danger {
  --spin: var(--bad);
  background: var(--bad-tint);
  color: var(--bad);
}

.btn-plain {
  --spin: var(--accent);
  padding: 0 10px;
  background: none;
  color: var(--accent);
}

/* 和普通按钮同一块灰底，只有字是红的：苹果那种"破坏性操作"的做法。
   操作条、页头这类一排按钮放在一起的地方用它 —— 一排里红底、蓝底、红底
   交替出现，看着就是三种不同的东西拼在一起 */
.btn-destructive {
  --spin: var(--bad);
  color: var(--bad);
}

/* 表格每一行里的危险操作：平时只是一行红字，指上去才有底色。
   一列都是红底按钮的话，整张表最显眼的就成了按钮而不是数据 */
.btn-quiet-danger {
  --spin: var(--bad);
  background: none;
  color: var(--bad);
}

.btn-large {
  min-height: 48px;
  padding: 0 24px;
  font-size: 16px;
}

.btn-small {
  min-height: 30px;
  padding: 0 12px;
  font-size: 13px;
}

.btn-icon {
  width: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 50%;
  color: var(--text-2);
}

.btn-block {
  width: 100%;
}

@media (hover: hover) {
  .btn:hover {
    background: var(--fill-hover);
  }

  .btn-primary:hover {
    background: var(--accent-hover);
  }

  .btn-tinted:hover {
    background: var(--accent-ring);
  }

  .btn-danger:hover {
    background: color-mix(in srgb, var(--bad) 22%, transparent);
  }

  .btn-plain:hover {
    background: var(--accent-tint);
  }

  .btn-quiet-danger:hover {
    background: var(--bad-tint);
  }
}

/* 进行中：文字让位给一个小转圈，按钮宽度不变 */
.btn.is-busy {
  color: transparent;
  pointer-events: none;
}

.btn.is-busy::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid var(--spin);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

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

.field {
  display: grid;
  gap: 6px;
}

.field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}

.field-hint {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-3);
}

.field-error {
  font-size: 12px;
  line-height: 1.4;
  color: var(--bad);
}

.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 0;
  border-radius: var(--r-control);
  background: var(--fill);
  color: var(--text);
  font-size: 15px;
  box-shadow:
    inset 0 0 0 1px transparent,
    0 0 0 0 transparent;
  transition:
    background var(--dur-fast) ease,
    box-shadow var(--dur) var(--ease-out);
}

.input::placeholder {
  color: var(--placeholder);
}

.input:focus,
.input:focus-visible {
  outline: none;
  background: var(--surface);
  box-shadow:
    inset 0 0 0 1px var(--accent),
    0 0 0 4px var(--accent-ring);
}

.input[aria-invalid="true"] {
  box-shadow:
    inset 0 0 0 1px var(--bad),
    0 0 0 4px var(--bad-tint);
}

.input[type="number"] {
  appearance: textfield;
  font-variant-numeric: tabular-nums;
}

.input[type="number"]::-webkit-inner-spin-button,
.input[type="number"]::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
}

/* 粘贴区:粘进来的是一批行,所以标题栏里放行数与操作,框本身是"裸数据"的
   surface(和 .code 一个族)。焦点环挂在整块上,不在 textarea 上 —— 点标题栏
   也看得出这一块是活的。 */
.paste {
  border: 1px solid var(--hairline);
  border-radius: var(--r-control);
  background: var(--surface-sunken);
  overflow: hidden;
  transition:
    background var(--dur-fast) ease,
    border-color var(--dur-fast) ease,
    box-shadow var(--dur) var(--ease-out);
}

.paste:focus-within {
  border-color: transparent;
  background: var(--surface);
  box-shadow:
    inset 0 0 0 1px var(--accent),
    0 0 0 4px var(--accent-ring);
}

.paste-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  padding: 4px 8px 4px 14px;
  border-bottom: 1px solid var(--hairline);
}

.paste-label {
  color: var(--text-2);
  font-size: 12.5px;
}

.paste-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.paste-count {
  color: var(--text-3);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.paste-count[data-tone="bad"] {
  color: var(--bad);
}

/* 标题栏里的小动作(选文件) */
.paste-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 10px 0 8px;
  border-radius: var(--r-pill);
  color: var(--text-2);
  font-size: 12.5px;
  transition:
    background var(--dur-fast) ease,
    color var(--dur-fast) ease;
}

@media (hover: hover) {
  .paste-action:hover {
    background: var(--fill);
    color: var(--text);
  }
}

.paste-action:active {
  background: var(--fill-hover);
}

.paste-area {
  display: block;
  width: 100%;
  min-height: 132px;
  padding: 12px 14px 14px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  tab-size: 2;
  resize: vertical;
}

.paste-area:focus {
  outline: none;
}

.paste-area::placeholder {
  color: var(--placeholder);
}

/* 格式说明:五段各是什么,一眼扫过去,不是一段散文 */
.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--text-3);
  font-size: 12.5px;
}

.legend-label {
  margin-right: 2px;
}

.legend-item {
  padding: 3px 9px;
  border-radius: var(--r-pill);
  background: var(--fill-faint);
  color: var(--text-2);
  font-size: 12px;
}

.legend-item[data-optional="true"] {
  color: var(--text-3);
}

/* 控件下面那句说明（粘贴区、重绑、注册对话框共用一套） */
.paste-note,
.rebind-note {
  margin-top: 8px;
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.55;
}

/* 坏行:行号可以点,点了光标跳到那一行 */
.problems {
  display: grid;
  gap: 2px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.problem {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 12.5px;
  line-height: 1.5;
}

.problem-line {
  flex: none;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--bad-tint);
  color: var(--bad);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  transition: background var(--dur-fast) ease;
}

@media (hover: hover) {
  .problem-line:hover {
    background: var(--bad);
    color: var(--on-accent);
  }
}

.problem-reason {
  color: var(--text-2);
  min-width: 0;
}

.problem-more {
  color: var(--text-3);
  font-size: 12.5px;
}

/* 建阅读任务之前先看一眼:这五段各自被认成了什么(列错位一眼就看出来) */
.preview {
  border: 1px solid var(--hairline);
  border-radius: var(--r-control);
  overflow: hidden;
}

.preview-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--hairline);
  background: var(--fill-faint);
  color: var(--text-3);
  font-size: 12px;
}

.preview-scroll {
  max-height: 168px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.preview-row {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1.1fr) minmax(0, 1.1fr) 52px 60px;
  gap: 10px;
  align-items: baseline;
  padding: 7px 12px;
  font-size: 12.5px;
}

.preview-row + .preview-row {
  border-top: 1px solid var(--hairline);
}

.preview-link,
.preview-id {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-link {
  color: var(--text-2);
}

.preview-id {
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 12px;
}

.preview-type {
  color: var(--text-2);
}

.preview-count {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.preview-more {
  padding: 7px 12px;
  border-top: 1px solid var(--hairline);
  color: var(--text-3);
  font-size: 12px;
}

/* 导入结果的颜色：底色带色，字就更要靠向墨色，灰字压在色底上会发飘 */
.result[data-tone="bad"] .result-summary {
  color: var(--text);
}

.result[data-tone="bad"] .result-summary svg {
  color: var(--bad);
}

.result[data-tone="ok"] .result-summary svg {
  color: var(--ok);
}

/* 导入结果 */
.result {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--fill-faint);
}

.result[data-tone="ok"] {
  background: var(--ok-tint);
}

.result[data-tone="bad"] {
  background: var(--bad-tint);
}

.result-summary {
  display: flex;
  gap: 8px;
  align-items: baseline;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.5;
}

.result strong {
  color: var(--text);
  font-weight: 600;
}

/* 窄一点的单个数字输入(剩余有效期那种) */
.field-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.field-inline .field-label {
  flex: none;
}

.field-inline .input {
  width: 120px;
  flex: none;
}

.field-inline .field-hint {
  flex: 1 1 160px;
  min-width: 0;
}

@media (hover: hover) {
  .input:hover:not(:focus) {
    background: var(--fill-hover);
  }
}

/* 快捷取值的小药丸 */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  min-height: 28px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  background: var(--fill-faint);
  color: var(--text-2);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  transition:
    background var(--dur-fast) ease,
    color var(--dur-fast) ease,
    transform var(--dur-spring) var(--spring);
}

.chip:active {
  transform: scale(0.94);
}

.chip[aria-pressed="true"] {
  background: var(--accent-tint);
  color: var(--accent);
}

@media (hover: hover) {
  .chip:hover {
    background: var(--fill);
    color: var(--text);
  }
}

/* ---- 状态药丸 ---- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px 0 8px;
  border-radius: var(--r-pill);
  background: var(--mute-tint);
  color: var(--mute);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.pill[data-status="running"] {
  background: var(--accent-tint);
  color: var(--accent);
}

.pill[data-status="running"]::before {
  animation: pulse 1.6s var(--ease-in-out) infinite;
}

.pill[data-status="pending"] {
  background: var(--warn-tint);
  color: var(--warn);
}

.pill[data-status="completed"],
.pill[data-status="active"] {
  background: var(--ok-tint);
  color: var(--ok);
}

.pill[data-status="failed"],
.pill[data-status="abnormal"],
.pill[data-status="expired"] {
  background: var(--bad-tint);
  color: var(--bad);
}

/* 物料：可以领 / 已领走 / 已用掉；代理：在用 / 已停用 */
.pill[data-status="idle"],
.pill[data-status="enabled"] {
  background: var(--ok-tint);
  color: var(--ok);
}

.pill[data-status="leased"] {
  background: var(--accent-tint);
  color: var(--accent);
}

.pill[data-status="consumed"],
.pill[data-status="disabled"] {
  background: var(--mute-tint);
  color: var(--mute);
}

/* 暂停的两种（运行中暂停、排队中暂停）同一个颜色：它们都在等人点恢复 */
.pill[data-status="paused_running"],
.pill[data-status="paused_pending"] {
  background: var(--pause-tint);
  color: var(--pause);
}

/* 代理冷却中：还能用，但暂时不参与挑选 —— 和"停用"分开，别让操作员以为
   它被永久踢掉了。 */
.pill[data-status="cooling"] {
  background: var(--warn-tint);
  color: var(--warn);
}

@keyframes pulse {
  50% {
    opacity: 0.3;
    transform: scale(0.75);
  }
}

/* ---- 进度条 ---- */

.progress {
  position: relative;
  height: 6px;
  border-radius: 3px;
  background: var(--fill);
}

.progress-fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--progress-from), var(--progress-to));
  /* 用 clip-path 而不是宽度：不触发布局，右端的圆角也不会被压扁 */
  clip-path: inset(0 calc(100% - var(--p, 0%)) 0 0 round 3px);
  transition:
    clip-path 1s linear,
    background var(--dur) ease;
}

/* 表格里大多数行都是做完的：满格的绿条用淡一档的颜色，让进行中的那几条跳出来 */
.progress[data-status="completed"] > .progress-fill {
  background: var(--ok-soft);
}

.progress[data-status="failed"] > .progress-fill {
  background: var(--bad);
}

.progress[data-status="cancelled"] > .progress-fill {
  background: var(--text-3);
}

.progress[data-status="paused_running"] > .progress-fill,
.progress[data-status="paused_pending"] > .progress-fill {
  background: var(--pause);
}

.progress-large {
  height: 10px;
  border-radius: 5px;
}

/* ---- 列表 ---- */

.list {
  overflow: hidden;
}

.row {
  position: relative;
  display: grid;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  transition:
    background var(--dur-fast) ease,
    opacity var(--dur) ease,
    transform var(--dur-spring) var(--spring);
}

@starting-style {
  .row {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* 分隔线从文字起始处开始，不顶到左边 */
.row + .row::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 20px;
  height: 1px;
  background: var(--hairline);
}

/* 整行可点，行里的按钮浮在上面 */
.row-link::after {
  content: "";
  position: absolute;
  inset: 0;
}

.row-link:focus-visible {
  outline: none;
}

.row-link:focus-visible::after {
  outline: 3px solid var(--accent-ring);
  outline-offset: -3px;
  border-radius: 10px;
}

.row-action {
  position: relative;
  z-index: 1;
}

@media (hover: hover) {
  .row-interactive:hover {
    background: var(--fill-faint);
  }
}

/* ---- 分段控件 ---- */

.seg {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  padding: 2px;
  border-radius: 10px;
  background: var(--fill);
}

.seg-thumb {
  position: absolute;
  z-index: -1;
  top: 2px;
  bottom: 2px;
  left: 0;
  width: var(--w, 0);
  border-radius: 8px;
  background: light-dark(#fff, #636366);
  box-shadow: var(--shadow-thumb);
  transform: translateX(var(--x, 0));
}

.seg.is-ready > .seg-thumb {
  transition:
    transform var(--dur-spring) var(--spring),
    width var(--dur-spring) var(--spring);
}

.seg-item {
  min-height: 30px;
  padding: 0 14px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: color var(--dur) ease;
}

.seg-item[aria-checked="true"] {
  color: var(--text);
}

/* ---- 对话框 ---- */

.sheet {
  width: min(560px, calc(100vw - 32px));
  max-height: min(86dvh, 860px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: var(--r-sheet);
  overflow: hidden;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sheet);
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  transition:
    opacity var(--dur) ease,
    transform var(--dur-spring) var(--spring),
    overlay var(--dur) ease allow-discrete,
    display var(--dur) ease allow-discrete;
}

.sheet[open] {
  opacity: 1;
  transform: none;
}

@starting-style {
  .sheet[open] {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
  }
}

.sheet::backdrop {
  background: transparent;
  backdrop-filter: blur(0);
  transition:
    background var(--dur) ease,
    backdrop-filter var(--dur) ease,
    overlay var(--dur) ease allow-discrete,
    display var(--dur) ease allow-discrete;
}

.sheet[open]::backdrop {
  background: var(--scrim);
  backdrop-filter: blur(8px) saturate(140%);
}

@starting-style {
  .sheet[open]::backdrop {
    background: transparent;
    backdrop-filter: blur(0);
  }
}

.sheet-compact {
  width: min(400px, calc(100vw - 32px));
}

/* 批量表单：一行有地址、绑定的账号、状态、有效期、时间，720 挤得账号只剩前几位 */
.sheet-wide {
  width: min(880px, calc(100vw - 32px));
}

.sheet-body {
  display: flex;
  flex-direction: column;
  max-height: inherit;
  /* 没有这两条 min-height:0,内容再高也不收缩:overflow-y 形同虚设,
     多出来的部分连同底部按钮一起被 .sheet 的 overflow:hidden 裁掉。 */
  min-height: 0;
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 24px 0 28px;
}

.sheet-title {
  padding-top: 4px;
  font: 600 22px/1.25 var(--font-display);
  letter-spacing: -0.015em;
}

.sheet-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px 28px 28px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* 一块一块按自己的高度排，谁也不许被压扁（grid 的 auto 行会把
   overflow:hidden 的子项缩到 0 基线上，粘贴框因此少了一截）。 */
.sheet-content > * {
  flex: none;
}

.sheet-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 28px 24px;
  border-top: 1px solid var(--hairline);
}

/* 手机上从底部升起 */
@media (max-width: 640px) {
  .sheet {
    width: 100vw;
    max-width: none;
    max-height: 92dvh;
    margin: auto 0 0;
    border-radius: var(--r-sheet) var(--r-sheet) 0 0;
    transform: translateY(100%);
  }

  @starting-style {
    .sheet[open] {
      opacity: 1;
      transform: translateY(100%);
    }
  }

  .sheet-head {
    padding: 22px 16px 0 20px;
  }

  .sheet-content {
    padding: 18px 20px 24px;
  }

  .sheet-foot {
    padding: 14px 20px calc(18px + env(safe-area-inset-bottom));
  }

  .sheet-foot > .btn {
    flex: 1;
    min-height: 46px;
    font-size: 16px;
  }
}

/* 确认框里的说明文字 */
.prose {
  color: var(--text-2);
  line-height: 1.55;
}

.prose strong {
  color: var(--text);
  font-weight: 600;
}

/* 提示块 */
.note {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--fill-faint);
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.5;
}

.note-bad {
  background: var(--bad-tint);
  color: var(--bad);
}

.note-warn {
  background: var(--warn-tint);
  color: var(--warn);
}

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

.toasts {
  position: fixed;
  z-index: 60;
  top: calc(72px + env(safe-area-inset-top));
  left: 50%;
  display: grid;
  justify-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 32px);
  pointer-events: none;
  transform: translateX(-50%);
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px 10px 12px;
  border-radius: var(--r-pill);
  background: var(--glass-strong);
  backdrop-filter: blur(24px) saturate(180%);
  box-shadow:
    inset 0 0.5px 0 var(--glass-rim),
    var(--shadow-float);
  font-size: 14px;
  font-weight: 500;
  opacity: 1;
  transform: none;
  transition:
    opacity var(--dur) ease,
    transform var(--dur-spring-soft) var(--spring-soft);
}

@starting-style {
  .toast {
    opacity: 0;
    transform: translateY(-14px) scale(0.94);
  }
}

.toast.is-leaving {
  opacity: 0;
  transform: translateY(-8px) scale(0.96);
}

.toast-icon {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--ok);
  color: var(--surface);
}

.toast[data-kind="error"] > .toast-icon {
  background: var(--bad);
}

.toast[data-kind="info"] > .toast-icon {
  background: var(--text-3);
}

/* ---- 浮层菜单 ---- */

.menu {
  position: fixed;
  inset: auto;
  margin: 0;
  min-width: 200px;
  padding: 6px;
  border: 0;
  border-radius: 16px;
  background: var(--glass-strong);
  backdrop-filter: blur(28px) saturate(180%);
  color: var(--text);
  box-shadow:
    inset 0 0.5px 0 var(--glass-rim),
    var(--shadow-float);
  opacity: 0;
  transform: scale(0.94);
  transform-origin: top right;
  transition:
    opacity var(--dur-fast) ease,
    transform var(--dur-spring) var(--spring),
    overlay var(--dur-fast) ease allow-discrete,
    display var(--dur-fast) ease allow-discrete;
}

.menu:popover-open {
  opacity: 1;
  transform: none;
}

@starting-style {
  .menu:popover-open {
    opacity: 0;
    transform: scale(0.94);
  }
}

.menu-label {
  padding: 8px 12px 6px;
  color: var(--text-3);
  font-size: 12px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 14px;
  text-align: left;
  transition: background var(--dur-fast) ease;
}

.menu-item:focus-visible {
  outline: none;
  background: var(--fill);
}

.menu-item > svg {
  color: var(--text-2);
}

.menu-item-label {
  flex: 1;
}

/* 右边那个小数字："能处理其中几条" */
.menu-item-hint {
  color: var(--text-3);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.menu-item-danger,
.menu-item-danger > svg {
  color: var(--bad);
}

.menu-item:disabled {
  opacity: 0.4;
  cursor: default;
}

.menu-sep {
  height: 1px;
  margin: 5px 10px;
  background: var(--hairline);
}

@media (hover: hover) {
  .menu-item:hover:not(:disabled) {
    background: var(--fill);
  }
}

/* ---- 空状态与占位 ---- */

.empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 44px 24px;
  color: var(--text-2);
  text-align: center;
}

.empty-title {
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.empty-text {
  max-width: 44ch;
  font-size: 14px;
  line-height: 1.5;
}

.empty-action {
  margin-top: 12px;
}

.skeleton {
  border-radius: 6px;
  background: linear-gradient(
    100deg,
    var(--fill-faint) 30%,
    var(--fill) 50%,
    var(--fill-faint) 70%
  );
  background-size: 300% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}

@keyframes shimmer {
  from {
    background-position: 100% 0;
  }

  to {
    background-position: 0 0;
  }
}

/* ---- 连续曲率的圆角 ----
   普通圆角是一段圆弧接一条直线，接点处曲率突变；超椭圆的过渡是连续的，
   大块的面看起来更"软"。同样的观感需要更大的半径。不支持的浏览器保持普通圆角。 */

@supports (corner-shape: squircle) {
  .card,
  .table-card,
  .run-card,
  .sheet,
  .login-mark,
  .brand-mark,
  .input,
  .code,
  .note,
  .menu,
  .tip {
    corner-shape: squircle;
  }

  :root {
    --r-control: 18px;
    --r-card: 34px;
    --r-sheet: 44px;
  }

  .login-mark {
    border-radius: 30px;
  }

  .brand-mark {
    border-radius: 12px;
  }

  .code,
  .note {
    border-radius: 22px;
  }

  .menu {
    border-radius: 26px;
  }

  .tip {
    border-radius: 18px;
  }
}

/* ---- 重新绑定快过期的出口 ---- */

.head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}


.rebind-box {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--fill-faint);
}

.rebind-summary {
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.5;
}

.rebind-note[data-level="bad"] {
  color: var(--bad);
}

/* ---- 代理测速 / 导出的对话框 ---- */

.speed-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0 24px;
}

.speed-field {
  margin-top: 4px;
}

/* 表头上的"同时测 5 个"（设置里改），和"已选几个"之间一条竖线隔开 */
.speed-concurrency {
  padding-right: 12px;
  border-right: 1px solid var(--hairline);
  color: var(--text-2);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* 范围的分段控件不撑满；手机上放不下就横着滑 */
.speed-field .seg {
  justify-self: start;
  max-width: 100%;
  overflow-x: auto;
}

/* 测速的单子：一行一个代理，最后一格是结果（在测的那一行转圈）。几百上千个也是一张，
   单子自己滚 */
.speed-box {
  margin-top: 16px;
}

.speed-items {
  max-height: min(56vh, 560px);
  overflow-y: auto;
}

.bulk-item.speed-item {
  grid-template-columns: 18px minmax(0, 1fr) auto minmax(9em, 17em);
}

.speed-head-end {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

/* 测的时候表头底下一条细进度 */
.progress.speed-progress {
  height: 3px;
  border-radius: 0;
}

.speed-result {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.speed-result[data-tone="muted"] {
  color: var(--text-3);
}

.speed-result[data-tone="busy"] {
  color: var(--accent);
}

.speed-result[data-tone="warn"] {
  color: var(--warn);
}

.speed-result[data-tone="bad"] {
  color: var(--bad);
}

.spinner {
  flex: none;
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 2.4s;
  }
}

.speed-badge {
  flex: none;
  padding: 0 6px;
  border-radius: 4px;
  background: var(--ok-tint);
  color: var(--ok);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 18px;
}

/* 手机：结果挪到地址下面一行 */
@media (max-width: 640px) {
  .bulk-item.speed-item {
    grid-template-columns: 18px minmax(0, 1fr) auto;
  }

  .speed-item > .speed-result {
    grid-row: 2;
    grid-column: 2 / -1;
  }

  .speed-head-end {
    flex-wrap: wrap;
    justify-content: flex-end;
    row-gap: 0;
    padding: 4px 0;
  }
}

/* ---- 注册 ---- */

.run-card {
  display: grid;
  gap: 14px;
  padding: 22px 24px;
  border-radius: var(--r-card);
  background: var(--surface);
  /* 和其它卡片一样用阴影收边，不另画一圈描边 */
  box-shadow: var(--shadow-card);
}

.run-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 20px;
}

.run-title {
  font: 600 20px/1.3 var(--font-display);
  letter-spacing: -0.01em;
}

.run-note {
  margin-top: 6px;
  max-width: 62ch;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.5;
}

.run-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.run-progress {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.run-count {
  color: var(--text-2);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* 表格格子里的两行：上面一行是主要的（.cell-main），下面一行小字（.cell-sub）——
   Worker 的账号 id 下面是身份，代理的出口下面是认证、最近使用下面是导入时间。
   两行都只占一行，放不下省略，全文在 title 里。 */
.cell-main {
  display: flex;
  align-items: center;
  min-width: 0;
}

/* 主行里会被省略的那段文字（后面可能还跟着复制按钮之类，那个不省略） */
.cell-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-sub {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--text-3);
  font-size: 12px;
  font-family: var(--font-mono);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-sub-plain {
  font-family: inherit;
}

/* Worker 列表里 id 下面那行：身份 + 新老标记。
   带底色的是"新号"（注册时服务端说这个身份原来没有账号，clients.user_exists=0）
   —— 它是绝大多数；"老号"是少数，安静着，扫过去一眼看出哪些是新号。 */
.sub-who {
  font-family: var(--font-mono);
}

.sub-mark {
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--accent-tint);
  color: var(--accent);
  font-family: var(--font-sans);
  font-size: 11px;
}

.sub-mark[data-old="1"] {
  background: var(--mute-tint);
  color: var(--text-3);
}

/* 观察区的号：只做测试任务。和任务上的"测试"同一个颜色；"优先"用橙色 */
.sub-pool,
.tag-test,
.tag-priority {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--observe-tint);
  color: var(--observe);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.sub-pool {
  margin-left: 6px;
}

.tag-test,
.tag-priority {
  margin-left: 6px;
  vertical-align: 1px;
}

.tag-priority {
  background: var(--warn-tint);
  color: var(--warn);
}

/* 新建任务：用哪些号 + 优先，一行 */
.create-opts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

/* ---- 批量确认框：范围 + 按状态拆开的数量 ---- */

.bulk-scope {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--fill-faint);
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.5;
}

.bulk-scope-label {
  flex: none;
  color: var(--text-3);
  font-size: 12px;
}

.bulk-group + .bulk-group,
.bulk-group + .bulk-note {
  margin-top: 12px;
}

.bulk-title {
  margin-bottom: 6px;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
}

.bulk-list {
  display: grid;
  gap: 6px;
}

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

.bulk-count {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* 会跳过的那一组退后一档，眼睛先落在"会被处理"的那一组上 */
.bulk-row[data-tone="skip"] {
  opacity: 0.6;
}

.bulk-row[data-tone="skip"] .bulk-count {
  font-weight: 500;
}

.bulk-note {
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.55;
}

.bulk-note-bad {
  color: var(--bad);
  font-weight: 500;
}

/* 二次校验框上方要照着打的那串数字 */
.confirm-code {
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--fill);
  color: var(--text);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ---- 批量表单：先筛、再勾 ---- */

.bulk-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
}

.bulk-filters > .search {
  flex: 1 1 180px;
  max-width: none;
}

/* 状态药丸上带着数量：选了哪几种、每种有多少，一眼看全 */
.chip-count {
  margin-left: 6px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.chip[aria-pressed="true"] > .chip-count {
  color: inherit;
  opacity: 0.7;
}

.bulk-box {
  border: 1px solid var(--hairline);
  border-radius: var(--r-control);
  overflow: clip;
  transition: opacity var(--dur) ease;
}

/* 换条件重新取的时候：上一份淡一点留着，不闪白 */
.bulk-box.is-stale {
  opacity: 0.55;
}

/* 单子的表头：全选 + 已选几条。滚动的时候粘在顶上 */
.bulk-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 0 14px 0 12px;
  border-bottom: 1px solid var(--hairline);
  background: var(--surface);
}

.bulk-all {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}

.bulk-sum {
  color: var(--text-2);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.bulk-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto 96px 92px;
  align-items: center;
  gap: 16px;
  min-height: 48px;
  padding: 6px 14px 6px 12px;
  cursor: pointer;
  transition:
    background var(--dur-fast) ease,
    opacity var(--dur-fast) ease;
}

.bulk-item + .bulk-item {
  border-top: 1px solid var(--hairline);
}

/* 复选框不接指针：整行可点，点一下只切一次（见 bulk-form.js）；键盘照常落在它上面 */
.bulk-item > .check {
  pointer-events: none;
}

/* 没勾上的退后一档：一眼看出哪些会被处理 */
.bulk-item[data-off="true"] {
  opacity: 0.45;
}

@media (hover: hover) {
  .bulk-item:hover {
    background: var(--fill-faint);
  }
}

.bulk-item-main {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

/* 主列里两段：id（任务 id、Worker id、代理的地址）和后面那段小字（参数、账号、原因）。
   地址很长的时候让它先省略，后面那段（绑定的账号）尽量完整 */
.bulk-item-id {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bulk-item-params {
  flex: 0 1 auto;
  min-width: 4em;
  overflow: hidden;
  color: var(--text-3);
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bulk-item-count,
.bulk-item-time {
  color: var(--text-2);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.bulk-empty {
  padding: 28px 16px;
  color: var(--text-2);
  font-size: 13.5px;
  text-align: center;
}

/* 手机：一行放不下五列，进度和时间挪到 id 下面一行 */
@media (max-width: 640px) {
  .bulk-item {
    grid-template-columns: 18px minmax(0, 1fr) auto;
    row-gap: 2px;
    padding: 8px 12px;
  }

  .bulk-item-count,
  .bulk-item-time {
    grid-row: 2;
    text-align: left;
  }

  .bulk-item-count {
    grid-column: 2;
  }

  .bulk-item-time {
    grid-column: 3;
    text-align: right;
  }

  .bulk-filters .seg-item {
    padding: 0 10px;
  }
}

/* ---- 下拉选择（ui/picker.js）：替代原生 <select> ---- */

.picker {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 10px 0 12px;
  border-radius: 10px;
  background: var(--fill);
  color: var(--text);
  font-size: 14px;
  white-space: nowrap;
  transition:
    background var(--dur-fast) ease,
    transform var(--dur-spring) var(--spring);
}

.picker > svg {
  color: var(--text-2);
}

.picker-chevron {
  display: grid;
  margin-left: 1px;
  color: var(--text-3);
  transition: transform var(--dur-spring) var(--spring);
}

/* 打开的时候箭头翻过来，按钮压一点底色：看得出"这个菜单是它的" */
.picker[aria-expanded="true"] {
  background: var(--fill-hover);
}

.picker[aria-expanded="true"] .picker-chevron {
  transform: rotate(180deg);
}

.picker:active {
  transform: scale(0.97);
}

@media (hover: hover) {
  .picker:hover {
    background: var(--fill-hover);
  }
}

/* 单选菜单里打勾那一格：没勾的也占着位置，字才对得齐 */
.menu-check {
  display: grid;
  place-items: center;
  width: 16px;
  margin-right: -2px;
  color: var(--accent);
}

.menu-item[aria-checked="true"] {
  font-weight: 500;
}

/* 不止一组药丸（代理：绑定、状态）：每组一行，行首写着是哪一组 */
.bulk-groups {
  display: grid;
  gap: 10px;
}

.chips-label {
  align-self: center;
  min-width: 2.6em;
  margin-right: 4px;
  color: var(--text-3);
  font-size: 12.5px;
}

/* 单子上方的一句提示（"另外 3 个没有代理，恢复不了"），贴着单子 */
.bulk-hint {
  margin-bottom: -8px;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.5;
}

/* 随勾选变的警告：删的里面有绑着账号的、置为异常之后一个正常的都不剩 */
.bulk-warn {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bad-tint);
  color: var(--bad);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
}

/* 批量表单里的翻页：单子底下一条，上一页 / 第几页 / 下一页 */
.bulk-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px;
  border-top: 1px solid var(--hairline);
}

.bulk-page-text {
  min-width: 8em;
  color: var(--text-2);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

/* ---- 标记：一个号一个号地读同一篇，人看着点正常 / 异常（views/task-mark.js） ---- */

.mark-setup {
  display: grid;
  gap: 12px;
}

.mark-setup .seg {
  justify-self: start;
}

.mark-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.mark-progress-text {
  font: 700 24px / 1.1 var(--font-display);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.mark-tally {
  color: var(--text-2);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.mark-card {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  padding: 16px;
  border-radius: 16px;
  background: var(--fill-faint);
}

.mark-who {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.mark-who .sub-mark,
.mark-who .sub-pool {
  margin-left: 0;
}

.mark-id {
  font-size: 17px;
  font-weight: 600;
}

.mark-red {
  color: var(--text-2);
}

.mark-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  color: var(--text-2);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.mark-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mark-read .mark-state {
  font-size: 14px;
}

.mark-state[data-tone="ok"] {
  color: var(--ok);
}

.mark-state[data-tone="bad"] {
  color: var(--bad);
}

.mark-state[data-tone="muted"] {
  color: var(--text-3);
}

.mark-recent {
  display: grid;
  max-height: 260px;
  margin-top: 14px;
  overflow: auto;
}

.mark-recent:empty {
  display: none;
}

.mark-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 40px minmax(0, 1.4fr);
  gap: 10px;
  align-items: center;
  padding: 7px 4px;
  border-top: 1px solid var(--hairline);
  font-size: 13px;
}

.mark-tag[data-mark="ok"] {
  color: var(--ok);
}

.mark-tag[data-mark="bad"] {
  color: var(--bad);
}

.mark-tag[data-mark="skip"] {
  color: var(--text-3);
}

.mark-done {
  display: grid;
  gap: 8px;
  padding: 20px 0 8px;
  text-align: center;
}

.mark-done-title {
  font: 700 24px / 1.2 var(--font-display);
}

.mark-done-tally {
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
