:root {
  --bg: #f7f8f6;
  --surface: #ffffff;
  --surface-2: #f2f5f3;
  --ink: #26302b;
  --muted: #68736d;
  --border: #dfe7e2;
  --accent: #315b48;
  --accent-2: #315a78;
  --accent-bright: #f2b84b;
  --accent-bright-hover: #dfa43a;
  --accent-bright-light: #fff5df;
  --accent-bright-ink: #5c3a05;
  --shadow: 0 8px 24px rgba(32, 42, 36, 0.08);
  --mono: "SFMono-Regular", "JetBrains Mono", Consolas, monospace;
  --body: "Century", "Century Schoolbook", Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  line-height: 1.55;
}

button,
select {
  font: inherit;
}

button,
.header-link {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 14px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.report-page {
  width: min(1540px, 100%);
  margin: 0 auto;
  padding: 24px 28px 44px;
}

.report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 18px;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.1;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

h3,
h4 {
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0;
  text-transform: uppercase;
}

.header-link,
.secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--ink);
}

.primary,
.primary-link {
  background: var(--accent);
  color: #ffffff;
}

.primary-link {
  border-color: var(--accent-bright);
  background: var(--accent-bright);
  color: var(--accent-bright-ink);
}

.primary-link:hover {
  background: var(--accent-bright-hover);
  border-color: var(--accent-bright-hover);
}

.report-controls,
.metrics-strip,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.report-controls {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  margin-bottom: 16px;
  padding: 16px;
}

.report-controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.download-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-left: auto;
}

.download-link {
  background: var(--surface-2);
  border-color: var(--border);
}

.report-controls select {
  min-width: 220px;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--ink);
}

.checkbox-label {
  display: flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  min-height: 40px;
}

.metrics-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 0;
  margin-bottom: 16px;
  overflow: hidden;
}

.metric {
  padding: 15px 16px;
  border-right: 1px solid var(--border);
}

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

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
  line-height: 1.1;
}

.grid-two {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, 0.8fr);
  gap: 16px;
  margin-bottom: 16px;
}

.detail-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(380px, 0.65fr);
}

.panel {
  min-width: 0;
  padding: 16px;
}

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

.panel-heading span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.table-wrap {
  max-height: 520px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  font-size: 14px;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tr.is-selected td {
  background: var(--accent-bright-light);
}

.link-button {
  min-height: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent-2);
  font-weight: 800;
  text-align: left;
}

.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.count-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.count-row:last-child {
  border-bottom: 0;
}

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

.summary-stack {
  display: grid;
  gap: 0;
}

.patch-detail {
  display: grid;
  gap: 12px;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-meta span {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.detail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.detail-list div {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}

dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

dd {
  margin: 2px 0 0;
}

pre {
  max-height: 300px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfb;
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
}

.empty-state {
  padding: 18px;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 8px;
}

.empty-state.compact {
  padding: 10px;
}

.report-toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 44px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #ffffff;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.report-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 960px) {
  .report-header,
  .report-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .download-actions {
    margin-left: 0;
  }

  .metrics-strip,
  .grid-two,
  .detail-grid,
  .breakdown-grid,
  .detail-list {
    grid-template-columns: 1fr;
  }

  .metric {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

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