:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-muted: #eef2f6;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9e0e8;
  --accent: #0969da;
  --accent-soft: #e8f2ff;
  --success: #16794c;
  --success-soft: #e7f6ee;
  --warning: #9a6700;
  --warning-soft: #fff4d6;
  --danger: #c4352b;
  --danger-soft: #fdecea;
  --neutral-soft: #eceff3;
  --shadow: 0 16px 50px rgba(32, 42, 55, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: 0;
}

button,
input,
select,
code,
pre {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

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

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

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

h2 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.2;
}

h3 {
  margin-bottom: 14px;
  font-size: 16px;
}

.header-actions {
  display: grid;
  gap: 6px;
  min-width: 220px;
}

.select-label,
label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 10px;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric-strip article,
.summary-panel,
.control-panel,
.detail-panel,
.review-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-strip article {
  min-height: 108px;
  padding: 16px;
}

.metric-label,
.metric-strip small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric-strip strong {
  display: block;
  margin: 8px 0 2px;
  font-size: 28px;
  line-height: 1;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
  overflow-x: auto;
}

.tab-button,
.segment {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.tab-button {
  min-width: 110px;
  padding: 12px 14px;
  border-radius: 6px 6px 0 0;
}

.tab-button.active {
  border-color: var(--line);
  border-bottom-color: var(--surface);
  background: var(--surface);
  color: var(--ink);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.segmented-control {
  display: inline-flex;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 3px;
}

.segment {
  min-width: 76px;
  padding: 7px 10px;
  border-radius: 6px;
}

.segment.active {
  background: var(--ink);
  color: #fff;
}

.trace-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 14px;
  align-items: start;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #fbfcfd;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tbody tr {
  transition: background-color 140ms ease;
}

tbody tr:hover,
tbody tr.selected {
  background: var(--accent-soft);
}

tbody tr:last-child td {
  border-bottom: 0;
}

.run-button {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 800;
  padding: 0;
}

.detail-panel {
  min-height: 510px;
  padding: 18px;
}

.detail-grid,
.split-grid,
.controls-grid,
.activation-layout,
.internal-layout,
.developer-layout {
  display: grid;
  gap: 14px;
}

.detail-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 14px 0;
}

.split-grid,
.activation-layout,
.internal-layout,
.developer-layout,
.audit-export-layout {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 14px;
}

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

.review-quality-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.summary-panel,
.control-panel {
  padding: 16px;
}

.controls-detail-panel {
  margin-top: 14px;
}

.pill,
.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-badge.passed,
.status-badge.pass,
.pill.success {
  background: var(--success-soft);
  color: var(--success);
}

.status-badge.flagged,
.pill.warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-badge.blocked,
.status-badge.fail {
  background: var(--danger-soft);
  color: var(--danger);
}

.pill.neutral,
.status-badge.neutral {
  background: var(--neutral-soft);
  color: #475467;
}

.timeline,
.status-list,
.event-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline li,
.status-list li,
.event-list li {
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.timeline li:last-child,
.status-list li:last-child,
.event-list li:last-child {
  border-bottom: 0;
}

.timeline strong,
.status-list strong,
.event-list strong {
  display: block;
}

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

.quality-bars {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  gap: 6px;
}

.bar-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.bar-threshold,
.table-note {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.table-note {
  margin-top: 4px;
  max-width: 360px;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-muted);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.bar-fill.internal {
  background: var(--success);
}

.economics-panel {
  margin-bottom: 20px;
}

.model-comparison-section {
  margin-top: 18px;
}

.compact-heading {
  margin-bottom: 12px;
}

.economics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.economics-grid > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
}

.economics-grid strong {
  display: block;
  margin: 5px 0 2px;
  font-size: 22px;
  line-height: 1.1;
}

.economics-grid span {
  display: block;
}

.economics-note {
  margin: 14px 0 0;
  color: var(--muted);
}

.eval-table table {
  min-width: 1320px;
}

.api-table {
  margin-bottom: 14px;
}

.compact-table table {
  min-width: 1040px;
}

.api-table table {
  min-width: 1120px;
}

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

.code-block {
  min-height: 236px;
  margin: 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111827;
  color: #f9fafb;
  padding: 14px;
  font-size: 13px;
  line-height: 1.55;
}

code {
  border-radius: 4px;
  background: var(--surface-muted);
  color: var(--ink);
  padding: 2px 4px;
  font-size: 12px;
  word-break: break-word;
}

.code-block code {
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: inherit;
  word-break: normal;
}

.api-card-list {
  display: grid;
  gap: 10px;
}

.api-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
}

.api-card p {
  margin-bottom: 8px;
}

.api-card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.severity-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.severity-medium {
  background: var(--neutral-soft);
  color: #475467;
}

.severity-high {
  background: var(--warning-soft);
  color: var(--warning);
}

.severity-critical {
  background: var(--danger-soft);
  color: var(--danger);
}

.review-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.review-quality-grid > .summary-panel {
  grid-column: span 1;
}

.review-quality-grid > .summary-panel:nth-child(1),
.review-quality-grid > .summary-panel:nth-child(2),
.review-quality-grid > .summary-panel:nth-child(3) {
  min-height: 260px;
}

.review-metric-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 14px;
}

.review-metric-card strong {
  display: block;
  margin: 6px 0 2px;
  font-size: 24px;
  line-height: 1.1;
}

.review-metric-card.success {
  border-color: #b7e4ca;
}

.review-metric-card.warning {
  border-color: #f3d38b;
}

.review-card {
  min-height: 300px;
  padding: 16px;
}

.review-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.review-card p {
  color: var(--muted);
}

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

.review-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.review-meta span {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  color: var(--muted);
  padding: 8px;
  font-size: 12px;
}

.review-meta strong {
  display: block;
  color: var(--ink);
}

.action-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  min-height: 34px;
  padding: 6px 10px;
  font-weight: 800;
}

.action-button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.action-button.danger {
  border-color: var(--danger);
  color: var(--danger);
}

.compact li {
  padding: 8px 0;
}

.budget-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

.budget-line strong {
  font-size: 26px;
}

.role-list {
  display: grid;
  gap: 10px;
}

.role-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.role-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

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

.funnel-step {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 72px;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.funnel-code {
  color: var(--accent);
  font-weight: 900;
}

.compact-step {
  grid-template-columns: 48px minmax(0, 1fr) 58px;
}

.internal-platform-section {
  margin-top: 20px;
}

.use-case-list {
  display: grid;
}

.use-case-row {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(120px, 0.65fr) minmax(160px, 0.8fr) minmax(90px, 0.45fr) minmax(200px, 1.1fr);
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.use-case-row:first-child {
  padding-top: 0;
}

.use-case-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.use-case-row span {
  display: block;
}

.use-case-row strong {
  display: block;
}

.signal-list {
  display: grid;
  gap: 14px;
  margin: 0;
}

.signal-list div {
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.signal-list div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.signal-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.signal-list dd {
  margin: 4px 0 0;
}

.audit-export-layout {
  margin-bottom: 0;
}

@media (max-width: 1100px) {
  .metric-strip,
  .controls-grid,
  .review-quality-grid,
  .review-board,
  .economics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .trace-layout,
  .activation-layout,
  .internal-layout,
  .developer-layout,
  .lower-layout,
  .audit-export-layout {
    grid-template-columns: 1fr;
  }

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

  .detail-panel {
    min-height: auto;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 16px;
  }

  .topbar,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .metric-strip,
  .split-grid,
  .controls-grid,
  .review-quality-grid,
  .review-board,
  .economics-grid,
  .use-case-row {
    grid-template-columns: 1fr;
  }

  .tab-button {
    min-width: 96px;
  }

  .segmented-control {
    width: 100%;
  }

  .segment {
    flex: 1;
    min-width: 0;
  }
}
