:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #17212b;
  --muted: #66727f;
  --line: #dfe5ea;
  --accent: #1769aa;
  --accent-dark: #0f4f83;
  --danger: #b3261e;
  --ok: #1d7a46;
  --warn: #9a6700;
  --chip: #eef3f7;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
button, .button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
button:hover, .button-link:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.secondary, .button-link.secondary {
  background: #fff;
  color: var(--accent);
  border-color: #b9d2e6;
}
button.secondary:hover { background: #f0f7fc; }
button.danger { background: #fff; color: var(--danger); border-color: #e4b4b0; }
button.danger:hover { background: #fdf3f2; }
a { color: var(--accent); }

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 28px 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
h1 { margin: 0; font-size: 22px; line-height: 1.25; letter-spacing: .2px; }
h2 { margin: 0; font-size: 16px; line-height: 1.35; }
.subtitle { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.login-control { display: inline-flex; align-items: center; gap: 6px; }
.login-control select { width: auto; min-width: 150px; padding: 6px 8px; }
.muted { color: var(--muted); font-size: 12px; }

.layout {
  max-width: 1680px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr);
  gap: 16px;
  align-items: start;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 16px;
  min-width: 0;
}
.panel.wide { grid-column: 1 / -1; }
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.panel-head .actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field > span { color: var(--muted); font-size: 12px; }
.field.compact { width: 150px; margin-bottom: 0; }
textarea, input[type="text"], input[type="number"], input[type="search"], select {
  width: 100%;
  border: 1px solid #cbd5dd;
  border-radius: 8px;
  background: #fff;
  padding: 8px 10px;
  outline: none;
}
textarea { resize: vertical; min-height: 120px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
textarea:focus, input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(23, 105, 170, .12); }
.form-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: 12px; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.check input { accent-color: var(--accent); }

.providers-fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px 12px; margin: 0 0 12px; }
.providers-fieldset legend { padding: 0 6px; color: var(--muted); font-size: 12px; }
.provider-options { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.provider-options label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.provider-options input { accent-color: var(--accent); }
.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.error-box, .notice {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #efc7c3;
  background: #fff5f4;
  color: #7a1c16;
  white-space: pre-wrap;
}
.notice { border-color: #ead7a9; background: #fffaf0; color: #6b4b00; }

.jobs-list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow: auto; }
.job-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fbfcfd;
  cursor: pointer;
  text-align: left;
}
.job-item:hover, .job-item.active { border-color: #9cc3e0; background: #f3f9fd; }
.job-item .job-id { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.job-item .job-sub { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12px; margin-top: 2px; }

.progress-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.provider-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fbfcfd; }
.provider-card .provider-title { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.provider-card .provider-title strong { font-size: 13px; }
.provider-card .bar { height: 6px; border-radius: 99px; background: #e8edf1; overflow: hidden; margin: 8px 0 6px; }
.provider-card .bar > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .3s ease; }
.provider-card .provider-meta { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 11px; }
.status-pill { display: inline-block; border-radius: 99px; padding: 2px 7px; background: var(--chip); color: var(--muted); font-size: 11px; white-space: nowrap; }
.status-pill.ok, .status-pill.completed { background: #e8f5ed; color: var(--ok); }
.status-pill.error, .status-pill.failed, .status-pill.needs_human, .status-pill.blocked { background: #fdecea; color: var(--danger); }
.status-pill.running, .status-pill.cached { background: #eaf3fa; color: var(--accent); }
.status-pill.partial, .status-pill.deadline, .status-pill.circuit, .status-pill.skipped, .status-pill.no_results { background: #fff6e5; color: var(--warn); }

.stats { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 14px; color: var(--muted); font-size: 12px; }
.stats b { color: var(--text); font-size: 16px; font-weight: 600; }

.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filters input[type="search"] { width: 260px; }
.filters select { width: 150px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; max-height: 640px; }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th, td { padding: 8px 10px; border-bottom: 1px solid #edf1f4; text-align: left; vertical-align: top; }
th { position: sticky; top: 0; background: #f7f9fb; color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; z-index: 1; }
tbody tr:hover { background: #fbfdff; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.nowrap { white-space: nowrap; }
td .tiers { font-size: 12px; color: #33414d; max-width: 360px; }
td .sub { color: var(--muted); font-size: 11px; }
.empty { color: var(--muted); text-align: center; padding: 18px; }
.footnote { color: var(--muted); font-size: 11px; margin: 10px 0 0; }
.badge { display: inline-block; border-radius: 4px; padding: 1px 5px; background: var(--chip); color: var(--muted); font-size: 10px; }
.qq-link { font-weight: 600; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  background: #17212b;
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0,0,0,.2);
  z-index: 10;
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; padding: 12px; }
  .topbar { padding: 16px; }
  .panel.wide { grid-column: auto; }
  .filters input[type="search"] { width: 100%; }
  .filters select { width: 100%; }
}
