/* ─── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d1117;
  --bg-surface: #161b22;
  --bg-chip: #1c2230;
  --border: rgba(255,255,255,0.07);
  --border-med: rgba(255,255,255,0.12);

  --text-primary: #e6edf3;
  --text-secondary: #7d8fa8;
  --text-muted: #7d8fa8;

  --col-standard: #378ADD;
  --col-highlight: #EAF93C;
  --col-president: #EF9F27;
  --col-coach: #fc2402;
  --col-selected: #EAF93C;
  --col-accent: #ef7a05;
  --col-fade-alpha: 0.08;

  --font-display: 'Utopia Std', serif;
  --font-mono: 'DM Mono', monospace;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

html, body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-display);
  min-height: 100vh;
}

[hidden] {
  display: none !important;
}

/* ─── Page wrapper — matches main salaries viz ─────────────── */
.page-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* IMPORTANT:
   The HTML uses <main id="table-view"> and <main id="beeswarm-view">.
   Do not give these their own page padding. The wrapper already handles it.
*/
#table-view,
#beeswarm-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ─── Header ────────────────────────────────────────────────── */
.site-header {
  border-left: 3px solid var(--col-accent);
  padding-left: 20px;
  position: relative;
  overflow: hidden;
}

/* .site-header::before {
  content: 'VA';
  position: absolute;
  top: -20px;
  right: 0;
  font-family: var(--font-display);
  font-size: clamp(80px, 14vw, 180px);
  font-weight: 800;
  color: transparent;
  -webkit-text-stroke: 1px rgba(255,255,255,0.04);
  pointer-events: none;
  user-select: none;
  line-height: 1;
  letter-spacing: -4px;
} */

.site-title {
  font-family: var(--font-display);
  font-size: clamp(40px, 3.5vw, 40px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.site-title .accent {
  color: var(--col-accent);
}

.site-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 400;
  max-width: 480px;
  line-height: 1.6;
}

/* ═══════════════════════════════════════════════════════════════
   TABLE VIEW
═══════════════════════════════════════════════════════════════ */

/* ─── Controls — spacing matched to main viz ───────────────── */
.controls-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-wrap label {
  display: none;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

#searchInput {
  width: 100%;
  appearance: none;
  background: var(--bg-surface);
  border: 1px solid var(--border-med);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 13px;
  padding: 10px 44px 10px 14px;
  outline: none;
  transition: border-color 0.2s;
}

#searchInput::placeholder { color: var(--text-muted); }
#searchInput:hover { border-color: rgba(255,255,255,0.2); }
#searchInput:focus { border-color: var(--col-standard); }

#clearBtn {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  display: none;
  transition: color 0.15s, background 0.15s;
}

#clearBtn:hover {
  color: var(--text-primary);
  background: var(--border-med);
}

#clearBtn.visible {
  display: block;
}

/* Put agency/salary controls on one row, like the main viz */
.controls-bar > .select-wrap {
  margin-top: 0;
}

.select-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.select-wrap label {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  white-space: nowrap;
}

select {
  appearance: none;
  background: var(--bg-surface);
  border: 1px solid var(--border-med);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 13px;
  padding: 8px 36px 8px 14px;
  cursor: pointer;
  min-width: 200px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237d8fa8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color 0.2s;
  outline: none;
}

select:hover { border-color: rgba(255,255,255,0.2); }
select:focus { border-color: var(--col-standard); }

.table-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

#resultCount {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

#tableHint {
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--col-standard);
  letter-spacing: 0.06em;
  opacity: 0.8;
}

#tableHint.hidden {
  display: none;
}

/* ─── Table container — matches main viz .table-container ───── */
.table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead tr {
  border-bottom: 1px solid var(--border-med);
}

th {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 16px;
  text-align: left;
  white-space: nowrap;
  user-select: none;
  background: var(--bg-chip);
}

th:first-child { border-radius: var(--radius-lg) 0 0 0; }
th:last-child { border-radius: 0 var(--radius-lg) 0 0; }

th.sortable {
  cursor: pointer;
  transition: color 0.15s;
}

th.sortable:hover {
  color: var(--text-secondary);
}

th.sort-asc,
th.sort-desc {
  color: var(--col-standard);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

tbody tr:last-child {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--bg-chip);
}

tbody tr.has-click {
  cursor: pointer;
}

tbody tr.has-click:hover td.name-cell {
  color: var(--col-standard);
  text-decoration: underline;
  text-underline-offset: 3px;
}

td {
  padding: 11px 16px;
  color: var(--text-primary);
  vertical-align: middle;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

td.agency-cell {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

td.name-cell {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  transition: color 0.15s;
}

td.position-cell {
  font-size: 12px;
  color: var(--text-secondary);
}

td.salary-cell {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--col-standard);
}

mark {
  background: rgba(55, 138, 221, 0.2);
  color: var(--col-standard);
  border-radius: 2px;
  padding: 0 1px;
}

/* ─── Empty state ───────────────────────────────────────────── */
.state-message {
  padding: 60px 24px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

/* ─── Pagination ────────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  padding-top: 4px;
}

.pagination button {
  background: var(--bg-surface);
  border: 1px solid var(--border-med);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  min-width: 36px;
}

.pagination button:hover {
  border-color: rgba(255,255,255,0.25);
  color: var(--text-primary);
}

.pagination button.active {
  background: var(--col-standard);
  border-color: var(--col-standard);
  color: #0d1117;
  font-weight: 600;
}

.pagination button:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.page-info {
  font-family: var(--font-display);
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 8px;
}

/* ═══════════════════════════════════════════════════════════════
   BEESWARM VIEW
═══════════════════════════════════════════════════════════════ */

#beeswarm-view .controls-bar {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.back-btn {
  appearance: none;
  background: var(--bg-surface);
  border: 1px solid var(--border-med);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 12px;
  padding: 8px 16px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.back-btn:hover {
  border-color: rgba(255,255,255,0.25);
  color: var(--text-primary);
}

.beeswarm-title-block {
  flex: 1;
  min-width: 0;
}

.chart-eyebrow {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--col-standard);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#beesAgencyLabel {
  font-family: var(--font-display);
  font-size: clamp(16px, 2vw, 22px);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

/* ─── Legend ────────────────────────────────────────────────── */
.legend {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

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

.dot-standard {
  background: var(--col-standard);
  opacity: 0.65;
}

.dot-selected {
  background: var(--col-selected);
  opacity: 0.95;
}

.dot-president {
  background: var(--col-president);
  opacity: 0.95;
}

.dot-coach {
  background: var(--col-coach);
  opacity: 0.95;
}

.legend-label {
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--text-secondary);
  margin-right: 12px;
}

/* ─── Stats bar ─────────────────────────────────────────────── */
.stats-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.stat-chip {
  background: var(--bg-chip);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 130px;
}

.stat-chip--highlight {
  border-color: rgba(239, 159, 39, 0.35);
  background: rgba(239, 159, 39, 0.07);
}

.stat-label {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.stat-value--highlight {
  color: var(--col-highlight);
}

/* ─── Chart area ────────────────────────────────────────────── */
.chart-area {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  -webkit-overflow-scrolling: touch;
}

#chart-container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

#chart-container svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100svh - 260px);
}

/* ─── Beeswarm circles ──────────────────────────────────────── */
.beeswarm-circle {
  cursor: pointer;
  transition: opacity 0.15s;
}

.beeswarm-circle.faded {
  opacity: 0.06 !important;
}

/* ─── Tooltip ───────────────────────────────────────────────── */
.tooltip {
  position: absolute;
  pointer-events: none;
  opacity: 0;
  background: #1c2230;
  border: 1px solid var(--border-med);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-primary);
  max-width: 260px;
  line-height: 1.6;
  z-index: 20;
  transition: opacity 0.12s;
}

.tooltip .tt-tag {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-primary);
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border-med);
  border-radius: 999px;
  padding: 2px 8px;
  margin-bottom: 8px;
}

.tooltip .tt-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.tooltip .tt-position {
  font-size: 12px;
  color: var(--text-secondary);
}

.tooltip .tt-agency {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-display);
  margin-bottom: 6px;
}

.tooltip .tt-salary {
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 500;
  color: var(--col-standard);
}

.tooltip .tt-salary.is-highlighted {
  color: var(--col-highlight);
}

.tooltip .tt-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

/* ─── Sample note / footer count ────────────────────────────── */
#sample-note,
.sample-note,
#footerCount {
  font-family: var(--font-display);
  font-size: 11px;
  color: var(--text-muted);
  min-height: 16px;
}

/* ─── SVG axes ──────────────────────────────────────────────── */
.x-axis .domain {
  stroke: rgba(255,255,255,0.15);
}

.x-axis .tick line {
  stroke: rgba(255,255,255,0.15);
}

.x-axis .tick text {
  fill: #7d8fa8;
  font-family: 'DM Mono', monospace;
  font-size: 13px;
}

.x-axis-label {
  fill: #4a5568;
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  letter-spacing: 0.06em;
}

.grid-line {
  stroke: rgba(255,255,255,0.04);
  stroke-dasharray: 3 4;
}

/* ─── Footer — matches main viz ─────────────────────────────── */
.site-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  flex-wrap: nowrap;
}

.footer-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--font-display);
  font-size: 11px;
  color: var(--text-muted);
}

.footer-right {
  flex-shrink: 0;
}

.footer-logo {
  width: 110px;
  opacity: 0.85;
}

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 700px) {
  .page-wrapper {
    padding: 24px 16px 28px;
    gap: 18px;
  }

  .site-header::before {
    display: none;
  }

  .controls-bar,
  #beeswarm-view .controls-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .search-wrap,
  .search-box,
  #searchInput,
  select {
    width: 100%;
    min-width: unset;
  }

  td {
    font-size: 12px;
  }

  .chart-area {
    overflow-x: auto;
    overflow-y: hidden;
  }

  #chart-container {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    margin: 0;
  }

  #chart-container svg {
    width: 100%;
    height: auto;
    max-height: min(360px, calc(100svh - 330px));
  }

  .site-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .footer-right {
    align-self: flex-end;
  }

  .footer-logo {
    width: 100px;
  }
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

/* ─── Responsive fit refinements ────────────────────────────── */
@media (max-width: 700px) {
  .page-wrapper {
    min-height: 100svh;
  }

  .controls-bar {
    gap: 10px;
  }

  .filter-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    flex-wrap: nowrap;
  }

  .select-wrap {
    width: 100%;
    gap: 6px;
  }

  .select-wrap label {
    min-width: 46px;
  }

  .search-wrap,
  .search-box,
  #searchInput,
  select {
    width: 100%;
    min-width: 0;
  }

  .table-wrap {
    overflow-x: hidden;
  }

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

  th,
  td {
    max-width: none;
  }

  th:nth-child(1),
  td:nth-child(1) { width: 25%; }

  th:nth-child(2),
  td:nth-child(2) { width: 25%; }

  th:nth-child(3),
  td:nth-child(3) { width: 27%; }

  th:nth-child(4),
  td:nth-child(4) { width: 23%; }

  .chart-area {
    overflow: hidden;
  }

  #chart-container {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    margin: 0;
  }

  #chart-container svg {
    width: 100%;
    height: auto;
    max-height: min(360px, calc(100svh - 330px));
  }
}

@media (max-width: 520px) {
  .site-title {
    font-size: clamp(24px, 8vw, 34px);
  }

  .site-subtitle {
    font-size: 13px;
    line-height: 1.45;
  }

  th,
  td {
    padding-left: 6px;
    padding-right: 6px;
  }

  th {
    letter-spacing: 0.04em;
  }

  .stats-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .stat-chip {
    min-width: 0;
    padding: 8px 10px;
  }

  .stat-value {
    font-size: 15px;
  }

  .stat-label {
    font-size: 9px;
  }

  .tooltip {
    max-width: min(260px, calc(100vw - 32px));
  }
}

@media (max-width: 380px) {
  .page-wrapper {
    padding-left: 8px;
    padding-right: 8px;
  }

  #tableHint,
  .page-info,
  .footer-left {
    font-size: 10px;
  }

  th,
  td {
    font-size: 10px;
    padding-left: 4px;
    padding-right: 4px;
  }

  td.salary-cell {
    font-size: 10px;
  }

  .pagination button {
    min-width: 30px;
    padding: 5px 8px;
  }
}
