:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef3ef;
  --ink: #1d2525;
  --muted: #5d6968;
  --line: #d9dfdb;
  --blue: #246b8f;
  --green: #287354;
  --gold: #a66d08;
  --red: #b14545;
  --shadow: 0 14px 38px rgba(31, 44, 42, 0.1);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(246, 247, 244, 0.98)),
    var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    box-shadow 120ms ease;
}

button:hover:not(:disabled),
button:focus-visible {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(36, 107, 143, 0.14);
  outline: none;
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  color: #8a9492;
  cursor: wait;
}

button.primary {
  border-color: #1f5f80;
  background: #246b8f;
  color: #ffffff;
}

button span[aria-hidden="true"] {
  display: inline-block;
  width: 1.2em;
  margin-right: 0.2rem;
  text-align: center;
}

a {
  color: var(--blue);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: #1f5f80;
  color: white;
  font-weight: 800;
}

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

h1 {
  font-size: 1.1rem;
  line-height: 1.15;
}

h2 {
  font-size: clamp(1.35rem, 2vw, 1.9rem);
  line-height: 1.15;
}

h3 {
  font-size: 1rem;
  line-height: 1.25;
}

.brand-block p,
.message,
.metric span,
.event-meta,
.mini-status,
.detail-empty,
.timeline.empty,
.sources-grid.empty {
  color: var(--muted);
}

.topnav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.4rem;
}

.topnav a,
.contract-links a,
.boundary-tags span,
.mini-status,
.state-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
}

.topnav a {
  padding: 0.55rem 0.75rem;
}

main {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1rem 0 2.5rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.8fr);
  gap: 1rem;
  align-items: stretch;
  margin-top: 1rem;
}

.controls,
.summary,
.timeline-panel,
.detail-panel,
.band {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.controls,
.summary {
  padding: 1rem;
}

.panel-heading,
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.panel-heading.tight {
  align-items: center;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin-bottom: 0.3rem;
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.state-pill {
  flex: 0 0 auto;
  padding: 0.5rem 0.65rem;
}

.state-pill.ok {
  border-color: rgba(40, 115, 84, 0.3);
  background: #e8f4ed;
  color: var(--green);
}

.state-pill.running {
  border-color: rgba(166, 109, 8, 0.35);
  background: #fff4dc;
  color: var(--gold);
}

.state-pill.error {
  border-color: rgba(177, 69, 69, 0.35);
  background: #fbe9e9;
  color: var(--red);
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.control-grid label:first-child {
  grid-column: span 2;
}

label {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

label span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
  color: var(--ink);
}

input,
select {
  height: 42px;
  padding: 0 0.7rem;
}

textarea {
  resize: vertical;
  padding: 0.7rem;
  line-height: 1.35;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(36, 107, 143, 0.14);
  outline: none;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.button-row button {
  padding: 0 0.85rem;
}

.button-row.compact {
  margin-top: 0.65rem;
}

.operator-panel {
  margin-top: 1rem;
  border-top: 1px solid var(--line);
  padding-top: 0.85rem;
}

.operator-panel summary {
  cursor: pointer;
  font-weight: 800;
}

.operator-panel label {
  margin-top: 0.85rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

.metric {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 0.8rem;
}

.metric strong {
  display: block;
  margin-top: 0.3rem;
  overflow-wrap: anywhere;
  font-size: 1.25rem;
  line-height: 1.1;
}

.message {
  margin-top: 1rem;
  border-left: 4px solid var(--blue);
  padding: 0.8rem 0.9rem;
  background: #f4f8fa;
  line-height: 1.45;
}

.contract-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.contract-links a {
  padding: 0.5rem 0.7rem;
}

.band {
  margin-top: 1rem;
  padding: 1rem;
}

.band.alt {
  background: #fbfcfb;
}

.boundary-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.4rem;
}

.boundary-tags span,
.mini-status {
  padding: 0.48rem 0.65rem;
}

.stream-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 1rem;
  margin-top: 1rem;
}

.timeline-panel,
.detail-panel {
  min-width: 0;
  padding: 1rem;
}

.timeline {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.85rem;
}

.timeline.empty,
.detail-empty,
.sources-grid.empty,
.source-import-grid.empty,
.convergence-panel.empty {
  min-height: 132px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
}

.event-row {
  position: relative;
  padding-left: 1.25rem;
}

.event-row::before {
  position: absolute;
  top: 0.75rem;
  left: 0.2rem;
  width: 0.55rem;
  height: 0.55rem;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: var(--blue);
  box-shadow: 0 0 0 2px rgba(36, 107, 143, 0.24);
  content: "";
}

.event-row::after {
  position: absolute;
  top: 1.55rem;
  bottom: -0.55rem;
  left: 0.45rem;
  width: 1px;
  background: var(--line);
  content: "";
}

.event-row:last-child::after {
  display: none;
}

.event-button {
  display: grid;
  width: 100%;
  min-height: 70px;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.25rem 0.7rem;
  align-items: center;
  padding: 0.75rem;
  text-align: left;
}

.event-button.active {
  border-color: rgba(36, 107, 143, 0.55);
  background: #f2f9fc;
}

.event-kind {
  grid-row: span 2;
  min-width: 118px;
  border-radius: 999px;
  background: #e7f1f5;
  color: #1f5f80;
  padding: 0.45rem 0.6rem;
  font-size: 0.76rem;
  font-weight: 800;
  text-align: center;
}

.event-title,
.event-meta {
  min-width: 0;
  overflow-wrap: anywhere;
}

.event-title {
  font-size: 0.98rem;
}

.detail-grid,
.source-detail {
  display: grid;
  gap: 0.7rem;
  margin-top: 0.85rem;
}

.kv-list {
  display: grid;
  grid-template-columns: minmax(110px, 0.35fr) minmax(0, 1fr);
  gap: 0.45rem 0.7rem;
  align-items: start;
}

.kv-list dt {
  color: var(--muted);
  font-weight: 800;
}

.kv-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

pre {
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #172221;
  color: #eef8f4;
  padding: 0.85rem;
  font-size: 0.82rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.sources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.source-import-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.edfi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.edfi-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 1rem;
}

.source-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0.9rem;
}

.source-card h3 {
  margin-bottom: 0.45rem;
}

.record-list {
  display: grid;
  gap: 0.7rem;
  margin-top: 0.85rem;
}

.record-list.empty {
  min-height: 132px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 1rem;
  color: var(--muted);
  text-align: center;
}

.record-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 0.85rem;
}

.record-card h3 {
  margin-bottom: 0.65rem;
  overflow-wrap: anywhere;
}

.convergence-panel {
  display: grid;
  gap: 0.85rem;
  margin-top: 1rem;
}

.convergence-question {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f8fa;
  padding: 0.85rem;
}

.convergence-question small,
.question-header p {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  line-height: 1.45;
}

.question-card {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 0.85rem;
}

.question-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  min-width: 0;
}

.question-header h3 {
  overflow-wrap: anywhere;
}

.convergence-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.convergence-card,
.rule-box {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0.9rem;
}

.convergence-card h3,
.rule-box h3 {
  margin-bottom: 0.45rem;
}

.convergence-card strong {
  display: block;
  color: var(--green);
  font-size: 1.2rem;
  line-height: 1.1;
}

.convergence-card p,
.rule-box li {
  margin-top: 0.5rem;
  overflow-wrap: anywhere;
  color: var(--muted);
}

.rule-box ul {
  margin: 0.5rem 0 0.8rem;
  padding-left: 1.2rem;
}

.storage-evidence p {
  margin-top: 0.35rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--green);
  font-weight: 800;
}

.status-dot::before {
  width: 0.58rem;
  height: 0.58rem;
  border-radius: 999px;
  background: currentColor;
  content: "";
}

.table-wrap {
  margin-top: 1rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: var(--surface);
}

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

th {
  background: #eef3ef;
  color: #31403e;
  font-size: 0.78rem;
  text-transform: uppercase;
}

td {
  overflow-wrap: anywhere;
}

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

.status-ok {
  color: var(--green);
  font-weight: 800;
}

.status-error {
  color: var(--red);
  font-weight: 800;
}

@media (max-width: 980px) {
  .workspace,
  .stream-layout,
  .source-import-grid,
  .edfi-grid {
    grid-template-columns: 1fr;
  }

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

  .control-grid label:first-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  .topbar,
  .section-heading,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .topnav,
  .boundary-tags {
    justify-content: flex-start;
  }

  main {
    width: min(100% - 1rem, 1180px);
  }

  .control-grid,
  .metric-grid,
  .convergence-grid {
    grid-template-columns: 1fr;
  }

  .control-grid label:first-child {
    grid-column: auto;
  }

  .button-row button {
    flex: 1 1 150px;
  }

  .event-button {
    grid-template-columns: 1fr;
  }

  .event-kind {
    width: fit-content;
    min-width: 0;
  }

  .convergence-question,
  .question-header {
    align-items: flex-start;
    flex-direction: column;
  }
}
