/* ===== Magazin Menu — fresh grocery design system ===== */
@import url('https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@400;600;700;800&family=Rubik:wght@500;600;700&display=swap');

:root {
  --brand:        #2E9F53;
  --brand-ink:    #1E7A3E;
  --brand-soft:   #E7F6EC;
  --gold:         #C2740A;
  --bg:           #F6FAF5;
  --surface:      #FFFFFF;
  --surface-2:    #F2F8F2;
  --text:         #14261A;
  --muted:        #6B7D70;
  --border:       #E3EEE4;
  --border-strong:#D2E4D3;
  --ok:           #17805A;
  --shadow:       0 1px 2px rgba(20,40,26,.05), 0 12px 28px -18px rgba(20,40,26,.30);
  --shadow-lg:    0 24px 60px -26px rgba(20,40,26,.40);
  --radius:       18px;
  --radius-sm:    12px;
  --sans: 'Nunito Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --head: 'Rubik', var(--sans);
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand:#4ADE80; --brand-ink:#6EE7A0; --brand-soft:#14321F;
    --gold:#E9B24B;
    --bg:#0E1611; --surface:#16211A; --surface-2:#121C15;
    --text:#EAF5EC; --muted:#9DB3A3; --border:#23332A; --border-strong:#2E4436;
    --ok:#4ADE9E;
    --shadow:0 1px 2px rgba(0,0,0,.4), 0 16px 30px -20px rgba(0,0,0,.7);
    --shadow-lg:0 30px 70px -30px rgba(0,0,0,.8);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3 { font-family: var(--head); margin: 0; letter-spacing: -.01em; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

/* ---------- Header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 13px; flex: none;
  background: linear-gradient(140deg, var(--brand), var(--gold));
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 8px 18px -8px var(--brand);
}
.brand-mark svg { width: 24px; height: 24px; }
.brand-name { font-family: var(--head); font-weight: 700; font-size: 1.15rem; line-height: 1.05; }
.brand-sub { font-size: .74rem; color: var(--muted); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }

/* ---------- Search ---------- */
.search {
  position: relative; flex: 1 1 240px; min-width: 200px; max-width: 460px;
}
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 19px; height: 19px; color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; height: 46px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 0 44px 0 42px; font-size: 15px; font-weight: 600;
  transition: border-color .18s, box-shadow .18s;
}
.search input::placeholder { color: var(--muted); font-weight: 500; }
.search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.search .clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  border: 0; background: var(--muted); color: #fff; width: 26px; height: 26px;
  border-radius: 50%; display: none; place-items: center; font-size: 15px; line-height: 1;
}
.search.has-value .clear { display: grid; }

/* ---------- Language toggle ---------- */
.lang { display: inline-flex; flex: none; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 999px; padding: 3px; gap: 2px; }
.lang button { border: 0; background: transparent; color: var(--muted); font-family: var(--sans); font-weight: 800; font-size: 13px; padding: 8px 13px; border-radius: 999px; line-height: 1; transition: background .16s, color .16s; }
.lang button:hover { color: var(--text); }
.lang button.active { background: var(--brand); color: #fff; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 800; font-size: 15px; white-space: nowrap;
  transition: transform .12s ease, background .18s, box-shadow .18s, border-color .18s;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 19px; height: 19px; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 10px 22px -12px var(--brand); }
.btn-primary:hover { background: var(--brand-ink); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand-ink); }
.btn-icon { width: 46px; padding: 0; }
.btn-sm { height: 38px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }

/* ---------- Layout ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 22px 20px 96px; }
.section-head { display: flex; align-items: center; gap: 12px; margin: 6px 2px 14px; }
.section-head h2 { font-size: 1.05rem; }
.count-pill { font-size: .78rem; font-weight: 800; color: var(--muted); background: var(--surface); border: 1px solid var(--border); padding: 3px 10px; border-radius: 999px; }

/* ---------- Category chips ---------- */
.chips { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 12px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 40px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; gap: 8px;
  transition: background .16s, color .16s, border-color .16s;
}
.chip:hover { border-color: var(--brand); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 10px 20px -14px var(--brand); }
.chip .chip-x { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: rgba(0,0,0,.08); font-size: 13px; }
.chip.active .chip-x { background: rgba(255,255,255,.25); }

/* ---------- Product grid ---------- */
.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
  transition: transform .18s ease, box-shadow .18s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.card-media { position: relative; aspect-ratio: 4/3; background: var(--surface-2); overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.card:hover .card-media img { transform: scale(1.04); }
.card-cat {
  position: absolute; top: 10px; left: 10px; font-size: .72rem; font-weight: 800;
  background: color-mix(in srgb, var(--surface) 88%, transparent); color: var(--brand-ink);
  border: 1px solid var(--border); padding: 4px 9px; border-radius: 999px; backdrop-filter: blur(4px);
}
.sold-out { position: absolute; inset: 0; background: rgba(20,12,9,.55); color: #fff; display: grid; place-items: center; font-family: var(--head); font-weight: 700; letter-spacing: .04em; }
.card-body { padding: 13px 15px 15px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-name { font-family: var(--head); font-weight: 600; font-size: 1.02rem; line-height: 1.25; }
.card-desc { font-size: .86rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 4px; }
.price { font-family: var(--head); font-weight: 700; font-size: 1.18rem; color: var(--text); font-variant-numeric: tabular-nums; }
.price small { font-size: .72rem; font-weight: 700; color: var(--muted); }
.gram { font-size: .76rem; font-weight: 800; color: var(--gold); background: color-mix(in srgb, var(--gold) 12%, transparent); padding: 3px 9px; border-radius: 999px; }

/* admin per-card actions */
.card-actions { display: flex; gap: 8px; padding: 0 15px 15px; }
.card-actions .btn { flex: 1; }
.btn-danger { background: var(--surface); color: #C23; border-color: var(--border-strong); }
.btn-danger:hover { background: #FDECEC; border-color: #E7A; color: #B4232B; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty .emo { width: 74px; height: 74px; margin: 0 auto 16px; border-radius: 22px; background: var(--surface); border: 1px solid var(--border); display: grid; place-items: center; color: var(--brand); box-shadow: var(--shadow); }
.empty .emo svg { width: 34px; height: 34px; }
.empty h3 { font-size: 1.15rem; color: var(--text); margin-bottom: 6px; }

/* ---------- Modal ---------- */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(28,16,12,.5); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 18px; opacity: 0; pointer-events: none; transition: opacity .2s; }
.overlay.open { opacity: 1; pointer-events: auto; }
.modal { width: 100%; max-width: 560px; max-height: 92dvh; overflow: auto; background: var(--surface); border-radius: 22px; border: 1px solid var(--border); box-shadow: var(--shadow-lg); transform: translateY(12px) scale(.98); transition: transform .22s ease; }
.overlay.open .modal { transform: none; }
.modal-head { position: sticky; top: 0; background: var(--surface); display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 1.2rem; }
.modal-close { border: 0; background: var(--surface-2); width: 36px; height: 36px; border-radius: 50%; color: var(--muted); font-size: 20px; display: grid; place-items: center; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.modal-foot { position: sticky; bottom: 0; background: var(--surface); padding: 16px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; }
.modal-foot .btn { flex: 1; }

/* ---------- Form ---------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-weight: 800; font-size: 13.5px; }
.field .req { color: var(--brand); }
.field .hint { font-weight: 600; font-size: 12px; color: var(--muted); }
.field input[type=text], .field input[type=number], .field textarea, .field select {
  width: 100%; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  border-radius: 12px; padding: 12px 14px; font-size: 15px; font-family: inherit; font-weight: 600;
  transition: border-color .16s, box-shadow .16s;
}
.field textarea { resize: vertical; min-height: 74px; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* image dropzone */
.drop { border: 2px dashed var(--border-strong); border-radius: 16px; background: var(--surface-2); aspect-ratio: 16/10; display: grid; place-items: center; text-align: center; color: var(--muted); overflow: hidden; position: relative; cursor: pointer; transition: border-color .16s, background .16s; }
.drop:hover { border-color: var(--brand); }
.drop.dragover { border-color: var(--brand); background: var(--brand-soft); }
.drop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.drop .ph { display: grid; gap: 8px; justify-items: center; padding: 16px; }
.drop .ph svg { width: 34px; height: 34px; color: var(--brand); }
.drop .ph b { color: var(--text); }
.drop .change { position: absolute; bottom: 10px; right: 10px; background: rgba(0,0,0,.62); color: #fff; font-size: 12px; font-weight: 800; padding: 6px 11px; border-radius: 999px; }

/* toggle */
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface-2); }
.toggle .t-label b { display: block; font-size: 14px; }
.toggle .t-label span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: background .18s; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; background: #fff; border-radius: 50%; box-shadow: 0 2px 5px rgba(0,0,0,.25); transition: transform .18s; }
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(20px); }

/* ---------- QR modal ---------- */
.qr-box { text-align: center; display: flex; flex-direction: column; gap: 16px; align-items: center; }
.qr-frame { padding: 16px; background: #fff; border-radius: 20px; border: 1px solid var(--border); box-shadow: var(--shadow); }
.qr-frame img { width: 240px; height: 240px; }
.qr-link { font-weight: 800; color: var(--brand-ink); word-break: break-all; font-size: 14px; background: var(--surface-2); border: 1px solid var(--border); padding: 10px 14px; border-radius: 12px; width: 100%; }
.qr-note { font-size: 13.5px; color: var(--muted); font-weight: 600; max-width: 360px; }

/* category manager rows */
.cat-manage { display: flex; flex-direction: column; gap: 10px; }
.cat-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.cat-row input { flex: 1; border: 1px solid transparent; background: transparent; color: var(--text); font-size: 15px; font-weight: 700; font-family: inherit; padding: 6px 8px; border-radius: 8px; }
.cat-row input:focus { outline: none; border-color: var(--border-strong); background: var(--surface); }
.cat-row .ico-btn { border: 0; background: transparent; color: var(--muted); width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; }
.cat-row .ico-btn:hover { background: var(--surface); color: var(--brand-ink); }
.cat-row .ico-btn svg { width: 18px; height: 18px; }
.add-cat { display: flex; gap: 10px; }
.add-cat input { flex: 1; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); border-radius: 12px; padding: 12px 14px; font-size: 15px; font-weight: 600; font-family: inherit; }
.add-cat input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; left: 0; right: 0; bottom: 22px; z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); font-weight: 700; font-size: 14px; padding: 12px 18px; border-radius: 999px; box-shadow: var(--shadow-lg); transform: translateY(10px); opacity: 0; transition: all .22s; display: flex; align-items: center; gap: 8px; }
.toast.show { transform: none; opacity: 1; }
.toast svg { width: 18px; height: 18px; color: var(--ok); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Mobile (phones) ---------- */
@media (max-width: 640px) {
  .topbar-inner { padding: 10px 12px; gap: 10px; row-gap: 10px; }
  .brand { gap: 10px; }
  .brand-mark { width: 38px; height: 38px; border-radius: 11px; }
  .brand-name { font-size: 1.02rem; }
  .brand-sub { display: none; }
  .wrap { padding: 14px 12px calc(90px + env(safe-area-inset-bottom)); }
  .chips { padding: 2px 2px 10px; gap: 8px; }
  .chip { height: 38px; }
  .grid { gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .search input { height: 44px; }
  .row2 { grid-template-columns: 1fr 1fr; }
  .lang button { padding: 8px 11px; font-size: 12.5px; }
  .btn { height: 44px; }
  .btn-icon { width: 44px; }
  .card-name { font-size: .96rem; }
  .price { font-size: 1.08rem; }
  .qr-frame img { width: min(62vw, 220px); height: min(62vw, 220px); }
  .hide-sm { display: none; }
  /* full-height sheet-style modals on phones */
  .overlay { padding: 0; align-items: flex-end; }
  .modal { max-width: none; max-height: 94dvh; border-radius: 22px 22px 0 0; }
  .modal-foot { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
}
@media (max-width: 380px) {
  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
}
