/* ── Behavior Bench dashboard styles ────────────────────────── */

.bench-wrap {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.bench-header {
  margin-bottom: 0.5rem;
}

.bench-subtitle {
  font-family: 'DM Sans', sans-serif;
  font-size: 1.05rem;
  color: #6b6865;
  margin-top: -0.5rem;
  margin-bottom: 1.5rem;
}

.bench-prose {
  font-family: 'Spectral', Georgia, serif;
  font-size: 1rem;
  line-height: 1.75;
  max-width: 700px;
  margin-bottom: 2.5rem;
}

.bench-prose p { margin: 0 0 1.1em; }
.bench-prose ul { padding-left: 1.4em; margin: 0 0 1.1em; }
.bench-prose li { margin-bottom: 0.3em; }
.bench-prose strong { font-weight: 600; }
.bench-prose a {
  color: #2d4739;
  border-bottom: 1px solid rgba(45,71,57,.25);
  text-decoration: none;
}
.bench-prose a:hover { color: #4a7a64; border-bottom-color: #4a7a64; }

/* ── Dashboard wrapper ───────────────────────────────────────── */
.bench-dashboard {
  background: #fff;
  border: 1px solid #dedad4;
  border-radius: 8px;
  overflow: hidden;
}

/* ── Tabs ────────────────────────────────────────────────────── */
.bench-tabs {
  display: flex;
  border-bottom: 1px solid #dedad4;
  background: #f3f0eb;
  padding: 0;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.bench-tabs::-webkit-scrollbar { display: none; }

.bench-tab {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  color: #6b6865;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.75rem 1.2rem;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}
.bench-tab:hover { color: #2d4739; }
.bench-tab.active {
  color: #2d4739;
  border-bottom-color: #2d4739;
  background: #fff;
}

/* ── Panels ─────────────────────────────────────────────────── */
.bench-panel {
  display: none;
  padding: 1.5rem;
}
.bench-panel.active { display: block; }

/* ── Controls ────────────────────────────────────────────────── */
.bench-controls { margin-bottom: 1.25rem; }
.bench-label {
  display: block;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: #6b6865;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.6rem;
}
.bench-label-sm {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  color: #6b6865;
  margin-right: 0.5rem;
}
.bench-hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: #999390;
}

.bench-select {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid #dedad4;
  border-radius: 4px;
  background: #faf8f4;
  color: #1c1b19;
  cursor: pointer;
}
.bench-select:focus { outline: 2px solid #2d4739; outline-offset: 1px; }

.filter-row {
  display: flex;
  align-items: center;
  margin-top: 0.75rem;
}

/* ── Model checkboxes ────────────────────────────────────────── */
.model-select-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.model-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  padding: 0.3rem 0.65rem;
  border: 1.5px solid var(--chip-color, #888);
  border-radius: 20px;
  cursor: pointer;
  color: #1c1b19;
  background: #fff;
  transition: background 0.12s, color 0.12s;
  user-select: none;
}
.model-chip input[type="checkbox"] { display: none; }
.model-chip.checked {
  background: var(--chip-color, #888);
  color: #fff;
}
.model-chip:hover { opacity: 0.85; }

/* ── Lab checkboxes ─────────────────────────────────────────── */
.lab-select-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.lab-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  padding: 0.35rem 0.8rem;
  border: 1.5px solid var(--chip-color, #888);
  border-radius: 20px;
  cursor: pointer;
  color: #1c1b19;
  background: #fff;
  transition: background 0.12s, color 0.12s;
  user-select: none;
}
.lab-chip input[type="checkbox"] { display: none; }
.lab-chip.checked {
  background: var(--chip-color, #888);
  color: #fff;
}
.lab-chip:hover { opacity: 0.85; }

/* ── Dimension tabs ─────────────────────────────────────────── */
.dim-tab-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.dim-tab-btn {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  padding: 0.35rem 0.9rem;
  border: 1.5px solid #dedad4;
  border-radius: 20px;
  background: #faf8f4;
  color: #6b6865;
  cursor: pointer;
  transition: all 0.12s;
}
.dim-tab-btn:hover { border-color: #2d4739; color: #2d4739; }
.dim-tab-btn.active {
  background: #2d4739;
  border-color: #2d4739;
  color: #fff;
}

/* ── Charts ─────────────────────────────────────────────────── */
.chart-container {
  position: relative;
  margin: 0.5rem auto;
}

.radar-container {
  max-width: 520px;
}

.bar-container {
  height: 680px;
  max-width: 100%;
}

.human-bar-container {
  height: 680px;
  max-width: 100%;
}

.scatter-container {
  height: 560px;
  max-width: 100%;
}

/* ── Legend ─────────────────────────────────────────────────── */
.bench-legend,
.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
  justify-content: center;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  color: #1c1b19;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-n {
  color: #999390;
  font-size: 0.78rem;
}

/* ── Note text ───────────────────────────────────────────────── */
.bench-note {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  color: #999390;
  text-align: center;
  margin-top: 1rem;
  margin-bottom: 0;
}

.bench-error {
  font-family: 'DM Sans', sans-serif;
  color: #c45c3a;
  padding: 2rem;
  text-align: center;
}

/* ── Country Affinity ────────────────────────────────────────── */
.country-select {
  min-width: 220px;
}

.country-affinity-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: start;
  margin-top: 1rem;
}

@media (max-width: 640px) {
  .country-affinity-layout {
    grid-template-columns: 1fr;
  }
}

/* ── Country mode toggle ─────────────────────────────────────── */
.country-mode-row {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.country-mode-btn {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  padding: 0.35rem 0.9rem;
  border: 1.5px solid #dedad4;
  border-radius: 20px;
  background: #faf8f4;
  color: #6b6865;
  cursor: pointer;
  transition: all 0.12s;
}
.country-mode-btn:hover { border-color: #2d4739; color: #2d4739; }
.country-mode-btn.active {
  background: #2d4739;
  border-color: #2d4739;
  color: #fff;
}

/* ── Country Affinity grid ───────────────────────────────────── */
.country-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.85rem;
  margin-top: 0.5rem;
}

.country-card {
  border: 1.5px solid var(--card-color, #dedad4);
  border-radius: 7px;
  padding: 0.75rem 0.85rem;
  background: #fff;
}

.country-card-header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.6rem;
}

.country-card-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--card-color, #888);
  flex-shrink: 0;
}

.country-card-name {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  color: #1c1b19;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.country-card-lab {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.72rem;
  color: #999390;
  white-space: nowrap;
}

.country-card-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.country-card-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.84rem;
}

.country-flag-lg { font-size: 1.15rem; line-height: 1; }

.country-card-country {
  flex: 1;
  color: #1c1b19;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.country-card-dist {
  font-size: 0.75rem;
  color: #999390;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ── Dim options row ─────────────────────────────────────────── */
.dim-options-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.7rem;
}

.dim-opt-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  color: #6b6865;
  cursor: pointer;
  user-select: none;
}
.dim-opt-label input[type="checkbox"] {
  accent-color: #2d4739;
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.human-dot {
  display: inline-block;
  width: 12px;
  height: 3px;
  background: repeating-linear-gradient(90deg, #2d6a4f 0, #2d6a4f 5px, transparent 5px, transparent 9px);
  vertical-align: middle;
}

/* ── Standardized View ───────────────────────────────────────── */
.normed-controls { margin-bottom: 1.25rem; }

.normed-top-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-start;
}

.normed-ref-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.normed-ref-btn {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  padding: 0.35rem 0.9rem;
  border: 1.5px solid #dedad4;
  border-radius: 20px;
  background: #faf8f4;
  color: #6b6865;
  cursor: pointer;
  transition: all 0.12s;
}
.normed-ref-btn:hover { border-color: #2d4739; color: #2d4739; }
.normed-ref-btn.active {
  background: #2d4739;
  border-color: #2d4739;
  color: #fff;
}

.normed-model-wrap { min-width: 180px; }

.normed-note-box {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.83rem;
  color: #6b6865;
  background: #f3f0eb;
  border-radius: 5px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 1rem;
  min-height: 2rem;
}

.legend-dash {
  display: inline-block;
  width: 18px;
  height: 2px;
  background: repeating-linear-gradient(90deg, #b4a082 0, #b4a082 4px, transparent 4px, transparent 8px);
  vertical-align: middle;
  margin-right: 2px;
}

/* ── Staircase risk note ─────────────────────────────────────── */
.risk-hint {
  font-style: italic;
  color: #6b6865;
  margin-left: 0.5rem;
}
.risk-hint code {
  font-size: 0.8rem;
  background: #f0ece6;
  padding: 0 3px;
  border-radius: 3px;
}

/* ── Human table ─────────────────────────────────────────────── */
.human-table-wrap {
  overflow-x: auto;
  margin-top: 2rem;
}

.human-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.83rem;
}

.human-table thead th {
  text-align: right;
  padding: 0.45rem 0.7rem;
  color: #6b6865;
  font-weight: 600;
  border-bottom: 2px solid #dedad4;
  white-space: nowrap;
}

.human-table thead th:first-child {
  text-align: left;
}

.human-table tbody tr:hover {
  background: #f8f6f2;
}

.human-table-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.7rem;
  white-space: nowrap;
  color: #1c1b19;
}

.human-table-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.human-table-cell {
  text-align: right;
  padding: 0.4rem 0.7rem;
  font-variant-numeric: tabular-nums;
  color: #1c1b19;
  background: color-mix(in srgb, #c0392b calc(var(--heat) * 0.45), transparent);
}

.human-table-total {
  font-weight: 600;
  border-left: 1px solid #dedad4;
  background: color-mix(in srgb, #8b1a1a calc(var(--heat) * 0.45), transparent);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  .bench-wrap { padding: 1.5rem 1rem 3rem; }
  .bench-panel { padding: 1rem; }
  .bench-tabs {
    gap: 0.25rem;
    padding: 0.35rem;
  }
  .bench-tab {
    flex: 1 0 auto;
    border: 1px solid #dedad4;
    border-radius: 4px;
    margin-bottom: 0;
    padding: 0.55rem 0.75rem;
    font-size: 0.78rem;
    background: #faf8f4;
  }
  .bench-tab.active {
    border-color: #2d4739;
  }
  .filter-row,
  .dim-options-row,
  .country-mode-row,
  .normed-top-row {
    align-items: stretch;
    flex-direction: column;
    gap: 0.5rem;
  }
  .bench-select {
    width: 100%;
  }
  .model-chip,
  .lab-chip,
  .dim-tab-btn,
  .country-mode-btn {
    justify-content: center;
    min-height: 36px;
  }
  .bar-container,
  .human-bar-container { height: 900px; }
  .scatter-container { height: 440px; }
  .radar-container { max-width: 100%; }
  .risk-hint {
    display: block;
    margin-left: 0;
  }
}
