.admin-page {
  min-height: 100dvh;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255, 219, 231, 0.7), transparent 38%),
    radial-gradient(circle at 88% 12%, rgba(50, 167, 157, 0.14), transparent 25%),
    var(--paper);
}

.admin-page button,
.admin-page textarea {
  font: inherit;
}

.admin-page textarea {
  resize: vertical;
}

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

.admin-topbar {
  position: relative;
  z-index: 30;
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 28px;
  border-bottom: 1px solid rgba(234, 216, 223, 0.9);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 8px 30px rgba(94, 47, 72, 0.06);
  backdrop-filter: blur(18px);
}

.admin-topbar .brand-copy small {
  color: var(--grape);
}

.admin-account {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.admin-link-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--grape);
  background: #fff;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 900;
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.admin-link-button:hover {
  border-color: rgba(105, 64, 144, 0.45);
  background: #fcf8ff;
  transform: translateY(-1px);
}

.danger-link {
  color: #a5284d;
}

.admin-gate {
  min-height: calc(100dvh - 78px);
  display: grid;
  place-items: center;
  padding: 40px 20px;
}

.admin-loader {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin-bottom: 12px;
}

.admin-loader span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--pitaya);
  animation: admin-bounce 900ms ease-in-out infinite alternate;
}

.admin-loader span:nth-child(2) {
  animation-delay: 140ms;
  background: var(--turquoise);
}

.admin-loader span:nth-child(3) {
  animation-delay: 280ms;
  background: var(--grape);
}

@keyframes admin-bounce {
  to { transform: translateY(-8px); }
}

.gate-card {
  width: min(100%, 510px);
  padding: 44px;
  border: 1px solid rgba(234, 216, 223, 0.95);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-soft);
}

.gate-kicker {
  display: block;
  margin-bottom: 8px;
  color: var(--turquoise-dark);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.gate-card h1 {
  margin-bottom: 14px;
  color: var(--ink);
  font-family: "Caprasimo", Georgia, serif;
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 400;
}

.gate-card > p {
  color: var(--ink-soft);
}

.login-card {
  text-align: center;
}

.login-mark {
  width: 70px;
  height: 70px;
  display: grid;
  place-items: center;
  margin: 0 auto 20px;
  border-radius: 24px 24px 24px 8px;
  color: #fff;
  background: linear-gradient(145deg, var(--pitaya), var(--grape));
  box-shadow: 0 15px 30px rgba(105, 64, 144, 0.24);
  font-family: "Caprasimo", Georgia, serif;
  font-size: 1.2rem;
}

.login-form {
  display: grid;
  gap: 15px;
  margin-top: 28px;
  text-align: left;
}

.login-form label,
.admin-field {
  display: grid;
  gap: 7px;
}

.login-form label > span,
.admin-field > span:first-child {
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 900;
}

.login-form input,
.admin-field input,
.admin-field select,
.admin-field textarea,
.admin-search input,
.repeater-row input,
.repeater-row select {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 13px;
  color: var(--ink);
  background: #fff;
  outline: 0;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.login-form input,
.admin-field input,
.admin-field select,
.admin-search input,
.repeater-row input,
.repeater-row select {
  min-height: 46px;
  padding: 0 13px;
}

.admin-field textarea {
  padding: 12px 13px;
}

.login-form input:focus,
.admin-field input:focus,
.admin-field select:focus,
.admin-field textarea:focus,
.admin-search input:focus,
.repeater-row input:focus,
.repeater-row select:focus {
  border-color: var(--pitaya);
  box-shadow: 0 0 0 3px rgba(236, 63, 125, 0.1);
}

.form-message {
  min-height: 20px;
  margin: -3px 0 0;
  color: #a5284d;
  font-size: 0.75rem;
  font-weight: 800;
}

.back-to-catalog {
  display: inline-block;
  margin-top: 22px;
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 800;
}

.setup-steps {
  display: grid;
  gap: 10px;
  margin: 24px 0;
  padding-left: 23px;
  color: var(--ink-soft);
}

.setup-steps code {
  padding: 2px 5px;
  border-radius: 5px;
  color: var(--grape);
  background: var(--grape-soft);
  font-size: 0.82em;
}

.gate-note {
  padding: 12px 14px;
  border-radius: 12px;
  color: #81500f !important;
  background: #fff2c6;
  font-size: 0.75rem;
  font-weight: 800;
}

.admin-workspace {
  height: calc(100dvh - 78px);
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
}

.product-rail {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 25px 20px 20px;
  border-right: 1px solid var(--line);
  background: rgba(255, 247, 250, 0.9);
}

.rail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.rail-heading h1 {
  margin: 0;
  font-family: "Caprasimo", Georgia, serif;
  font-size: 2rem;
  font-weight: 400;
}

.product-total {
  min-width: 40px;
  min-height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--grape);
  background: var(--grape-soft);
  font-weight: 900;
}

.admin-search {
  position: relative;
  display: block;
  margin-top: 17px;
}

.admin-search svg {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 13px;
  width: 18px;
  fill: none;
  stroke: var(--ink-soft);
  stroke-linecap: round;
  stroke-width: 2;
  transform: translateY(-50%);
}

.admin-search input {
  padding-left: 40px;
}

.rail-summary {
  display: flex;
  gap: 8px;
  margin: 12px 0;
  color: var(--ink-soft);
  font-size: 0.66rem;
}

.rail-summary span {
  flex: 1;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
}

.rail-summary strong {
  color: var(--ink);
}

.admin-product-list {
  min-height: 0;
  display: grid;
  gap: 9px;
  overflow-y: auto;
  padding: 2px 3px 20px 0;
  scrollbar-color: rgba(105, 64, 144, 0.3) transparent;
  scrollbar-width: thin;
}

.admin-product-card {
  width: 100%;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1.5px solid transparent;
  border-radius: 15px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.admin-product-card:hover {
  background: #fff;
  transform: translateX(2px);
}

.admin-product-card.is-active {
  border-color: var(--pitaya);
  background: #fff;
  box-shadow: 0 8px 22px rgba(94, 47, 72, 0.09);
}

.admin-product-card img,
.admin-product-placeholder {
  width: 58px;
  height: 58px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--blush);
}

.admin-product-placeholder {
  display: grid;
  place-items: center;
  color: var(--pitaya);
  font-size: 1.3rem;
}

.admin-product-copy {
  min-width: 0;
}

.admin-product-copy strong,
.admin-product-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-product-copy strong {
  font-size: 0.79rem;
}

.admin-product-copy small {
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 0.67rem;
}

.product-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(24, 139, 85, 0.1);
}

.product-status-dot.is-draft {
  background: #b69aa7;
  box-shadow: 0 0 0 4px rgba(113, 94, 104, 0.1);
}

.rail-empty {
  padding: 30px 15px;
  color: var(--ink-soft);
  text-align: center;
  font-size: 0.78rem;
}

.product-editor {
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(circle at 12px 12px, rgba(236, 63, 125, 0.03) 1px, transparent 1.5px) 0 0 / 24px 24px,
    #fbf8fa;
}

.editor-empty {
  height: 100%;
  display: grid;
  place-items: center;
  align-content: center;
  padding: 40px;
  color: var(--ink-soft);
  text-align: center;
}

.editor-empty > span {
  color: var(--pitaya);
  font-size: 3.2rem;
}

.editor-empty h2 {
  margin: 8px 0;
  color: var(--ink);
  font-family: "Caprasimo", Georgia, serif;
  font-size: 2rem;
  font-weight: 400;
}

.editor-empty p {
  margin-bottom: 22px;
}

.product-form {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.editor-header,
.editor-footer {
  position: relative;
  z-index: 5;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.93);
  backdrop-filter: blur(15px);
}

.editor-header {
  min-height: 88px;
  padding: 15px 30px;
  border-bottom: 1px solid var(--line);
}

.editor-header h2 {
  max-width: 650px;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-family: "Caprasimo", Georgia, serif;
  font-size: clamp(1.35rem, 3vw, 2rem);
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.editor-scroll {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding: 28px clamp(20px, 4vw, 52px) 45px;
  scrollbar-color: rgba(105, 64, 144, 0.3) transparent;
  scrollbar-width: thin;
}

.form-sheet {
  width: min(900px, 100%);
  margin: 0 auto 18px;
  padding: clamp(22px, 4vw, 34px);
  border: 1px solid rgba(234, 216, 223, 0.95);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 35px rgba(94, 47, 72, 0.06);
}

.form-sheet-main {
  position: relative;
}

.form-sheet-main::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 13px;
  border-left: 2px dotted rgba(236, 63, 125, 0.18);
  content: "";
}

.sheet-heading {
  margin-bottom: 23px;
  padding-bottom: 16px;
  border-bottom: 1px dashed var(--line);
}

.sheet-heading > span,
.sheet-heading > div > span {
  display: block;
  color: var(--grape);
  font-family: "Caprasimo", Georgia, serif;
  font-size: 1.2rem;
}

.sheet-heading p {
  margin: 5px 0 0;
  color: var(--ink-soft);
  font-size: 0.75rem;
}

.sheet-heading-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

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

.field-span-2 {
  grid-column: 1 / -1;
}

.admin-field small {
  color: var(--ink-soft);
  font-weight: 700;
}

.money-input {
  position: relative;
  display: block;
}

.money-input small {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 13px;
  color: var(--turquoise-dark);
  font-weight: 900;
  transform: translateY(-50%);
}

.money-input input {
  padding-left: 42px;
}

.publish-switch {
  min-height: 70px;
  display: grid;
  grid-template-columns: 42px 1fr;
  column-gap: 11px;
  align-content: center;
  cursor: pointer;
}

.publish-switch input {
  position: absolute;
  opacity: 0;
}

.publish-switch > span {
  position: relative;
  grid-row: 1 / 3;
  width: 42px;
  height: 24px;
  align-self: center;
  border-radius: 999px;
  background: #cbbbc3;
  transition: background 160ms ease;
}

.publish-switch > span::after {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(60, 39, 50, 0.2);
  content: "";
  transition: transform 160ms ease;
}

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

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

.publish-switch input:focus-visible + span {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.publish-switch strong {
  font-size: 0.78rem;
}

.publish-switch small {
  color: var(--ink-soft);
  font-size: 0.66rem;
}

.image-editor {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) 1.2fr;
  gap: 28px;
  align-items: center;
}

.image-preview {
  position: relative;
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  align-content: center;
  overflow: hidden;
  border: 2px dashed #e9cbd6;
  border-radius: 20px;
  color: var(--ink-soft);
  background: var(--paper);
  text-align: center;
}

.image-preview > span {
  color: var(--pitaya);
  font-family: "Caprasimo", Georgia, serif;
  font-size: 2rem;
}

.image-preview p {
  margin: 4px 0 0;
  font-size: 0.72rem;
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-controls {
  display: grid;
  gap: 14px;
}

.image-controls > p {
  margin: -4px 0 0;
  color: var(--ink-soft);
  font-size: 0.68rem;
}

.upload-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: start;
  padding: 9px 17px;
  border: 1.5px solid var(--pitaya);
  border-radius: 999px;
  color: var(--pitaya);
  background: #fff;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 900;
}

.upload-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.option-label-field {
  max-width: 420px;
  margin-bottom: 17px;
}

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

.repeater-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(170px, 1.2fr) minmax(110px, 0.55fr) minmax(180px, 1.3fr) 38px;
  gap: 10px;
  align-items: end;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fffafd;
}

.repeater-row.field-row {
  grid-template-columns: minmax(170px, 1.2fr) 130px minmax(180px, 1fr) minmax(160px, 1fr) 90px 38px;
}

.mini-field {
  display: grid;
  gap: 5px;
}

.mini-field > span {
  color: var(--ink-soft);
  font-size: 0.62rem;
  font-weight: 900;
  text-transform: uppercase;
}

.mini-field input,
.mini-field select {
  min-height: 40px;
  font-size: 0.73rem;
}

.mini-check {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 0.68rem;
  font-weight: 800;
}

.mini-check input {
  width: 17px;
  height: 17px;
  accent-color: var(--pitaya);
}

.remove-row {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #9f3151;
  background: #ffe9f0;
  cursor: pointer;
  font-size: 1.1rem;
}

.repeater-empty {
  margin: 0;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--ink-soft);
  background: var(--paper);
  font-size: 0.74rem;
  text-align: center;
}

.editor-footer {
  min-height: 74px;
  padding: 12px 30px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 25px rgba(94, 47, 72, 0.05);
}

.editor-footer > span {
  color: var(--ink-soft);
  font-size: 0.72rem;
}

.admin-toast {
  position: fixed;
  z-index: 100;
  right: 24px;
  bottom: max(24px, env(safe-area-inset-bottom));
  max-width: 390px;
  padding: 13px 18px;
  border-radius: 14px;
  color: #fff;
  background: var(--ink);
  box-shadow: 0 16px 35px rgba(60, 39, 50, 0.25);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
  font-size: 0.76rem;
  font-weight: 800;
}

.admin-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

[hidden] {
  display: none !important;
}

@media (max-width: 1120px) {
  .admin-workspace {
    grid-template-columns: 290px minmax(0, 1fr);
  }

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

  .remove-row {
    position: absolute;
    top: 10px;
    right: 10px;
  }

  .repeater-row .mini-field:first-child {
    padding-right: 42px;
  }
}

@media (max-width: 780px) {
  .admin-page {
    overflow: auto;
  }

  .admin-topbar {
    min-height: 70px;
    padding: 12px 16px;
  }

  .admin-account > span {
    display: none;
  }

  .admin-account > a.admin-link-button {
    display: none;
  }

  .admin-workspace {
    height: auto;
    min-height: calc(100dvh - 70px);
    display: block;
  }

  .product-rail {
    height: auto;
    padding: 22px 16px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .admin-product-list {
    display: flex;
    overflow-x: auto;
    padding-bottom: 9px;
    scroll-snap-type: x proximity;
  }

  .admin-product-card {
    min-width: 245px;
    scroll-snap-align: start;
  }

  .product-editor {
    min-height: 600px;
  }

  .product-form {
    height: auto;
  }

  .editor-header {
    position: sticky;
    top: 0;
    min-height: 76px;
    padding: 12px 16px;
  }

  .editor-header h2 {
    max-width: 43vw;
    font-size: 1.15rem;
  }

  .editor-header .button {
    min-height: 42px;
    padding: 9px 14px;
    font-size: 0.72rem;
  }

  .editor-scroll {
    overflow: visible;
    padding: 18px 12px 110px;
  }

  .editor-footer {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    min-height: 72px;
    padding: 10px 14px max(10px, env(safe-area-inset-bottom));
  }

  .editor-footer > span {
    display: none;
  }

  .editor-footer .button {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .gate-card {
    padding: 30px 22px;
    border-radius: 22px;
  }

  .admin-topbar .brand-mark {
    width: 34px;
    height: 34px;
  }

  .admin-topbar .brand-copy strong {
    font-size: 1.1rem;
  }

  .admin-topbar .brand-copy small {
    font-size: 0.52rem;
  }

  .admin-form-grid,
  .image-editor,
  .repeater-row,
  .repeater-row.field-row {
    grid-template-columns: 1fr;
  }

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

  .form-sheet {
    padding: 22px 17px;
    border-radius: 19px;
  }

  .sheet-heading-action {
    align-items: flex-start;
    flex-direction: column;
  }

  .image-preview {
    aspect-ratio: 16 / 10;
  }

  .editor-actions .danger-link {
    width: 38px;
    min-height: 38px;
    overflow: hidden;
    padding: 0;
    font-size: 0;
  }

  .editor-actions .danger-link::before {
    color: #a5284d;
    content: "×";
    font-size: 1.25rem;
  }

  .editor-header h2 {
    max-width: 38vw;
  }

  .admin-toast {
    right: 12px;
    bottom: calc(82px + env(safe-area-inset-bottom));
    left: 12px;
    max-width: none;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .admin-loader span {
    animation: none;
  }
}
