.admin-grid:has(.department-route-list) {
  width: min(100%, 1320px);
  grid-template-columns: minmax(260px, 340px) minmax(560px, 1fr);
  align-items: start;
  gap: 16px;
}

.admin-grid:has(.department-route-list) .admin-panel {
  min-width: 0;
}

.admin-grid:has(.department-route-list) .admin-panel:first-child {
  position: sticky;
  top: 18px;
  padding: 16px;
  border-radius: 22px;
}

.admin-grid:has(.department-route-list) .admin-panel:nth-child(2) {
  padding: 18px 20px 22px;
  border-radius: 22px;
}

.department-route-list {
  display: grid;
  gap: 12px;
  max-height: min(72vh, 820px);
  padding: 2px 2px 4px;
  overflow: auto;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.department-route-row {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1fr);
  gap: 9px;
  min-height: 96px;
  padding: 15px 16px;
  border: 1px solid rgba(15, 17, 19, 0.1);
  border-radius: 18px;
  background: #ffffff;
  color: #151719;
  box-shadow: 0 1px 2px rgba(15, 17, 19, 0.04);
  text-align: left;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.department-route-row:hover,
.department-route-row:focus-visible {
  background: #fbfbfa;
  border-color: rgba(15, 17, 19, 0.18);
  box-shadow: 0 8px 18px rgba(15, 17, 19, 0.06);
  transform: translateY(-1px);
}

.department-route-row.active {
  border-color: #151719;
  background: #151719;
  color: #ffffff;
  box-shadow: 0 12px 28px rgba(15, 17, 19, 0.14);
  outline: 0;
}

.department-route-row span:first-child {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 10px;
  align-items: start;
}

.department-route-row span:first-child strong {
  min-width: 0;
  color: inherit;
  font-size: 0.98rem;
  line-height: 1.18;
  font-weight: 820;
}

.department-route-row span:first-child small {
  grid-column: 1 / -1;
  display: -webkit-box;
  max-width: 100%;
  overflow: hidden;
  color: #6f747a;
  font-size: 0.78rem;
  font-weight: 690;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.department-route-row.active span:first-child small {
  color: rgba(255, 255, 255, 0.68);
}

.department-route-row .admin-badge {
  grid-row: 1;
  grid-column: 2;
  min-height: 24px;
  max-width: 132px;
  padding: 3px 9px;
  overflow: hidden;
  align-self: start;
  background: #f6f6f4;
  color: #303337;
  border-color: rgba(15, 17, 19, 0.1);
  font-size: 0.69rem;
  text-overflow: ellipsis;
}

.department-route-row.active .admin-badge {
  background: #ffffff;
  color: #151719;
  border-color: transparent;
}

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

.department-editor > label:nth-child(3),
.department-editor > label:nth-child(4),
.department-editor > label:nth-child(9),
.department-editor > label:nth-child(10),
.department-editor > .checkbox-row,
.department-editor > .admin-action,
.department-editor > .inline-feedback {
  grid-column: 1 / -1;
}

.department-editor > label:nth-child(4),
.department-editor > label:nth-child(9),
.department-editor > .checkbox-row {
  padding-top: 42px;
  border-top: 1px solid rgba(15, 17, 19, 0.08);
}

.department-editor > label:nth-child(4)::before,
.department-editor > label:nth-child(9)::before,
.department-editor > .checkbox-row::before {
  margin-bottom: 8px;
  color: #151719;
  font-size: 0.78rem;
  font-weight: 840;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.department-editor > label:nth-child(1)::before {
  content: "Basic info";
  margin-bottom: 8px;
  color: #151719;
  font-size: 0.78rem;
  font-weight: 840;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.department-editor > label:nth-child(4)::before {
  content: "Contact / routing";
}

.department-editor > label:nth-child(9)::before {
  content: "Email template";
}

.department-editor > .checkbox-row::before {
  content: "Emergency settings";
}

.department-editor label {
  display: grid;
  gap: 8px;
  min-width: 0;
  color: #51565c;
  font-size: 0.83rem;
  font-weight: 760;
  line-height: 1.2;
}

.department-editor input,
.department-editor textarea {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 11px 13px;
  border-radius: 14px;
  color: #151719;
  background: #ffffff;
  border: 1px solid rgba(15, 17, 19, 0.12);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 680;
  line-height: 1.35;
  box-shadow: inset 0 1px 0 rgba(15, 17, 19, 0.02);
  overflow-wrap: anywhere;
}

.department-editor textarea {
  min-height: 108px;
  resize: vertical;
}

.department-editor label:nth-child(10) textarea {
  min-height: 172px;
}

.department-editor .checkbox-row {
  grid-template-columns: auto 1fr;
  align-items: center;
  justify-content: start;
  min-height: 54px;
  padding: 14px;
  border: 1px solid rgba(15, 17, 19, 0.1);
  border-radius: 16px;
  background: #f7f7f4;
  color: #4d5358;
  font-size: 0.9rem;
}

.department-editor .checkbox-row input {
  width: 18px;
  min-height: 18px;
  height: 18px;
  padding: 0;
  border-radius: 5px;
}

.department-editor .admin-action {
  justify-self: start;
  min-width: 210px;
  min-height: 46px;
  border-radius: 14px;
  box-shadow: 0 10px 22px rgba(15, 17, 19, 0.12);
}

@media (max-width: 980px) {
  .admin-grid:has(.department-route-list) {
    grid-template-columns: 1fr;
  }

  .admin-grid:has(.department-route-list) .admin-panel:first-child {
    position: static;
  }

  .department-route-list {
    max-height: none;
  }
}

@media (max-width: 640px) {
  .department-editor {
    grid-template-columns: 1fr;
  }

  .department-route-list {
    gap: 10px;
  }

  .department-route-row {
    min-height: 88px;
  }

  .department-route-row .admin-badge {
    justify-self: start;
    grid-row: auto;
    grid-column: auto;
  }

  .department-route-row span:first-child {
    grid-template-columns: 1fr;
  }

  .admin-grid:has(.department-route-list) .admin-panel:nth-child(2) {
    padding: 16px;
  }
}
