:root {
  --bg: #f6f7f9; --surface: #fff; --text: #16181d; --muted: #646b78; --line: #e3e6eb;
  --accent: #2f5bea; --accent-ink: #fff; --ok: #1f8a4c; --warn: #b7791f; --err: #c53030;
  --code: #f0f2f5; --radius: 10px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1115; --surface: #171a21; --text: #e7e9ee; --muted: #9aa3b2; --line: #272c36;
          --accent: #6d8dff; --accent-ink: #0b0d12; --code: #1e222b; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
a { color: var(--accent); }
.btn { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 8px;
       padding: 7px 12px; font: inherit; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input, textarea, select { width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
textarea { resize: vertical; min-height: 70px; }
label { display: block; font-weight: 600; margin: 12px 0 4px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.muted { color: var(--muted); }

/* login */
body.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: 100%; max-width: 360px; }
.login-card .btn { width: 100%; margin-top: 8px; }
.error { color: var(--err); min-height: 1em; margin: 6px 0 0; }
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.logo { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: var(--accent-ink);
        display: grid; place-items: center; font-weight: 800; }

/* app shell */
header.top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line);
             background: var(--surface); position: sticky; top: 0; z-index: 5; }
header.top .spacer { flex: 1; }
.layout { display: grid; grid-template-columns: 300px 1fr; min-height: calc(100vh - 52px); }
aside { border-right: 1px solid var(--line); background: var(--surface); padding: 12px; overflow-y: auto; max-height: calc(100vh - 52px); position: sticky; top: 52px; }
main { padding: 20px; min-width: 0; }
.group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 6px 4px; }
.step { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 7px; cursor: pointer; }
.step:hover { background: var(--code); }
.step.active { background: var(--code); outline: 1px solid var(--accent); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); flex: none; }
.dot.done { background: var(--ok); } .dot.skipped { background: var(--warn); }
.dot.running { background: var(--accent); animation: pulse 1s infinite; } .dot.error { background: var(--err); }
@keyframes pulse { 50% { opacity: .3; } }
.step .n { color: var(--muted); width: 18px; text-align: right; font-variant-numeric: tabular-nums; }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.prompt-box { white-space: pre-wrap; }
.hint { background: var(--code); border-left: 3px solid var(--warn); padding: 8px 10px; border-radius: 6px; margin: 10px 0; }
.live { background: var(--code); border-radius: 8px; padding: 10px; margin-top: 12px; max-height: 180px; overflow-y: auto;
        font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--muted); }
.live div { white-space: pre-wrap; }
.result { margin-top: 16px; }
.md { overflow-wrap: anywhere; }
.md table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; margin: 10px 0; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.md th { background: var(--code); }
.md pre { background: var(--code); padding: 12px; border-radius: 8px; overflow-x: auto; }
.md code { background: var(--code); padding: 1px 4px; border-radius: 4px; font-size: 12.5px; }
.md pre code { padding: 0; }
.files a { display: inline-block; margin: 3px 6px 3px 0; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; font-size: 12.5px; }
.audits li { margin: 4px 0; }
.pill { font-size: 11px; padding: 2px 7px; border-radius: 99px; background: var(--code); color: var(--muted); }

.brand { white-space: nowrap; }
#site { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
@media (max-width: 820px) {
  header.top { gap: 8px; padding: 10px 12px; }
  #site { display: none; }
  header.top .btn { padding: 6px 9px; white-space: nowrap; }
  .layout { grid-template-columns: 1fr; }
  aside { position: static; max-height: 300px; border-right: 0; border-bottom: 1px solid var(--line); }
  main { padding: 16px; }
}

/* fixes */
select { appearance: auto; }
.change { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin: 8px 0; }
pre.diff { background: var(--code); padding: 10px; border-radius: 8px; overflow-x: auto; font-size: 12px; line-height: 1.45; max-height: 420px; }
pre.diff .add { color: var(--ok); display: inline-block; }
pre.diff .del { color: var(--err); display: inline-block; }
pre.diff .hunk { color: var(--accent); }
.st-applied { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.st-failed, .st-rolled_back { background: color-mix(in srgb, var(--err) 15%, transparent); color: var(--err); }
.st-staged { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }

/* one-job control */
.busy { position: sticky; top: 52px; z-index: 4; background: color-mix(in srgb, var(--accent) 14%, var(--surface));
        border-bottom: 1px solid var(--line); padding: 8px 16px; font-size: 13.5px; }
.busy a { margin-left: 6px; }
.spin { display: inline-block; width: 11px; height: 11px; border: 2px solid var(--accent); border-right-color: transparent;
        border-radius: 50%; animation: rot .8s linear infinite; vertical-align: -1px; }
@keyframes rot { to { transform: rotate(360deg); } }
.btn:disabled { pointer-events: none; }
.badge { font-size: 11px; padding: 0 6px; border-radius: 99px; margin-left: auto; }
.badge.warn { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.badge.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.flow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0 4px; font-size: 12.5px; }
.fl { padding: 3px 9px; border-radius: 99px; background: var(--code); color: var(--muted); }
.fl-done { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.fl-now { color: var(--accent-ink); background: var(--accent); font-weight: 600; }
.fl-err { color: var(--err); background: color-mix(in srgb, var(--err) 14%, transparent); }
.fl-off { opacity: .6; }
.fl-sep { color: var(--muted); }
@media (max-width: 820px) { .busy { top: 56px; } }
