/* ===== Сагс — brand tokens ===== */
:root {
  --deep: #015312;      /* Deep Green — лого, гарчиг */
  --green: #64B601;     /* SAGS Green — товч, гол элемент */
  --green-2: #57a000;
  --cream: #FAF4E6;     /* Дулаан суурь */
  --red: #FB4640;       /* Хямдрал, урамшуулал */
  --ink: #13261a;
  --muted: #5d6b61;
  --line: #ece5d4;
  --bg: #ffffff;
  --card: #ffffff;
  --radius: 18px;
  --shadow: 0 6px 24px rgba(1, 83, 18, .08);
  --font: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
/* Утасны дээд захын зайг (notch) толгойн өнгөөр будна */
body::before {
  content: ""; position: fixed; inset: 0 0 auto; z-index: 45;
  height: env(safe-area-inset-top, 0px); background: #fff;
}
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
h1, h2, h3, h4 { margin: 0; }

.wrap { width: min(1200px, 100% - 32px); margin-inline: auto; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 10px 18px;
  font-weight: 700; font-size: 14px; transition: .18s ease;
}
.btn--primary { background: var(--green); color: #fff; }
.btn--primary:hover { background: var(--green-2); transform: translateY(-1px); }
.btn--ghost { background: transparent; color: var(--deep); border: 2px solid var(--deep); }
.btn--ghost:hover { background: var(--deep); color: #fff; }
.btn--lg { padding: 14px 26px; font-size: 15px; }
.btn--block { width: 100%; }

/* ===== Top bar ===== */

/* ===== Header ===== */
.header {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 40;
  background: rgba(255,255,255,.96); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.header__in { display: flex; align-items: center; gap: 16px; padding: 12px 0; }
.logo img { height: 46px; width: auto; }

.search {
  flex: 1; display: flex; align-items: center; gap: 10px;
  background: var(--cream); border: 2px solid transparent; border-radius: 999px;
  padding: 0 16px; height: 46px; transition: .18s;
}
.search:focus-within { border-color: var(--green); background: #fff; }
.search svg { width: 20px; height: 20px; fill: none; stroke: var(--deep); stroke-width: 2.2; stroke-linecap: round; flex: none; }
.search input { flex: 1; border: 0; background: transparent; outline: 0; font: inherit; font-size: 14px; color: var(--ink); min-width: 0; }

.addr {
  display: flex; align-items: center; gap: 8px; text-align: left;
  background: none; border: 0; padding: 6px 8px; border-radius: 12px; color: var(--ink);
}
.addr { cursor: pointer; }
.addr:hover, .addr:focus-visible { background: var(--cream); outline: 0; }
.addr__input {
  font: inherit; font-size: 13px; font-weight: 700; color: var(--ink); width: 180px;
  border: 1.5px solid var(--green); border-radius: 8px; padding: 2px 6px; background: #fff; outline: 0;
}
.addr svg { width: 22px; height: 22px; fill: none; stroke: var(--green); stroke-width: 2.2; }
.addr small { display: block; font-size: 11px; color: var(--muted); }
.addr b { font-size: 13px; white-space: nowrap; }

.cart-btn {
  position: relative; display: flex; align-items: center; gap: 10px;
  background: var(--deep); color: #fff; border: 0; border-radius: 999px;
  padding: 8px 18px 8px 12px; height: 46px; transition: .18s;
}
.cart-btn:hover { background: #02691a; }
.cart-btn svg { width: 24px; height: 24px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cart-btn__count {
  position: absolute; top: -4px; left: 26px;
  min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px;
  background: var(--red); color: #fff; font-size: 11px; font-weight: 800;
  display: grid; place-items: center; border: 2px solid #fff;
}
.cart-btn__sum { font-weight: 800; font-size: 14px; }
.cart-btn.bump { animation: bump .4s ease; }
@keyframes bump { 40% { transform: scale(1.08); } }

/* Category nav */
.catnav { border-top: 1px solid var(--line); }
.catnav__in { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding: 6px 0; }
.catnav__in::-webkit-scrollbar { display: none; }
.catnav button {
  flex: none; background: none; border: 0; padding: 8px 14px; border-radius: 999px;
  font-size: 14px; font-weight: 600; color: var(--ink); white-space: nowrap;
}
.catnav button:hover { background: var(--cream); }
.catnav button.active { background: var(--green); color: #fff; }

/* ===== Hero (зөвхөн баннер зураг) ===== */
.hero { margin-top: 20px; }
.hero__viewport {
  position: relative; overflow: hidden; border-radius: 28px; background: var(--cream);
  aspect-ratio: 3 / 1; touch-action: pan-y;
}
.hero__track { display: flex; height: 100%; transition: transform .6s cubic-bezier(.4, 0, .2, 1); }
.hero__slide { flex: 0 0 100%; height: 100%; }
.hero__slide img { display: block; width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-drag: none; }
.hero__dots { position: absolute; left: 0; right: 0; bottom: 14px; display: flex; justify-content: center; gap: 6px; }
.hero__dots button {
  width: 9px; height: 9px; padding: 0; border: 0; border-radius: 99px;
  background: rgba(255, 255, 255, .6); box-shadow: 0 0 0 1px rgba(0, 0, 0, .1); transition: width .3s, background .3s;
}
.hero__dots button.active { width: 24px; background: #fff; }
.hero__nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 42px; height: 42px; border: 0; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255, 255, 255, .9); color: var(--deep); font-size: 28px; line-height: 1; padding-bottom: 3px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .14); opacity: 0; transition: opacity .2s;
}
.hero__nav--prev { left: 16px; }
.hero__nav--next { right: 16px; }
.hero:hover .hero__nav, .hero__nav:focus-visible { opacity: 1; }
.hero--single .hero__nav, .hero--single .hero__dots { display: none; }
@media (prefers-reduced-motion: reduce) { .hero__track { transition: none; } }
.pill {
  display: inline-block; background: #fff; color: var(--deep);
  font-size: 12px; font-weight: 700; padding: 6px 12px; border-radius: 999px; margin-bottom: 16px;
}
@keyframes run { 50% { transform: translateY(-10px) rotate(-2deg); } }

/* ===== Sections ===== */
.section { margin-top: 44px; }
.section__head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.section__head h2 { font-size: 24px; font-weight: 800; color: var(--deep); }

/* Category tiles */
.cats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.cat {
  background: var(--cream); border: 0; border-radius: var(--radius);
  padding: 18px 8px 14px; display: flex; flex-direction: column; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 700; color: var(--ink); transition: .18s; text-align: center;
}
.cat span { font-size: 40px; line-height: 1; transition: .25s; }
.cat:hover { background: #eef7e0; transform: translateY(-3px); }
.cat:hover span { transform: scale(1.12) rotate(-6deg); }

/* Tabs */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button {
  border: 1.5px solid var(--line); background: #fff; color: var(--ink);
  padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
}
.tabs button:hover { border-color: var(--green); }
.tabs button.active { background: var(--deep); border-color: var(--deep); color: #fff; }

/* Product grid */
.grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; display: flex; flex-direction: column; transition: .18s;
}
.card:hover { box-shadow: var(--shadow); border-color: transparent; }
.card__img {
  position: relative; aspect-ratio: 1; border-radius: 14px; display: grid; place-items: center;
  font-size: 64px; margin-bottom: 12px; overflow: hidden;
}
.card__img img { width: 100%; height: 100%; object-fit: cover; }
.badge {
  position: absolute; top: 8px; left: 8px; background: var(--red); color: #fff;
  font-size: 12px; font-weight: 800; padding: 3px 8px; border-radius: 8px;
}
.card__name { font-size: 14px; font-weight: 600; line-height: 1.35; min-height: 38px; }
.card__unit { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card__price { display: flex; align-items: baseline; gap: 8px; margin: 10px 0 12px; flex-wrap: wrap; }
.card__price b { font-size: 17px; font-weight: 800; color: var(--deep); }
.card__price s { font-size: 12px; color: #9aa59d; }
.card .add { margin-top: auto; }
.card.out { opacity: .55; }
.card.out .add { background: #d9d9d9; color: #666; cursor: not-allowed; transform: none; }

.qty {
  margin-top: auto; display: flex; align-items: center; justify-content: space-between;
  background: #eef7e0; border-radius: 999px; padding: 4px;
}
.qty button {
  width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--green); color: #fff;
  font-size: 18px; font-weight: 800; display: grid; place-items: center;
}
.qty button:hover { background: var(--green-2); }
.qty b { font-size: 15px; color: var(--deep); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.signin-note {
  display: flex; align-items: center; gap: 24px;
  background: var(--cream); border-radius: 24px; padding: 28px 32px;
}
.signin-note img { width: 96px; flex: none; }
.signin-note h3 { font-size: 20px; font-weight: 800; color: var(--deep); margin-bottom: 6px; }
.signin-note p { margin: 0 0 16px; color: var(--muted); line-height: 1.55; max-width: 560px; }
@media (max-width: 640px) {
  .signin-note { flex-direction: column; text-align: center; padding: 24px 20px; gap: 12px; }
  .signin-note img { width: 80px; }
}

/* Why */
.why {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  background: var(--cream); border-radius: 24px; padding: 24px;
}
.why__item { display: flex; gap: 14px; align-items: center; }
.why__ico {
  flex: none; width: 52px; height: 52px; border-radius: 16px; background: #fff;
  display: grid; place-items: center; font-size: 26px;
}
.why b { color: var(--deep); font-size: 15px; }
.why p { margin: 3px 0 0; font-size: 13px; color: var(--muted); }

/* ===== Footer ===== */
.footer { background: var(--deep); color: #d6ebc8; margin-top: 56px; padding-top: 44px; }
.footer__in { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 24px; }
.footer__brand img { height: 56px; width: auto; }
.footer__brand p { margin-top: 12px; }
.footer h4 { color: #fff; font-size: 15px; margin-bottom: 12px; }
.footer a, .footer p { display: block; font-size: 14px; margin: 0 0 8px; color: #d6ebc8; }
.footer a:hover { color: var(--green); }
.footer .fb-link { display: inline-flex; align-items: center; gap: 8px; margin: 0; overflow-wrap: anywhere; }
.footer .fb-link svg { width: 18px; height: 18px; flex: none; fill: #fff; background: #1877f2; border-radius: 50%; padding: 2px; }
.footer__bottom { border-top: 1px solid rgba(255,255,255,.12); margin-top: 28px; padding: 18px 0; font-size: 13px; color: #a9c99b; }

/* ===== Drawer ===== */
.overlay { position: fixed; inset: 0; background: rgba(10, 30, 15, .45); z-index: 60; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100%); z-index: 70;
  background: #fff; display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .28s ease;
}
.drawer.open { transform: none; }
.drawer__head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.drawer__head h3 { font-size: 20px; color: var(--deep); font-weight: 800; }
.x { background: var(--cream); border: 0; width: 36px; height: 36px; border-radius: 50%; font-size: 15px; color: var(--ink); }
.x:hover { background: #efe6cf; }

.freebar { padding: 14px 20px; background: #f4faea; }
.freebar p { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--deep); }
.freebar__track { height: 8px; background: #dcebc6; border-radius: 99px; overflow: hidden; }
.freebar__track i { display: block; height: 100%; width: 0; background: var(--green); border-radius: 99px; transition: width .3s; }

.drawer__body { flex: 1; overflow-y: auto; padding: 8px 20px; }
.line { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.line__img { width: 56px; height: 56px; border-radius: 12px; display: grid; place-items: center; font-size: 30px; overflow: hidden; }
.line__img img { width: 100%; height: 100%; object-fit: cover; }
.line__name { font-size: 14px; font-weight: 600; }
.line__price { font-size: 13px; color: var(--muted); margin-top: 2px; }
.line .qty { margin: 0; padding: 3px; gap: 8px; }
.line .qty button { width: 28px; height: 28px; font-size: 15px; }

.cart-empty { text-align: center; padding: 50px 10px; color: var(--muted); }
.cart-empty img { width: 120px; margin: 0 auto 16px; opacity: .9; }

.drawer__foot { padding: 16px 20px calc(20px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); }
.drawer__head { padding-top: calc(18px + env(safe-area-inset-top, 0px)); }
.row { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 8px; color: var(--muted); }
.row b { color: var(--ink); }
.row--total { font-size: 17px; color: var(--ink); font-weight: 700; margin: 12px 0 14px; }
.row--total b { color: var(--deep); font-weight: 800; }

/* ===== Modal ===== */
.modal {
  position: fixed; inset: 0; z-index: 80; background: rgba(10,30,15,.5);
  display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 16px; overflow-y: auto;
}
.modal[hidden] { display: none; }
.modal__card { position: relative; background: #fff; border-radius: 24px; width: min(440px, 100%); padding: 28px; max-height: 92vh; overflow-y: auto; }
.modal__card .x { position: absolute; top: 14px; right: 14px; }
.modal h3 { font-size: 20px; color: var(--deep); font-weight: 800; margin-bottom: 18px; }
form label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 12px; }
form input:not([type=radio]):not([type=checkbox]), form textarea, form select {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px; font: inherit; font-size: 14px;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); resize: vertical;
}
form input:focus, form textarea:focus, form select:focus { outline: 0; border-color: var(--green); }
form select { cursor: pointer; }
form select:invalid { color: #9aa59d; }
form select option { color: var(--ink); }
fieldset { border: 0; padding: 0; margin: 4px 0 0; display: flex; gap: 8px; flex-wrap: wrap; }
legend { font-size: 13px; font-weight: 600; margin-bottom: 8px; padding: 0; }
.radio {
  display: flex; align-items: center; gap: 6px; margin: 0;
  border: 1.5px solid var(--line); border-radius: 999px; padding: 8px 14px; cursor: pointer;
}
.radio:has(input:checked) { border-color: var(--green); background: #f4faea; }
.radio input { accent-color: var(--green); margin: 0; }
.pay-note { flex-basis: 100%; font-size: 12px; color: var(--muted); margin-top: 2px; }

.form-err {
  background: #fdecea; color: #b3261e; border-radius: 12px; padding: 10px 12px;
  font-size: 13px; font-weight: 600; margin: 0 0 12px; line-height: 1.45;
}
.done__no { color: var(--ink) !important; margin-bottom: 8px !important; }
.done__no b { color: var(--deep); letter-spacing: .5px; }
.done { text-align: center; }
.done img { width: 130px; margin: 6px auto 14px; animation: run 2.4s ease-in-out infinite; }
.done p { color: var(--muted); line-height: 1.5; margin: 0 0 20px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 16px); opacity: 0; visibility: hidden;
  background: var(--deep); color: #fff; padding: 12px 20px; border-radius: 999px;
  font-size: 14px; font-weight: 600; z-index: 90; pointer-events: none;
  transition: transform .25s ease, opacity .25s ease, visibility .25s;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }

/* Mobile cart bar */
.mbar {
  position: fixed; z-index: 50;
  left: max(16px, env(safe-area-inset-left, 0px)); right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  display: none; justify-content: space-between; align-items: center;
  background: var(--green); color: #fff; border: 0; border-radius: 16px; padding: 14px 18px;
  font-size: 14px; box-shadow: 0 10px 24px rgba(100,182,1,.35);
}

/* ===== Responsive ===== */
@media (max-width: 1080px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
  .addr { display: none; }
}
@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
  .why { grid-template-columns: 1fr 1fr; }
  .footer__in { grid-template-columns: 1fr 1fr; }
  .footer__brand { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .header__in { flex-wrap: wrap; gap: 10px; }
  .logo img { height: 38px; }
  .search { order: 3; flex-basis: 100%; height: 42px; }
  .cart-btn { margin-left: auto; }
  .cart-btn__sum { display: none; }
  .cart-btn { padding: 8px 12px; height: 42px; }
  .hero { margin-top: 14px; }
  .hero__viewport { border-radius: 18px; }
  .hero__nav { display: none; }
  .hero__dots { bottom: 8px; }
  .section { margin-top: 32px; }
  .section__head h2 { font-size: 20px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; width: 100%; }
  .tabs button { flex: none; }
  /* 10 ангиллыг хоёр мөрөөр хажуу тийш гүйлгэнэ */
  .cats {
    grid-template-columns: none; grid-auto-flow: column; grid-template-rows: repeat(2, auto);
    grid-auto-columns: 30%; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px;
  }
  .cats::-webkit-scrollbar { display: none; }
  .cat { padding: 12px 4px 10px; font-size: 11px; }
  .cat span { font-size: 30px; }
  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 10px; }
  .card__img { font-size: 52px; }
  .why { grid-template-columns: 1fr; }
  .footer__in { grid-template-columns: 1fr 1fr; }
  .footer__brand { grid-column: 1 / -1; }
  .mbar:not([hidden]) { display: flex; }
  .footer { padding-bottom: 70px; }
}

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