:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e3e6ea;
  --text: #16191d;
  --muted: #6b7280;
  --accent: #1f6feb;
  --good: #0f7b3f;
  --bad: #b42318;
  --warn: #9a6700;
}

* {
  box-sizing: border-box;
}

/* Author rules that set `display` would otherwise beat the UA `[hidden]` rule. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  /* Dashboard layout: header stays, the table fills the rest of the viewport. */
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.stats-inline {
  color: var(--muted);
  font-size: 12px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.key {
  display: flex;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

input,
button,
.button {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 6px 10px;
  background: var(--surface);
  color: inherit;
}

button,
.button {
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

button#run-all {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.ghost {
  background: transparent;
}

button:disabled {
  opacity: 0.5;
  cursor: progress;
}

main {
  padding: 16px 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  flex: 1;
  min-height: 0;
}

.stats-inline b {
  color: var(--text);
  font-weight: 600;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.panel-head {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.panel-head h2 {
  font-size: 15px;
  margin: 0;
}

.panel-head input {
  min-width: 240px;
}

.table-wrap {
  overflow: auto;
  flex: 1;
  min-height: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

a.wf-link,
.thumb {
  color: inherit;
  text-decoration: none;
}

a.wf-link {
  color: var(--accent);
  border-bottom: 1px dotted transparent;
}

a.wf-link:hover {
  border-bottom-color: var(--accent);
}

a .thumb:hover {
  border-color: var(--accent);
}

th,
td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

thead th {
  position: sticky;
  top: 0;
  background: #fbfcfd;
  font-weight: 600;
  color: var(--muted);
  z-index: 1;
}

tbody tr:hover {
  background: #f8fafc;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.diff-up {
  color: var(--bad);
}

.diff-down {
  color: var(--good);
}

.chip {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #eef2f7;
  color: var(--muted);
}

.chip.ok {
  background: #e7f6ed;
  color: var(--good);
}

.chip.blocked {
  background: #fdecea;
  color: var(--bad);
}

.chip.error,
.chip.parse_error {
  background: #fff6e0;
  color: var(--warn);
}

.thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f2f4f7;
  object-fit: cover;
  display: block;
}

.thumb.empty {
  display: grid;
  place-items: center;
  color: #b3b8c0;
  font-size: 16px;
}

.trend {
  display: flex;
  align-items: center;
  gap: 8px;
}

.trend svg {
  display: block;
  background: #fbfcfd;
  border-radius: 4px;
}

.trend .delta {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.trend .delta.up {
  color: var(--bad);
}

.trend .delta.down {
  color: var(--good);
}

.trend .delta.flat {
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 460px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #16191d;
  color: #fff;
  box-shadow: 0 8px 24px rgb(0 0 0 / 18%);
  z-index: 10;
}

.banner {
  padding: 10px 20px;
  background: #fff6e0;
  border-bottom: 1px solid #f0d9a8;
  color: #7a4f00;
  font-size: 13px;
  font-weight: 600;
}

.toast.error {
  background: var(--bad);
}

dialog {
  width: min(760px, 92vw);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
}

dialog::backdrop {
  background: rgb(0 0 0 / 30%);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.dialog-head h2 {
  font-size: 15px;
  margin: 0;
}

#history-body {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.form-body {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.form-body label {
  display: grid;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

.form-body input[type="url"],
.form-body input[type="text"],
.form-body input:not([type]) {
  width: 100%;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-body label.check {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  padding-top: 18px;
}

.form-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

svg.spark {
  width: 100%;
  height: 120px;
  background: #fbfcfd;
  border: 1px solid var(--border);
  border-radius: 8px;
}
