:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --text: #16181d;
  --muted: #646b78;
  --accent: #3b5bdb;
  --accent-text: #ffffff;
  --ok: #2b8a3e;
  --warn: #b7791f;
  --bad: #c92a2a;
  --info: #1971c2;
  --code-bg: #f3f4f7;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1e222b;
    --border: #2a2f3a;
    --text: #e7e9ee;
    --muted: #9099a8;
    --accent: #5c7cfa;
    --accent-text: #ffffff;
    --ok: #51cf66;
    --warn: #fcc419;
    --bad: #ff6b6b;
    --info: #4dabf7;
    --code-bg: #12151b;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
h2 { font-size: 15px; margin: 0 0 10px; font-weight: 600; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
pre, code { font-family: var(--mono); font-size: 12.5px; }

.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; letter-spacing: -0.01em; }
.logo { width: 18px; height: 18px; border-radius: 5px; background: linear-gradient(135deg, var(--accent), var(--info)); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 24px; display: grid; gap: 10px; box-shadow: var(--shadow); }
.login-card .brand { font-size: 18px; margin-bottom: 8px; }

/* header */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.tabs { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs button { background: none; border: 0; padding: 7px 12px; border-radius: 8px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button:hover { color: var(--text); background: var(--surface-2); }
.tabs button[aria-selected="true"] { color: var(--text); background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); font-weight: 600; }

main { max-width: 1180px; margin: 0 auto; padding: 16px; }
.foot { max-width: 1180px; margin: 0 auto; padding: 0 16px 24px; color: var(--muted); font-size: 12px; }

/* controls */
input[type="password"], input[type="text"], select, textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; outline: none;
}
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
label { font-size: 13px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
button { cursor: pointer; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); padding: 8px 14px; }
button:hover { background: var(--surface-2); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); }
button.ghost { background: none; }
button.small { padding: 5px 10px; font-size: 13px; }
button:disabled { opacity: 0.5; cursor: default; }
.error { color: var(--bad); min-height: 1em; margin: 0; font-size: 13px; }

/* layout */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.panel, .card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.panel { margin-bottom: 14px; }
#job-form { display: grid; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.row label { flex: none; }
.row.between { justify-content: space-between; flex-wrap: wrap; }
.split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
@media (min-width: 900px) { .split.has-detail { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); } }

.card.click { cursor: pointer; transition: border-color 0.12s; }
.card.click:hover { border-color: var(--accent); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.big { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
.muted { color: var(--muted); }
.small-text { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; vertical-align: 1px; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; white-space: nowrap; border: 1px solid currentColor; }
.pill.queued { color: var(--muted); }
.pill.running { color: var(--info); }
.pill.done { color: var(--ok); }
.pill.failed { color: var(--bad); }
.pill.cancelled { color: var(--warn); }

/* lists */
.list { display: grid; gap: 6px; align-content: start; }
.item { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 9px 12px; cursor: pointer; text-align: left; width: 100%; }
.item:hover { border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); background: var(--surface); }
.item.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.item .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { grid-column: 2 / 4; font-size: 12px; color: var(--muted); }
.item .when { font-size: 12px; color: var(--muted); white-space: nowrap; }
.item .expand { grid-column: 1 / 4; }
.empty { color: var(--muted); padding: 24px; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius); }

.detail { position: relative; min-width: 0; }
.detail .actions { display: flex; gap: 8px; }
pre.box { background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; overflow: auto; white-space: pre-wrap; word-break: break-word; margin: 6px 0 12px; max-height: 340px; }
pre.box.log { max-height: 420px; }
.section-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-top: 10px; }

/* dialog + markdown */
dialog { width: min(820px, calc(100vw - 24px)); max-height: calc(100vh - 48px); border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); padding: 0; }
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.dialog-head { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
.dialog-head h2 { margin: 0; }
.md { padding: 4px 18px 18px; overflow-wrap: anywhere; }
.md h1, .md h2, .md h3, .md h4 { margin: 16px 0 6px; line-height: 1.3; }
.md h1 { font-size: 20px; } .md h2 { font-size: 17px; } .md h3 { font-size: 15px; }
.md p { margin: 6px 0; }
.md ul, .md ol { padding-left: 22px; margin: 6px 0; }
.md code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; }
.md pre { background: var(--code-bg); border: 1px solid var(--border); padding: 10px; border-radius: 8px; overflow: auto; }
.md pre code { background: none; padding: 0; }
.md a { color: var(--accent); }
.md blockquote { margin: 6px 0; padding-left: 12px; border-left: 3px solid var(--border); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--border); }

@media (max-width: 600px) {
  .top { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .tabs { order: 3; flex-basis: 100%; }
  .brand { flex: 1; }
  main { padding: 12px; }
  .grid { grid-template-columns: 1fr; }
}
.mt { margin-top: 14px; }
