/* ─── 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;   /* highlightedvemployee dot */
  /* --col-selected:   #111111; */
  --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;
  min-height: 100svh;
  width: 100%;
  overflow-x: hidden;
}

[hidden] {
  display: none !important;
}

/* ─── Page wrapper — matches main salaries viz ──────────────── */
main {
  width: min(1400px, 100%);
  max-width: 1400px;
  min-height: 100svh;
  margin: 0 auto;
  padding: clamp(12px, 2.3vw, 32px) clamp(10px, 1.8vw, 20px) clamp(12px, 2vw, 24px);
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.2vw, 16px);
}

/* ─── Header ────────────────────────────────────────────────── */
header {
  border-left: 3px solid var(--col-accent);
  padding-left: clamp(12px, 1.5vw, 20px);
  position: relative;
  overflow: hidden;
}

/* 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;
} */

.header-inner {
  padding-bottom: clamp(10px, 1.8vw, 24px);
}

.header-meta {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--col-standard);
  margin-bottom: 8px;
}

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

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

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

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

.controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.search-icon {
  position: absolute;
  left: 14px;
  font-size: 20px;
  color: var(--text-muted);
  pointer-events: none;
  line-height: 1;
  top: 50%;
  transform: translateY(-50%);
}

#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 44px;
  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); }

.clear-btn {
  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;
}

.clear-btn:hover {
  color: var(--text-primary);
  background: var(--border-med);
}

.clear-btn.visible {
  display: block;
}

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

.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); }

.result-count {
  margin-left: auto;
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.table-hint {
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--col-standard);
  letter-spacing: 0.06em;
  opacity: 0.8;
  display: flex;
  align-items: center;
  gap: 6px;
  /* padding-bottom: 0; */
}

.table-hint.hidden {
  display: none;
}

.hint-icon {
  font-size: 13px;
}

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

table {
  width: 100%;
  table-layout: fixed;
  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: clamp(8px, 1.1vw, 12px) clamp(8px, 1.2vw, 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);
}

.sort-arrow {
  font-size: 10px;
  margin-left: 4px;
  opacity: 0.3;
}

th.sort-asc .sort-arrow::after {
  content: '↑';
  opacity: 1;
  color: var(--col-standard);
}

th.sort-desc .sort-arrow::after {
  content: '↓';
  opacity: 1;
  color: var(--col-standard);
}

.num-col {
  text-align: right;
}

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: clamp(8px, 1vw, 11px) clamp(8px, 1.2vw, 16px);
  color: var(--text-primary);
  vertical-align: middle;
  max-width: none;
  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 ───────────────────────────────────────────── */
.empty-state {
  padding: 60px 24px;
  text-align: center;
}

.empty-icon {
  display: block;
  font-size: 32px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.empty-state p {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ─── 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 {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bees-header {
  display: flex;
  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);
}

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

.bees-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;
}

.bees-title {
  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-highlighted {
  background: var(--col-highlight);
  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: min(130px, 100%);
}

.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: min(560px, 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: clamp(8px, 1.1vw, 12px) clamp(8px, 1.2vw, 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 ───────────────────────────────────────────── */
.sample-note {
  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 ────────────────────────────────────────────────── */
.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;
}

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

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .filter-row {
    gap: 12px;
  }

  .select-wrap {
    flex: 1 1 220px;
  }

  select {
    min-width: 0;
    width: 100%;
  }

  .result-count {
    margin-left: 0;
  }

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

  .stat-chip {
    min-width: 0;
  }
}

@media (max-width: 700px) {
  main {
    padding: 14px 10px 14px;
    gap: 12px;
  }

  header::before {
    display: none;
  }

  .controls {
    gap: 8px;
  }

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

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

  .select-wrap label {
    width: 52px;
    flex: 0 0 52px;
  }

  select {
    min-width: 0;
    width: 100%;
  }

  td,
  th {
    font-size: 11px;
  }

  .bees-header {
    gap: 10px;
  }

  .back-btn {
    width: 100%;
  }

  .legend {
    width: 100%;
  }

  .stats-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #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));
  }

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

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

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

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

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

  #searchInput {
    padding-top: 9px;
    padding-bottom: 9px;
  }

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

  th {
    letter-spacing: 0.04em;
  }

  .agency-cell,
  th:nth-child(1) {
    width: 25%;
  }

  .name-cell,
  th:nth-child(2) {
    width: 25%;
  }

  .position-cell,
  th:nth-child(3) {
    width: 27%;
  }

  .salary-cell,
  th:nth-child(4) {
    width: 23%;
  }

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

  .stat-chip {
    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) {
  main {
    padding-left: 8px;
    padding-right: 8px;
  }

  .table-hint,
  .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;
  }
}
