body.admin-body {
  display: grid;
  grid-template-columns: 230px 1fr;
  min-height: 100vh;
}
.sidebar {
  height: calc(100vh - 32px);
  margin: 16px 0 16px 16px;
  border-radius: 24px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  animation: admin-fade 0.55s ease-out both;
}
.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 42px;
}
.sidebar nav a {
  height: 48px;
  border-radius: 13px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #7d8292;
  font-weight: 700;
  font-size: 14px;
  transition:
    transform 0.22s ease,
    box-shadow 0.22s ease,
    border-color 0.22s ease,
    background 0.22s ease;
}
.sidebar nav a > span:first-child {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  flex: 0 0 24px;
}
.sidebar nav a svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nav-label {
  white-space: nowrap;
}
.sidebar nav .side-active {
  background: linear-gradient(135deg, #6651c5, #b461b8);
  color: white;
  box-shadow: 0 10px 22px rgba(120, 86, 173, 0.18);
}
.sidebar-bottom {
  margin-top: auto;
}
.sidebar-bottom a {
  color: #777d90;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}
.admin-main {
  padding: 24px 34px 40px;
  max-width: 1100px;
  width: 100%;
  margin: auto;
}
.admin-header {
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: admin-enter 0.55s 0.05s ease-out both;
}
.admin-header small,
.panel-heading small {
  color: #88849a;
  letter-spacing: 1.8px;
  font-size: 10px;
  font-weight: 800;
}
.admin-header h1 {
  font: 800 27px "Manrope";
  margin: 5px 0;
}
.header-actions {
  display: flex;
  gap: 10px;
}
.back-to-store {
  height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(83, 69, 150, 0.14);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  text-decoration: none;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  transition:
    transform 0.22s ease,
    box-shadow 0.22s ease,
    border-color 0.22s ease,
    background 0.22s ease;
}
@media (max-width: 560px) {
  .header-actions .icon-button {
    display: none;
  }
  .back-to-store {
    height: 38px;
    padding: 0 10px;
    white-space: nowrap;
  }
}
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 8px 0 22px;
}
.stats article {
  height: 116px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 32px rgba(64, 52, 117, 0.07);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  animation: admin-enter 0.55s ease-out both;
  transition:
    transform 0.25s ease,
    box-shadow 0.25s ease;
}
.stats article:nth-child(2) {
  animation-delay: 0.08s;
}
.stats article:nth-child(3) {
  animation-delay: 0.16s;
}
.stats article:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 36px rgba(64, 52, 117, 0.12);
}
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 20px;
}
.stat-icon.purple {
  background: #eeeafd;
  color: #6551c5;
}
.stat-icon.pink {
  background: #fdeaf4;
  color: #d65a9e;
}
.stat-icon.blue {
  background: #e5eefb;
  color: #557cc1;
}
.stats article div {
  display: grid;
}
.stats article small {
  color: #8c8e9c;
}
.stats article strong {
  font: 800 21px "Manrope";
  margin: 5px 0;
}
.stats article em {
  font-style: normal;
  color: #6aa079;
  font-size: 11px;
  font-weight: 800;
}
.admin-panel {
  border-radius: 24px;
  padding: 22px;
  animation: admin-enter 0.65s 0.12s ease-out both;
}
.admin-panel:nth-of-type(2) {
  animation-delay: 0.2s;
}
.admin-panel:nth-of-type(3) {
  animation-delay: 0.28s;
}
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.panel-heading h2 {
  font: 800 24px "Manrope";
  margin: 4px 0;
}
.panel-heading .button {
  height: 44px;
  border: 0;
  transition:
    transform 0.22s ease,
    box-shadow 0.22s ease,
    border-color 0.22s ease,
    background 0.22s ease;
}
.table-wrap {
  overflow-x: auto;
  width: 100%;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th {
  text-align: left;
  color: #9a9baa;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 10px;
}
td {
  border-top: 1px solid rgba(72, 65, 115, 0.08);
  padding: 12px 10px;
  font-size: 13px;
}
.product-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}
.product-thumb {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  background: #efedf7;
}
.status {
  display: inline-flex;
  padding: 5px 9px;
  border-radius: 20px;
  background: #eaf7ef;
  color: #579268;
  font-size: 10px;
  font-weight: 800;
}
.delete-button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: #f3f0fa;
  color: #7d758d;
  cursor: pointer;
  transition:
    transform 0.22s ease,
    box-shadow 0.22s ease,
    border-color 0.22s ease,
    background 0.22s ease;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 54, 0.28);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  display: none;
  place-items: center;
  z-index: 20;
}
.modal-backdrop.open {
  display: grid;
  animation: admin-fade 0.25s ease-out;
}
.modal-backdrop.open .modal {
  animation: admin-enter 0.32s ease-out;
}
.modal {
  width: min(440px, calc(100% - 30px));
  border-radius: 24px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}
.modal > small {
  color: #948ba8;
  font-weight: 800;
  letter-spacing: 1.5px;
}
.modal h2 {
  font: 800 24px "Manrope";
  margin: 0 0 4px;
}
.modal label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #77798a;
}
.modal input,
.modal select {
  height: 46px;
  border: 1px solid rgba(73, 65, 117, 0.11);
  border-radius: 12px;
  padding: 0 13px;
  background: rgba(255, 255, 255, 0.75);
  font: 600 13px "DM Sans";
  outline: none;
}
.close-modal {
  position: absolute;
  right: 16px;
  top: 14px;
  border: 0;

  background: transparent;
  font-size: 24px;
  color: #77798a;
}
.submit {
  border: 0;
  margin-top: 8px;
  width: 100%;
  cursor: pointer;
}
#loans {
  margin-top: 22px;
}
#orders {
  margin-top: 22px;
}
.loan-admin-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.loan-admin-controls label {
  color: #77798a;
  font-size: 12px;
  font-weight: 800;
}
.loan-admin-controls select {
  height: 42px;
  min-width: 190px;
  border: 1px solid rgba(73, 65, 117, 0.11);
  border-radius: 11px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  font: 700 12px "DM Sans";
}
.loan-admin-table {
  min-width: 650px;
}
.loan-row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  border-top: 1px solid rgba(72, 65, 115, 0.08);
}
.loan-edit-button {
  height: 34px;
  border: 0;
  border-radius: 9px;
  padding: 0 11px;
  background: #eeeafd;
  color: #6551c5;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition:
    transform 0.22s ease,
    box-shadow 0.22s ease,
    border-color 0.22s ease,
    background 0.22s ease;
}
.admin-login-topbar {
  display: flex;
  justify-content: flex-end;
  height: 40px;
}
.admin-login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #f7f8ff 0%, #f1efff 48%, #fff5fb 100%);
}
.admin-login-card {
  width: min(420px, 100%);
  border-radius: 24px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  background: rgba(255, 255, 255, 0.76);
}
.admin-login-brand {
  margin-bottom: 4px;
}
.admin-login-kicker {
  color: #88849a;
  letter-spacing: 1.8px;
  font-size: 10px;
  font-weight: 800;
}
.admin-login-card h1 {
  margin: 6px 0 8px;
  font: 800 28px "Manrope";
}
.admin-login-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}
.admin-login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.admin-login-form label {
  font-size: 12px;
  font-weight: 800;
  color: #77798a;
}
.admin-login-form input {
  height: 48px;
  border: 1px solid rgba(73, 65, 117, 0.14);
  border-radius: 12px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  font: 600 14px "DM Sans";
  outline: none;
}
.admin-login-form input:focus {
  border-color: #6551c5;
  box-shadow: 0 0 0 4px rgba(101, 81, 197, 0.11);
}
.admin-login-form .button {
  width: 100%;
  border: 0;
  margin-top: 4px;
}
.admin-login-error {
  min-height: 20px;
  color: #c54a67 !important;
  font-size: 12px !important;
}
.sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#adminLogout {
  border: 0;
  padding: 0;
  background: transparent;
  color: #b64a72;
  font: 800 13px "DM Sans";
  text-align: left;
  cursor: pointer;
}
#adminLogout {
  min-height: 40px;
  width: 100%;
  border: 1px solid rgba(182, 74, 114, 0.15);
  border-radius: 12px;
  padding: 0 12px;
  background: #fff1f6;
  color: #b64a72;
  font: 800 13px "DM Sans";
  text-align: center;
  cursor: pointer;
  transition:
    transform 0.22s ease,
    background 0.22s ease,
    box-shadow 0.22s ease;
}
#adminLogout:hover {
  transform: translateY(-2px);
  background: #ffe7ef;
  box-shadow: 0 10px 22px rgba(182, 74, 114, 0.12);
}
:root {
  --admin-text-primary: #18203a;
  --admin-text-secondary: #62687a;
}
:root[data-theme="dark"] {
  --admin-text-primary: #f4f6ff;
  --admin-text-secondary: #c8cde2;
}

.admin-header h1,
.panel-heading h2,
.modal h2,
.admin-login-card h1,
.stats article strong,
.product-cell,
.product-cell strong,
.loan-admin-table td,
.loan-admin-table th {
  color: var(--admin-text-primary);
}
.admin-header small,
.panel-heading small,
.stats article small,
.stats article em,
th,
td,
.sidebar nav a,
.sidebar-bottom a,
.modal label,
.modal > small,
.admin-login-kicker,
.admin-login-form label,
.admin-login-card p,
.loan-admin-controls label,
.back-to-store,
.delete-button,
.loan-edit-button {
  color: var(--admin-text-secondary);
}

:root[data-theme="dark"] .sidebar nav a,
:root[data-theme="dark"] .sidebar-bottom a,
:root[data-theme="dark"] .admin-header small,
:root[data-theme="dark"] .panel-heading small,
:root[data-theme="dark"] th,
:root[data-theme="dark"] td,
:root[data-theme="dark"] .modal label,
:root[data-theme="dark"] .admin-login-form label,
:root[data-theme="dark"] .stats article small,
:root[data-theme="dark"] .back-to-store,
:root[data-theme="dark"] .delete-button,
:root[data-theme="dark"] .loan-edit-button {
  color: var(--admin-text-secondary);
}

.table-wrap,
.loan-table-wrap {
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(91, 70, 189, 0.38) transparent;
}
.table-wrap::-webkit-scrollbar,
.loan-table-wrap::-webkit-scrollbar {
  height: 5px;
  width: 5px;
}
.table-wrap::-webkit-scrollbar-thumb,
.loan-table-wrap::-webkit-scrollbar-thumb {
  background: rgba(91, 70, 189, 0.38);
  border-radius: 999px;
}
:root[data-theme="dark"] .table-wrap::-webkit-scrollbar-thumb,
:root[data-theme="dark"] .loan-table-wrap::-webkit-scrollbar-thumb {
  background: rgba(176, 162, 255, 0.48);
}
@keyframes admin-enter {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes admin-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .admin-header,
  .stats article,
  .admin-panel,
  .modal-backdrop.open,
  .modal-backdrop.open .modal {
    animation: none;
  }
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
@media (max-width: 1000px) {
  body.admin-body {
    grid-template-columns: 82px minmax(0, 1fr);
  }
  .sidebar {
    height: calc(100vh - 24px);
    margin: 12px 0 12px 12px;
    padding: 12px 8px;
  }
  .sidebar .brand > span:last-child,
  .sidebar nav a span + *,
  .sidebar nav a:not(.side-active) {
    font-size: 0;
  }
  .sidebar nav a {
    justify-content: center;
    padding: 0;
  }
  .sidebar nav a span {
    font-size: 18px;
  }
  .sidebar nav a span + * {
    display: none;
  }
  .sidebar-bottom {
    display: none;
  }
  .admin-main {
    min-width: 0;
    padding: 20px;
  }
  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  body.admin-body {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }
  .sidebar {
    position: sticky;
    top: 8px;
    z-index: 50;
    height: 68px;
    width: calc(100% - 24px);
    margin: 12px;
    padding: 8px 12px;
    flex-direction: row;
    align-items: center;
  }
  .sidebar .brand {
    display: flex;
    align-items: center;
  }
  .sidebar .brand > span:last-child {
    display: flex;
  }
  .admin-menu-toggle {
    width: 44px;
    height: 44px;
    margin-left: auto;
    border: 0;
    border-radius: 12px;
    background: rgba(101, 81, 197, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
  }
  .admin-menu-toggle span {
    width: 20px;
    height: 2px;
    border-radius: 999px;
    background: var(--ink);
    transition:
      transform 0.2s ease,
      opacity 0.2s ease;
  }
  .sidebar.menu-open .admin-menu-toggle span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }
  .sidebar.menu-open .admin-menu-toggle span:nth-child(2) {
    opacity: 0;
  }
  .sidebar.menu-open .admin-menu-toggle span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }
  .sidebar nav {
    display: none;
    position: absolute;
    top: 76px;
    left: 0;
    right: 0;
    margin: 0;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 18px 40px rgba(64, 52, 117, 0.16);
    flex-direction: column;
    gap: 4px;
  }
  .sidebar.menu-open nav {
    display: flex;
  }
  .sidebar nav a,
  .sidebar nav a:not(.side-active) {
    display: flex;
    width: 100%;
    height: 48px;
    padding: 0 14px;
    justify-content: flex-start;
    font-size: 14px;
  }
  .sidebar nav a > span:first-child,
  .sidebar nav a svg {
    display: grid;
  }
  .sidebar nav a .nav-label,
  .sidebar nav a span + * {
    display: inline;
  }
  .sidebar-bottom {
    display: none;
  }
  .sidebar.menu-open .sidebar-bottom {
    display: flex;
  }
  .sidebar-bottom {
    position: absolute;
    top: 340px;
    left: 10px;
    right: 10px;
    z-index: 51;
  }
  .sidebar-bottom a {
    display: none;
  }
  #adminLogout {
    width: 100%;
    min-height: 44px;
    border-radius: 12px;
  }
}
@media (max-width: 520px) {
  .admin-login-body {
    padding: 12px;
  }
  .admin-login-card {
    width: 100%;
    max-width: 420px;
    padding: 20px;
  }
  .sidebar nav {
    gap: 4px;
  }
}
:root[data-theme="dark"] body.admin-body,
:root[data-theme="dark"] .admin-login-body {
  background: linear-gradient(
    135deg,
    var(--page-start),
    var(--page-middle) 48%,
    var(--page-end)
  );
}
:root[data-theme="dark"] .sidebar,
:root[data-theme="dark"] .admin-panel,
:root[data-theme="dark"] .stats article,
:root[data-theme="dark"] .modal,
:root[data-theme="dark"] .admin-login-card {
  background: var(--surface);
  border-color: var(--line);
}
:root[data-theme="dark"] .stats article,
:root[data-theme="dark"] .sidebar nav a,
:root[data-theme="dark"] .modal label,
:root[data-theme="dark"] .loan-admin-controls label,
:root[data-theme="dark"] th,
:root[data-theme="dark"] td,
:root[data-theme="dark"] .admin-login-card p {
  color: var(--muted);
}
:root[data-theme="dark"] .stats article strong,
:root[data-theme="dark"] .panel-heading h2,
:root[data-theme="dark"] .admin-header h1,
:root[data-theme="dark"] .modal h2,
:root[data-theme="dark"] .admin-login-card h1 {
  color: var(--ink);
}
:root[data-theme="dark"] .modal input,
:root[data-theme="dark"] .modal select,
:root[data-theme="dark"] .loan-admin-controls select,
:root[data-theme="dark"] .admin-login-form input {
  background: rgba(23, 24, 39, 0.92);
  color: var(--ink);
  border-color: var(--line);
}
:root[data-theme="dark"] .admin-header small,
:root[data-theme="dark"] .panel-heading small,
:root[data-theme="dark"] .admin-login-kicker,
:root[data-theme="dark"] .admin-login-form label,
:root[data-theme="dark"] .modal > small,
:root[data-theme="dark"] .close-modal,
:root[data-theme="dark"] .sidebar-bottom a,
:root[data-theme="dark"] .back-to-store,
:root[data-theme="dark"] .delete-button,
:root[data-theme="dark"] .loan-edit-button,
:root[data-theme="dark"] .stats article small,
:root[data-theme="dark"] .stats article em {
  color: #cfd4ea;
}
:root[data-theme="dark"] .back-to-store,
:root[data-theme="dark"] .delete-button,
:root[data-theme="dark"] .loan-edit-button,
:root[data-theme="dark"] #adminLogout {
  background: var(--surface-solid);
  border-color: var(--line);
}
:root[data-theme="dark"] .sidebar nav a {
  color: #cfd4ea;
}
:root[data-theme="dark"] .sidebar nav .side-active {
  color: #ffffff;
}
:root[data-theme="dark"] .status {
  background: #263b35;
  color: #a8d8b6;
}
