:root {
  color-scheme: light;
  --ink: #101820;
  --muted: #5d6670;
  --paper: #f7f8fa;
  --white: #ffffff;
  --line: #d9dee4;
  --yellow: #f6c945;
  --teal: #087f8c;
  --red: #c63c32;
  --green: #1f7a4d;
  --blue: #2155a3;
  --radius: 6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button { font: inherit; }

button:focus-visible {
  outline: 3px solid rgba(33, 85, 163, 0.35);
  outline-offset: 2px;
}

.topbar {
  min-height: 88px;
  padding: 18px clamp(20px, 4vw, 64px);
  background: var(--ink);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 5px solid var(--yellow);
}

.brand, .eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.topbar .brand { color: var(--yellow); }

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 1.65rem; line-height: 1.2; letter-spacing: 0; overflow-wrap: anywhere; }
h2 { margin-bottom: 0; font-size: 1.55rem; line-height: 1.25; letter-spacing: 0; }
h3 { margin-bottom: 0; font-size: 1rem; letter-spacing: 0; }

.header-status {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #d9e0e6;
  font-size: 0.9rem;
  white-space: nowrap;
}

.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 0 4px rgba(246, 201, 69, 0.14); }

.disclaimer {
  padding: 12px clamp(20px, 4vw, 64px);
  background: #fff6cf;
  border-bottom: 1px solid #e7cf72;
  font-size: 0.92rem;
  font-weight: 650;
}

main section { padding: 34px clamp(20px, 4vw, 64px); }
.workspace, .architecture, .mapping { background: var(--white); }

.workspace-heading, .section-heading, .panel-heading, .evidence-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.segmented { display: flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.segment { min-height: 40px; padding: 0 15px; border: 0; background: var(--white); color: var(--ink); cursor: pointer; }
.segment + .segment { border-left: 1px solid var(--line); }
.segment.active { background: var(--ink); color: var(--white); }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  margin-top: 24px;
}

.metric { padding: 16px 18px; min-width: 0; }
.metric + .metric { border-left: 1px solid var(--line); }
.metric span, .evidence-grid span, .hash-line span { display: block; color: var(--muted); font-size: 0.8rem; font-weight: 700; }
.metric strong { display: block; margin-top: 4px; font-size: 1.2rem; overflow-wrap: anywhere; }

.monitor-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.7fr); gap: 18px; margin-top: 18px; }
.event-list-wrap, .trace-panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); min-width: 0; }
.panel-heading { min-height: 52px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.panel-heading button, .fault-controls button {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid #b9c1ca;
  border-radius: 4px;
  background: var(--white);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}
.panel-heading button:hover, .fault-controls button:hover { border-color: var(--teal); color: var(--teal); }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 12px 14px; border-bottom: 1px solid #edf0f2; text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: 0.76rem; text-transform: uppercase; }
tbody tr { cursor: pointer; }
tbody tr:hover, tbody tr.selected { background: #f0f7f8; }
.event-select { padding: 0; border: 0; background: transparent; color: var(--blue); text-decoration: underline; font-weight: 700; cursor: pointer; }
.context-note { margin: 20px 0 0; font-size: .875rem; max-width: 85ch; }
.evidence .context-note { color: #cbd4dd; }
.evidence-dates { display: flex; flex-wrap: wrap; gap: 8px 28px; margin-top: 20px; font-size: .875rem; }
.evidence-dates p { margin: 0; }
.report-links { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 20px; }
.report-links a { color: #a6e9f0; text-underline-offset: 4px; }
.empty { padding: 30px 14px; text-align: center; color: var(--muted); }
.decision { font-weight: 750; }
.decision.candidate { color: var(--red); }
.decision.rejected { color: var(--green); }

.trace-details { margin: 0; padding: 4px 16px; }
.trace-details div { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 12px; padding: 10px 0; border-bottom: 1px solid #edf0f2; }
.trace-details dt { color: var(--muted); font-size: 0.82rem; font-weight: 700; }
.trace-details dd { margin: 0; overflow-wrap: anywhere; font-weight: 650; }
.reason-box { margin: 14px; padding: 13px; background: var(--ink); color: var(--white); border-left: 5px solid var(--yellow); }
.reason-box span { display: block; color: #aeb8c2; font-size: 0.78rem; }
.reason-box strong { display: block; margin-top: 3px; overflow-wrap: anywhere; }

.fault-band { background: #e8f2f4; border-top: 1px solid #c5dfe3; border-bottom: 1px solid #c5dfe3; }
.fault-controls { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 18px; }
.fault-output { display: block; margin-top: 14px; padding: 13px 15px; border-left: 4px solid var(--teal); background: var(--white); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; overflow-wrap: anywhere; }

.flow { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr auto 1fr; align-items: stretch; gap: 10px; margin-top: 24px; }
.flow-node { min-height: 138px; padding: 16px; border: 1px solid var(--line); border-top: 4px solid var(--teal); border-radius: var(--radius); }
.flow-node span { display: block; color: var(--teal); font-size: 0.78rem; font-weight: 800; }
.flow-node strong { display: block; margin: 10px 0 6px; }
.flow-node small { display: block; color: var(--muted); font-size: 0.82rem; }
.flow-arrow { align-self: center; color: var(--muted); font-weight: 900; }

.evidence { background: var(--ink); color: var(--white); }
.evidence .eyebrow { color: var(--yellow); }
.evidence-state { padding: 6px 10px; border: 1px solid #65717e; border-radius: 4px; font-size: 0.82rem; }
.evidence-state.passed { color: #9ee6c2; border-color: var(--green); }
.evidence-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 24px; border: 1px solid #42505d; }
.evidence-grid div { padding: 17px; }
.evidence-grid div:not(:nth-child(4n + 1)) { border-left: 1px solid #42505d; }
.evidence-grid div:nth-child(n + 5) { border-top: 1px solid #42505d; }
.evidence-grid span { color: #aeb8c2; }
.evidence-grid strong { display: block; margin-top: 5px; font-size: 1.25rem; overflow-wrap: anywhere; }
.hash-line { margin-top: 15px; }
.hash-line span { color: #aeb8c2; }
.hash-line code { display: block; margin-top: 5px; color: var(--yellow); overflow-wrap: anywhere; }

.mapping-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); margin-top: 24px; }
.mapping-grid div { min-height: 112px; padding: 18px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.mapping-grid strong { display: block; margin-bottom: 7px; color: var(--blue); }
.mapping-grid span { color: var(--muted); }

footer { padding: 20px clamp(20px, 4vw, 64px); display: flex; justify-content: space-between; gap: 20px; background: #e9edf1; color: #39434d; font-size: 0.82rem; }

@media (max-width: 920px) {
  .metrics, .evidence-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:nth-child(3), .metric:nth-child(4), .evidence-grid div:nth-child(3), .evidence-grid div:nth-child(4) { border-top: 1px solid var(--line); }
  .metric:nth-child(3), .evidence-grid div:nth-child(3) { border-left: 0; }
  .monitor-grid { grid-template-columns: 1fr; }
  .flow { grid-template-columns: 1fr; }
  .flow-arrow { transform: rotate(90deg); justify-self: center; }
}

@media (max-width: 620px) {
  .topbar, .workspace-heading, .section-heading, .evidence-heading, footer { align-items: flex-start; flex-direction: column; }
  .header-status { white-space: normal; }
  main section { padding: 27px 18px; }
  .disclaimer, .topbar, footer { padding-left: 18px; padding-right: 18px; }
  .metrics, .evidence-grid, .mapping-grid { grid-template-columns: 1fr; }
  .metric + .metric, .evidence-grid div + div { border-left: 0; border-top: 1px solid var(--line); }
  .mapping-grid { border-left: 1px solid var(--line); }
  .segmented { width: 100%; }
  .segment { flex: 1; }
  .trace-details div { grid-template-columns: 94px minmax(0, 1fr); }
}
