:root {
  --bg: #0b1018;
  --panel: #111826;
  --panel-2: #162033;
  --line: #243149;
  --text: #e8eefc;
  --muted: #8fa0bd;
  --brand: #4da3ff;
  --brand-2: #2f7df6;
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(77, 163, 255, .16), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(52, 211, 153, .08), transparent 55%),
    var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 16, 24, .75);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 46px; height: 46px; border-radius: 12px;
  display: grid; place-items: center;
  font-weight: 800; letter-spacing: .5px;
  background: linear-gradient(135deg, #4da3ff, #7c5cff);
  box-shadow: 0 8px 22px rgba(77, 163, 255, .35);
}
.brand h1 { margin: 0; font-size: 18px; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pill { color: var(--muted); font-size: 12px; border: 1px solid var(--line); padding: 5px 10px; border-radius: 999px; }

main { max-width: 1360px; margin: 0 auto; padding: 22px 28px 60px; display: grid; gap: 18px; }
.panel {
  background: linear-gradient(180deg, rgba(22, 32, 51, .9), rgba(17, 24, 38, .9));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.actions { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; justify-content: space-between; }
.action-group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.inline-field { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
input, select {
  background: #0d1420; color: var(--text);
  border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 11px; outline: none; font: inherit;
}
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(77, 163, 255, .13); }
input[type=number] { width: 80px; }
input[type=file] { display: none; }
.btn {
  border: 1px solid var(--line);
  background: #182337; color: var(--text);
  border-radius: 9px; padding: 9px 13px;
  font: inherit; cursor: pointer; transition: .15s;
  white-space: nowrap;
}
.btn:hover { border-color: #3b5480; transform: translateY(-1px); }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); border-color: transparent; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.file-btn { display: inline-flex; align-items: center; }

.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 3px;
}
.card-label { color: var(--muted); font-size: 12px; }
.card strong { font-size: 24px; line-height: 1.25; font-variant-numeric: tabular-nums; }
.card small { color: var(--muted); font-size: 11px; }
.danger { color: var(--red); }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type=search] { flex: 1; min-width: 240px; }
.spacer { flex: 1; }
.muted { color: var(--muted); font-size: 12px; }
.badge { border: 1px solid var(--line); border-radius: 999px; padding: 5px 10px; font-size: 12px; color: var(--muted); }
.badge.live { color: var(--green); border-color: rgba(52, 211, 153, .4); background: rgba(52, 211, 153, .08); }
.badge.paused { color: var(--amber); border-color: rgba(251, 191, 36, .4); }

.table-wrap { overflow: auto; border-radius: 10px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; font-weight: 500; background: #0e1623; position: sticky; top: 0; }
tbody tr:hover { background: rgba(77, 163, 255, .045); }
tbody tr:last-child td { border-bottom: 0; }
.game-title { font-weight: 600; }
.game-sub { color: var(--muted); font-size: 11px; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line); }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.status.queued::before { background: var(--muted); }
.status.crawling::before { background: var(--brand); box-shadow: 0 0 8px var(--brand); }
.status.paused::before { background: var(--amber); }
.status.done::before { background: var(--green); }
.status.partial::before { background: var(--amber); }
.status.failed::before { background: var(--red); }
.progress { width: 180px; }
.bar { height: 8px; border-radius: 99px; background: #0d1420; overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; }
.bar .ok { background: linear-gradient(90deg, #2f7df6, #34d399); }
.bar .bad { background: var(--red); }
.progress small { color: var(--muted); font-size: 11px; }
.entry { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #b7c8e6; font-size: 12px; }
.entry a { color: inherit; text-decoration: none; }
.entry a:hover { color: var(--brand); }
.right { text-align: right; }
.row-actions { display: inline-flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.btn.mini { padding: 5px 9px; font-size: 12px; }
.empty { text-align: center; color: var(--muted); padding: 36px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; padding-top: 14px; }

.logs .panel-head { display: flex; align-items: center; justify-content: space-between; }
.logs h2 { margin: 0; font-size: 14px; color: var(--muted); font-weight: 500; }
.log-box {
  margin: 12px 0 0; max-height: 320px; overflow: auto;
  background: #0a101a; border: 1px solid var(--line); border-radius: 10px;
  padding: 14px; font-size: 12px; line-height: 1.6; color: #b9c9e4;
  white-space: pre-wrap; word-break: break-all;
}

.modal { position: fixed; inset: 0; background: rgba(3, 7, 13, .72); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal.hidden, .toast.hidden { display: none; }
.modal-card {
  width: min(1080px, 96vw); max-height: 90vh; overflow: auto;
  background: var(--panel); border: 1px solid #314565; border-radius: 16px;
  padding: 24px; position: relative; box-shadow: 0 24px 80px rgba(0, 0, 0, .55);
}
.modal-close { position: sticky; top: 0; float: right; background: transparent; border: 0; color: var(--muted); font-size: 28px; cursor: pointer; line-height: 1; }
.modal h2 { margin: 0 0 4px; font-size: 20px; }
.modal h3 { margin: 22px 0 10px; font-size: 14px; color: var(--muted); font-weight: 500; }
.meta-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 16px 0; }
.meta { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.meta b { display: block; font-size: 18px; }
.meta span { color: var(--muted); font-size: 11px; }
.url-box { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: #0a101a; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; word-break: break-all; }
.fail-table { width: 100%; min-width: 0; }
.fail-table th, .fail-table td { padding: 8px 9px; font-size: 12px; }
.fail-url { max-width: 480px; word-break: break-all; }
.fail-error { color: var(--amber); }
.events { display: grid; gap: 6px; font-size: 12px; }
.events div { padding: 7px 10px; background: #0d1420; border-radius: 8px; border-left: 2px solid var(--line); }
.events time { color: var(--muted); margin-right: 8px; font-family: ui-monospace, monospace; }
.events .error { border-left-color: var(--red); }
.events .warn { border-left-color: var(--amber); }
.toast {
  position: fixed; right: 24px; bottom: 24px; z-index: 80;
  background: #162033; border: 1px solid #3b5480; color: var(--text);
  padding: 12px 16px; border-radius: 10px; box-shadow: 0 14px 40px rgba(0,0,0,.5);
  max-width: 420px;
}
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .topbar { align-items: flex-start; flex-direction: column; }
  .meta-grid { grid-template-columns: repeat(2, 1fr); }
}
