:root {
  color-scheme: light;
  --auth-wine: #3b090e;
  --auth-wine-dark: #240306;
  --auth-copper: #b96543;
  --auth-cream: #f8f3ee;
  --auth-paper: #fffdfa;
  --auth-text: #2a1715;
  --auth-muted: #765f59;
  --auth-border: #ded0c8;
  --auth-danger: #8f1f2d;
  --auth-success: #246447;
  --auth-warning: #72501c;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--auth-wine-dark); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--auth-text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 18% 12%, rgba(185, 101, 67, .26), transparent 34rem),
    linear-gradient(145deg, #260407 0%, #3b090e 58%, #1b0204 100%);
}

button, input { font: inherit; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
}

.auth-card {
  width: min(100%, 520px);
  padding: 34px;
  border: 1px solid rgba(255, 255, 255, .55);
  border-radius: 28px;
  background: var(--auth-cream);
  box-shadow: 0 28px 70px rgba(0, 0, 0, .32);
}

.auth-card-compact { width: min(100%, 480px); }
.auth-card-catalog { width: min(100%, 1120px); }

.auth-logo {
  display: block;
  width: 104px;
  height: 104px;
  margin: 0 auto 22px;
  border-radius: 24px;
  object-fit: cover;
  box-shadow: 0 14px 30px rgba(36, 3, 6, .22);
}

.kicker {
  margin: 0 0 8px;
  color: var(--auth-copper);
  font-size: .77rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: var(--auth-text);
  font-size: clamp(2rem, 7vw, 2.75rem);
  line-height: 1.02;
  letter-spacing: -.045em;
}

.auth-copy,
.auth-message {
  margin: 14px 0 22px;
  color: var(--auth-muted);
  line-height: 1.52;
}

.auth-form { display: grid; gap: 16px; margin-top: 22px; }

.auth-field { display: grid; gap: 7px; }

.auth-field label {
  color: var(--auth-text);
  font-size: .9rem;
  font-weight: 750;
}

.auth-field input {
  width: 100%;
  min-height: 50px;
  padding: 11px 14px;
  border: 1px solid var(--auth-border);
  border-radius: 14px;
  color: var(--auth-text);
  background: var(--auth-paper);
  outline: none;
}

.auth-field input:focus {
  border-color: var(--auth-copper);
  box-shadow: 0 0 0 3px rgba(185, 101, 67, .16);
}

.auth-password-wrap { position: relative; }
.auth-password-wrap input { padding-right: 78px; }

.auth-password-toggle {
  position: absolute;
  top: 50%;
  right: 7px;
  min-width: 62px;
  padding: 8px;
  border: 0;
  border-radius: 10px;
  color: var(--auth-wine);
  background: transparent;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 750;
}

.auth-check {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 10px;
  color: var(--auth-text);
  cursor: pointer;
  line-height: 1.4;
}

.auth-check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--auth-wine); }

.auth-primary,
.auth-link {
  min-height: 48px;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 800;
}

.auth-primary {
  border: 1px solid var(--auth-wine);
  color: white;
  background: var(--auth-wine);
  box-shadow: 0 10px 22px rgba(59, 9, 14, .2);
}

.auth-primary:hover { background: #501018; }
.auth-primary:disabled { cursor: wait; opacity: .64; }

.auth-link {
  border: 0;
  color: var(--auth-copper);
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-alert {
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 13px;
  font-size: .9rem;
  line-height: 1.45;
}

.auth-alert-info { color: #315b73; border-color: #b9d4e2; background: #edf7fb; }
.auth-alert-success { color: var(--auth-success); border-color: #b8d9c9; background: #eef8f2; }
.auth-alert-warning { color: var(--auth-warning); border-color: #e2cfa8; background: #fff8e8; }
.auth-alert-danger { color: var(--auth-danger); border-color: #e4b8be; background: #fff0f2; }
.auth-alert[hidden] { display: none; }

.auth-help {
  margin: 14px 0 0;
  color: var(--auth-muted);
  font-size: .84rem;
  line-height: 1.45;
}

.auth-build {
  margin: 24px 0 0;
  color: var(--auth-muted);
  font-size: .72rem;
  opacity: .8;
  text-align: center;
}

.auth-profile {
  display: grid;
  gap: 10px;
  margin: 24px 0 18px;
}

.auth-profile > div {
  display: grid;
  gap: 3px;
  padding: 13px 15px;
  border: 1px solid var(--auth-border);
  border-radius: 14px;
  background: var(--auth-paper);
}

.auth-profile span { color: var(--auth-muted); font-size: .78rem; }
.auth-profile strong { overflow-wrap: anywhere; }

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 24px 0 18px;
}

.catalog-item {
  display: grid;
  align-content: start;
  gap: 7px;
  padding: 16px;
  border: 1px solid var(--auth-border);
  border-radius: 16px;
  background: var(--auth-paper);
}

.catalog-image {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  margin-bottom: 4px;
  overflow: hidden;
  border: 1px solid var(--auth-border);
  border-radius: 12px;
  background: #eee7e1;
}

.catalog-image > img { width: 100%; height: 100%; display: block; object-fit: cover; }
.catalog-image.is-empty { display: grid; place-items: center; align-content: center; gap: 8px; color: var(--auth-muted); background: linear-gradient(145deg,#f8f3ee,#eee4dc); }
.catalog-image.is-empty img { width: 58px; height: 58px; border-radius: 14px; opacity: .55; }
.catalog-image.is-empty span { font-size: .75rem; font-weight: 750; }

.catalog-item > span { color: var(--auth-muted); font-size: .8rem; line-height: 1.4; }
.catalog-item > strong:not(.catalog-price) { font-size: 1.06rem; overflow-wrap: anywhere; }
.catalog-item p { margin: 0; color: var(--auth-text); font-size: .9rem; line-height: 1.45; }
.catalog-item .catalog-note { color: var(--auth-warning); }
.catalog-item.is-temporarily-unavailable { border-color: #d6b277; background: #fffaf1; }
.catalog-item .catalog-stock-status {
  justify-self: start;
  padding: 6px 10px;
  border: 1px solid #d6b277;
  border-radius: 999px;
  color: #6d4700;
  background: #fff1cf;
  font-size: .82rem;
  font-weight: 800;
  line-height: 1.2;
}
.catalog-item .catalog-price { align-self: end; margin-top: auto; padding-top: 3px; color: var(--auth-wine); font-size: 1.18rem; }

@media (max-width: 860px) {
  .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .auth-shell { align-items: start; padding: 14px 10px; }
  .auth-card { padding: 24px 20px; border-radius: 22px; }
  .auth-logo { width: 88px; height: 88px; border-radius: 20px; }
  .catalog-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}

.admin-shell { align-items: start; padding: 24px 14px; }
.admin-card { width: min(100%, 1180px); }
.admin-header { display: flex; align-items: center; gap: 20px; }
.admin-header .auth-copy { margin-bottom: 0; }
.admin-logo { flex: 0 0 auto; margin: 0; }
.admin-account-bar, .admin-section-heading, .admin-actions, .admin-check-grid { display: flex; align-items: center; gap: 12px; }
.admin-account-bar, .admin-section-heading { justify-content: space-between; margin: 24px 0 16px; }
.admin-account-bar > div, .admin-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.admin-account-bar button, .admin-actions button, .admin-record > button, .admin-subrecord button { min-height: 38px; padding: 8px 12px; border: 1px solid var(--auth-border); border-radius: 10px; color: var(--auth-wine); background: var(--auth-paper); cursor: pointer; font-weight: 750; }
.admin-nav { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 8px; margin: 22px 0; }
.admin-nav button { min-height: 46px; padding: 8px 10px; border: 1px solid var(--auth-border); border-radius: 12px; color: var(--auth-text); background: var(--auth-paper); cursor: pointer; font-weight: 750; }
.admin-nav button.is-active { border-color: var(--auth-wine); color: white; background: var(--auth-wine); }
.admin-content h2, .admin-content h3 { margin: 0; }
.admin-content p { color: var(--auth-muted); }
.admin-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(320px,.9fr); gap: 18px; align-items: start; }
.admin-grid-products { grid-template-columns: minmax(280px,.72fr) minmax(420px,1.28fr); }
.admin-grid-products > .admin-list { max-height: clamp(420px,calc(100vh - 340px),720px); overflow-y: auto; overscroll-behavior: contain; align-content: start; padding-right: 6px; scrollbar-gutter: stable; }
.admin-grid-products > .admin-editor { position: static; align-self: start; scroll-margin-top: 12px; }
.admin-list, .admin-editor { display: grid; gap: 12px; }
.admin-editor { position: sticky; top: 12px; padding: 18px; border: 1px solid var(--auth-border); border-radius: 16px; background: rgba(255,253,250,.72); }
.admin-record, .admin-catalog-row { padding: 15px; border: 1px solid var(--auth-border); border-radius: 15px; background: var(--auth-paper); }
.admin-record { display: grid; gap: 10px; }
.admin-record-compact { grid-template-columns: minmax(0,1fr) auto; align-items: center; }
.admin-product-record { grid-template-columns: 72px minmax(0,1fr) auto; }
.admin-product-thumbnail { width: 72px; aspect-ratio: 4 / 3; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--auth-border); border-radius: 10px; object-fit: cover; background: #eee7e1; }
.admin-product-thumbnail.is-empty { color: var(--auth-muted); font-size: .72rem; font-weight: 800; }
.admin-record h3 { margin-top: 7px; }
.admin-record p { margin: 5px 0 0; font-size: .88rem; }
.admin-subrecord { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 10px; border-top: 1px solid var(--auth-border); }
.admin-subrecord div, .admin-catalog-title { display: grid; gap: 3px; }
.admin-subrecord span, .admin-catalog-title span:last-child { color: var(--auth-muted); font-size: .82rem; }
.admin-status { display: inline-flex; width: fit-content; padding: 3px 8px; border-radius: 999px; font-size: .74rem; font-weight: 800; }
.admin-status.is-active { color: var(--auth-success); background: #e3f4ea; }
.admin-status.is-inactive { color: var(--auth-muted); background: #eee8e3; }
.auth-field select, .auth-field textarea, .admin-catalog-fields input:not([type="checkbox"]) { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--auth-border); border-radius: 12px; color: var(--auth-text); background: var(--auth-paper); outline: none; font: inherit; }
.auth-field textarea { resize: vertical; }
.admin-form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.admin-check-grid { flex-wrap: wrap; align-items: start; }
.admin-check-grid .auth-check { flex: 1 1 180px; }
.admin-product-photo { display: grid; grid-template-columns: minmax(180px,240px) 1fr; gap: 16px; align-items: start; padding: 14px; border: 1px solid var(--auth-border); border-radius: 15px; background: #fbf7f3; }
.admin-product-photo-preview { width: 100%; aspect-ratio: 4 / 3; overflow: hidden; border: 1px solid var(--auth-border); border-radius: 12px; background: #eee7e1; }
.admin-product-photo-preview > img { width: 100%; height: 100%; display: block; object-fit: cover; }
.admin-product-photo-empty { width: 100%; height: 100%; display: grid; place-items: center; align-content: center; gap: 8px; color: var(--auth-muted); }
.admin-product-photo-empty img { width: 64px; height: 64px; border-radius: 14px; opacity: .5; }
.admin-product-photo-empty span { font-size: .78rem; font-weight: 750; }
.admin-product-photo > div:last-child { display: grid; justify-items: start; gap: 8px; }
.admin-product-photo p { margin: 0; font-size: .85rem; line-height: 1.45; }
.admin-product-photo input[type="file"] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.admin-product-photo-button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 9px 14px; border: 1px solid var(--auth-wine); border-radius: 11px; color: white; background: var(--auth-wine); cursor: pointer; font-weight: 800; }
.admin-product-photo-button:hover { background: #501018; }
.admin-product-photo input[type="file"]:focus + .admin-product-photo-button { outline: 3px solid rgba(185,101,67,.24); outline-offset: 2px; }
.admin-inline-button { width: auto; min-width: 150px; padding: 8px 14px; }
.admin-customer-picker { max-width: 520px; margin-bottom: 14px; }
.admin-catalog-row { display: grid; gap: 14px; margin-top: 18px; border-color: #d9cbc0; box-shadow: 0 5px 16px rgba(59, 9, 14, .06); }
.admin-catalog-row[hidden] { display: none; }
.admin-catalog-tools { display: grid; grid-template-columns: minmax(0,1fr) minmax(240px,360px); align-items: end; gap: 12px; margin: 12px 0 14px; }
.admin-catalog-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.admin-catalog-filter { min-height: 40px; padding: 8px 13px; border: 1px solid var(--auth-border); border-radius: 999px; color: var(--auth-text); background: var(--auth-paper); cursor: pointer; font-weight: 750; }
.admin-catalog-filter strong { color: var(--auth-wine); }
.admin-catalog-filter.is-active { border-color: var(--auth-wine); color: white; background: var(--auth-wine); }
.admin-catalog-filter.is-active strong { color: white; }
.admin-catalog-title { gap: 6px; padding-bottom: 2px; }
.admin-catalog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.admin-catalog-heading > strong { color: var(--auth-text); font-size: 1.18rem; line-height: 1.25; overflow-wrap: anywhere; }
.admin-catalog-heading .admin-status { flex: 0 0 auto; margin-top: 1px; }
.admin-catalog-sku { color: var(--auth-muted); font-size: .82rem; line-height: 1.35; }
.admin-catalog-search { display: grid; gap: 5px; color: var(--auth-muted); font-size: .8rem; }
.admin-catalog-search input { width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--auth-border); border-radius: 12px; color: var(--auth-text); background: var(--auth-paper); outline: none; font: inherit; }
.admin-catalog-search input:focus { border-color: var(--auth-wine); box-shadow: 0 0 0 3px rgba(122,20,32,.12); }
.admin-catalog-inactive { margin: 0; }
.admin-price-choice { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px 14px; margin: 0; padding: 14px; border: 1px solid var(--auth-border); border-radius: 13px; background: #fbf7f3; }
.admin-price-choice legend { padding: 0 6px; color: var(--auth-text); font-size: .84rem; font-weight: 800; }
.admin-price-option { display: flex; align-items: center; gap: 9px; min-height: 42px; color: var(--auth-text); cursor: pointer; line-height: 1.35; }
.admin-price-option input { width: 18px; height: 18px; margin: 0; accent-color: var(--auth-wine); }
.admin-price-option strong { color: var(--auth-wine); }
.admin-price-custom { display: grid; grid-column: 2; width: min(100%, 320px); gap: 5px; color: var(--auth-muted); font-size: .8rem; }
.admin-price-custom input { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--auth-border); border-radius: 12px; color: var(--auth-text); background: var(--auth-paper); outline: none; font: inherit; }
.admin-price-custom input:disabled { color: var(--auth-muted); background: #eee8e3; cursor: not-allowed; opacity: .72; }
.admin-catalog-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)) auto; align-items: end; gap: 12px; }
.admin-catalog-fields > label:not(.admin-availability) { display: grid; gap: 5px; color: var(--auth-muted); font-size: .8rem; }
.admin-catalog-fields .admin-availability { display: inline-flex; align-items: center; gap: 8px; min-height: 46px; padding: 0 4px; color: var(--auth-text); font-size: .9rem; white-space: nowrap; }
.admin-catalog-fields .admin-availability input { width: 18px; height: 18px; min-height: 18px; margin: 0; padding: 0; }

.product-image-editor-open { overflow: hidden; }
.product-image-modal { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 16px; background: rgba(24,2,4,.78); }
.product-image-dialog { width: min(100%,780px); max-height: calc(100vh - 32px); overflow-y: auto; padding: 22px; border: 1px solid rgba(255,255,255,.5); border-radius: 22px; background: var(--auth-cream); box-shadow: 0 28px 70px rgba(0,0,0,.45); }
.product-image-dialog header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.product-image-dialog h2 { margin: 0; }
.product-image-dialog header button { width: 42px; height: 42px; border: 1px solid var(--auth-border); border-radius: 50%; color: var(--auth-wine); background: var(--auth-paper); cursor: pointer; font-size: 1.5rem; line-height: 1; }
.product-image-stage { width: 100%; margin-top: 14px; overflow: hidden; border: 2px solid white; border-radius: 15px; background: #1b1312; box-shadow: 0 0 0 1px var(--auth-border); }
.product-image-canvas { width: 100%; aspect-ratio: 4 / 3; display: block; cursor: grab; touch-action: none; }
.product-image-canvas.is-dragging { cursor: grabbing; }
.product-image-zoom { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 12px; margin-top: 16px; color: var(--auth-text); font-weight: 750; }
.product-image-zoom input { width: 100%; accent-color: var(--auth-wine); }
.product-image-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.product-image-actions button { min-height: 44px; padding: 9px 15px; border: 1px solid var(--auth-border); border-radius: 11px; cursor: pointer; font-weight: 800; }
.product-image-actions .auth-primary { border-color: var(--auth-wine); }
@media (max-width: 860px) { .admin-nav { grid-template-columns: repeat(2,minmax(0,1fr)); } .admin-grid, .admin-grid-products { grid-template-columns: 1fr; } .admin-editor { position: static; } .admin-grid-products > .admin-list { max-height: none; overflow: visible; overscroll-behavior: auto; padding-right: 0; scrollbar-gutter: auto; } }
@media (max-width: 560px) { .admin-header { align-items: flex-start; } .admin-account-bar, .admin-section-heading { align-items: flex-start; flex-direction: column; } .admin-nav, .admin-form-grid, .admin-price-choice, .admin-product-photo { grid-template-columns: 1fr; } .admin-price-custom { grid-column: 1; width: 100%; } .admin-price-custom input, .admin-catalog-fields input:not([type="checkbox"]) { font-size: 18px; font-weight: 600; } .admin-catalog-tools { grid-template-columns: 1fr; } .admin-catalog-filters { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); } .admin-catalog-filter { min-width: 0; padding: 7px 4px; font-size: .78rem; line-height: 1.2; } .admin-catalog-search input { font-size: 16px; } .admin-catalog-heading { gap: 10px; } .admin-catalog-heading > strong { font-size: 1.1rem; } .admin-catalog-fields { grid-template-columns: repeat(2,minmax(0,1fr)); } .admin-catalog-fields .admin-availability { grid-column: 1 / -1; justify-self: start; } .admin-record-compact { grid-template-columns: 1fr; } .admin-product-record { grid-template-columns: 64px minmax(0,1fr); } .admin-product-record > button { grid-column: 1 / -1; } .admin-product-thumbnail { width: 64px; } .admin-inline-button { width: 100%; } .product-image-modal { padding: 8px; } .product-image-dialog { max-height: calc(100vh - 16px); padding: 17px; border-radius: 18px; } .product-image-actions { display: grid; grid-template-columns: 1fr; } .product-image-actions .auth-primary { grid-row: 1; } }
