:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --ok: #4ade80;
  --warn: #fbbf24;
  --err: #f87171;
  --line: #334155;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(circle at top left, #1d4ed833, transparent 40%),
    var(--bg);
  color: var(--text);
}

body:not(.app-shell) {
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.app-shell {
  padding: 0.65rem 1rem 0.85rem;
  max-width: none;
  width: 100%;
  margin: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-bottom: 0.35rem;
  flex-shrink: 0;
}

.topbar h1 {
  margin: 0;
  font-size: 1.75rem;
}

.topbar-meta {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.panel {
  width: min(40rem, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 2rem;
  box-shadow: 0 20px 50px #0006;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 0.75rem;
  font-size: 2rem;
}

.lede {
  margin: 0 0 1.25rem;
  color: var(--muted);
  line-height: 1.5;
}

code, .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
}

code { color: var(--accent); }

.status {
  margin: 0;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  background: #0f172a;
  color: var(--muted);
  font-size: 0.9rem;
}

.status.ok { color: var(--ok); }
.status.err { color: var(--err); }

.form {
  display: grid;
  gap: 0.85rem;
}

.form label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.form input {
  padding: 0.65rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid var(--line);
  background: #0f172a;
  color: var(--text);
}

.form button, .btn {
  margin-top: 0.25rem;
  padding: 0.55rem 0.9rem;
  border: 0;
  border-radius: 0.5rem;
  background: var(--accent);
  color: #0f172a;
  font-weight: 600;
  cursor: pointer;
}

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

.btn-sm {
  margin-top: 0;
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
}

.btn-ghost {
  margin-top: 0;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.link { color: var(--accent); text-decoration: none; }
.link:hover { text-decoration: underline; }

.pill {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: #0f172a;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
}

.tabs {
  display: flex;
  gap: 0.35rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0.55rem;
  flex-shrink: 0;
}

.tab {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-weight: 600;
}

.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.tab-panel { display: none; }
.tab-panel.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 0.5rem;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 0;
  flex-shrink: 0;
}

.toolbar-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.env-filters {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.15rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: #0f172a;
}

.filter-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.35rem 0.7rem;
  border-radius: 0.35rem;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.filter-btn .dot {
  width: 0.55rem;
  height: 0.55rem;
  flex-shrink: 0;
}

.filter-btn .dot.muted {
  background: var(--muted);
  box-shadow: none;
}

.filter-btn:hover {
  color: var(--text);
}

.filter-btn.active {
  background: var(--panel);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line);
}

.filter-btn.filter-ok {
  color: var(--ok);
}

.filter-btn.filter-ok.active {
  color: var(--ok);
}

.filter-btn.filter-bad {
  color: var(--err);
}

.filter-btn.filter-bad.active {
  color: var(--err);
}

.filter-btn.filter-empty {
  color: var(--muted);
}

.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.4rem 0.7rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.stat.ok { color: var(--ok); }
.stat.err { color: var(--err); }

.muted { color: var(--muted); }

.error {
  color: var(--err);
  background: #450a0a55;
  border: 1px solid #7f1d1d;
  padding: 0.6rem 0.8rem;
  border-radius: 0.5rem;
  margin-bottom: 0.75rem;
}

.split-pane {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(22rem, 1fr);
  gap: 0.75rem;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

@media (max-width: 1100px) {
  .app-shell {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .split-pane {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .log-panel {
    max-height: 50vh;
  }
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--panel);
  min-height: 0;
}

.log-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100%;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: #020617;
  overflow: hidden;
}

.log-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--line);
  background: #0f172a;
  flex-shrink: 0;
}

.log-title {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.log-label {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.log-actions {
  display: flex;
  gap: 0.4rem;
}

.log-terminal {
  flex: 1;
  margin: 0;
  padding: 0.75rem 0.9rem;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  color: #d1fae5;
  min-height: 0;
}

.log-meta {
  margin: 0;
  padding: 0.35rem 0.75rem 0.5rem;
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
  flex-shrink: 0;
}

.col-actions {
  white-space: nowrap;
  text-align: right;
  width: 1%;
  position: sticky;
  right: 0;
  background: var(--panel);
  box-shadow: -8px 0 12px -12px #000a;
}

.data-table thead .col-actions {
  background: #0f172a;
}

.action-btns {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  justify-content: flex-end;
}

.btn-logs {
  min-width: 3.5rem;
}

.btn-start:not(:disabled) {
  background: var(--ok);
}

.btn-stop:not(:disabled):hover {
  border-color: var(--err);
  color: var(--err);
}

.data-table tr.row-active td {
  background: #0ea5e914;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.data-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #0f172a88;
  position: sticky;
  top: 0;
}

.data-table tr:last-child td { border-bottom: 0; }

.dots {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.dot {
  display: inline-block;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: var(--muted);
}

.dot.green { background: var(--ok); box-shadow: 0 0 0 3px #4ade8022; }
.dot.yellow { background: var(--warn); box-shadow: 0 0 0 3px #fbbf2422; }
.dot.red { background: var(--err); box-shadow: 0 0 0 3px #f8717122; }
