:root {
  color-scheme: dark;
  --bg: #0d1117;
  --card: #161b22;
  --text: #c9d1d9;
  --muted: #8b949e;
  --border: #30363d;
  --primary: #2ea043;
  --danger: #f85149;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(13, 17, 23, 0.96);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
}

.topbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.topbar-actions {
  margin-top: 0;
}

.local-service-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.local-service-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(33, 38, 45, 0.88);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.local-service-pill.info {
  color: #9ecbff;
  border-color: rgba(56, 139, 253, 0.35);
  background: rgba(56, 139, 253, 0.1);
}

.local-service-pill.success {
  color: #7ee787;
  border-color: rgba(46, 160, 67, 0.4);
  background: rgba(46, 160, 67, 0.12);
}

.local-service-pill.warn {
  color: #f2cc60;
  border-color: rgba(210, 153, 34, 0.4);
  background: rgba(210, 153, 34, 0.12);
}

.local-service-pill.error {
  color: #ffb3ad;
  border-color: rgba(248, 81, 73, 0.4);
  background: rgba(248, 81, 73, 0.12);
}

.console-connection {
  max-width: 1100px;
  margin: 18px auto 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
}

.runtime-status-card {
  max-width: 1100px;
  margin: 16px auto 0;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background:
    radial-gradient(circle at top right, rgba(88, 166, 255, 0.16), transparent 32%),
    linear-gradient(180deg, rgba(22, 27, 34, 0.98), rgba(11, 15, 20, 0.98));
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.24);
}

.runtime-status-card.success {
  border-color: rgba(46, 160, 67, 0.55);
  background:
    radial-gradient(circle at top right, rgba(46, 160, 67, 0.16), transparent 32%),
    linear-gradient(180deg, rgba(22, 27, 34, 0.98), rgba(11, 15, 20, 0.98));
}

.runtime-status-card.warn {
  border-color: rgba(210, 153, 34, 0.55);
  background:
    radial-gradient(circle at top right, rgba(210, 153, 34, 0.16), transparent 32%),
    linear-gradient(180deg, rgba(22, 27, 34, 0.98), rgba(11, 15, 20, 0.98));
}

.runtime-status-card.error {
  border-color: rgba(248, 81, 73, 0.55);
  background:
    radial-gradient(circle at top right, rgba(248, 81, 73, 0.16), transparent 32%),
    linear-gradient(180deg, rgba(22, 27, 34, 0.98), rgba(11, 15, 20, 0.98));
}

.runtime-status-main {
  display: grid;
  gap: 14px;
}

.runtime-status-badge {
  display: inline-flex;
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(88, 166, 255, 0.35);
  background: rgba(56, 139, 253, 0.12);
  color: #9ecbff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.runtime-status-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.runtime-status-title-meta {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
}

.runtime-status-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: 1px solid rgba(88, 166, 255, 0.35);
  background: rgba(56, 139, 253, 0.12);
  color: #9ecbff;
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.runtime-status-icon.success {
  border-color: rgba(46, 160, 67, 0.4);
  background: rgba(46, 160, 67, 0.12);
  color: #7ee787;
}

.runtime-status-icon.warn {
  border-color: rgba(210, 153, 34, 0.4);
  background: rgba(210, 153, 34, 0.12);
  color: #f2cc60;
}

.runtime-status-icon.error {
  border-color: rgba(248, 81, 73, 0.4);
  background: rgba(248, 81, 73, 0.12);
  color: #ffb3ad;
}

.runtime-status-icon.info {
  border-color: rgba(88, 166, 255, 0.35);
  background: rgba(56, 139, 253, 0.12);
  color: #9ecbff;
}

.runtime-status-title-row h2 {
  margin: 0;
  font-size: 24px;
}

.runtime-status-title-row p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.runtime-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid rgba(88, 166, 255, 0.35);
  background: rgba(56, 139, 253, 0.12);
  color: #9ecbff;
}

.runtime-status-pill.success {
  border-color: rgba(46, 160, 67, 0.4);
  background: rgba(46, 160, 67, 0.12);
  color: #7ee787;
}

.runtime-status-pill.warn {
  border-color: rgba(210, 153, 34, 0.4);
  background: rgba(210, 153, 34, 0.12);
  color: #f2cc60;
}

.runtime-status-pill.error {
  border-color: rgba(248, 81, 73, 0.4);
  background: rgba(248, 81, 73, 0.12);
  color: #ffb3ad;
}

.runtime-status-pill.info {
  border-color: rgba(88, 166, 255, 0.35);
  background: rgba(56, 139, 253, 0.12);
  color: #9ecbff;
}

.runtime-status-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.runtime-alert-mode {
  display: grid;
  gap: 6px;
  justify-items: end;
}

.runtime-alert-mode-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.runtime-alert-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid rgba(88, 166, 255, 0.22);
  background: rgba(11, 15, 20, 0.68);
}

.runtime-alert-option {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    opacity 0.2s ease;
}

.runtime-alert-option.is-active {
  background: rgba(56, 139, 253, 0.18);
  color: #9ecbff;
}

.runtime-alert-option:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.runtime-status-open-btn,
.runtime-status-refresh-btn {
  min-width: 104px;
}

.runtime-status-metrics {
  margin-top: 18px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.runtime-metric {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(11, 15, 20, 0.86);
}

.runtime-metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.runtime-metric strong {
  display: block;
  margin-top: 8px;
  font-size: 18px;
  line-height: 1.4;
  word-break: break-word;
}

.runtime-status-footer {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
  justify-content: space-between;
}

.runtime-status-footer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
}

.runtime-status-page,
.runtime-status-reason,
.runtime-status-next-refresh {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.runtime-status-page {
  text-decoration: none;
}

.runtime-status-page:not(.is-disabled) {
  color: #9ecbff;
}

.runtime-status-page.is-disabled {
  pointer-events: none;
}

.runtime-status-next-refresh {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(88, 166, 255, 0.24);
  background: rgba(56, 139, 253, 0.08);
  color: #9ecbff;
  font-weight: 600;
}

.console-connection-head {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.console-connection-head h2 {
  margin: 0 0 6px;
  font-size: 16px;
}

.console-connection-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.layout {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 16px 36px;
  display: grid;
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 17px;
}

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

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

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

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

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

.full {
  grid-column: 1 / -1;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

input,
textarea,
select {
  background: #0b0f14;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 13px;
}

textarea {
  resize: vertical;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.topbar .actions {
  margin-top: 0;
  align-items: center;
}

.btn {
  border: 1px solid var(--border);
  background: #21262d;
  color: var(--text);
  border-radius: 8px;
  height: 40px;
  padding: 0 12px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  line-height: 1;
  vertical-align: middle;
}

.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn.danger {
  background: rgba(248, 81, 73, 0.12);
  border-color: var(--danger);
  color: #ff9c9c;
}

.hint {
  display: inline-block;
  margin-top: 8px;
  color: var(--muted);
}

.status-banner {
  margin-top: 12px;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  border: 1px solid var(--border);
}

.status-banner.info {
  background: rgba(56, 139, 253, 0.08);
  color: #9ecbff;
}

.status-banner.success {
  background: rgba(46, 160, 67, 0.12);
  color: #7ee787;
  border-color: rgba(46, 160, 67, 0.4);
}

.status-banner.warn {
  background: rgba(210, 153, 34, 0.12);
  color: #f2cc60;
  border-color: rgba(210, 153, 34, 0.4);
}

.status-banner.error {
  background: rgba(248, 81, 73, 0.12);
  color: #ffb3ad;
  border-color: rgba(248, 81, 73, 0.4);
}

.output {
  margin-top: 12px;
  background: #0b0f14;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  min-height: 90px;
  max-height: 280px;
  overflow: auto;
  font-size: 12px;
}

.log {
  min-height: 160px;
}

.history-list {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: auto;
}

.history-list .empty {
  padding: 12px;
  color: var(--muted);
}

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

.summary-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: #0b0f14;
}

.summary-card .label {
  color: var(--muted);
  font-size: 12px;
}

.summary-card .value {
  margin-top: 6px;
  font-size: 24px;
  font-weight: 600;
}

.summary-card .subvalue {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.history-table th,
.history-table td {
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  white-space: nowrap;
}

.history-table td.actions-cell {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mini-btn {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  background: #21262d;
  color: var(--text);
  cursor: pointer;
  font-size: 11px;
}

.mini-btn.retry {
  border-color: var(--primary);
  color: #7ee787;
}

.link-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.link-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--text);
  text-decoration: none;
  background: #161b22;
}

.link-chip:hover {
  border-color: #58a6ff;
  color: #c2dcff;
}

.cell-text {
  max-width: 360px;
  white-space: normal;
  line-height: 1.5;
}

.cell-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  white-space: normal;
}

.mini-input {
  width: 88px;
  background: #0b0f14;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
}

.inline-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

@media (max-width: 900px) {
  .topbar {
    align-items: flex-start;
    gap: 12px;
  }

  .topbar-right {
    width: 100%;
    justify-content: flex-start;
  }

  .local-service-toolbar,
  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .console-connection-head,
  .grid.two,
  .grid.three,
  .grid.four {
    display: block;
  }

  .runtime-status-title-row,
  .runtime-status-footer {
    display: block;
  }

  .runtime-status-title-meta {
    margin-bottom: 12px;
  }

  .runtime-status-actions {
    align-items: stretch;
  }

  .runtime-alert-mode {
    justify-items: stretch;
  }

  .runtime-alert-toggle {
    display: grid;
    grid-template-columns: 1fr;
  }

  .runtime-status-pill {
    margin-top: 0;
  }

  .runtime-status-open-btn,
  .runtime-status-refresh-btn {
    width: 100%;
  }

  .runtime-status-footer-meta {
    margin-bottom: 12px;
  }

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

  .runtime-status-metrics {
    grid-template-columns: 1fr;
  }

  .console-connection-head .actions {
    margin-top: 12px;
  }

  .grid.two,
  .grid.three,
  .grid.four {
    grid-template-columns: 1fr;
  }
}
