/* Expult deploys page. Phone first, no italics anywhere (house rule), and no
   external fonts or files: it must work when everything else is broken. */
:root {
  --navy: #0f172a;
  --navy-2: #1e293b;
  --amber: #f59e0b;
  --amber-dark: #b45309;
  --amber-soft: #fef3c7;
  --bg: #f8fafc;
  --card: #ffffff;
  --line: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --green: #15803d;
  --green-soft: #dcfce7;
  --red: #b91c1c;
  --red-soft: #fee2e2;
  --grey: #64748b;
  --grey-soft: #f1f5f9;
  --run: #b45309;
  --run-soft: #fef3c7;
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; font-style: normal !important; }
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;
}
a { color: var(--navy); }
button { font: inherit; }
[hidden] { display: none !important; }

.top {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.top-inner {
  max-width: 1280px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { display: block; height: 27px; width: auto; }
.brand-tag {
  font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--navy); background: var(--amber-soft); border: 1px solid #fcd34d;
  padding: 2px 8px; border-radius: 999px;
}
.wrap { max-width: 1280px; margin: 0 auto; padding: 16px 16px 40px; }

/* Side by side once there's room: the live card beside the timeline, and the
   steps beside the server log, so nothing needs scrolling to reach. Stacked on
   a phone. */
.home, .detail-grid { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
.detail-top { margin-bottom: 4px; }
@media (min-width: 900px) {
  .home { grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); align-items: start; }
  .home-side { position: sticky; top: 64px; }
  .home .timeline-section > h2:first-child { margin-top: 0; }
  .detail-grid { grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); align-items: start; }
  .detail-side > h2:first-child, .detail-side > .box:first-child { margin-top: 0; }
  .detail-log { position: sticky; top: 64px; }
  .detail-log .log-head { margin-top: 0; }
  .detail-log .log { height: calc(100vh - 140px); min-height: 360px; }
}

.link-btn {
  background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px 4px;
  text-decoration: underline; text-underline-offset: 3px;
}

h1 { font-size: 22px; line-height: 1.25; margin: 4px 0 14px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 26px 0 10px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.card + .card { margin-top: 10px; }

/* ── live now ── */
.live {
  background: var(--navy); color: #fff; border: 0;
  background-image: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%);
}
.live a { color: #fde68a; }
.live .label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: #cbd5e1; font-weight: 700; }
.live .commit { font-family: var(--mono); font-size: 22px; font-weight: 700; margin: 2px 0; }
.live .subject { color: #e2e8f0; }
.live .meta { color: #94a3b8; font-size: 13px; margin-top: 6px; }
.live .warn {
  margin-top: 10px; background: rgba(245, 158, 11, .15); border: 1px solid rgba(245, 158, 11, .5);
  color: #fde68a; border-radius: 10px; padding: 8px 10px; font-size: 13px;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .15);
  color: #e2e8f0; border-radius: 999px; padding: 4px 10px; font-size: 13px; text-decoration: none;
}
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--grey); }
.dot.ok { background: #22c55e; } .dot.bad { background: #ef4444; } .dot.run { background: var(--amber); }

.running-banner {
  display: flex; align-items: center; gap: 10px; margin-top: 10px; text-decoration: none;
  background: var(--run-soft); border: 1px solid #fcd34d; color: var(--navy);
  border-radius: var(--radius); padding: 12px 14px; font-weight: 600;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 12px; border: 1px solid transparent; cursor: pointer;
  padding: 12px 18px; font-weight: 700; min-height: 46px;
}
.btn-primary { background: var(--amber); color: var(--navy); border-color: #d97706; }
.btn-primary:hover { background: #fbbf24; }
.btn-primary:disabled { background: #fde68a; color: #92400e; cursor: not-allowed; }
.btn-quiet { background: var(--card); color: var(--navy); border-color: var(--line); }
.btn-block { width: 100%; }
.deploy-row { margin-top: 14px; }

/* ── status badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; padding: 3px 9px; border-radius: 999px;
  white-space: nowrap;
}
.badge.succeeded { background: var(--green-soft); color: var(--green); }
.badge.failed { background: var(--red-soft); color: var(--red); }
.badge.running, .badge.timed_out { background: var(--run-soft); color: var(--run); }
.badge.unknown { background: var(--grey-soft); color: var(--grey); }
.badge.running::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--amber);
  animation: pulse 1.2s ease-in-out infinite;
}

/* ── timeline ── */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before {
  content: ""; position: absolute; left: 11px; top: 8px; bottom: 8px; width: 2px; background: var(--line);
}
.tl-item { position: relative; padding-left: 34px; margin-bottom: 12px; }
.tl-node {
  position: absolute; left: 4px; top: 18px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--card); border: 3px solid var(--grey);
}
.tl-node.succeeded { border-color: var(--green); }
.tl-node.failed { border-color: var(--red); }
.tl-node.running, .tl-node.timed_out { border-color: var(--amber); animation: pulse 1.2s ease-in-out infinite; }
.tl-card { display: block; text-decoration: none; color: inherit; }
.tl-card:hover { border-color: #cbd5e1; }
.tl-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.tl-when { font-weight: 700; }
.tl-sub { color: var(--muted); font-size: 13px; }
.tl-commits { font-family: var(--mono); font-size: 13px; margin-top: 8px; }
.tl-commits .arrow { color: var(--muted); padding: 0 4px; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.facts b { color: var(--text); font-weight: 600; }
.went { margin: 10px 0 0; padding: 0; list-style: none; }
.went li { font-size: 14px; padding: 4px 0; border-top: 1px dashed var(--line); display: flex; gap: 8px; }
.went li:first-child { border-top: 0; }
.went .sha { font-family: var(--mono); font-size: 12px; color: var(--muted); flex: none; padding-top: 2px; }
.show-all { margin-top: 4px; }
.note { margin-top: 8px; font-size: 14px; background: var(--grey-soft); border-radius: 8px; padding: 6px 10px; overflow-wrap: anywhere; }

/* ── detail ── */
.back { display: inline-block; margin-bottom: 8px; color: var(--muted); text-decoration: none; }
.detail-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; }
.steps { list-style: none; margin: 0; padding: 0; }
.step { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.step:first-child { border-top: 0; }
.step-icon {
  flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; font-size: 14px; border: 2px solid var(--line); color: var(--muted); background: var(--card);
}
.step.done .step-icon { background: var(--green); border-color: var(--green); color: #fff; }
.step.failed .step-icon { background: var(--red); border-color: var(--red); color: #fff; }
.step.running .step-icon { border-color: var(--amber); color: var(--amber-dark); position: relative; }
.step.running .step-icon::after {
  content: ""; position: absolute; inset: -5px; border-radius: 50%;
  border: 2px solid transparent; border-top-color: var(--amber); animation: spin 1s linear infinite;
}
.step.pending .step-name { color: var(--muted); }
.step-name { font-weight: 600; }
.step-state { margin-left: auto; font-size: 13px; color: var(--muted); }
.step.failed .step-state { color: var(--red); font-weight: 600; }
.step.running .step-state { color: var(--amber-dark); font-weight: 600; }

.box { border-radius: var(--radius); padding: 14px 16px; margin-top: 12px; }
.box h3 { margin: 0 0 6px; font-size: 16px; }
.box p { margin: 6px 0; }
.box-fail { background: var(--red-soft); border: 1px solid #fca5a5; }
.box-fail h3 { color: var(--red); }
.box-db {
  background: #fff7ed; border: 2px solid #f97316; color: #7c2d12;
}
.box-db h3 { color: #c2410c; }
.box-ok { background: var(--green-soft); border: 1px solid #86efac; }
.box-ok h3 { color: var(--green); }
.box-time { background: var(--run-soft); border: 1px solid #fcd34d; }
.fail-lines {
  font-family: var(--mono); font-size: 12px; background: #fff; border: 1px solid #fecaca; border-radius: 8px;
  padding: 8px 10px; margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 260px; overflow: auto;
}
.check {
  display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px; margin-top: 8px;
  background: #fff; border: 1px solid #bbf7d0; border-radius: 10px; cursor: pointer;
}
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--green); flex: none; }
.check-sub { display: block; font-size: 13px; color: var(--muted); }

.health { width: 100%; border-collapse: collapse; font-size: 13px; }
.health td { padding: 6px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.health tr:first-child td { border-top: 0; }
.health td.code { text-align: right; font-family: var(--mono); font-weight: 700; padding-left: 10px; }
.code.ok { color: var(--green); } .code.bad { color: var(--red); }

.log-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 26px 0 10px; }
.log-head h2 { margin: 0; }
.log {
  background: #0b1220; color: #e2e8f0; border-radius: var(--radius); padding: 12px;
  font-family: var(--mono); font-size: 12px; line-height: 1.55;
  height: 55vh; min-height: 260px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
}
.log .mark { color: #fcd34d; font-weight: 700; }
.log .err { color: #fca5a5; }
.log .ok { color: #86efac; }
.btn-small { padding: 6px 12px; min-height: 34px; font-size: 13px; border-radius: 10px; }

/* ── login ── */
.login { max-width: 380px; margin: 40px auto 0; }
.login label { display: block; font-weight: 600; margin-bottom: 6px; }
.input {
  width: 100%; padding: 12px 14px; border: 1px solid #cbd5e1; border-radius: 12px; font: inherit; background: #fff;
}
.input:focus { outline: 3px solid #fde68a; border-color: var(--amber); }
.error { color: var(--red); font-size: 14px; margin-top: 8px; min-height: 20px; }

/* ── confirm sheet ── */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .55); z-index: 20;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--card); width: 100%; max-width: 560px; max-height: 88vh; overflow: auto;
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}
@media (min-width: 640px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 18px; }
}
.sheet h3 { margin: 0 0 4px; font-size: 19px; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; margin-top: 16px; }
.warn-soft { background: var(--amber-soft); border: 1px solid #fcd34d; border-radius: 10px; padding: 8px 10px; font-size: 13px; margin-top: 10px; }

.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.spinner {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--amber);
  animation: spin 1s linear infinite; display: inline-block; vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; }
}
