:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --text: #17202a;
  --muted: #5b6774;
  --line: #d6dde5;
  --teal: #047a7a;
  --blue: #2563eb;
  --amber: #b45309;
  --red: #b91c1c;
  --green: #15803d;
  --shadow: 0 10px 30px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

.topbar {
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px clamp(18px, 4vw, 52px);
  background: #111827;
  color: #f8fafc;
  border-bottom: 4px solid var(--teal);
}

.eyebrow {
  margin: 0 0 4px;
  color: #9ccfcf;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 5vw, 54px);
  line-height: 1;
  letter-spacing: 0;
}

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

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

.exports a,
.segmented button {
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  padding: 8px 12px;
  text-decoration: none;
  font-weight: 700;
  font-size: 13px;
}

.exports a {
  background: rgba(255, 255, 255, 0.08);
}

.exports .nav-primary {
  background: #0f766e;
  border-color: #5eead4;
}

main {
  width: min(1480px, calc(100vw - 32px));
  margin: 18px auto 42px;
}

.safety-band {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-left: 5px solid var(--amber);
  border-radius: 8px;
  color: #5f3209;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  min-height: 98px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.metric strong {
  display: block;
  margin-top: 12px;
  font-size: 34px;
  line-height: 1;
}

.metric-good {
  border-top: 4px solid var(--green);
}

.metric-blue {
  border-top: 4px solid var(--blue);
}

.metric-warn {
  border-top: 4px solid var(--amber);
}

.metric-risk,
.metric-reject {
  border-top: 4px solid var(--red);
}

.controls {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) minmax(180px, 1.1fr) minmax(360px, 1.6fr) minmax(140px, 0.7fr) 88px;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

label span,
legend {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.segmented {
  display: flex;
  gap: 6px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.segmented legend {
  width: 100%;
}

.segmented button {
  flex: 1;
  min-width: 0;
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

.segmented button.active {
  background: #102a43;
  color: #fff;
}

.toggle {
  display: flex;
  align-items: center;
  min-height: 40px;
  gap: 8px;
}

.toggle input {
  width: 18px;
  min-height: 18px;
}

.toggle span {
  margin: 0;
}

.reset-button {
  min-height: 40px;
  border: 1px solid #a9b5c2;
  border-radius: 8px;
  background: #243447;
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.reset-button:hover {
  background: #102a43;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  gap: 16px;
  align-items: start;
}

.table-shell,
.detail,
.breakdown {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

#result-count {
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.table-scroll {
  max-height: 620px;
  overflow: auto;
}

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

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #e8edf3;
  color: #344152;
  font-size: 11px;
  text-transform: uppercase;
}

tr {
  cursor: pointer;
}

tr:hover,
tr.selected {
  background: #eefdfb;
}

td {
  overflow-wrap: anywhere;
}

th:nth-child(1),
td:nth-child(1) {
  width: 86px;
}

th:nth-child(3),
td:nth-child(3) {
  width: 210px;
}

th:nth-child(4),
td:nth-child(4),
th:nth-child(5),
td:nth-child(5) {
  width: 106px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 4px 9px;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.badge.high {
  background: var(--green);
}

.badge.medium {
  background: var(--blue);
}

.badge.low {
  background: var(--amber);
}

.badge.rejected {
  background: var(--red);
}

.detail {
  position: sticky;
  top: 14px;
  padding: 16px;
}

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

dl {
  margin: 0;
}

dt {
  margin-top: 14px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

dd {
  margin: 5px 0 0;
  padding: 10px;
  min-height: 38px;
  background: #f7f9fb;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.breakdown {
  margin-top: 16px;
  padding: 16px;
}

.bars {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.bar {
  display: grid;
  grid-template-columns: minmax(170px, 280px) minmax(0, 1fr) 42px;
  gap: 12px;
  align-items: center;
}

.bar-label {
  color: #344152;
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.bar-track {
  height: 14px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--teal);
}

.bar-count {
  color: var(--muted);
  font-weight: 800;
  text-align: right;
}

@media (max-width: 1180px) {
  .metrics {
    grid-template-columns: repeat(3, 1fr);
  }

  .controls,
  .workspace {
    grid-template-columns: 1fr;
  }

  .detail {
    position: static;
  }
}

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

  main {
    width: min(100vw - 20px, 1480px);
  }

  .metrics {
    grid-template-columns: repeat(2, 1fr);
  }

  .safety-band {
    align-items: flex-start;
    flex-direction: column;
  }

  .segmented {
    flex-wrap: wrap;
  }

  .segmented button {
    flex-basis: calc(50% - 4px);
  }

  th:nth-child(3),
  td:nth-child(3),
  th:nth-child(4),
  td:nth-child(4),
  th:nth-child(5),
  td:nth-child(5) {
    width: auto;
  }

  .bar {
    grid-template-columns: 1fr 52px;
  }

  .bar-track {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}
