:root {
  --bg: #0b1222;
  --panel: #111a2e;
  --line: #26324e;
  --text: #dce6ff;
  --muted: #92a4cd;
  --accent: #63b3ff;
  --ok: #4ade80;
  --fail: #fb7185;
  --warn: #fbbf24;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 800px at 10% -10%, #1b315d 0%, var(--bg) 42%);
  color: var(--text);
}

.layout {
  max-width: 1480px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  gap: 14px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

h1 { margin: 0; font-size: 24px; color: #9ad2ff; }
h2 { margin: 0 0 10px; font-size: 16px; color: #b7deff; }

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

.panel {
  background: linear-gradient(180deg, rgba(25,39,67,0.88), rgba(14,23,42,0.92));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}

.grid { display: grid; gap: 10px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: 220px 1fr auto; }
.grid.four { grid-template-columns: repeat(4, minmax(180px,1fr)); }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline.end { justify-content: flex-end; }
.run-launch-actions { grid-column: 1 / -1; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mt8 { margin-top: 8px; }
.mt12 { margin-top: 12px; display: block; }

label { display: grid; gap: 6px; }
label > span { color: #a8bddf; font-size: 12px; }

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

textarea { width: 100%; resize: vertical; min-height: 64px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #355186;
  background: #1b2d52;
  color: #d9ebff;
  text-decoration: none;
  cursor: pointer;
  font-size: 13px;
}
.btn:hover { background: #26427a; }
.btn.primary { background: #1e6dd8; border-color: #2f80ef; }
.btn.primary:hover { background: #2780f0; }
.btn.ghost { background: transparent; }
.btn:disabled {
  pointer-events: none;
  opacity: .45;
}
.btn.disabled { pointer-events: none; opacity: .4; }
.btn.tiny {
  padding: 4px 8px;
  font-size: 11px;
}

.badge {
  border-radius: 999px;
  border: 1px solid #335183;
  padding: 3px 9px;
  font-size: 12px;
  color: #c7dcff;
  background: #132542;
}

.checks { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; }

.table-wrap {
  overflow: auto;
  border: 1px solid #24375e;
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1240px;
}

th, td {
  border-bottom: 1px solid #1f2e4f;
  padding: 8px 10px;
  font-size: 12px;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #12203d;
  color: #9ec8ff;
  z-index: 1;
}

tr.pass td { background: rgba(34, 197, 94, 0.08); }
tr.fail td { background: rgba(244, 63, 94, 0.08); }
tr.selected td {
  outline: 1px solid #5f8fd2;
  background: rgba(65, 118, 205, 0.2);
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.card {
  border: 1px solid #274273;
  border-radius: 10px;
  padding: 10px;
  background: #0f1d39;
}

.card h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: #a9d6ff;
}

.card div {
  font-size: 12px;
  color: #d7e9ff;
  margin: 2px 0;
}

.summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(160px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.summary > div {
  border: 1px solid #2b4576;
  border-radius: 8px;
  padding: 8px;
  background: #132644;
  font-size: 12px;
}

.details-panel {
  border: 1px solid #2b4576;
  border-radius: 10px;
  background: #10203a;
  padding: 10px;
}

.details-content {
  font-size: 12px;
  line-height: 1.45;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.details-grid > div {
  border: 1px solid #2a416e;
  border-radius: 8px;
  padding: 8px;
  background: #0f1e36;
}

.details-section {
  margin-top: 10px;
}

.details-section h3 {
  margin: 0 0 6px;
  font-size: 12px;
  color: #9fc8fb;
}

.details-pre {
  margin: 0;
  border: 1px solid #2a406c;
  border-radius: 8px;
  background: #0c172d;
  color: #d9e9ff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.45;
  padding: 8px;
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

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

.progress-wrap {
  border: 1px solid #2b4576;
  border-radius: 8px;
  padding: 10px;
  background: #12233f;
  margin-bottom: 10px;
}

.progress-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: #0b1830;
  border: 1px solid #284372;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #2d8cff 0%, #4ad6a3 100%);
  transition: width 180ms ease-out;
}

/* ── Metric tier sections ── */
.metrics-tier {
  margin-bottom: 8px;
}

.metrics-tier-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  padding: 2px 0;
  border-bottom: 1px solid #1f3058;
}

.metrics-tier-label.core { color: #9ad2ff; }
.metrics-tier-label.extended { color: #a8bddf; }
.metrics-tier-label.trust { color: #fbbf24; }
.metrics-tier-label.diagnostics { color: #92a4cd; }
.metrics-tier-label.risk { color: #fb7185; }
.metrics-tier-label.coverage { color: #4ade80; }

.metrics-tier-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 6px;
}

.metrics-tier-grid > div {
  border: 1px solid #2a416e;
  border-radius: 6px;
  padding: 6px 8px;
  background: #0f1e36;
  font-size: 12px;
}

.metrics-tier-grid > div strong {
  display: block;
  font-size: 11px;
  color: #a8bddf;
  margin-bottom: 2px;
}

/* ── Coverage badges ── */
.coverage-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.coverage-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  border: 1px solid #335183;
  padding: 3px 10px;
  font-size: 11px;
  background: #132542;
  color: #c7dcff;
}

.coverage-badge.good { border-color: #2d6b3f; color: var(--ok); }
.coverage-badge.warn { border-color: #6b5e2d; color: var(--warn); }
.coverage-badge.bad { border-color: #6b2d3f; color: var(--fail); }

/* ── Risk indicators ── */
.risk-section {
  border: 1px solid #5c2a2a;
  border-radius: 8px;
  background: rgba(244, 63, 94, 0.06);
  padding: 8px;
  margin-bottom: 8px;
}

.risk-section.clean {
  border-color: #2a5c3a;
  background: rgba(34, 197, 94, 0.06);
}

.risk-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 2px 0;
}

.risk-item.triggered { color: var(--fail); }
.risk-item.ok { color: var(--ok); }

/* ── Collapsible diagnostics ── */
.diagnostics-toggle {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.diagnostics-toggle::before {
  content: '>';
  display: inline-block;
  transition: transform 120ms ease;
  font-size: 11px;
}

.diagnostics-toggle.open::before {
  transform: rotate(90deg);
}

.diagnostics-body {
  display: none;
}

.diagnostics-body.open {
  display: block;
}

@media (max-width: 1100px) {
  .grid.four { grid-template-columns: 1fr 1fr; }
  .cards { grid-template-columns: 1fr 1fr; }
  .summary { grid-template-columns: 1fr 1fr; }
  .details-grid { grid-template-columns: 1fr 1fr; }
  .metrics-tier-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  .grid.two, .grid.three, .grid.four {
    grid-template-columns: 1fr;
  }
  .cards, .summary {
    grid-template-columns: 1fr;
  }
  .details-grid {
    grid-template-columns: 1fr;
  }
  .metrics-tier-grid {
    grid-template-columns: 1fr;
  }
}
