* { box-sizing: border-box; }
body {
  margin: 0; padding: 24px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #0f172a; color: #e2e8f0; line-height: 1.5;
}
header {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 24px;
}
h1 { font-size: 24px; margin: 0; }
h2 { font-size: 18px; margin: 0 0 16px; color: #cbd5e1; }
.muted { color: #64748b; font-size: 13px; font-weight: normal; }
.card {
  background: #1e293b; border-radius: 8px; padding: 20px;
  margin-bottom: 16px; border: 1px solid #334155;
}
form .row {
  display: flex; gap: 12px; margin-bottom: 12px; flex-wrap: wrap;
  align-items: end;
}
form label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 13px; color: #94a3b8; flex: 1; min-width: 200px;
}
form label.checkbox {
  flex-direction: row; align-items: center; min-width: auto;
  color: #cbd5e1;
}
input, select {
  background: #0f172a; color: #e2e8f0;
  border: 1px solid #475569; border-radius: 4px;
  padding: 8px 12px; font-size: 14px;
}
input:focus, select:focus { outline: none; border-color: #3b82f6; }
button {
  background: #3b82f6; color: white; border: none;
  border-radius: 4px; padding: 10px 20px; font-size: 14px;
  cursor: pointer; font-weight: 500;
}
button:hover:not(:disabled) { background: #2563eb; }
button:disabled { background: #475569; cursor: not-allowed; opacity: 0.6; }
button#stop-btn { background: #f59e0b; }
button#stop-btn:hover:not(:disabled) { background: #d97706; }
button#kill-btn { background: #ef4444; }
button#kill-btn:hover:not(:disabled) { background: #dc2626; }

.status-pill {
  padding: 4px 12px; border-radius: 12px;
  font-size: 12px; font-weight: 600;
  background: #475569; color: #e2e8f0;
}
.status-pill.crawling { background: #3b82f6; }
.status-pill.checking { background: #8b5cf6; }
.status-pill.writing { background: #06b6d4; }
.status-pill.done { background: #10b981; }
.status-pill.error { background: #ef4444; }
.status-pill.stopped { background: #f59e0b; }

.progress-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.stat {
  background: #0f172a; padding: 12px 16px; border-radius: 6px;
  border: 1px solid #334155;
}
.stat-label { font-size: 11px; color: #64748b; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 24px; font-weight: 600; color: #f1f5f9; margin-top: 4px; }
.stat-value.dead { color: #ef4444; }

.bar-wrap { margin-top: 12px; }
.bar-label { font-size: 12px; color: #94a3b8; margin-bottom: 4px; }
.bar {
  background: #0f172a; height: 8px; border-radius: 4px; overflow: hidden;
  border: 1px solid #334155;
}
.bar-fill {
  background: linear-gradient(90deg, #3b82f6, #06b6d4);
  height: 100%; width: 0%; transition: width 0.3s;
}

/* 环境状态 */
#health-list { display: grid; gap: 6px; }
.health-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; background: #0f172a; border-radius: 4px;
  border: 1px solid #334155; font-size: 13px;
}
.health-row.required-fail { border-color: #ef4444; }
.health-icon {
  font-size: 16px; width: 24px; text-align: center;
  flex-shrink: 0;
}
.health-row.ok .health-icon { color: #10b981; }
.health-row:not(.ok) .health-icon { color: #ef4444; }
.health-row.optional:not(.ok) .health-icon { color: #f59e0b; }
.health-name { min-width: 200px; color: #cbd5e1; }
.health-detail { color: #64748b; flex: 1; font-family: monospace; font-size: 12px; }
.health-action button { padding: 4px 12px; font-size: 12px; }
#install-log {
  background: #020617; padding: 10px; border-radius: 4px;
  font-family: monospace; font-size: 11px; color: #94a3b8;
  max-height: 200px; overflow-y: auto; margin: 8px 0 0;
  border: 1px solid #1e293b;
}
#health-summary.all-ok { color: #10b981; }
#health-summary.has-fail { color: #ef4444; }

#log {
  background: #020617; color: #94a3b8; padding: 12px;
  border-radius: 6px; max-height: 400px; overflow-y: auto;
  font-family: "Consolas", "Monaco", "Cascadia Code", monospace;
  font-size: 12px; line-height: 1.6;
  border: 1px solid #1e293b; white-space: pre-wrap; word-break: break-all;
  margin: 0;
}

#history .report-item {
  background: #0f172a; border: 1px solid #334155; border-radius: 6px;
  padding: 12px 16px; margin-bottom: 8px;
  display: flex; justify-content: space-between; align-items: center;
  cursor: pointer; transition: border-color 0.2s;
}
#history .report-item:hover { border-color: #3b82f6; }
.report-meta { font-size: 12px; color: #64748b; }
.report-actions { display: flex; gap: 8px; }
.report-actions a, .report-actions button {
  font-size: 12px; padding: 6px 12px; text-decoration: none;
}
.report-actions a {
  background: #334155; color: #e2e8f0; border-radius: 4px;
  display: inline-block;
}
.report-actions a:hover { background: #475569; }

#summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.summary-stat {
  background: #0f172a; padding: 12px; border-radius: 6px;
  border: 1px solid #334155;
}
.summary-stat-label { font-size: 11px; color: #64748b; }
.summary-stat-value { font-size: 22px; font-weight: 600; color: #f1f5f9; margin-top: 4px; }
.bucket-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.bucket-table th, .bucket-table td {
  padding: 8px 12px; text-align: left; border-bottom: 1px solid #334155;
  font-size: 13px;
}
.bucket-table th { color: #94a3b8; font-weight: 500; font-size: 11px; text-transform: uppercase; }
.bucket-table .err-name { color: #ef4444; font-family: monospace; }
.bucket-table .err-count { color: #f1f5f9; font-weight: 600; }

#reports {
  display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap;
}
#reports a {
  background: #3b82f6; color: white; padding: 8px 16px;
  border-radius: 4px; text-decoration: none; font-size: 13px;
}
#reports a:hover { background: #2563eb; }

/* 死链清单弹窗 */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal[hidden] { display: none !important; }
.modal-content {
  background: #1e293b; border-radius: 8px;
  width: 90%; max-width: 1200px; height: 85vh;
  display: flex; flex-direction: column;
  padding: 20px; position: relative;
  border: 1px solid #334155;
}
.modal-close {
  position: absolute; top: 12px; right: 12px;
  background: transparent; color: #94a3b8;
  padding: 4px 10px; font-size: 18px;
}
#modal-filters {
  display: flex; gap: 8px; margin-bottom: 12px; align-items: center;
}
#modal-filters input { flex: 1; }
#modal-list {
  flex: 1; overflow-y: auto;
  background: #0f172a; border-radius: 6px; padding: 8px;
  border: 1px solid #334155;
}
.dl-row {
  padding: 8px 12px; border-bottom: 1px solid #1e293b;
  font-size: 13px;
}
.dl-row:hover { background: #1e293b; }
.dl-row .dl-status {
  display: inline-block; padding: 2px 8px; border-radius: 3px;
  background: #ef4444; color: white; font-size: 11px;
  font-family: monospace; margin-right: 8px; min-width: 60px; text-align: center;
}
.dl-row .dl-url {
  font-family: monospace; word-break: break-all; color: #e2e8f0;
}
.dl-row .dl-parents {
  font-size: 11px; color: #64748b; margin-top: 4px; padding-left: 8px;
}
#modal-pager {
  display: flex; gap: 8px; justify-content: center; margin-top: 12px;
}
#modal-pager button { padding: 6px 12px; font-size: 12px; }
