:root {
  --bg: #f4f6f6;
  --surface: #ffffff;
  --surface-2: #f0f3f3;
  --border: #dde3e3;
  --text: #182224;
  --muted: #5d6b6e;
  --accent: #0e6b63;
  --accent-strong: #0a524c;
  --accent-soft: #e2f1ef;
  --on-accent: #ffffff;
  --ok: #1d7a3e;
  --ok-soft: #e4f4e9;
  --warn: #8a5a00;
  --warn-soft: #fbf0d9;
  --bad: #b3261e;
  --bad-soft: #fbe6e4;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1516;
    --surface: #172022;
    --surface-2: #1e292b;
    --border: #2c3a3d;
    --text: #e6eeee;
    --muted: #9aaaad;
    --accent: #3fb5a8;
    --accent-strong: #67cbbf;
    --accent-soft: #163a37;
    --on-accent: #062522;
    --ok: #5ccf83;
    --ok-soft: #143222;
    --warn: #e9b44c;
    --warn-soft: #3a2c10;
    --bad: #f28b82;
    --bad-soft: #3d1a18;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
h1, h2, h3 { line-height: 1.25; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 16px; }
.logo {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 700; letter-spacing: .5px;
}
.env { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; font-size: 13px; color: var(--muted); }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); font-size: 12.5px; white-space: nowrap;
}
.pill.live { border-color: transparent; background: var(--bad-soft); color: var(--bad); font-weight: 600; }
.pill.safe { border-color: transparent; background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }

/* ---------- layout ---------- */
.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start;
  max-width: 1180px; margin: 0 auto; padding: 24px;
}
.steps { display: grid; gap: 16px; min-width: 0; }
.intro h1 { font-size: 26px; margin-bottom: 4px; }
.intro p { margin: 0; color: var(--muted); max-width: 60ch; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.card h2 { font-size: 16px; display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.num {
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-strong); font-size: 13px; font-weight: 700; flex: none;
}

/* ---------- choices ---------- */
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.choice {
  text-align: left; cursor: pointer; padding: 12px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); display: grid; gap: 4px; min-height: 92px;
  transition: border-color .12s, background .12s;
}
.choice:hover { border-color: var(--accent); }
.choice[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.choice[disabled] { opacity: .45; cursor: not-allowed; }
.choice[disabled]:hover { border-color: var(--border); }
.choice-title { font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.choice-desc { font-size: 13px; color: var(--muted); }
.tag {
  font-size: 11.5px; font-weight: 700; letter-spacing: .4px; padding: 1px 7px; border-radius: 5px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}

/* ---------- fields ---------- */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field-label { font-weight: 600; font-size: 14px; display: flex; align-items: baseline; gap: 8px; }
.optional, .count { font-weight: 400; color: var(--muted); font-size: 12.5px; }
.count.over { color: var(--bad); font-weight: 600; }
.hint { color: var(--muted); font-size: 12.5px; }
.hint.bad { color: var(--bad); }
input[type="text"], textarea, select {
  width: 100%; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); min-height: 40px;
}
textarea { resize: vertical; }
input[type="text"]:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg button {
  text-align: left; cursor: pointer; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); font-weight: 600; display: grid;
}
.seg button small { font-weight: 400; color: var(--muted); font-size: 12.5px; }
.seg button[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; width: fit-content; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.track {
  width: 40px; height: 22px; border-radius: 999px; background: var(--border); position: relative; flex: none; transition: background .15s;
}
.track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); box-shadow: 0 1px 2px rgb(0 0 0 / 25%); transition: transform .15s;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- people picker ---------- */
.picker {
  position: relative; display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 5px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); min-height: 40px;
}
.picker:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.picker input { border: 0 !important; box-shadow: none !important; flex: 1 1 160px; min-width: 120px; padding: 4px 6px; min-height: 28px; background: transparent; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 4px 2px 3px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; max-width: 100%;
}
.chip .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button {
  border: 0; background: none; cursor: pointer; color: var(--muted); width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: 15px; line-height: 1;
}
.chip button:hover { background: var(--border); color: var(--text); }
.avatar {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-size: 10.5px; font-weight: 700; background: var(--accent-soft); color: var(--accent-strong);
}
.results {
  position: absolute; left: -1px; right: -1px; top: calc(100% + 4px); z-index: 20; margin: 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgb(16 24 40 / 14%);
  max-height: 300px; overflow: auto;
}
.results li { display: flex; gap: 10px; align-items: center; padding: 7px 8px; border-radius: 6px; cursor: pointer; }
.results li[aria-selected="true"], .results li:hover { background: var(--accent-soft); }
.results .meta { display: grid; min-width: 0; }
.results .meta small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results .empty { color: var(--muted); cursor: default; }
.results .empty:hover { background: none; }

/* ---------- preview ---------- */
.preview { position: sticky; top: 78px; display: grid; gap: 12px; }
.preview .card { padding: 18px; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; }
.pv-name { font-size: 21px; font-weight: 700; margin: 4px 0 2px; overflow-wrap: anywhere; }
.pv-name.placeholder { color: var(--muted); font-weight: 500; font-size: 16px; }
.pv-url { font: 12.5px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--muted); overflow-wrap: anywhere; }
.status-line { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 13.5px; font-weight: 600; }
.status-line.ok { color: var(--ok); }
.status-line.bad { color: var(--bad); }
.status-line.wait { color: var(--muted); font-weight: 500; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.wait .dot { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 13.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts .sub { color: var(--muted); font-size: 12.5px; }
.card h3 { font-size: 13px; margin: 14px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.card h3:first-child { margin-top: 0; }
.chips-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chips-row .pill { font-size: 12.5px; }
.lib { font-size: 13.5px; margin: 4px 0; }
.lib ul { margin: 2px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
details summary { cursor: pointer; font-size: 13px; color: var(--muted); font-weight: 600; }
.meta-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 12px; }
.meta-table td { padding: 3px 0; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; }
.meta-table td:first-child { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--muted); padding-right: 10px; white-space: nowrap; }

.notes { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.note { display: flex; gap: 8px; padding: 9px 11px; border-radius: 8px; font-size: 13.5px; }
.note.bad { background: var(--bad-soft); color: var(--bad); }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.info { background: var(--surface-2); color: var(--muted); }
.note .icon { flex: none; font-weight: 700; }

.actions { display: grid; gap: 8px; }
.btn {
  cursor: pointer; border-radius: 8px; padding: 10px 16px; font-weight: 600; border: 1px solid var(--border);
  background: var(--surface); min-height: 42px;
}
.btn:hover:not([disabled]) { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.primary:hover:not([disabled]) { background: var(--accent-strong); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.small-print { font-size: 12.5px; color: var(--muted); margin: 0; }

/* ---------- run view ---------- */
.run-layout { max-width: 820px; margin: 0 auto; padding: 24px; display: grid; gap: 16px; }
.run-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.run-head h1 { font-size: 24px; margin-top: 4px; overflow-wrap: anywhere; }
.badge { padding: 4px 12px; border-radius: 999px; font-weight: 600; font-size: 13px; background: var(--surface-2); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.run { background: var(--accent-soft); color: var(--accent-strong); }

.timeline { list-style: none; margin: 18px 0 0; padding: 0; }
.timeline > li { position: relative; padding: 0 0 16px 34px; }
.timeline > li::before {
  content: ""; position: absolute; left: 10px; top: 24px; bottom: 0; width: 2px; background: var(--border);
}
.timeline > li:last-child::before { display: none; }
.mark {
  position: absolute; left: 0; top: 1px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; background: var(--surface-2); border: 2px solid var(--border); color: var(--muted);
}
.step.done .mark { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.step.failed .mark { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.step.active .mark { border-color: var(--accent); border-top-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.step-row { display: flex; justify-content: space-between; gap: 12px; }
.step-name { font-weight: 600; }
.step-time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13.5px; white-space: nowrap; }
.step-notes { margin: 4px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.step-notes li { font-size: 13px; color: var(--muted); }
.step-notes li.warn { color: var(--warn); }
.step-notes li.bad { color: var(--bad); }

.result { display: grid; gap: 12px; }
.result a { color: var(--accent-strong); font-weight: 600; overflow-wrap: anywhere; }
.bars { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) 140px 52px; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 10px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 3px; min-width: 2px; }
.bar-row .secs { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
pre.log {
  margin: 8px 0 0; padding: 12px; border-radius: 8px; background: var(--surface-2); max-height: 360px; overflow: auto;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere;
}
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- navigation, acting as ---------- */
.nav { display: flex; gap: 4px; margin-right: auto; margin-left: 16px; }
.nav a {
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; padding: 6px 10px; border-radius: 6px;
  display: inline-flex; align-items: center; gap: 6px;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--accent-strong); background: var(--accent-soft); }
.count-badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--on-accent);
  font-size: 12px; display: inline-grid; place-items: center;
}
.topbar-right { display: flex; align-items: center; gap: 14px; }
.actor { display: flex; align-items: center; gap: 8px; }
.actor-label { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.picker.compact { width: 240px; min-height: 34px; padding: 3px; }
.picker.compact input { min-width: 0; flex-basis: 100px; }
.picker.compact .results { left: auto; width: 320px; }
.readonly { padding: 8px 11px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); font-size: 14px; }
.readonly.missing { color: var(--warn); background: var(--warn-soft); border-color: transparent; }

/* ---------- request list ---------- */
.list-layout { max-width: 1180px; margin: 0 auto; padding: 24px; display: grid; gap: 16px; }
.list-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.list-head h1 { font-size: 26px; }
.tabs { display: inline-flex; gap: 4px; padding: 3px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); }
.tabs button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; font-weight: 600; font-size: 13.5px; color: var(--muted); cursor: pointer; }
.tabs button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.req-list { padding: 0; overflow: hidden; }
.req-row {
  display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr) 120px minmax(0, 1.4fr) 110px; gap: 14px; align-items: center;
  padding: 12px 18px; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none;
}
.req-row:last-child { border-bottom: 0; }
a.req-row:hover { background: var(--surface-2); }
.req-row.head { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.req-row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.req-row .sub, .req-row .people { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.req-row .when { color: var(--muted); font-size: 13px; text-align: right; }
.empty-state { padding: 32px 18px; text-align: center; color: var(--muted); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; width: fit-content; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.Pending { background: var(--warn-soft); color: var(--warn); }
.status.Approved, .status.Provisioning { background: var(--accent-soft); color: var(--accent-strong); }
.status.Provisioning::before { animation: pulse 1s ease-in-out infinite; }
.status.Completed { background: var(--ok-soft); color: var(--ok); }
.status.Rejected, .status.Failed { background: var(--bad-soft); color: var(--bad); }

/* ---------- request detail ---------- */
.people-list { display: flex; flex-wrap: wrap; gap: 6px; }
.decision textarea { margin: 6px 0 10px; }
.decision .row-actions .btn { min-width: 120px; }
.btn.danger { color: var(--bad); }
.btn.danger:hover:not([disabled]) { border-color: var(--bad); }
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.history li { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.history li:last-child { border-bottom: 0; }
.history .k { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.history .k.ok { background: var(--ok-soft); color: var(--ok); }
.history .k.bad { background: var(--bad-soft); color: var(--bad); }
.history .k.warn { background: var(--warn-soft); color: var(--warn); }
.history .k.acc { background: var(--accent-soft); color: var(--accent-strong); }
.history .what { overflow-wrap: anywhere; }
.history .what small { display: block; color: var(--muted); }
.history .t { color: var(--muted); font-size: 12.5px; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }

/* ---------- small screens ---------- */
@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .preview { position: static; }
  .topbar { flex-wrap: wrap; }
  .nav { order: 3; width: 100%; margin: 0; }
  .env { display: none; }
  .req-row { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
  .req-row.head { display: none; }
  .req-row .type, .req-row .people { grid-column: 1; }
  .req-row .when { grid-column: 2; grid-row: 2; }
  .req-row .status { grid-column: 2; grid-row: 1; justify-self: end; }
}
@media (max-width: 560px) {
  .topbar { padding: 10px 16px; }
  .layout, .run-layout, .list-layout { padding: 16px; }
  .actor-label { display: none; }
  .picker.compact { width: 190px; }
  .picker.compact .results { width: min(320px, calc(100vw - 32px)); }
  .card { padding: 16px; }
  .seg { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: minmax(0, 1fr) 80px 46px; }
  .env .pill:not(.live):not(.safe) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- product: signed-in user, sign-in page ---------- */
.user { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.user-name { font-weight: 600; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.link-button { border: 0; background: none; color: var(--accent-strong); cursor: pointer; font-weight: 600; padding: 4px 6px; border-radius: 6px; }
.link-button:hover { background: var(--accent-soft); }
.signin-layout { min-height: calc(100vh - 60px); display: grid; place-items: center; padding: 24px 16px; }
.signin-card { max-width: 420px; width: 100%; text-align: center; display: grid; gap: 14px; justify-items: center; padding: 32px 24px; }
.signin-card h1 { font-size: 24px; }
.signin-card p { margin: 0; color: var(--muted); }
.signin-card .btn { width: 100%; }
.logo.big { width: 52px; height: 52px; border-radius: 12px; font-size: 18px; }
.live-note { display: flex; align-items: center; gap: 8px; color: var(--accent-strong); font-weight: 600; font-size: 13.5px; }
@media (max-width: 560px) { .user-name { display: none; } }
.facts.spaced { margin-top: 14px; }
