:root {
  color-scheme: dark;
  --bg: #071019;
  --panel: #0d1924;
  --panel-2: #111f2c;
  --line: #223342;
  --text: #ecf6f2;
  --muted: #91a7b3;
  --green: #58e6a9;
  --cyan: #55c7f2;
  --amber: #ffc765;
  --red: #ff7d86;
  --shadow: 0 18px 54px rgb(0 0 0 / 28%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 85% -10%, rgb(85 199 242 / 10%), transparent 30rem),
    linear-gradient(180deg, #08131d 0, var(--bg) 18rem);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}

button, input, select { font: inherit; }

.topbar {
  min-height: 7rem;
  padding: 1.5rem clamp(1rem, 4vw, 3.5rem);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  background: rgb(7 16 25 / 86%);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.55rem, 3vw, 2.25rem); letter-spacing: -0.035em; }
h2 { margin-bottom: .25rem; font-size: clamp(1.25rem, 2vw, 1.65rem); letter-spacing: -0.025em; }
h3 { margin: 0 0 .2rem; font-size: 1rem; }

.eyebrow, .section-kicker {
  margin-bottom: .25rem;
  color: var(--green);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.top-status { display: flex; align-items: center; gap: .65rem; color: var(--muted); font-weight: 700; }
.pulse { width: .7rem; height: .7rem; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 .28rem rgb(88 230 169 / 12%); }
.top-status .secondary { min-height: 2.25rem; padding: .4rem .7rem; margin-left: .35rem; }
.compact-action { min-height: 2.25rem; padding: .4rem .7rem; white-space: nowrap; }

main {
  width: min(1500px, calc(100% - 2rem));
  margin: 2rem auto 4rem;
  display: grid;
  gap: 1.25rem;
}

.launch-card, .run-shell, .accounts-shell, .log-shell {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: linear-gradient(145deg, rgb(17 31 44 / 96%), rgb(10 23 34 / 96%));
  box-shadow: var(--shadow);
}

.launch-card {
  display: grid;
  grid-template-columns: minmax(18rem, 1fr) minmax(28rem, 1.4fr);
  gap: 2rem;
  padding: 1.35rem;
  align-items: end;
  scroll-margin-top: 8rem;
}
.launch-card > *, #launch-form, #launch-form > * { min-width: 0; }

.muted { color: var(--muted); margin-bottom: 0; max-width: 70ch; }

#launch-form {
  display: grid;
  grid-template-columns: minmax(14rem, 1.4fr) 1fr 1fr auto;
  align-items: end;
  gap: .8rem;
}

label { display: grid; gap: .4rem; color: #c9d9dd; font-weight: 700; font-size: .9rem; }

input[type="number"], select {
  width: 100%;
  min-height: 2.8rem;
  border: 1px solid #345064;
  border-radius: .65rem;
  background: #07131e;
  color: var(--text);
  padding: .6rem .75rem;
  outline: none;
  min-width: 0;
  max-width: 100%;
}

input:focus, select:focus { border-color: var(--cyan); box-shadow: 0 0 0 .2rem rgb(85 199 242 / 14%); }

.acknowledge { grid-column: 1 / -1; display: flex; align-items: center; gap: .6rem; font-weight: 500; }
.acknowledge span { min-width: 0; overflow-wrap: anywhere; }
.acknowledge input { width: 1.05rem; height: 1.05rem; accent-color: var(--green); }
.capacity-note { grid-column: 1 / -1; margin: -.15rem 0 0; color: var(--muted); font-size: .86rem; }
.launch-details { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: .55rem; }
.launch-details summary { cursor: pointer; color: var(--muted); font-size: .84rem; font-weight: 700; }
.launch-details[open] summary { margin-bottom: .65rem; }
.launch-details .capacity-note + .capacity-note { margin-top: .45rem; }

button, .button-link {
  border: 1px solid transparent;
  border-radius: .65rem;
  min-height: 2.8rem;
  padding: .65rem 1rem;
  background: var(--green);
  color: #03110c;
  font-weight: 850;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button:hover, .button-link:hover { filter: brightness(1.06); }
button:disabled, .disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.secondary { background: transparent; color: var(--text); border-color: #3b5363; }
.danger { background: rgb(255 125 134 / 14%); color: #ffd9dc; border-color: rgb(255 125 134 / 58%); }
.danger:hover { background: rgb(255 125 134 / 23%); }
.danger-solid { background: #b93343; color: #fff; border-color: #e06470; }
.danger-solid:hover { background: #ca3b4c; }
.form-message { margin: 0; grid-column: 1 / -1; min-height: 1.5rem; color: var(--amber); }
#launch-button { grid-column: 4; grid-row: 1; }

.run-shell, .accounts-shell { padding: 1.35rem; }
.run-heading, .accounts-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.run-controls { display: flex; align-items: end; gap: .7rem; flex-wrap: wrap; }
.run-controls .button-link { white-space: nowrap; }
.run-controls button { white-space: nowrap; }
.run-picker { min-width: min(28rem, 48vw); }

.progress-track { height: .55rem; background: #07131e; border-radius: 999px; overflow: hidden; border: 1px solid #263a49; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--green), var(--cyan)); transition: width .3s ease; }
.progress-bar.stopped, .progress-bar.exited { background: linear-gradient(90deg, var(--red), var(--amber)); }

.metrics { display: grid; grid-template-columns: repeat(6, 1fr); gap: .7rem; margin: 1rem 0; }
.metrics article { background: #0a1620; border: 1px solid var(--line); border-radius: .75rem; padding: .75rem; }
.metrics article.success-metric { border-color: rgb(88 230 169 / 34%); }
.metrics article.failure-metric { border-color: rgb(255 125 134 / 34%); }
.metrics span { display: block; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.metrics strong { display: block; margin-top: .15rem; font-size: clamp(1.18rem, 2vw, 1.55rem); font-variant-numeric: tabular-nums; white-space: nowrap; }
.metrics small { display: block; min-height: 1.2rem; margin-top: .15rem; color: var(--muted); font-size: .75rem; }
.success-metric strong { color: var(--green); }
.failure-metric strong { color: var(--red); }

.run-meta { display: flex; flex-wrap: wrap; gap: .7rem 1.1rem; align-items: center; margin-bottom: 1rem; color: var(--muted); }
.control-message { min-height: 1.4rem; margin: -.45rem 0 .8rem; color: var(--amber); font-size: .88rem; }
.status-pill { border-radius: 999px; padding: .25rem .65rem; background: rgb(85 199 242 / 12%); color: var(--cyan); font-weight: 800; text-transform: capitalize; }
.status-pill.complete { color: var(--green); background: rgb(88 230 169 / 12%); }
.status-pill.stopped, .status-pill.exited { color: var(--red); background: rgb(255 125 134 / 12%); }

.failure-panel { margin: 1rem 0; border: 1px solid var(--line); border-radius: .8rem; padding: 1rem; background: rgb(7 19 30 / 54%); }
.subsection-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.subsection-heading > .muted { text-align: right; }
.failure-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: .7rem; margin-top: .85rem; }
.failure-grid article { min-width: 0; border: 1px solid #2a3e4d; border-radius: .7rem; padding: .7rem; background: #0a1620; }
.failure-card-heading { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; }
.failure-card-heading strong { overflow-wrap: anywhere; }
.failure-card-heading span { color: var(--red); font-weight: 850; font-variant-numeric: tabular-nums; }
.failure-track { height: .35rem; margin: .6rem 0 .45rem; border-radius: 999px; overflow: hidden; background: #172735; }
.failure-track span { display: block; height: 100%; background: linear-gradient(90deg, var(--red), var(--amber)); border-radius: inherit; }
.failure-grid small { color: var(--muted); }
.empty-card { grid-column: 1 / -1; margin: 0; color: var(--muted); }
.activity-heading { margin: 1.2rem 0 .65rem; }

.configuration-panel { margin: 1rem 0; border: 1px solid var(--line); border-radius: .8rem; background: rgb(7 19 30 / 54%); }
.configuration-panel summary { cursor: pointer; padding: .9rem 1rem; font-weight: 800; }
.configuration-report { border-top: 1px solid var(--line); padding: 1rem; }
.configuration-overview { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; }
.configuration-overview article { background: #0a1620; border: 1px solid var(--line); border-radius: .7rem; padding: .75rem; }
.configuration-overview span, .configuration-overview small { display: block; color: var(--muted); }
.configuration-overview strong { display: block; margin: .15rem 0; font-size: 1.35rem; }
.configuration-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); gap: .8rem; margin-top: 1rem; }
.configuration-groups section { overflow: auto; border: 1px solid var(--line); border-radius: .7rem; background: #0a1620; }
.configuration-groups h4 { margin: 0; padding: .65rem .75rem; }
.configuration-groups table { min-width: 30rem; }
.configuration-contrasts { margin-top: 1rem; overflow: auto; border: 1px solid var(--line); border-radius: .7rem; background: #0a1620; }
.configuration-contrasts h4 { margin: 0; padding: .65rem .75rem; }
.configuration-contrasts table { min-width: 64rem; }
.configuration-limitations { margin: 1rem 0 0; color: var(--muted); font-size: .86rem; }

.autopilot-evolution-panel { margin: 1rem 0; border: 1px solid rgb(85 199 242 / 35%); border-radius: .8rem; background: rgb(7 19 30 / 62%); overflow: hidden; }
.autopilot-evolution-panel > summary { cursor: pointer; padding: .9rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; list-style: none; }
.autopilot-evolution-panel > summary::-webkit-details-marker { display: none; }
.autopilot-evolution-panel > summary > span:first-child { display: grid; gap: .1rem; }
.autopilot-evolution-panel > summary small { color: var(--muted); font-weight: 500; }
.autopilot-evolution-panel[open] > summary { border-bottom: 1px solid var(--line); }
.autopilot-evolution-panel[open] > summary .summary-action { font-size: 0; }
.autopilot-evolution-panel[open] > summary .summary-action::after { content: "Hide evolution"; font-size: .86rem; }
.autopilot-evolution-content { padding: 1rem; display: grid; gap: 1rem; }
.autopilot-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .7rem; }
.autopilot-kpis article { min-width: 0; border: 1px solid var(--line); border-radius: .7rem; padding: .75rem; background: #0a1620; }
.autopilot-kpis span, .autopilot-kpis small { display: block; color: var(--muted); }
.autopilot-kpis span { font-size: .75rem; text-transform: uppercase; letter-spacing: .07em; }
.autopilot-kpis strong { display: block; margin: .15rem 0; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.autopilot-kpis small { font-size: .75rem; }
.evolution-block { min-width: 0; border: 1px solid var(--line); border-radius: .75rem; padding: .85rem; background: #0a1620; }
.evolution-columns { display: grid; grid-template-columns: minmax(0, 2fr) minmax(18rem, .8fr); gap: 1rem; align-items: start; }
.trend-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .75rem; color: var(--muted); font-size: .78rem; }
.trend-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.trend-legend span::before { content: ""; width: .65rem; height: .18rem; border-radius: 999px; background: currentColor; }
.legend-pass { color: var(--green); }
.legend-vps { color: var(--red); }
.legend-interactive { color: var(--amber); }
.trend-chart { margin-top: .75rem; overflow: hidden; }
.trend-chart svg { display: block; width: 100%; height: auto; }
.trend-grid { stroke: #263947; stroke-width: 1; }
.trend-axis-label { fill: var(--muted); font-size: 11px; }
.trend-line { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.trend-pass { stroke: var(--green); }
.trend-vps { stroke: var(--red); }
.trend-interactive { stroke: var(--amber); stroke-dasharray: 5 5; }
.trend-point { stroke: #071019; stroke-width: 2; }
.trend-point.pass { fill: var(--green); }
.trend-point.vps { fill: var(--red); }
.trend-point.interactive { fill: var(--amber); }
.evolution-table-wrap { max-height: 29rem; margin-top: .7rem; }
.evolution-profile-wrap { max-height: 30rem; margin-top: .75rem; }
.evolution-table { min-width: 66rem; font-size: .82rem; }
.evolution-table th, .evolution-table td { padding: .55rem .6rem; }
.evolution-table .family-name, .evolution-table .profile-name { color: #fff; font-weight: 800; white-space: nowrap; }
.rate-good { color: var(--green); font-weight: 800; }
.rate-warn { color: var(--amber); font-weight: 800; }
.rate-bad { color: var(--red); font-weight: 800; }
.delta-good { color: var(--green); }
.delta-bad { color: var(--red); }
.delta-neutral { color: var(--muted); }
.pool-badge { display: inline-flex; align-items: center; border-radius: 999px; padding: .15rem .45rem; margin: .08rem .18rem .08rem 0; background: rgb(85 199 242 / 12%); color: var(--cyan); font-size: .72rem; font-weight: 800; white-space: nowrap; }
.pool-badge.quarantined { background: rgb(255 125 134 / 12%); color: var(--red); }
.sibling-summary { display: grid; gap: .08rem; min-width: 8rem; }
.sibling-summary strong { color: #fff; font-size: .8rem; }
.sibling-summary small { color: var(--muted); }
.promotion-timeline { max-height: 29rem; overflow: auto; list-style: none; margin: .7rem 0 0; padding: 0; display: grid; gap: .6rem; }
.promotion-timeline li { border-left: 3px solid var(--cyan); padding: .55rem .65rem; background: #07131e; border-radius: 0 .55rem .55rem 0; }
.promotion-timeline li.trigger { border-left-color: var(--amber); }
.promotion-timeline strong, .promotion-timeline span, .promotion-timeline small { display: block; }
.promotion-timeline span { margin-top: .15rem; color: #c9d9dd; font-size: .8rem; overflow-wrap: anywhere; }
.promotion-timeline small { margin-top: .2rem; color: var(--muted); }
.profile-detail-panel { border: 1px solid var(--line); border-radius: .7rem; overflow: hidden; }
.profile-detail-panel > summary { cursor: pointer; padding: .75rem .85rem; font-weight: 800; }
.profile-detail-panel[open] > summary { border-bottom: 1px solid var(--line); }
.profile-detail-panel > .table-wrap { margin: .8rem; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: .75rem; }
.run-shell > .table-wrap { max-height: 34rem; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: .68rem .75rem; text-align: left; border-bottom: 1px solid #1d303f; vertical-align: top; }
th { position: sticky; top: 0; background: #0b1924; color: var(--muted); font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; z-index: 1; }
tr:last-child td { border-bottom: 0; }
td { font-variant-numeric: tabular-nums; }
.state { font-weight: 800; text-transform: capitalize; }
.state.passed { color: var(--green); }
.state.failed, .state.unexecuted { color: var(--red); }
.state.running { color: var(--cyan); }
.state.queued { color: var(--muted); }
.empty { text-align: center; padding: 2rem; color: var(--muted); }
.attempt-pager { display: flex; justify-content: flex-end; align-items: center; gap: .75rem; margin-top: .8rem; color: var(--muted); }
.attempt-pager button { min-height: 2.3rem; padding: .35rem .75rem; }

.accounts-shell { border-color: #315042; padding: 0; overflow: hidden; }
.accounts-summary { cursor: pointer; padding: 1rem 1.35rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; list-style: none; }
.accounts-summary::-webkit-details-marker { display: none; }
.accounts-summary > span:first-child { display: grid; gap: .12rem; }
.accounts-summary strong { font-size: 1rem; }
.accounts-summary small { color: var(--muted); font-weight: 500; }
.summary-action { color: var(--cyan); font-size: .86rem; font-weight: 800; white-space: nowrap; }
.accounts-shell[open] .summary-action { font-size: 0; }
.accounts-shell[open] .summary-action::after { content: "Hide preview"; font-size: .86rem; }
.accounts-content { border-top: 1px solid var(--line); padding: 1.15rem 1.35rem 1.35rem; }
.account-table-wrap { max-height: 20rem; }
.actions { display: flex; gap: .65rem; flex-wrap: wrap; }
.account-table-wrap td { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .84rem; overflow-wrap: anywhere; }
.token-value.masked { filter: blur(.38rem); user-select: none; }

.log-shell { padding: 0; overflow: hidden; }
.log-shell summary { cursor: pointer; padding: 1rem 1.35rem; font-weight: 800; }
.log-shell pre { margin: 0; border-top: 1px solid var(--line); padding: 1rem 1.35rem; max-height: 24rem; overflow: auto; color: #b9ccd2; background: #050d14; font-size: .82rem; white-space: pre-wrap; }

footer { width: min(1500px, calc(100% - 2rem)); margin: 0 auto 2rem; color: var(--muted); display: flex; justify-content: space-between; gap: 1rem; font-size: .82rem; }

.confirm-dialog {
  width: min(35rem, calc(100% - 2rem));
  padding: 0;
  border: 1px solid rgb(255 125 134 / 55%);
  border-radius: 1rem;
  background: #0b1721;
  color: var(--text);
  box-shadow: 0 2rem 6rem rgb(0 0 0 / 70%);
}
.confirm-dialog::backdrop { background: rgb(1 7 12 / 82%); backdrop-filter: blur(3px); }
.confirm-card { display: grid; gap: 1rem; padding: 1.4rem; }
.confirm-card h2, .confirm-card p { margin: 0; }
.danger-kicker { color: var(--red); }
.confirm-run-target { display: grid; gap: .35rem; padding: .75rem; border: 1px solid var(--line); border-radius: .65rem; background: #07131e; }
.confirm-run-target span { color: var(--muted); font-size: .75rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.confirm-run-target code { color: #fff; overflow-wrap: anywhere; }
.confirm-card input[type="text"] {
  width: 100%; min-height: 2.8rem; border: 1px solid #8b4a52; border-radius: .65rem;
  background: #07131e; color: var(--text); padding: .6rem .75rem; outline: none;
  font: 800 1rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.confirm-card input[type="text"]:focus { border-color: var(--red); box-shadow: 0 0 0 .2rem rgb(255 125 134 / 14%); }
.confirm-note { color: var(--muted); font-size: .84rem; }
.confirm-actions { display: flex; justify-content: flex-end; gap: .65rem; }

@media (max-width: 980px) {
  .launch-card { grid-template-columns: 1fr; }
  #launch-form { grid-template-columns: 1fr 1fr; }
  #launch-form button { grid-column: 1 / -1; grid-row: auto; }
  .metrics { grid-template-columns: repeat(3, 1fr); }
  .evolution-columns { grid-template-columns: 1fr; }
  .autopilot-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .topbar, .run-heading, .accounts-heading, footer { align-items: flex-start; flex-direction: column; }
  .topbar { position: static; }
  .top-status { width: 100%; flex-wrap: wrap; }
  .launch-card { padding: 1rem; gap: 1.25rem; overflow: hidden; }
  #launch-form { grid-template-columns: 1fr; }
  .acknowledge, #launch-form button { grid-column: auto; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .run-picker { min-width: 100%; width: 100%; }
  .run-controls { width: 100%; align-items: stretch; flex-direction: column; }
  .subsection-heading { flex-direction: column; }
  .subsection-heading > .muted { text-align: left; }
  .configuration-overview { grid-template-columns: 1fr; }
  .autopilot-kpis { grid-template-columns: 1fr 1fr; }
  .autopilot-evolution-panel > summary, .subsection-heading { align-items: flex-start; }
  .trend-legend { justify-content: flex-start; }
  .actions { width: 100%; }
  .actions > * { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

.login-page { min-height: 100vh; display: grid; place-items: center; }
.login-main { width: min(29rem, calc(100% - 2rem)); margin: 2rem auto; }
.login-card {
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: linear-gradient(145deg, rgb(17 31 44 / 98%), rgb(10 23 34 / 98%));
  box-shadow: var(--shadow);
  padding: clamp(1.25rem, 5vw, 2rem);
}
.login-card h1 { margin-bottom: .4rem; }
.login-form { display: grid; gap: 1rem; margin-top: 1.5rem; }
.login-form input {
  width: 100%; min-height: 2.8rem; border: 1px solid #345064; border-radius: .65rem;
  background: #07131e; color: var(--text); padding: .6rem .75rem; outline: none;
}
.login-form input:focus { border-color: var(--cyan); box-shadow: 0 0 0 .2rem rgb(85 199 242 / 14%); }
.login-error { min-height: 1.5rem; margin: 1rem 0 0; color: var(--red); }
