:root {
  color-scheme: light;
  --bg: #eef2f6;
  --panel: #ffffff;
  --text: #18212f;
  --muted: #647084;
  --line: #d8dee8;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --danger: #b42318;
  --warning: #a16207;
  --ok: #15803d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  min-height: 40px;
  padding: 0 14px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button.secondary {
  background: #e6ebf2;
  color: var(--text);
}

button.secondary:hover {
  background: #d7dee9;
}

button.danger {
  background: var(--danger);
}

button.outline {
  border: 1px solid var(--blue);
  background: white;
  color: var(--blue);
}

button.outline:hover {
  background: var(--blue-soft);
}

button.loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button.loading::before,
.spinner {
  display: inline-block;
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  animation: spin 0.7s linear infinite;
  content: "";
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: white;
  color: var(--text);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.shell {
  width: min(1560px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.hidden {
  display: none !important;
}

.login-panel {
  width: min(420px, 100%);
  margin: 12vh auto 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
}

.topbar,
.panel-head,
.top-actions,
.actions,
.toggles {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.topbar h1,
.login-panel h1 {
  margin: 0;
  font-size: 32px;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.top-actions,
.actions,
.toggles {
  gap: 10px;
  flex-wrap: wrap;
}

.ops-bar {
  display: grid;
  grid-template-columns: minmax(230px, 1.1fr) minmax(180px, 0.8fr) minmax(260px, 1fr) minmax(420px, 1.5fr);
  gap: 14px;
  align-items: stretch;
  margin-bottom: 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  padding: 12px 14px;
}

.ops-block {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.ops-app,
.ops-deployment {
  justify-content: space-between;
}

.ops-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.ops-title strong {
  overflow: hidden;
  color: var(--text);
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.env-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 5px;
  padding: 0 8px;
  background: #dc2626;
  color: white;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

.env-badge.dry {
  background: var(--warning);
}

.ops-label {
  color: var(--text);
  font-weight: 800;
}

.ops-versions {
  flex-wrap: wrap;
}

.ops-version {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  max-width: 100%;
  border-radius: 6px;
  padding: 0 9px;
  background: var(--blue);
  color: white;
  font-size: 12px;
  font-weight: 900;
}

.ops-version.muted {
  background: #7b8794;
}

.ops-version.warn {
  background: var(--warning);
}

.ops-version.error {
  background: var(--danger);
}

.ops-control {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto 28px auto;
  gap: 9px;
}

.ops-control select {
  min-width: 0;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 40px;
}

.status-dot::before {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--ok);
  content: "";
}

.status-dot.muted::before {
  background: var(--muted);
}

.status-dot.warn::before {
  background: var(--warning);
}

.status-dot.error::before {
  background: var(--danger);
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.panel-head {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel h2 {
  margin: 0;
  font-size: 18px;
}

.stack {
  display: grid;
  gap: 14px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.check {
  display: inline-flex;
  grid-template-columns: auto;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  color: var(--text);
}

.check input {
  width: auto;
  min-height: auto;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
  background: #dcfce7;
  color: var(--ok);
}

.badge.muted {
  background: #e6ebf2;
  color: var(--muted);
}

.badge.warn {
  background: #fef3c7;
  color: var(--warning);
}

.badge.error {
  background: #fee2e2;
  color: var(--danger);
}

.output {
  min-height: 320px;
  max-height: 560px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border-radius: 6px;
  background: #101828;
  color: #e7edf7;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.message,
.error {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
}

.activity {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid #99f6e4;
  border-radius: 6px;
  background: #f0fdfa;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
}

.error {
  color: var(--danger);
}

.version-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}

.version-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.version-chip,
.version-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.version-chip {
  display: grid;
  gap: 4px;
  min-height: 78px;
  padding: 11px;
}

.version-chip span,
.version-chip small,
.version-meta,
.version-empty {
  color: var(--muted);
  font-size: 12px;
}

.version-chip strong,
.version-card strong {
  font-size: 13px;
}

.version-grid {
  display: grid;
  gap: 12px;
}

.version-card {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.version-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.version-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.version-box {
  display: grid;
  gap: 5px;
  min-height: 92px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
}

.version-box code,
.candidate code {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  font-weight: 800;
}

.version-candidates {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.candidate {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  background: white;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.candidate:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.candidate.selected {
  border-color: var(--accent);
  background: #ccfbf1;
  color: var(--accent-dark);
}

.history {
  display: grid;
  gap: 10px;
}

.history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.history-item strong {
  display: block;
}

.history-item span {
  color: var(--muted);
  font-size: 13px;
}

.modal {
  width: min(620px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
  color: var(--text);
}

.modal::backdrop {
  background: rgba(16, 24, 40, 0.52);
}

.modal-panel {
  display: grid;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 22px 60px rgba(16, 24, 40, 0.26);
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-head {
  justify-content: space-between;
}

.modal-head h2 {
  margin: 0;
  font-size: 20px;
}

.modal-close {
  width: 36px;
  min-height: 36px;
  padding: 0;
}

.modal-body {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.modal-details {
  max-height: min(50vh, 420px);
  overflow: auto;
  margin: 0;
  padding: 12px;
  border-radius: 6px;
  background: #101828;
  color: #e7edf7;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.modal-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1180px) {
  .ops-bar {
    grid-template-columns: 1fr 1fr;
  }

  .ops-control {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .layout,
  .field-grid,
  .version-summary,
  .version-columns {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .ops-bar {
    grid-template-columns: 1fr;
  }

  .ops-app,
  .ops-deployment {
    align-items: flex-start;
    flex-direction: column;
  }

  .ops-control {
    grid-template-columns: 1fr;
  }

  .status-dot {
    display: none;
  }

  .top-actions,
  .actions {
    width: 100%;
  }

  .actions button,
  .top-actions button,
  .ops-bar button {
    flex: 1;
  }

  .modal-actions button {
    flex: 1;
  }
}
