:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --panel: #ffffff;
  --text: #16211f;
  --muted: #5e6a67;
  --line: #dce2df;
  --accent: #0f7b6c;
  --accent-strong: #09584e;
  --warn: #9b5a10;
  --shadow: 0 16px 36px rgba(20, 38, 35, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

a {
  color: inherit;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.shell.wide {
  width: min(1360px, calc(100% - 28px));
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 0 28px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  max-width: 760px;
  margin-bottom: 0;
  font-size: clamp(32px, 5vw, 58px);
  line-height: 1;
  letter-spacing: 0;
}

.lede {
  max-width: 820px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 0 16px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  text-decoration: none;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 16px;
  margin: 28px 0;
}

label span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  padding: 0 12px;
}

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

.section-heading h2 {
  margin: 0;
  font-size: 22px;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.card {
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
}

.card h3 {
  margin-bottom: 8px;
  font-size: 20px;
}

.card p {
  color: var(--muted);
  line-height: 1.5;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.meta.tight {
  margin-top: 0;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.pill.internal {
  color: var(--warn);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 28px 0;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 28px 0;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
}

.metric strong {
  display: block;
  font-size: 34px;
}

.metric.compact strong {
  font-size: 28px;
}

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

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

table {
  width: 100%;
  border-collapse: collapse;
}

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

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

.cell-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.dense {
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
}

.mini-list {
  margin: 16px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.5;
}

.graph-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: stretch;
}

.graph-panel,
.detail-panel {
  min-height: 700px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.graph-panel {
  overflow: hidden;
}

.detail-panel {
  padding: 18px;
  overflow: auto;
}

#graph {
  display: block;
  width: 100%;
  height: 700px;
}

.edge {
  stroke: #cbd5d0;
  stroke-width: 1;
}

.graph-node {
  cursor: pointer;
}

.graph-node circle {
  stroke: white;
  stroke-width: 2;
}

.graph-node text {
  fill: var(--text);
  font-size: 11px;
  paint-order: stroke;
  stroke: white;
  stroke-width: 4px;
}

.graph-node.selected circle {
  stroke: #111827;
  stroke-width: 4;
}

.flow-card {
  position: relative;
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 20px;
}

.flow-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.flow-header h2 {
  margin: 0;
}

.flow-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 18px 0;
}

.flow-line span {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f9faf9;
  padding: 9px 11px;
  font-weight: 700;
}

.flow-line b {
  color: var(--muted);
}

.diagram-shell {
  margin-top: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: auto;
}

.diagram-summary {
  margin-top: 28px;
}

#diagram-svg {
  display: block;
  min-width: 980px;
  width: 100%;
  height: auto;
}

.diagram-edge {
  fill: none;
  stroke: #9ca3af;
  stroke-width: 2;
  marker-end: url("#arrow");
}

.edge-label {
  fill: #4b5563;
  font-size: 12px;
  font-weight: 700;
  text-anchor: middle;
}

.node-title {
  fill: var(--text);
  font-size: 15px;
  font-weight: 800;
}

.node-kind,
.node-note {
  fill: var(--muted);
  font-size: 12px;
}

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

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

  .toolbar,
  .metrics,
  .stats-row,
  .graph-layout {
    grid-template-columns: 1fr;
  }

  .graph-panel,
  .detail-panel,
  #graph {
    min-height: 520px;
    height: 520px;
  }
}
