:root {
  color-scheme: light;
  --page: #f5f6f7;
  --surface: #ffffff;
  --surface-subtle: #fafbfc;
  --ink: #181b20;
  --muted: #626a75;
  --line: #e1e5e9;
  --line-strong: #cbd1d7;
  --accent: #1769aa;
  --accent-soft: #e9f3fb;
  --green: #247452;
  --green-soft: #e8f4ed;
  --amber: #996318;
  --amber-soft: #fff3dc;
  --red: #a43f39;
  --red-soft: #faeae8;
  --shadow: 0 24px 70px rgba(23, 31, 40, 0.18);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.48;
}

body.drawer-open {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

h1 {
  margin-bottom: 6px;
  font-size: 25px;
  font-weight: 660;
  letter-spacing: -0.02em;
  line-height: 1.12;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

h3 {
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.3;
}

.topbar,
main {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding-right: 32px;
  padding-left: 32px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 36px;
  padding-top: 30px;
  padding-bottom: 24px;
}

.topbar-note {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar-note b {
  color: var(--ink);
  font-weight: 650;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 740;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.snapshot {
  display: grid;
  min-width: 210px;
  padding: 10px 12px;
  border-left: 2px solid var(--accent);
  background: var(--surface);
}

.snapshot span,
.snapshot small {
  color: var(--muted);
  font-size: 10px;
}

.snapshot strong {
  margin: 2px 0;
  font-size: 12px;
  font-weight: 650;
}

main {
  padding-bottom: 64px;
}

.summary-section {
  padding: 24px 0 22px;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
}

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

.summary-copy p:last-child {
  max-width: 700px;
  margin-bottom: 0;
  color: var(--muted);
  text-align: right;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.metric {
  min-height: 72px;
  padding: 10px 14px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
  transition: background 150ms ease, box-shadow 150ms ease;
}

.metric:last-child {
  border-right: 0;
}

.metric:hover,
.metric.selected {
  background: var(--surface);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.metric strong,
.metric span {
  display: block;
}

.metric strong {
  font-size: 26px;
  font-variant-numeric: tabular-nums;
  font-weight: 630;
  line-height: 1.05;
}

.metric span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
}

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

.tabs {
  display: flex;
  flex-wrap: wrap;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  overflow: hidden;
}

.tab {
  min-height: 33px;
  padding: 6px 11px;
  border: 0;
  border-right: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
}

.tab:last-child {
  border-right: 0;
}

.tab:hover {
  background: var(--surface-subtle);
  color: var(--ink);
}

.tab.active {
  background: #20242a;
  color: #fff;
}

.view-actions {
  display: flex;
  align-items: flex-end;
  gap: 7px;
}

.view-actions label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
}

.view-actions input,
.view-actions select {
  min-height: 33px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  padding: 6px 9px;
}

.view-actions input {
  width: 290px;
}

.view-actions select {
  width: 160px;
}

#resetFilter,
#copyVisible,
#closeDetail {
  min-height: 33px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  padding: 6px 11px;
}

#resetFilter:hover,
#copyVisible:hover,
#closeDetail:hover {
  background: var(--surface-subtle);
}

.flow-section {
  padding: 30px 0 26px;
}

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

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

.flow-scroll {
  overflow-x: auto;
  padding-bottom: 4px;
}

#flowSvg {
  display: block;
  width: 100%;
  min-width: 1200px;
  height: auto;
}

.flow-link {
  fill: none;
  stroke: #d6dce1;
  stroke-width: 6;
  stroke-linecap: round;
  cursor: pointer;
  transition: stroke 160ms ease, stroke-width 160ms ease;
}

.flow-link:hover,
.flow-link.selected {
  stroke: var(--accent);
  stroke-width: 8;
}

.section-separator {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 1;
  stroke-dasharray: 5 7;
}

.flow-node {
  cursor: pointer;
  outline: none;
}

.flow-node rect {
  fill: var(--surface);
  stroke: var(--line-strong);
  stroke-width: 1;
  transition: fill 150ms ease, stroke 150ms ease;
}

.flow-node:hover rect,
.flow-node.selected rect {
  fill: var(--accent-soft);
  stroke: var(--accent);
}

.flow-node:focus rect,
.flow-node.selected rect {
  stroke-width: 2;
}

.flow-node.ok rect {
  fill: var(--green-soft);
  stroke: #9ab9a8;
}

.flow-node.warn rect {
  fill: var(--amber-soft);
  stroke: #d6b16d;
}

.flow-node.bad rect {
  fill: var(--red-soft);
  stroke: #d8a4a0;
}

.flow-node.info rect {
  fill: var(--accent-soft);
  stroke: #9dbdd6;
}

.flow-node.muted rect {
  fill: #eef0f2;
  stroke: #cbd0d5;
}

.flow-node.selected rect {
  stroke: var(--accent);
}

.flow-count {
  fill: var(--ink);
  font-size: 22px;
  font-weight: 630;
  font-variant-numeric: tabular-nums;
}

.flow-label {
  fill: var(--ink);
  font-size: 12px;
  font-weight: 660;
}

.flow-caption {
  fill: var(--muted);
  font-size: 10px;
}

.task-rail {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 1;
  stroke-dasharray: 4 5;
}

.rail-label {
  fill: var(--muted);
  font-size: 9px;
  font-weight: 730;
  letter-spacing: 0.12em;
}

.table-section {
  padding-top: 28px;
  border-top: 1px solid var(--line-strong);
}

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

table {
  width: 100%;
  min-width: 1240px;
  border-collapse: collapse;
  table-layout: fixed;
  text-align: left;
}

th {
  padding: 9px 11px;
  border-bottom: 1px solid var(--line-strong);
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 10px;
  font-weight: 730;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

th:nth-child(1) {
  width: 21%;
}

th:nth-child(2) {
  width: 12%;
}

th:nth-child(3) {
  width: 16%;
}

th:nth-child(4) {
  width: 15%;
}

th:nth-child(5) {
  width: 36%;
}

td {
  padding: 13px 11px;
  border-top: 1px solid var(--line);
  vertical-align: top;
  overflow-wrap: anywhere;
}

tbody tr:first-child td {
  border-top: 0;
}

tbody tr {
  cursor: pointer;
  transition: background 140ms ease;
}

tbody tr:hover,
tbody tr:focus {
  background: #fafbfd;
  outline: none;
}

td strong,
td span,
td small {
  display: block;
}

td strong {
  font-weight: 650;
}

td small,
td p {
  color: var(--muted);
}

td small {
  margin-top: 4px;
  font-size: 10px;
}

td small b {
  color: var(--ink);
  font-weight: 650;
}

.identity-cell > span {
  margin-top: 4px;
  color: var(--ink);
}

.identity-cell > small + span {
  margin-top: 9px;
}

.status-copy p {
  margin-bottom: 8px;
  color: var(--ink);
}

.tag {
  display: inline-block;
  width: max-content;
  max-width: 100%;
  margin-bottom: 4px;
  border-radius: 3px;
  padding: 3px 6px;
  font-size: 10px;
  font-weight: 650;
  line-height: 1.25;
}

.tag.ok {
  background: var(--green-soft);
  color: var(--green);
}

.tag.info {
  background: var(--accent-soft);
  color: var(--accent);
}

.tag.warn {
  background: var(--amber-soft);
  color: var(--amber);
}

.tag.bad {
  background: var(--red-soft);
  color: var(--red);
}

.tag.muted {
  background: #edf0f2;
  color: var(--muted);
}

.task-state {
  width: max-content;
  padding-left: 8px;
  border-left: 2px solid var(--line-strong);
  font-size: 11px;
  font-weight: 650;
}

.task-state.ok {
  border-color: var(--green);
  color: var(--green);
}

.task-state.bad {
  border-color: var(--red);
  color: var(--red);
}

.empty {
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

.detail-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(26, 33, 41, 0.3);
  backdrop-filter: blur(2px);
}

.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 21;
  width: min(660px, 100%);
  height: 100dvh;
  padding: 25px 28px 40px;
  transform: translateX(102%);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow-y: auto;
  transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

.detail-drawer.open {
  transform: translateX(0);
}

.detail-drawer > header {
  display: flex;
  justify-content: space-between;
  gap: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line-strong);
}

.detail-drawer > header p {
  margin-bottom: 0;
  color: var(--muted);
}

#detailBody {
  display: grid;
  gap: 20px;
  padding-top: 20px;
}

#detailBody > section {
  padding-bottom: 19px;
  border-bottom: 1px solid var(--line);
}

#detailBody > section:last-child {
  border-bottom: 0;
}

.status-path {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.status-path span {
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface-subtle);
  font-size: 11px;
  font-weight: 620;
}

.status-path i {
  color: var(--muted);
  font-style: normal;
}

.detail-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.detail-summary > div {
  padding: 10px 11px;
  border-left: 2px solid var(--line-strong);
  background: var(--surface-subtle);
}

.detail-summary span,
.detail-summary strong {
  display: block;
}

.detail-summary span {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
}

.detail-summary strong {
  font-size: 12px;
  font-weight: 620;
}

.detail-links {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.detail-links a {
  padding: 6px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 620;
}

.contacts-grid,
.task-list,
.note-list {
  display: grid;
  gap: 8px;
}

.contact-card {
  display: grid;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-subtle);
}

.contact-card span {
  color: var(--muted);
  font-size: 10px;
}

.contact-card a {
  margin-top: 3px;
  width: max-content;
  font-size: 11px;
}

.task-detail {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: 4px;
  background: var(--surface-subtle);
}

.task-detail.open {
  border-left-color: var(--amber);
}

.task-detail.complete {
  border-left-color: var(--line-strong);
}

.task-detail strong {
  display: block;
  font-size: 11px;
}

.task-detail time {
  color: var(--muted);
  font-size: 10px;
}

.task-detail p {
  grid-column: 1 / -1;
  margin-bottom: 0;
  color: var(--muted);
  white-space: pre-wrap;
}

.missing-callout {
  margin-bottom: 0;
  padding: 10px 12px;
  border-left: 3px solid var(--red);
  background: var(--red-soft);
  color: var(--red);
}

.section-note {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 11px;
}

.note {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
}

.note summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 10px;
  cursor: pointer;
  color: var(--ink);
  font-size: 11px;
  font-weight: 630;
}

.note summary time {
  color: var(--muted);
  font-size: 10px;
  font-weight: 400;
}

.note p {
  margin: 0;
  padding: 0 10px 12px;
  color: var(--muted);
  white-space: pre-wrap;
}

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

@media (max-width: 1080px) {
  .metric-strip {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
  }

  .metric:nth-child(4) {
    border-right: 0;
  }

  .metric:nth-child(-n + 4) {
    border-bottom: 1px solid var(--line);
  }

  .viewbar,
  .summary-copy {
    align-items: stretch;
    flex-direction: column;
  }

  .summary-copy p:last-child {
    text-align: left;
  }

  .view-actions {
    align-items: stretch;
  }

  .view-actions label:first-child {
    flex: 1;
  }

  .view-actions input {
    width: 100%;
  }
}

@media (max-width: 720px) {
  .topbar,
  main {
    padding-right: 18px;
    padding-left: 18px;
  }

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

  .snapshot {
    min-width: 0;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .view-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .view-actions label:first-child,
  #resetFilter {
    grid-column: 1 / -1;
  }

  .view-actions select {
    width: 100%;
  }

  .tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .tab:nth-child(even) {
    border-right: 0;
  }

  .tab {
    border-bottom: 1px solid var(--line-strong);
  }

  .detail-drawer {
    padding: 21px 18px 32px;
  }

  .detail-summary {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 22px;
  }

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

  .metric:nth-child(3) {
    border-right: 1px solid var(--line);
  }

  .metric:nth-child(even) {
    border-right: 0;
  }

  .metric:nth-child(-n + 6) {
    border-bottom: 1px solid var(--line);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .detail-drawer {
    transition: none;
  }
}
