:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --ink: #17201b;
  --muted: #61706a;
  --line: #d9e0dc;
  --panel: #ffffff;
  --panel-soft: #edf3f1;
  --accent: #0f8b6f;
  --accent-deep: #09634f;
  --warn: #b96b00;
  --danger: #b93232;
  --blue: #2868a6;
  --violet: #7650a8;
  --shadow: 0 18px 45px rgba(23, 32, 27, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(15, 139, 111, 0.08), transparent 360px),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.identity {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 260px;
}

.mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.eyebrow,
.stage-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.1;
}

h1 {
  font-size: clamp(26px, 4vw, 42px);
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
}

h3 {
  font-size: 15px;
}

.connection-panel {
  display: grid;
  grid-template-columns: minmax(260px, 460px) 150px 112px;
  align-items: end;
  gap: 10px;
  width: min(100%, 760px);
}

.endpoint-field {
  display: grid;
  gap: 6px;
}

.endpoint-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select,
button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

input,
select {
  width: 100%;
  background: var(--panel);
  color: var(--ink);
  padding: 0 12px;
}

button {
  cursor: pointer;
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
  font-weight: 750;
  padding: 0 16px;
}

button:hover {
  background: #25312b;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.status-strip article,
.side-panel,
.stage-panel {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.status-strip article {
  min-width: 0;
  border-radius: 8px;
  padding: 14px;
}

.status-strip span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 750;
}

.status-strip strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 18px;
}

.main-grid {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 16px;
}

.side-panel,
.stage-panel {
  border-radius: 8px;
}

.side-panel {
  align-self: start;
  overflow: hidden;
}

.panel-block {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-block:last-child {
  border-bottom: 0;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.badge,
.state-pill,
.tag-list span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.neutral {
  background: var(--panel-soft);
  color: var(--muted);
}

.badge.live,
.state-pill.done {
  background: rgba(15, 139, 111, 0.12);
  color: var(--accent-deep);
}

.badge.warn,
.state-pill.review {
  background: rgba(185, 107, 0, 0.12);
  color: var(--warn);
}

.badge.error,
.state-pill.blocked {
  background: rgba(185, 50, 50, 0.12);
  color: var(--danger);
}

.meter-row {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.meter {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6ece9;
}

.meter i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 240ms ease;
}

.meter-row.risk .meter i {
  background: var(--warn);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-list span {
  background: #eef4f8;
  color: var(--blue);
}

.details-list {
  display: grid;
  gap: 14px;
  margin: 0;
}

.details-list div {
  min-width: 0;
}

.details-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.details-list dd {
  margin: 5px 0 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.stage-panel {
  min-width: 0;
  padding: 18px;
}

.stage-heading {
  align-items: start;
}

.view-toggle {
  display: flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.view-toggle button {
  min-height: 32px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0 10px;
}

.view-toggle button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 12px rgba(23, 32, 27, 0.08);
}

.stage-list {
  display: grid;
  gap: 10px;
}

.stage-list.grid-mode {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stage-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.stage-card.current {
  border-color: rgba(15, 139, 111, 0.5);
  box-shadow: inset 3px 0 0 var(--accent);
}

.stage-index {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--accent-deep);
  font-weight: 850;
}

.stage-title-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.stage-body p {
  margin: 8px 0 10px;
  color: var(--muted);
  line-height: 1.45;
}

.stage-body time {
  color: #7a8782;
  font-size: 12px;
  font-weight: 650;
}

.state-pill.pending {
  background: #f0f2f1;
  color: #68736f;
}

.state-pill.active {
  background: rgba(118, 80, 168, 0.12);
  color: var(--violet);
}

@media (max-width: 980px) {
  .topbar,
  .main-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .connection-panel {
    grid-template-columns: 1fr 140px 112px;
    width: 100%;
  }

  .status-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: 14px;
  }

  .connection-panel,
  .status-strip,
  .stage-list.grid-mode {
    grid-template-columns: 1fr;
  }

  .stage-heading,
  .stage-title-row {
    display: grid;
  }

  .view-toggle {
    width: 100%;
  }

  .view-toggle button {
    flex: 1;
  }
}
