:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2330;
  --muted: #5d6779;
  --border: #dde1e8;
  --accent: #2557d6;
  --accent-text: #ffffff;
  --code-bg: #f0f2f6;
  --ok: #157f3d;      --ok-bg: #e3f5e9;
  --pending: #6b5d00; --pending-bg: #fdf4c7;
  --warn: #9a4b00;    --warn-bg: #ffe8d1;
  --error: #b42318;   --error-bg: #fde4e1;
  --off: #5d6779;     --off-bg: #eceef2;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --surface: #1a1f27;
    --text: #e6e9ef;
    --muted: #9aa4b5;
    --border: #2c3340;
    --accent: #6d95ff;
    --accent-text: #0d1220;
    --code-bg: #232a35;
    --ok: #6fd391;      --ok-bg: #173523;
    --pending: #e8d66a; --pending-bg: #383114;
    --warn: #ffb36b;    --warn-bg: #3d2812;
    --error: #ff8b80;   --error-bg: #3f1d1a;
    --off: #9aa4b5;     --off-bg: #262c36;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
code, pre { font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; font-size: 13px; }
code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
h1 { font-size: 24px; margin: 0 0 4px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 17px; margin: 0 0 12px; }
.card > h2:not(:first-child) { margin-top: 22px; }
h3 { font-size: 15px; margin: 0; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.topbar .brand { font-weight: 650; color: var(--text); text-decoration: none; }
.topbar nav { display: flex; align-items: center; gap: 14px; }
.container { max-width: 1120px; margin: 0 auto; padding: 24px 16px 64px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.card.narrow { max-width: 380px; margin: 60px auto; }
.card.empty { text-align: center; padding: 40px; }
.card.danger { border-color: var(--error-bg); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 { margin-bottom: 18px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--error); }
.hint { display: block; color: var(--muted); font-size: 13px; margin-top: 4px; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn-danger { color: var(--error); border-color: var(--error); }
.btn-link { border: none; background: none; color: var(--accent); padding: 4px; }
.btn-small { padding: 4px 10px; font-size: 13px; }
.btn-on { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.btn.busy, .btn:disabled { opacity: .6; cursor: progress; }
form.inline { display: inline; margin: 0; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.6; white-space: nowrap; }
.pill-ok { color: var(--ok); background: var(--ok-bg); }
.pill-pending { color: var(--pending); background: var(--pending-bg); }
.pill-warn { color: var(--warn); background: var(--warn-bg); }
.pill-error { color: var(--error); background: var(--error-bg); }
.pill-off { color: var(--off); background: var(--off-bg); }

.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid transparent; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-warn { background: var(--warn-bg); color: var(--warn); }
.flash-error { background: var(--error-bg); color: var(--error); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table.clients { width: 100%; border-collapse: collapse; }
table.clients th, table.clients td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
table.clients th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
table.clients tr:last-child td { border-bottom: none; }
.client-name { font-weight: 600; text-decoration: none; }

.status-list { list-style: none; margin: 0 0 12px; padding: 0; }
.status-list li { padding: 7px 0; border-bottom: 1px solid var(--border); }
.status-list li:last-child { border-bottom: none; }
.status-list .pill { margin-right: 6px; min-width: 64px; text-align: center; }
.detail { color: var(--muted); font-size: 13px; margin: 3px 0 0 76px; overflow-wrap: anywhere; }
.status-list .hint { margin-left: 76px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 0; }
.stats div { background: var(--code-bg); border-radius: 8px; padding: 8px 10px; }
.stats dt { font-size: 12px; color: var(--muted); }
.stats dd { margin: 0; font-size: 18px; font-weight: 650; }

.steps { list-style: none; margin: 0; padding: 0; }
.step { border-top: 1px solid var(--border); padding: 14px 0; }
.step:first-child { border-top: none; padding-top: 0; }
.step-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.step-head h3 { flex: 1; min-width: 200px; }
.step-num { width: 26px; height: 26px; border-radius: 50%; background: var(--code-bg); display: inline-flex; align-items: center; justify-content: center; font-weight: 650; font-size: 13px; flex-shrink: 0; }
.step-body { margin-left: 36px; }
.step-body p { margin: 8px 0; }
.links { margin: 6px 0; padding-left: 20px; }

.field { margin: 8px 0; }
.field-label { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.field-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.field-value { flex: 1; min-width: 200px; padding: 6px 9px; }
pre.code, pre.log { background: var(--code-bg); border-radius: 8px; padding: 12px; overflow: auto; margin: 8px 0; }
pre.code { max-height: 340px; }
pre.log { max-height: 360px; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }

.form-grid { display: grid; gap: 14px; }
label { display: grid; gap: 5px; font-weight: 550; font-size: 14px; }
input, select, textarea { font: inherit; font-weight: 400; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px 16px; display: grid; gap: 14px; margin: 0; }
legend { font-weight: 650; padding: 0 6px; }
.actions { display: flex; gap: 10px; align-items: center; }
.checklist { display: block; margin-top: 10px; }

@media (max-width: 640px) {
  .topbar { padding: 10px 16px; }
  .step-body { margin-left: 0; }
  .detail, .status-list .hint { margin-left: 0; }
}
