:root {
  --bg: #f6f7fb;
  --panel: #fff;
  --panel-soft: #fbfcff;
  --ink: #181b34;
  --ink-soft: #383c5c;
  --muted: #676879;
  --line: #e1e5ef;
  --line-strong: #d0d4e4;
  --blue: #0073ea;
  --blue-soft: #e7f1ff;
  --green: #00a36c;
  --green-soft: #e3f6ee;
  --red: #e2445c;
  --red-soft: #fde7eb;
  --amber: #e8a317;
  --amber-soft: #fdf3da;
  --shadow-sm: 0 1px 2px rgba(24, 27, 52, .04);
  --shadow-md: 0 6px 18px rgba(24, 27, 52, .08);
  --shadow-lg: 0 14px 38px rgba(24, 27, 52, .10);
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  background: linear-gradient(180deg, #f6f7fb 0%, #eef1f8 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin: 0; }

/* ── Layout shell ──────────────────────────────────────────── */
.shell {
  width: min(960px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 60px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.shell.narrow { width: min(560px, calc(100vw - 32px)); padding-top: 6vh; }
.shell.wide   { width: min(1500px, calc(100vw - 32px)); }

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 2px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: .2px;
}
.brand-logo {
  font-size: 22px;
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--blue); color: #fff;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}
.brand-text { font-size: 16px; color: var(--ink); }

.topbar-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

/* ── Language toggle ──────────────────────────────────────── */
.lang-toggle {
  display: inline-flex;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 3px;
  box-shadow: var(--shadow-sm);
}
.lang-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 12px;
  min-height: 0;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: .3px;
  transition: background .15s, color .15s;
}
.lang-btn:hover { background: var(--panel-soft); color: var(--ink); }
.lang-btn.active {
  background: var(--blue);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.lang-btn.active:hover { background: #005bbb; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn-primary, .btn-secondary, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform .04s ease, box-shadow .15s ease, background .15s ease;
  white-space: nowrap;
  min-height: 38px;
  padding: 0 16px;
  text-decoration: none;
}
.btn-primary, button {
  background: var(--blue);
  color: #fff;
  border: 1px solid var(--blue);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover, button:hover { background: #005bbb; border-color: #005bbb; text-decoration: none; }
.btn-primary:active, button:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-secondary {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line-strong);
}
.btn-secondary:hover { background: var(--panel-soft); text-decoration: none; }

/* ── Hero card (job page header) ───────────────────────────── */
.hero-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-md);
}
.hero-card h1 {
  font-size: 26px;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.2px;
}
.hero-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--panel-soft);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ── Status pill ───────────────────────────────────────────── */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
}
.status-queued  { background: var(--amber-soft); color: #8a6500;  border-color: #f1d889; }
.status-running { background: var(--blue-soft);  color: #004fa3; border-color: #b8d8ff; }
.status-done    { background: var(--green-soft); color: #00603f; border-color: #a8e0c8; }
.status-failed  { background: var(--red-soft);   color: #a31a30; border-color: #f4b6c1; }

/* ── Overall progress (job hero) ───────────────────────────── */
.overall-progress { margin-top: 14px; }
.overall-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
}
.overall-text { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.overall-percent { font-size: 22px; font-weight: 800; color: var(--blue); font-variant-numeric: tabular-nums; }
.overall-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.overall-stats span { display: inline-flex; align-items: center; gap: 5px; }
.dot {
  width: 8px; height: 8px;
  border-radius: 999px;
  display: inline-block;
}
.dot-blue  { background: var(--blue); }
.dot-green { background: var(--green); }
.dot-red   { background: var(--red); }

/* ── Progress bar ──────────────────────────────────────────── */
.bar-track {
  height: 8px;
  background: #eaeefb;
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--blue), #4ea3ff);
  transition: width .25s ease;
  border-radius: 999px;
}

/* ── Boards (sections with header + body) ──────────────────── */
.board {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}
.board-header h2 {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .2px;
}
.board-body {
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.empty-state {
  padding: 22px 8px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ── Per-URL progress rows ─────────────────────────────────── */
.prog-row {
  border: 1px solid var(--line);
  border-left: 4px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.prog-row.row-done    { border-left-color: var(--green); background: var(--green-soft); }
.prog-row.row-running { border-left-color: var(--blue);  background: var(--blue-soft); }
.prog-row.row-queued  { border-left-color: var(--line-strong); }
.prog-row.row-failed  { border-left-color: var(--red); background: var(--red-soft); }
.prog-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.prog-row-top strong {
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.prog-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.row-done .prog-label    { color: var(--green); }
.row-running .prog-label { color: var(--blue); }
.row-failed .prog-label  { color: var(--red); }
.row-failed .bar-fill    { background: linear-gradient(90deg, var(--red), #ff8195); }
.prog-error {
  font-size: 12px;
  color: #a31a30;
  background: var(--red-soft);
  border: 1px solid #f4b6c1;
  border-radius: 6px;
  padding: 6px 10px;
  margin-top: 4px;
  line-height: 1.45;
}

/* ── File list rows ────────────────────────────────────────── */
.file-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
  transition: background .15s ease, border-color .15s ease;
}
.file-row:hover { background: var(--blue-soft); border-color: #b8d8ff; text-decoration: none; }
.file-icon { font-size: 18px; }
.file-name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.file-size {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.file-action {
  font-size: 12px;
  font-weight: 700;
  color: var(--blue);
  white-space: nowrap;
}

/* ── Index form card ───────────────────────────────────────── */
.form-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.form-card h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.2px;
}
.lead { color: var(--muted); font-size: 13.5px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.field-hint { font-size: 11.5px; color: var(--muted); }
.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.btn-ghost {
  background: var(--panel-soft);
  color: var(--blue);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
  min-height: 28px;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn-ghost:hover { background: var(--blue-soft); border-color: #b8d8ff; }
.btn-ghost:active { transform: translateY(1px); }
.btn-ghost.flash {
  background: var(--green-soft);
  border-color: #a8e0c8;
  color: var(--green);
}
.error {
  background: var(--red-soft);
  color: #a31a30;
  border: 1px solid #f4b6c1;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
}

/* form inputs */
input, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}
textarea { min-height: 240px; resize: vertical; line-height: 1.5; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

.notice {
  font-size: 11.5px;
  color: var(--muted);
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  line-height: 1.55;
}

/* ── Admin login old-style row layout (back-compat) ────────── */
.row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.text-muted { color: var(--muted); }

/* ── Admin logs table ──────────────────────────────────────── */
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  box-shadow: var(--shadow-md);
}
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { border-bottom: 1px solid var(--line); padding: 10px 12px; text-align: left; vertical-align: top; }
th {
  color: var(--muted);
  background: var(--panel-soft);
  font-weight: 700;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .4px;
  position: sticky;
  top: 0;
  z-index: 1;
}
tbody tr:hover { background: var(--panel-soft); }
.url-cell { max-width: 380px; overflow-wrap: anywhere; font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 720px) {
  .shell { padding: 16px 0 40px; gap: 14px; }
  .hero-card, .form-card { padding: 18px; }
  .hero-card h1 { font-size: 22px; }
  .form-card h1 { font-size: 20px; }
  .board-header, .board-body { padding-left: 14px; padding-right: 14px; }
  .file-row { grid-template-columns: auto 1fr auto; }
  .file-row .file-action { display: none; }
  .overall-percent { font-size: 18px; }
}
