:root {
  --bg: #FAF9F6;
  --surface: #FFFFFF;
  --surface2: #F5F0EB;
  --border: #E8E4DF;
  --border2: #D9D2CA;
  --text: #1A1A1A;
  --text2: #8B8580;
  --text3: #B0A99F;
  --accent: #C4956A;
  --accent-bg: #F5EDE5;
  --accent-dark: #A67B52;
  --green: #5A9E6F;
  --green-bg: #EDF5EF;
  --red: #C75B4A;
  --red-bg: #FAEDEB;
  --blue: #5B8EC7;
  --blue-bg: #EBF0FA;
  --purple: #8B6FB0;
  --purple-bg: #F0ECF5;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.08);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { overflow-y: scroll; scrollbar-gutter: stable; }
/* Full-page (cross-document) navigations cross-fade instead of flashing:
   without this, every nav/button click that reloads the page blanks the
   viewport for the server round-trip and the page visibly "convulses". */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.14s; }
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } }
body {
  font-family: 'Inter', -apple-system, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.container { max-width: 1400px; margin: 0 auto; padding: 0 32px; }
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
  position: sticky; top: 0; z-index: 100;
}
header .container { display: flex; align-items: center; gap: 24px; }
.logo { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.3px; color: var(--text); }
.logo span { color: var(--accent-dark); }
header nav { display: flex; gap: 2px; background: var(--surface2); border-radius: 10px; padding: 3px; max-width: 100%; overflow-x: auto; }
header nav a {
  background: transparent; border: none; color: var(--text2);
  padding: 8px 18px; border-radius: 8px; cursor: pointer;
  font-size: 0.875rem; font-weight: 500; transition: color 0.12s; white-space: nowrap;
}
header nav a:hover { color: var(--text); text-decoration: none; }
header nav a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.auth-nav { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.auth-nav a,
.auth-nav button {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text2); border-radius: 8px; padding: 7px 12px;
  font: inherit; font-size: 0.82rem; font-weight: 650; white-space: nowrap; cursor: pointer;
}
.auth-nav a:hover,
.auth-nav button:hover { border-color: var(--border2); color: var(--text); text-decoration: none; }
.auth-nav .primary { background: var(--accent-bg); border-color: var(--accent); color: var(--accent-dark); }
.auth-nav form { margin: 0; }
.auth-modal[hidden] { display: none; }
.auth-modal { position: fixed; inset: 0; z-index: 1200; }
.auth-backdrop { position: absolute; inset: 0; background: rgba(26,26,26,.38); }
.auth-dialog {
  position: absolute; top: 72px; left: 50%; transform: translateX(-50%);
  width: min(460px, calc(100vw - 32px)); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 20px;
}
.auth-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.auth-dialog h2 { font-size: 1.1rem; line-height: 1.35; margin: 0; color: var(--text); letter-spacing: 0; text-transform: none; border: 0; padding: 0; }
.auth-close { width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text2); font: inherit; font-size: 1.1rem; line-height: 1; cursor: pointer; }
.auth-close:hover { border-color: var(--border2); color: var(--text); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0 0 14px; }
.auth-tabs button { border: 1px solid var(--border); background: var(--surface); color: var(--text2); border-radius: 8px; padding: 9px 10px; font: inherit; font-size: .84rem; font-weight: 700; cursor: pointer; }
.auth-tabs button.active { background: var(--accent-bg); border-color: var(--accent); color: var(--accent-dark); }
.auth-modal-form { display: none; gap: 12px; }
.auth-modal-form.active { display: grid; }
.auth-field { display: grid; gap: 5px; }
.auth-field label { font-size: .76rem; color: var(--text2); text-transform: uppercase; letter-spacing: .65px; font-weight: 700; }
.auth-field label .alert-tip { margin-left: 4px; vertical-align: middle; }
/* Left-anchor the tooltip: the mark sits near the dialog's left edge, so the
   default centred 300px bubble would run off-screen on narrow viewports. */
.auth-field .alert-tip::after { left: -6px; transform: translate(0, 3px); width: min(300px, calc(100vw - 104px)); text-transform: none; letter-spacing: normal; }
.auth-field .alert-tip:hover::after { transform: translate(0, 0); }
.auth-field input { width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font: inherit; padding: 9px 11px; }
.auth-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(196,149,106,0.15); }
.auth-submit { background: var(--accent-dark); border: 1px solid var(--accent-dark); color: #fff; border-radius: 8px; padding: 9px 16px; font: inherit; font-size: .86rem; font-weight: 700; cursor: pointer; }
.auth-submit:disabled { opacity: .65; cursor: default; }
.auth-status { font-size: .84rem; color: var(--text2); line-height: 1.45; }
.auth-status.err { color: #8B3A4A; }
.auth-switch { font-size: .84rem; color: var(--text2); line-height: 1.45; margin: 0; }

main { padding: 30px 0 32px; }
main.container { padding-top: 20px; padding-bottom: 32px; }

.intro {
  margin-top: 0;
  margin-bottom: 28px;
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--text2);
}
.intro h2 { font-size: 1.25rem; font-weight: 600; color: var(--text); margin: 0 0 12px; }
.intro .page-h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.5px; color: var(--text); margin: 0 0 12px; line-height: 1.25; }
.intro p { margin: 0 0 10px; }
.intro p:last-child { margin-bottom: 0; }
footer.site-foot { margin-top: 56px; padding: 32px 0 24px; border-top: 1px solid var(--border); background: var(--surface); color: var(--text3); font-size: 0.85rem; }
footer.site-foot .foot-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 28px; margin-bottom: 18px; }
footer.site-foot .foot-heading { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.9px; font-weight: 600; color: var(--text); margin: 0 0 10px; }
footer.site-foot ul { list-style: none; margin: 0; padding: 0; }
footer.site-foot li { padding: 3px 0; }
footer.site-foot a { color: var(--text2); }
footer.site-foot a:hover { color: var(--accent-dark); }

/* Stats cards */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 32px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: box-shadow 0.2s;
}
.stat-card:hover { box-shadow: var(--shadow); }
.stat-card .label { font-size: 0.75rem; color: var(--text2); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 8px; font-weight: 500; }
.stat-card .value { font-size: 2rem; font-weight: 700; letter-spacing: -1px; }
.stat-card .value.accent { color: var(--accent-dark); }
.stat-card .value.green { color: var(--green); }
.stat-card .value.orange { color: var(--accent); }
.stat-card .sub { font-size: 0.8rem; color: var(--text2); margin-top: 4px; }

/* Activity table */
.section-title { font-size: 1.25rem; font-weight: 600; margin-bottom: 16px; color: var(--text); display: flex; align-items: baseline; justify-content: flex-start; gap: 12px; flex-wrap: wrap; }
.section-title .last-update { font-size: 0.85rem; font-weight: 400; color: var(--text2); }
.activity-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px; margin-bottom: 40px;
}
.activity-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex; justify-content: space-between; align-items: center;
  transition: box-shadow 0.2s, border-color 0.2s;
  color: var(--text); text-decoration: none;
}
.activity-card:hover { box-shadow: var(--shadow-sm); border-color: var(--accent); text-decoration: none; }
.activity-card .act-name { font-size: 0.85rem; flex: 1; color: var(--text); }
.activity-card .act-id { display: inline-flex; align-items: center; justify-content: center; background: var(--accent-bg); color: var(--accent-dark); border-radius: 8px; padding: 2px 8px; font-size: 0.75rem; font-weight: 600; margin-right: 12px; min-width: 28px; }
.activity-card .act-stats { text-align: right; white-space: nowrap; }
.activity-card .act-stats span { display: block; font-size: 0.8rem; color: var(--text2); }
.activity-card .act-stats strong { color: var(--green); }

/* Search & filters */
.toolbar {
  display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; align-items: center;
  position: relative; z-index: 2;
}
.search-box {
  flex: 1; min-width: 250px; position: relative;
}
.search-box input {
  width: 100%; padding: 10px 16px 10px 40px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-box input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(196,149,106,0.15); }
.search-box input::placeholder { color: var(--text3); }
.search-box::before {
  content: "\1F50D"; position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-size: 0.85rem; opacity: 0.4; pointer-events: none;
}
.search-box.has-submit input { padding-right: 74px; }
.search-submit {
  position: absolute; right: 4px; top: 4px; bottom: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 60px; border: 1px solid transparent; border-left-color: var(--border);
  border-radius: 8px; background: transparent; color: var(--text2);
  font: inherit; font-size: 0.78rem; font-weight: 600; cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.search-submit:hover { background: var(--surface2); border-color: var(--border); color: var(--accent-dark); }
.search-submit:focus { outline: none; color: var(--accent-dark); box-shadow: inset 0 0 0 1px var(--accent); }
.filter-pills { display: flex; gap: 4px; }
.intro-toggle { display: none; }
.filter-pills button {
  background: var(--surface); border: 1px solid var(--border); color: var(--text2);
  padding: 8px 16px; border-radius: 20px; cursor: pointer; font-size: 0.8rem;
  font-weight: 500; transition: all 0.2s;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.filter-pills button:hover { border-color: var(--border2); color: var(--text); }
.filter-pills button.active { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.inline-alert {
  display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; min-width: 0;
}
.inline-alert-link {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--border); color: var(--text2);
  border-radius: 20px; padding: 8px 14px; font-size: 0.8rem; font-weight: 500; transition: all 0.2s;
}
.inline-alert-link:hover { border-color: var(--border2); color: var(--text); text-decoration: none; }
.alert-tip {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border-radius: 50%; border: 1px solid currentColor;
  color: inherit; background: transparent; font-size: 0.62rem; font-weight: 700;
  line-height: 1; cursor: help; flex: 0 0 14px;
}
.alert-tip::before,
.alert-tip::after {
  position: absolute; left: 50%; bottom: calc(100% + 9px);
  opacity: 0; pointer-events: none; transition: opacity 0.12s, transform 0.12s;
  transform: translate(-50%, 3px); z-index: 260;
}
.alert-tip::before {
  content: ""; bottom: calc(100% + 4px);
  border: 6px solid transparent; border-top-color: #fff;
  filter: drop-shadow(0 1px 0 var(--border));
}
.alert-tip::after {
  content: attr(data-tooltip); width: 300px; max-width: calc(100vw - 40px);
  background: #fff; border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; box-shadow: var(--shadow-lg); padding: 9px 11px;
  font-size: 0.75rem; line-height: 1.45; font-weight: 400; text-align: left;
  white-space: normal;
}
.alert-tip:hover::before,
.alert-tip:hover::after,
.inline-alert-link:focus-visible .alert-tip::before,
.inline-alert-link:focus-visible .alert-tip::after {
  opacity: 1; transform: translate(-50%, 0);
}
.section-title-main { display: inline-flex; align-items: baseline; gap: 12px; flex-wrap: wrap; min-width: 0; }
.inline-alert-link .bell-ico { width: 16px; height: 16px; display: block; fill: #E8A83A; }
.watch-toggle {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--surface2); border: 1px solid var(--border2); color: var(--text2);
  border-radius: 20px; padding: 6px 12px; font: inherit; font-size: 0.8rem; font-weight: 600;
  line-height: 1; cursor: pointer; white-space: nowrap;
}
.watch-toggle .bell-ico { width: 16px; height: 16px; display: block; fill: #E8A83A; }
.watch-toggle:hover { border-color: var(--accent); color: var(--text); }
.watch-toggle[aria-pressed="true"] { background: var(--accent-bg); border-color: var(--accent); color: var(--accent-dark); }
.watch-toggle:disabled { opacity: .6; cursor: default; }
.filter-note {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border-radius: 50%; border: 1px solid currentColor;
  font-size: 0.65rem; font-weight: 700; line-height: 1;
}
.filter-note::before,
.filter-note::after {
  position: absolute; left: 50%; bottom: calc(100% + 9px);
  opacity: 0; pointer-events: none; transition: opacity 0.12s, transform 0.12s;
  transform: translate(-50%, 3px); z-index: 250;
}
.filter-note::before {
  content: "";
  bottom: calc(100% + 4px);
  border: 6px solid transparent; border-top-color: #fff;
  filter: drop-shadow(0 1px 0 var(--border));
}
.filter-note::after {
  content: attr(data-tooltip);
  width: 280px; max-width: calc(100vw - 40px);
  background: #fff; border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; box-shadow: var(--shadow-lg);
  padding: 9px 11px; font-size: 0.75rem; line-height: 1.45; font-weight: 400;
  text-align: left; white-space: normal;
}
.filter-note:hover::before,
.filter-note:hover::after,
.filter-note:focus-visible::before,
.filter-note:focus-visible::after {
  opacity: 1; transform: translate(-50%, 0);
}
.th-with-note { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.th-with-note .filter-note { text-transform: none; letter-spacing: 0; color: var(--text2); }
.th-with-note .filter-note::before,
.th-with-note .filter-note::after {
  top: calc(100% + 9px); bottom: auto;
  transform: translate(-50%, -3px);
}
.th-with-note .filter-note::before {
  top: calc(100% + 4px);
  border-top-color: transparent; border-bottom-color: #fff;
  filter: drop-shadow(0 -1px 0 var(--border));
}
.th-with-note .filter-note:hover::before,
.th-with-note .filter-note:hover::after,
.th-with-note .filter-note:focus-visible::before,
.th-with-note .filter-note:focus-visible::after {
  transform: translate(-50%, 0);
}

/* Table */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative; z-index: 1;
  box-shadow: var(--shadow-sm);
  transition: opacity 0.12s ease;
}
/* Refetch in progress: keep the old rows visible (dimmed) so the page height
   never collapses - swapping in a tiny "Loading..." div makes filter clicks
   jitter the whole viewport. */
.table-wrap.reloading { opacity: 0.55; pointer-events: none; }
table { width: 100%; border-collapse: collapse; }
th {
  background: var(--surface2); text-align: left; padding: 12px 20px;
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text2); font-weight: 600;
}
td { padding: 14px 20px; border-top: 1px solid var(--border); font-size: 0.9rem; }
tr { transition: background 0.15s; cursor: pointer; }
tr:hover { background: var(--surface2); }
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.3px;
}
.badge-active { background: var(--green-bg); color: var(--green); }
.badge-ceased, .badge-dissolved { background: var(--red-bg); color: var(--red); }
.badge-ri { background: var(--purple-bg); color: var(--purple); }
.badge-ro { background: var(--blue-bg); color: var(--blue); }
.badge-rep { background: var(--surface2); color: var(--text2); }
.badge-move-add { background: var(--green-bg); color: var(--green); }
.badge-move-end { background: var(--red-bg); color: var(--red); }
.badge-category-buy { background: #E8F3E8; color: #2D6A2D; }
.badge-category-sell { background: #E8EEF8; color: #24568C; }
.category-badge-wrap { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.category-uncertain-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 13px; height: 13px; flex: 0 0 13px; border-radius: 50%;
  border: 1px solid currentColor; font-size: 0.62rem; line-height: 1;
  font-weight: 700; opacity: 0.78; vertical-align: middle; box-sizing: border-box;
}
.table-sub { margin-top: 2px; font-size: 0.75rem; color: var(--text3); line-height: 1.35; }
.table-link { color: var(--accent-dark); font-weight: 500; text-decoration: none; }
.table-link:hover { text-decoration: underline; }
.nowrap { white-space: nowrap; }
.moves-date-control {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px 8px 6px 12px;
}
.moves-date-control span {
  font-size: 0.7rem; color: var(--text2); text-transform: uppercase;
  letter-spacing: 0.6px; font-weight: 600; white-space: nowrap;
}
.moves-date-control input[type="date"] {
  border: none; background: transparent; color: var(--text);
  font: inherit; font-size: 0.85rem; cursor: pointer;
}
.moves-date-control input[type="date"]:focus { outline: none; }
.moves-date-control button {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text2); padding: 4px 10px; border-radius: 6px;
  cursor: pointer; font-size: 0.75rem; font-weight: 600;
}
.moves-date-control button:hover:not(:disabled) { border-color: var(--border2); color: var(--text); }
.moves-date-control button:disabled { opacity: 0.4; cursor: default; }

/* Pagination */
.pagination {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px; background: var(--surface); border-top: 1px solid var(--border);
}
.pagination .info { font-size: 0.8rem; color: var(--text2); }
.pagination .btns { display: flex; gap: 8px; }
.pagination button {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 6px 16px; border-radius: 8px; cursor: pointer; font-size: 0.8rem; font-weight: 500;
  transition: all 0.15s;
}
.pagination button:disabled { opacity: 0.35; cursor: default; }
.pagination button:not(:disabled):hover { border-color: var(--border2); background: var(--surface2); }

/* Dropdown */
.dropdown { position: relative; z-index: 210; }
#category-dropdown .dropdown-btn { display: inline-flex; align-items: center; gap: 6px; }
.dl-btn {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--border); color: var(--text2);
  padding: 8px 14px; border-radius: 20px; cursor: pointer;
  font-size: 0.8rem; font-weight: 500;
  transition: all 0.2s;
}
.dl-btn svg { width: 14px; height: 14px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dl-btn:hover { border-color: var(--accent); color: var(--accent-dark); background: var(--accent-bg); }
.dl-btn:disabled { cursor: default; opacity: 0.6; }
/* '?' help mark lives inside the pill and inherits the button colour (same as
   the alerts pill's mark). It sits near the toolbar's right edge, so its tooltip
   is right-anchored instead of centred to avoid overflowing off-screen. */
.dl-note::before, .dl-note::after { left: auto; right: 0; transform: translate(0, 3px); }
.dl-note::before { right: 1px; }
.dl-note:hover::before, .dl-note:hover::after,
.dl-btn:focus-visible .dl-note::before, .dl-btn:focus-visible .dl-note::after { opacity: 1; transform: translate(0, 0); }
/* Out of flow (the toolbar is position:relative): the status text appears just
   below the button's right edge, so showing/clearing "Preparing..." etc. can't
   reflow the toolbar and jerk the download button. */
.dl-status { position: absolute; top: 100%; right: 0; margin-top: 5px; color: var(--text2); font-size: 0.78rem; max-width: 260px; text-align: right; }
.dl-status:empty { display: none; }
/* Download quota / refusal popup */
.dl-notice[hidden] { display: none; }
.dl-notice { position: fixed; inset: 0; z-index: 1200; display: flex; align-items: center; justify-content: center; padding: 20px; }
.dl-notice-backdrop { position: absolute; inset: 0; background: rgba(26, 26, 26, 0.42); }
.dl-notice-dialog {
  position: relative; width: min(440px, calc(100vw - 40px));
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 22px 22px 18px;
}
.dl-notice-title { font-size: 1.05rem; color: var(--text); margin: 0 0 8px; border: 0; padding: 0; text-transform: none; letter-spacing: 0; }
.dl-notice-body { font-size: 0.9rem; color: var(--text2); line-height: 1.55; margin: 0; }
.dl-notice-foot { display: flex; justify-content: flex-end; margin-top: 18px; }
.dl-notice-ok {
  background: var(--accent-dark); border: 1px solid var(--accent-dark); color: #fff;
  border-radius: 8px; padding: 8px 18px; font: inherit; font-size: 0.86rem; font-weight: 700; cursor: pointer;
}
.dl-notice-ok:hover { opacity: 0.92; }
.dropdown-btn {
  background: var(--surface); border: 1px solid var(--border); color: var(--text2);
  padding: 8px 16px; border-radius: 20px; cursor: pointer; font-size: 0.8rem;
  font-weight: 500; transition: all 0.2s;
}
.dropdown-btn:hover { border-color: var(--border2); color: var(--text); }
.dropdown-menu {
  display: none; position: absolute; top: calc(100% + 6px); left: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 0;
  min-width: 320px; max-height: 400px; overflow-y: auto;
  z-index: 300; box-shadow: var(--shadow-lg);
}
.dropdown-menu.open { display: block; }
.dropdown-menu label {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; cursor: pointer; font-size: 0.85rem;
  transition: background 0.1s; color: var(--text);
}
.dropdown-menu label:hover { background: var(--surface2); }
.dropdown-menu label .act-num {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-bg); color: var(--accent-dark);
  border-radius: 6px; min-width: 24px; height: 22px;
  font-size: 0.7rem; font-weight: 600;
}
.dropdown-menu label.cat-side-opt { font-weight: 600; }
.dropdown-menu label.cat-side-opt:not(:first-child) {
  border-top: 1px solid var(--border); margin-top: 4px; padding-top: 10px;
}
.dropdown-menu label.cat-detail-opt { padding-left: 50px; }

/* Staff range */
.staff-range { display: flex; gap: 6px; align-items: center; }
.staff-range .range-label { font-size: 0.75rem; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; font-weight: 500; }
.staff-range input[type="number"] {
  width: 70px; padding: 7px 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 0.85rem;
  transition: border-color 0.2s, box-shadow 0.2s; -moz-appearance: textfield;
}
.staff-range input[type="number"]::-webkit-outer-spin-button,
.staff-range input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.staff-range input[type="number"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(196,149,106,0.15); }
.staff-range input[type="number"]::placeholder { color: var(--text3); }

/* Responsive */
@media (max-width: 768px) {
  header .container { flex-direction: column; align-items: flex-start; gap: 12px; }
  header { position: static; }
  header nav { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); overflow-x: visible; }
  header nav a { text-align: center; padding: 8px 10px; min-height: 44px; display: flex; align-items: center; justify-content: center; }
  .auth-nav { width: 100%; margin-left: 0; }
  .auth-nav a, .auth-nav button { flex: 1 1 auto; min-height: 44px; }
  .auth-dialog { top: 16px; max-height: calc(100vh - 32px); overflow: auto; -webkit-overflow-scrolling: touch; }
  main { padding-top: 22px; }
  main.container { padding-top: 12px; }
  .intro { margin-top: 0; margin-bottom: 22px; font-size: 0.98rem; line-height: 1.62; }
  .intro .page-h1 { font-size: 1.35rem; letter-spacing: -0.2px; }
  .intro-body { max-height: 4.8em; overflow: hidden; }
  .intro-body.expanded { max-height: none; overflow: visible; }
  .intro-toggle { display: inline-block; margin-top: 2px; padding: 6px 0; background: none; border: 0; color: var(--accent-dark); font: inherit; font-weight: 600; cursor: pointer; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 24px; }
  .stat-card { padding: 16px; }
  .stat-card .label { font-size: 0.68rem; letter-spacing: 0.5px; }
  .stat-card .value { font-size: 1.55rem; letter-spacing: -0.5px; }
  .activity-grid { grid-template-columns: 1fr; margin-bottom: 24px; }
  .activity-card { align-items: flex-start; gap: 10px; padding: 14px; }
  .activity-card .act-stats { flex-shrink: 0; }
  .toolbar { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px 8px; }
  .toolbar .search-box { grid-column: 1; grid-row: 1; width: auto; min-width: 0; }
  .toolbar .inline-alert { grid-column: 2; grid-row: 1; width: auto; min-width: 0; align-self: center; }
  .toolbar .dropdown,
  .toolbar .moves-date-control,
  .toolbar .filter-pills,
  .toolbar .dl-btn,
  .toolbar .dl-status,
  .toolbar .staff-range { grid-column: 1 / -1; width: auto; }
  .toolbar .net-select { grid-column: 1 / -1; width: 100%; margin-left: 0 !important; min-height: 44px; }
  .toolbar .dl-btn { justify-content: center; min-height: 40px; }
  #net-search-wrap, #flow-search-wrap { width: 100%; min-width: 0; }
  .dropdown-btn, .net-controls { width: 100%; }
  .search-box input,
  #net-search-wrap input,
  #flow-search-wrap input,
  .staff-range input[type="number"],
  .moves-date-control input[type="date"] { font-size: 16px; }
  .search-box.has-submit input { padding-right: 56px; }
  .search-submit { min-width: 44px; }
  .dropdown-btn { display: flex; align-items: center; justify-content: space-between; text-align: left; }
  .dropdown-menu {
    min-width: 0;
    width: min(100%, calc(100vw - 32px));
    max-width: calc(100vw - 32px);
  }
  .filter-pills {
    margin-left: 0 !important;
    flex-wrap: wrap;
    row-gap: 6px;
    overflow: visible;
  }
  .filter-pills button { flex: 1 1 auto; min-height: 40px; justify-content: center; }
  .staff-range { flex-wrap: wrap; }
  .staff-range input[type="number"] { flex: 1 1 90px; min-width: 0; }
  .moves-date-control { justify-content: space-between; flex-wrap: wrap; }
  .moves-date-control input[type="date"] { flex: 1 1 150px; min-width: 0; }
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table-wrap td, .table-wrap th { padding: 10px 12px; }
  .table-wrap th:first-child, .table-wrap td:first-child { position: sticky; left: 0; z-index: 1; }
  .table-wrap td:first-child { background: var(--bg); }
  .table-wrap th:first-child { background: var(--surface2); }
  .lh-table, .lh-table tbody, .lh-table tr, .lh-table td { display: block; }
  .lh-table { overflow: visible; }
  .lh-table thead { display: none; }
  .lh-table tr { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 10px 12px; margin-bottom: 10px; }
  .lh-table td { border: 0; padding: 2px 0; white-space: normal; min-width: 0; }
  .lh-table td:first-child { font-weight: 600; margin-bottom: 4px; min-width: 0; }
  .lh-table td[data-label]::before { content: attr(data-label) ": "; color: var(--text2); font-weight: 600; text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.4px; }
  .table-wrap table { min-width: 640px; }
  #org-table table { min-width: 820px; }
  #moves-table table { min-width: 760px; }
  #fmoves-table table { min-width: 640px; }
  .pagination { align-items: flex-start; flex-direction: column; gap: 10px; }
  .pagination .btns { width: 100%; }
  .pagination button { flex: 1; }
  .container { padding: 0 16px; }
}

@media (max-width: 420px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-title { gap: 6px; }
  .trend-chart { padding: 14px; }
}

@media (hover: none) and (pointer: coarse) {
  a, button, tr, .filter-pills button, .net-result-item {
    -webkit-tap-highlight-color: transparent;
  }
  tr:active, .filter-pills button:active, .net-result-item:active {
    background: var(--surface2);
  }
}

@media (prefers-reduced-motion: reduce) and (max-width: 768px) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

.loading { text-align: center; padding: 40px; color: var(--text2); }
.empty { text-align: center; padding: 40px; color: var(--text2); }
.trend-chart {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 32px;
  position: relative;
}
.trend-chart canvas {
  width: 100% !important;
  height: auto !important;
}
/* Plotly-style camera: wraps just the canvas so the button anchors to the
   plot's top-right corner regardless of any controls row above it. */
.chart-shot { position: relative; }
.chart-shot-btn {
  position: absolute; top: 4px; right: 0; z-index: 5;
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text2); cursor: pointer; opacity: 0;
  transition: opacity 0.15s, color 0.15s, border-color 0.15s;
}
.trend-chart:hover .chart-shot-btn, .chart-shot-btn:focus-visible { opacity: 1; }
.chart-shot-btn:hover { color: var(--accent-dark); border-color: var(--accent); background: var(--accent-bg); }
.chart-shot-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: none) { .chart-shot-btn { opacity: 0.7; } }
.cat-trend-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px 16px; flex-wrap: wrap; margin-bottom: 14px;
}
.cat-trend-controls { display: flex; align-items: center; gap: 10px 12px; flex-wrap: wrap; }
.cat-trend-note {
  font-size: 0.8rem; color: var(--text2);
  display: inline-flex; align-items: center; gap: 6px;
}
/* On desktop this note sits near the right edge, so centring its 280px tooltip
   pushed it past the viewport and added a horizontal scrollbar. That overflow is
   clipped the instant any modal sets body{overflow:hidden} (e.g. the CSV download
   auth/limit popups), snapping the whole layout ("convulsing"). Right-anchor the
   tooltip body so it stays on-screen and never widens the document; the arrow
   stays centred on the mark. */
.cat-trend-note .filter-note::after { left: auto; right: 0; transform: translate(0, 3px); }
.cat-trend-note .filter-note:hover::after,
.cat-trend-note .filter-note:focus-visible::after { transform: translate(0, 0); }
.cat-trend-status { margin-top: 10px; font-size: 0.82rem; color: var(--text2); }
.cat-trend-status:empty { display: none; margin-top: 0; }
@media (min-width: 769px) {
  #ppl-trend-menu, #moves-trend-menu, #fmoves-trend-menu { min-width: 290px; }
}
#ppl-trend-menu .cat-trend-group, #moves-trend-menu .cat-trend-group {
  padding: 8px 16px 2px; font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.6px; text-transform: uppercase; color: var(--text3);
}
#ppl-trend-menu label.cat-sub, #moves-trend-menu label.cat-sub { padding-left: 30px; }
.cat-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
/* Current firm-category statistics (firms tab): an HTML bar list per side.
   Bars share one scale across both columns so magnitudes compare honestly;
   rows are real buttons because clicking one drives the table filter. */
.cat-stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 36px; align-items: start; }
.cat-stats-side-head, .cat-stats-row {
  display: block; width: 100%; text-align: left; background: none;
  border: 1px solid transparent; border-radius: 8px; cursor: pointer;
  font: inherit; color: inherit; padding: 5px 8px;
}
.cat-stats-side-head { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 2px; }
.cat-stats-side-count { color: var(--text2); font-weight: 500; font-size: 0.85rem; }
.cat-stats-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.cat-stats-row:hover, .cat-stats-side-head:hover { background: var(--surface2); }
.cat-stats-row.active, .cat-stats-side-head.active { border-color: var(--accent); background: var(--accent-bg); }
.cat-stats-row:focus-visible, .cat-stats-side-head:focus-visible {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(196,149,106,0.15);
}
.cat-stats-row-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 0.9rem; line-height: 1.35; margin-bottom: 4px; }
.cat-stats-label { color: var(--text); }
.cat-stats-val { color: var(--text); font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cat-stats-share { color: var(--text2); font-weight: 500; }
/* Data-end rounded, baseline end square, per the house bar spec. */
.cat-stats-bar { display: block; height: 10px; border-radius: 0 4px 4px 0; min-width: 2px; transition: width 0.35s ease; }
.cat-stats-bar.zero { min-width: 0; }
.cat-stats-bar.buy { background: #338055; }
.cat-stats-bar.sell { background: #4173B8; }
.cat-stats-foot { margin-top: 12px; font-size: 0.8rem; color: var(--text2); }
@media (prefers-reduced-motion: reduce) { .cat-stats-bar { transition: none; } }
@media (max-width: 768px) {
  .trend-chart { padding: 16px; margin-bottom: 24px; }
  .cat-trend-head .dropdown { width: 100%; }
  .cat-trend-controls { width: 100%; }
  .cat-stats-grid { grid-template-columns: 1fr; gap: 18px 0; }
}

/* Network view */
#view-network { display: flex; flex-direction: column; }
/* "Network" menu-bar dropdown: the nav item opens a menu of visualisations
   (colleague network / firm talent flow / global talent-flow network). The
   menu is position:fixed and JS-placed so the header's overflow-x:auto scroll
   container never clips it. */
.net-nav { position: relative; display: inline-flex; }
.net-nav-caret { font-size: 0.62em; margin-left: 5px; opacity: 0.75; vertical-align: 1px; }
.net-nav-menu { position: fixed; min-width: 236px; padding: 6px; }
.net-nav-menu a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--text); font-size: 0.85rem; font-weight: 500; white-space: nowrap; text-decoration: none; }
.net-nav-menu a:hover { background: var(--surface2); color: var(--text); text-decoration: none; }
.net-nav-menu a.active { background: var(--accent-bg); color: var(--accent-dark); }
.net-nav-menu a svg { width: 16px; height: 16px; flex: none; color: var(--text3); }
.net-nav-menu a.active svg { color: var(--accent-dark); }
/* Methodology shown directly as an "About" section (one visualisation per view). */
.net-about { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-top: 22px; font-size: 0.85rem; color: var(--text2); line-height: 1.6; }
.net-about-title { font-size: 0.95rem; font-weight: 700; color: var(--text); margin: 0 0 10px; letter-spacing: 0; }
.net-about p { margin: 8px 0; }
.net-about ul { padding-left: 22px; margin: 8px 0; }
.net-about li { margin: 4px 0; }
.net-about code { background: var(--surface2); padding: 1px 6px; border-radius: 4px; font-size: 0.82rem; font-family: 'SF Mono', Menlo, Consolas, monospace; color: var(--text); }
.net-about a { color: var(--accent-dark); font-weight: 600; text-decoration: none; }
.net-about a:hover { text-decoration: underline; }
.net-about .net-about-more { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--border); }
.net-toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; position: relative; z-index: 2; }
#net-search-wrap, #flow-search-wrap, #map-search-wrap { position: relative; flex: 1; min-width: 250px; }
#net-search-wrap input, #flow-search-wrap input, #map-search-wrap input {
  width: 100%; padding: 10px 16px 10px 40px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#net-search-wrap input:focus, #flow-search-wrap input:focus, #map-search-wrap input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(196,149,106,0.15); }
#net-search-wrap input::placeholder, #flow-search-wrap input::placeholder, #map-search-wrap input::placeholder { color: var(--text3); }
#net-search-wrap.has-submit input, #flow-search-wrap.has-submit input, #map-search-wrap.has-submit input { padding-right: 76px; }
#net-search-wrap::before, #flow-search-wrap::before, #map-search-wrap::before {
  content: "\1F50D"; position: absolute; left: 14px; top: 50%;
  transform: translateY(-50%); font-size: 0.85rem; opacity: 0.4; z-index: 1;
}
#net-results, #flow-results, #map-results {
  display: none; position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); max-height: 320px; overflow-y: auto;
  z-index: 150; box-shadow: var(--shadow-lg);
}
.net-result-item {
  padding: 10px 16px; cursor: pointer; font-size: 0.85rem;
  display: flex; align-items: center; gap: 6px; transition: background 0.1s;
}
.net-result-item:hover { background: var(--surface2); }
#network-canvas {
  position: relative; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; height: calc(100vh - 220px); min-height: 450px;
}
#view-network.map-mode #network-canvas {
  height: clamp(500px, 62vh, 640px);
  min-height: 500px;
}
/* Expanded talent-flow ego view can grow taller than the frame; let it scroll. */
#network-canvas.flow-scroll { overflow-y: auto; overflow-x: hidden; }
#network-canvas svg { display: block; }
.net-tooltip {
  position: absolute; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px; font-size: 0.8rem; line-height: 1.6;
  pointer-events: auto; z-index: 10; box-shadow: var(--shadow); max-width: 300px;
}
.net-tooltip .net-tip-actions {
  margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border);
  display: flex; gap: 12px; align-items: center;
}
.net-tooltip .net-tip-actions a { color: var(--accent-dark); font-weight: 600; text-decoration: none; }
.net-tooltip .net-tip-actions a:hover { text-decoration: underline; }
.net-tip-ro {
  display: inline-block; margin-left: 6px; padding: 0 5px; border-radius: 4px;
  background: var(--accent-dark); color: #fff; font-size: 0.65rem; font-weight: 700;
  vertical-align: 1px; letter-spacing: 0.3px;
}
.row-net-btn {
  display: inline-flex; align-items: center; vertical-align: middle; margin-left: 7px;
  padding: 2px 3px; border: none; background: none; cursor: pointer;
  color: var(--text3); border-radius: 4px; text-decoration: none;
}
.row-net-btn:hover { color: var(--accent-dark); background: var(--surface2); }
.row-net-btn svg { width: 14px; height: 14px; display: block; }
/* Touch: the tooltip must not become a dead zone over the graph - taps pass
   through its body; only the action row (Open profile) stays interactive. */
@media (hover: none) and (pointer: coarse) {
  .net-tooltip { pointer-events: none; }
  .net-tooltip .net-tip-actions { pointer-events: auto; }
}
#network-footer { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
#network-status { font-size: 0.85rem; color: var(--text2); padding: 8px 0; white-space: nowrap; }
#network-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 8px 0; flex: 1; }
.net-legend-item { display: flex; align-items: center; gap: 6px; font-size: 0.75rem; color: var(--text2); cursor: pointer; transition: opacity 0.15s; }
.net-legend-item:hover { opacity: 0.7; }
.net-legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.net-controls { display: flex; gap: 16px; align-items: center; }
.net-controls label { font-size: 0.8rem; color: var(--text2); display: flex; align-items: center; gap: 5px; cursor: pointer; white-space: nowrap; }
.net-controls input[type="checkbox"] { accent-color: var(--accent-dark); }
.net-intro {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 16px; margin-top: 12px;
  font-size: 0.85rem; color: var(--text2); line-height: 1.55;
}
.net-intro summary {
  cursor: pointer; font-weight: 600; color: var(--text);
  padding: 2px 0; user-select: none; list-style: none;
}
.net-intro summary::-webkit-details-marker { display: none; }
.net-intro summary::before {
  content: "\25B6"; display: inline-block; margin-right: 8px;
  font-size: 0.7rem; color: var(--accent-dark); transition: transform 0.15s;
}
.net-intro[open] summary::before { transform: rotate(90deg); }
.net-intro[open] summary {
  margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.net-intro p { margin: 5px 0; }
.net-intro ul { padding-left: 22px; margin: 5px 0; }
.net-intro li { margin: 2px 0; }
.net-intro code {
  background: var(--surface2); padding: 1px 6px; border-radius: 4px;
  font-size: 0.78rem; font-family: 'SF Mono', Menlo, Consolas, monospace;
  color: var(--text);
}
.net-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 10px; height: 100%; padding: 24px; color: var(--text2); font-size: 0.95rem;
}
.net-empty .big { font-size: 2rem; opacity: 0.3; }
.net-empty-ico { color: var(--accent); opacity: 0.6; line-height: 0; }
.net-empty-ico svg { width: 46px; height: 46px; display: block; }
.net-empty-title { font-size: 0.98rem; color: var(--text2); margin: 0; font-weight: 500; max-width: 42ch; }
.net-empty-link { background: none; border: 0; color: var(--accent-dark); font: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer; padding: 2px 0; }
.net-empty-link:hover { text-decoration: underline; }
@keyframes pulse { 0%,100% { opacity: 0.2; } 50% { opacity: 0.5; } }
#view-network.net-fullscreen {
  position: fixed; inset: 0; z-index: 9999; background: var(--surface);
  display: flex; flex-direction: column; height: 100vh !important; padding: 12px;
}
/* !important: the mobile media queries below set equal-specificity heights on
   the map-mode canvas later in the sheet; fullscreen must beat them. */
#view-network.net-fullscreen #network-canvas { flex: 1; min-height: 0 !important; height: auto !important; border-radius: 0; }
#view-network.net-fullscreen .net-toolbar { flex-shrink: 0; }
#view-network.net-fullscreen #network-footer { flex-shrink: 0; }
#view-network.net-fullscreen > .intro,
#view-network.net-fullscreen > .net-intro,
#view-network.net-fullscreen > .map-rankings,
#view-network.net-fullscreen > .net-about { display: none !important; }
@media (max-width: 768px) {
  #network-canvas { height: 60vh; min-height: 360px; }
  /* Fullscreen on a phone is for the graph: hide the search box and the flow
     stat chips (the flow SVG carries its own baked-in legend), and collapse
     the wrapping colour key to one sideways-scrollable row instead of hiding
     it - in map/ego fullscreen it is the only key to the node colours. */
  #view-network.net-fullscreen .search-box,
  #view-network.net-fullscreen #flow-chips { display: none; }
  #view-network.net-fullscreen #network-legend { flex-wrap: nowrap; overflow-x: auto; }
  #view-network.net-fullscreen #network-legend .net-legend-item { flex: none; white-space: nowrap; }
  .net-toolbar { flex-direction: column; align-items: stretch; }
  .net-controls { justify-content: space-between; flex-wrap: wrap; gap: 8px; }
  #network-status { white-space: normal; }
  .net-select { min-height: 44px; }
  #flow-range-select, .net-map-only.net-select { flex: 1 1 auto; }
  #view-network.map-mode .net-controls { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); width: 100%; }
  #view-network.map-mode #map-range-select { grid-column: span 2; }
  #view-network.map-mode #map-size-wrap { grid-column: span 4; }
  #view-network.map-mode #map-color-wrap { grid-column: span 3; }
  #view-network.map-mode .net-controls .net-select { width: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  #view-network.map-mode .net-controls button { min-height: 44px; justify-content: center !important; }
  #view-network.map-mode .net-controls .map-hint-btn { min-height: 0; width: 18px; height: 18px; }
}
.net-hull { cursor: pointer; transition: fill-opacity 0.3s; }
.net-hull:hover { fill-opacity: 0.15 !important; }
.map-sel-wrap { position: relative; display: flex; min-width: 0; }
.map-sel-wrap .net-select { min-width: 0; padding-right: 54px; }
.map-hint-btn {
  position: absolute; right: 31px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; border-radius: 50%;
  border: 1px solid var(--border2); background: none; color: var(--text3);
  font-size: .64rem; font-weight: 700; line-height: 1;
  cursor: help; display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.map-hint-btn:hover, .map-hint-btn:focus-visible { border-color: var(--accent); color: var(--accent); }
#map-hint-pop {
  position: fixed; z-index: 320; max-width: 320px; padding: 11px 13px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  box-shadow: 0 8px 26px rgba(0,0,0,0.13); font-size: .8rem; line-height: 1.5; color: var(--text);
}
#map-hint-pop .map-hint-title { font-weight: 700; font-size: .82rem; margin-bottom: 5px; }
#map-hint-pop p { margin: 0 0 7px; }
#map-hint-pop .map-hint-note { color: var(--text2); font-size: .74rem; }
#map-hint-pop a { color: var(--accent-dark); font-weight: 600; text-decoration: none; }
#map-hint-pop a:hover { text-decoration: underline; }
/* Three network modes. The server emits one explicit class so deep links paint
   the correct controls before JavaScript starts. */
#view-network.ego-mode .net-flow-only, #view-network.ego-mode .net-map-only,
#view-network.flow-mode .net-ego-only, #view-network.flow-mode .net-map-only,
#view-network.map-mode .net-ego-only, #view-network.map-mode .net-flow-only { display: none !important; }

.map-rankings { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--border); }
.map-rank-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.map-rank-head h2 { margin: 0; font-size: 1.08rem; letter-spacing: 0; }
.map-rank-note { margin: 5px 0 0; color: var(--text2); font-size: 0.82rem; line-height: 1.5; }
.map-rank-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.map-rank-table th { color: var(--text2); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0; text-align: right; }
.map-rank-table th:nth-child(2), .map-rank-table td:nth-child(2) { text-align: left; }
.map-rank-table td { text-align: right; }
.map-rank-table .map-rank-num { color: var(--text3); width: 42px; font-family: 'SF Mono', Menlo, Consolas, monospace; }
.map-rank-firm { display: flex; align-items: center; gap: 8px; min-width: 0; }
.map-rank-firm a { color: var(--text); font-weight: 650; text-decoration: none; overflow-wrap: anywhere; }
.map-rank-firm a:hover { color: var(--accent-dark); text-decoration: underline; }
.map-rank-view { color: var(--accent-dark); font-weight: 600; text-decoration: none; white-space: nowrap; }
.map-rank-view:hover { text-decoration: underline; }
.map-rank-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 12px; }
/* Every control in this row pins to the standard 34px toolbar-control height
   (same idiom as .toolbar .net-select); mobile's 44px touch min-height wins. */
.map-rank-controls .net-select { height: 34px; line-height: normal; }
.map-rank-search-wrap { flex: 1 1 240px; min-width: 200px; max-width: 380px; }
#map-rank-search {
  width: 100%; height: 34px; padding: 0 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 0.84rem;
}
#map-rank-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(196,149,106,0.15); }
#map-rank-search::placeholder { color: var(--text3); }
.map-rank-range { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text2); white-space: nowrap; }
.map-rank-range input {
  width: 74px; height: 34px; padding: 0 10px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 0.84rem; font-variant-numeric: tabular-nums;
}
.map-rank-range input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(196,149,106,0.15); }
.map-node { cursor: pointer; transition: opacity .15s, stroke-width .15s; }
.map-edge {
  cursor: pointer; transition: opacity .15s, stroke-width .15s;
  mix-blend-mode: multiply;
}
.map-label-leader { pointer-events: none; }
.map-label {
  pointer-events: none; paint-order: stroke; stroke: var(--surface);
  stroke-width: 3.5px; stroke-linejoin: round;
}
@media (max-width: 640px) {
  #view-network.map-mode #network-canvas { height: 60vh; min-height: 360px; }
  .map-rank-head { align-items: stretch; flex-direction: column; }
  .map-rank-controls { gap: 8px; }
  .map-rank-search-wrap { flex-basis: 100%; max-width: none; }
  #map-rank-search, .map-rank-range input { min-height: 44px; }
  .map-rank-table { table-layout: fixed; font-size: 0.73rem; }
  .map-rankings .table-wrap .map-rank-table { min-width: 0; display: table; }
  .map-rank-table th { font-size: 0.61rem; white-space: normal; padding: 8px 4px; }
  .map-rank-table td { padding: 9px 4px; }
  /* Narrow screens keep the # column (the continuous rank the range filter
     targets) and drop the global PageRank rank, score, and people columns. */
  .map-rank-table th:nth-child(3), .map-rank-table td:nth-child(3),
  .map-rank-table th:nth-child(5), .map-rank-table td:nth-child(5),
  .map-rank-table th:nth-child(6), .map-rank-table td:nth-child(6) { display: none; }
  .map-rank-table th:nth-child(1) { width: 40px; }
  .map-rank-table th:nth-child(2) { width: 52%; }
  .map-rank-table th:nth-child(4) { width: 17%; }
  .map-rank-table th:nth-child(7) { width: 16%; }
  .map-rank-firm { gap: 5px; }
  .map-rank-firm a { font-size: 0.73rem; line-height: 1.35; }
  .map-rank-view { font-size: 0.68rem; }
}

/* Latest Moves page modes (individual moves vs firm licence changes): the
   firm-mode class is server-set on /moves/firms deep links (mirrored by
   setMovesMode) so a deep-linked shell paints the right controls before JS. */
#view-moves.firm-mode .mv-ind-only { display: none !important; }
#view-moves:not(.firm-mode) .mv-firm-only { display: none !important; }
/* Single-select dropdowns (network mode, time range), styled to match the
   header language selector. The mode <select> reflects the server-set mode on
   deep links because setNetMode syncs its value before first paint. */
.net-select {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  background-color: var(--surface); border: 1px solid var(--border); color: var(--text2);
  border-radius: 20px; padding: 8px 34px 8px 15px; font: inherit; font-size: 0.8rem;
  font-weight: 500; cursor: pointer; flex-shrink: 0; transition: all 0.2s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7' viewBox='0 0 10 7' fill='none' stroke='%238B8580' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5 5 5.5 9 1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
}
.net-select:hover { border-color: var(--border2); color: var(--text); }
.net-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(196,149,106,0.15); }
/* In the search toolbars the status/role selects sit beside the .dropdown-btn
   controls (34px tall). .net-select's `font: inherit` pulls the body's taller
   line-height, and <select> adds ~1px of intrinsic height, so pin it to match
   exactly. (Mobile's min-height:44px still wins for touch targets.) */
.toolbar .net-select { height: 34px; line-height: normal; }
#flow-chips { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 0 0; font-size: 0.78rem; color: var(--text2); }
.flow-chip { display: inline-flex; align-items: baseline; gap: 6px; padding: 5px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); white-space: nowrap; }
#flow-chips .flow-chip strong { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 700; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
#network-canvas.flow-list-mode { height: auto; min-height: 0; }
/* No SVG in list layout: the PNG and fit-view buttons have nothing to act on.
   !important because both buttons carry inline display:flex; :has is
   progressive - unsupported browsers just keep the buttons, and the shot
   button then shows its "load a talent flow first" message. */
#view-network:has(#network-canvas.flow-list-mode) #net-shot-btn,
#view-network:has(#network-canvas.flow-list-mode) #net-fit-btn { display: none !important; }
.flow-ledger { padding: 16px 18px; }
.flow-ledger h3 { font-size: 0.85rem; margin: 14px 0 6px; color: var(--text); }
.flow-ledger h3:first-child { margin-top: 0; }
.flow-lrow { display: flex; align-items: center; gap: 10px; padding: 4px 6px; font-size: 0.82rem; cursor: pointer; border-radius: 4px; }
.flow-lrow:hover { background: var(--surface2); }
.flow-lrow.flow-lother { cursor: default; }
.flow-lname { flex: 0 1 44%; min-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.flow-lbar-wrap { flex: 1 1 auto; min-width: 40px; }
.flow-lbar { height: 10px; border-radius: 2px; min-width: 2px; }
.flow-lbar.sis { background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.55) 0 2px, transparent 2px 6px); }
.flow-lcount { flex: 0 0 auto; font-variant-numeric: tabular-nums; font-weight: 600; min-width: 34px; text-align: right; }
.net-legend-hatch { width: 14px; height: 10px; border-radius: 2px; flex-shrink: 0; background-color: #5B8EC7; background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.6) 0 1.5px, transparent 1.5px 5px); }
.net-legend-item.flow-static { cursor: default; }
.net-legend-item.flow-static:hover { opacity: 1; }
