:root {
  --bg: #faf6f0;
  --surface: #ffffff;
  --ink: #23201c;
  --ink-soft: #6f675c;
  --line: #e8e0d5;
  --brand: #1f6f4a;
  --brand-dark: #175636;
  --brand-soft: #e3f1e9;
  --accent: #e0632a;
  --accent-soft: #fdeadf;
  --danger: #c0392b;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(35, 32, 28, .06), 0 10px 30px rgba(35, 32, 28, .07);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: min(1120px, calc(100% - 40px)); margin-inline: auto; }

a { color: var(--brand); }

button { font-family: inherit; cursor: pointer; }

input, select, textarea { font-family: inherit; font-size: 15px; }

:focus-visible { outline: 3px solid rgba(31, 111, 74, .35); outline-offset: 2px; }

#offlineNotice {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 11px;
  background: var(--accent-soft);
  border: 1px solid #f3c9ae;
  color: #9a4318;
  font-size: 13px;
  font-weight: 600;
}

#offlineNotice[hidden] { display: none; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(250, 246, 240, .9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-block: 14px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }

.brand-logo {
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: 14px;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 26px;
  overflow: hidden;
}

.brand-logo img { width: 100%; height: 100%; object-fit: cover; }

.brand h1 { font-size: 21px; margin: 0; letter-spacing: -.02em; }

.brand p { margin: 0; font-size: 13.5px; color: var(--ink-soft); }

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

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid rgba(31, 111, 74, .18);
  white-space: nowrap;
}

.pill.muted { background: #f1ece4; color: var(--ink-soft); border-color: var(--line); }

.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 11px;
  padding: 10px 16px;
  font-size: 14.5px;
  font-weight: 600;
  transition: transform .06s ease, background .15s ease, border-color .15s ease;
}

.btn:hover { border-color: #d6cbbd; background: #fffdf9; }

.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }

.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }

.btn-accent:hover { background: #c9541f; border-color: #c9541f; }

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

.btn-danger:hover { background: #fdf1ef; border-color: #eab3ab; }

.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }

.btn-icon { padding: 8px 10px; }

.btn:disabled { opacity: .55; cursor: not-allowed; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin: 26px 0 20px;
}

.search {
  position: relative;
  flex: 1 1 260px;
  max-width: 420px;
}

.search input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.search svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--ink-soft);
}

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

.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13.5px;
  font-weight: 600;
}

.chip:hover { border-color: #d6cbbd; }

.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
  padding-bottom: 40px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: transform .12s ease, box-shadow .12s ease;
}

.card:hover { transform: translateY(-3px); box-shadow: 0 2px 4px rgba(35,32,28,.05), 0 16px 40px rgba(35,32,28,.12); }

.card-media {
  position: relative;
  aspect-ratio: 16 / 10;
  background: linear-gradient(135deg, #f4ede2, #eae0cf);
  display: grid;
  place-items: center;
  font-size: 54px;
}

.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }

.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 7px; flex: 1; }

.card-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }

.card-title h3 { margin: 0; font-size: 16.5px; letter-spacing: -.01em; }

.price { font-size: 16px; font-weight: 800; color: var(--brand-dark); white-space: nowrap; }

.card-desc { margin: 0; font-size: 13.5px; color: var(--ink-soft); flex: 1; }

.tag {
  align-self: flex-start;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-soft);
  background: #f4efe7;
  border-radius: 999px;
  padding: 4px 10px;
}

.card.out { opacity: .78; }

.card.out .card-media { filter: grayscale(.7); }

.badge-out {
  position: absolute;
  inset: auto 10px 10px auto;
  background: rgba(35, 32, 28, .88);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 8px;
}

.empty {
  text-align: center;
  padding: 70px 20px;
  color: var(--ink-soft);
  grid-column: 1 / -1;
}

.empty .big { font-size: 46px; margin-bottom: 10px; }

.site-footer {
  border-top: 1px solid var(--line);
  padding: 22px 0 34px;
  color: var(--ink-soft);
  font-size: 13px;
  text-align: center;
}

.admin-main { padding-block: 26px 60px; }

.admin-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  align-items: start;
}

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

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.panel + .panel { margin-top: 20px; }

.admin-grid .panel + .panel { margin-top: 0; }

.panel h2 { margin: 0 0 4px; font-size: 17px; letter-spacing: -.01em; }

.panel .hint { margin: 0 0 16px; font-size: 13px; color: var(--ink-soft); }

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

.qr-box {
  width: 208px;
  height: 208px;
  margin: 0 auto 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 10px;
}

.qr-box img, .qr-box canvas { width: 100% !important; height: 100% !important; display: block; }

.qr-box table { margin: 0 auto; }

.qr-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.qr-actions .btn { flex: 1 1 auto; }

.field { display: block; margin-bottom: 14px; }

.field span { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; color: var(--ink); }

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

.field input:focus, .field textarea:focus { border-color: var(--brand); background: #fff; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

@media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }

.check { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; margin: 4px 0 16px; }

.check input { width: 18px; height: 18px; accent-color: var(--brand); }

.emoji-picks { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }

.emoji-pick {
  border: 1px solid var(--line);
  background: #fffdf9;
  border-radius: 10px;
  font-size: 19px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
}

.emoji-pick:hover, .emoji-pick.active { border-color: var(--brand); background: var(--brand-soft); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }

.stat { background: #faf6f0; border: 1px solid var(--line); border-radius: 12px; padding: 12px; }

.stat b { display: block; font-size: 21px; letter-spacing: -.02em; }

.stat span { font-size: 12px; color: var(--ink-soft); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }

table.items { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }

table.items th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-soft);
  padding: 11px 14px;
  background: #faf6f0;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

table.items td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }

table.items tr:last-child td { border-bottom: 0; }

table.items tbody tr:hover { background: #fffdf9; }

.item-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }

.thumb {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #f4ede2, #eae0cf);
  display: grid;
  place-items: center;
  font-size: 22px;
  overflow: hidden;
  border: 1px solid var(--line);
}

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

.item-cell b { display: block; font-size: 14.5px; }

.item-cell small { color: var(--ink-soft); font-size: 12.5px; }

.switch { position: relative; display: inline-block; width: 44px; height: 25px; flex: none; }

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute; inset: 0;
  background: #ddd3c6; border-radius: 999px;
  transition: background .15s ease;
}

.slider::before {
  content: "";
  position: absolute;
  width: 19px; height: 19px;
  left: 3px; top: 3px;
  background: #fff; border-radius: 50%;
  transition: transform .15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}

.switch input:checked + .slider { background: var(--brand); }

.switch input:checked + .slider::before { transform: translateX(19px); }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.status-live { color: var(--brand-dark); font-size: 13px; font-weight: 700; }

.status-off { color: var(--ink-soft); font-size: 13px; font-weight: 700; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(35, 32, 28, .55);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
  overflow-y: auto;
}

.modal-backdrop[hidden] { display: none; }

.modal {
  background: var(--surface);
  border-radius: 18px;
  width: min(520px, 100%);
  box-shadow: 0 30px 80px rgba(0,0,0,.35);
  padding: 22px;
  margin-block: auto;
}

.modal h2 { margin: 0 0 4px; font-size: 19px; }

.modal .hint { margin: 0 0 18px; }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }

.modal-actions .btn { min-width: 110px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 12px 40px rgba(0,0,0,.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 80;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.toast.error { background: var(--danger); }

.copy-note { font-size: 12.5px; color: var(--brand-dark); font-weight: 600; min-height: 18px; margin-top: 8px; }

.auth-notice {
  min-height: 55vh;
  display: grid;
  place-items: center;
  padding: 30px 0;
}

.auth-notice[hidden] { display: none; }

.auth-notice .panel { max-width: 520px; width: 100%; }

body[data-authed="false"] .admin-grid,
body[data-authed="false"] #logoutBtn { display: none; }

.login-main {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 20px;
}

.login-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-error {
  margin: 14px 0 0;
  padding: 10px 13px;
  border-radius: 10px;
  background: #fdf1ef;
  border: 1px solid #f0c8c2;
  color: var(--danger);
  font-size: 13.5px;
  font-weight: 600;
}

.login-foot {
  margin: 20px 0 0;
  font-size: 13px;
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.7;
}

@media print {
  .site-header, .toolbar, .site-footer, .badge-out { display: none; }
  body { background: #fff; }
  .card { box-shadow: none; break-inside: avoid; }
}
