:root {
  --bg: #f6f7f9; --card: #fff; --text: #1d2129; --muted: #6b7280; --line: #e5e7eb; --accent: #1d4ed8;
  --accent-text: #fff; --ok: #15803d; --warn: #b45309; --bad: #b91c1c; --run: #1d4ed8; --changed: #fef3c7;
  --input: #fff; --chip: #eef2ff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418; --card: #1a1f26; --text: #e6e8eb; --muted: #9aa3ae; --line: #2b323c; --accent: #3b82f6;
    --accent-text: #fff; --ok: #4ade80; --warn: #fbbf24; --bad: #f87171; --run: #93c5fd; --changed: #3a3218;
    --input: #12161b; --chip: #1e2740;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 14px/1.5 system-ui, "Microsoft YaHei", sans-serif; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line); background: var(--card); border-radius: 6px; padding: 4px 12px; cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.danger { color: var(--bad); }
button:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=password], input[type=number], input:not([type]), select, textarea {
  background: var(--input); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; max-width: 100%;
}
textarea { width: 100%; min-height: 8em; font-family: ui-monospace, Consolas, monospace; }
input[type=checkbox] { width: 16px; height: 16px; vertical-align: -3px; margin: 0 4px 0 0; }

header {
  position: sticky; top: 0; z-index: 10; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px;
  padding: 8px 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
header .brand { font-weight: 700; font-size: 16px; }
nav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
nav a { padding: 4px 10px; border-radius: 6px; text-decoration: none; color: var(--text); }
nav a.active { background: var(--chip); color: var(--accent); font-weight: 600; }
#who { color: var(--muted); }
td.bad { color: var(--bad); font-weight: 600; }
#pausebar { background: var(--changed); color: var(--warn); font-weight: 600; text-align: center; padding: 8px 16px;
  border-bottom: 1px solid var(--line); }
#pausebar button { margin-left: 12px; }
#who button { margin-left: 8px; }

main { padding: 16px; max-width: 1400px; margin: 0 auto; }
h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 24px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; margin: 0 0 12px; }
.card.table { padding: 0; overflow-x: auto; }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 12px; }
.bar .grow { flex: 1; }
.stack > * + * { margin-top: 8px; }
.field { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 6px 0; }
.field > .lbl { min-width: 8em; color: var(--muted); }
.error { color: var(--bad); }
.okmsg { color: var(--ok); }
.chip {
  display: inline-block; padding: 0 8px; margin: 1px 4px 1px 0; border-radius: 10px; background: var(--chip);
  font-size: 12px; cursor: default;
}
button.chip { border: none; cursor: pointer; }
a.chip { text-decoration: none; }
.chip.warn { background: var(--changed); color: var(--warn); font-weight: 600; }
button.chip.danger { color: var(--bad); }
code, .mono { font-family: ui-monospace, Consolas, monospace; }
.key { font-family: ui-monospace, Consolas, monospace; font-size: 15px; padding: 2px 8px; background: var(--chip); border-radius: 4px; user-select: all; }

table { border-collapse: collapse; width: 100%; }
td.pick { cursor: pointer; user-select: none; -webkit-user-select: none; }
input.num { width: 5.5em; }
th, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: 12px; }
tr:last-child td { border-bottom: none; }
td.wrap { white-space: normal; min-width: 14em; }
tr.off td { opacity: .55; }
.s-运行中 { color: var(--run); font-weight: 600; }
.s-空闲, .s-已停止, .s-还没连上 { color: var(--muted); }
.s-超时, .s-掉线 { color: var(--bad); font-weight: 700; }
.s-异常慢 { color: var(--warn); font-weight: 700; }
.s-异常慢 .small { font-weight: 400; }
tr.sub td { color: var(--muted); font-size: 12px; }
.r-ok { color: var(--ok); } .r-failed, .r-stuck { color: var(--bad); } .r-skipped { color: var(--warn); }

/* the settings form generated from the app's UI */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); margin: 8px 0 0; }
.tabs button { border-radius: 6px 6px 0 0; border-bottom: none; }
.tabs button.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.tabs button .count { font-size: 11px; opacity: .8; margin-left: 4px; }
.form { padding: 8px 0; }
.form .tabhead { font-weight: 600; margin: 16px 0 4px; }
.form .item { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; padding: 3px 4px; border-radius: 4px; }
.form .row { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; padding: 3px 4px; border-radius: 4px; }
.form .row:hover, .form .item:hover { background: var(--bg); }
.form label.ctl { display: inline-flex; align-items: center; gap: 4px; }
.form .changed { background: var(--changed); border-radius: 4px; padding: 0 4px; }
.form .txt { color: var(--muted); }
.form .txt.head { color: var(--text); font-weight: 600; margin-top: 6px; }
.form input[type=text], .form input[type=password] { width: 12em; }
.form .hidden { display: none; }
.savebar {
  position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 8px 16px; margin: 12px -16px 0; background: var(--card); border-top: 1px solid var(--line);
}

#toast {
  position: fixed; right: 16px; bottom: 16px; z-index: 20; max-width: min(420px, calc(100vw - 32px));
  display: flex; flex-direction: column; gap: 6px;
}
#toast div { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
#toast div.bad { border-color: var(--bad); color: var(--bad); }

.login { max-width: 360px; margin: 10vh auto; }
.login .field > .lbl { min-width: 5em; }

@media (max-width: 640px) {
  main { padding: 12px; }
  .field > .lbl { min-width: 0; width: 100%; }
}
