:root {
  color-scheme: light dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --ink: #17202a;
  --muted: #5f6c7b;
  --border: #d8dde6;
  --accent: #126b5f;
  --ok: #1d7a46;
  --ok-bg: #e0f3e8;
  --warn: #8a5a00;
  --warn-bg: #fff1cf;
  --bad: #a73333;
  --bad-bg: #fbe1e1;
  --info: #255d9a;
  --info-bg: #e1ecf8;
  --run: #255d9a;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181d; --surface: #1c222a; --surface-2: #232a33; --ink: #e4e8ed;
    --muted: #93a0ae; --border: #323b46; --accent: #4cc2b0;
    --ok: #62d08c; --ok-bg: #173324; --warn: #f0b650; --warn-bg: #3a2d10;
    --bad: #ff8a85; --bad-bg: #3d1c1c; --info: #7db4ee; --info-bg: #19293b; --run: #7db4ee;
  }
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--ink); font-size: 14px; }
button, input, select { font: inherit; color: inherit; }
button, .link-btn {
  min-height: 32px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center;
}
button:hover, .link-btn:hover { background: var(--surface-2); }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select { min-height: 32px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); padding: 0 8px; }
a { color: var(--info); }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }

.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 10px 18px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; }
h1 { font-size: 17px; margin: 0; }
h2 { font-size: 14px; margin: 0; }
.readonly-tag { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 2px 7px; border-radius: 10px; background: var(--info-bg); color: var(--info); }
.picker { display: flex; align-items: center; gap: 8px; }
.picker select { min-width: 280px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.check { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.check input { min-height: 0; }

.content { padding: 14px 18px 40px; max-width: 1600px; margin: 0 auto; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-bottom: 14px; min-width: 0; }
.panel-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.panel-heading .pill, .panel-heading .hint { margin-left: auto; }
.hint { color: var(--muted); font-size: 12px; }
.empty { text-align: center; padding: 40px 14px; }
.two-col { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 14px; }
.stack { min-width: 0; }
@media (max-width: 1000px) { .two-col { grid-template-columns: 1fr; } .picker select { min-width: 160px; } }

.pill { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.run { background: var(--info-bg); color: var(--run); }

.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; min-width: 0; }
.card span { display: block; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.card strong { display: block; font-size: 17px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card small { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card.bad { border-color: var(--bad); } .card.warn { border-color: var(--warn); }

.problems { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.problems li { display: flex; gap: 10px; align-items: baseline; padding: 6px 10px; border-radius: 6px; background: var(--surface-2); }
.problems li.bad { background: var(--bad-bg); } .problems li.warn { background: var(--warn-bg); } .problems li.ok { background: var(--ok-bg); }
.problems .sev { font-weight: 700; font-size: 11px; text-transform: uppercase; min-width: 40px; }
.problems li.bad .sev { color: var(--bad); } .problems li.warn .sev { color: var(--warn); } .problems li.ok .sev { color: var(--ok); }
.problems .where { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.problems a.jump { cursor: pointer; text-decoration: underline; }

.gantt { position: relative; margin-bottom: 12px; }
.gantt-row { display: grid; grid-template-columns: 130px 1fr; align-items: center; gap: 8px; height: 22px; cursor: pointer; }
.gantt-row:hover { background: var(--surface-2); }
.gantt-row.sel { background: var(--info-bg); }
.gantt-label { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gantt-track { position: relative; height: 12px; background: var(--surface-2); border-radius: 3px; }
.gantt-bar { position: absolute; top: 0; height: 12px; min-width: 3px; border-radius: 3px; background: var(--ok); }
.gantt-bar.running { background: var(--run); background-image: linear-gradient(90deg, transparent 0 50%, rgba(255,255,255,.25) 50% 100%); background-size: 12px 100%; animation: slide 1s linear infinite; }
.gantt-bar.failed { background: var(--bad); }
.gantt-bar.cancelled { background: var(--warn); }
@keyframes slide { to { background-position: 12px 0; } }
.gantt-axis { display: grid; grid-template-columns: 130px 1fr; gap: 8px; font-size: 11px; color: var(--muted); }
.gantt-axis div { display: flex; justify-content: space-between; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
tr.clickable { cursor: pointer; } tr.clickable:hover { background: var(--surface-2); }

.phases { display: grid; gap: 10px; }
.phase .row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.phase .row small { color: var(--muted); }
.bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 3px; }
.bar > i { display: block; height: 100%; background: var(--run); }
.phase.done .bar > i { background: var(--ok); }
.phase.idle { opacity: .75; }

.residual-chart svg { width: 100%; height: 90px; display: block; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; margin: 8px 0 0; font-size: 13px; }
.facts dt { color: var(--muted); } .facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.facts dd.bad { color: var(--bad); font-weight: 600; } .facts dd.ok { color: var(--ok); }

.log-tools { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; gap: 5px; align-items: center; padding: 2px 9px; border-radius: 12px; border: 1px solid var(--border); font-size: 12px; cursor: pointer; user-select: none; background: var(--surface); }
.chip.on { background: var(--info-bg); border-color: var(--info); color: var(--info); }
.chip b { font-weight: 600; opacity: .8; }
.log { height: 420px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); font-family: var(--mono); font-size: 12.5px; resize: vertical; }
.ev { border-bottom: 1px solid var(--border); padding: 2px 8px; }
.ev .line { display: grid; grid-template-columns: 78px 92px 1fr; gap: 8px; cursor: pointer; align-items: baseline; }
.ev .t { color: var(--muted); } .ev .k { font-weight: 600; }
.ev.k-task_failed, .ev.k-job_failed { background: var(--bad-bg); } .ev.k-task_failed .k, .ev.k-job_failed .k { color: var(--bad); }
.ev.k-job_completed .k, .ev.k-task_finished .k { color: var(--ok); }
.ev.k-task_started .k, .ev.k-step .k { color: var(--info); }
.ev.k-job_cancelled, .ev.k-job_deleted { background: var(--warn-bg); }
.ev.hl { outline: 2px solid var(--info); }
.ev pre { margin: 4px 0 6px; padding: 6px; background: var(--surface); border-radius: 4px; overflow: auto; max-height: 280px; white-space: pre-wrap; word-break: break-word; }
details { margin: 4px 0; } summary { cursor: pointer; color: var(--muted); }
details pre { max-height: 380px; overflow: auto; background: var(--surface-2); padding: 8px; border-radius: 6px; }

.finished-list { max-height: 180px; overflow: auto; margin-top: 4px; }
.fin { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; font-size: 12.5px; border-bottom: 1px solid var(--border); }
