:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --border: #2d3f56;
  --text: #e8eef5;
  --muted: #8fa3bc;
  --accent: #3d9a6a;
  --accent-dim: #2d7350;
  --women: #c45c8a;
  --men: #4a8fd4;
  --radius: 10px;
  --font: "DM Sans", system-ui, sans-serif;
  --sticky-select-width: 2.25rem;
  --sticky-name-width: 11rem;
  --header-height: 5.25rem;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
}

header {
  flex-shrink: 0;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #152030 0%, var(--bg) 100%);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.header-copy {
  min-width: 0;
}

header h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

header p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.header-login {
  position: relative;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.45rem;
}

.header-account-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pro-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  padding: 0.24rem 0.55rem;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffd34d, #f5a623);
  color: #231a04;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 0 0 1px rgba(245, 166, 35, 0.45), 0 2px 8px rgba(245, 166, 35, 0.25);
}

.pro-badge[hidden] {
  display: none !important;
}

.account-email-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#site-plan {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}

#site-plan[hidden] {
  display: none !important;
}

#site-plan .text-button {
  font-size: 0.78rem;
}

.login-panel {
  position: fixed;
  top: 6.5rem;
  right: 1rem;
  width: min(18.5rem, calc(100vw - 2rem));
  max-height: calc(100vh - 7.5rem);
  overflow: auto;
  padding: 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  z-index: 40;
}

.login-panel .auth-submit {
  margin-top: 0.85rem;
}

.plan-status {
  margin: 0 0 0.7rem;
  color: var(--text);
  font-size: 0.95rem;
}

#site-plan {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

#site-plan[hidden] {
  display: none !important;
}

.provider-logins {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.provider-logins[hidden],
#site-login-form[hidden],
#site-register-form[hidden],
#site-forgot-form[hidden] {
  display: none !important;
}

.provider-logins .btn {
  width: 100%;
  padding: 0.45rem 0.7rem;
  font-size: 0.82rem;
}

.login-message:empty {
  display: none;
}

.login-message {
  margin: 0 0 0.65rem;
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.35;
}

.login-hint {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.35;
}

.login-switch {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0.65rem 0 0;
}

.text-button {
  padding: 0;
  border: none;
  background: none;
  color: var(--men);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}

#site-signed-in {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#site-signed-in[hidden] {
  display: none;
}

#site-signed-in .btn {
  width: 100%;
}

@media (max-width: 640px) {
  .header-top {
    flex-direction: column;
  }

  .login-panel {
    left: 1rem;
    right: auto;
  }
}

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  align-items: stretch;
}

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

aside {
  display: flex;
  flex-direction: column;
  padding: 1rem 1.25rem;
  border-right: 1px solid var(--border);
  background: var(--surface);
  overflow: visible;
}

.filters-collapse {
  margin: 0 0 0.85rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface2);
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.filters-collapse:hover {
  border-color: var(--men);
  color: var(--men);
}

.layout.filters-collapsed {
  grid-template-columns: 3rem 1fr;
}

.layout.filters-collapsed aside {
  padding: 0.65rem 0.35rem;
  overflow: hidden;
}

.layout.filters-collapsed aside > :not(.filters-collapse) {
  display: none !important;
}

.layout.filters-collapsed .filters-collapse {
  margin: 0;
  min-height: 8.5rem;
  padding: 0.75rem 0.2rem;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

@media (max-width: 900px) {
  .layout.filters-collapsed {
    grid-template-columns: 1fr;
  }

  .layout.filters-collapsed aside {
    padding: 0.65rem 1rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .layout.filters-collapsed .filters-collapse {
    width: 100%;
    min-height: 0;
    writing-mode: horizontal-tb;
    transform: none;
  }
}

main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 1rem 1.25rem;
}

@media (max-width: 900px) {
  main {
    max-height: none !important;
    overflow: visible;
  }

  .table-wrap {
    min-height: 280px;
    max-height: min(70vh, 640px);
  }
}

.gender-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.gender-tab {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.gender-tab[data-gender="m"].active {
  border-color: var(--men);
  color: var(--men);
  background: rgba(74, 143, 212, 0.12);
}

.gender-tab[data-gender="f"].active {
  border-color: var(--women);
  color: var(--women);
  background: rgba(196, 92, 138, 0.12);
}

.gender-tab .count {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  margin-top: 0.2rem;
  opacity: 0.85;
}

.filter-group {
  margin-bottom: 1rem;
}

.filter-group label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

input[type="search"],
input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

select[multiple] {
  min-height: 100px;
}

select.filter-select-list-all[multiple] {
  min-height: 0;
  overflow: visible;
}

.school-filter-box {
  --school-list-rows: 8;
  display: flex;
  align-items: stretch;
  min-height: calc(1.35rem * var(--school-list-rows) + 0.75rem);
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  overflow: hidden;
}

.school-filter-box .school-select-scroll {
  flex: 1;
  min-width: 0;
  min-height: 0;
  border: none;
  border-radius: 0;
  background: transparent;
}

.school-alpha-rail {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex-shrink: 0;
  align-self: stretch;
  width: 1.35rem;
  padding: 0.15rem 0.1rem;
  border-left: 1px solid var(--border);
  background: var(--surface2);
  overflow: hidden;
}

.school-alpha-letter {
  padding: 0;
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.58rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}

.school-alpha-letter:hover:not(:disabled) {
  color: var(--men);
}

.school-alpha-letter:disabled {
  opacity: 0.22;
  cursor: default;
}

.distance-filter-row {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}

.distance-origin-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.distance-origin-wrap input {
  width: 100%;
  border: none;
  border-radius: 6px 0 0 6px;
  background: transparent;
}

.distance-miles-wrap {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--surface2);
  border-radius: 0 6px 6px 0;
}

.distance-miles-wrap input {
  width: 3.25rem;
  border: none;
  border-radius: 0;
  background: transparent;
  text-align: right;
  padding: 0.5rem 0.25rem 0.5rem 0.5rem;
  -moz-appearance: textfield;
}

.distance-miles-wrap input::-webkit-outer-spin-button,
.distance-miles-wrap input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.distance-miles-suffix {
  font-size: 0.75rem;
  color: var(--muted);
  padding: 0 0.55rem 0 0.1rem;
  user-select: none;
}

.filter-suggestions {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.2rem);
  z-index: 30;
  max-height: 12rem;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.distance-filter-group .filter-suggestions {
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  margin-top: 0.25rem;
  max-height: 10rem;
}

.filter-suggestion-item {
  display: block;
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
}

.filter-suggestion-item:last-child {
  border-bottom: none;
}

.filter-suggestion-item:hover {
  background: rgba(74, 143, 212, 0.12);
  color: var(--men);
}

.view-toggle {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.view-toggle button {
  flex: 1;
  padding: 0.45rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface2);
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.view-toggle button.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(61, 154, 106, 0.15);
}

.portal-toggle {
  width: 100%;
  margin-bottom: 1rem;
  padding: 0.65rem 0.75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--muted);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.portal-toggle.active {
  border-color: #c9a227;
  color: #e8c547;
  background: rgba(201, 162, 39, 0.12);
}

.portal-toggle:disabled {
  opacity: 0.65;
  cursor: wait;
}

.portal-toggle-label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
}

.portal-toggle-count {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  margin-top: 0.2rem;
  opacity: 0.9;
}

.portal-reload {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.portal-reload:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.portal-reload:disabled {
  opacity: 0.6;
  cursor: wait;
}

.portal-reload-progress {
  margin-top: 0.45rem;
}

.portal-reload-progress-track {
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.portal-reload-progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.25s ease;
}

.portal-reload-progress-label {
  margin: 0.3rem 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
}

.portal-reload-hint {
  margin: 0.35rem 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.signed-in-as {
  font-size: 0.8rem;
  color: var(--muted);
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  padding: 1.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.auth-card h1 {
  margin: 0;
  font-size: 1.25rem;
}

.auth-sub {
  margin: 0.5rem 0 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-form label {
  display: block;
  margin: 0.75rem 0 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.auth-form input {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.auth-submit {
  width: 100%;
  margin-top: 1.25rem;
}

.auth-error {
  margin: 0.75rem 0 0;
  color: #f08080;
  font-size: 0.85rem;
}

.portal-connect-block {
  margin-top: 0.5rem;
  margin-bottom: 0.75rem;
}

.portal-connect {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.portal-connect:hover:not(:disabled) {
  border-color: var(--men);
  color: var(--men);
  background: rgba(74, 143, 212, 0.1);
}

.portal-connect:disabled {
  opacity: 0.65;
  cursor: wait;
}

.portal-connect-state {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
}

.portal-connect-state.is-connected {
  color: var(--accent);
}

.portal-connect-state.is-disconnected {
  color: #e07070;
}

.portal-connect-state.is-signing-in {
  color: var(--men);
}

.portal-connect-state.is-expired {
  color: #e0b060;
}

.portal-connect-hint {
  margin: 0.35rem 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
  text-align: center;
}

.portal-connect-hint.err {
  color: #f08080;
}

.prompt-search-group {
  margin-bottom: 1rem;
}

.prompt-search-row {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  overflow: hidden;
}

.prompt-search-row input {
  flex: 1;
  min-width: 0;
  border: none;
  border-radius: 0;
  background: transparent;
}

.prompt-voice-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  border: none;
  border-left: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}

.prompt-voice-btn:hover {
  color: var(--text);
  background: var(--border);
}

.prompt-voice-btn.is-listening {
  color: #e07070;
  background: rgba(224, 112, 112, 0.12);
}

.prompt-apply-btn {
  width: 100%;
  margin-top: 0.45rem;
  font-size: 0.82rem;
  padding: 0.45rem 0.65rem;
}

#prompt-apply-hint {
  margin-top: 0.35rem;
}

.filter-hint.err {
  color: #e07070;
}

.portal-location-note {
  margin: 0.45rem 0 0;
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--muted);
}

.portal-location-note--modal {
  margin-top: 0.85rem;
  margin-bottom: 0;
}

.portal-cloud-note {
  margin-top: 0.45rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid rgba(212, 168, 74, 0.45);
  border-radius: 6px;
  background: rgba(212, 168, 74, 0.1);
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--text);
}

.portal-cloud-note strong {
  display: block;
  color: #e0b86a;
  font-size: 0.78rem;
  margin-bottom: 0.2rem;
}

.portal-cloud-note p {
  margin: 0;
  color: var(--muted);
}

.portal-cloud-note--modal {
  margin-top: 0.85rem;
  margin-bottom: 0;
}

.portal-local-banner {
  margin-top: 0.45rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--men);
  border-radius: 6px;
  background: rgba(74, 143, 212, 0.12);
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--text);
}

.portal-local-banner strong {
  display: block;
  color: var(--men);
  font-size: 0.78rem;
  margin-bottom: 0.2rem;
}

.portal-local-banner p {
  margin: 0;
  color: var(--muted);
}

.portal-connect-finish {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.55rem 0.75rem;
  border: 2px solid var(--men);
  border-radius: var(--radius);
  background: rgba(74, 143, 212, 0.12);
  color: var(--men);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}

.portal-connect-finish:hover:not(:disabled) {
  background: rgba(74, 143, 212, 0.22);
}

.portal-connect-finish:disabled {
  opacity: 0.65;
  cursor: wait;
}

.portal-connect-cancel {
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, color 0.15s;
}

.portal-connect-cancel:hover:not(:disabled) {
  border-color: #e07070;
  color: #e07070;
}

.portal-signin-fallback {
  margin-top: 0.5rem;
  padding: 0.55rem 0.65rem;
  border: 1px dashed var(--men);
  border-radius: 6px;
  background: rgba(74, 143, 212, 0.08);
  text-align: center;
}

.portal-signin-fallback-note {
  margin: 0 0 0.45rem;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
}

.portal-signin-fallback-btn {
  display: inline-block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--men);
  border-radius: 6px;
  background: rgba(74, 143, 212, 0.18);
  color: var(--men);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  box-sizing: border-box;
}

.portal-signin-fallback-btn:hover {
  background: rgba(74, 143, 212, 0.28);
  color: #7eb8f0;
}

.portal-browser-modal-panel--instructions {
  width: min(480px, 100%);
  height: auto;
  max-height: min(88vh, 520px);
}

.portal-browser-modal-body {
  padding: 1rem 1.25rem 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.portal-browser-modal-lead {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text);
}

.portal-browser-open-full {
  margin: 0;
}

.portal-browser-finish-btn {
  margin: 0.5rem 0 0;
  width: 100%;
}

.portal-browser-stuck-hint .link-btn {
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  color: var(--men);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.portal-browser-mobile-note {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--muted);
}

.portal-browser-new-tab {
  display: inline-block;
  margin-left: 0.5rem;
  color: var(--men);
  font-weight: 600;
  text-decoration: none;
}

.portal-browser-new-tab:hover {
  text-decoration: underline;
}

.portal-browser-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.portal-browser-modal[hidden] {
  display: none;
}

.portal-browser-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
}

.portal-browser-modal-panel {
  position: relative;
  z-index: 1;
  width: min(1100px, 100%);
  height: min(88vh, 900px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}

.portal-browser-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: #fff;
}

.portal-browser-modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  padding-right: 3rem;
}

.portal-browser-modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.portal-browser-modal-header p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.portal-browser-modal-close {
  position: absolute;
  top: 0.65rem;
  right: 0.75rem;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
}

.portal-browser-modal-close:hover {
  color: var(--text);
}

.portal-session-paste {
  margin-top: 0.65rem;
  font-size: 0.8rem;
}

.portal-session-pin {
  margin-top: 0.65rem;
  font-size: 0.8rem;
  border: 1px solid var(--men);
  border-radius: var(--radius);
  padding: 0.35rem 0.5rem;
}

.portal-session-pin-note {
  margin: 0.5rem 0;
  color: var(--muted);
  line-height: 1.4;
}

.portal-session-pin textarea {
  width: 100%;
  margin: 0.35rem 0 0.5rem;
  font-family: ui-monospace, monospace;
  font-size: 0.65rem;
}

#portal-session-pin-copy {
  width: 100%;
}

.portal-session-pin summary {
  cursor: pointer;
  color: var(--men);
  font-weight: 600;
}

.portal-session-paste-note {
  margin: 0.5rem 0;
  color: var(--muted);
  line-height: 1.4;
}

.portal-session-paste textarea {
  width: 100%;
  margin: 0.35rem 0 0.5rem;
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
}

#portal-session-save {
  width: 100%;
}

.portal-session-paste summary {
  cursor: pointer;
  color: var(--muted);
}

.portal-session-paste textarea {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.45rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: 0.7rem monospace;
  resize: vertical;
}

.country-link,
.portal-email,
.portal-status-link {
  white-space: nowrap;
}

.portal-status-link,
.portal-email {
  text-decoration: none;
}

.portal-email {
  color: var(--accent);
}

.portal-status-link:hover,
.portal-email:hover {
  text-decoration: underline;
}

.portal-status {
  font-size: 0.85rem;
  font-weight: 500;
}

.portal-status-active {
  color: #5cb87a;
}

.portal-status-signed {
  color: #e07070;
}

.portal-status-matriculated {
  color: #6ba3d4;
}

.portal-status-withdrawn {
  color: #9aa8b8;
}

.portal-status-other {
  color: #d4a843;
}

.portal-status-link.portal-status-active:hover {
  color: #72cc8a;
}

.portal-status-link.portal-status-signed:hover {
  color: #f08888;
}

.portal-status-link.portal-status-matriculated:hover {
  color: #85b8e8;
}

.portal-status-link.portal-status-withdrawn:hover {
  color: #b0bdcc;
}

.portal-status-link.portal-status-other:hover {
  color: #e8bc55;
}

.country-unknown {
  color: var(--muted);
}

.btn-link {
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.btn-link:disabled {
  opacity: 0.5;
  cursor: wait;
}

.badge-portal {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(201, 162, 39, 0.25);
  color: #e8c547;
  vertical-align: middle;
}

.portal-status-cell .badge-portal {
  display: block;
  margin: 0 0 0.3rem;
}

.portal-email-missing,
.portal-email-pending {
  color: var(--muted);
  font-size: 0.85em;
}

.toolbar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.75rem;
  min-height: 2.5rem;
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}

.toolbar .result-count {
  color: var(--muted);
  font-size: 0.9rem;
  flex: 1;
  min-height: 1.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pr-filter-row th {
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  vertical-align: bottom;
  padding: 0.35rem 0.25rem;
}

.pr-filter-lead {
  text-align: left;
  padding-left: 0.75rem !important;
  vertical-align: middle;
  white-space: nowrap;
}

.pr-filter-inline-label {
  position: relative;
  z-index: 1;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.01em;
}

.pr-filter-row--max th {
  padding-top: 0;
}

.pr-filter-cell {
  padding: 0.2rem 0.25rem !important;
  vertical-align: top;
}

.pr-filter-row--min .pr-filter-cell {
  padding-bottom: 0.1rem !important;
}

.pr-filter-row--max .pr-filter-cell {
  padding-top: 0.1rem !important;
}

.pr-filter-input {
  width: 100%;
  min-width: 2.5rem;
  max-width: 3.5rem;
  padding: 0.25rem 0.2rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.68rem;
  text-align: center;
  box-sizing: border-box;
}

.pr-filter-input:focus {
  outline: none;
  border-color: var(--men);
}

.pr-filter-input::placeholder {
  color: rgba(255, 255, 255, 0.28);
  font-size: 0.72rem;
}

.pr-filter-spacer {
  background: var(--surface2);
}

.export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn {
  padding: 0.55rem 1rem;
  border: none;
  border-radius: 6px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-dim);
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

#export-xlsx-btn[hidden],
#export-csv-btn[hidden],
#emailer-link[hidden],
#get-portal-emails-btn[hidden] {
  display: none !important;
}

a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-sizing: border-box;
}

a.btn:hover {
  filter: brightness(1.08);
}

.table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  --pr-filter-min-h: 2rem;
  --pr-filter-max-h: 2rem;
  --pr-filter-header-top: 4rem;
}

table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th,
td {
  padding: 0.55rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  background: var(--surface2);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  z-index: 1;
}

thead > tr:not(.pr-filter-row) th {
  position: sticky;
  top: var(--pr-filter-header-top);
  z-index: 5;
}

.pr-filter-row--min th {
  position: sticky;
  top: 0;
  z-index: 6;
}

.pr-filter-row--max th {
  position: sticky;
  top: var(--pr-filter-min-h);
  z-index: 6;
}

.pr-filter-row th.sticky-col {
  z-index: 12;
  background: #243044;
}

.pr-filter-row th.sticky-col-name {
  left: var(--sticky-select-width);
  z-index: 13;
  background: #243044;
  box-shadow: 10px 0 0 #243044;
}

thead > tr:not(.pr-filter-row) th.sticky-col {
  z-index: 9;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

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

th.sort-active {
  color: var(--men);
}

th.select-col,
td.select-col {
  width: var(--sticky-select-width);
  text-align: center;
  vertical-align: middle;
  padding-left: 0.35rem;
  padding-right: 0.35rem;
}

.sticky-col {
  position: sticky;
  z-index: 2;
}

tbody td.sticky-col {
  background: var(--bg);
}

tr:hover td.sticky-col {
  background: #141c28;
}

th.sticky-col {
  z-index: 3;
  background: var(--surface2);
}

.pr-filter-row th.sticky-col {
  z-index: 12;
  background: #243044;
}

.pr-filter-row th.sticky-col.sticky-col-name {
  z-index: 13;
  background: #243044;
  box-shadow: 10px 0 0 #243044;
}

.sticky-col-select {
  left: 0;
  min-width: var(--sticky-select-width);
  max-width: var(--sticky-select-width);
}

.sticky-col-name {
  left: var(--sticky-select-width);
  min-width: var(--sticky-name-width);
  max-width: 16rem;
  box-shadow: 4px 0 10px rgba(0, 0, 0, 0.4);
}

th.sticky-col-name {
  white-space: nowrap;
}

td.sticky-col-name strong {
  display: inline;
}

th.select-col input,
td.select-col input {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  accent-color: var(--men);
}

td.pr-col,
th.pr-col {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

tbody td.pr-col {
  vertical-align: middle;
}

td.multi-value-cell {
  line-height: 1.35;
  font-size: 0.82rem;
  word-break: break-word;
}

td.multi-value-cell .school-line {
  display: block;
}

tbody td.select-col,
tbody td.pr-col,
tbody td.col-align-middle {
  vertical-align: middle;
}

.filter-hint {
  margin: 0.35rem 0 0;
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.35;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

a.profile-link {
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

a.profile-link:hover {
  text-decoration: underline;
}

.marks-cell {
  max-width: 420px;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

.empty {
  padding: 3rem;
  text-align: center;
  color: var(--muted);
}

.loading,
.loading[style] {
  display: none !important;
  height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

tr.portal-blur td {
  filter: blur(6px);
  user-select: none;
}

.event-col-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}

.event-col-toolbar-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.event-col-toolbar-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.event-cat-btn {
  padding: 0.28rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface2);
  color: var(--muted);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
}

.event-cat-btn:hover {
  color: var(--text);
  border-color: var(--men);
}

.event-cat-btn.active {
  background: rgba(74, 143, 212, 0.18);
  border-color: var(--men);
  color: var(--men);
}

.event-col-visible-count {
  font-size: 0.75rem;
  color: var(--muted);
  margin-left: auto;
}

.column-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
  margin: 0.35rem 0 0.5rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
}

.col-restore-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.col-restore-btn {
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-size: 0.72rem;
  cursor: pointer;
}

.col-restore-btn:hover {
  border-color: var(--women);
  color: var(--women);
  background: rgba(196, 92, 138, 0.1);
}

th.col-head-cell {
  padding-left: 0.35rem;
  padding-right: 0.35rem;
}

.pr-col-head-inner {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  justify-content: flex-end;
  width: 100%;
}

.pr-col-hide {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  padding: 0;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.55;
}

.pr-col-hide:hover {
  opacity: 1;
  color: var(--women);
  background: rgba(196, 92, 138, 0.15);
}

.pr-col-label {
  white-space: nowrap;
}

th.pr-col-head-cell {
  padding-left: 0.35rem;
  padding-right: 0.35rem;
}

.clear-filters {
  width: 100%;
  margin: 0 0 0.85rem;
  padding: 0.45rem;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.preview-unlock {
  margin: 0 0 0.75rem;
  padding: 0.7rem 0.85rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}

.preview-unlock p {
  margin: 0.15rem 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.preview-unlock #preview-count {
  color: var(--text);
  font-weight: 600;
}

.preview-placeholders {
  display: flex;
  gap: 0.75rem;
  margin: 0.35rem 0 0.55rem;
  overflow: hidden;
  user-select: none;
}

.preview-placeholders span {
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
  filter: blur(2px);
  opacity: 0.7;
}

.results-pagination { display: flex; align-items: center; gap: 1rem; min-height: 2.75rem; margin: 0 0 0.5rem; }
.results-pagination[hidden] { display: flex !important; visibility: hidden; pointer-events: none; }
.results-pagination button {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f4f7fb;
  color: #142033;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.results-pagination button:disabled {
  opacity: 1;
  background: #d5deea;
  color: #243044;
  cursor: default;
}

/* Sticky table header fix: .layout had no height constraint, so .table-wrap
   grew to the full table height and never scrolled; the page scrolled
   instead and the sticky thead rules (relative to .table-wrap) never
   engaged. Constrain the app to the viewport so .table-wrap is the real
   scroll container and the TOP MARK / BOTTOM MARK / column header rows pin
   while the athlete rows scroll under them. */
body {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.layout {
  flex: 1 1 auto;
  min-height: 0;
}

.layout > aside {
  overflow-y: auto;
  min-height: 0;
}

/* Pin the two filter rows at exact heights so the stacked sticky offsets
   (0, --pr-filter-min-h, --pr-filter-header-top) line up with no gap and no
   body rows showing through between them. */
.pr-filter-row--min th {
  height: var(--pr-filter-min-h);
}

.pr-filter-row--max th {
  height: var(--pr-filter-max-h);
}

/* Views without PR filter rows (All marks) pin their single header row at
   the very top; the athletes view offsets it below the two filter rows. */
thead > tr:not(.pr-filter-row) th {
  top: 0;
}

table.has-pr-filters thead > tr:not(.pr-filter-row) th {
  top: var(--pr-filter-header-top);
}

@media (max-width: 900px) {
  /* Small screens keep the previous page-scroll layout; .table-wrap keeps
     its own max-height cap there and scrolls internally as before. */
  body {
    height: auto;
    display: block;
  }

  .layout {
    flex: none;
    min-height: auto;
  }

  .layout > aside {
    overflow: visible;
  }
}
