.tables-modal {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: clamp(1rem, 3vw, 2.5rem);
  border: 0;
  color: var(--color1);
  background: transparent;
  overflow: hidden;
}

.tables-modal[open] {
  display: grid;
  place-items: center;
}

.tables-modal::backdrop {
  background: rgba(9, 17, 34, 0.78);
}

.tables-modal__panel {
  width: min(100%, 1180px);
  max-height: min(88dvh, 900px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(30, 48, 84, 0.12);
  border-radius: var(--radius-lg);
  background: var(--color-soft-white);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.32);
}

.tables-modal__header {
  position: relative;
  padding: clamp(1.5rem, 3vw, 2.4rem)
    clamp(4.8rem, 7vw, 6rem)
    clamp(1.4rem, 2.5vw, 2rem)
    clamp(1.4rem, 3vw, 2.5rem);
  color: var(--color-white);
  background: var(--color1);
}

.tables-modal__eyebrow {
  margin-bottom: 0.35rem;
  color: var(--color-accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.tables-modal__title {
  font-family: var(--font-title);
  font-size: clamp(3rem, 6vw, 5rem);
  font-weight: 400;
  line-height: 0.9;
  letter-spacing: 0.015em;
  text-transform: uppercase;
}

.tables-modal__intro {
  max-width: 40rem;
  margin-top: 0.75rem;
  color: var(--color-text-muted);
  font-size: clamp(0.9rem, 1.2vw, 1rem);
}

.tables-modal__close {
  position: absolute;
  top: 1.3rem;
  right: 1.4rem;
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  color: var(--color-white);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition:
    transform 180ms ease,
    background-color 180ms ease,
    border-color 180ms ease;
}

.tables-modal__close svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.tables-modal__controls {
  display: grid;
  grid-template-columns: minmax(15rem, 0.8fr) minmax(0, 1.2fr);
  gap: clamp(1rem, 3vw, 2rem);
  align-items: end;
  padding: 1.25rem clamp(1.4rem, 3vw, 2.5rem);
  border-bottom: 1px solid rgba(30, 48, 84, 0.1);
  background: var(--color-white);
}

.tables-modal__field {
  display: grid;
  gap: 0.45rem;
}

.tables-modal__label {
  color: var(--color1);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.tables-modal__select-wrap {
  position: relative;
}

.tables-modal__select {
  width: 100%;
  min-height: 3.15rem;
  padding: 0.78rem 2.8rem 0.78rem 1rem;
  border: 1px solid rgba(30, 48, 84, 0.2);
  border-radius: 0.85rem;
  color: var(--color1);
  background: var(--color-soft-white);
  font: inherit;
  font-size: 0.94rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.tables-modal__select:disabled {
  cursor: wait;
  opacity: 0.65;
}

.tables-modal__current {
  display: grid;
  justify-items: end;
  gap: 0.18rem;
  text-align: right;
}

.tables-modal__current strong {
  color: var(--color1);
  font-size: 1rem;
  font-weight: 900;
}

.tables-modal__current span {
  color: rgba(30, 48, 84, 0.64);
  font-size: 0.82rem;
}

.tables-modal__body {
  min-height: 0;
  overflow: hidden;
  background: var(--color-white);
}

.tables-modal__status {
  min-height: 16rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem;
  color: rgba(30, 48, 84, 0.72);
  text-align: center;
  font-size: 0.95rem;
  font-weight: 700;
}

.tables-modal__status[data-state="loading"]::before {
  content: "";
  width: 2rem;
  height: 2rem;
  border: 3px solid rgba(30, 48, 84, 0.14);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: tablesSpinner 0.8s linear infinite;
}

.tables-modal__status[data-state="error"] {
  color: #8b2d2d;
}

.tables-modal__retry {
  min-height: 2.8rem;
  padding: 0.7rem 1.15rem;
  border-radius: 999px;
  color: var(--color1);
  background: var(--color-accent);
  font-weight: 900;
  cursor: pointer;
  box-shadow: var(--shadow-accent);
}

.tables-modal__table-wrap {
  width: 100%;
  height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.tables-modal__table {
  width: 100%;
  min-width: 52rem;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--color1);
  background: var(--color-white);
  font-size: 0.88rem;
}

.tables-modal__caption {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.tables-modal__table th,
.tables-modal__table td {
  padding: 0.9rem 1rem;
  border-right: 1px solid rgba(30, 48, 84, 0.08);
  border-bottom: 1px solid rgba(30, 48, 84, 0.08);
  text-align: center;
  white-space: nowrap;
}

.tables-modal__table thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  color: var(--color-white);
  background: var(--color1);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.tables-modal__table tbody tr:nth-child(even) td,
.tables-modal__table tbody tr:nth-child(even) th[scope="row"] {
  background: #f5f7fb;
}

.tables-modal__table tbody th[scope="row"] {
  position: static;
  z-index: auto;
  color: var(--color1);
  background: var(--color-white);
  font-weight: 800;
  text-transform: none;
  letter-spacing: normal;
}

.tables-modal__table td.is-numeric {
  font-variant-numeric: tabular-nums;
}

@media (hover: hover) and (pointer: fine) {
  .tables-modal__close:hover {
    transform: scale(1.04);
    border-color: rgba(255, 255, 255, 0.34);
    background: rgba(255, 255, 255, 0.15);
  }

  .tables-modal__select:hover {
    border-color: rgba(30, 48, 84, 0.42);
  }

  .tables-modal__retry:hover {
    transform: translateY(-1px);
  }

  .tables-modal__table tbody tr:hover td,
  .tables-modal__table tbody tr:hover th {
    background: rgba(241, 167, 5, 0.1);
  }
}

.tables-modal__close:active,
.tables-modal__retry:active {
  transform: scale(0.98);
}

.tables-modal__select:focus-visible {
  border-color: var(--color-accent);
  outline: 3px solid rgba(241, 167, 5, 0.28);
  outline-offset: 2px;
}

@keyframes tablesSpinner {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 760px) {
  .tables-modal {
    padding: 0;
  }

  .tables-modal[open] {
    place-items: stretch;
  }

  .tables-modal__panel {
    width: 100%;
    height: 100dvh;
    max-height: none;
    border: 0;
    border-radius: 0;
  }

  .tables-modal__header {
    padding:
      max(1.2rem, env(safe-area-inset-top))
      4.6rem
      1.2rem
      1rem;
  }

  .tables-modal__close {
    top: max(0.8rem, env(safe-area-inset-top));
    right: 0.85rem;
  }

  .tables-modal__title {
    font-size: clamp(3rem, 15vw, 4.2rem);
  }

  .tables-modal__intro {
    margin-top: 0.55rem;
    font-size: 0.88rem;
  }

  .tables-modal__controls {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 0.8rem;
    padding: 1rem;
  }

  .tables-modal__current {
    justify-items: start;
    text-align: left;
  }

  .tables-modal__table {
    min-width: 48rem;
    font-size: 0.82rem;
  }

  .tables-modal__table th,
  .tables-modal__table td {
    min-width: 5.5rem;
    padding: 0.78rem 0.8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tables-modal__close,
  .tables-modal__select,
  .tables-modal__retry {
    transition: none;
  }

  .tables-modal__status[data-state="loading"]::before {
    animation-duration: 1.4s;
  }
}

.tables-modal [hidden] {
  display: none !important;
}
