.admin-body {
  min-height: 100vh;
  background: #f3f7fa;
  color: #173444;
}

.login-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(130deg, rgba(15, 119, 154, 0.08), rgba(17, 186, 161, 0.08)),
    #f4f9fb;
}

.login-gate[hidden] {
  display: none;
}

.login-card {
  width: min(430px, 100%);
  display: grid;
  gap: 16px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: 0 24px 70px rgba(11, 56, 75, 0.14);
}

.login-card h1,
.login-card p {
  margin: 0;
}

.login-card h1 {
  font-size: 30px;
  line-height: 1.1;
}

.login-card p {
  color: var(--muted);
}

.login-card label,
.admin-form label,
.settings-card label,
.team-row label,
.orders-table label {
  display: grid;
  gap: 7px;
  color: #385463;
  font-size: 13px;
  font-weight: 850;
}

.login-card input,
.admin-form input,
.admin-form select,
.admin-form textarea,
.settings-card input,
.settings-card select,
.settings-card textarea,
.team-row input,
.orders-table input,
.orders-table select,
.admin-table input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 9px 11px;
  font: inherit;
}

.admin-form textarea,
.settings-card textarea {
  resize: vertical;
}

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
}

.admin-shell[hidden] {
  display: none;
}

.admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 14px;
  background: #103446;
  color: #fff;
}

.admin-brand {
  padding: 0 6px;
}

.admin-brand small {
  color: #b9d1dc;
}

.admin-nav {
  display: grid;
  gap: 6px;
}

.admin-nav button {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: #c8dfe7;
  text-align: left;
  font-size: 14px;
  font-weight: 830;
}

.admin-nav button:hover,
.admin-nav button.active {
  background: rgba(255, 255, 255, 0.13);
  color: #fff;
}

.admin-sidebar-note {
  margin-top: auto;
  padding: 13px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  color: #c0d4dd;
  font-size: 12px;
  line-height: 1.55;
}

.admin-main {
  min-width: 0;
  padding: 22px;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.admin-topbar p,
.admin-topbar h1 {
  margin: 0;
}

.admin-topbar p {
  color: var(--primary-strong);
  font-size: 13px;
  font-weight: 900;
}

.admin-topbar h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.08;
}

.admin-top-actions,
.editor-actions,
.backup-actions,
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.admin-section {
  display: none;
}

.admin-section.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric-grid article,
.admin-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 12px 28px rgba(10, 62, 84, 0.07);
}

.metric-grid article {
  padding: 16px;
}

.metric-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.metric-grid strong {
  display: block;
  margin-top: 8px;
  color: var(--primary-strong);
  font-size: 34px;
  line-height: 1;
}

.admin-card {
  padding: 18px;
}

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

.admin-card-head.slim {
  margin-bottom: 10px;
}

.admin-card h2,
.admin-card h3,
.admin-card p {
  margin: 0;
}

.admin-card h2 {
  font-size: 22px;
  line-height: 1.2;
}

.admin-card h3 {
  font-size: 16px;
}

.admin-card p {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.6;
}

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

.two-col {
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
}

.spacing-top {
  margin-top: 16px;
}

.admin-checklist {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.admin-checklist li {
  position: relative;
  padding-left: 24px;
  color: #2d4e5d;
  line-height: 1.55;
  font-weight: 760;
}

.admin-checklist li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 5px var(--aqua);
}

.product-admin-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(390px, 460px);
  gap: 16px;
  align-items: start;
}

.editor-card {
  position: sticky;
  top: 18px;
}

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

.product-list-card .admin-table-wrap {
  max-height: calc(100vh - 190px);
  overflow: auto;
}

.admin-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th,
.admin-table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-soft);
  color: #385463;
  font-size: 12px;
  font-weight: 900;
}

.product-table {
  min-width: 760px;
}

.product-cell {
  display: flex;
  gap: 10px;
  min-width: 260px;
}

.product-cell img {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  object-fit: cover;
  background: var(--bg-soft);
}

.product-cell strong,
.product-cell span {
  display: block;
}

.product-cell span,
.admin-table small,
.muted {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.icon-btn {
  min-height: 32px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 900;
}

.icon-btn.danger {
  color: #a53535;
}

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

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

.span-2 {
  grid-column: span 2;
}

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

.rate-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
}

.switch {
  display: flex !important;
  align-items: center;
  gap: 10px !important;
  min-height: 42px;
}

.switch input {
  position: absolute;
  width: 1px !important;
  height: 1px !important;
  min-height: 0 !important;
  opacity: 0;
  pointer-events: none;
}

.switch span {
  position: relative;
  width: 42px;
  height: 23px;
  border-radius: 999px;
  background: #cfdfe6;
  flex: 0 0 auto;
}

.switch span::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s ease;
}

.switch input:checked + span {
  background: var(--teal);
}

.switch input:checked + span::after {
  transform: translateX(19px);
}

.switch.mini {
  min-height: 34px;
  font-size: 12px;
}

.switch.mini span {
  width: 38px;
  height: 21px;
}

.switch.mini span::after {
  width: 15px;
  height: 15px;
}

.switch.mini input:checked + span::after {
  transform: translateX(17px);
}

.file-control input,
.import-btn input {
  display: none;
}

.file-control span,
.import-btn {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 9px 11px;
  border: 1px dashed var(--primary);
  border-radius: var(--radius);
  background: var(--bg-soft);
  color: var(--primary-strong);
  font-weight: 900;
}

.file-control.mini span {
  min-height: 34px;
}

.image-preview-row {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
}

.image-preview-row figure {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.image-preview-row img {
  width: 100%;
  aspect-ratio: 1;
  display: block;
  object-fit: cover;
  background: var(--bg-soft);
}

.image-preview-row figcaption {
  padding: 6px;
  color: var(--muted);
  font-size: 11px;
}

.variant-panel {
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.variant-editor {
  display: grid;
  gap: 10px;
  max-height: 520px;
  overflow: auto;
  padding-right: 4px;
}

.variant-row,
.settings-card,
.team-row {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.variant-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.variant-price-preview {
  grid-column: span 2;
  display: grid;
  gap: 3px;
  padding: 9px 10px;
  border-radius: var(--radius);
  background: #fff;
}

.variant-price-preview strong {
  color: #0c6b60;
}

.variant-price-preview span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.payment-admin-preview {
  min-height: 42px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.payment-admin-preview img {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.settings-list {
  display: grid;
  gap: 12px;
}

.settings-card {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.settings-card.compact {
  grid-template-columns: minmax(160px, 1fr) minmax(170px, 1fr) auto auto;
  align-items: end;
}

.proof-thumb {
  width: 72px;
  height: 72px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  object-fit: cover;
  background: var(--bg-soft);
}

.empty-admin {
  padding: 26px;
  color: var(--muted);
  text-align: center;
  font-weight: 850;
}

.team-editor {
  display: grid;
  gap: 12px;
}

.team-row {
  grid-template-columns: 74px minmax(150px, 1fr) minmax(170px, 1.2fr) 90px auto auto;
  align-items: end;
}

.team-row img {
  width: 74px;
  height: 74px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  object-fit: cover;
  background: var(--bg-soft);
}

.backup-actions {
  margin-top: 18px;
}

.toast {
  z-index: 200;
}

@media (max-width: 1180px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: static;
    height: auto;
  }

  .admin-nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .admin-sidebar-note {
    margin-top: 0;
  }

  .product-admin-layout,
  .two-col {
    grid-template-columns: 1fr;
  }

  .editor-card {
    position: static;
  }
}

@media (max-width: 820px) {
  .admin-main {
    padding: 14px;
  }

  .admin-topbar,
  .admin-card-head {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-top-actions .btn,
  .admin-card-head .btn,
  .backup-actions .btn {
    width: 100%;
  }

  .admin-nav,
  .metric-grid,
  .admin-form,
  .form-row,
  .rate-grid,
  .settings-card,
  .settings-card.compact,
  .team-row {
    grid-template-columns: 1fr;
  }

  .span-2,
  .variant-price-preview {
    grid-column: auto;
  }

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

  .team-row img {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
  }

  .image-preview-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .admin-card,
  .login-card {
    padding: 14px;
  }

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

  .admin-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
