/* ── base tokens (overridden below by responsive block) ── */
:root {
  --bg: #f3f6fa; --fg: #17212b; --muted: #596878; --card: #ffffff; --line: #d7e0e8;
  --accent: #145da0; --accent-fg: #ffffff;
  --ok: #17692f; --ok-bg: #dff3e4; --bad: #a3231b; --bad-bg: #fbe3e1;
  --run: #7a4b00; --run-bg: #fdecc8; --idle: #444a52; --idle-bg: #e7e8e9;
  --code-bg: #edf2f7;
  --public-bg: #e6f4ea; --public-fg: #1a7a35;
  --shadow-sm: 0 1px 3px rgba(20,35,50,.07);
  --shadow-md: 0 4px 16px rgba(20,35,50,.10);
  --radius: 0.85rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111820; --fg: #e8eef5; --muted: #a4b2c1; --card: #19232d; --line: #344454;
    --accent: #78baff; --accent-fg: #101923;
    --ok: #7fdc99; --ok-bg: #16301e; --bad: #ff9b92; --bad-bg: #3a1b19;
    --run: #f2c26b; --run-bg: #382b0f; --idle: #c0c5cc; --idle-bg: #2a2e34;
    --code-bg: #202c38;
    --public-bg: #16301e; --public-fg: #7fdc99;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.25);
    --shadow-md: 0 4px 16px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; line-height: 1.45; }
a { color: var(--accent); }
a.plain { text-decoration: none; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9em; }
code { background: var(--code-bg); padding: 0.05em 0.3em; border-radius: 3px; word-break: break-all; }
pre { background: var(--code-bg); padding: 0.7rem; border-radius: 6px; overflow: auto; max-width: 100%; }
pre.log { max-height: 70vh; min-height: 4rem; white-space: pre-wrap; word-break: break-word; }
header.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem;
  padding: 0.55rem max(1rem, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--card) 94%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5; min-height: 3.5rem;
}
header.top .brand { font-weight: 700; font-size: 1.05rem; letter-spacing: -0.02em; text-decoration: none; color: var(--fg); display: flex; align-items: center; gap: 0.45rem; }
header.top nav { display: flex; gap: 0.35rem; flex: 1; align-items: center; }
header.top nav a { text-decoration: none; padding: 0.45rem 0.65rem; border-radius: 0.5rem; border-bottom: 2px solid transparent; display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.9rem; }
header.top nav a:hover { background: var(--code-bg); }
header.top nav a.active { color: var(--fg); background: var(--code-bg); border-bottom-color: transparent; font-weight: 600; }
header.top nav a svg { width: 1em; height: 1em; flex-shrink: 0; opacity: 0.7; }
main { max-width: 64rem; margin: 0 auto; padding: 1rem; }
h1 { font-size: 1.5rem; margin: 0.2rem 0 0.6rem; }
h2 { font-size: 1.15rem; margin: 1.6rem 0 0.5rem; }
h3 { font-size: 1rem; margin: 1rem 0 0.4rem; }
.row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; }
.muted { color: var(--muted); }
.err { color: var(--bad); }
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 0.65rem 0.8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); white-space: nowrap; font-weight: 700; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable::after { content: " ↕"; opacity: 0.4; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--accent) 4%, var(--card)); }
.badge { display: inline-block; padding: 0.05rem 0.5rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600; background: var(--idle-bg); color: var(--idle); white-space: nowrap; }
.st-succeeded, .st-active, .st-valid, .st-verified, .st-passed { background: var(--ok-bg); color: var(--ok); }
.st-failed, .st-error, .st-missing, .st-invalid { background: var(--bad-bg); color: var(--bad); }
.st-running { background: var(--run-bg); color: var(--run); }
.st-queued, .st-cancelled, .st-pending, .st-skipped { background: var(--idle-bg); color: var(--idle); }
button, .btn {
  font: inherit; padding: 0.5rem 1rem; border: 1px solid var(--line);
  border-radius: 0.65rem; background: var(--card); color: var(--fg);
  cursor: pointer; min-height: 2.75rem; display: inline-flex; align-items: center; gap: 0.4rem;
  touch-action: manipulation; transition: background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
  font-size: 0.9rem; font-weight: 500; box-shadow: var(--shadow-sm);
}
button:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--card)); }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 35%, transparent); }
button.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
button.danger { color: var(--bad); border-color: var(--bad); }
button.danger:hover { background: var(--bad-bg); }
button.link { border: 0; background: none; color: var(--accent); padding: 0.2rem 0.5rem; min-height: 0; box-shadow: none; }
button.secondary { border-color: var(--line); }
form.inline { display: inline; margin: 0; }
.banner { padding: 0.6rem 0.8rem; border-radius: 6px; border: 1px solid var(--line); }
.banner.error { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.banner.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.narrow { max-width: 22rem; margin: 3rem auto; }
label { display: block; margin: 0.6rem 0; }
input[type=password], input[type=text] { display: block; width: 100%; font: inherit; padding: 0.45rem; margin-top: 0.2rem; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--fg); }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; margin: 0.4rem 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; min-width: 0; }
.chip { font-size: 0.72rem; padding: 0 0.4rem; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); text-transform: uppercase; }
details { margin: 0.6rem 0; }
summary { cursor: pointer; }
/* live connection indicator and toast */
.live { font-size: 0.75rem; padding: 0.05rem 0.5rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.live.on { color: var(--ok); background: var(--ok-bg); border-color: var(--ok); }
.live.off { color: var(--run); background: var(--run-bg); border-color: var(--run); }
.live::before { content: "\25CF  "; }
.toast { position: fixed; right: 1rem; bottom: 1rem; max-width: 22rem; padding: 0.6rem 0.9rem; border-radius: 6px; border: 1px solid var(--line); background: var(--card); box-shadow: 0 2px 10px rgba(0,0,0,0.2); z-index: 10; }
.toast.ok { border-color: var(--ok); }
.toast.bad { border-color: var(--bad); color: var(--bad); }
[hidden] { display: none !important; }
pre.clog { max-height: 40vh; font-size: 0.8em; }
.row.tight { justify-content: flex-start; margin: 0.4rem 0; }
textarea { display: block; width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem; line-height: 1.4; padding: 0.6rem; border: 1px solid var(--line); border-radius: 6px; background: var(--code-bg); color: var(--fg); resize: vertical; tab-size: 2; }
textarea[readonly] { opacity: 0.8; }
/* ── pipeline steps: numbered card rows ── */
ol.flow { list-style: none; margin: 0.5rem 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
ol.flow > li { position: relative; }
ol.flow > li::after { content: none; }
ol.flow > li.fail { margin-top: 0.25rem; }
.step {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.8rem 1rem; display: grid;
  grid-template-columns: 2rem 1.5rem 1fr auto;
  align-items: center; gap: 0.5rem 0.75rem;
  box-shadow: var(--shadow-sm);
}
.step-num {
  width: 2rem; height: 2rem; border-radius: 999px;
  background: var(--ok-bg); color: var(--ok); border: 2px solid var(--ok);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 700; flex-shrink: 0;
}
.step-num.pending { background: var(--idle-bg); color: var(--idle); border-color: var(--idle); }
.step-num.running { background: var(--run-bg); color: var(--run); border-color: var(--run); }
.step-num.failed { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.step-icon { color: var(--muted); display: flex; align-items: center; }
.step-body { min-width: 0; }
.step-body strong { display: block; font-size: 0.95rem; }
.step-body code { font-size: 0.82rem; color: var(--muted); word-break: break-all; }
.step-meta { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.step.on-fail { border-left: 3px solid var(--bad); }
.step-head { margin-bottom: 0.2rem; }
@media (max-width: 600px) {
  html { font-size: 14px; }
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { padding: 0.4rem 0; border-bottom: 1px solid var(--line); }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack td { border: 0; padding: 0.15rem 0.6rem; display: flex; gap: 0.6rem; align-items: baseline; }
  table.stack td::before { content: attr(data-label); flex: 0 0 5.5rem; color: var(--muted); font-size: 0.75rem; text-transform: uppercase; }
  table.stack td:not([data-label])::before { content: none; }
  main { padding: 0.7rem; }
  dl.kv { grid-template-columns: 1fr; gap: 0; }
  dl.kv dd { margin-bottom: 0.4rem; }
}

/* ── global layout polish (supercedes base above) ── */
html { min-width: 320px; scroll-padding-top: 5rem; }
body { min-height: 100vh; }
main { max-width: 78rem; padding: clamp(1rem, 3vw, 2rem); }
h1 { font-size: clamp(1.45rem, 4vw, 1.85rem); line-height: 1.2; letter-spacing: -0.025em; }
h2 { margin-top: 1.8rem; }
.row { gap: 0.75rem; }
.row > h1, .row > h2 { min-width: 0; }
.scroll { border-radius: var(--radius); overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
}
input[type=password], input[type=text], textarea { min-height: 2.75rem; border-radius: 0.65rem; }
.banner { padding: 0.8rem 1rem; border-radius: var(--radius); }
.badge, .live { padding: 0.2rem 0.6rem; }
pre { border: 1px solid var(--line); border-radius: var(--radius); }
.narrow { width: min(100% - 1.5rem, 26rem); }
@media (max-width: 600px) {
  header.top {
    display: grid; grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 0.35rem 0.55rem; padding: 0.5rem max(0.75rem, env(safe-area-inset-right)) 0.35rem max(0.75rem, env(safe-area-inset-left));
  }
  header.top .brand { grid-column: 1; grid-row: 1; align-self: center; }
  header.top nav {
    grid-column: 1 / -1; grid-row: 2; min-width: 0; width: 100%;
    overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
    gap: 0.2rem; padding-bottom: 0.15rem;
  }
  header.top nav::-webkit-scrollbar { display: none; }
  header.top nav a { flex: 0 0 auto; min-height: 2.75rem; display: inline-flex; align-items: center; }
  header.top .live { grid-column: 2; grid-row: 1; align-self: center; }
  header.top form.inline { grid-column: 3; grid-row: 1; }
  main { padding: 1rem 0.75rem max(1.25rem, env(safe-area-inset-bottom)); }
  .row { align-items: flex-start; }
  .row > button, .row > form { max-width: 100%; }
  .narrow { margin: clamp(1.5rem, 10vh, 3rem) auto; }
  dl.kv { grid-template-columns: minmax(5.5rem, 32%) minmax(0, 1fr); gap: 0.4rem 0.65rem; }
  dl.kv dd { margin-bottom: 0.35rem; overflow-wrap: anywhere; }
  table.stack {
    display: block; width: 100%; overflow: visible; border: 0; background: transparent;
  }
  table.stack tbody { display: grid; gap: 0.65rem; }
  table.stack tr {
    display: block; width: 100%; padding: 0.55rem 0.7rem;
    background: var(--card); border: 1px solid var(--line); border-radius: 0.75rem;
    box-shadow: 0 1px 2px rgba(20, 35, 50, 0.05);
  }
  table.stack tr:last-child { border-bottom: 1px solid var(--line); }
  table.stack td {
    display: grid; grid-template-columns: minmax(5.5rem, 32%) minmax(0, 1fr);
    align-items: start; gap: 0.35rem 0.65rem; width: 100%; padding: 0.32rem 0;
    overflow-wrap: anywhere;
  }
  table.stack td::before {
    flex: initial; min-width: 0; font-size: 0.7rem; font-weight: 650;
    letter-spacing: 0.035em; line-height: 1.4;
  }
  table.stack td:not([data-label]) { display: flex; justify-content: flex-end; padding-top: 0.5rem; }
  table.stack td > * { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
  .scroll > table:not(.stack) { min-width: 38rem; }
  .toast { right: 0.75rem; bottom: max(0.75rem, env(safe-area-inset-bottom)); left: 0.75rem; max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}

/* ── routes: summary info-card strip ── */
.routes-summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.75rem; margin-bottom: 1.5rem;
}
.routes-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.85rem 1rem; display: flex; align-items: flex-start; gap: 0.75rem;
  box-shadow: var(--shadow-sm);
}
.routes-card-icon {
  width: 2.25rem; height: 2.25rem; border-radius: 0.5rem;
  background: var(--code-bg); display: flex; align-items: center; justify-content: center;
  color: var(--accent); flex-shrink: 0;
}
.routes-card-title { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.routes-card-value { font-size: 0.95rem; font-weight: 600; margin-top: 0.15rem; }
.routes-card-sub { font-size: 0.78rem; color: var(--muted); margin-top: 0.05rem; }
/* public/private access badges */
.access-public { display: inline-flex; align-items: center; gap: 0.3em; padding: 0.2rem 0.55rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600; background: var(--public-bg); color: var(--public-fg); white-space: nowrap; }
.access-private { display: inline-flex; align-items: center; gap: 0.3em; padding: 0.2rem 0.55rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600; background: var(--idle-bg); color: var(--idle); white-space: nowrap; }
/* routes table address sub-label */
.route-address { font-weight: 600; }
.route-sub { display: block; font-size: 0.78rem; color: var(--muted); margin-top: 0.1rem; }

/* ── run detail: page-level back link ── */
.back-link { display: inline-flex; align-items: center; gap: 0.3rem; color: var(--muted); text-decoration: none; font-size: 0.88rem; margin-bottom: 0.5rem; }
.back-link:hover { color: var(--fg); }
.run-head-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem 1.5rem; margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.run-head-card .kv-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 0.65rem 2rem; margin-top: 0.85rem;
}
.run-kv-label { font-size: 0.78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.run-kv-value { font-size: 0.9rem; margin-top: 0.1rem; }

/* ── run detail: steps section ── */
.steps-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.65rem; }
.steps-count { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.step-row {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.75rem 1rem; margin-bottom: 0.5rem;
  display: grid; grid-template-columns: 2.25rem 1.75rem 1fr auto 1fr auto;
  align-items: center; gap: 0.5rem 0.75rem;
  box-shadow: var(--shadow-sm);
}
.step-row:last-child { margin-bottom: 0; }
.step-row .step-cmd { color: var(--muted); font-size: 0.82rem; background: var(--code-bg); border-radius: 0.4rem; padding: 0.15rem 0.45rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-row .step-dur { color: var(--muted); font-size: 0.82rem; display: flex; align-items: center; gap: 0.25rem; white-space: nowrap; }
.step-row .step-chevron { color: var(--muted); cursor: pointer; flex-shrink: 0; }

/* ── log toolbar ── */
.log-section h2 { margin-bottom: 0.5rem; }
.log-toolbar {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.75rem; background: var(--card);
  border: 1px solid var(--line); border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
}
.log-toolbar .log-live-badge {
  display: inline-flex; align-items: center; gap: 0.3em;
  font-size: 0.78rem; font-weight: 600;
  background: var(--run-bg); color: var(--run);
  border-radius: 999px; padding: 0.15rem 0.55rem;
}
.log-toolbar .log-live-badge::before { content: "\25CF"; font-size: 0.65em; }
.log-toolbar .log-search {
  flex: 1; max-width: 18rem; padding: 0.35rem 0.65rem 0.35rem 2rem;
  border: 1px solid var(--line); border-radius: 0.5rem;
  background: var(--code-bg); color: var(--fg); font: inherit; font-size: 0.85rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23596878' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 0.55rem center;
}
.log-toolbar .log-search:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.log-toolbar .log-actions { display: flex; align-items: center; gap: 0.35rem; margin-left: auto; }
.log-toolbar button { min-height: 2rem; padding: 0.3rem 0.7rem; font-size: 0.82rem; }
pre.log.with-toolbar { border-top-left-radius: 0; border-top-right-radius: 0; }

/* ── config page info-cards ── */
.config-info-strip {
  display: grid; grid-template-columns: 1fr auto;
  gap: 1rem; margin-bottom: 1.5rem; align-items: start;
}
.config-intro-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem 1.5rem; display: flex; align-items: flex-start; gap: 1rem;
  box-shadow: var(--shadow-sm);
}
.config-intro-icon {
  width: 2.75rem; height: 2.75rem; border-radius: 0.65rem;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); flex-shrink: 0;
}
.config-secrets-card {
  background: color-mix(in srgb, var(--accent) 6%, var(--card)); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 0.85rem 1rem;
  min-width: 14rem; max-width: 18rem;
}
.config-secrets-title { font-size: 0.82rem; font-weight: 700; color: var(--accent); }
.config-secrets-title svg { vertical-align: middle; margin-right: 0.25rem; }
.config-secrets-body { font-size: 0.82rem; color: var(--muted); margin-top: 0.3rem; }
/* YAML editor header toolbar */
.yaml-editor-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden;
}
.yaml-editor-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.85rem 1rem; border-bottom: 1px solid var(--line);
}
.yaml-chip {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  padding: 0.1rem 0.45rem; border: 1px solid var(--line); border-radius: 4px;
  color: var(--muted); background: var(--code-bg);
}
/* Config history table inside card */
.config-history-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); margin-top: 1.5rem; box-shadow: var(--shadow-sm);
}
.config-history-head { padding: 0.85rem 1rem; border-bottom: 1px solid var(--line); }
.config-history-head h2 { margin: 0; font-size: 1.05rem; }

/* ── Restart Shipyard button (danger, right-aligned) ── */
.config-restart-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 0.25rem; margin-top: 0.5rem; }
.config-restart-note { font-size: 0.78rem; color: var(--muted); text-align: right; max-width: 18rem; }
.heading-icon { vertical-align: middle; margin-right: 0.4rem; }
.history-empty { padding: 0.85rem 1rem; }
.log-live-badge { display: inline-flex; align-items: center; gap: 0.3em; font-size: 0.78rem; font-weight: 600; background: var(--run-bg); color: var(--run); border-radius: 999px; padding: 0.15rem 0.55rem; vertical-align: middle; }
.log-live-badge::before { content: "\25CF"; font-size: 0.65em; }

/* ── small screen adjustments ── */
@media (max-width: 600px) {
  header.top {
    display: grid; grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 0.35rem 0.55rem; padding: 0.5rem max(0.75rem, env(safe-area-inset-right)) 0.35rem max(0.75rem, env(safe-area-inset-left));
  }
  header.top .brand { grid-column: 1; grid-row: 1; align-self: center; }
  header.top nav {
    grid-column: 1 / -1; grid-row: 2; min-width: 0; width: 100%;
    overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
    gap: 0.2rem; padding-bottom: 0.15rem;
  }
  header.top nav::-webkit-scrollbar { display: none; }
  header.top nav a { flex: 0 0 auto; min-height: 2.75rem; display: inline-flex; align-items: center; }
  header.top .live { grid-column: 2; grid-row: 1; align-self: center; }
  header.top form.inline { grid-column: 3; grid-row: 1; }
  main { padding: 1rem 0.75rem max(1.25rem, env(safe-area-inset-bottom)); }
  .row { align-items: flex-start; }
  .row > button, .row > form { max-width: 100%; }
  .narrow { margin: clamp(1.5rem, 10vh, 3rem) auto; }
  dl.kv { grid-template-columns: minmax(5.5rem, 32%) minmax(0, 1fr); gap: 0.4rem 0.65rem; }
  dl.kv dd { margin-bottom: 0.35rem; overflow-wrap: anywhere; }
  table.stack {
    display: block; width: 100%; overflow: visible; border: 0; background: transparent;
  }
  table.stack tbody { display: grid; gap: 0.65rem; }
  table.stack tr {
    display: block; width: 100%; padding: 0.55rem 0.7rem;
    background: var(--card); border: 1px solid var(--line); border-radius: 0.75rem;
    box-shadow: 0 1px 2px rgba(20, 35, 50, 0.05);
  }
  table.stack tr:last-child { border-bottom: 1px solid var(--line); }
  table.stack td {
    display: grid; grid-template-columns: minmax(5.5rem, 32%) minmax(0, 1fr);
    align-items: start; gap: 0.35rem 0.65rem; width: 100%; padding: 0.32rem 0;
    overflow-wrap: anywhere;
  }
  table.stack td::before {
    flex: initial; min-width: 0; font-size: 0.7rem; font-weight: 650;
    letter-spacing: 0.035em; line-height: 1.4;
  }
  table.stack td:not([data-label]) { display: flex; justify-content: flex-end; padding-top: 0.5rem; }
  table.stack td > * { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
  .scroll > table:not(.stack) { min-width: 38rem; }
  .toast { right: 0.75rem; bottom: max(0.75rem, env(safe-area-inset-bottom)); left: 0.75rem; max-width: none; }
  .routes-summary { grid-template-columns: 1fr; }
  .config-info-strip { grid-template-columns: 1fr; }
  .config-secrets-card { max-width: none; }
  .run-head-card .kv-grid { grid-template-columns: 1fr; }
  .step-row { grid-template-columns: 2.25rem 1.75rem 1fr; }
  .step-row .step-cmd, .step-row .step-dur, .step-row .step-chevron { display: none; }
}
#config-form { display: grid; gap: 0.65rem; }
.config-editor-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.2rem 1rem; }
.config-editor-head label { margin: 0; }
.config-editor-head p { margin: 0; }
#config-text {
  height: min(68vh, 54rem); min-height: 28rem; max-height: 78vh;
  padding: 1rem 1.1rem; border-color: var(--line); border-radius: 0.85rem;
  background: var(--card); font-size: 0.9rem; line-height: 1.6;
  tab-size: 2; white-space: pre; overflow: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch; box-shadow: 0 2px 8px rgba(20, 35, 50, 0.06);
}
#config-text[readonly] { background: var(--code-bg); }
#config-form .config-actions {
  position: sticky; bottom: 0; z-index: 3; gap: 0.55rem;
  margin: 0; padding: 0.65rem; border: 1px solid var(--line); border-radius: 0.85rem;
  background: color-mix(in srgb, var(--card) 94%, transparent);
  backdrop-filter: blur(12px); box-shadow: 0 -3px 12px rgba(20, 35, 50, 0.08);
}
#config-form .config-actions button { min-width: 7rem; }
@media (max-width: 600px) {
  #config-form { gap: 0.5rem; }
  .config-editor-head { display: block; }
  .config-editor-head p { margin-top: 0.2rem; }
  #config-text {
    height: 58svh; min-height: 20rem; max-height: 72svh;
    padding: 0.8rem; font-size: 16px; line-height: 1.55;
  }
  #config-form .config-actions {
    bottom: max(0.35rem, env(safe-area-inset-bottom));
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.4rem; padding: 0.45rem;
  }
  #config-form .config-actions button { min-width: 0; width: 100%; padding-inline: 0.35rem; }
}
.resource-section { margin: 0.5rem 0 1.5rem; }
.resource-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem 1rem; }
.resource-heading h2 { margin: 0 0 0.65rem; }
.resource-heading > span { font-size: 0.8rem; }
.resource-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); gap: 0.75rem; }
.resource-card { min-width: 0; padding: 1rem; border: 1px solid var(--line); border-radius: 0.85rem; background: var(--card); }
.resource-label { color: var(--muted); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.resource-value { margin: 0.35rem 0 0.55rem; font-size: clamp(1.35rem, 4vw, 1.8rem); font-weight: 700; letter-spacing: -0.03em; }
.resource-value span { margin-left: 0.4rem; color: var(--muted); font-size: 0.85rem; font-weight: 500; letter-spacing: 0; }
.resource-meter { display: block; width: 100%; height: 0.7rem; overflow: hidden; appearance: none; border: 0; border-radius: 999px; background: var(--code-bg); }
.resource-meter::-webkit-progress-bar { border-radius: 999px; background: var(--code-bg); }
.resource-meter::-webkit-progress-value { border-radius: 999px; background: var(--accent); }
.resource-meter::-moz-progress-bar { border-radius: 999px; background: var(--accent); }
.resource-detail { margin-top: 0.55rem; color: var(--muted); font-size: 0.88rem; }
@media (max-width: 600px) {
  .resource-heading { align-items: flex-start; flex-direction: column; gap: 0; }
  .resource-heading h2 { margin-bottom: 0.15rem; }
  .resource-grid { grid-template-columns: 1fr; gap: 0.55rem; }
  .resource-card { padding: 0.85rem; }
}

/* ── Routes & Runs tabs ── */
.routes-tab-bar {
  display: flex; gap: 0.5rem; margin-bottom: 1.25rem;
  padding: 0.25rem; border-radius: 0.75rem; background: var(--code-bg);
  width: fit-content; max-width: 100%; overflow-x: auto;
}
.routes-tab-btn {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.5rem 1rem; border-radius: 0.6rem; border: 0;
  background: transparent; color: var(--muted); font-size: 0.9rem; font-weight: 600;
  cursor: pointer; transition: all 0.15s ease; min-height: 2.5rem;
}
.routes-tab-btn:hover { color: var(--ink); background: color-mix(in srgb, var(--card) 60%, transparent); }
.routes-tab-btn.active {
  background: var(--card); color: var(--ink);
  box-shadow: 0 1px 3px rgba(20, 35, 50, 0.1);
}
.routes-tab-panel { display: none; }
.routes-tab-panel.active { display: block; animation: fadeIn 0.15s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: translateY(0); } }
.runs-tab-intro { margin-bottom: 1rem; }
.runs-tab-intro h2 { margin: 0 0 0.25rem; }

/* ── Service routes grouping ── */
.services-routes-container { display: grid; gap: 1.25rem; margin-top: 1rem; }
.service-routes-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.service-routes-head {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 0.5rem 1rem; padding: 0.85rem 1.15rem; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--card) 96%, var(--code-bg));
}
.service-routes-title {
  display: flex; align-items: center; gap: 0.5rem; min-width: 0;
}
.service-routes-icon { color: var(--accent); flex-shrink: 0; }
.service-name { font-size: 1.05rem; font-weight: 700; color: var(--ink); }
.service-project-hint { color: var(--muted); font-size: 0.85rem; }
.service-routes-badges { display: flex; align-items: center; gap: 0.4rem; }
.service-routes-table { width: 100%; border-collapse: collapse; }

/* ── Brand icon cell ── */
.route-brand-cell {
  display: flex; align-items: center; gap: 0.65rem; min-width: 0;
}
.route-brand-icon {
  width: 1.25rem; height: 1.25rem; border-radius: 0.35rem; flex-shrink: 0;
  object-fit: contain; background: var(--code-bg); padding: 1px;
}
.route-brand-text { display: flex; flex-direction: column; min-width: 0; }

/* ── YAML Editor: realtime compiler status & snippets & auto-complete ── */
.yaml-head-right { display: flex; align-items: center; gap: 0.65rem; }
.yaml-realtime-status {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.25rem 0.65rem; border-radius: 999px;
  background: var(--code-bg); border: 1px solid var(--line);
  font-size: 0.78rem; font-weight: 600; color: var(--muted);
}
.yaml-status-dot {
  width: 0.5rem; height: 0.5rem; border-radius: 999px;
  background: var(--idle); flex-shrink: 0; transition: background 0.2s;
}
.yaml-status-dot.ok { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.yaml-status-dot.err { background: var(--bad); box-shadow: 0 0 6px var(--bad); }
.yaml-status-dot.warn { background: #d97706; }
.yaml-status-dot.checking { background: var(--run); animation: pulse 1s infinite; }
@keyframes pulse { 0% { opacity: 0.4; } 50% { opacity: 1; } 100% { opacity: 0.4; } }

.yaml-snippets-bar {
  display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap;
  padding: 0.65rem 1rem; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--card) 98%, var(--code-bg));
  overflow-x: auto; overscroll-behavior-x: contain;
}
.yaml-snippets-title { font-size: 0.75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.snippet-chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.3rem 0.65rem; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-size: 0.8rem; font-weight: 550;
  cursor: pointer; transition: all 0.15s ease; white-space: nowrap;
}
.snippet-chip:hover {
  background: var(--accent); color: #fff; border-color: var(--accent);
  transform: translateY(-1px);
}
.snippet-chip svg { flex-shrink: 0; }

.yaml-editor-wrap { position: relative; }
.yaml-autocomplete-popup {
  position: absolute; top: 0.5rem; left: 1rem; z-index: 10;
  min-width: 18rem; max-width: min(90vw, 26rem);
  background: var(--card); border: 1px solid var(--line); border-radius: 0.75rem;
  box-shadow: 0 8px 24px rgba(20, 35, 50, 0.16); overflow: hidden;
  animation: fadeIn 0.12s ease;
}
.yaml-auto-head {
  padding: 0.4rem 0.75rem; font-size: 0.72rem; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em;
  background: var(--code-bg); border-bottom: 1px solid var(--line);
}
.yaml-auto-item {
  padding: 0.5rem 0.75rem; border-bottom: 1px solid color-mix(in srgb, var(--line) 40%, transparent);
  cursor: pointer; transition: background 0.1s;
}
.yaml-auto-item:last-child { border-bottom: 0; }
.yaml-auto-item:hover, .yaml-auto-item.active {
  background: color-mix(in srgb, var(--accent) 12%, var(--card));
}
.yaml-auto-label { font-size: 0.88rem; font-weight: 600; color: var(--ink); font-family: monospace; }
.yaml-auto-desc { font-size: 0.75rem; color: var(--muted); margin-top: 0.15rem; }

/* ── Project Detail Hero & Panel Cards ── */
.project-hero {
  display: flex; align-items: center; justify-content: space-between; gap: 1.25rem;
  padding: 1.25rem 1.5rem; margin-bottom: 1.5rem; border-radius: 0.85rem;
  background: var(--card); border: 1px solid var(--line);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
}
.project-hero-main { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.project-avatar {
  width: 3.25rem; height: 3.25rem; border-radius: 0.75rem;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff; font-size: 1.6rem; font-weight: 750;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}
.project-title { font-size: 1.65rem; font-weight: 750; margin: 0; line-height: 1.2; }
.project-sub { font-size: 0.88rem; color: var(--muted); margin: 0.25rem 0 0; }
.project-kind { font-weight: 600; color: var(--accent); }
.project-hero-actions { flex-shrink: 0; }
.deploy-btn {
  font-size: 0.92rem; font-weight: 600; padding: 0.6rem 1.25rem;
  border-radius: 0.5rem;
}

/* ── Panel Cards (Backups, Containers, Webhook, Pipeline, Runs) ── */
.panel-card {
  border: 1px solid var(--line); background: var(--card);
  border-radius: 0.85rem; margin-bottom: 1.5rem; overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.9rem 1.25rem; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--card) 98%, var(--code-bg));
}
.panel-head-title { display: flex; align-items: center; gap: 0.6rem; }
.panel-icon { color: var(--accent); flex-shrink: 0; }
.panel-head-title h2 { font-size: 1.05rem; font-weight: 700; margin: 0; }
.panel-head-right { display: flex; align-items: center; gap: 0.65rem; }
.panel-body { padding: 1.25rem; }
.section-subtitle {
  font-size: 0.82rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted); margin: 1.25rem 0 0.65rem;
}
.panel-table { width: 100%; border-collapse: collapse; }
.runs-footer-link { margin-top: 1rem; text-align: right; }
.runs-footer-link a { font-size: 0.88rem; font-weight: 600; color: var(--accent); text-decoration: none; }
.runs-footer-link a:hover { text-decoration: underline; }

/* ── Copy cells & buttons ── */
.copy-cell { display: inline-flex; align-items: center; gap: 0.45rem; max-width: 100%; }
.copy-btn {
  background: var(--code-bg); border: 1px solid var(--line); border-radius: 0.35rem;
  padding: 0.2rem 0.45rem; font-size: 0.75rem; cursor: pointer; color: var(--muted);
  display: inline-flex; align-items: center; gap: 0.3rem; transition: all 0.15s;
  flex-shrink: 0;
}
.copy-btn:hover { background: var(--card); color: var(--ink); border-color: var(--accent); }
.copy-btn.copied {
  background: #059669 !important; color: #fff !important; border-color: #059669 !important;
}

/* ── Pipeline Step Flow ── */
.step-flow-list {
  list-style: none; padding: 0; margin: 0.75rem 0 1.25rem;
  display: flex; flex-direction: column; gap: 0.5rem;
}
.step-flow-item {
  display: flex; align-items: center; gap: 0.85rem; padding: 0.75rem 1rem;
  border-radius: 0.6rem; border: 1px solid var(--line);
  background: color-mix(in srgb, var(--card) 96%, var(--code-bg));
}
.step-num-circle {
  width: 1.75rem; height: 1.75rem; border-radius: 999px;
  background: var(--code-bg); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; color: var(--muted); flex-shrink: 0;
}
.step-flow-content { flex: 1; min-width: 0; }
.step-flow-top { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.step-name { font-size: 0.92rem; font-weight: 650; }
.step-kind-badge {
  font-size: 0.72rem; font-weight: 600; padding: 0.15rem 0.5rem;
  border-radius: 999px; background: var(--code-bg); color: var(--muted);
}
.step-cmd {
  font-size: 0.8rem; color: var(--muted); margin-top: 0.2rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.step-flow-status { display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0; }
.step-time { font-size: 0.78rem; color: var(--muted); }
.step-timeout { font-size: 0.75rem; color: var(--muted); margin-left: 0.5rem; flex-shrink: 0; }
.step-failure-box {
  display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.85rem 1rem;
  border-radius: 0.6rem; border: 1px solid color-mix(in srgb, #f59e0b 35%, var(--line));
  background: color-mix(in srgb, #f59e0b 8%, var(--card)); font-size: 0.85rem;
  color: var(--ink); margin-top: 1rem;
}
.failure-icon { color: #d97706; flex-shrink: 0; margin-top: 2px; }
.pipeline-yaml-drawer {
  margin-top: 1rem; border-radius: 0.5rem; overflow: hidden;
  border: 1px solid var(--line); background: var(--code-bg);
}

/* ── Routes Search & Filter Bar ── */
.routes-filter-bar {
  margin-bottom: 1rem; display: flex; align-items: center; justify-content: space-between;
}
.routes-search-wrap { position: relative; flex: 1; max-width: 26rem; }
.search-icon {
  position: absolute; left: 0.85rem; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}
.routes-search-input {
  width: 100%; padding: 0.55rem 0.85rem 0.55rem 2.35rem; border-radius: 0.5rem;
  border: 1px solid var(--line); background: var(--card); font-size: 0.9rem;
  color: var(--ink); outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.routes-search-input:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}

/* ── Routes Certificate Auto-Renewal Bar ── */
.routes-cert-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.85rem 1.25rem; border-radius: 0.75rem;
  border: 1px solid color-mix(in srgb, var(--ok) 30%, var(--line));
  background: color-mix(in srgb, var(--ok) 6%, var(--card)); margin-top: 1.5rem;
}
.routes-cert-info { display: flex; align-items: center; gap: 0.75rem; }
.cert-shield-icon { color: var(--ok); flex-shrink: 0; }

/* ── Table Action Buttons ── */
.btn-table-action {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.25rem 0.55rem; border-radius: 0.35rem; border: 1px solid var(--line);
  background: var(--card); font-size: 0.78rem; font-weight: 550; color: var(--ink);
  text-decoration: none; cursor: pointer; transition: all 0.15s;
}
.btn-table-action:hover {
  background: var(--code-bg); border-color: var(--accent); color: var(--accent);
}
.btn-outline-primary {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); color: var(--accent);
}
.btn-outline-primary:hover { background: var(--accent); color: #fff; }
.btn-outline-danger {
  border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); color: var(--bad);
}
.btn-outline-danger:hover { background: var(--bad); color: #fff; }

/* ── Mobile web enhancements (especially iPhone 15: 393px viewport) ── */
@media (max-width: 480px) {
  html { font-size: 15px; }
  body {
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
    padding-bottom: max(2rem, env(safe-area-inset-bottom));
  }
  .project-hero {
    flex-direction: column; align-items: flex-start; padding: 1rem; gap: 0.85rem;
  }
  .project-hero-main { width: 100%; }
  .project-hero-actions { width: 100%; }
  .project-hero-actions form, .deploy-btn { width: 100%; justify-content: center; text-align: center; }
  .panel-head { flex-direction: column; align-items: flex-start; gap: 0.6rem; padding: 0.85rem 1rem; }
  .panel-head-right { width: 100%; justify-content: space-between; }
  .panel-body { padding: 1rem 0.75rem; }
  .routes-tab-bar { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .routes-tab-btn { justify-content: center; font-size: 0.85rem; padding: 0.65rem; min-height: 44px; }
  .routes-filter-bar { flex-direction: column; align-items: stretch; }
  .routes-search-wrap { max-width: 100%; }
  .routes-cert-bar { flex-direction: column; align-items: flex-start; gap: 0.75rem; padding: 0.85rem 1rem; }
  .yaml-head-right { flex-direction: column; align-items: flex-end; gap: 0.35rem; }
  .yaml-realtime-status { font-size: 0.72rem; padding: 0.2rem 0.45rem; }
  .yaml-snippets-bar {
    flex-wrap: nowrap; padding: 0.5rem 0.75rem;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .yaml-snippets-bar::-webkit-scrollbar { display: none; }
  .snippet-chip { min-height: 38px; }
  .service-routes-head { padding: 0.7rem 0.85rem; }
  .service-routes-title { flex-wrap: wrap; }
  .route-brand-cell { gap: 0.45rem; }
  .route-brand-icon { width: 1.15rem; height: 1.15rem; }
  .step-flow-item { flex-wrap: wrap; gap: 0.5rem; }
  .step-flow-status { width: 100%; justify-content: space-between; margin-top: 0.25rem; }
  #config-text { font-size: 16px !important; }
  button, input, select { min-height: 40px; }
}


