:root {
  --paper: #f8f5ee;
  --sand: #eee7dc;
  --olive: #424a32;
  --muted: #666a57;
  --bronze: #85633b;
  --line: #dad8ca;
  --danger: #8f3b2f;
  --ok: #3f6b3a;
  --sans: "Manrope", "Helvetica Neue", Arial, sans-serif;
  --serif: "Cormorant Garamond", Georgia, serif;
  --sidebar: 280px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--olive);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
  border: 0;
  background: none;
}

a { color: inherit; text-decoration: none; }

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

.admin-nav {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 28px 18px 24px;
  background: #efecdf;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.admin-brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 8px 16px;
  border-bottom: 1px solid var(--line);
}

.admin-brand strong {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 500;
}

.admin-brand span {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.4px;
}

.admin-nav__label {
  margin: 0 8px;
  color: var(--bronze);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.cat-list {
  display: grid;
  gap: 4px;
}

.cat-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px;
  min-height: 44px;
  padding: 2px;
  border-radius: 8px;
  color: #66675c;
}

.cat-row:hover { background: #e5e4d6; }
.cat-row.is-active {
  background: var(--olive);
  color: var(--paper);
}
.cat-row.is-dragging { opacity: 0.45; }
.cat-row.is-drag-over {
  outline: 1px dashed var(--bronze);
  outline-offset: 1px;
}

.cat-handle {
  width: 28px;
  height: 36px;
  border-radius: 6px;
  color: inherit;
  opacity: 0.55;
  cursor: grab;
  font-size: 12px;
  letter-spacing: -2px;
}
.cat-handle:active { cursor: grabbing; }
.cat-row.is-active .cat-handle { opacity: 0.8; }

.cat-select {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 40px;
  padding: 0 8px;
  border-radius: 6px;
  text-align: left;
  color: inherit;
  font-size: 13px;
  font-weight: 500;
}

.cat-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cat-thumb {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 6px;
  object-fit: contain;
  border: 0;
  background: transparent;
}

.cat-thumb--empty {
  border: 1px dashed rgba(66, 74, 50, 0.25);
  opacity: 0.45;
}

.cat-row.is-active .cat-thumb--empty {
  border-color: rgba(248, 245, 238, 0.35);
}

.cat-list .num {
  width: 22px;
  flex: 0 0 auto;
  opacity: 0.7;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.cat-move {
  display: grid;
  gap: 2px;
  padding-right: 4px;
}

.cat-move-btn {
  width: 24px;
  height: 18px;
  border-radius: 4px;
  color: inherit;
  opacity: 0.7;
  font-size: 11px;
  line-height: 1;
}
.cat-move-btn:hover { background: rgba(0, 0, 0, 0.08); }
.cat-row.is-active .cat-move-btn:hover { background: rgba(255, 255, 255, 0.14); }
.cat-move-btn:disabled { opacity: 0.25; cursor: default; }

.admin-nav__actions {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #f8f5ee;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover { background: #efeadd; }
.btn-primary {
  background: var(--olive);
  border-color: var(--olive);
  color: var(--paper);
}
.btn-primary:hover { background: #343b28; }
.btn-danger {
  color: var(--danger);
  border-color: #e2c4bd;
  background: #f8ece9;
}
.btn-ghost { background: transparent; }

.admin-main {
  padding: 28px 34px 60px;
}

.admin-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.admin-top h1 {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 40px;
  font-weight: 500;
  letter-spacing: -0.8px;
}

.admin-top p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.admin-top__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status {
  min-height: 20px;
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 12px;
}
.status.is-ok { color: var(--ok); }
.status.is-warn { color: var(--bronze); }

.panel {
  background: #f3efe4;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 18px;
}

.panel h2 {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
}

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

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--bronze);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8f5ee;
  padding: 11px 12px;
  outline: none;
}

.field input:focus,
.field textarea:focus {
  border-color: #b9b59f;
  box-shadow: 0 0 0 3px #424a3214;
}

.field textarea {
  min-height: 78px;
  resize: vertical;
  line-height: 1.5;
}

.field.full { grid-column: 1 / -1; }

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

.items-head h2 { margin: 0; }

.item-card {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.6fr) 120px auto;
  gap: 10px;
  align-items: start;
  padding: 12px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(248, 245, 238, 0.72);
}

.item-card .field label { font-size: 10px; }

.item-card .remove {
  align-self: end;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid #e2c4bd;
  color: var(--danger);
  background: #f8ece9;
  font-size: 12px;
  font-weight: 600;
}

.empty {
  color: var(--muted);
  font-size: 13px;
  padding: 18px 4px;
}

.branding-panel { margin-bottom: 18px; }

.branding-grid {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.category-image-row {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.category-image-box {
  display: grid;
  gap: 12px;
  justify-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(248, 245, 238, 0.8);
}

.category-image-box img {
  width: 120px;
  height: 120px;
  border-radius: 0;
  object-fit: contain;
  border: 0;
  background: transparent;
  filter: drop-shadow(0 6px 14px rgba(66, 74, 50, 0.14));
}

.category-image-placeholder {
  width: 120px;
  height: 120px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px dashed var(--line);
  background: #f8f5ee;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  padding: 12px;
}

.category-fields {
  align-content: start;
}

.logo-box {
  display: grid;
  gap: 12px;
  justify-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(248, 245, 238, 0.8);
}

.logo-box img {
  width: 100%;
  max-width: 170px;
  height: auto;
  object-fit: contain;
  background: #f8f5ee;
  border-radius: 10px;
}

.logo-actions {
  display: grid;
  gap: 8px;
  width: 100%;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

.branding-fields {
  align-content: start;
}

.pdf-preview {
  display: grid;
  gap: 12px;
  max-height: 360px;
  overflow: auto;
  padding: 4px;
}

.pdf-cat {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(248, 245, 238, 0.75);
  padding: 12px 14px;
}

.pdf-cat h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.pdf-cat ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.pdf-cat li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
}

.pdf-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.pdf-raw {
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
}

.pdf-raw pre {
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  background: #f8f5ee;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-size: 11px;
  line-height: 1.5;
}

.live-preview {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  min-height: 170px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--paper);
}

.live-preview__sidebar {
  background: var(--sand);
  border-right: 1px solid var(--line);
  padding: 14px 12px;
  display: grid;
  gap: 6px;
  align-content: start;
}

.live-preview__logo {
  margin-bottom: 8px;
  color: var(--olive);
  font-family: var(--serif);
  font-size: 18px;
}

.live-preview__nav {
  min-height: 28px;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 11px;
}

.live-preview__nav.is-active {
  background: var(--olive);
  color: var(--paper);
}

.live-preview__main {
  padding: 14px 16px;
  display: grid;
  gap: 10px;
  align-content: start;
}

.live-preview__card {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--sand);
}

.live-preview__card strong {
  font-size: 18px;
  font-family: var(--sans);
}

.live-preview__card span {
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 10px;
  background: color-mix(in srgb, var(--paper) 70%, transparent);
}

.live-preview__item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  color: var(--olive);
  font-size: 13px;
}

.live-preview__tagline {
  margin: 4px 0 0;
  color: var(--bronze);
  font-family: var(--serif);
  font-size: 20px;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preset-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f8f5ee;
  font-size: 12px;
  font-weight: 600;
}

.preset-chip.is-active {
  border-color: var(--olive);
  box-shadow: inset 0 0 0 1px var(--olive);
}

.preset-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.color-grid input[type="color"] {
  width: 100%;
  height: 42px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8f5ee;
  cursor: pointer;
}

#font-preset {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8f5ee;
  padding: 0 12px;
}

.font-preview {
  font-family: var(--serif);
  font-size: 22px;
  color: var(--olive);
}

@media (max-width: 980px) {
  .admin { grid-template-columns: 1fr; }
  .admin-nav {
    position: relative;
    height: auto;
    border-left: 0;
    border-bottom: 1px solid var(--line);
  }
  .admin-main { padding: 22px 16px 50px; }
  .grid-2,
  .item-card,
  .branding-grid,
  .category-image-row,
  .color-grid,
  .live-preview { grid-template-columns: 1fr; }

  .live-preview__sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
}

/* --- Auth / shops --- */
.gate-screen{min-height:100vh;display:grid;place-items:center;padding:28px 16px;background:radial-gradient(circle at top left,#efe8da,transparent 45%),var(--paper)}
.gate-screen[hidden],
.admin[hidden]{display:none !important}
.gate-card,.shops-shell{width:min(920px,100%)}
.gate-card{width:min(420px,100%);padding:28px;border:1px solid var(--line);border-radius:18px;background:#fff;display:grid;gap:14px}
.shops-header{display:flex;justify-content:space-between;gap:16px;align-items:flex-start;margin-bottom:18px}
.shops-header__actions,.shop-create__actions,.shop-card__actions{display:flex;gap:8px;flex-wrap:wrap}
.shop-create{margin-bottom:16px}
.shop-list{display:grid;gap:12px}
.shop-card{display:flex;justify-content:space-between;gap:16px;align-items:center;padding:18px;border:1px solid var(--line);border-radius:16px;background:#fff}
.shop-card h3{margin:0 0 6px;font-family:var(--serif);font-size:28px;font-weight:500}
.shop-card p{margin:0;color:var(--muted);font-size:13px}
.shop-card__meta{margin-top:8px !important}
.admin-nav__meta{display:grid;gap:8px}
.admin-status-field{margin:0 8px}
@media (max-width:720px){.shops-header,.shop-card{flex-direction:column;align-items:stretch}}
