:root {
  --bg: #f6f6f8; --surface: #ffffff; --surface-2: #f0f0f4; --border: #e2e2ea;
  --text: #17171c; --muted: #6b6b78; --accent: #6d5efc; --accent-text: #ffffff;
  --ok: #16a34a; --warn: #d97706; --bad: #dc2626; --info: #2563eb;
  --log-bg: #111116; --log-text: #d8d8e0;
  --radius: 10px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e12; --surface: #17171d; --surface-2: #1f1f27; --border: #2a2a35;
    --text: #ececf1; --muted: #8d8d9b; --accent: #8578ff;
    --log-bg: #0a0a0d;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; text-decoration: none; }
h1 { font-size: 24px; margin: 0; display: flex; align-items: center; gap: 10px; }
h2 { font-size: 18px; margin: 0 0 8px; }
h3 { font-size: 15px; margin: 0; }
code, .mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 24px; border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar nav { display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand.big { font-size: 22px; justify-content: center; margin-bottom: 4px; }
.logo { width: 22px; height: 22px; border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), #c084fc); display: inline-block; }
.me { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.me img { width: 24px; height: 24px; border-radius: 50%; }

.container { max-width: 1040px; margin: 0 auto; padding: 24px 16px 64px; }
.page-head { display: flex; align-items: baseline; gap: 12px; margin: 8px 0 20px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.wide { width: 100%; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px; }
.panel.flush { padding: 0; overflow: hidden; }
.panel.center { text-align: center; }
.panel.danger { border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
.pad { padding: 16px 20px; margin: 0; }
.empty { text-align: center; padding: 48px 20px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card { display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); transition: border-color .15s; }
.card:hover { border-color: var(--accent); }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.url { color: var(--accent); }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted);
  text-transform: capitalize; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.muted::before { display: none; }
.badge.running, .badge.finished { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.badge.degraded, .badge.restarting, .badge.starting, .badge.queued
  { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }
.badge.in_progress { color: var(--info); background: color-mix(in srgb, var(--info) 12%, transparent); }
.badge.failed, .badge.stopped, .badge.cancelled-by-user
  { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }

.svc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  flex-wrap: wrap; margin: 12px 0 18px; }
.svc-head > div:first-child { display: flex; flex-direction: column; gap: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.deploying { display: inline-flex; align-items: center; gap: 8px; color: var(--info); font-size: 14px; }
.spinner { width: 13px; height: 13px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; color: var(--info); }
@keyframes spin { to { transform: rotate(360deg); } }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.pills { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.pills a { padding: 4px 12px; border-radius: 999px; border: 1px solid var(--border); font-size: 13px; font-family: var(--mono); }
.pills a.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.row, .row-link { display: flex; align-items: center; gap: 12px; padding: 12px 20px;
  border-bottom: 1px solid var(--border); }
.row:last-child, .row-link:last-child { border-bottom: 0; }
.row.bare { padding: 0 0 12px; border: 0; }
.row-link:hover { background: var(--surface-2); }
.row form { margin: 0; }
.key { min-width: 180px; font-weight: 600; }
.secret { cursor: pointer; color: var(--muted); }

.logbox { background: var(--log-bg); color: var(--log-text); border-radius: var(--radius); padding: 14px 16px;
  margin: 0 0 16px; height: 520px; overflow: auto; font: 12.5px/1.55 var(--mono); white-space: pre-wrap; word-break: break-word; }
.logbox.tall { height: 70vh; }
.logbox .err { color: #ff8a8a; }

.form { display: flex; flex-direction: column; gap: 16px; }
.form.narrow { max-width: 560px; }
.inline-form { flex-direction: row; align-items: center; gap: 8px; flex-wrap: wrap; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
input, select { font: inherit; font-weight: 400; padding: 9px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); width: 100%; }
.inline-form input { width: auto; }
.inline-form input.grow { flex: 1; min-width: 160px; }
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); border-color: var(--accent); }
.hint { font-weight: 400; color: var(--muted); font-size: 13px; }
.note { background: var(--surface-2); border-radius: 8px; padding: 12px 14px; font-size: 13px; color: var(--muted); }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px;
  background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); }
.alert.error { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }

.login { min-height: 80vh; display: grid; place-items: center; }
.login .panel { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; padding: 32px; }
.login p { margin: 0; }
.center-text { text-align: center; }
label.check { flex-direction: row; align-items: center; gap: 6px; font-weight: 400; }
label.check input { width: auto; }
.row.wrap { flex-wrap: wrap; }
.row .inline-form input { width: 170px; padding: 5px 10px; font-size: 13px; }
.me:hover { color: var(--text); }

@media (max-width: 640px) {
  .topbar { padding: 10px 16px; }
  .me { display: none; }
  .key { min-width: 110px; }
  .row-link .mono.small { display: none; }
}
