:root {
  --navy: #1a1a1a;
  --ink: #0a0a0a;
  --muted: #6b6b6b;
  --faint: #9a9a9a;
  --line: #d8d8d0;
  --line-light: #ebebe6;
  --soft: #f7f7f4;
  --paper: #fdfdf9;
  --red: #c0392b;
  --green: #00843d;
  --amber: #8a5c00;
  --low-red: #b41f2a;
  --header: #f7f7f4;
  --hover: #fdfdf9;
  --font-main: "DM Sans", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-heading: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--soft);
  color: var(--navy);
  font-family: var(--font-main);
}

button, input, select { font: inherit; }

.topbar {
  display: block;
  padding: 0 36px;
  border-top: 0;
  border-bottom: 3px solid var(--ink);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
  overflow: hidden;
}

.topbar::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 7px;
  height: 100%;
  background: var(--green);
  content: "";
}

.topbar::after {
  position: absolute;
  top: 0;
  right: 0;
  width: 120px;
  height: 7px;
  background: var(--red);
  content: "";
}

.brand {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: -0.2px;
  line-height: 1.1;
  color: var(--ink);
  padding: 14px 0 0;
  border-bottom: 0;
}

.main-tabs {
  display: flex;
  gap: 0;
  border-top: 1px solid var(--line);
  border-bottom: 0;
  width: 100%;
  margin-top: 0;
  margin-top: 12px;
}

.tab-button {
  border: 0;
  border-right: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
  flex: 0 1 200px;
  min-width: 0;
  padding: 12px 20px 13px;
  border-bottom: 0;
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.25;
  text-align: left;
}

.tab-button:hover {
  color: var(--green);
  background: #fff;
}

.tab-button span {
  display: block;
  margin-bottom: 4px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.tab-button.active {
  background: var(--ink);
  color: #fff;
  box-shadow: inset 0 -3px 0 var(--green);
}

.tab-button.active span {
  color: rgba(255, 255, 255, 0.58);
}

.page-shell {
  max-width: 1360px;
  margin: 0 auto;
  padding: 28px 28px 56px;
}

.tab-panel { display: none; }

.tab-panel.active {
  display: block;
  background: transparent;
  border: 0;
  padding: 0;
  box-shadow: none;
}

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

.section-head > div:first-child {
  border-left: 4px solid var(--green);
  padding-left: 14px;
}

.section-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  padding-top: 2px;
}

h1, h2, h3, p { margin-top: 0; }
h1 {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 400;
  margin-bottom: 6px;
}
h2 { font-size: 16px; }
h3 { font-size: 17px; }
p { color: var(--muted); }

.control-row, .results-toolbar {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-top: 4px solid var(--ink);
  border-radius: 0;
  margin-bottom: 18px;
}

.control-row.compact { align-items: center; }

.view-toolbar {
  display: block;
}

.view-controls {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
}

.static-source-row {
  align-items: stretch;
}

.static-source-row .preset-source {
  min-width: 220px;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: uppercase;
}

.field select, .search-field input {
  min-width: 170px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--navy);
  padding: 0 10px;
}

.field select:focus, .search-field input:focus {
  border-color: var(--green);
  outline: 2px solid rgba(0, 132, 61, 0.12);
}

.field.small select { min-width: 120px; }
.search-field input { min-width: 230px; }

.results-toolbar .search-field {
  display: flex;
  align-items: flex-end;
}

.preset-source {
  min-height: 38px;
  display: grid;
  align-content: center;
  padding: 0 14px;
  border-left: 4px solid var(--green);
  background: #fff;
}

.preset-source span {
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.preset-source strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
}

.primary-btn, .secondary-btn, .file-btn {
  height: 38px;
  border-radius: 0;
  border: 1px solid var(--red);
  padding: 0 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.primary-btn {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
  box-shadow: none;
}

.secondary-btn, .file-btn {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.secondary-btn:hover, .file-btn:hover {
  border-color: var(--green);
  color: var(--green);
}

button:active, .file-btn:active { transform: translateY(1px); }
.file-btn input { display: none; }
.upload-note, .upload-strip span { color: var(--muted); font-size: 13px; }

.upload-strip {
  display: flex;
  gap: 18px;
  margin: -8px 0 16px;
}

.criteria-box, .plain-panel, .results-panel {
  border: 1px solid #c8c8c8;
  border-radius: 0;
  background: #fff;
  padding: 14px;
  margin-bottom: 18px;
}

.criteria-box {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  align-items: stretch;
}

.criteria-box strong {
  display: flex;
  align-items: center;
  color: var(--muted);
  background: transparent;
  margin: -14px 0 -14px -14px;
  padding: 14px 12px 14px 14px;
  border-right: 1px solid var(--line-light);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}

.criteria-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-content: center;
}

.criteria-box span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 10px;
  border-left: 2px solid var(--red);
  background: #fff8f7;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.25;
}

.criteria-review {
  border: 2px solid var(--red);
  border-top: 3px solid var(--red);
  background: #fff;
  margin-bottom: 18px;
  box-shadow: 0 8px 0 rgba(192, 57, 43, 0.08);
}

.review-heading {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(192, 57, 43, 0.35);
  background: #fff8f7;
}

.section-strip {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: -14px -14px 14px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.section-strip::after {
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 70px;
  height: 2px;
  background: var(--red);
  content: "";
}

.section-strip span {
  color: var(--faint);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.section-strip strong {
  color: var(--ink);
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 400;
}

.review-heading::after {
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 104px;
  height: 3px;
  background: var(--red);
  content: "";
}

.review-heading span,
.review-grid span {
  color: var(--red);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.review-heading strong {
  color: var(--ink);
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 400;
}

.review-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.bonus-overview-grid {
  grid-template-columns: 1.25fr 0.75fr;
}

.review-grid div {
  min-height: 122px;
  padding: 16px;
  border-right: 1px solid rgba(192, 57, 43, 0.18);
  background: linear-gradient(#fff, #fdfdf9);
}

.review-grid div:last-child {
  border-right: 0;
}

.review-grid p {
  margin: 8px 0 0;
  color: var(--navy);
  font-size: 13px;
  line-height: 1.5;
}

.bonus-criteria-panel {
  border: 1px solid var(--line);
  border-top: 3px solid var(--green);
  background: #fff;
  padding: 14px;
  margin-bottom: 18px;
}

.bonus-criteria-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.bonus-criteria-grid article {
  min-height: 148px;
  border: 1px solid var(--line-light);
  border-left: 3px solid var(--green);
  background: var(--paper);
  padding: 12px;
}

.bonus-criteria-grid strong {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 7px;
  background: var(--green);
  color: #fff;
  font-size: 11px;
  letter-spacing: 0.8px;
}

.bonus-criteria-grid span {
  display: block;
  margin: 10px 0 7px;
  color: var(--ink);
  font-weight: 700;
  line-height: 1.25;
}

.bonus-criteria-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.summary-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.view-summary {
  margin: 14px 0 0;
}

.view-summary .summary-card {
  border-color: var(--line);
  border-top-color: var(--ink);
  background: #fff;
}

.view-summary .summary-card span {
  color: var(--ink);
}

.summary-card {
  border: 1px solid var(--line);
  border-top: 4px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  padding: 16px;
  color: var(--muted);
}

.summary-card span {
  display: block;
  color: var(--ink);
  font-size: 25px;
  font-weight: 300;
  margin-bottom: 4px;
}

.summary-card small {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.summary-card.review-summary {
  border-color: color-mix(in srgb, var(--red) 45%, var(--line));
  border-top-color: var(--red);
  background: #fff;
}

.summary-card.review-summary span,
.summary-card.review-summary small {
  color: var(--red);
}

.table-wrap {
  position: relative;
  max-height: 380px;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid #bfbfbf;
  border-radius: 0;
  scrollbar-color: #8d8d86 var(--line-light);
  scrollbar-width: thin;
}

.table-wrap.tall { max-height: 520px; }
.case1-table-wrap { max-height: 620px; }
.case2-table-wrap {
  max-height: 560px;
  box-shadow: inset 0 -18px 18px -20px rgba(10, 10, 10, 0.7);
}

.case2-table-wrap::after {
  position: sticky;
  bottom: 0;
  display: block;
  height: 10px;
  margin-top: -10px;
  background: linear-gradient(to bottom, rgba(253, 253, 249, 0), rgba(253, 253, 249, 0.95));
  content: "";
  pointer-events: none;
}

.table-wrap::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

.table-wrap::-webkit-scrollbar-track { background: var(--line-light); }
.table-wrap::-webkit-scrollbar-thumb {
  background: #8d8d86;
  border: 3px solid var(--line-light);
}

.table-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: -4px 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.case2-table-meta span:last-child {
  color: var(--muted);
  font-weight: 500;
}

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

.case1-table { min-width: 0; }

th, td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 12px;
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: normal;
}

.case1-table th,
.case1-table td {
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.35;
}

.case1-table th:nth-child(1), .case1-table td:nth-child(1) { width: 12%; }
.case1-table th:nth-child(2), .case1-table td:nth-child(2) { width: 6%; }
.case1-table th:nth-child(3), .case1-table td:nth-child(3) { width: 6%; }
.case1-table th:nth-child(4), .case1-table td:nth-child(4) { width: 10%; }
.case1-table th:nth-child(5), .case1-table td:nth-child(5) { width: 29%; }
.case1-table th:nth-child(6), .case1-table td:nth-child(6) { width: 25%; }
.case1-table th:nth-child(7), .case1-table td:nth-child(7) { width: 11%; }

#case2-table th:nth-child(1), #case2-table td:nth-child(1) { width: 12%; }
#case2-table th:nth-child(2), #case2-table td:nth-child(2) { width: 6%; }
#case2-table th:nth-child(3), #case2-table td:nth-child(3) { width: 14%; }
#case2-table th:nth-child(4), #case2-table td:nth-child(4) { width: 6%; }
#case2-table th:nth-child(5), #case2-table td:nth-child(5) { width: 7%; }
#case2-table th:nth-child(6), #case2-table td:nth-child(6) { width: 28%; }
#case2-table th:nth-child(7), #case2-table td:nth-child(7) { width: 16%; }
#case2-table th:nth-child(8), #case2-table td:nth-child(8) { width: 11%; }

#bonus-table th:nth-child(1), #bonus-table td:nth-child(1) { width: 15%; }
#bonus-table th:nth-child(2), #bonus-table td:nth-child(2) { width: 6%; }
#bonus-table th:nth-child(3), #bonus-table td:nth-child(3) { width: 7%; }
#bonus-table th:nth-child(4), #bonus-table td:nth-child(4) { width: 8%; }
#bonus-table th:nth-child(5), #bonus-table td:nth-child(5) { width: 14%; }
#bonus-table th:nth-child(6), #bonus-table td:nth-child(6) { width: 5%; }
#bonus-table th:nth-child(7), #bonus-table td:nth-child(7) { width: 10%; }
#bonus-table th:nth-child(8), #bonus-table td:nth-child(8) { width: 25%; }
#bonus-table th:nth-child(9), #bonus-table td:nth-child(9) { width: 10%; }

#mapping-table th,
#mapping-table td {
  font-size: 11px;
  line-height: 1.3;
  padding: 8px 7px;
}

#mapping-table .badge,
#bonus-table .badge,
#case2-table .badge,
.case1-table .badge {
  padding-inline: 6px;
  white-space: normal;
}

#mapping-table .link-btn,
#bonus-table .link-btn,
#case2-table .link-btn,
.case1-table .link-btn {
  white-space: normal;
}

.case1-table th:last-child,
.case1-table td:last-child,
#case2-table th:last-child,
#case2-table td:last-child,
#mapping-table th:last-child,
#mapping-table td:last-child,
#bonus-table th:last-child,
#bonus-table td:last-child {
  text-align: center;
}

.numeric {
  font-variant-numeric: tabular-nums;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--ink);
  border-bottom: 3px solid var(--green);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  overflow-wrap: normal;
  word-break: normal;
}

.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  cursor: pointer;
  font: inherit;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  text-align: left;
  text-transform: inherit;
  overflow-wrap: normal;
  word-break: normal;
}

.sort-btn::after {
  color: rgba(255, 255, 255, 0.7);
  content: "↕";
  font-size: 10px;
}

.sort-btn.asc::after { content: "↑"; color: #fff; }
.sort-btn.desc::after { content: "↓"; color: #fff; }

tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--hover); }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 0;
  font-size: 12px;
  font-weight: 500;
}

.pass, .high { color: var(--green); background: #f0f7f2; }
.review, .medium { color: var(--amber); background: #fff8e8; }
.fail, .low { color: var(--low-red); background: #fdf2f0; }

.link-btn {
  border: 0;
  background: transparent;
  color: var(--red);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 420px));
  justify-content: center;
  gap: 16px;
  margin-bottom: 18px;
}

.theme-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 2px solid var(--red);
  border-top: 5px solid var(--red);
  border-radius: 0;
  padding: 18px;
  background: #fff;
  box-shadow: 0 8px 0 rgba(192, 57, 43, 0.08);
}

.theme-card::before {
  position: absolute;
  top: -5px;
  left: 0;
  width: 72px;
  height: 5px;
  background: var(--green);
  content: "";
}

.theme-card .case2-theme-detail {
  align-self: flex-start;
  margin-top: auto;
}

dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin: 14px 0;
}

dt { color: var(--muted); }
dd { margin: 0; font-weight: 700; }

.theme-metrics {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  margin: 16px 0;
}

.theme-metrics div {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 9px 0 8px;
  border-bottom: 2px solid rgba(192, 57, 43, 0.28);
}

.theme-metrics div:first-child {
  border-top: 2px solid rgba(192, 57, 43, 0.28);
}

.theme-metrics dt {
  color: var(--muted);
  font-size: 14px;
}

.theme-metrics dd {
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
}

.theme-metrics .badge {
  border-bottom: 2px solid var(--red);
  background: transparent;
}

.criterion-key {
  display: grid;
  gap: 7px;
  font-weight: 500;
}

.criterion-key span {
  display: block;
  padding-left: 8px;
  border-left: 2px solid var(--red);
  color: var(--navy);
}

.criterion-key b {
  margin-right: 6px;
  color: var(--red);
  font-size: 11px;
  letter-spacing: 0.6px;
}

.company-list {
  columns: 2;
  color: var(--navy);
}

.panel-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.panel-title-row h2 { margin: 0; }

.panel-title-row span {
  color: var(--faint);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.review-list {
  columns: 1;
  max-height: none;
  overflow: visible;
  margin: 0;
  padding: 0 12px 0 18px;
  scrollbar-color: var(--red) var(--line-light);
  scrollbar-width: thin;
}

.review-list li {
  margin-bottom: 9px;
  line-height: 1.35;
}

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: auto;
}

.segmented span {
  margin-right: 6px;
  color: var(--muted);
  font-weight: 700;
}

.segmented button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
  height: 32px;
  padding: 0 12px;
  cursor: pointer;
}

.segmented button:first-of-type { border-radius: 0; }
.segmented button:last-of-type { border-radius: 0; }
.segmented button.active {
  border-color: var(--green);
  background: #fff;
  color: var(--green);
  box-shadow: inset 0 -3px 0 var(--green);
  font-weight: 600;
}

.view-note {
  color: var(--muted);
  margin: -2px 0 12px;
  font-size: 13px;
}

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

.evidence-panel {
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(760px, calc(100vw - 40px));
  max-height: min(82vh, 780px);
  background: #fff;
  border: 1px solid var(--line);
  border-top: 4px solid var(--green);
  box-shadow: 0 20px 50px rgba(19, 35, 59, 0.22);
  padding: 20px;
  transform: translate(-50%, -46%) scale(0.98);
  transition: opacity 160ms ease, transform 160ms ease, visibility 160ms ease;
  visibility: hidden;
  opacity: 0;
  z-index: 30;
  overflow: auto;
}

.evidence-panel.open {
  transform: translate(-50%, -50%) scale(1);
  visibility: visible;
  opacity: 1;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}

.icon-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 0;
  width: 32px;
  height: 32px;
  cursor: pointer;
}

.panel-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 140%);
  background: var(--navy);
  color: #fff;
  border-radius: 0;
  padding: 12px 16px;
  opacity: 0;
  transition: all 160ms ease;
  z-index: 40;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

@media (max-width: 900px) {
  .section-head { align-items: flex-start; flex-direction: column; }
  .main-tabs { flex-wrap: wrap; }
  .page-shell { padding: 22px 18px 42px; }
  .summary-grid, .summary-grid.four, .theme-grid, .review-grid, .bonus-overview-grid, .bonus-criteria-grid { grid-template-columns: 1fr; }
  .review-grid div { border-right: 0; border-bottom: 1px solid var(--line-light); }
  .review-grid div:last-child { border-bottom: 0; }
  .segmented { width: 100%; }
  th, td { padding: 8px 6px; font-size: 11px; }
  #mapping-table th,
  #mapping-table td { font-size: 10.5px; padding: 7px 5px; }
}


