:root {
  --bg: #f6f7f9; --surface: #ffffff; --text: #1b2330; --muted: #5d6879; --line: #dfe3ea;
  --accent: #2563eb; --accent-text: #ffffff; --accent-soft: #e8efff;
  --ok: #15803d; --ok-bg: #e3f6e9; --err: #b42318; --err-bg: #fde8e6;
  --warn: #92560a; --warn-bg: #fdf0d4; --run: #1d4ed8; --run-bg: #e4ecff; --idle: #4b5563; --idle-bg: #eceff3;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 40, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151c; --surface: #1a202b; --text: #e6e9ef; --muted: #9aa5b6; --line: #2c3544;
    --accent: #5b8def; --accent-text: #0b1220; --accent-soft: #1f2a44;
    --ok: #5fd08a; --ok-bg: #16301f; --err: #ff8f85; --err-bg: #3a1c1a;
    --warn: #f1c26b; --warn-bg: #3a2c12; --run: #8db0ff; --run-bg: #1c2a4d; --idle: #aab3c2; --idle-bg: #262e3b;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 1.2rem 0 .6rem; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 1.4rem 0 .6rem; }
p { margin: .5rem 0; }
code, .mono, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .err-text { color: var(--err); }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-bottom: 48px; }

.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.bar { display: flex; align-items: center; gap: 16px; min-height: 54px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; }
.nav a:hover { background: var(--idle-bg); }
.nav a[aria-current=page] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.who { display: flex; align-items: center; gap: 10px; margin: 0; }

button, .btn, select, input[type=text], input[type=number], input[type=time] {
  font: inherit; color: inherit; border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
  padding: 7px 12px; min-height: 36px;
}
button, .btn { cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { background: var(--idle-bg); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.primary:hover, .btn.primary:hover { filter: brightness(1.08); }
button.danger { background: var(--err-bg); border-color: var(--err); color: var(--err); font-weight: 600; }
button.link, button.danger-text { border: 0; background: none; padding: 4px 6px; min-height: 0; color: var(--accent); }
button.danger-text { color: var(--err); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input.code { font-family: ui-monospace, monospace; font-size: 1.2rem; letter-spacing: .15em; width: 9.5em; text-align: center; }
input.narrow { width: 5.5em; }
label { display: block; font-size: .9rem; color: var(--muted); margin: 10px 0 4px; }
label input, label select { display: block; margin-top: 4px; color: var(--text); }
label.chk { display: inline-flex; align-items: center; gap: 6px; margin: 0 10px 0 0; color: var(--text); }
label.chk input { display: inline; margin: 0; }
form.inline, .actions { display: inline-flex; gap: 8px; align-items: end; flex-wrap: wrap; margin: 0; }
form.inline label { margin: 0; }
.actions form { margin: 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 14px 0; box-shadow: var(--shadow); }
.card h2 { margin-top: 0; }
.card.alert { border-color: var(--warn); background: var(--warn-bg); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.grid .card { margin: 0; display: flex; flex-direction: column; }
.job header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.job h2 { font-size: 1.05rem; margin: 0; } .job h2 a { color: var(--text); text-decoration: none; }
.job h2 a:hover { text-decoration: underline; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 10px 0; font-size: .92rem; }
.facts dt { color: var(--muted); } .facts dd { margin: 0; }
.job footer { margin-top: auto; padding-top: 10px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; background: var(--idle-bg); color: var(--idle); }
.badge.s-success, .badge.s-ok { background: var(--ok-bg); color: var(--ok); }
.badge.s-failed { background: var(--err-bg); color: var(--err); }
.badge.s-running, .badge.s-starting { background: var(--run-bg); color: var(--run); }
.badge.s-warning { background: var(--warn-bg); color: var(--warn); }
.badge.s-running span:first-child { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .badge.s-running span:first-child { animation: none; } }
.tag { font-size: .75rem; padding: 1px 7px; border-radius: 6px; background: var(--idle-bg); color: var(--idle); }
.dots { display: flex; gap: 4px; margin: 4px 0 2px; }
.dot { width: 10px; height: 22px; border-radius: 3px; background: var(--idle-bg); border: 1px solid var(--line); }
.dot.s-success { background: var(--ok); border-color: var(--ok); } .dot.s-failed { background: var(--err); border-color: var(--err); }
.dot.s-running, .dot.s-starting { background: var(--run); border-color: var(--run); } .dot.s-cancelled { background: var(--idle); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table.runs { width: 100%; border-collapse: collapse; }
.runs th, .runs td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.runs th { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.runs tr:last-child td { border-bottom: 0; }
.runs td.result { max-width: 340px; }
.filters { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; margin-bottom: 12px; }
.filters label { margin: 0; }
.pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin: 16px 0; }
.crumbs { color: var(--muted); font-size: .9rem; margin: 14px 0 0; }

.flash { padding: 10px 14px; border-radius: var(--radius); margin: 12px 0; background: var(--idle-bg); }
.flash.ok { background: var(--ok-bg); color: var(--ok); } .flash.err { background: var(--err-bg); color: var(--err); }

.run-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.run-head h1 { margin-top: .6rem; }
.steps { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); margin-left: 8px; }
.step { position: relative; padding: 6px 0 14px 18px; }
.step::before { content: ""; position: absolute; left: -7px; top: 14px; width: 12px; height: 12px; border-radius: 50%; background: var(--idle); border: 2px solid var(--bg); }
.step.s-ok::before { background: var(--ok); } .step.s-failed::before { background: var(--err); } .step.s-warning::before { background: var(--warn); }
.step.s-running::before { background: var(--run); }
.step-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.note { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }
.shots { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; align-items: flex-start; }
.shots figure { margin: 0; width: 200px; }
.shots img { width: 100%; height: 130px; object-fit: cover; object-position: top; border: 1px solid var(--line); border-radius: 8px; background: var(--idle-bg); display: block; }
.shots figcaption { font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filelink { display: inline-block; padding: 4px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); text-decoration: none; font-size: .88rem; margin: 2px 6px 2px 0; }
.log pre, .code-block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; overflow: auto; max-height: 460px; white-space: pre-wrap; word-break: break-word; }
.log summary, details.add summary, details.edit summary { cursor: pointer; color: var(--accent); }
.log { margin: 18px 0; }

.sched { display: flex; flex-wrap: wrap; gap: 10px 16px; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--line); }
.sched.paused .sched-main { opacity: .65; }
.sched details.edit { flex-basis: 100%; }
.sched-fields { display: flex; flex-wrap: wrap; gap: 4px 18px; align-items: end; }
.sched-fields fieldset { border: 0; padding: 0; margin: 10px 0 0; }
.sched-fields legend { font-size: .9rem; color: var(--muted); padding: 0 0 4px; }
.sched-fields [hidden] { display: none; }
details.add, details.edit { margin-top: 10px; }
details form { padding: 6px 0; }
.plain { list-style: none; padding: 0; margin: 8px 0; } .plain li { padding: 6px 0; border-top: 1px solid var(--line); }
.spec { overflow-x: auto; } .spec table { border-collapse: collapse; } .spec th, .spec td { border: 1px solid var(--line); padding: 4px 10px; }
.spec pre { background: var(--bg); padding: 10px; border-radius: 8px; overflow: auto; }

.login { max-width: 400px; margin: 48px auto; }
.login .primary { width: 100%; justify-content: center; margin-top: 14px; }
.login input { width: 100%; }
.qr { background: #fff; padding: 10px; border-radius: 10px; width: fit-content; margin: 12px auto; }
.qr svg { width: 240px; height: 240px; display: block; }

.lightbox { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .82); display: flex; align-items: center; justify-content: center; padding: 20px; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 100%; background: #fff; border-radius: 6px; }
.lightbox .close { position: absolute; top: 10px; right: 14px; font-size: 1.6rem; line-height: 1; padding: 4px 12px; }

@media (max-width: 600px) {
  h1 { font-size: 1.35rem; }
  .grid { grid-template-columns: 1fr; }
  .shots figure { width: calc(50% - 5px); }
  .runs th:nth-child(4), .runs td:nth-child(4) { display: none; }
  .bar { padding-block: 8px; gap: 8px 12px; }
  .nav { order: 3; flex-basis: 100%; }
  .who { margin-left: auto; }
}
