.admin-page {
  display: grid;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  padding-top: 8px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 58px;
  padding: 0 0 8px 18px;
}

.page-header > div {
  min-width: 0;
}

.page-header h1 {
  margin: 0;
  color: #07132c;
  font-size: clamp(25px, 2.1vw, 34px);
  line-height: 1.08;
}

.page-header p {
  max-width: 100%;
  margin: 8px 0 0;
  color: #344054;
  font-size: 15px;
  font-weight: 560;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.profile {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 244px;
  margin-right: 18px;
  color: #111827;
}

.profile-button {
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}

.avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(16, 24, 40, 0.09);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.56);
  font-size: 17px;
  font-weight: 950;
}

.profile-details,
.profile-details strong,
.profile-details span {
  display: block;
}

.profile-details strong {
  margin-bottom: 3px;
  font-size: 14px;
}

.profile-details span {
  color: #344054;
  font-size: 12px;
  font-weight: 650;
}

.admin-layout,
.bottom-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.43fr) minmax(390px, 0.95fr);
  gap: 10px;
  min-width: 0;
}

.left-stack {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.admin-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card-strong);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.card-title {
  display: flex;
  align-items: center;
  min-height: 52px;
  padding: 0 18px;
}

.card-title.compact {
  min-height: 44px;
}

.card-title.stacked {
  display: block;
  min-height: 0;
  padding: 16px 18px 12px;
}

.card-title h2,
.detail-header h2 {
  margin: 0;
  color: #101828;
  font-size: 18px;
  line-height: 1.1;
}

.card-title p,
.detail-header p {
  margin: 7px 0 0;
  color: #344054;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
}

.import-grid,
.capacity-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 0 16px 16px;
}

.import-source,
.capacity-box,
.active-source {
  min-width: 0;
  border: 1px solid rgba(16, 24, 40, 0.1);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.64);
}

.import-source {
  display: grid;
  gap: 14px;
  width: 100%;
  padding: 16px;
}

.source-header,
.active-source {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.source-header > div,
.active-source > div {
  min-width: 0;
}

.source-header h3,
.capacity-name h3,
.active-source h3,
.history-block h3,
.religion-block h3 {
  margin: 0;
  color: #172033;
  font-size: 14px;
  line-height: 1.1;
}

.source-header p,
.active-source p {
  margin: 8px 0 0;
  color: #3a4860;
  font-size: 12px;
  font-weight: 640;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.source-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

.source-icon.purple {
  color: #8b5cf6;
  background: rgba(139, 92, 246, 0.14);
}

.source-icon.blue {
  color: #0b72ff;
  background: rgba(11, 114, 255, 0.12);
}

.drop-zone {
  display: grid;
  place-items: center;
  width: 100%;
  min-width: 0;
  min-height: 124px;
  padding: 18px;
  color: #0b72ff;
  border: 1px dashed rgba(43, 83, 143, 0.35);
  border-radius: 6px;
  background: rgba(248, 251, 255, 0.7);
  text-align: center;
  white-space: normal;
}

.drop-zone strong {
  max-width: 100%;
  margin-top: 8px;
  color: #172033;
  font-size: 12px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.drop-zone span {
  max-width: 100%;
  margin-top: 8px;
  color: #536071;
  font-size: 12px;
  font-weight: 650;
}

.import-source footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  color: #536071;
  font-size: 12px;
  font-weight: 650;
}

.import-source footer span {
  min-width: 0;
  flex: 1 1 180px;
  overflow-wrap: anywhere;
}

.import-source footer .status-pill {
  flex: 0 0 auto;
}

.status-pill,
.mini-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.status-pill.valid,
.mini-status.active {
  color: #1b6e35;
  background: rgba(102, 164, 39, 0.18);
}

.mini-status {
  color: #536071;
  background: rgba(83, 96, 113, 0.1);
}

.capacity-box {
  display: grid;
  grid-template-columns: minmax(80px, 0.7fr) minmax(116px, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 14px;
}

.capacity-name {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  gap: 10px;
  color: #0b72ff;
  align-self: start;
}

.capacity-current,
.number-field {
  display: grid;
  gap: 5px;
}

.capacity-current span,
.number-field span {
  color: #536071;
  font-size: 11px;
  font-weight: 750;
}

.capacity-current strong {
  color: #07132c;
  font-size: 28px;
  line-height: 1;
  font-weight: 950;
}

.capacity-current small {
  color: #344054;
  font-size: 12px;
  font-weight: 650;
}

.number-field input,
.search-box,
.select-button,
.teacher-select {
  min-height: 36px;
  color: #142033;
  border: 1px solid rgba(16, 24, 40, 0.14);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
  font-size: 12px;
  font-weight: 800;
}

.number-field input {
  width: 100%;
  padding: 0 10px;
}

.save-button {
  min-height: 36px;
  padding: 0 14px;
  color: #fff;
  border-radius: 6px;
  background: #172033;
  font-size: 12px;
  font-weight: 900;
}

.source-list {
  display: grid;
  gap: 12px;
  padding: 0 18px 16px;
}

.active-source {
  grid-template-columns: 54px minmax(0, 1fr) auto 28px;
  min-height: 84px;
  padding: 12px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: #07132c;
  border-radius: 6px;
  background: transparent;
}

.icon-button:hover {
  background: rgba(16, 24, 40, 0.06);
}

.history-block {
  padding: 0 18px 18px;
}

.history-block h3,
.religion-block h3 {
  margin-bottom: 10px;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
}

.compact-table table,
.groups-table table,
.religion-table table {
  min-width: 560px;
  border: 1px solid rgba(16, 24, 40, 0.1);
  border-radius: 7px;
  overflow: hidden;
  table-layout: fixed;
}

.compact-table th,
.compact-table td,
.groups-table th,
.groups-table td,
.religion-table th,
.religion-table td {
  height: 38px;
  padding: 0 12px;
  font-size: 11px;
  white-space: nowrap;
}

.compact-table th,
.groups-table th,
.religion-table th {
  border-bottom: 1px solid rgba(16, 24, 40, 0.08);
  background: rgba(248, 250, 252, 0.74);
}

.groups-card {
  min-height: 0;
}

.group-tools {
  display: grid;
  grid-template-columns: minmax(160px, 1.35fr) repeat(2, minmax(116px, 0.85fr)) minmax(220px, 1.45fr) auto auto;
  gap: 9px;
  align-items: center;
  padding: 0 16px 12px;
}

.search-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #111827;
  font: inherit;
}

.search-box input::placeholder {
  color: #667085;
  opacity: 1;
}

.select-button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: 0 10px;
}

.select-button.slim {
  white-space: nowrap;
}

.toggle-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #536071;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.toggle-line input {
  position: absolute;
  opacity: 0;
}

.toggle-line span {
  position: relative;
  width: 30px;
  height: 18px;
  border-radius: 999px;
  background: #cfd6e2;
}

.toggle-line span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.2);
}

.toggle-line input:checked + span {
  background: var(--dept-work);
}

.toggle-line input:checked + span::after {
  transform: translateX(12px);
}

.groups-table table {
  min-width: 980px;
  border-right: 0;
  border-left: 0;
  border-radius: 0;
}

.groups-table td {
  font-weight: 700;
}

.groups-table .selected {
  background: rgba(11, 114, 255, 0.07);
}

.state-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  vertical-align: middle;
}

.state-dot.ok {
  background: #1fad63;
}

.state-dot.warn {
  background: #f59e0b;
}

.pagination-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 0 16px;
  color: #536071;
  font-size: 12px;
  font-weight: 650;
}

.pagination {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pagination button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: #1f2b3d;
  border: 1px solid rgba(16, 24, 40, 0.12);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  font-weight: 850;
}

.pagination button:first-child svg {
  transform: rotate(180deg);
}

.pagination .active {
  color: #0b72ff;
  border-color: rgba(11, 114, 255, 0.6);
}

.detail-panel {
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 16px;
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.summary-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.summary-row span {
  display: grid;
  gap: 5px;
  color: #536071;
  font-size: 12px;
  font-weight: 750;
}

.summary-row strong {
  color: #07132c;
  font-size: 21px;
  line-height: 1;
  font-weight: 950;
}

.religion-table table {
  min-width: 430px;
}

.teacher-select {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 0 10px;
  text-align: left;
}

.success-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 14px;
  color: #2f6f3f;
  border: 1px solid rgba(102, 164, 39, 0.16);
  border-radius: 7px;
  background: rgba(102, 164, 39, 0.1);
  font-size: 12px;
  font-weight: 750;
}

.success-note .icon {
  color: #2f9e44;
}

@media (max-width: 1280px) {
  .admin-layout,
  .bottom-layout {
    grid-template-columns: 1fr;
  }

  .group-tools {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1040px) {
  .admin-page {
    width: 100%;
    max-width: calc(100vw - 24px);
    overflow: visible;
    padding-top: 0;
  }

  .page-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    padding: 0 4px 4px;
  }

  .profile {
    min-width: 0;
    margin-right: 0;
  }
}

@media (max-width: 760px) {
  .admin-page {
    max-width: calc(100vw - 24px);
  }

  .import-grid,
  .capacity-grid,
  .group-tools {
    grid-template-columns: 1fr;
  }

  .capacity-box {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .active-source {
    grid-template-columns: 44px minmax(0, 1fr) auto;
  }

  .active-source .icon-button {
    grid-column: 3;
    grid-row: 1;
  }

  .page-header h1 {
    font-size: 25px;
  }

  .page-header p {
    width: 44ch;
    max-width: 100%;
    font-size: 13px;
  }

  .pagination-row {
    align-items: flex-start;
    flex-direction: column;
    padding: 12px 16px;
  }
}

@media (max-width: 520px) {
  .admin-page {
    max-width: calc(100vw - 16px);
  }

  .page-header p {
    width: 34ch;
  }

  .card-title,
  .card-title.stacked,
  .history-block,
  .detail-panel {
    padding-right: 12px;
    padding-left: 12px;
  }

  .import-grid,
  .capacity-grid,
  .source-list,
  .group-tools {
    padding-right: 12px;
    padding-left: 12px;
  }

  .source-header {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .source-header p {
    width: 28ch;
    max-width: 100%;
  }

  .source-icon {
    width: 40px;
    height: 40px;
  }

  .active-source {
    align-items: start;
  }

  .import-source footer {
    display: block;
  }

  .import-source footer span {
    display: block;
  }

  .import-source footer .status-pill {
    display: inline-flex;
    margin-top: 8px;
  }

  .summary-row {
    grid-template-columns: 1fr;
  }
}

.status-pill.processing {
  color: #8a5b00;
  background: rgba(255, 184, 77, 0.22);
}

.status-pill.invalid {
  color: #9d1c1c;
  background: rgba(239, 68, 68, 0.16);
}

.drop-zone.is-processing {
  cursor: progress;
  opacity: 0.78;
}
