:root {
  --ink: #0e1a1c;
  --ink-2: #1b2a2d;
  --bg: #f4f5f2;
  --card: #ffffff;
  --line: #e2e6e1;
  --line-2: #eef0ec;
  --text: #172124;
  --muted: #67747a;
  --teal: #0f766e;
  --teal-dark: #0b5d57;
  --teal-soft: #e6f3f1;
  --amber: #f2a20c;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 26, .05), 0 1px 1px rgba(16, 24, 26, .03);
  --sans: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 var(--sans); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 26px; font-weight: 650; letter-spacing: -.01em; }
h1.serif, .serif { font-family: var(--serif); font-weight: 600; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; margin: 18px 0 8px; }
code { font: 12.5px var(--mono); background: var(--line-2); padding: 1px 5px; border-radius: 4px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.strong { font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.row { display: flex; align-items: center; }
.row.gap { gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; gap: 10px; }
.row.end { justify-content: flex-end; }
.top-gap { margin-top: 14px; }
.spacer { flex: 1; }
.clip { max-width: 420px; overflow: hidden; text-overflow: ellipsis; }

/* ---------- top bar */
.topbar { display: flex; align-items: center; gap: 28px; padding: 0 24px; height: 60px; background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text small { color: #9fb0b3; font-size: 11px; letter-spacing: .02em; }
.logo { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 7px; background: var(--amber); color: var(--ink); font-weight: 800; font-size: 13px; letter-spacing: .02em; }
.logo.big { width: 46px; height: 46px; font-size: 17px; border-radius: 10px; }
.tabs { display: flex; gap: 4px; height: 100%; }
.tabs a { display: flex; align-items: center; gap: 6px; padding: 0 12px; color: #c4d0d2; font-weight: 550; border-bottom: 2px solid transparent; }
.tabs a:hover { color: #fff; text-decoration: none; }
.tabs a.active { color: #fff; border-bottom-color: var(--amber); }
.count { background: var(--amber); color: var(--ink); border-radius: 999px; font-size: 11px; font-weight: 750; padding: 0 7px; line-height: 18px; }
.me { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.me form { margin: 0; }
.avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--teal); color: #fff; font-weight: 700; font-size: 12px; }
.me-name { color: #dfe7e8; font-weight: 550; }
.demo-banner { background: #fff6df; border-bottom: 1px solid #f1dfaa; color: #6b4a06; padding: 8px 24px; font-size: 13px; }
.demo-banner a { color: #8a5a00; font-weight: 650; text-decoration: underline; }

/* ---------- layout */
.page { max-width: 1280px; margin: 0 auto; padding: 26px 24px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.crumbs { color: var(--muted); font-size: 12.5px; margin-bottom: 6px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.card > h2 { margin-bottom: 6px; }
.card-title { padding: 16px 20px 12px; }
.card .muted { margin-top: 2px; }
.pad { padding: 4px 20px 18px; }
.note { background: var(--teal-soft); border: 1px solid #cfe7e3; border-radius: 8px; padding: 10px 12px; color: #1f4b47; }

.flash { border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; font-weight: 500; }
.flash.ok { background: #e8f6ec; color: #14532d; border: 1px solid #c6e8d1; }
.flash.err { background: #fdecec; color: #7f1d1d; border: 1px solid #f5c9c9; }

/* ---------- buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid transparent; font: 600 13.5px var(--sans); cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.btn.small { height: 30px; padding: 0 11px; font-size: 12.5px; }
.btn.block { width: 100%; height: 42px; }
.btn.primary { background: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-dark); }
.btn.primary:disabled { background: #9cc5c0; cursor: not-allowed; }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--text); }
.btn.ghost:hover { border-color: #c5ccc6; background: #fafbf9; }
.btn.ghost-dark { background: transparent; border-color: #3a4a4d; color: #dfe7e8; }
.btn.ghost-dark:hover { border-color: #6a7c80; }
.btn.danger { background: #b91c1c; color: #fff; }
.btn.danger:hover { background: #991b1b; }
.btn.danger-ghost { background: #fff; border-color: #f1c9c9; color: #b91c1c; }

label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 12.5px; color: #35454a; }
label.check, .check { flex-direction: row; align-items: center; gap: 8px; font-weight: 550; }
label.check.tall { align-self: end; min-height: 38px; flex-wrap: wrap; }
label.inline { flex-direction: row; align-items: center; gap: 8px; }
input, select, textarea { font: 14px var(--sans); color: var(--text); background: #fff; border: 1px solid #d6dbd5; border-radius: 8px; padding: 8px 10px; min-height: 38px; width: 100%; }
input[type=checkbox] { width: 16px; height: 16px; min-height: 0; accent-color: var(--teal); padding: 0; }
select[multiple] { padding: 4px; min-height: 76px; }
textarea { min-height: 120px; resize: vertical; font-family: var(--mono); font-size: 13px; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(15, 118, 110, .25); border-color: var(--teal); }
.help { font-weight: 400; color: var(--muted); font-size: 12px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px 16px; margin-top: 12px; }
.form-grid .span2 { grid-column: span 2; }
.form-grid .actions { grid-column: 1 / -1; display: flex; gap: 10px; }

/* ---------- tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 650; padding: 10px 14px; background: #fafbf9; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fbfcfa; }
.table.clickable tbody tr[data-href] { cursor: pointer; }
.table .w1 { width: 1%; }
.table .empty { text-align: center; color: var(--muted); padding: 36px 14px; }
.toolbar { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-bottom: 1px solid var(--line); background: #fff; flex-wrap: wrap; }
.toolbar select { width: auto; }

.filters .filter-grid { display: grid; grid-template-columns: 1.3fr repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--line-2); border-radius: 999px; padding: 1px 9px; font-size: 12px; margin: 1px 4px 1px 0; color: #3b4b50; }
.chip.big { padding: 4px 6px 4px 12px; font-size: 13px; margin: 0 6px 6px 0; }
.chip .x { border: 0; background: transparent; cursor: pointer; font-size: 16px; color: var(--muted); padding: 0 4px; }
.tag { display: inline-block; background: #eef0f6; color: #36405a; border-radius: 5px; padding: 2px 8px; font-size: 12px; font-weight: 550; white-space: nowrap; }
.chips-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.filter-chip { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: #3b4b50; font-weight: 550; font-size: 13px; }
.filter-chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.filter-chip:hover { text-decoration: none; border-color: #c5ccc6; }

/* ---------- status pills */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 650; white-space: nowrap; border: 1px solid transparent; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.s-succeeded { background: #e8f6ec; color: #15803d; border-color: #cbead5; }
.s-running { background: #e9f0ff; color: #1d4ed8; border-color: #cddbff; }
.s-running::before { animation: blink 1s infinite; }
.s-queued { background: #eef1f6; color: #475569; }
.s-needs_review { background: #fdf3e1; color: #b45309; border-color: #f4dfb5; }
.s-failed { background: #fdecec; color: #b91c1c; border-color: #f6cccc; }
.s-stopped { background: #eef1f4; color: #475569; }
.s-skipped { background: #f6f7f5; color: #6b7779; border: 1px dashed #d5dad4; }
.s-pending, .s-not_run { background: transparent; color: #8a969a; }
.s-pending::before, .s-not_run::before { background: transparent; border: 1px solid currentColor; }
@keyframes blink { 50% { opacity: .25; } }

/* ---------- run page */
.run-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 18px; }
.run-grid .card { margin-bottom: 18px; }
.meta dl { display: grid; grid-template-columns: 120px 1fr; gap: 9px 14px; margin: 0; }
.meta dt { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 650; padding-top: 2px; }
.meta dd { margin: 0; word-break: break-all; }
.review-box h2 { margin-bottom: 8px; }
.review-box .reason { font-weight: 550; background: #fdf6e8; border-left: 3px solid #e3a008; padding: 10px 12px; border-radius: 6px; margin: 0 0 10px; }
.review-box.failed .reason { background: #fdf0f0; border-left-color: #dc2626; }
.review-box.ok { border-left: 4px solid #16a34a; }
.review-box.live { border-left: 4px solid #2563eb; }

.stages { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.stage { border-bottom: 1px solid var(--line-2); }
.stage:last-child { border-bottom: 0; }
.stage-row { display: grid; grid-template-columns: 44px 1fr auto 64px 28px; align-items: center; gap: 12px; padding: 12px 18px; cursor: default; }
.stage.has-log .stage-row { cursor: pointer; }
.stage .num { font: 12px var(--mono); color: var(--muted); }
.stage-name { font-weight: 650; }
.stage-detail { color: var(--muted); font-size: 12.5px; margin-top: 2px; word-break: break-word; }
.stage .dur { font: 12px var(--mono); color: var(--muted); text-align: right; }
.stage.st-running { background: linear-gradient(90deg, #eef3ff 0, #fff 60%); box-shadow: inset 3px 0 0 #2563eb; }
.stage.st-needs_review { background: #fffaf0; box-shadow: inset 3px 0 0 #e3a008; }
.stage.st-failed { background: #fff6f6; box-shadow: inset 3px 0 0 #dc2626; }
.stage.st-not_run .stage-name, .stage.st-pending .stage-name { color: #8a969a; font-weight: 550; }
.log-toggle { border: 0; background: transparent; cursor: pointer; color: var(--muted); font-size: 14px; transition: transform .15s; }
.stage.open .log-toggle { transform: rotate(180deg); }
.log { display: none; margin: 0 18px 14px 74px; max-height: 360px; overflow: auto; background: #0f1a1c; color: #d4e0e2; border-radius: 8px; padding: 12px 14px; font: 12px/1.55 var(--mono); white-space: pre-wrap; word-break: break-word; }
.stage.open .log { display: block; }
.conf { display: inline-flex; align-items: center; gap: 8px; }
.conf .bar { width: 64px; height: 6px; background: var(--line-2); border-radius: 3px; overflow: hidden; }
.conf .bar i { display: block; height: 100%; }

/* ---------- admin */
.rows { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.rowform { display: grid; grid-template-columns: 1.1fr 1.3fr .7fr .7fr 1fr auto; gap: 10px; align-items: center; }
.rowform.head { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 650; }
.stat-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.stat { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px; padding: 10px 16px; min-width: 110px; color: var(--text); }
.stat strong { font-size: 22px; }
.stat span { color: var(--muted); font-size: 12px; text-transform: capitalize; }
.stat:hover { text-decoration: none; border-color: #c5ccc6; }

/* ---------- auth */
body.auth { background: radial-gradient(1200px 600px at 15% 0%, #1f5f5a 0, transparent 60%), linear-gradient(160deg, #0e1a1c 0%, #12302f 55%, #0f766e 140%); min-height: 100vh; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 30px 16px; }
.auth-wrap > .flash { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 5; max-width: 90vw; }
.auth-card { width: 100%; max-width: 420px; background: #fff; border-radius: 14px; padding: 28px; box-shadow: 0 30px 60px rgba(0, 0, 0, .35); }
.auth-brand { display: flex; gap: 14px; align-items: center; margin-bottom: 20px; }
.auth-brand h1 { font-family: var(--serif); font-size: 24px; }
.auth-brand p { margin: 2px 0 0; font-size: 13px; }
.auth-foot { color: var(--muted); font-size: 13px; margin: 18px 0 0; text-align: center; }
.ticks { margin: 0 0 18px; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 13px; color: #35454a; }
.ticks li::before { content: "✓"; color: var(--teal); font-weight: 800; margin-right: 8px; }

@media (max-width: 960px) {
  .topbar { height: auto; flex-wrap: wrap; gap: 8px 16px; padding: 10px 16px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; height: 40px; }
  .me-name { display: none; }
  .page { padding: 18px 14px 50px; }
  .filters .filter-grid { grid-template-columns: 1fr 1fr; }
  .run-grid { grid-template-columns: 1fr; }
  .rowform { grid-template-columns: 1fr 1fr; }
  .rowform.head { display: none; }
  .form-grid .span2 { grid-column: auto; }
  .stage-row { grid-template-columns: 30px 1fr auto; }
  .stage .dur, .log-toggle, .log-toggle-spacer { display: none; }
  .log { margin-left: 18px; }
}
