:root {
  --bg: #121410;
  --bg-2: #1b2017;
  --bg-3: #262c21;
  --line: #3a4232;
  --text: #e7e6d8;
  --muted: #8f967f;
  --brass: #e2a122;
  --ink: #1a1406;
  --ok: #c6d36b;
  --bad: #e15a3a;
  --warn: #e7c07a;
  --info: #8fb8a8;
  --log: #0c0e0a;
  --sans: "Outfit", "Avenir Next", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
}
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brass), transparent 72%);
  z-index: 5;
}
button, input, select { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
button { cursor: pointer; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.gate {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}
.gate-card, .dialog-card {
  width: min(420px, 100%);
  background: var(--bg-2);
  border: 1px solid var(--line);
  padding: 1.4rem;
  display: grid;
  gap: 0.85rem;
}
.gate-card h1 { font-size: 2.4rem; font-weight: 600; letter-spacing: -0.04em; }
.eyebrow {
  color: var(--brass);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.lede, .muted { color: var(--muted); }
label { display: grid; gap: 0.3rem; color: var(--muted); font-size: 0.86rem; }
input, select {
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 0.55rem 0.65rem;
  border-radius: 2px;
}
input:focus, select:focus { outline: 2px solid var(--brass); border-color: transparent; }
.form-error { color: var(--bad); }
.button {
  border: 1px solid var(--line);
  background: var(--bg-3);
  border-radius: 2px;
  padding: 0.45rem 0.75rem;
}
.button:hover { border-color: var(--brass); }
.button:disabled { opacity: 0.45; cursor: not-allowed; }
.button.primary { background: var(--brass); color: var(--ink); border-color: transparent; font-weight: 600; }
.button.danger:hover { border-color: var(--bad); color: #ffd0c6; }

.shell {
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.8rem;
  padding: 0.75rem 1rem 0.7rem;
  border-bottom: 1px solid var(--line);
  background: rgba(18, 20, 16, 0.94);
}
.brand { display: grid; min-width: 9rem; }
.mark { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.03em; }
.brand-note { color: var(--muted); font-size: 0.78rem; }
.search { flex: 1; min-width: 8rem; }
.search input, .check { width: 100%; }
.check { width: auto; display: flex; align-items: center; gap: 0.4rem; color: var(--muted); white-space: nowrap; }
.top-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-left: auto; }
.who { color: var(--muted); font-family: var(--mono); font-size: 0.78rem; }

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 220px minmax(300px, 380px) minmax(0, 1fr);
}
.groups, .stage, .log { min-width: 0; min-height: 0; }
.groups {
  border-right: 1px solid var(--line);
  overflow: auto;
  padding: 0.7rem;
  display: grid;
  align-content: start;
  gap: 0.35rem;
}
.group-button, .target {
  text-align: left;
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
}
.group-button {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.5rem;
  color: var(--text);
}
.group-button.active, .target.selected { background: var(--bg-3); border-color: var(--line); }
.group-button small, .tag { color: var(--muted); font-family: var(--mono); font-size: 0.72rem; }
.group-tools { display: flex; gap: 0.35rem; margin-top: 0.4rem; }

.stage { display: grid; grid-template-rows: auto minmax(0, 1fr); }
.banner {
  margin: 0.7rem 0.8rem 0;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--warn);
  color: var(--warn);
}
.list { overflow: auto; padding: 0.7rem; display: grid; align-content: start; gap: 0.45rem; }
.target {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 0.65rem;
  row-gap: 0.55rem;
  align-items: start;
  padding: 0.7rem 0.75rem;
  border-color: var(--line);
  background: var(--bg-2);
  cursor: pointer;
}
.target h3 { font-size: 1rem; font-weight: 600; overflow-wrap: break-word; }
.target-main { display: grid; gap: 0.2rem; min-width: 0; }
.meta-line { color: var(--muted); font-size: 0.82rem; display: flex; flex-wrap: wrap; gap: 0.45rem; }
.dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  margin-top: 0.35rem;
  background: var(--muted);
}
.dot.running, .dot.active { background: var(--ok); }
.dot.failed { background: var(--bad); }
.dot.starting, .dot.stopping { background: var(--warn); }
.actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
.empty { color: var(--muted); padding: 1rem; }

.log {
  border-left: 1px solid var(--line);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--log);
}
.log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.log-head > div:first-child { min-width: 0; }
.log-head h2 {
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.log-tools { display: flex; flex-wrap: wrap; align-items: end; justify-content: flex-end; gap: 0.4rem; }
.log-tools label { font-size: 0.75rem; }
.log-body {
  overflow: auto;
  padding: 0.85rem 1rem 1.2rem;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre;
  word-break: normal;
}
.log-line { min-height: 1.2em; }
.log-empty { padding: 0.2rem 0; white-space: normal; }

.dialog-card.wide { width: min(760px, 92vw); max-height: min(80vh, 720px); overflow: auto; }
.dialog-head, .dialog-actions, .row-actions { display: flex; gap: 0.4rem; align-items: center; }
.dialog-head { justify-content: space-between; }
dialog {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.62); }
.stack { display: grid; gap: 0.7rem; }
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th, .table td { border-bottom: 1px solid var(--line); padding: 0.4rem 0.3rem; text-align: left; vertical-align: top; }
.table th { color: var(--muted); font-weight: 500; }
.member-list { max-height: 280px; overflow: auto; border: 1px solid var(--line); padding: 0.4rem 0.6rem; display: grid; gap: 0.25rem; }
.member-list label { display: flex; gap: 0.45rem; align-items: center; color: var(--text); }
.ok { color: var(--ok); }
.bad { color: var(--bad); }

#toasts {
  position: fixed;
  right: 0.8rem;
  bottom: 0.8rem;
  display: grid;
  gap: 0.4rem;
  z-index: 6;
}
.toast {
  background: var(--bg-3);
  border: 1px solid var(--line);
  padding: 0.55rem 0.7rem;
  max-width: 320px;
}

@media (max-width: 1100px) {
  .top { flex-wrap: wrap; }
  .workspace { grid-template-columns: 1fr; grid-template-rows: auto minmax(220px, 1fr) minmax(240px, 42vh); }
  .groups { display: flex; border-right: 0; border-bottom: 1px solid var(--line); }
  .group-button { width: auto; white-space: nowrap; }
  .log { border-left: 0; border-top: 1px solid var(--line); }
  .log-head { flex-wrap: wrap; }
  .log-head h2 { white-space: normal; }
  .log-body { white-space: pre-wrap; }
  .actions { justify-content: flex-start; }
}
