:root {
  --rd-content-max: 1680px;
  --rd-page-gap: 18px;
  --rd-surface: #101927;
  --rd-surface-subtle: #0d1622;
  --rd-line: #26364a;
  --rd-line-soft: #1d2a3a;
  --rd-focus: #8fb4f4;
}

.content-wrap > .rd-page {
  width: min(100%, var(--rd-content-max));
  margin-inline: auto;
}

.rd-page-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px 20px;
  margin-block: 0 var(--rd-page-gap);
  padding-block: 2px 14px;
  border-bottom: 1px solid var(--rd-line-soft);
}

.rd-page-context {
  grid-column: 1 / -1;
  color: var(--text3);
  font-size: 12px;
  line-height: 1.2;
}

.rd-page-heading h1,
.rd-page-heading h2 {
  margin: 0;
  color: var(--text);
  font-size: 22px;
  font-weight: 680;
  letter-spacing: -0.02em;
}

.rd-page-heading > p {
  max-width: 72ch;
  margin: 5px 0 0;
  color: var(--text3);
  font-size: 13px;
}

.rd-table-region {
  overflow: auto;
  border: 1px solid var(--rd-line);
  border-radius: 10px;
  background: var(--rd-surface-subtle);
}

.rd-data-table {
  width: 100%;
  margin: 0;
  border-collapse: separate;
  border-spacing: 0;
}

.rd-data-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #131f2e;
}

.rd-data-table th,
.rd-data-table td {
  border-bottom: 1px solid var(--rd-line-soft);
}

.rd-data-table tbody tr:last-child td {
  border-bottom: 0;
}

.rd-modal-overlay {
  padding: 20px;
  background: rgba(3, 7, 12, 0.76);
}

.rd-modal {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(760px, calc(100vw - 40px));
  max-height: calc(100dvh - 40px);
  padding: 0 !important;
  overflow: hidden;
  border: 1px solid var(--rd-line) !important;
  border-radius: 14px !important;
  background: var(--rd-surface) !important;
  box-shadow: 0 28px 72px rgba(0, 0, 0, 0.5) !important;
}

.modal-box-wide.rd-modal {
  width: min(1080px, calc(100vw - 40px));
}

.rd-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--rd-line-soft);
}

.rd-modal-header h3 {
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  color: var(--text);
  font-size: 19px;
  font-weight: 680;
  letter-spacing: -0.015em;
}

.rd-modal-close {
  width: 40px;
  height: 40px;
  color: transparent;
  background: transparent;
  border: 1px solid var(--rd-line);
  border-radius: 8px;
  cursor: pointer;
  position: relative;
}

.rd-modal-close::before,
.rd-modal-close::after {
  content: "";
  position: absolute;
  top: 19px;
  left: 11px;
  width: 16px;
  height: 1.5px;
  background: var(--text2);
}

.rd-modal-close::before { transform: rotate(45deg); }
.rd-modal-close::after { transform: rotate(-45deg); }

.rd-modal-close:hover { background: var(--bg3); }

.rd-modal-close:focus-visible {
  outline: 2px solid var(--rd-focus);
  outline-offset: 2px;
}

.rd-modal-body {
  min-height: 0;
  padding: 18px;
  overflow: auto;
}

.rd-modal-body > .card,
.rd-modal-body > .settings-card,
.rd-modal-body > .mc-card {
  padding-inline: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.rd-modal-footer {
  display: flex !important;
  justify-content: flex-end !important;
  gap: 10px !important;
  margin: 0 !important;
  padding: 12px 18px;
  border-top: 1px solid var(--rd-line-soft);
}

@media (max-width: 900px) {
  .content-wrap > .rd-page {
    width: 100%;
  }

  .rd-page-header {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .rd-modal-overlay { padding: 0; }

  .rd-modal,
  .modal-box-wide.rd-modal {
    width: 100vw;
    max-width: none;
    height: 100dvh;
    max-height: none;
    border: 0 !important;
    border-radius: 0 !important;
  }

  .rd-modal-body { padding: 16px; }
  .rd-modal-footer { padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .rd-modal,
  .rd-modal-overlay { transition: none !important; }
}
