:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --text: #18212f;
  --muted: #647084;
  --line: #dbe1ea;
  --line-strong: #c4ccd8;
  --green: #15734f;
  --green-bg: #e7f6ef;
  --red: #b42318;
  --red-bg: #fde9e7;
  --amber: #915c00;
  --amber-bg: #fff3d8;
  --blue: #285ea8;
  --blue-bg: #e9f1ff;
  --code: #101722;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
a {
  font: inherit;
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

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

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.1;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 18px;
  line-height: 1.2;
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.timestamp {
  color: var(--muted);
  font-size: 13px;
}

button {
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--text);
  border-radius: 6px;
  min-height: 34px;
  padding: 0 12px;
  cursor: pointer;
}

button:hover {
  border-color: var(--blue);
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 22px 0;
  border: 1px solid var(--line);
  background: var(--line);
}

.summary > div {
  background: var(--panel);
  padding: 16px;
  min-width: 0;
}

.summary-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.summary strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.instances {
  display: grid;
  grid-template-columns: repeat(5, minmax(210px, 1fr));
  gap: 12px;
}

.instance {
  display: flex;
  flex-direction: column;
  min-height: 420px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.instance-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--line);
}

.instance-name {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.domain {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.badge {
  align-self: flex-start;
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.online {
  color: var(--green);
  background: var(--green-bg);
}

.badge.offline {
  color: var(--red);
  background: var(--red-bg);
}

.badge.warn {
  color: var(--amber);
  background: var(--amber-bg);
}

.instance-body {
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 14px;
  flex: 1;
}

.field {
  display: grid;
  gap: 4px;
}

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

.field code,
.field strong,
.field a,
.field p {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.35;
}

.field code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.run-label {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  color: var(--blue);
  background: var(--blue-bg);
  border-radius: 6px;
  padding: 4px 7px;
  font-weight: 700;
}

.log-preview {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.mini-log {
  width: 100%;
  max-height: 96px;
  margin: 8px 0 0;
  overflow: hidden;
  white-space: pre-wrap;
  color: #394557;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.35;
}

.log-workspace {
  margin-top: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.log-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.log-header p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.log-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.log-tabs button.active {
  background: var(--code);
  border-color: var(--code);
  color: #ffffff;
}

.log-output {
  min-height: 260px;
  max-height: 560px;
  overflow: auto;
  margin: 0;
  padding: 16px;
  background: var(--code);
  color: #edf3fb;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.empty,
.error {
  grid-column: 1 / -1;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
}

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

@media (max-width: 1220px) {
  .instances {
    grid-template-columns: repeat(3, minmax(230px, 1fr));
  }
}

@media (max-width: 820px) {
  .shell {
    width: min(100% - 20px, 720px);
    padding-top: 18px;
  }

  .topbar,
  .log-header {
    flex-direction: column;
  }

  .actions,
  .log-tabs {
    justify-content: flex-start;
  }

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

  .instances {
    grid-template-columns: 1fr;
  }
}
