:root {
  --bg: #f4f5f8; --panel: #ffffff; --text: #1a1e27; --muted: #5b6577; --line: #e2e5eb; --hover: #f1f3f8;
  --accent: #2f5bea; --accent-ink: #ffffff; --focus: #2f5bea55;
  --pass: #17794a; --pass-bg: #e3f4ec; --fail: #c1281b; --fail-bg: #fdebe9;
  --warn: #8f5f00; --warn-bg: #fff3d1; --run: #1b57d4; --run-bg: #e4edfc; --idle: #566074; --idle-bg: #eceef3;
  --code-bg: #10151c; --code-text: #d7dfec; --shadow: 0 1px 2px #1a1e270d, 0 4px 14px #1a1e270a;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1117; --panel: #161a22; --text: #e5e8ef; --muted: #9aa3b5; --line: #272d39; --hover: #1e2330;
    --accent: #7391ff; --accent-ink: #0b1020; --focus: #7391ff66;
    --pass: #52c68d; --pass-bg: #12301f; --fail: #ff8279; --fail-bg: #3b1816;
    --warn: #e6b94a; --warn-bg: #3a2e10; --run: #82a8ff; --run-bg: #16264b; --idle: #9aa3b5; --idle-bg: #232937;
    --code-bg: #0a0d12; --shadow: none;
  }
}
* { box-sizing: border-box; }
html { color-scheme: light dark; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans); }
h1, h2, h3, p { margin: 0; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* header */
.top { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: 12px; align-items: center; }
.brand h1 { font-size: 17px; line-height: 1.2; }
.brand p { color: var(--muted); font-size: 12.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px; border-radius: 999px;
  background: var(--idle-bg); color: var(--idle); font-size: 12.5px; font-weight: 500; max-width: 340px; }
.chip .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.chip.ok { background: var(--pass-bg); color: var(--pass); }
.chip.bad { background: var(--fail-bg); color: var(--fail); }
.chip.busy { background: var(--run-bg); color: var(--run); }
.chip.busy .dot { animation: pulse 1.4s ease-in-out infinite; }
.chip.plain { background: transparent; border: 1px solid var(--line); font-weight: 400; }
.chip.plain .dot { display: none; }

/* layout */
.layout { display: grid; grid-template-columns: minmax(320px, 440px) minmax(0, 1fr); gap: 16px;
  padding: 16px 24px 40px; max-width: 1500px; margin: 0 auto; align-items: start; }
.col { display: grid; gap: 16px; min-width: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.panel > h2 { font-size: 15px; margin-bottom: 14px; }
@media (max-width: 960px) { .layout { grid-template-columns: minmax(0, 1fr); padding: 12px 16px 32px; } .top { padding: 12px 16px; } }

/* form */
form { display: grid; gap: 14px; }
label { font-weight: 600; font-size: 13px; }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 9px; }
legend { font-weight: 600; font-size: 13px; padding: 0; margin-bottom: 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; cursor: pointer; }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.check b { display: block; font-weight: 600; }
.check small { display: block; color: var(--muted); font-size: 12.5px; }
.picker { position: relative; display: flex; gap: 8px; margin-top: 6px; }
.picker input { flex: 1; min-width: 0; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.picker input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
#branch-list { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; right: 0; margin: 0; padding: 4px; list-style: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; max-height: 320px; overflow: auto;
  box-shadow: 0 8px 28px #00000033; }
#branch-list li { padding: 7px 9px; border-radius: 7px; cursor: pointer; display: grid; gap: 1px; }
#branch-list li[aria-selected="true"], #branch-list li:hover { background: var(--hover); }
#branch-list .n { display: flex; gap: 8px; align-items: baseline; font-weight: 600; }
#branch-list .n em { font-style: normal; font-weight: 400; color: var(--muted); font-family: var(--mono); font-size: 12px; }
#branch-list .s { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#branch-list .empty { color: var(--muted); cursor: default; }
.msg { min-height: 1.4em; font-size: 13px; color: var(--muted); }
.msg.err { color: var(--fail); } .msg.warn { color: var(--warn); } .msg.ok { color: var(--pass); }

/* buttons */
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.danger { color: var(--fail); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.icon { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; width: 38px; cursor: pointer; font-size: 17px; line-height: 1; }
.icon:hover { background: var(--hover); }
.icon.spin { animation: spin 0.9s linear infinite; }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px;
  font-weight: 600; background: var(--idle-bg); color: var(--idle); white-space: nowrap; }
.pill.pass { background: var(--pass-bg); color: var(--pass); }
.pill.fail { background: var(--fail-bg); color: var(--fail); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.live { background: var(--run-bg); color: var(--run); }
.pill.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.4s ease-in-out infinite; }

/* runs list */
.runs { display: grid; gap: 6px; margin: -4px; }
.run { display: grid; gap: 4px; text-align: left; width: 100%; padding: 10px 12px; border: 1px solid transparent; border-radius: 10px;
  background: transparent; cursor: pointer; }
.run:hover { background: var(--hover); }
.run.sel { background: var(--hover); border-color: var(--line); }
.run .r1 { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.run .br { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run .br code { font-weight: 400; color: var(--muted); margin-left: 6px; }
.run .r2 { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run .r3 { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: 12.5px; }
.empty-note { color: var(--muted); padding: 8px 4px; }
code { font-family: var(--mono); font-size: 12px; }

/* detail */
.detail .placeholder { color: var(--muted); text-align: center; padding: 56px 12px; }
.d-head { display: grid; gap: 10px; margin-bottom: 16px; }
.d-title { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.d-title h2 { font-size: 17px; overflow-wrap: anywhere; }
.d-title code { color: var(--muted); }
.d-sub { color: var(--muted); }
.d-meta { display: flex; flex-wrap: wrap; gap: 4px 18px; color: var(--muted); font-size: 12.5px; }
.d-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.bar { height: 6px; border-radius: 6px; background: var(--idle-bg); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--run); transition: width .4s; }
.notice { padding: 9px 12px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); font-size: 13px; }
.notice.bad { background: var(--fail-bg); color: var(--fail); }
.stage { margin: 18px 0 6px; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.steps { width: 100%; border-collapse: collapse; }
.steps td { padding: 8px 8px; border-top: 1px solid var(--line); vertical-align: top; }
.steps tr:first-child td { border-top: 0; }
.steps tr.step { cursor: pointer; }
.steps tr.step:hover td { background: var(--hover); }
.steps tr.sel td { background: var(--hover); }
.steps .st { width: 92px; } .steps .tm { width: 78px; color: var(--muted); white-space: nowrap; text-align: right; }
.steps .ts { color: var(--muted); font-size: 12.5px; }
.steps .tag { color: var(--muted); font-size: 11.5px; margin-left: 6px; }
.steps .nt { display: block; color: var(--muted); font-size: 12.5px; }
.logbox { margin-top: 20px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.logbar { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between;
  padding: 8px 12px; background: var(--hover); border-bottom: 1px solid var(--line); }
.logbar b { font-size: 13px; }
.logbar label { font-weight: 400; display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
pre.log { margin: 0; padding: 12px; background: var(--code-bg); color: var(--code-text); font: 12px/1.5 var(--mono);
  max-height: 460px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; min-height: 80px; }
pre.log:empty::before { content: "Nothing logged yet."; color: #8a94a8; }

@keyframes pulse { 50% { opacity: .35; } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* expandable step rows */
[hidden] { display: none !important; }
.hint { color: var(--muted); font-size: 12.5px; }
.toggle { display: inline-flex; gap: 8px; align-items: baseline; background: none; border: 0; padding: 0; cursor: pointer;
  text-align: left; color: inherit; font: inherit; }
.chev { display: inline-block; width: 10px; color: var(--muted); font-size: 11px; transition: transform .15s; }
.steps tr.step.open .chev { transform: rotate(90deg); }
.steps tr.step.open td { background: var(--hover); }
.steps .nt { margin-left: 18px; }
.logrow td { padding: 0 8px 14px 8px; border-top: 0; }
.logrow .logbox { margin: 0; }
.logbar .ts { color: var(--muted); font-size: 12.5px; }
a.btn { text-decoration: none; color: inherit; display: inline-block; line-height: 1.5; }

/* sign-in gate and user chip */
.gate { max-width: 460px; margin: 72px auto; text-align: center; display: grid; gap: 14px; justify-items: center; }
.gate h2 { font-size: 18px; }
.gate p { color: var(--muted); }
.gate .btn { text-decoration: none; }
.chip.user { background: var(--run-bg); color: var(--run); gap: 10px; }
/* Admin button in the header */
.chip.admin { cursor: pointer; gap: 7px; padding: 4px 12px 4px 9px; border: 1px solid var(--line); background: var(--panel);
  color: var(--text); font: inherit; font-size: 12.5px; font-weight: 600; transition: background .15s, border-color .15s, box-shadow .15s; }
.chip.admin svg { width: 15px; height: 15px; flex: none; color: var(--accent); }
.chip.admin:hover { background: var(--hover); border-color: var(--accent); }
.chip.admin[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.chip.admin[aria-pressed="true"] svg { color: inherit; }
.chip .badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--fail); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; animation: pulse 1.8s ease-in-out infinite; }

/* Admin page */
.admin-panel { max-width: 860px; margin: 24px auto; display: grid; gap: 22px; padding: 22px; }
.admin-head { display: flex; gap: 14px; align-items: center; }
.admin-head .shield { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--run-bg); color: var(--accent); flex: none; }
.admin-head .shield svg { width: 22px; height: 22px; }
.admin-head h2 { font-size: 19px; line-height: 1.2; }
.admin-head p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.admin-note { display: flex; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); font-size: 13px; }
.admin-note svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.admin-panel .msg { min-height: 0; padding: 8px 12px; border-radius: 8px; font-weight: 500; }
.admin-panel .msg.ok { background: var(--pass-bg); } .admin-panel .msg.err { background: var(--fail-bg); }
.sec-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.sec-title .count { padding: 0 8px; border-radius: 999px; background: var(--idle-bg); color: var(--idle); font-size: 11.5px; line-height: 18px; letter-spacing: 0; }
.sec-title .count.hot { background: var(--fail); color: #fff; }
.admin-panel .rows { display: grid; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.admin-panel .row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 10px 14px; background: var(--panel); }
.admin-panel .row + .row { border-top: 1px solid var(--line); }
.admin-panel .row:hover { background: var(--hover); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 700; font-size: 14px; color: #fff; text-transform: uppercase; }
.admin-panel .who { flex: 1 1 180px; min-width: 0; display: grid; line-height: 1.3; }
.admin-panel .who b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-panel .who small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { padding: 1px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--idle-bg); color: var(--idle); white-space: nowrap; }
.tag.admin { background: var(--run-bg); color: var(--run); } .tag.you { background: var(--pass-bg); color: var(--pass); }
.row-actions { display: flex; gap: 6px; margin-left: auto; }
.admin-panel .empty { padding: 18px 14px; text-align: center; color: var(--muted); font-size: 13px; background: var(--panel); }
.admin-panel .add { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.admin-panel .add .field { position: relative; flex: 1 1 220px; }
.admin-panel .add .field span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.admin-panel .add input { width: 100%; padding: 9px 11px 9px 28px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.admin-panel .add input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.chip.user { padding-right: 4px; }
.chip.user .signout { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; font-size: 12.5px; font-weight: 600; }
.chip.user .signout svg { width: 14px; height: 14px; }
.chip.user .signout:hover { background: var(--fail-bg); color: var(--fail); border-color: var(--fail); }
.chip.user .link { background: none; border: 0; padding: 0; cursor: pointer; color: inherit; text-decoration: underline; font: inherit; }
