  *,
  *::before,
  *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }

  body {
    font-family:
      system-ui,
      -apple-system,
      "Segoe UI",
      Roboto,
      sans-serif;
    background: #f0f2f5;
    color: #212121;
    font-size: 14px;
    line-height: 1.5;
  }

  a {
    color: #1976d2;
  }

  /* App bar */
  .app-bar {
    background: #1a3a5c;
    color: #fff;
    height: 56px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  }
  .app-bar-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 16px;
  }
  .app-bar-title {
    font-size: 20px;
    font-weight: 500;
    letter-spacing: 0.01em;
    background: none;
    border: none;
    color: inherit;
    padding: 0;
    cursor: pointer;
  }

  /* Main layout */
  .main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px 16px 32px;
  }

  /* Cards */
  .card {
    background: #fff;
    border-radius: 4px;
    box-shadow:
      0 1px 3px rgba(0, 0, 0, 0.12),
      0 1px 2px rgba(0, 0, 0, 0.08);
    margin-bottom: 16px;
    overflow: clip;
  }
  .card-section {
    padding: 16px;
  }

  /* Tabs */
  .tabs {
    display: flex;
    border-bottom: 1px solid #e0e0e0;
  }
  .tab {
    padding: 14px 24px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #757575;
    border-bottom: 3px solid transparent;
    transition:
      color 0.15s,
      border-color 0.15s,
      background 0.15s;
    user-select: none;
  }
  .tab:hover {
    color: #1a3a5c;
    background: #f8f9fa;
  }
  .tab.active {
    color: #1a3a5c;
    border-bottom-color: #1a3a5c;
  }

  /* Search */
  .search-wrapper {
    position: relative;
    flex: 1;
    max-width: 480px;
  }
  .search-input {
    width: 100%;
    padding: 10px 14px 10px 42px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition:
      border-color 0.2s,
      box-shadow 0.2s,
      background 0.2s,
      color 0.2s;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
  }
  .search-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
  }
  .search-input:focus {
    background: #fff;
    color: #212121;
    border-color: #fff;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2);
  }
  .search-input:focus::placeholder {
    color: #9e9e9e;
  }
  .search-icon {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.5);
    font-size: 16px;
    pointer-events: none;
  }
  .search-wrapper:focus-within .search-icon {
    color: #9e9e9e;
  }

  #auth-controls {
    margin-left: auto;
    display: flex;
    align-items: center;
  }

  .logout-button {
    display: none;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.9);
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    transition:
      background 0.15s,
      border-color 0.15s,
      color 0.15s;
  }

  .logout-button:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.42);
    color: #fff;
  }

  body.is-authenticated .logout-button {
    display: inline-flex;
  }

  /* Filter chips */
  .filter-groups {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid #f0f0f0;
  }
  .filter-sep {
    width: 1px;
    height: 22px;
    background: #e0e0e0;
    flex-shrink: 0;
    margin: 0 2px;
  }
  .chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 16px;
    border: 1px solid #bdbdbd;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s;
    background: #fff;
    color: #424242;
    font-family: inherit;
    line-height: 1.4;
    white-space: nowrap;
  }
  .chip:hover {
    background: #f5f5f5;
    border-color: #9e9e9e;
  }
  .chip.active {
    background: #1a3a5c;
    border-color: #1a3a5c;
    color: #fff;
  }

  /* Dropdown filter chips */
  .chip-dropdown {
    position: relative;
    display: inline-flex;
  }
  .chip-has-menu {
    gap: 4px;
  }
  .chip-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 20;
    min-width: 100%;
    max-height: 60dvh;
    overflow-y: auto;
  }
  .chip-dropdown-menu.open {
    display: block;
  }
  .chip-dropdown-item {
    display: block;
    width: 100%;
    padding: 8px 16px;
    border: none;
    background: none;
    font-size: 13px;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
  }
  .chip-dropdown-item:hover {
    background: #f5f5f5;
  }
  .chip-dropdown-item.active {
    background: #e8f0fe;
    color: #1a3a5c;
    font-weight: 500;
  }
  .chip-clear {
    font-size: 11px;
    margin-left: 2px;
    margin-right: -4px;
    opacity: 0.7;
    display: inline-flex;
    align-items: center;
    align-self: stretch;
    padding: 0 4px 0 6px;
  }
  .chip-clear:hover {
    opacity: 1;
  }

  /* Table meta */
  .table-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    font-size: 13px;
    color: #757575;
    border-bottom: 1px solid #f0f0f0;
    flex-wrap: wrap;
    gap: 4px;
  }
  .table-meta strong {
    color: #424242;
  }

  /* overflow-x: auto enables horizontal scrolling on narrow screens.
    position: sticky on thead th still works within a scrollable container. */
  .table-wrapper {
    overflow-x: auto;
  }
  table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
  }
  thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #fafafa;
    box-shadow: inset 0 -2px 0 #e0e0e0;
    padding: 9px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: #424242;
    white-space: nowrap;
    user-select: none;
  }
  thead th[data-sort] {
    cursor: pointer;
  }
  thead th[data-sort]:hover {
    background: #f0f0f0;
  }
  thead th.sort-active {
    color: #1a3a5c;
  }
  .sort-icon {
    display: inline-block;
    margin-left: 3px;
    font-size: 11px;
    color: #9e9e9e;
  }
  thead th.sort-active .sort-icon {
    color: #1a3a5c;
  }
  td {
    padding: 9px 12px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
    font-size: 13px;
  }
  tbody tr {
    cursor: pointer;
    transition: background 0.1s;
  }
  tbody tr:hover {
    background: #e8f0fe !important;
  }
  tbody tr.selected {
    background: #d2e3fc !important;
    outline: 2px solid #1a73e8;
    outline-offset: -2px;
  }
  tbody tr:nth-child(even) {
    background: #fafafa;
  }
  tbody tr:last-child td {
    border-bottom: none;
  }

  /* Status badges */
  .status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
  }
  .status-badge.orange {
    color: #ff9800;
  }
  .status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    align-self: center;
  }
  .status-dot.green {
    background: #4caf50;
  }
  .status-dot.yellow {
    background: #ffc107;
  }
  .status-dot.orange {
    background: #ff9800;
  }
  .status-dot.gray {
    background: #bdbdbd;
  }
  .status-dot.blue {
    background: #1976d2;
  }
  .tenured-label {
    font-size: 10px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }

  table.table-fixed {
    table-layout: fixed;
  }

  /* Cross-tab separator */
  .cross-tab-header {
    padding: 10px 16px 6px;
    font-size: 13px;
    font-weight: 500;
    color: #757575;
    border-top: 2px solid #e0e0e0;
    background: #fafafa;
  }
  .cross-tab-searching {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 13px;
    color: #9e9e9e;
    border-top: 2px solid #e0e0e0;
    background: #fafafa;
  }
  .spinner-inline {
    display: inline-block;
    flex-shrink: 0;
    width: 12px;
    height: 12px;
    border: 2px solid #e0e0e0;
    border-top-color: #9e9e9e;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
  }

  /* Loading / empty */
  .loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 16px;
    color: #9e9e9e;
    gap: 16px;
  }
  .spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e0e0e0;
    border-top-color: #1a3a5c;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
  }
  @keyframes spin {
    to {
      transform: rotate(360deg);
    }
  }
  .error-msg {
    padding: 24px 16px;
    color: #c62828;
    text-align: center;
    font-size: 14px;
  }
  .google-signin-container {
    position: relative;
    display: inline-block;
    min-height: 40px;
    min-width: 240px;
  }
  .google-signin-container #google-signin-button {
    opacity: 0;
    transition: opacity 0.12s ease-out;
  }
  .google-signin-placeholder {
    position: absolute;
    inset: 0;
    border: 1px solid #dadce0;
    border-radius: 4px;
    background: linear-gradient(90deg, #f1f3f4 0%, #fff 45%, #f1f3f4 100%);
    background-size: 200% 100%;
    animation: google-signin-shimmer 1.1s linear infinite;
  }
  .google-signin-container.is-ready #google-signin-button {
    opacity: 1;
  }
  .google-signin-container.is-ready .google-signin-placeholder {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease-out;
  }
  @keyframes google-signin-shimmer {
    to {
      background-position: -200% 0;
    }
  }
  .empty-state {
    text-align: center;
    padding: 48px 16px;
    color: #9e9e9e;
  }
  .empty-state h3 {
    font-size: 16px;
    color: #757575;
    margin-bottom: 6px;
  }

  /* Detail view */
  .detail-back {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #1976d2;
    cursor: pointer;
    font-size: 14px;
    background: none;
    border: none;
    padding: 0 0 12px;
    font-family: inherit;
  }
  .detail-back:hover {
    text-decoration: underline;
  }
  .detail-name {
    font-size: 26px;
    font-weight: 500;
    color: #1a3a5c;
    margin-bottom: 6px;
  }
  .detail-badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 3px;
    margin-left: 10px;
    vertical-align: middle;
  }
  .detail-badge-yellow {
    background: #fff3e0;
    color: #e65100;
  }
  .detail-badge-red {
    background: #fbe9e7;
    color: #c62828;
  }
  .detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(400px, 1fr));
    gap: 16px;
    margin-top: 16px;
  }
  .detail-card {
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    padding: 16px;
    min-width: 0;
  }
  /* Full-width card spanning all grid columns */
  .detail-card-full {
    grid-column: 1 / -1;
  }
  .detail-card-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #757575;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0f0f0;
  }
  .detail-row {
    display: flex;
    gap: 8px;
    padding: 4px 0;
  }
  .detail-label {
    flex: 0 0 148px;
    font-size: 12px;
    color: #9e9e9e;
    padding-top: 1px;
  }
  .detail-value {
    flex: 1;
    font-size: 13px;
    color: #212121;
    word-break: break-word;
  }
  span.empty {
    color: #bdbdbd;
    font-style: italic;
  }
  .detail-muted {
    color: #9e9e9e;
    font-size: 12px;
  }

  /* Y/N/U and boolean field values */
  .val-yes {
    color: #4caf50;
    font-size: 13px;
  }
  table:not(.usah-reg-table) .val-yes {
    font-weight: 700;
  }
  .val-no {
    color: #9e9e9e;
    font-size: 13px;
  }

  /* Arbiter action links */
  .arbiter-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #f0f0f0;
  }
  .arbiter-link {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border: 1px solid #1976d2;
    border-radius: 3px;
    color: #1976d2;
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    transition: background 0.15s;
  }
  .arbiter-link:hover {
    background: #e3f2fd;
  }

  /* USA Hockey Registration table */
  .table-wrapper-detail {
    overflow-x: auto;
  }
  .usah-reg-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
  }
  .usah-reg-table th,
  .usah-reg-table td {
    padding: 6px 12px;
    border-bottom: 1px solid #f0f0f0;
    text-align: left;
    white-space: nowrap;
    min-width: 150px;
  }
  /* Override the global sticky thead th for this table */
  .usah-reg-table thead th {
    position: static;
    z-index: auto;
    font-weight: 600;
    font-size: 13px;
    color: #424242;
    background: #fafafa;
    cursor: default;
    user-select: text;
  }
  .usah-reg-table tbody tr {
    cursor: default;
  }
  .usah-reg-table tbody tr:hover {
    background: transparent !important;
  }
  .usah-reg-table tbody tr:last-child td,
  .usah-reg-table tbody tr:last-child th {
    border-bottom: none;
  }
  .usah-row-label {
    font-size: 12px;
    color: #9e9e9e;
    font-weight: 400;
  }
  .usah-note {
    font-size: 12px;
    color: #666;
    margin-top: 10px;
    padding: 0 12px 12px;
  }

  /* USA Hockey merged card — 2-column field grid above the table */
  .usah-fields {
    display: grid;
    grid-template-rows: repeat(3, auto);
    grid-auto-flow: column;
    gap: 0 24px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
  }

  /* Copy-to-clipboard button */
  .copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: none;
    background: none;
    cursor: pointer;
    color: #bdbdbd;
    font-size: 13px;
    padding: 0;
    margin-left: 3px;
    border-radius: 3px;
    flex-shrink: 0;
    align-self: flex-start;
    transition:
      color 0.15s,
      background 0.15s;
    font-family: inherit;
    line-height: 1;
  }
  .copy-btn:hover {
    color: #757575;
    background: #f0f0f0;
  }
  .copy-btn.copied {
    color: #4caf50;
  }

  /* Mailing lists card */
  .ml-email {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0 10px;
    margin-bottom: 6px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
    color: #212121;
  }
  /* Orange dot indicator for overridden email address */
  .override-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff9800;
    flex-shrink: 0;
  }
  .ml-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    font-size: 13px;
  }
  .ml-check {
    font-size: 15px;
  }
  .ml-check.yes {
    color: #4caf50;
  }
  .ml-check.no {
    color: #e0e0e0;
  }

  /* Async card states */
  .async-loading {
    color: #9e9e9e;
    font-style: italic;
    font-size: 13px;
  }
  .async-error {
    color: #c62828;
    font-size: 13px;
  }
  .async-empty {
    color: #9e9e9e;
    font-style: italic;
    font-size: 13px;
  }

  /* Async card tables */
  .async-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
  }
  .async-table thead th {
    position: static;
    z-index: auto;
    background: transparent;
    box-shadow: none;
    font-size: 12px;
    font-weight: 600;
    color: #757575;
    text-align: left;
    padding: 4px 12px 4px 0;
    border-bottom: 1px solid #f0f0f0;
    cursor: default;
    user-select: text;
  }
  .async-table td {
    padding: 5px 12px 5px 0;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
    color: #212121;
  }
  .async-table tbody tr {
    cursor: default;
  }
  .async-table tbody tr:hover {
    background: transparent !important;
  }
  .async-table tbody tr:last-child td {
    border-bottom: none;
  }

  /* Evaluation requests (pending, shown above completed evaluations) */
  .eval-requests {
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0f0f0;
  }
  .eval-request-item {
    font-size: 13px;
    color: #757575;
    padding: 3px 0;
  }

  /* Responsive */
  @media (max-width: 900px) {
    .app-bar-title {
      font-size: 17px;
    }
    /* .search-wrapper { max-width: 240px; } */
    .search-input {
      font-size: 13px;
      padding: 8px 12px 8px 36px;
    }
    .main-content {
      padding: 8px 8px 24px;
    }
    .detail-grid {
      grid-template-columns: 1fr;
    }
    .usah-fields {
      grid-auto-flow: row;
      grid-template-rows: unset;
    }
    .detail-label {
      flex: 0 0 120px;
    }
    thead th,
    td {
      padding: 8px;
    }
    .tab {
      padding: 12px 16px;
    }
  }

  @media (max-width: 600px) {
    /* Hide low-priority columns: USAH # (4th), Level (6th), NIHOA (7th), Status (9th) */
    table:not(.usah-reg-table):not(.async-table) thead th:nth-child(4),
    table:not(.usah-reg-table):not(.async-table) td:nth-child(4),
    table:not(.usah-reg-table):not(.async-table) thead th:nth-child(6),
    table:not(.usah-reg-table):not(.async-table) td:nth-child(6),
    table:not(.usah-reg-table):not(.async-table) thead th:nth-child(7),
    table:not(.usah-reg-table):not(.async-table) td:nth-child(7),
    table:not(.usah-reg-table):not(.async-table) thead th:nth-child(9),
    table:not(.usah-reg-table):not(.async-table) td:nth-child(9) {
      display: none;
    }

    .th-extra {
      display: none;
    }
    .detail-label {
      flex: 0 0 100px;
    }
    .detail-name {
      font-size: 20px;
    }
    .app-bar-title {
      font-size: 15px;
    }
    .app-bar-inner {
      padding: 0 12px;
      gap: 10px;
    }
    body.is-authenticated .logout-button {
      display: none;
    }
    .main-content {
      padding: 6px 6px 20px;
    }
    .tab {
      padding: 10px 12px;
      font-size: 13px;
    }

    .filter-groups {
      padding: 8px 12px;
    }
  }
