:root {
  --bg: #0e1014;
  --panel: #161a21;
  --panel-2: #1c212a;
  --line: #242b36;
  --text: #e7eaf0;
  --muted: #8a93a6;
  --dim: #5d6577;
  --accent: #4c8dff;
  --accent-soft: #1b2c4a;
  --ok: #35c07f;
  --ok-soft: #12291f;
  --warn: #e0a33c;
  --warn-soft: #2c2415;
  --danger: #f0616d;
  --danger-soft: #2e181b;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.6 -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

code,
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
}

/* ---------- 顶栏 ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 56px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 500;
  font-size: 15px;
}

.brand .dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent);
}

.spacer {
  flex: 1;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
  background: var(--panel-2);
}

.chip b {
  color: var(--text);
  font-weight: 500;
}

/* ---------- 布局 ---------- */

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

@media (min-width: 900px) {
  .grid.split {
    grid-template-columns: 400px 1fr;
    align-items: start;
  }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.hint {
  color: var(--muted);
  font-size: 12.5px;
  margin: 0 0 10px;
}

hr.sep {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 16px 0;
}

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

textarea,
input[type='text'],
input[type='password'],
input[type='number'],
select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 11px 12px;
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--accent);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) calc(50% + 1px), calc(100% - 12px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}

select option {
  background: var(--panel);
  color: var(--text);
}

textarea {
  min-height: 112px;
  resize: vertical;
  line-height: 1.55;
}

label.field {
  display: block;
  margin-bottom: 12px;
}

label.field > span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

button {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 10px;
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

button:hover:not(:disabled) {
  border-color: #3a4454;
  background: #232936;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.primary:hover:not(:disabled) {
  background: #3f7ce8;
  border-color: #3f7ce8;
}

button.ghost {
  background: transparent;
}

button.sm {
  padding: 5px 11px;
  font-size: 12.5px;
  border-radius: 8px;
}

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

.row.wrap-row {
  flex-wrap: wrap;
}

/* ---------- 识别结果 ---------- */

.parsed {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  font-size: 12.5px;
}

.parsed .line {
  display: flex;
  gap: 10px;
  padding: 7px 11px;
  border-bottom: 1px solid var(--line);
}

.parsed .line:last-child {
  border-bottom: 0;
}

.parsed .k {
  color: var(--muted);
  width: 58px;
  flex: none;
}

.parsed .v {
  color: var(--text);
  word-break: break-all;
}

.parsed.ok {
  border-color: #24402f;
}

.parsed.bad {
  border-color: #43262a;
}

/* ---------- 任务卡 ---------- */

.task {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  margin-bottom: 12px;
  overflow: hidden;
}

.task .head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

.task .title {
  font-weight: 500;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task .sub {
  color: var(--dim);
  font-size: 12px;
  flex: none;
}

.badge {
  flex: none;
  font-size: 11.5px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--panel-2);
}

.badge.run {
  color: #8ab4ff;
  background: var(--accent-soft);
  border-color: #24406b;
}

.badge.ok {
  color: var(--ok);
  background: var(--ok-soft);
  border-color: #1d4536;
}

.badge.err {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #4a2a2e;
}

.badge.warn {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: #4a3b1e;
}

.task .body {
  padding: 13px 16px;
}

.bar {
  height: 5px;
  border-radius: 999px;
  background: #222833;
  overflow: hidden;
  margin: 9px 0 8px;
}

.bar > i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.bar.done > i {
  background: var(--ok);
}

.bar.err > i {
  background: var(--danger);
}

.meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.err-msg {
  color: var(--danger);
  font-size: 12.5px;
  margin-top: 8px;
}

/* 部分条目转存失败之类的提示：不影响任务成败，用次要色 */
.notice-msg {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 8px;
}

/* ---------- 批次表 ---------- */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  margin-top: 10px;
}

th,
td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--muted);
  font-weight: 400;
  font-size: 11.5px;
}

tr:last-child td {
  border-bottom: 0;
}

td.num {
  text-align: right;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------- 空态 ---------- */

.empty {
  text-align: center;
  padding: 44px 20px;
  color: var(--dim);
  font-size: 13px;
}

.empty .big {
  font-size: 26px;
  color: #2c3444;
  margin-bottom: 10px;
}

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

.login-wrap {
  min-height: calc(100vh - 56px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px;
}

.login h1 {
  font-size: 17px;
  font-weight: 500;
  margin: 0 0 6px;
}

.login p {
  color: var(--muted);
  font-size: 12.5px;
  margin: 0 0 20px;
}

.login input {
  text-align: center;
  letter-spacing: 1.5px;
  font-family: ui-monospace, monospace;
  font-size: 15px;
  padding: 13px;
  text-transform: uppercase;
}

.msg {
  font-size: 12.5px;
  margin-top: 12px;
  min-height: 18px;
}

.msg.err {
  color: var(--danger);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 50;
}

.toast.show {
  opacity: 1;
}

.foot {
  text-align: center;
  color: var(--dim);
  font-size: 12px;
  padding: 26px 0 0;
}

/* ---------- 百度账号接入 ---------- */

.setup-card {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 10px;
  padding: 14px 16px;
}

.setup-card.warn {
  border-color: rgba(224, 163, 60, 0.45);
  background: var(--warn-soft);
}

.setup-head {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.setup-steps {
  margin: 0 0 10px;
  padding-left: 20px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.9;
}

.setup-steps code {
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 6px;
  border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11.5px;
  color: var(--text);
}

.cmd {
  margin: 0;
  padding: 10px 12px;
  background: #0b0e13;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #b8c4d8;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  overflow-x: auto;
  white-space: pre;
}

/* 等待授权：一条会呼吸的提示条，不挡操作 */
.wait-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 9px 12px;
  border: 1px solid var(--accent-soft);
  background: var(--accent-soft);
  border-radius: 9px;
  font-size: 12.5px;
  color: var(--text);
}

.wait-strip[hidden] {
  display: none;
}

.dot-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.1s ease-in-out infinite;
  flex: 0 0 auto;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.35;
    transform: scale(0.75);
  }
}

/* 刚加进来的通道闪一下 */
tr.flash > td {
  animation: flashRow 2.2s ease-out;
}

@keyframes flashRow {
  0% {
    background: rgba(76, 141, 255, 0.22);
  }
  100% {
    background: transparent;
  }
}

.manual {
  margin-top: 14px;
  border-top: 1px dashed var(--line);
  padding-top: 12px;
}

.manual > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12.5px;
  list-style: none;
}

.manual > summary::-webkit-details-marker {
  display: none;
}

.manual > summary::before {
  content: '＋ ';
  color: var(--dim);
}

/* ---------- oob 接入表单 ---------- */
/* 两列输入 + 右侧按钮。用 grid 而不是 flex：flex 里 label 的 flex-basis
   和 input 的 100% 宽度会互相打架，实测过一个框被挤成 170px、按钮跑出屏幕 */
.oob-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
  margin-top: 10px;
}

.oob-form label.field {
  margin-bottom: 0;
  min-width: 0;
}

.oob-form input {
  width: 100%;
  box-sizing: border-box;
}

.oob-form button {
  margin-bottom: 1px;
}

@media (max-width: 900px) {
  .oob-form {
    grid-template-columns: 1fr;
  }
}

/* 下载器入口：批次表格下面的一块，别再让用户一个个点「下载」 */
.downloader-box {
  margin-top: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.dl-text {
  flex: 1;
  min-width: 0;
}

.dl-title {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dl-tag {
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 1px 8px;
}

.dl-desc {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}

@media (max-width: 640px) {
  .downloader-box {
    flex-direction: column;
    align-items: stretch;
  }
}
