/* ==========================================================================
   视频复刻控制台 —— 样式
   单文件、无预处理器。变量集中在 :root，深浅色跟系统。
   ========================================================================== */

:root {
  --bg: #0e1014;
  --bg-soft: #14171d;
  --panel: #181c23;
  --panel-2: #1f242c;
  --line: #2a3038;
  --line-strong: #3a424d;

  --fg: #e6e9ef;
  --fg-dim: #98a2b3;
  --fg-faint: #6b7482;

  --accent: #7c6cff;
  --accent-soft: rgba(124, 108, 255, 0.14);
  --accent-fg: #ffffff;

  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.14);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --info: #60a5fa;
  --info-soft: rgba(96, 165, 250, 0.14);

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.32);

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Source Han Sans SC", sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7f9;
    --bg-soft: #eceef2;
    --panel: #ffffff;
    --panel-2: #f3f5f8;
    --line: #dfe3e9;
    --line-strong: #c6ccd6;

    --fg: #1b1f26;
    --fg-dim: #5a6472;
    --fg-faint: #8a939f;

    --accent: #5b4bd6;
    --accent-soft: rgba(91, 75, 214, 0.1);
    --accent-fg: #ffffff;

    --ok: #0f9d63;
    --ok-soft: rgba(15, 157, 99, 0.12);
    --warn: #b45309;
    --warn-soft: rgba(180, 83, 9, 0.12);
    --danger: #d92d20;
    --danger-soft: rgba(217, 45, 32, 0.1);
    --info: #1d4ed8;
    --info-soft: rgba(29, 78, 216, 0.1);

    --shadow: 0 8px 24px rgba(16, 24, 40, 0.1);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.boot {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--fg-dim);
}

/* ---------- 骨架：侧栏 + 主区 ---------- */

.shell {
  display: grid;
  grid-template-columns: 208px 1fr;
  height: 100%;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 10px;
  background: var(--bg-soft);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 8px 14px;
  font-weight: 650;
  letter-spacing: 0.2px;
}
.brand img { width: 22px; height: 22px; border-radius: 5px; }
.brand small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: var(--fg-faint);
  letter-spacing: 0;
}

.nav-group {
  margin: 12px 8px 4px;
  font-size: 11px;
  color: var(--fg-faint);
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--fg-dim);
  font-size: 13.5px;
  cursor: pointer;
  user-select: none;
}
.nav-item:hover { background: var(--panel-2); color: var(--fg); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 550; }
.nav-item .ico { width: 16px; text-align: center; opacity: 0.9; }

.sidebar-foot {
  margin-top: auto;
  padding: 10px 8px 4px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--fg-faint);
  line-height: 1.7;
}
.sidebar-foot b { color: var(--fg-dim); font-weight: 550; }

.main {
  overflow-y: auto;
  padding: 22px 26px 60px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
}
.page-head h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 620;
  letter-spacing: 0.1px;
}
.page-head .sub {
  margin: 3px 0 0;
  color: var(--fg-dim);
  font-size: 12.5px;
}
.page-head .spacer { flex: 1; }

/* ---------- 卡片 / 面板 ---------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card + .card { margin-top: 14px; }

.card-title {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-dim);
  letter-spacing: 0.3px;
}

.grid-cards {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat .k { font-size: 12px; color: var(--fg-faint); }
.stat .v {
  margin-top: 5px;
  font-size: 21px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.2px;
}
.stat .v small { font-size: 12px; color: var(--fg-faint); font-weight: 400; margin-left: 3px; }

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

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
}
button:hover, .btn:hover { background: var(--line); text-decoration: none; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible, .btn:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
  font-weight: 550;
}
button.primary:hover { filter: brightness(1.08); }

button.danger { color: var(--danger); border-color: var(--line-strong); }
button.danger:hover { background: var(--danger-soft); border-color: var(--danger); }

button.ghost { background: transparent; border-color: transparent; color: var(--fg-dim); }
button.ghost:hover { background: var(--panel-2); color: var(--fg); }

button.sm { padding: 4px 9px; font-size: 12px; }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

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

.field { margin-bottom: 13px; }
.field > label {
  display: block;
  margin-bottom: 5px;
  font-size: 12.5px;
  color: var(--fg-dim);
}
.field .hint { margin-top: 4px; font-size: 11.5px; color: var(--fg-faint); }
.field .err { margin-top: 4px; font-size: 12px; color: var(--danger); }

input[type="text"], input[type="password"], input[type="number"], input[type="search"],
select, textarea {
  width: 100%;
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--fg);
  font: inherit;
  font-size: 13px;
}
textarea { resize: vertical; min-height: 84px; font-family: var(--mono); font-size: 12.5px; }
input::placeholder, textarea::placeholder { color: var(--fg-faint); }
input:disabled, textarea:disabled, select:disabled { opacity: 0.55; }

.check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  font-size: 13px;
  line-height: 1.5;
}
.check input { margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.check:hover { border-color: var(--line-strong); }
.check.on { border-color: var(--accent); background: var(--accent-soft); }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 680px) { .row2 { grid-template-columns: 1fr; } }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}
.filters select, .filters input { width: auto; min-width: 130px; }

/* ---------- 表格 ---------- */

.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  /* 横向可滚，不要 hidden：宽表（变量表的影响位置常有三段引用）在窄窗口下
     会被 hidden 直接切掉右半截，而右边恰好是最需要看的内容。纵向仍然裁切，
     圆角才不会被行背景铺出直角。 */
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--panel);
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  padding: 9px 14px;
  background: var(--panel-2);
  color: var(--fg-faint);
  font-weight: 550;
  font-size: 11.5px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--panel-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* 首列给一个下限：短内容（如租户 id `t_root`）会让浏览器把这一列压到很窄，
   而剩下的空间被"状态/套餐"这类短列吃走，整张表看起来东倒西歪。 */
.table-wrap tbody td:first-child { min-width: 140px; }
.mono { font-family: var(--mono); font-size: 12px; }
.nowrap { white-space: nowrap; }
.dim { color: var(--fg-dim); }
.faint { color: var(--fg-faint); }

/* ---------- 徽章 ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 550;
  line-height: 1.6;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge.neutral { background: var(--panel-2); color: var(--fg-dim); border-color: var(--line); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- 空态 / 加载 ---------- */

.empty {
  padding: 42px 20px;
  text-align: center;
  color: var(--fg-faint);
  font-size: 13px;
}
.empty b { display: block; color: var(--fg-dim); font-size: 14px; margin-bottom: 5px; font-weight: 550; }

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-row { padding: 30px; text-align: center; color: var(--fg-faint); font-size: 13px; }

/* ---------- 步骤条（任务 8 步） ---------- */

.steps {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  margin: 4px 0 2px;
}
@media (max-width: 900px) { .steps { grid-template-columns: repeat(4, 1fr); } }

.step {
  position: relative;
  padding: 9px 8px 8px;
  border: 1px solid var(--line);
  border-top: 2px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 11.5px;
  text-align: center;
}
.step .n { display: block; font-size: 10px; color: var(--fg-faint); margin-bottom: 2px; }
.step .lbl { display: block; color: var(--fg-dim); font-weight: 550; }
.step .st { display: block; margin-top: 3px; font-size: 10.5px; color: var(--fg-faint); }

.step.pending { opacity: 0.62; }
.step.running {
  border-top-color: var(--info);
  background: var(--info-soft);
  opacity: 1;
}
.step.running .st { color: var(--info); }
.step.done { border-top-color: var(--ok); background: var(--ok-soft); opacity: 1; }
.step.done .st { color: var(--ok); }
.step.failed { border-top-color: var(--danger); background: var(--danger-soft); opacity: 1; }
.step.failed .st { color: var(--danger); }
.step.skipped { border-top-color: var(--warn); opacity: 1; }
.step.skipped .st { color: var(--warn); }
.step.current { outline: 1px solid var(--accent); outline-offset: 1px; }

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

.bar {
  height: 3px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
  margin-top: 4px;
}
.bar > i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.25s ease;
}
.bar.over > i { background: var(--danger); }

/* ---------- 提示条 ---------- */

.notice {
  display: flex;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 14px;
}
.notice .tag {
  flex: none;
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding-top: 1px;
}
.notice.warn { border-color: var(--warn); background: var(--warn-soft); }
.notice.warn .tag { color: var(--warn); }
.notice.danger { border-color: var(--danger); background: var(--danger-soft); }
.notice.danger .tag { color: var(--danger); }
.notice.ok { border-color: var(--ok); background: var(--ok-soft); }
.notice.ok .tag { color: var(--ok); }
.notice.info { border-color: var(--info); background: var(--info-soft); }
.notice.info .tag { color: var(--info); }

/* ---------- 键值列表 ---------- */

.kv { display: grid; grid-template-columns: 132px 1fr; gap: 7px 14px; font-size: 13px; }
.kv dt { color: var(--fg-faint); font-size: 12.5px; }
.kv dd { margin: 0; word-break: break-all; }

/* ---------- 代码块 ---------- */

pre.code {
  margin: 0;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: auto;
  max-height: 460px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--fg-dim);
  tab-size: 2;
}
pre.code.tall { max-height: 70vh; }

/* ---------- 抽屉 / 模态 ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 46px 18px 24px;
  overflow-y: auto;
  z-index: 50;
}
.modal {
  width: 100%;
  max-width: 620px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 20px 22px;
}
.modal.wide { max-width: 820px; }
.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.modal-head h2 { margin: 0; font-size: 16px; font-weight: 620; }
.modal-head .spacer { flex: 1; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

/* ---------- toast ---------- */

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 80;
  max-width: min(420px, calc(100vw - 36px));
}
.toast {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--panel);
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.5;
  animation: toast-in 0.16s ease-out;
  word-break: break-word;
}
.toast.ok { border-color: var(--ok); }
.toast.err { border-color: var(--danger); }
.toast.warn { border-color: var(--warn); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 登录页 ---------- */

.login-wrap {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-box {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 26px 26px 22px;
}
.login-box .brand { padding: 0 0 18px; }
.login-box h1 { margin: 0 0 6px; font-size: 17px; font-weight: 620; }
.login-box p.lead { margin: 0 0 18px; color: var(--fg-dim); font-size: 12.5px; line-height: 1.6; }

/* ---------- 时间轴（词级） ---------- */

.words {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 340px;
  overflow-y: auto;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.word {
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--panel-2);
  font-size: 12px;
  color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
}
.word b { color: var(--fg); font-weight: 550; }
.word i { font-style: normal; color: var(--fg-faint); font-size: 10.5px; margin-left: 4px; }

/* ---------- 工具 ---------- */

.flex { display: flex; align-items: center; gap: 9px; }
.flex.wrap { flex-wrap: wrap; }
.gap-sm { gap: 6px; }
.mt { margin-top: 14px; }
.mt-sm { margin-top: 8px; }
.mb { margin-bottom: 14px; }
.right { margin-left: auto; }
.trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34ch; }
.hidden { display: none !important; }

/* ---------- 拆解复核工作台 ---------- */

.sheet-slot { min-height: 120px; }
.sheet-img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--line);
}

/* 批次进度条：完成 / 失败 / 在跑 三段并排。
   普通 .bar 是 3px 的单色条（任务页的步骤进度），批次要在一行里看出三种
   状态，所以单独一档：更高、分段、每段自己上色。 */
.bar.tall {
  display: flex;
  gap: 1px;
  height: 8px;
  border-radius: 4px;
  margin-top: 0;
}
.bar.tall > i {
  border-radius: 0;
  background: var(--line);
}
.bar.tall > i.ok { background: var(--ok); }
.bar.tall > i.danger { background: var(--danger); }
.bar.tall > i.warn { background: var(--warn); }
.bar.tall > i:first-child { border-radius: 4px 0 0 4px; }
.bar.tall > i:last-child { border-radius: 0 4px 4px 0; }
