:root {
  --bg: #f4f6f9; --panel: #ffffff; --ink: #1d2733; --muted: #66727f; --line: #d9dee5;
  --accent: #1f5f8b; --accent-ink: #ffffff; --accent-soft: #e3eef7; --danger: #b3261e; --ok: #1b7f4b; --warn: #a66b00;
  --mono: ui-monospace, Consolas, "Cascadia Mono", Menlo, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121619; --panel: #1b2126; --ink: #e6ebf0; --muted: #9aa6b2; --line: #313a43; --accent: #5aa0d8; --accent-ink: #0d1116; --accent-soft: #1f2f3d; }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font: 14px/1.45 var(--sans); color: var(--ink); background: var(--bg); }
a { color: var(--accent); }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 14px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
button, input, select, textarea { font: inherit; color: inherit; }
input[type=text], input[type=date], input[type=number], input[type=password], input[type=search], select, textarea {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
textarea { min-height: 90px; font-family: var(--mono); font-size: 12.5px; }
button { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--danger); }
button.link { border: none; background: none; padding: 2px 4px; color: var(--accent); text-decoration: underline; }
button:disabled { opacity: .5; cursor: default; }
label { display: block; margin-bottom: 8px; }
label > span.lbl, .lbl { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.check { display: inline-flex; align-items: center; gap: 6px; margin: 0 14px 6px 0; }
.check input { width: auto; }

header.top { background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 20px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; position: sticky; top: 0; z-index: 5; }
header.top nav { display: flex; gap: 4px; flex-wrap: wrap; }
header.top nav button { border: none; background: none; padding: 6px 12px; border-radius: 6px; }
header.top nav button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
header.top .spacer { flex: 1; }
header.top form { margin: 0; }
main { max-width: 1280px; margin: 0 auto; padding: 16px 20px 60px; }
section.view { display: none; }
section.view.active { display: block; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
.grid { display: grid; gap: 10px 16px; }
.grid.c2 { grid-template-columns: 1fr 1fr; }
.grid.c3 { grid-template-columns: 1fr 1fr 1fr; }
.grid.c4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; } }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: 1px solid transparent; border-bottom: none; background: none; border-radius: 8px 8px 0 0; padding: 8px 14px; margin-bottom: -1px; }
.tabs button.active { background: var(--panel); border-color: var(--line); font-weight: 600; color: var(--accent); }
.src { display: none; }
.src.active { display: block; }

.listbox { border: 1px solid var(--line); border-radius: 6px; background: var(--panel); max-height: 260px; overflow: auto; padding: 4px 6px; }
.listbox label { display: flex; gap: 6px; align-items: flex-start; margin: 0; padding: 2px 0; font-size: 13px; cursor: pointer; }
.listbox label input { width: auto; margin-top: 3px; }
.listbox .grp { font-size: 11px; text-transform: uppercase; color: var(--muted); margin: 6px 0 2px; letter-spacing: .04em; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip { background: var(--accent-soft); color: var(--accent); border-radius: 12px; padding: 1px 8px; font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
.chip button { border: none; background: none; padding: 0; color: inherit; font-size: 14px; line-height: 1; }
.toolbar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.toolbar input[type=search] { flex: 1; min-width: 160px; }
.toolbar button { padding: 3px 8px; font-size: 12px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.nowrap { white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--accent-soft); }
.status { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; background: var(--accent-soft); color: var(--accent); }
.status.done { background: #e2f3e8; color: var(--ok); }
.status.failed, .status.interrupted { background: #fbe4e2; color: var(--danger); }
.status.cancelled { background: #f1e6d0; color: var(--warn); }
.status.running { background: #fff3c4; color: #7a5a00; }
@media (prefers-color-scheme: dark) {
  .status.done { background: #17331f; } .status.failed, .status.interrupted { background: #3b1d1b; } .status.cancelled { background: #3a2f16; } .status.running { background: #3a3414; color: #e8cf6a; }
}
.progress { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 6px 0; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .3s; }
pre.log { background: #0f1419; color: #d7e0e8; font: 12px/1.4 var(--mono); padding: 10px; border-radius: 8px; max-height: 420px; overflow: auto; white-space: pre-wrap; word-break: break-word; margin: 0; }
.error { color: var(--danger); background: #fbe4e2; border: 1px solid #f0b9b4; border-radius: 6px; padding: 8px 10px; margin: 8px 0; }
.notice { background: var(--accent-soft); border-radius: 6px; padding: 8px 10px; margin: 8px 0; }
.hidden { display: none !important; }
details summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }
.files li { margin: 2px 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 2px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.preview { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; max-height: 60vh; overflow: auto; white-space: pre-wrap; font: 13px/1.5 var(--sans); }
.help p, .help li { max-width: 900px; }
.help code { font-family: var(--mono); background: var(--accent-soft); padding: 0 4px; border-radius: 4px; }

body.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px 30px; width: min(420px, 92vw); }
.login-card h1 { margin-bottom: 4px; }
.login-card form { margin-top: 16px; }
.login-card button { width: 100%; margin-top: 6px; padding: 9px; }
