:root {
  --bg: #f6f7f9; --panel: #ffffff; --text: #1d2330; --muted: #667085; --border: #e2e5ea;
  --accent: #2f6fed; --accent-text: #ffffff; --danger: #c93a3a; --ok: #1f8a4c; --warn: #b7791f;
  --code-bg: #f1f3f6; --add: #e6f6ec; --del: #fdecec; --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151b; --panel: #1a1e26; --text: #e6e9ef; --muted: #98a2b3; --border: #2b313c;
    --accent: #5b8def; --accent-text: #0b0f16; --danger: #f07070; --ok: #4cc27f; --warn: #e0a84a;
    --code-bg: #141821; --add: #173322; --del: #3a1c1c; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12151b; --panel: #1a1e26; --text: #e6e9ef; --muted: #98a2b3; --border: #2b313c;
  --accent: #5b8def; --accent-text: #0b0f16; --danger: #f07070; --ok: #4cc27f; --warn: #e0a84a;
  --code-bg: #141821; --add: #173322; --del: #3a1c1c; --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, "Segoe UI", sans-serif; }
[hidden] { display: none !important; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; }
a { color: var(--accent); }
code, pre, .mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12.5px; }
pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: 6px; padding: 12px; overflow: auto; max-height: 520px; margin: 8px 0; white-space: pre-wrap; word-break: break-word; }
.muted { color: var(--muted); }
.error { color: var(--danger); }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 200px; flex: none; background: var(--panel); border-right: 1px solid var(--border); padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 600; padding: 0 8px 14px; }
.sidebar a { padding: 7px 10px; border-radius: 6px; color: var(--text); text-decoration: none; }
.sidebar a:hover { background: var(--bg); }
.sidebar a.active { background: var(--accent); color: var(--accent-text); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.strip { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
main { flex: 1; min-width: 0; padding: 24px; max-width: 1200px; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.stat { font-size: 22px; font-weight: 600; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-weight: 500; color: var(--muted); font-size: 12px; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--bg); }
.table-wrap { overflow-x: auto; }
.objective { max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board { display: grid; grid-template-columns: repeat(5, minmax(190px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.lane { min-height: 180px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.task-card { display: flex; width: 100%; flex-direction: column; align-items: flex-start; gap: 7px; margin-bottom: 8px; text-align: left; }
.task-card small { color: var(--muted); }
.task-list { display: flex; flex-direction: column; gap: 7px; }
.task-list a { display: flex; gap: 9px; align-items: center; text-decoration: none; }

label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; margin-bottom: 12px; }
label.inline { flex-direction: row; align-items: center; gap: 8px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; width: 100%; }
input[type=checkbox] { width: auto; }
textarea { min-height: 90px; resize: vertical; font-family: Consolas, monospace; font-size: 12.5px; }
textarea.plain { font-family: inherit; font-size: 14px; }
.hint { font-weight: 400; font-size: 12px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0 16px; }

button { font: inherit; border: 1px solid var(--border); background: var(--panel); color: var(--text); border-radius: 6px; padding: 7px 12px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.danger { color: var(--danger); }
button.link { border: none; background: none; color: var(--accent); padding: 0; text-align: left; }
button:disabled { opacity: .5; cursor: default; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; border: 1px solid var(--border); white-space: nowrap; }
.s-done { color: var(--ok); border-color: var(--ok); }
.s-failed, .s-blocked, .s-uncertain { color: var(--danger); border-color: var(--danger); }
.s-running, .s-verifying, .s-review, .s-queued { color: var(--accent); border-color: var(--accent); }
.s-retry_pending { color: var(--warn); border-color: var(--warn); }
.s-cancelled { color: var(--muted); }
.notice { border-left: 3px solid var(--warn); padding: 8px 12px; background: var(--bg); border-radius: 4px; margin-bottom: 12px; }
.notice.danger { border-color: var(--danger); }

.diff .add { background: var(--add); display: block; }
.diff .del { background: var(--del); display: block; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 6px 0; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: 150px 170px 1fr; gap: 8px; }
.timeline .payload { color: var(--muted); font-size: 12px; word-break: break-word; }

.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 10; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--ok); border-radius: 6px; padding: 10px 14px; box-shadow: 0 4px 12px rgba(0,0,0,.12); }
.toast.error { border-left-color: var(--danger); color: var(--text); }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; }

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 8px 16px; }
  .brand { padding: 0 8px 0 0; }
  .sidebar-foot { margin: 0 0 0 auto; flex-direction: row; }
  .strip { display: none; }
  main { padding: 16px; }
  .timeline li { grid-template-columns: 1fr; }
}

/* Control panel */
.stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat { margin: 0; }
.stat-value { font-size: 1.6em; font-weight: 600; margin: 4px 0; }
.stat.warn .stat-value { color: #b45309; }
.progress { height: 8px; background: rgba(127, 127, 127, .2); border-radius: 4px; overflow: hidden; margin: 10px 0; }
.progress > div { height: 100%; background: #16a34a; }
pre.diff { max-height: 520px; overflow: auto; font-size: 12px; }

/* Questions to the operator */
.s-awaiting_input { color: var(--warn); border-color: var(--warn); }
.card.ask { border-left: 3px solid var(--warn); }
.question { margin: 12px 0 16px; }
.choices { display: grid; gap: 8px; margin-bottom: 8px; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer; }
.choice.selected { border-color: var(--accent); }
.choice input { margin-top: 3px; }
.choice-label { font-weight: 600; }
.question textarea { width: 100%; box-sizing: border-box; }
.analysis { border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; margin: 12px 0; }
.analysis h3 { margin-top: 0; }

/* Dashboard layout and readable data density */
:root {
  --font-ui: "Segoe UI Variable", Inter, "Segoe UI", Roboto, Arial, sans-serif;
  --radius-card: 14px;
  --shadow-card: 0 8px 26px rgba(16, 24, 40, .045);
}
body { font-family: var(--font-ui); font-size: 14px; line-height: 1.55; letter-spacing: .005em; }
button, input, select, textarea { font-family: var(--font-ui); }
code, pre, .mono { font-family: "Cascadia Code", Consolas, "SFMono-Regular", monospace; }
main { max-width: none; width: 100%; padding: clamp(22px, 2.4vw, 42px); }
.sidebar { width: 224px; padding: 20px 14px; gap: 4px; }
.brand { font-size: 15px; letter-spacing: -.02em; padding-bottom: 20px; }
.sidebar a { padding: 9px 12px; border-radius: 8px; }
.dashboard { width: 100%; max-width: 1920px; margin: 0 auto; }
.dashboard-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 0 0 24px; }
.dashboard-header h1 { font-size: clamp(28px, 2vw, 36px); line-height: 1.12; letter-spacing: -.045em; margin: 0; }
.eyebrow { color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: .13em; margin: 0 0 8px; }
.dashboard-lede { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.dashboard-updated, .count-pill { color: var(--muted); font-size: 12px; white-space: nowrap; }
.count-pill { padding: 5px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; }
.dashboard .card { border-radius: var(--radius-card); padding: clamp(16px, 1.35vw, 22px); box-shadow: var(--shadow-card); margin-bottom: 18px; }
.dashboard .card h2 { font-size: 17px; letter-spacing: -.02em; margin-bottom: 6px; }
.dashboard .stats { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 14px; margin-bottom: 22px; }
.dashboard .stat { min-height: 126px; display: flex; flex-direction: column; justify-content: center; }
.dashboard .stat-value { font-size: clamp(24px, 2vw, 32px); line-height: 1.15; letter-spacing: -.045em; margin: 8px 0 4px; font-variant-numeric: tabular-nums; }
.dashboard .stat .muted { font-size: 13px; }
.dashboard .stat.warn { border-color: color-mix(in srgb, var(--warn) 42%, var(--border)); }
.dashboard .stat.warn .stat-value { color: var(--warn); }
.dashboard .card-heading { align-items: center; margin-bottom: 14px; }
.dashboard .card-heading h2 { margin: 0; }
.dashboard .card-heading .hint { margin: 4px 0 0; }
.dashboard table { min-width: 780px; }
.dashboard th { text-transform: uppercase; letter-spacing: .075em; font-size: 10px; font-weight: 700; padding: 10px 11px; white-space: nowrap; }
.dashboard td { padding: 11px; }
.dashboard tbody tr:last-child td { border-bottom: 0; }
.dashboard .recent-card .table-wrap { border: 1px solid var(--border); border-radius: 10px; }
.dashboard .recent-card table { min-width: 1120px; }
.recent-row td { vertical-align: middle; }
.recent-row .date-cell { min-width: 148px; white-space: nowrap; font-size: 12px; }
.recent-row .recent-task { min-width: 180px; max-width: 310px; }
.recent-row .recent-task a { display: block; font-weight: 600; color: var(--text); text-decoration: none; }
.recent-row .recent-task a:hover { color: var(--accent); }
.recent-row .model-cell { max-width: 210px; overflow-wrap: anywhere; font-size: 12px; }
.numeric-cell { text-align: right !important; white-space: nowrap; font-variant-numeric: tabular-nums; }
.recent-error-type { margin-top: 4px; }
.run-details { min-width: 110px; }
.run-details > summary { color: var(--accent); font-size: 12px; cursor: pointer; white-space: nowrap; }
.run-detail-body { position: relative; z-index: 2; min-width: 300px; max-width: min(560px, 70vw); padding: 14px; margin: 8px 0 4px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); box-shadow: 0 12px 32px rgba(0, 0, 0, .12); white-space: normal; }
.run-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; color: var(--muted); font-size: 12px; }
.run-meta code { color: var(--text); }
.usage-breakdown { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.usage-breakdown span { display: grid; gap: 2px; min-width: 90px; padding: 8px 10px; background: var(--bg); border-radius: 8px; font-size: 12px; font-variant-numeric: tabular-nums; }
.usage-breakdown b { color: var(--muted); font-size: 10px; font-weight: 600; }
.run-summary { margin: 12px 0 0; }
.run-error { margin: 12px 0 0; color: var(--danger); white-space: pre-wrap; overflow-wrap: anywhere; }
.run-files { margin: 6px 0 0; padding-left: 20px; max-height: 180px; overflow: auto; }
.run-files li { margin: 3px 0; overflow-wrap: anywhere; }
.dashboard .notice { border-radius: 10px; padding: 12px 16px; }
@media (min-width: 1800px) {
  .dashboard .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .dashboard .board { grid-template-columns: repeat(5, minmax(220px, 1fr)); }
}
@media (max-width: 980px) {
  .sidebar { width: 204px; }
  .dashboard-header { align-items: flex-start; }
}
@media (max-width: 760px) {
  main { padding: 16px; }
  .sidebar { width: auto; }
  .dashboard-header { flex-direction: column; gap: 10px; margin-bottom: 18px; }
  .dashboard-updated { white-space: normal; }
  .dashboard .stats { grid-template-columns: repeat(auto-fit, minmax(min(100%, 155px), 1fr)); gap: 10px; }
  .dashboard .stat { min-height: 108px; }
  .dashboard .card { padding: 14px; }
  .dashboard .card-heading { align-items: flex-start; }
  .run-detail-body { position: static; min-width: 260px; max-width: calc(100vw - 64px); }
}

/* Stage assignments on the executors page: one horizontal block per stage. */
.stage-rows { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.stage-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(220px, 1.2fr) minmax(0, 1.5fr); gap: 16px;
  align-items: start; padding: 12px 14px; border: 1px solid var(--border, #333); border-radius: 8px; }
@media (max-width: 900px) { .stage-row { grid-template-columns: 1fr; } }

/* Options and flags in question cards: control on the left, text on the right (overrides the column label). */
label.choice { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 400; }
label.choice > input { flex: 0 0 auto; width: auto; margin-top: 3px; }
