/* deployer web UI: one hand-written stylesheet, no framework (llm/06-deploy-pipeline.md §15.1).
   Served by nginx from /usr/share/deployer/static/ with immutable caching; the file name carries
   a content hash (crates/web/src/ui/assets.rs checks it). No inline styles anywhere: the CSP is
   style-src 'self'. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --text: #1b1f24;
  --muted: #59636e;
  --border: #d0d7de;
  --accent: #0b5cad;
  --accent-text: #ffffff;
  --ok: #1a7f37;
  --ok-bg: #dafbe1;
  --warn: #8a5a00;
  --warn-bg: #fff4d6;
  --bad: #b42318;
  --bad-bg: #ffebe9;
  --info-bg: #ddf0ff;
  --run: #6639ba;
  --run-bg: #f0e9ff;
  --code-bg: #f0f2f5;
  --log-bg: #0f1419;
  --log-text: #d6dde6;
  --focus: #f59e0b;
  --radius: 6px;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", "DejaVu Sans Mono", Menlo, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-2: #1f2630;
    --text: #e6edf3;
    --muted: #9aa5b1;
    --border: #30363d;
    --accent: #4c9be8;
    --accent-text: #0d1117;
    --ok: #3fb950;
    --ok-bg: #12261a;
    --warn: #d29922;
    --warn-bg: #2b2111;
    --bad: #f47067;
    --bad-bg: #2d1414;
    --info-bg: #10243a;
    --run: #b291f5;
    --run-bg: #231a38;
    --code-bg: #1f2630;
    --log-bg: #010409;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

h1, h2, h3 { line-height: 1.25; margin: 1.5rem 0 0.75rem; }
h1 { font-size: 1.6rem; margin-top: 0.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0.5rem 0 0.75rem; }

code, pre, kbd, samp { font-family: var(--mono); font-size: 0.9em; }
code { background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 4px; overflow-wrap: anywhere; }
pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  overflow-x: auto;
  line-height: 1.45;
}
pre code { background: none; padding: 0; overflow-wrap: normal; }

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--surface);
  padding: 0.5rem 1rem;
}
.skip:focus { left: 0.5rem; z-index: 10; }

/* ---- layout ---------------------------------------------------------------------------- */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 76rem;
  margin: 0 auto;
  padding: 0.5rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1rem;
}
.brand {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  margin-right: 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.brand img { width: 1.4rem; height: 1.4rem; }
.nav { display: flex; flex-wrap: wrap; gap: 0.25rem; list-style: none; margin: 0; padding: 0; flex: 1; }
.nav a {
  display: block;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
}
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { background: var(--surface-2); font-weight: 600; }
.whoami { display: flex; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 0.9rem; }
.whoami form { margin: 0; }

main {
  max-width: 76rem;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
}
main.narrow { max-width: 30rem; }

footer.page-footer {
  max-width: 76rem;
  margin: 0 auto;
  padding: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

.breadcrumb { font-size: 0.9rem; color: var(--muted); margin: 0.25rem 0; }
.breadcrumb a { color: var(--muted); }

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}
.page-head h1 { margin-bottom: 0.25rem; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.lead { color: var(--muted); font-size: 1.05rem; max-width: 60rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1rem 0;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card.danger { border-color: var(--bad); }

.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
.grid > .card { margin: 0; }

.two-col { display: grid; gap: 1.5rem; grid-template-columns: 15rem 1fr; align-items: start; }
@media (max-width: 52rem) { .two-col { grid-template-columns: 1fr; } }

.subnav { display: flex; flex-wrap: wrap; gap: 0.25rem; list-style: none; padding: 0; margin: 0.5rem 0 1rem; border-bottom: 1px solid var(--border); }
.subnav a {
  display: block;
  padding: 0.4rem 0.75rem;
  text-decoration: none;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.subnav a:hover { color: var(--text); }
.subnav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

/* ---- tables ---------------------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; }
td form { display: inline; }
.empty { color: var(--muted); font-style: italic; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1rem; margin: 0.5rem 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }

/* ---- badges and states ----------------------------------------------------------------- */

.badge {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.bad { color: var(--bad); background: var(--bad-bg); }
.badge.warn { color: var(--warn); background: var(--warn-bg); }
.badge.run { color: var(--run); background: var(--run-bg); }
.badge.idle { color: var(--muted); background: var(--surface-2); }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.break { overflow-wrap: anywhere; }

/* ---- notices --------------------------------------------------------------------------- */

.notice {
  border-left: 4px solid var(--accent);
  background: var(--info-bg);
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  margin: 0.75rem 0;
}
.notice > :first-child { margin-top: 0; }
.notice > :last-child { margin-bottom: 0; }
.notice.ok { border-color: var(--ok); background: var(--ok-bg); }
.notice.warn { border-color: var(--warn); background: var(--warn-bg); }
.notice.bad { border-color: var(--bad); background: var(--bad-bg); }
.notice ul { margin: 0.25rem 0; padding-left: 1.25rem; }

/* ---- forms ----------------------------------------------------------------------------- */

form.stack { display: grid; gap: 0.9rem; max-width: 40rem; }
form.inline { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: flex-end; }
.field { display: grid; gap: 0.25rem; }
.field label, .label { font-weight: 600; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0; }
.field-error { color: var(--bad); font-size: 0.9rem; margin: 0; }

input[type="text"], input[type="password"], input[type="url"], input[type="number"],
input[type="search"], select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.45rem 0.6rem;
  width: 100%;
  max-width: 40rem;
}
textarea { min-height: 6rem; font-family: var(--mono); font-size: 0.9rem; }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--bad); }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.5rem 1rem 0.75rem; margin: 0; }
legend { font-weight: 600; padding: 0 0.25rem; }
.check { display: flex; gap: 0.5rem; align-items: flex-start; font-weight: normal; }
.check input { margin-top: 0.3rem; }

button, .button {
  font: inherit;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  line-height: 1.3;
}
button:hover, .button:hover { filter: brightness(0.96); }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.danger, .button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
button.link { background: none; border: none; color: var(--accent); padding: 0; font-weight: normal; text-decoration: underline; }
button.big, .button.big { font-size: 1.1rem; padding: 0.7rem 1.4rem; }
button.small, .button.small { font-size: 0.85rem; padding: 0.2rem 0.55rem; }
button[disabled] { opacity: 0.6; cursor: not-allowed; }

/* htmx request indicator (htmx's own injected CSS is switched off: includeIndicatorCSS=false) */
.htmx-indicator { opacity: 0; visibility: hidden; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator {
  opacity: 1;
  visibility: visible;
  transition: opacity 200ms ease-in 150ms;
}
.spinner::before {
  content: "";
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -0.1em;
  margin-right: 0.35rem;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner::before { animation: none; } }

/* ---- copyable values ------------------------------------------------------------------- */

.copyable { display: flex; gap: 0.5rem; align-items: flex-start; margin: 0.5rem 0; }
.copyable pre, .copyable code.value { flex: 1; margin: 0; }
.copyable pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.value-box {
  display: block;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-family: var(--mono);
  overflow-wrap: anywhere;
}
.secret-once { border: 2px dashed var(--warn); }

/* ---- wizard stepper -------------------------------------------------------------------- */

ol.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.25rem; counter-reset: none; }
ol.steps li a, ol.steps li > span {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
}
ol.steps li a:hover { background: var(--surface-2); }
ol.steps li a[aria-current="step"] { background: var(--surface-2); font-weight: 600; }
.step-mark {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: 700;
  border: 2px solid var(--border);
  color: var(--muted);
  background: var(--surface);
}
.step-done .step-mark { border-color: var(--ok); color: var(--ok); background: var(--ok-bg); }
.step-failed .step-mark { border-color: var(--bad); color: var(--bad); background: var(--bad-bg); }
.step-skipped .step-mark { border-style: dashed; }
.step-state { margin-left: auto; font-size: 0.8rem; color: var(--muted); }
.step-failed .step-state { color: var(--bad); }
.step-done .step-state { color: var(--ok); }

.steps-inline { display: flex; flex-wrap: wrap; gap: 0.35rem; list-style: none; padding: 0; margin: 0.5rem 0; }
.steps-inline li { font-size: 0.85rem; }

.next-step { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem; margin-top: 1.5rem; border-top: 1px solid var(--border); padding-top: 1rem; }

/* ---- deploy log ------------------------------------------------------------------------ */

.log {
  background: var(--log-bg);
  color: var(--log-text);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.45;
  max-height: 70vh;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0.5rem 0;
}
.log .l-e { color: #ffa198; }
.log .l-s { color: #79c0ff; font-weight: 600; }
.log .l-step { color: #8b949e; }
.log-status { font-size: 0.85rem; color: var(--muted); }

ol.timeline { list-style: none; padding: 0; margin: 0.5rem 0; display: grid; gap: 0.2rem; }
ol.timeline li { display: flex; gap: 0.75rem; align-items: baseline; }
ol.timeline .t { font-family: var(--mono); font-size: 0.85rem; color: var(--muted); min-width: 5.5rem; }

/* ---- guide ----------------------------------------------------------------------------- */

.guide-flow { counter-reset: flow; list-style: none; padding: 0; display: grid; gap: 0.75rem; }
.guide-flow > li {
  counter-increment: flow;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem 0.75rem 3.25rem;
  position: relative;
}
.guide-flow > li::before {
  content: counter(flow);
  position: absolute;
  left: 0.9rem;
  top: 0.75rem;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  display: grid;
  place-items: center;
  font-weight: 700;
}
.guide-flow h3 { margin-top: 0.1rem; }

.toc { font-size: 0.95rem; }
.toc ul { padding-left: 1.1rem; margin: 0.25rem 0; }

/* ---- misc ------------------------------------------------------------------------------ */

.recovery-codes { columns: 2; font-family: var(--mono); list-style: none; padding: 0; }
.kv-diff li { font-family: var(--mono); }
.added { color: var(--ok); }
.removed { color: var(--bad); }
.changed { color: var(--warn); }

details > summary { cursor: pointer; font-weight: 600; }
details { margin: 0.5rem 0; }

@media (max-width: 40rem) {
  dl.facts { grid-template-columns: 1fr; }
  dl.facts dt { margin-top: 0.4rem; }
  .recovery-codes { columns: 1; }
  .topbar-inner { padding: 0.5rem; }
}

@media print {
  .topbar, .page-footer, button, .button { display: none; }
}
