.page--admin {
  align-items: flex-start;
  padding-top: 3rem;
  overflow-x: auto;
  overflow-y: visible;
  width: 100%;
  justify-items: center;
}

.page--admin > .card {
  min-width: 0;
  max-width: 100%;
}

.card--form,
.card--wide {
  width: min(100%, 720px);
  text-align: left;
  min-width: 0;
}

.card--wide {
  width: min(100%, 920px);
}

.title--sm {
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  margin-bottom: 1.25rem;
}

.subtitle--left {
  margin-bottom: 0;
  text-align: left;
}

.form {
  display: grid;
  gap: 1rem;
}

.field {
  display: grid;
  gap: 0.45rem;
}

.field__label {
  font-size: 0.9rem;
  color: var(--muted);
}

.field__input {
  width: 100%;
  padding: 0.8rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
}

.field__input:focus {
  outline: none;
  border-color: rgba(108, 140, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(108, 140, 255, 0.15);
}

select.field__input {
  color-scheme: dark;
  cursor: pointer;
  padding-right: 2.25rem;
  background-color: rgba(255, 255, 255, 0.04);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23e8ecf4' d='M1.41 0 6 4.58 10.59 0 12 1.41l-6 6-6-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.95rem center;
  appearance: none;
}

select.field__input option {
  background-color: #121828;
  color: #e8ecf4;
}

select.field__input option:checked {
  background-color: #2a3a66;
  color: #fff;
}

.field__hint {
  font-size: 0.82rem;
  color: var(--muted);
}

.bot-settings-form {
  max-width: 720px;
}

.bot-settings-form--wide {
  max-width: 920px;
}

.bot-settings-form--familiars {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.bot-settings-form--pg {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.bot-settings-form--familiars .settings-block {
  min-width: 0;
  max-width: 100%;
}

.bot-settings-form--pg .settings-block {
  min-width: 0;
  max-width: 100%;
}

.bot-settings-form--familiars .settings-block--group {
  overflow: hidden;
}

.settings-block--familiar-section {
  margin: 1.25rem 0 0;
  padding-top: 0;
  border-top: none;
}

.resource-table__header {
  margin-bottom: 0.75rem;
}

.resource-table-wrap {
  overflow-x: auto;
}

.resource-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
}

.resource-table th,
.resource-table td {
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.resource-table th {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-align: left;
}

.resource-table__resource {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 9rem;
}

.resource-table__name {
  font-size: 0.95rem;
}

.resource-table__checkbox {
  display: inline-flex;
  margin: 0;
  cursor: pointer;
}

.resource-table__checkbox input {
  margin: 0;
  accent-color: var(--accent);
}

.familiar-table-wrap {
  margin-top: 0.25rem;
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
}

.familiar-table {
  width: 100%;
  min-width: 1040px;
  table-layout: fixed;
  border-collapse: collapse;
}

.familiar-table th,
.familiar-table td {
  overflow-wrap: anywhere;
}

.familiar-table__col-name,
.familiar-table__name-cell {
  position: sticky;
  left: 0;
  z-index: 1;
  background: rgba(14, 20, 34, 0.98);
  width: 9.5rem;
  min-width: 9.5rem;
  box-shadow: 1px 0 0 var(--border);
}

.familiar-table__col-check,
.familiar-table__check-cell {
  text-align: center;
  width: 7.25rem;
  min-width: 7.25rem;
}

.familiar-table th.familiar-table__col-check {
  font-size: 0.72rem;
  line-height: 1.25;
  text-align: center;
  vertical-align: bottom;
  padding-left: 0.35rem;
  padding-right: 0.35rem;
}

.familiar-table__name {
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
}

.familiar-table__check-cell .resource-table__checkbox {
  justify-content: center;
  width: 100%;
}

.settings-block--pg-section {
  margin: 0;
  padding-top: 0;
  border-top: none;
}

.pg-general-fields {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1.15rem;
  border-bottom: 1px solid var(--border);
}

.pg-mission-table-wrap {
  overflow: auto;
  max-width: 100%;
  max-height: min(70vh, 720px);
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
}

.pg-mission-table {
  width: 100%;
  min-width: 760px;
  table-layout: fixed;
  border-collapse: collapse;
}

.pg-mission-table__col-name,
.pg-mission-table__name-cell {
  width: 11rem;
  min-width: 11rem;
}

.pg-mission-table__col-tier {
  text-align: center;
}

.pg-mission-table__col-check,
.pg-mission-table__check-cell {
  width: 3.25rem;
  min-width: 3.25rem;
  text-align: center;
}

.pg-mission-table__col-points,
.pg-mission-table__points-cell {
  width: 4.75rem;
  min-width: 4.75rem;
  text-align: center;
}

.pg-mission-table th {
  font-size: 0.78rem;
  line-height: 1.25;
  text-align: center;
  vertical-align: bottom;
}

.pg-mission-table__name {
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
}

.pg-mission-table__check-cell .resource-table__checkbox,
.pg-mission-table__points-cell .field__input--table {
  margin: 0 auto;
}

.pg-mission-table__points-cell .field__input--table {
  width: 100%;
  max-width: 4.5rem;
  padding: 0.45rem 0.5rem;
}

.field__input--table {
  min-width: 8.5rem;
  padding: 0.55rem 0.7rem;
}

.settings-block--checkbox-row {
  margin: 1rem 0;
}

.checkbox-row--nested {
  margin: 0.85rem 0 0;
}

.checkbox-row__inner,
.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
}

.checkbox-row__label {
  flex: 0 0 auto;
  min-width: 4.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
}

.checkbox-row__items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.checkbox-row__item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-size: 0.92rem;
}

.checkbox-row__item input {
  margin: 0;
  accent-color: var(--accent);
}

.checkbox-row__item--disabled {
  opacity: 0.55;
  cursor: default;
}

.settings-block--columns,
.settings-block--section {
  margin: 1.25rem 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.settings-block--group {
  margin: 1.75rem 0;
  padding: 1.25rem 1.35rem 1.1rem;
  border: 1px solid rgba(108, 140, 255, 0.22);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.02);
}

.settings-block--group.settings-block--section {
  border-top: 1px solid rgba(108, 140, 255, 0.22);
}

.settings-subsection {
  margin-top: 1.15rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.settings-subsection__title {
  margin-bottom: 0.65rem;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.settings-section__title {
  margin-bottom: 0.65rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.settings-section__fields {
  display: grid;
  gap: 0.35rem;
}

.settings-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

.settings-column__title {
  margin-bottom: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: #c7d2fe;
  text-align: center;
}

.settings-column__fields {
  display: grid;
  gap: 0.35rem;
}

@media (max-width: 640px) {
  .settings-columns {
    grid-template-columns: 1fr;
  }
}

.field--checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin-bottom: 0.35rem;
  cursor: pointer;
}

.field--checkbox input {
  margin-top: 0.2rem;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.field__checkbox-label {
  font-size: 0.95rem;
  line-height: 1.4;
}

.field--checkbox-disabled {
  opacity: 0.55;
}

.field__hint--inline {
  display: block;
  margin-top: 0.15rem;
  padding-left: 1.65rem;
}

.field__input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.field__input[type="number"]::-webkit-outer-spin-button,
.field__input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem 1.2rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-soft));
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.button--ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.alert {
  margin-bottom: 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  font-size: 0.92rem;
}

.alert--error {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.alert--success {
  color: #bbf7d0;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.admin-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}

.admin-header__actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.admin-user {
  font-size: 0.9rem;
  color: var(--muted);
}

.admin-nav {
  display: grid;
  gap: 0.75rem;
}

.admin-link {
  display: grid;
  gap: 0.25rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.admin-link:hover {
  border-color: rgba(108, 140, 255, 0.35);
  background: rgba(108, 140, 255, 0.08);
}

.admin-link__title {
  font-size: 1.05rem;
  font-weight: 600;
}

.admin-link__desc {
  font-size: 0.9rem;
  color: var(--muted);
}

.bot-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
  max-height: 60vh;
  overflow: auto;
  padding-right: 0.25rem;
}

.bot-list__item {
  display: block;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.95rem;
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.bot-list__item:hover {
  border-color: rgba(108, 140, 255, 0.35);
  background: rgba(108, 140, 255, 0.08);
}

.bot-toolbar {
  margin-bottom: 1rem;
}

.bot-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.bot-tabs__item {
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.9rem;
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.bot-tabs__item:hover {
  border-color: rgba(108, 140, 255, 0.35);
  color: var(--text);
}

.bot-tabs__item--active {
  border-color: rgba(108, 140, 255, 0.45);
  background: rgba(108, 140, 255, 0.12);
  color: #c7d2fe;
}

.bot-panel {
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  min-width: 0;
}

.bot-panel__title {
  margin-bottom: 0.75rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.stats-file {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.85rem;
  color: var(--muted);
}

.stats-note {
  margin-top: 1rem;
}

.report-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 1.25rem;
}

.field--inline {
  min-width: 180px;
}

.report-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding-bottom: 0.55rem;
  color: var(--text);
  cursor: pointer;
}

.report-checkbox input {
  accent-color: var(--accent);
}

.table-wrap--report {
  max-height: 70vh;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.data-table--report {
  --report-head-row: 2.05rem;
  --report-sticky-bg: #121828;
  border-collapse: separate;
  border-spacing: 0;
  width: max-content;
  min-width: 100%;
}

.data-table--report th,
.data-table--report td {
  white-space: nowrap;
  padding: 0.55rem 0.45rem;
  font-size: 0.85rem;
}

.data-table--report thead th {
  position: sticky;
  z-index: 3;
  background: var(--report-sticky-bg);
  box-shadow: 0 1px 0 var(--border);
}

.data-table--report thead tr:first-child th {
  top: 0;
  z-index: 5;
}

.data-table--report thead tr:nth-child(2) th {
  top: var(--report-head-row);
  z-index: 4;
}

.data-table--report tbody tr.data-table__totals td {
  position: sticky;
  top: calc(var(--report-head-row) * 2);
  z-index: 2;
  font-weight: 700;
  background: #152038;
  box-shadow: 0 1px 0 var(--border), 0 4px 8px rgba(0, 0, 0, 0.18);
}

.data-table--report th.sortable {
  padding: 0;
}

.data-table__sort {
  display: flex;
  align-items: center;
  justify-content: inherit;
  width: 100%;
  height: 100%;
  padding: 0.55rem 0.45rem;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.data-table--report th.sortable.level .data-table__sort,
.data-table--report th.sortable.total .data-table__sort {
  justify-content: center;
}

.data-table__sort:hover {
  color: var(--text);
  background: rgba(108, 140, 255, 0.1);
}

.data-table__sort--active {
  color: #c7d2fe;
}

.data-table--report th.group {
  text-align: center;
}

.data-table--report th.level,
.data-table--report th.total {
  text-align: center;
  min-width: 2.6rem;
}

.data-table--report th.total {
  font-weight: 700;
}

.data-table--report td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  min-width: 2.6rem;
}

.data-table--report td.num .points {
  color: var(--muted);
  font-size: 0.82em;
}

.gift-settings {
  max-width: 420px;
}

.gift-settings__group {
  margin: 0;
  padding: 0;
  border: none;
}

.gift-settings__title {
  margin-bottom: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.field--gift {
  grid-template-columns: 1fr 96px;
  align-items: center;
  margin-bottom: 0.65rem;
}

.field__input--gift {
  text-align: right;
}

.data-table__totals td {
  border-bottom: 2px solid var(--border);
}

.empty-state {
  color: var(--muted);
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 0.85rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.data-table th {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table td {
  font-size: 0.95rem;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.data-table__actions {
  text-align: right;
  white-space: nowrap;
}

.button--small {
  padding: 0.55rem 0.85rem;
  font-size: 0.88rem;
}

.bot-checkboxes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.5rem;
  max-height: 320px;
  overflow: auto;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}

.bot-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.9rem;
  cursor: pointer;
}

.bot-checkbox input {
  accent-color: var(--accent);
}

@media (max-width: 640px) {
  .page--admin {
    padding: 1rem 0.75rem 1.5rem;
  }

  .card,
  .card--wide,
  .card--form {
    padding: 1.5rem 1rem;
  }

  .admin-header {
    flex-direction: column;
  }

  .admin-header__actions {
    width: 100%;
  }

  .admin-header__actions .button {
    flex: 1 1 auto;
  }

  .report-filters {
    display: grid;
    grid-template-columns: 1fr;
  }

  .field--inline {
    min-width: 0;
    width: 100%;
  }

  .report-filters .button {
    width: 100%;
  }
}
