:root {
  --black: #0f0f0d;
  --white: #fcfcfa;
  --paper: #f5f4ee;
  --blue: #1e3af6;
  --gray: #6b6a63;
  --line: #dedcd2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--white);
  color: var(--black);
  font-family: "Archivo", sans-serif;
  font-weight: 400;
  line-height: 1.5;
}

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 24px 72px;
}

.site-header {
  margin-bottom: 40px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
  font-family: "Archivo", sans-serif;
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--black);
  text-decoration: none;
  transition: color 0.15s ease;
}

.wordmark:hover {
  color: var(--blue);
}

.wordmark-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--blue);
  transform: translateY(-1px);
}

.header {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 8px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gray);
}

h1,
h2,
h3 {
  font-family: "Archivo", sans-serif;
  margin: 0;
}

h1 {
  font-weight: 800;
  font-size: clamp(2rem, 4vw, 2.75rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
}

h2 {
  font-weight: 700;
  font-size: 1.35rem;
  line-height: 1.2;
}

h3 {
  font-weight: 700;
  font-size: 1.1rem;
}

.subtitle,
.section-head p,
.status {
  color: var(--gray);
  font-weight: 400;
}

.subtitle {
  margin: 10px 0 0;
}

.date-filter {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
}

.date-filter label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray);
}

.date-filter input,
.date-filter button {
  font: inherit;
}

.date-filter input {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--black);
  padding: 10px 12px;
  border-radius: 8px;
}

.date-filter input:focus {
  outline: 1px solid var(--blue);
  outline-offset: 0;
}

.date-filter button {
  border: none;
  background: var(--black);
  color: var(--white);
  font-weight: 500;
  padding: 11px 18px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.date-filter button:hover:not(:disabled) {
  background: var(--blue);
  color: var(--white);
}

.date-filter button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.status {
  min-height: 1.5rem;
  margin: 0 0 24px;
  font-size: 0.875rem;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 40px;
}

.metric-card {
  background: var(--paper);
  border-radius: 8px;
  padding: 18px 20px;
}

.metric-card.emphasis {
  background: var(--white);
  outline: 1px solid var(--blue);
  outline-offset: -1px;
}

.metric-card .label {
  color: var(--gray);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 10px;
}

.metric-card .value {
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.75rem;
  font-weight: 500;
  color: var(--black);
  line-height: 1.1;
}

.section {
  padding-top: 32px;
  margin-top: 32px;
  border-top: 1px solid var(--line);
}

.section-head {
  margin-bottom: 20px;
}

.section-head p {
  margin: 8px 0 0;
  font-size: 0.9375rem;
}

.flow-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.path-segment-label {
  margin: 0 0 12px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gray);
}

.path-handoff {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.path-handoff-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--black);
}

.path-handoff-value {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--blue);
}

.main-path {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.main-path.followup-path {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.path-step,
.exit-card {
  background: var(--paper);
  border-radius: 8px;
  padding: 16px 18px;
  cursor: pointer;
  transition: background-color 0.15s ease, outline-color 0.15s ease;
}

.path-step:hover,
.exit-card:hover,
.clickable-row:hover {
  background: var(--white);
  outline: 1px solid var(--blue);
  outline-offset: -1px;
}

.path-step .count,
.exit-card .count {
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--black);
}

.path-step .label,
.exit-card .label {
  font-weight: 500;
  margin: 8px 0 0;
}

.exit-card-meta {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gray);
  margin-bottom: 8px;
}

.path-step .conversion {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8125rem;
  color: var(--gray);
}

.exit-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gray);
  text-align: left;
  padding: 0 10px 12px;
  border-bottom: 1px solid var(--line);
}

.data-table td {
  text-align: left;
  padding: 14px 10px;
  border-bottom: 1px solid var(--line);
}

.data-table td:last-child {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 500;
}

.data-table tbody tr {
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.data-table tbody tr:hover {
  background: var(--paper);
}

.detail-modal {
  border: none;
  padding: 0;
  background: transparent;
  width: min(720px, calc(100vw - 32px));
}

.detail-modal::backdrop {
  background: rgba(15, 15, 13, 0.4);
}

.detail-inner {
  background: var(--white);
  border-radius: 8px;
  padding: 28px 24px 24px;
  border: 1px solid var(--line);
  position: relative;
}

.close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--gray);
  cursor: pointer;
  transition: color 0.15s ease;
}

.close-btn:hover {
  color: var(--blue);
}

.linkish {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--black);
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
  cursor: pointer;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

.linkish:hover {
  color: var(--blue);
  text-decoration-color: var(--blue);
}

.timeline {
  list-style: none;
  padding: 0;
  margin: 20px 0 0;
}

.timeline li {
  display: grid;
  grid-template-columns: 148px 1fr;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.timeline .when {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8125rem;
  color: var(--gray);
}

.timeline .kind-stage {
  color: var(--black);
  font-weight: 500;
}

.timeline .kind-activity {
  color: var(--gray);
}

body.is-loading .metrics,
body.is-loading .flow-layout,
body.is-loading .exit-grid,
body.is-loading .data-table {
  opacity: 0.45;
  pointer-events: none;
}

@media (max-width: 980px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .main-path,
  .main-path.followup-path,
  .exit-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .header {
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .metrics,
  .main-path,
  .main-path.followup-path,
  .exit-grid {
    grid-template-columns: 1fr;
  }

  .timeline li {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
