:root {
  --bg: #f7f7f5; --fg: #1d1d1f; --muted: #6b6b70; --line: #e2e2de; --card: #fff;
  --accent: #2f6fde; --ok: #1f8a4c; --bad: #c4362c; --warn: #b7791f; --run: #2f6fde; --idle: #8a8a90;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151517; --fg: #ececee; --muted: #9a9aa2; --line: #2c2c31; --card: #1d1d21;
          --accent: #6b9cff; --ok: #4cc27c; --bad: #ff6b5f; --warn: #e3a948; --run: #6b9cff; --idle: #77777f; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.4 -apple-system, system-ui, "Segoe UI", sans-serif; padding: 0 16px 40px; }
body.noscroll { overflow: hidden; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 17px; margin: 0; word-break: break-word; }
h3 { font-size: 14px; margin: 18px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--bad); min-height: 1em; }
button, .button, select, input { font: inherit; color: inherit; }
button, .button { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .button:hover { border-color: var(--accent); }
button.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
button.link { border: 0; background: none; padding: 4px; color: var(--muted); }
select, input { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }

.top { display: flex; align-items: baseline; gap: 12px; padding: 14px 0 10px; }
.top .logout { margin-left: auto; }
#updated.stale { color: var(--bad); }

.runners { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); margin-bottom: 12px; }
.runner { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.runner.offline { border-color: var(--bad); }
.runner-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; margin-bottom: 8px; }
.cores { display: grid; grid-template-columns: repeat(auto-fill, minmax(26px, 1fr)); gap: 4px; }
.core { position: relative; height: 38px; border-radius: 5px; background: color-mix(in srgb, var(--idle) 12%, transparent); overflow: hidden; border: 1px solid transparent; }
.core.claimed { border-color: var(--run); }
.core.outside { opacity: .45; }
.core.claimed { cursor: pointer; }
.core-fill { position: absolute; left: 0; right: 0; bottom: 0; background: color-mix(in srgb, var(--run) 55%, transparent); transition: height .6s; }
.core span { position: absolute; left: 0; right: 0; top: 2px; text-align: center; font-size: 11px; color: var(--muted); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 4px 10px; border-radius: 999px; font-size: 13px; opacity: .55; }
.chip.on { opacity: 1; border-color: currentColor; }
#f-text { flex: 1 1 180px; min-width: 0; }

.badge { display: inline-block; max-width: 22ch; overflow: hidden; text-overflow: ellipsis; vertical-align: top; border-radius: 999px; padding: 1px 8px; font-size: 12px; white-space: nowrap; border: 1px solid currentColor; }
.s-running { color: var(--run); } .s-starting { color: var(--run); } .s-queued { color: var(--warn); }
.s-done { color: var(--ok); } .s-failed, .s-lost { color: var(--bad); } .s-cancelled { color: var(--idle); }
tr.s-running, tr.s-done, tr.s-failed, tr.s-lost, tr.s-cancelled, tr.s-queued, tr.s-starting { color: inherit; }

.jobs { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.jobs th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); }
.jobs td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.jobs tbody tr { cursor: pointer; }
.jobs tbody tr:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.name { font-weight: 600; word-break: break-word; }
.kind { font-weight: 400; font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin-left: 6px; }
.id { word-break: break-all; }
.tail { font-family: ui-monospace, Menlo, monospace; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46ch; }
.prog { position: relative; height: 18px; min-width: 90px; border-radius: 4px; background: color-mix(in srgb, var(--idle) 15%, transparent); overflow: hidden; }
.prog-bar { position: absolute; top: 0; bottom: 0; left: 0; background: color-mix(in srgb, var(--ok) 45%, transparent); }
.prog span { position: relative; font-size: 11px; padding: 0 6px; line-height: 18px; }

.detail { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; justify-content: flex-end; z-index: 10; }
.detail-box { background: var(--bg); width: min(860px, 100%); height: 100%; overflow-y: auto; padding: 14px 16px 40px; box-shadow: -4px 0 20px rgba(0,0,0,.15); }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; position: sticky; top: -14px; background: var(--bg); padding: 4px 0 6px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 12px 0; }
.facts dt { color: var(--muted); } .facts dd { margin: 0; word-break: break-word; }
.dprog { max-width: 400px; margin: 8px 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
pre { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font: 12px/1.45 ui-monospace, Menlo, monospace; white-space: pre-wrap; word-break: break-word; margin: 0; }
pre.log { max-height: 55vh; overflow-y: auto; }
pre.cmd { max-height: 30vh; overflow-y: auto; }
ul.out { padding-left: 18px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; max-height: 30vh; overflow-y: auto; }

@media (max-width: 720px) {
  .jobs thead { display: none; }
  .jobs, .jobs tbody, .jobs tr, .jobs td { display: block; width: 100%; }
  .jobs { background: none; border: 0; }
  .jobs tr { background: var(--card); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; padding: 6px 0; display: grid; grid-template-columns: 1fr 1fr; }
  .jobs td { border: 0; padding: 3px 12px; }
  .jobs td.c-name { grid-column: 1 / -1; }
  .jobs td[data-l]::before { content: attr(data-l); display: block; font-size: 11px; color: var(--muted); }
  .tail { max-width: 100%; }
  .facts { grid-template-columns: 1fr 2fr; }
}

body.login { display: flex; justify-content: center; align-items: center; min-height: 100vh; }
.login-box { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 24px; width: min(360px, 100%); }
.login-box form { display: grid; gap: 10px; margin-top: 14px; }
.login-box label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
.login-box input { color: var(--fg); }
.tg { min-height: 0; margin-top: 8px; }
