/* Neutral, theme-aware, no framework. */
:root {
  --bg: #f7f7f8; --panel: #ffffff; --ink: #17181c; --muted: #6b6f76;
  --line: #e2e4e8; --accent: #2b6cb0; --bad: #b4232a; --good: #1e7a45;
  --warn: #8a5a00;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a; --panel: #1b1e24; --ink: #e8eaee; --muted: #9aa0a8;
    --line: #2b2f36; --accent: #6aa9e9; --bad: #f08b8f; --good: #6bd398;
    --warn: #e0b866;
  }
}
* { box-sizing: border-box; }

/* The `hidden` attribute must actually hide things.
 *
 * The UA stylesheet says `[hidden] { display: none }`, which any explicit
 * `display` rule outranks — and three elements here are both toggled by
 * `hidden` and given a display: the confirm dialog (`display: flex`), the nav
 * and the signed-in user block. The dialog therefore rendered empty over the
 * campaign list on first load, and its overlay dimmed the page; the nav and
 * user block showed on the login screen.
 *
 * A global rule rather than three scoped ones, because the next element given a
 * display would fail the same way and nothing would say so. */
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* header + nav */
header {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .6rem 1.25rem; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 600; }
.brand img { height: 22px; width: auto; }
.brand span { color: var(--muted); font-weight: 500; }
nav { display: flex; gap: .25rem; flex: 1 1 auto; flex-wrap: wrap; }
nav a {
  color: var(--muted); text-decoration: none; padding: .3rem .65rem;
  border-radius: 6px; font-size: 14px;
}
nav a:hover { color: var(--ink); background: var(--bg); }
nav a.on { color: var(--ink); background: var(--bg); font-weight: 600; }
.who { display: flex; align-items: center; gap: .75rem; font-size: 14px; }

main { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
h1 { font-size: 1.3rem; margin: 0 0 .35rem; }
h2 { font-size: 1.02rem; margin: 2rem 0 .5rem; }
.muted { color: var(--muted); font-size: 14px; margin: .2rem 0 1rem; }
.crumb { font-size: 13px; color: var(--muted); margin: 0 0 .5rem; }
.crumb a { color: var(--accent); text-decoration: none; }
.row { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.row-actions { display: flex; align-items: center; gap: .75rem; }
.empty {
  color: var(--muted); background: var(--panel); border: 1px dashed var(--line);
  border-radius: 8px; padding: 1.1rem; text-align: center; font-size: 14px;
}

/* forms */
form { display: flex; flex-wrap: wrap; gap: .9rem; align-items: start; margin: .6rem 0; }
label { display: flex; flex-direction: column; gap: .25rem; font-size: 13px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: .4rem; }
label.check input { min-width: 0; }
.grow { flex: 1 1 240px; }
input, select {
  font: inherit; padding: .45rem .6rem; border: 1px solid var(--line);
  border-radius: 6px; background: var(--panel); color: var(--ink);
  min-width: 0; width: 100%;
}
label { min-width: 190px; }
label small.hint {
  color: var(--muted); font-size: 12px; font-weight: 400; max-width: 34ch; line-height: 1.35;
}
button {
  font: inherit; padding: .45rem .9rem; border: 1px solid var(--line);
  border-radius: 6px; background: var(--panel); color: var(--ink); cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: .55; cursor: progress; }
button.link { border: 0; background: none; color: var(--accent); padding: 0; }
button.danger { border-color: var(--warn); color: var(--warn); }
button.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--warn) 12%, transparent); }
.error { color: var(--bad); font-size: 14px; }

/* stat cards */
.stats { display: flex; flex-wrap: wrap; gap: .7rem; margin: 1rem 0; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: .6rem .85rem; min-width: 120px; flex: 1 1 120px;
}
.card .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.card .v { font-size: 1.45rem; font-weight: 600; }
.card.attn .v { color: var(--warn); }

/* campaign cards */
.camp {
  display: block; text-decoration: none; color: inherit; background: var(--panel);
  border: 1px solid var(--line); border-left: 3px solid var(--line);
  border-radius: 8px; padding: .75rem .9rem; margin-bottom: .6rem;
}
.camp:hover { border-color: var(--accent); }
.camp.attn { border-left-color: var(--warn); }
.camp.ok { border-left-color: var(--good); }
.camp-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.verdict { font-size: 14px; margin-top: .35rem; }
.verdict.attn, .camp.attn .verdict { color: var(--warn); font-weight: 600; }
.verdict.ok, .camp.ok .verdict { color: var(--good); }

/* operation cards */
.ops { display: grid; gap: .6rem; }
.op { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .75rem .9rem; }
.op-head { display: flex; align-items: baseline; gap: .6rem; justify-content: space-between; flex-wrap: wrap; }
.op-actions { display: flex; gap: .5rem; align-self: end; }

/* tables */
.scroll { overflow-x: auto; }
table {
  width: 100%; border-collapse: collapse; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; font-size: 14px;
}
th, td { text-align: left; padding: .45rem .7rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
/* Only rows that actually go somewhere invite a click. */
tr[data-run] { cursor: pointer; }
tr[data-run]:hover td { background: var(--bg); }
tr[data-run]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
tr.sel td { background: color-mix(in srgb, var(--accent) 10%, transparent); }

.pill { font-size: 12px; padding: .1rem .45rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
a.pill.live { text-decoration: none; color: var(--warn); border-color: var(--warn); }
.tag { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: .05rem .35rem; border-radius: 4px; border: 1px solid var(--line); }
.tag.safe { color: var(--good); border-color: var(--good); }
.status-succeeded { color: var(--good); }
.status-failed { color: var(--bad); }
.status-running, .status-queued { color: var(--warn); }
.zero { color: var(--muted); }
.attn { color: var(--warn); }
code { font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }

/* run panel */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .85rem 1rem; margin-top: 1rem; }
.argv { font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); margin: .4rem 0; word-break: break-all; }
pre.out {
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  padding: .6rem .7rem; overflow: auto; max-height: 24rem;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; margin: .4rem 0 0;
  white-space: pre-wrap; word-break: break-word;
}

/* confirm dialog */
.modal {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .45);
  display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 10;
}
.modal-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 1.1rem 1.2rem; max-width: 560px; width: 100%;
}
.modal-card h2 { margin: 0 0 .5rem; font-size: 1.05rem; }
.modal-card summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1rem; }

/* The first width rules this console has ever had. A 260px select inside a
   wrapping flex form used to overflow a phone viewport, and operation forms are
   not inside a .scroll wrapper, so that overflow was on the page itself. */
@media (max-width: 640px) {
  main { padding: 1rem .8rem 3rem; }
  header { gap: .5rem; padding: .5rem .8rem; }
  form { flex-direction: column; gap: .7rem; }
  label, .grow { min-width: 0; width: 100%; flex: 1 1 auto; }
  .op-actions { width: 100%; }
  .op-actions button { flex: 1 1 auto; }
  .card { flex: 1 1 45%; }
  .who { font-size: 13px; }
}

/* the ? affordance */
button.q {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  width: 1.15rem; height: 1.15rem; padding: 0; margin-left: .35rem;
  border-radius: 50%; font-size: 11px; line-height: 1; cursor: pointer;
  vertical-align: middle;
}
button.q:hover { border-color: var(--accent); color: var(--accent); }
.help {
  display: block; margin-top: .4rem; padding: .5rem .65rem;
  background: var(--bg); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 6px; color: var(--ink); font-size: 13px; font-weight: 400;
  line-height: 1.45; text-transform: none; letter-spacing: normal; max-width: 42ch;
}
/* Stat-card labels are uppercase and tight; the explanation must not inherit
   that or it becomes unreadable. */
.card .k .help { max-width: 30ch; }
h1 .help, h2 .help { font-size: 14px; }

/* campaign settings form */
form.settings { display: block; }
fieldset {
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
  padding: .9rem 1rem 1rem; margin: 0 0 1rem;
}
legend { font-weight: 600; padding: 0 .4rem; font-size: .95rem; }
fieldset > label, .threshold { margin-bottom: .8rem; }
fieldset .muted { margin-top: 0; }
textarea {
  font: inherit; padding: .45rem .6rem; border: 1px solid var(--line);
  border-radius: 6px; background: var(--panel); color: var(--ink);
  width: 100%; resize: vertical;
}
/* A threshold and its justification read as one thing, because they are. */
.threshold {
  border-left: 3px solid var(--line); padding-left: .7rem;
  display: flex; flex-direction: column; gap: .4rem;
}
.threshold:focus-within { border-left-color: var(--accent); }
.why-field textarea { font-size: 13px; }
a.pill { text-decoration: none; }
a.pill:hover { border-color: var(--accent); color: var(--accent); }
