@import url('https://fonts.googleapis.com/css2?family=Saira:wght@400;500;600;700;800&display=swap');

:root {
  --ink: #050505;
  --graphite: #262626;
  --muted: #737373;
  --surface: #f6f4ef;
  --bone: #fbfaf7;
  --line: #e8e3d8;
  --accent: #b59b6b;
  --danger: #b42318;
  --shadow: 0 22px 70px rgba(5, 5, 5, 0.1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Saira, system-ui, sans-serif;
  background: var(--surface);
  color: var(--ink);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select { font: inherit; }

button {
  cursor: pointer;
  border: 0;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font-size: 0.84rem;
  font-weight: 700;
  min-height: 34px;
  padding: 0.45rem 0.72rem;
  transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

button:hover {
  transform: translateY(-1px);
  background: #1b1b1b;
  box-shadow: 0 16px 40px rgba(5, 5, 5, 0.16);
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #ded8cb;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 0.84rem;
  min-height: 34px;
  padding: 0.35rem 0.5rem;
  outline: none;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 4px rgba(5, 5, 5, 0.08);
}

textarea { min-height: 64px; }

label {
  display: block;
  color: var(--graphite);
  font-size: 0.82rem;
  font-weight: 800;
}

label input,
label textarea,
label select {
  margin-top: 0.28rem;
}

.hidden {
  display: none !important;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
  background:
    radial-gradient(circle at 20% 12%, rgba(181, 155, 107, 0.22), transparent 28%),
    linear-gradient(135deg, #050505, #171717 55%, #050505);
}

.login-shell {
  width: min(460px, 100%);
  display: grid;
  gap: 0;
}

.card {
  background: rgba(251, 250, 247, 0.94);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.7rem;
  box-shadow: var(--shadow);
  animation: fadeUp 0.55s ease both;
}

.login-card {
  width: min(100%, 460px);
  padding: 0.85rem;
  border: 1px solid rgba(232, 227, 216, 0.9);
  background: linear-gradient(165deg, rgba(251, 250, 247, 0.98), rgba(251, 250, 247, 0.9));
}

.login-card h1 {
  margin: 0.2rem 0 0.9rem;
  font-size: clamp(1.55rem, 5vw, 2.2rem);
  line-height: 0.95;
  letter-spacing: -0.06em;
}

.login-card form,
.form-card {
  display: grid;
  gap: 0.75rem;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.error {
  color: var(--danger);
  font-weight: 700;
}

.admin {
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  background: var(--ink);
  color: #fff;
  padding: 0.65rem;
}

.sidebar h1 {
  flex: 0 0 auto;
  margin: 0;
  padding: 0.55rem 0.7rem;
  font-size: 0.95rem;
  letter-spacing: -0.04em;
}

.sidebar button {
  flex: 0 0 auto;
  justify-content: flex-start;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.78);
  box-shadow: none;
}

.sidebar button.active {
  background: #fff;
  color: var(--ink);
}

.content {
  padding: 0.7rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.7rem;
}

.alerts {
  position: fixed;
  left: 50%;
  top: 0.8rem;
  transform: translateX(-50%);
  z-index: 9999;
  width: min(calc(100% - 1rem), 560px);
  display: grid;
  gap: 0.45rem;
  margin: 0;
  pointer-events: none;
}

.alert {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 800;
  padding: 0.55rem 0.7rem;
  box-shadow: 0 10px 24px rgba(5, 5, 5, 0.045);
  pointer-events: auto;
}

.alert.success {
  border-color: #cfc5b1;
}

.alert.error {
  border-color: #e3b4ad;
  color: var(--danger);
}

.topbar h2 {
  margin: 0.1rem 0 0;
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  line-height: 0.95;
  letter-spacing: -0.06em;
}

.grid {
  display: grid;
  gap: 0.8rem;
}

.list {
  display: grid;
  gap: 0.6rem;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(251, 250, 247, 0.78);
  padding: 0.55rem 0.62rem;
}

.section-head p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.products-toolbar {
  display: grid;
  gap: 0.45rem;
  grid-template-columns: 1fr;
  margin-bottom: 0.45rem;
}

.products-count {
  margin: 0 0 0.55rem;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--muted);
}

.item {
  display: grid;
  gap: 0.6rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(251, 250, 247, 0.94);
  padding: 0.55rem;
  box-shadow: 0 12px 35px rgba(5, 5, 5, 0.05);
  animation: fadeUp 0.5s ease both;
}

.item-product {
  grid-template-columns: 56px 1fr;
  gap: 0.55rem;
  align-items: center;
}

.item-media {
  display: flex;
  align-items: center;
  justify-content: center;
}

.item-thumb {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  border: 1px solid var(--line);
  object-fit: cover;
  background: #fff;
}

.item-thumb-placeholder {
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--muted);
  background: linear-gradient(145deg, #f8f5ee, #ece7dc);
}

.item strong {
  font-size: 0.98rem;
  letter-spacing: -0.03em;
}

.item-heading-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.item-status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.45rem;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.item-status-promo {
  border: 1px solid #b7dfcc;
  background: #ebfff5;
  color: #157347;
}

.item-status-neutral {
  border: 1px solid #ddd6c8;
  background: #f6f4ee;
  color: #666154;
}

.item p {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-self: start;
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.55rem;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--graphite);
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.3rem 0.55rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(5, 5, 5, 0.42);
  backdrop-filter: blur(8px);
}

.modal {
  position: fixed;
  inset: 0.4rem;
  z-index: 50;
  display: grid;
  place-items: start center;
  overflow-y: auto;
  padding: 0.4rem 0;
}

.modal .card {
  width: min(100%, 720px);
}

.modal-head,
.builder-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.modal-head h3,
.builder-head h4 {
  margin: 0.15rem 0 0;
  font-size: 1rem;
  letter-spacing: -0.05em;
}

.builder-head p {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.form-grid {
  display: grid;
  gap: 0.7rem;
}

.field-builder {
  display: grid;
  gap: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.54);
  padding: 0.42rem;
}

.field-rows {
  display: grid;
  gap: 0.35rem;
}

.field-row {
  display: grid;
  gap: 0.35rem;
  grid-template-columns: 1fr;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0.1rem;
}

.field-row button {
  min-height: 34px;
  padding: 0.35rem 0.52rem;
}

.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.secondary:hover {
  background: #f8f5ee;
  color: var(--ink);
  box-shadow: none;
}

.danger {
  background: var(--danger);
  color: #fff;
}

.danger:hover {
  background: #8f1d14;
  color: #fff;
}

.sidebar button:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  box-shadow: none;
}

.sidebar button.active:hover {
  background: #fff;
  color: var(--ink);
}

.asterisk {
  color: var(--danger);
  display: inline;
  font-size: 0.9rem;
  line-height: 1;
  margin-left: 0.08rem;
  vertical-align: baseline;
}

.empty-admin {
  display: grid;
  place-items: center;
  gap: 0.45rem;
  border: 1px dashed #d5cbb8;
  border-radius: 12px;
  background: rgba(251, 250, 247, 0.72);
  padding: 0.95rem;
  text-align: center;
  color: var(--muted);
}

.empty-admin strong {
  color: var(--ink);
}

.stats {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.stat {
  border-radius: 12px;
  background: rgba(251, 250, 247, 0.94);
  padding: 0.55rem;
  border: 1px solid var(--line);
  box-shadow: 0 12px 35px rgba(5, 5, 5, 0.05);
}

.stat strong {
  display: block;
  font-size: 1.45rem;
  letter-spacing: -0.06em;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.checkbox input {
  width: auto;
}

button:disabled,
.is-loading {
  opacity: 0.62;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

@media (min-width: 900px) {
  .admin {
    display: grid;
    grid-template-columns: 260px 1fr;
  }

  .sidebar {
    min-height: 100vh;
    align-content: start;
    align-items: stretch;
    flex-direction: column;
    overflow-x: visible;
    padding: 1rem;
  }

  .content {
    padding: 1rem;
  }

  .products-toolbar {
    grid-template-columns: 1fr 220px 190px;
  }

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

  .field-row {
    grid-template-columns: minmax(150px, 0.8fr) minmax(180px, 1fr) auto auto;
  }

  .two {
    grid-template-columns: minmax(360px, 440px) 1fr;
    align-items: start;
  }

  .item-product {
    grid-template-columns: 56px minmax(0, 1fr) auto;
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}
