:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --border: #d8dee6;
  --text: #1b2733;
  --text-dim: #5c6b7a;
  --accent: #0e7c86;
  --accent-strong: #0a5b63;
  --accent-soft: #d7ecee;
  --argentina: #6c9bd1;
  --abroad: #e0a458;
  --returned: #7cab6e;
  --shadow: 0 1px 3px rgba(20, 35, 50, .08), 0 8px 24px rgba(20, 35, 50, .06);
  --radius: 10px;
  --sidebar-w: 324px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10161d;
    --surface: #182029;
    --surface-2: #1e2833;
    --border: #2b3844;
    --text: #e6ecf2;
    --text-dim: #93a2b2;
    --accent: #2bb7c4;
    --accent-strong: #57cdd8;
    --accent-soft: #16323a;
    --argentina: #5b86bb;
    --abroad: #cf9350;
    --returned: #6d9a60;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
a { color: var(--accent); }

#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- top bar ---------- */
#topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 12px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .mark {
  width: 34px; height: 34px; object-fit: contain; flex-shrink: 0;
}
@media (prefers-color-scheme: dark) {
  /* the logo art is a fixed teal; lift it slightly so it reads on dark */
  .brand .mark { filter: brightness(1.35) saturate(0.9); }
}
:root[data-theme="dark"] .brand .mark { filter: brightness(1.35) saturate(0.9); }
:root[data-theme="light"] .brand .mark { filter: none; }
#topbar h1 { font-size: 20px; margin: 0; letter-spacing: .2px; }
.tagline { margin: 2px 0 0; color: var(--text-dim); font-size: 14px; max-width: 46ch; }

.headline-stats { display: flex; gap: 22px; margin-left: auto; }
.headline-stats .stat { text-align: right; }
.headline-stats .num { font-size: 24px; font-weight: 650; color: var(--accent); }
.headline-stats .lbl { font-size: 12.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; }

.ghost-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text);
  padding: 7px 14px; border-radius: 999px;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent); }

.about-panel {
  padding: 14px 20px; background: var(--surface-2);
  border-bottom: 1px solid var(--border); font-size: 14.5px; color: var(--text-dim);
}
.about-panel h3 { margin: 0 0 6px; color: var(--text); font-size: 14.5px; }
.about-panel ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- layout ---------- */
#layout { display: flex; flex: 1; min-height: 0; }

#sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 14px;
}
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- search + toggles ---------- */
.search-wrap { margin-bottom: 12px; }
#search {
  width: 100%; padding: 9px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
#search:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.quick-toggle { display: flex; gap: 4px; margin-bottom: 16px; background: var(--surface-2); padding: 4px; border-radius: 8px; }
.quick-toggle button {
  flex: 1; border: 0; background: transparent; color: var(--text-dim);
  padding: 6px 4px; border-radius: 6px; font-size: 14px;
}
.quick-toggle button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }

.inline-toggle { margin: 0 0 14px; font-size: 14px; color: var(--text-dim); }
.inline-toggle input { accent-color: var(--accent); }

/* ---------- facets ---------- */
.facet { border-top: 1px solid var(--border); padding: 10px 0; }
.facet > summary {
  list-style: none; cursor: pointer; font-weight: 600; font-size: 14px;
  text-transform: uppercase; letter-spacing: .6px; color: var(--text-dim);
  display: flex; justify-content: space-between; align-items: center;
}
.facet > summary::-webkit-details-marker { display: none; }
.facet > summary::after { content: "▾"; font-size: 11.5px; }
.facet[open] > summary::after { content: "▴"; }
.facet-options { margin-top: 8px; display: flex; flex-direction: column; gap: 3px; max-height: 260px; overflow-y: auto; }
.opt {
  display: flex; align-items: center; gap: 8px; font-size: 14.5px;
  padding: 3px 4px; border-radius: 5px; cursor: pointer;
}
.opt:hover { background: var(--surface-2); }
.opt input { accent-color: var(--accent); }
.opt .count { margin-left: auto; color: var(--text-dim); font-size: 13px; font-variant-numeric: tabular-nums; }
.opt.disabled { opacity: .4; cursor: default; }

.reset-btn {
  margin-top: 14px; width: 100%; padding: 8px;
  background: transparent; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text-dim);
}
.reset-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- view tabs ---------- */
.view-tabs {
  display: flex; align-items: center; gap: 4px;
  padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface);
  overflow-x: auto; scrollbar-width: none;
}
.view-tabs::-webkit-scrollbar { display: none; }
.view-tabs button {
  border: 0; background: transparent; color: var(--text-dim);
  padding: 7px 14px; border-radius: 7px; font-size: 14.5px; white-space: nowrap;
}
.view-tabs button:hover { color: var(--text); }
.view-tabs button.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.result-count { margin-left: auto; padding-left: 12px; color: var(--text-dim); font-size: 14px; white-space: nowrap; }

.view { flex: 1; min-height: 0; position: relative; }
#map { position: absolute; inset: 0; background: var(--surface-2); }

.legend {
  position: absolute; right: 10px; bottom: 10px; z-index: 500;
  display: flex; flex-direction: column; gap: 4px;
  padding: 8px 10px; font-size: 13px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  box-shadow: var(--shadow); color: var(--text-dim);
}
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.legend .dot.ar { background: #6c9bd1; }
.legend .dot.abroad { background: #e0a458; }
.legend .dot.home { background: #d64545; }
.legend .dot.faint { background: transparent; border: 1.5px solid #b0863f; }
.legend .dash {
  display: inline-block; width: 16px; height: 3px; border-radius: 2px;
  background: #e0a458; margin-right: 5px; vertical-align: middle;
}

.unmapped-note {
  position: absolute; left: 10px; bottom: 10px; z-index: 500;
  margin: 0; padding: 6px 10px; font-size: 13px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text-dim); box-shadow: var(--shadow);
}

/* ---------- map popup ---------- */
.leaflet-popup-content-wrapper { border-radius: 10px; }
.leaflet-popup-content { margin: 12px 14px; width: 250px !important; }
.pp { font-size: 14.5px; }
.pp-head { display: flex; gap: 10px; }
.pp-photo {
  width: 46px; height: 46px; border-radius: 8px; object-fit: cover; flex-shrink: 0;
  background: var(--surface-2);
}
.pp-name { font-weight: 650; font-size: 16px; line-height: 1.25; }
.pp-role { color: var(--text-dim); font-size: 13.5px; }
.pp-line { margin-top: 7px; }
.pp-line b { font-weight: 600; }
.pp-metrics { color: var(--text-dim); font-size: 13px; }
.asof { color: var(--text-dim); font-size: 12px; }
.pp-thesis { font-size: 13px; font-style: italic; color: var(--text-dim); }
.pp-career { font-size: 12.5px; color: var(--text-dim); line-height: 1.6; }
.pp-career .yr { opacity: .7; }
.pp-inferred { font-size: 12px; color: var(--abroad); border-top: 1px dashed var(--border); padding-top: 6px; }
.pp-chips { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  font-size: 12px; padding: 2px 7px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-strong); white-space: nowrap;
}
.chip.muted { background: var(--surface-2); color: var(--text-dim); }
.chip.lvl { background: transparent; border: 1px solid var(--accent); color: var(--accent-strong); }
.chip.skill { background: var(--surface-2); color: var(--text-dim); border: 1px dashed var(--border); }
.pp-skills { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.pp-lang { color: var(--text-dim); font-size: 13.5px; }
.pp-links { margin-top: 9px; display: flex; flex-wrap: wrap; gap: 8px; }
.pp-links a { font-size: 13.5px; text-decoration: none; }
.pp-links a:hover { text-decoration: underline; }

.cluster-ar { filter: hue-rotate(20deg); }

/* ---------- insights ---------- */
#view-hires, #view-studied, #view-return { overflow-y: auto; padding: 22px 24px 30px; }
.insights-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.card:hover { border-color: var(--accent-soft); }
.card h3 {
  margin: 0 0 5px; font-size: 13px; font-weight: 650;
  text-transform: uppercase; letter-spacing: .6px; color: var(--text-dim);
}
.card .sub { margin: 0 0 12px; color: var(--text-dim); font-size: 13px; line-height: 1.45; }
.card .big-figure + .callout { margin-top: -2px; }

.bar-row { display: grid; min-width: 0; grid-template-columns: minmax(90px, 46%) 1fr 44px; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 14px; }
.bar-row .bl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.bar-row .bl:hover { color: var(--accent); }
.bar-track { background: var(--surface-2); border-radius: 4px; height: 14px; overflow: hidden; }
.bar-fill {
  height: 100%; background: var(--accent); border-radius: 4px;
  transition: width .35s cubic-bezier(.4, 0, .2, 1);
}
.bar-fill.ar { background: var(--argentina); }
.bar-fill.abroad { background: var(--abroad); }
.bar-row .bv { text-align: right; color: var(--text-dim); font-variant-numeric: tabular-nums; }

.split { display: flex; height: 30px; border-radius: 6px; overflow: hidden; margin: 6px 0 10px; }
.split span { display: flex; align-items: center; justify-content: center; font-size: 12.5px; color: #fff; min-width: 2px; }

.big-figure { font-size: 36px; font-weight: 700; color: var(--accent); }
.callout { font-size: 14px; color: var(--text-dim); }
.legend-line { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.legend-line .key {
  display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-left: 8px;
}
.legend-line .key:first-child { margin-left: 0; }

/* ---------- list ---------- */
#view-list { overflow-y: auto; padding: 0; }
table.people { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.people th, table.people td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.people th { position: sticky; top: 0; background: var(--surface); z-index: 2; cursor: pointer; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-dim); }
table.people tbody tr { cursor: pointer; }
table.people tr:hover td { background: var(--surface-2); }
table.people tbody tr.sel td {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}
table.people .nm { font-weight: 600; }
table.people .subtle { color: var(--text-dim); }
.row-trail { margin-left: 6px; color: var(--accent); font-size: 12.5px; opacity: .75; }

/* ---------- selected person panel (map overlay) ---------- */
.selection {
  position: absolute; z-index: 700;
  top: 12px; right: 12px; width: 350px; max-width: calc(100% - 24px);
  max-height: calc(100% - 92px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.sel-head {
  position: sticky; top: 0; z-index: 1;
  display: flex; gap: 6px; align-items: center; justify-content: space-between;
  padding: 8px 10px; background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
}
.sel-head button {
  font: inherit; font-size: 13px; cursor: pointer;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 4px 9px;
}
.sel-head button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.sel-head button:disabled { opacity: .45; cursor: default; }
.sel-close { line-height: 1; padding: 4px 8px !important; }
.sel-body { padding: 10px 12px 12px; }
.sel-body .pp { font-size: 14px; }
.sel-note { margin: 0 12px 12px; font-size: 13px; color: var(--text-dim); }

@media (max-width: 820px) {
  .selection { top: auto; bottom: 10px; left: 10px; right: 10px; width: auto; max-height: 45%; }
}
.tag-ar { color: var(--argentina); font-weight: 600; }
.tag-abroad { color: var(--abroad); font-weight: 600; }

/* ---------- responsive ---------- */
@media (max-width: 820px) {
  #sidebar { position: fixed; z-index: 1200; inset: 0 auto 0 0; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  #sidebar.open { transform: none; }
  .headline-stats { margin-left: 0; gap: 14px; }
  #topbar h1 { font-size: 17px; }
}

.mobile-filter-btn {
  display: none; position: absolute; z-index: 1100; left: 10px; top: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px;
  box-shadow: var(--shadow); color: var(--text);
}
@media (max-width: 820px) { .mobile-filter-btn { display: block; } }

/* ---------- analytical view headers ---------- */
.view-intro { max-width: 70ch; margin: 0 0 20px; }
.view-intro h2 {
  margin: 0 0 6px; font-size: 25px; font-weight: 640; letter-spacing: -.3px;
  color: var(--text);
}
.view-intro p { margin: 0; color: var(--text-dim); font-size: 15.5px; line-height: 1.55; }

/* ---------- flow toggle ---------- */
.flow-btn {
  width: 34px; height: 34px; font-size: 16px; line-height: 1;
  background: var(--surface); color: var(--text-dim);
}
.flow-btn.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.pp-career .cap { opacity: .7; font-size: 11px; }
