.admin-body {
  min-height: 100vh;
  background: #f4efe6;
}

.admin-shell,
.admin-login-shell {
  width: min(100% - 28px, 1180px);
  margin: 0 auto;
  padding: 24px 0 42px;
}

.admin-login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.admin-header,
.admin-panel {
  border: 1px solid rgba(23, 33, 29, 0.12);
  border-radius: 8px;
  background: rgba(255, 250, 243, 0.96);
  box-shadow: 0 16px 28px rgba(20, 32, 27, 0.08);
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px;
}

.admin-header-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.admin-logo-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(23, 33, 29, 0.12);
  border-radius: 8px;
  background: #fffdf9;
  box-shadow: 0 10px 22px rgba(20, 32, 27, 0.08);
}

.admin-logo-link:focus-visible {
  outline: 3px solid rgba(36, 76, 63, 0.28);
  outline-offset: 3px;
}

.admin-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.admin-login-panel .admin-logo-link {
  justify-self: start;
}

.admin-header h1,
.admin-panel h2,
.admin-login-panel h1 {
  margin: 4px 0 0;
}

.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.admin-nav a,
.admin-back-link {
  color: #244c3f;
  font-weight: 700;
  text-decoration: none;
}

.admin-grid {
  display: grid;
  gap: 20px;
  margin-top: 20px;
}

.admin-panel {
  display: grid;
  gap: 22px;
  padding: 24px;
}

.admin-login-panel {
  width: min(100%, 460px);
}

.admin-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.admin-panel-head span {
  color: #8a6d46;
  font-weight: 800;
}

.admin-form {
  display: grid;
  gap: 16px;
}

.admin-secondary-form {
  padding-top: 4px;
}

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

.admin-list {
  display: grid;
  gap: 10px;
}

.admin-list-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid rgba(23, 33, 29, 0.1);
  border-radius: 8px;
  background: #fffdf9;
}

.admin-list-item div {
  display: grid;
  gap: 5px;
}

.admin-list-item span,
.admin-list-item a,
.admin-empty {
  color: #66736d;
  font-size: 0.94rem;
}

.admin-subgrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.admin-olp-workflow {
  grid-template-columns: 1fr;
}

.admin-subpanel {
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid rgba(23, 33, 29, 0.1);
  border-radius: 8px;
  background: #fffdf9;
}

.admin-panel-head.compact h3 {
  margin: 2px 0 0;
}

.admin-check-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.admin-check-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  padding: 14px;
  border: 1px solid rgba(23, 33, 29, 0.1);
  border-radius: 8px;
  background: #fffdf9;
}

.admin-check-card input {
  margin-top: 4px;
}

.admin-check-card span {
  display: grid;
  gap: 4px;
}

.admin-check-card small,
.admin-muted {
  color: #66736d;
  font-size: 0.9rem;
}

.admin-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.admin-actions-row form {
  display: inline;
}

.admin-license-actions {
  flex-wrap: nowrap;
  min-width: max-content;
}

.admin-license-actions form {
  display: inline-flex;
  flex: 0 0 auto;
}

.admin-license-actions .button,
.admin-license-actions .admin-danger-button {
  white-space: nowrap;
}

.admin-compact-form {
  width: 100%;
}

.admin-license-item {
  align-items: start;
}

.admin-license-item > form:first-child,
.admin-license-item > div:first-child {
  min-width: 0;
}

.admin-institution-add-form,
.admin-institution-row-form {
  display: flex;
  flex-flow: row nowrap;
  align-items: end;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.admin-institution-item {
  display: flex;
  align-items: end;
  overflow-x: auto;
}

.admin-institution-item > form:first-child {
  flex: 1 0 auto;
  min-width: max-content;
}

.admin-institution-item > form:not(:first-child) {
  flex: 0 0 auto;
}

.admin-institution-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.admin-institution-search-field {
  flex: 1 1 360px;
  max-width: 520px;
}

.admin-institution-search-field input {
  width: 100%;
}

.admin-institution-list {
  max-height: 286px;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-gutter: stable;
}

.admin-institution-list .admin-empty {
  margin: 0;
}

.admin-institution-field {
  flex: 0 0 auto;
  gap: 4px;
}

.admin-institution-field span,
.admin-institution-count span {
  white-space: nowrap;
}

.admin-institution-name-field input {
  width: 150px;
}

.admin-institution-code-field input {
  width: 116px;
}

.admin-institution-contact-field input {
  width: 190px;
}

.admin-institution-limit-field input {
  width: 96px;
}

.admin-institution-state-field select {
  width: 104px;
}

.admin-institution-count {
  display: grid;
  flex: 0 0 auto;
  gap: 4px;
  min-width: 98px;
  color: #6f6252;
  font-size: 0.82rem;
}

.admin-institution-count strong {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  color: #244c3f;
  font-size: 0.92rem;
}

.admin-institution-actions {
  flex: 0 0 auto;
  flex-wrap: nowrap;
  padding-bottom: 0;
}

.admin-bulk-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(36, 76, 63, 0.12);
  border-radius: 8px;
  background: rgba(36, 76, 63, 0.05);
}

.admin-bulk-check,
.admin-request-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #244c3f;
  font-weight: 800;
  white-space: nowrap;
}

.admin-bulk-check input,
.admin-request-check input {
  width: 18px;
  height: 18px;
  accent-color: #255a4a;
}

.admin-period-field {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #244c3f;
  font-size: 0.86rem;
  font-weight: 800;
  white-space: nowrap;
}

.admin-period-field input {
  width: 58px;
  min-height: 34px;
  padding: 6px 7px;
}

.admin-period-field small {
  color: #66736d;
  font-size: 0.82rem;
  font-weight: 700;
}

.admin-inline-period-form,
.admin-license-period-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.admin-license-period-form {
  align-items: flex-start;
}

.admin-actions-row .admin-license-period-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.admin-period-summary {
  min-width: 150px;
  color: #51443a;
  font-size: 0.86rem;
  font-weight: 700;
  white-space: nowrap;
}

.admin-request-item {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.admin-request-check {
  align-self: center;
}

.admin-request-table {
  min-width: 880px;
}

.admin-request-table th,
.admin-request-table td {
  white-space: nowrap;
  vertical-align: middle;
}

.admin-request-check-column {
  width: 64px;
}

.admin-request-actions {
  flex-wrap: nowrap;
}

.admin-sort-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.admin-sort-button::after {
  content: "sort";
  color: #8a6d46;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.admin-sort-button[data-sort-direction="asc"]::after {
  content: "asc";
}

.admin-sort-button[data-sort-direction="desc"]::after {
  content: "desc";
}

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

.admin-user-item {
  display: flex;
  align-items: end;
  overflow-x: auto;
}

.admin-user-item > form:first-child {
  min-width: max-content;
  flex: 1 0 auto;
}

.admin-user-title {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-width: 150px;
}

.admin-user-row-form {
  display: flex;
  flex-flow: row nowrap;
  align-items: end;
  gap: 10px;
}

.admin-user-field {
  flex: 0 0 auto;
  gap: 4px;
}

.admin-user-field span {
  white-space: nowrap;
}

.admin-user-id-field input {
  width: 132px;
}

.admin-user-email-field input {
  width: 220px;
}

.admin-user-role-field select,
.admin-user-state-field select {
  width: 112px;
}

.admin-user-password-field input {
  width: 150px;
}

.admin-user-actions {
  flex: 0 0 auto;
  flex-wrap: nowrap;
  padding-bottom: 0;
}

.admin-user-item > form:not(:first-child) {
  flex: 0 0 auto;
}

.admin-role-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 5px 8px;
  border-radius: 8px;
  color: #244c3f;
  background: rgba(36, 76, 63, 0.08);
  font-size: 0.82rem;
  font-weight: 800;
}

.admin-role-badge.manager {
  color: #17372f;
  background: rgba(37, 90, 74, 0.14);
}

.admin-role-badge.general {
  color: #8a6d46;
  background: rgba(138, 109, 70, 0.14);
}

.admin-role-badge.viewer {
  color: #40506a;
  background: rgba(64, 80, 106, 0.14);
}

.admin-role-badge.current {
  color: #7a3d20;
  background: rgba(191, 111, 65, 0.12);
}

.admin-inline-fields {
  display: grid;
  grid-template-columns: minmax(84px, 0.5fr) minmax(96px, 1fr);
  gap: 8px;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.admin-table th,
.admin-table td {
  padding: 10px;
  border-bottom: 1px solid rgba(23, 33, 29, 0.1);
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  color: #244c3f;
  background: rgba(36, 76, 63, 0.06);
}

.admin-license-table thead th {
  text-align: center;
}

.admin-license-table th + th,
.admin-license-table td + td {
  border-left: 1px solid rgba(23, 33, 29, 0.16);
}

.admin-body .button,
.admin-danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(122, 61, 32, 0.2);
  border-radius: 8px;
  text-decoration: none;
  box-shadow: inset 0 -1px 0 rgba(23, 33, 29, 0.08), 0 1px 2px rgba(23, 33, 29, 0.08);
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease, background 140ms ease;
}

.admin-body .button:hover,
.admin-danger-button:hover {
  transform: translateY(-1px);
  box-shadow: inset 0 -1px 0 rgba(23, 33, 29, 0.08), 0 4px 10px rgba(23, 33, 29, 0.12);
}

.admin-body .button:disabled,
.admin-danger-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
  box-shadow: none;
}

.admin-body .button.ghost {
  background: rgba(36, 76, 63, 0.08);
  color: #244c3f;
  border-color: rgba(36, 76, 63, 0.16);
}

.button-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
}

.button-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.admin-danger-button {
  background: rgba(191, 111, 65, 0.12);
  color: #7a3d20;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.admin-body input[type="file"]::file-selector-button {
  min-height: 38px;
  margin-right: 12px;
  padding: 0 14px 0 36px;
  border: 1px solid rgba(36, 76, 63, 0.18);
  border-radius: 8px;
  background-color: rgba(36, 76, 63, 0.08);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%23244c3f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 16V4'/%3E%3Cpath d='M7 9l5-5 5 5'/%3E%3Cpath d='M5 20h14'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
  background-size: 16px 16px;
  color: #244c3f;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.admin-alert {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 8px;
  font-weight: 700;
}

.admin-alert.success {
  color: #17372f;
  background: rgba(37, 90, 74, 0.12);
  border: 1px solid rgba(37, 90, 74, 0.2);
}

.admin-alert.error {
  color: #7a3d20;
  background: rgba(191, 111, 65, 0.12);
  border: 1px solid rgba(191, 111, 65, 0.2);
}

@media (max-width: 760px) {
  .admin-header,
  .admin-panel-head,
  .admin-list-item {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .admin-header {
    display: grid;
  }

  .admin-form-grid {
    grid-template-columns: 1fr;
  }

  .admin-user-row-form {
    min-width: 860px;
  }

  .admin-institution-add-form,
  .admin-institution-row-form {
    min-width: 760px;
  }

  .admin-user-actions {
    display: flex;
  }

  .admin-subgrid,
  .admin-check-grid {
    grid-template-columns: 1fr;
  }

  .admin-actions-row,
  .admin-inline-fields {
    display: grid;
    grid-template-columns: 1fr;
  }
}
