.performance-page main {
  padding-bottom: 40px;
  max-width: 1600px;
}
.performance-page .topbar .nav-item {
  display: flex;
  align-items: center;
}
.perf-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin: 4px 0 22px;
}
.perf-intro h1 {
  font:
    500 clamp(24px, 3vw, 34px) / 1.15 'Space Grotesk',
    sans-serif;
  letter-spacing: -1px;
  margin: 0 0 7px;
}
.perf-intro p,
.perf-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
#refresh-status {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.perf-filters {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fcfcfa;
  padding: 16px 18px;
}
.perf-selects {
  display: grid;
  grid-template-columns: 1.3fr 0.8fr 1.15fr 1.2fr 1.25fr 1fr;
  gap: 16px;
}
.perf-selects label,
.metric-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.performance-page select {
  width: 100%;
  min-height: 36px;
  min-width: 0;
  border: 1px solid #d9dcd3;
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 6px 26px 6px 9px;
  font-size: 12px;
}
.perf-checks {
  display: flex;
  gap: 22px;
  margin-top: 15px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.perf-checks fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.perf-checks fieldset + fieldset {
  border-left: 1px solid var(--line);
  padding-left: 22px;
}
.perf-checks legend {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}
.perf-checks fieldset > div {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.perf-checks label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
}
.perf-checks label:has(:checked) {
  background: var(--accent-soft);
  border-color: #d7d0f2;
  color: #4e3e9b;
}
.perf-checks input {
  accent-color: var(--accent);
  margin: 0;
  width: 13px;
  height: 13px;
}
.perf-scope {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  min-height: 50px;
}
.perf-scope p {
  margin: 10px 0;
}
.perf-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 8px 0 12px;
}
.perf-heading h2 {
  font:
    500 18px 'Space Grotesk',
    sans-serif;
  margin: 0 0 3px;
}
.perf-scroll {
  overflow: auto;
  max-height: 65vh;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
}
.perf-summary-scroll,
.perf-skill-scroll {
  max-height: none;
  overflow-x: auto;
  overflow-y: hidden;
}
#model-summary th,
#model-summary td,
#skill-matrix th {
  padding: 6px 14px;
}
#model-summary th button {
  min-height: 24px;
}
#model-summary small,
#skill-matrix small {
  margin-top: 0;
  line-height: 1.2;
}
#model-summary .perf-number,
#skill-matrix .perf-number {
  font-size: 14px;
}
#model-summary .perf-bar {
  margin-top: 5px;
}
.perf-table {
  table-layout: auto;
  min-width: 780px;
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.perf-table th,
.perf-table td {
  height: auto;
  vertical-align: middle;
  border-right: 0;
  padding: 13px 16px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
.perf-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f0f1eb;
  color: #5c625a;
  font-size: 11px;
  font-weight: 600;
}
.perf-table th:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: #fcfcfa;
  z-index: 1;
  min-width: 185px;
  border-right: 1px solid var(--line);
}
.perf-table thead th:first-child {
  z-index: 3;
  background: #f0f1eb;
}
.perf-table tbody tr:last-child > * {
  border-bottom: 0;
}
.perf-table th button {
  padding: 0;
  text-align: inherit;
  min-height: 28px;
}
.perf-table tbody th button {
  font-weight: 600;
}
.perf-table th small,
.perf-table td small {
  display: block;
  font-size: 10px;
  font-weight: 400;
  color: var(--muted);
  margin-top: 4px;
}
.perf-table tbody tr:hover td {
  background: #fafbf7;
}
.perf-number {
  font-weight: 600;
  font-size: 15px;
}
.perf-bar {
  height: 3px;
  display: block;
  background: var(--accent);
  opacity: 0.4;
  border-radius: 2px;
  margin-top: 8px;
  max-width: 100%;
  min-width: 2px;
}
.perf-error-count {
  color: #a44237;
}
.perf-note {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
  margin: 10px 0 24px;
}
.perf-matrix-section {
  margin-top: 24px;
}
.metric-picker {
  flex-direction: row;
  align-items: center;
  gap: 9px;
}
.metric-picker select {
  width: 180px;
}
#skill-matrix td {
  padding: 0;
  min-width: 135px;
}
.perf-cell {
  padding: 6px 14px;
  width: 100%;
  text-align: right;
  min-height: 48px;
}
#skill-matrix thead th {
  height: 37px;
}
#skill-matrix tbody th {
  height: 49px;
}
#skill-matrix .perf-empty {
  padding: 6px 14px !important;
}
.perf-cell:hover {
  background: var(--accent-soft);
}
.perf-empty {
  padding: 16px !important;
  color: var(--muted);
}
.perf-method {
  margin-top: 24px;
  border-top: 1px solid var(--line);
  padding: 16px 0;
  font-size: 12px;
  line-height: 1.65;
  color: var(--muted);
}
.perf-method summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 600;
}
.perf-method > div {
  max-width: 1000px;
}
#perf-error {
  padding: 12px;
  background: #fff0ea;
  color: #a44237;
  border-radius: 6px;
}
#runs-dialog {
  width: min(1200px, calc(100vw - 32px));
  max-width: none;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
}
#runs-dialog::backdrop {
  background: #20232166;
}
.perf-dialog-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 15px;
}
.perf-dialog-head h2 {
  font:
    500 22px 'Space Grotesk',
    sans-serif;
  margin: 0;
}
.perf-dialog-head p {
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0 0;
}
#close-runs {
  min-width: 40px;
  min-height: 40px;
  border-radius: 6px;
  background: white;
  border: 1px solid var(--line);
}
#runs-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
@media (max-width: 1100px) {
  .perf-selects {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .perf-checks {
    flex-direction: column;
    gap: 12px;
  }
  .perf-checks fieldset + fieldset {
    border-left: 0;
    padding-left: 0;
  }
  .performance-page .topbar {
    padding: 0 24px;
    gap: 20px;
  }
  .performance-page main {
    padding-left: 24px;
    padding-right: 24px;
  }
}
@media (max-width: 600px) {
  .performance-page main {
    padding: 18px 16px 30px;
  }
  .performance-page .topbar {
    height: auto;
    min-height: 72px;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 16px;
  }
  .performance-page .topbar nav {
    margin-left: 0;
    height: 32px;
    gap: 20px;
  }
  .performance-page .local-badge {
    display: none;
  }
  .perf-intro {
    display: block;
    margin-bottom: 18px;
  }
  #refresh-status {
    display: block;
    margin-top: 10px;
  }
  .perf-selects {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .perf-filters {
    padding: 13px;
  }
  .perf-heading {
    align-items: start;
    flex-direction: column;
    gap: 8px;
  }
  .perf-scope {
    align-items: start;
    flex-direction: column;
    gap: 0;
    margin-bottom: 16px;
  }
  .perf-table th,
  .perf-table td {
    padding: 11px 12px;
  }
  .perf-table th:first-child {
    min-width: 155px;
  }
  .perf-table {
    font-size: 12px;
  }
  .perf-heading p {
    font-size: 12px;
  }
  #runs-dialog {
    padding: 14px;
  }
  .perf-dialog-head h2 {
    font-size: 18px;
  }
}

/* One independent low-to-high scale per metric or skill column. */
[data-heat='0'] {
  --heat-ink: #4f705b;
  --heat-bar: #819c88;
}
[data-heat='1'],
[data-heat='2'],
[data-heat='3'] {
  --heat-ink: var(--ink);
  --heat-bar: #c9cdc7;
}
[data-heat='4'] {
  --heat-ink: #90615c;
  --heat-bar: #b7948e;
}
.perf-heat .perf-number {
  color: var(--heat-ink, var(--ink));
}
.perf-table .perf-heat small {
  color: #555c55;
}
.perf-heat .perf-bar {
  height: 2px;
  background: var(--heat-bar, #c9cdc7);
  opacity: 0.55;
}
.perf-heat .perf-cell:hover {
  background: #00000005;
}
.perf-heat .perf-cell:focus-visible {
  outline-offset: -4px;
}
.perf-heat-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  margin: 0 0 18px;
  line-height: 1.6;
}
.perf-heat-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.perf-heat-legend > span:first-child {
  font-weight: 600;
  margin-right: 6px;
  color: var(--ink);
}
.perf-heat-legend i {
  width: 6px;
  height: 6px;
  background: var(--heat-bar);
  border-radius: 2px;
}
.perf-heat-ramp {
  width: 64px;
  height: 2px;
  border-radius: 3px;
  background: linear-gradient(90deg, #819c88, #d2d5d0, #b7948e);
}
.perf-heat-help {
  margin-left: 8px;
}
@media (max-width: 600px) {
  .perf-heat-help {
    flex-basis: 100%;
    margin-left: 0;
  }
}
