:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --text: #1d2433;
  --muted: #6b7484;
  --line: #e3e6ec;
  --accent: #2f6feb;
  --accent-dark: #1f57c3;
  --danger: #d64545;
  --ok: #1f9d63;
  --warn: #c77700;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ── 顶栏 ─────────────────────────────────────── */
.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, #2f6feb, #1f9d9d);
  color: #fff; font-weight: 700; font-size: 15px;
  align-self: center;
}
.brand-name { font-size: 17px; font-weight: 650; letter-spacing: .5px; }
.brand-sub { font-size: 12px; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.stat-mini { font-size: 12px; color: var(--muted); }
.user { font-size: 13px; color: var(--text); }

/* ── 通用控件 ──────────────────────────────────── */
.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
}
.btn:hover { border-color: #c9cfdb; background: #f8f9fb; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: #f0f2f6; color: var(--text); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.block { width: 100%; margin-top: 10px; }

input[type=text], input[type=tel], input[type=search], select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: .15s;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,111,235,.12); }
label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 6px; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; }

/* ── 登录 ─────────────────────────────────────── */
.login-wrap {
  min-height: calc(100vh - 56px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 28px;
}
.login-card h1 { margin-bottom: 4px; }
.login-card > p.muted { margin: 4px 0 8px; }
#loginMsg { color: var(--danger); min-height: 18px; margin-top: 8px; }

/* ── 主区域 ───────────────────────────────────── */
.app {
  max-width: 1180px;
  margin: 20px auto 60px;
  padding: 0 20px;
  display: grid;
  gap: 16px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.panel-head h2 + .muted { margin-left: 8px; }
.panel-actions { display: flex; gap: 8px; }

/* 上传区 */
.dropzone {
  border: 1.5px dashed #c9cfdb;
  border-radius: 10px;
  background: #fafbfd;
  padding: 26px 16px;
  text-align: center;
  cursor: pointer;
  transition: .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: #f3f7ff; }
.dz-icon { font-size: 26px; color: var(--accent); line-height: 1; }
.dz-title { margin-top: 8px; font-size: 14px; }
#chosenFile { margin-top: 6px; word-break: break-all; }

.form-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.4fr;
  gap: 0 16px;
  margin-bottom: 14px;
}
.checks { display: flex; flex-direction: column; gap: 4px; padding-top: 2px; }
.checks label {
  margin: 0; font-size: 12px; color: var(--text);
  display: flex; align-items: center; gap: 6px; cursor: pointer;
}
.checks input { width: auto; }
@media (max-width: 860px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
}

/* 任务列表 */
.task-list { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow: auto; }
.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: .15s;
}
.task-item:hover { border-color: #c9cfdb; background: #fafbfd; }
.task-item.active { border-color: var(--accent); background: #f3f7ff; }
.task-main { flex: 1; min-width: 0; }
.task-title { font-size: 13px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef1f6;
  color: var(--muted);
  white-space: nowrap;
}
.badge.running { background: #e8f0ff; color: var(--accent); }
.badge.ready { background: #e6f6ee; color: var(--ok); }
.badge.failed { background: #fdecec; color: var(--danger); }
.progress {
  height: 4px;
  background: #eef1f6;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}
.progress > i { display: block; height: 100%; background: var(--accent); transition: width .3s; }

/* 结果 */
.result-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f2f4f8;
  color: #3a4353;
}
.chip b { color: var(--text); }
.result-tools { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.result-tools select { width: 180px; }
.result-tools input { width: 260px; }
.table-wrap {
  overflow: auto;
  max-height: 560px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
table.issues { width: 100%; border-collapse: collapse; font-size: 13px; }
table.issues th, table.issues td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.issues th {
  position: sticky;
  top: 0;
  background: #f7f8fa;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  z-index: 1;
}
table.issues tbody tr { cursor: pointer; }
table.issues tbody tr:hover { background: #f8f9fb; }
td.orig { color: #b02a2a; }
td.sug { color: #1f7a4d; }
td.cell-narrow { white-space: nowrap; }
.conf { font-variant-numeric: tabular-nums; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 12px; }

/* 抽屉 */
.drawer {
  position: fixed;
  right: 0; top: 56px; bottom: 0;
  width: 380px;
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 24px rgba(16,24,40,.08);
  z-index: 30;
  display: flex;
  flex-direction: column;
}
.drawer-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.drawer-body { padding: 16px; overflow: auto; font-size: 13px; }
.drawer-body .field { margin-bottom: 14px; }
.drawer-body .field .k { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.drawer-body .ctx { background: #f7f8fa; border-radius: 8px; padding: 10px; line-height: 1.9; }
.drawer-body .ctx mark { background: #ffe9a8; padding: 0 2px; border-radius: 3px; }
.drawer-body .ctx .sug { color: #1f7a4d; font-weight: 600; }

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  background: #1d2433;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 50;
  box-shadow: var(--shadow);
  max-width: 80vw;
}
