/* ============================================================
   Нөөцөө — загвар
   Санаа: захын савны хөх, үнийн шошгоны шар.
   Гадаа нарны гэрэлд уншигдах, бээлийтэй хуруугаар дарагдах.
   ============================================================ */
:root {
  --ink: #13203A;
  --ink-2: #3B4763;
  --mute: #6A7490;
  --line: #D6DBE6;
  --bg: #ECEFF5;
  --card: #FFFFFF;
  --blue: #2449C8;
  --blue-deep: #1A358F;
  --blue-soft: #DDE5FB;
  --tag: #FFC53D;
  --tag-deep: #E9A800;
  --tag-ink: #3A2A00;
  --green: #148A56;
  --green-soft: #D7F2E4;
  --red: #D23B3B;
  --red-soft: #FBE1E1;
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --display: "Unbounded", "Onest", system-ui, sans-serif;
  --text: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tabs-h: 72px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--text);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--tag-deep); outline-offset: 2px; }
.num { font-family: var(--display); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

/* ---------- Ачаалал ---------- */
.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--mute); }
.boot-mark { width: 56px; height: 56px; border-radius: 16px; background: var(--blue); position: relative; }
.boot-mark::after { content: ""; position: absolute; inset: 16px 12px 16px 20px; background: var(--tag); border-radius: 3px 8px 8px 3px; animation: pulse 1s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(.82); } }

/* ---------- Бүтэц ---------- */
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; position: relative; }
.view { padding: 12px 16px calc(var(--tabs-h) + var(--safe-b) + 24px); outline: none; }

.top {
  position: sticky; top: 0; z-index: 20;
  background: var(--blue); color: #fff;
  padding: calc(var(--safe-t) + 14px) 16px 14px;
  display: grid; gap: 12px;
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top h1 { margin: 0; font-family: var(--display); font-size: 20px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.top .sub { margin: 2px 0 0; font-size: 13px; color: #C9D5FF; }
.top-btn { width: 44px; height: 44px; border-radius: 12px; background: rgba(255,255,255,.14); display: grid; place-items: center; color: #fff; }
.top-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Горим солих: Зарах / Нэмэх — апп-ын хамгийн чухал товч */
.mode {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: rgba(0,0,0,.22); border-radius: 14px; padding: 4px;
}
.mode button {
  height: 48px; border-radius: 11px; font-weight: 700; font-size: 17px; color: #DCE4FF;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.mode button .sign { font-family: var(--display); font-size: 20px; line-height: 1; }
.mode button[aria-pressed="true"].sell { background: var(--tag); color: var(--tag-ink); }
.mode button[aria-pressed="true"].add  { background: #fff; color: var(--green); }
.top.is-add { background: #11663F; }
.top.is-add .sub { color: #BFE8D2; }

.banner {
  margin: 12px 0 0; padding: 10px 12px; border-radius: var(--r-sm);
  background: var(--tag); color: var(--tag-ink); font-size: 14px; font-weight: 500;
  display: flex; gap: 10px; align-items: center; justify-content: space-between;
}
.banner.warn { background: var(--red-soft); color: #7A1D1D; }
.banner button { font-weight: 700; text-decoration: underline; white-space: nowrap; }

/* ---------- Табууд ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  max-width: 560px; margin: 0 auto;
  height: calc(var(--tabs-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: #fff; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
}
.tab { display: grid; justify-items: center; gap: 3px; font-size: 12px; font-weight: 600; color: var(--mute); height: 100%; align-content: center; }
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--blue); }
.tab-scan {
  width: 68px; height: 68px; border-radius: 22px; margin: -30px auto 0;
  background: var(--tag); color: var(--tag-ink); align-content: center;
  box-shadow: 0 6px 0 var(--tag-deep), 0 10px 24px rgba(19,32,58,.25);
}
.tab-scan svg { width: 32px; height: 32px; stroke-width: 2.2; }
.tab-scan:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--tag-deep); }

/* ---------- Ерөнхий блокууд ---------- */
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 26px 0 10px; }
.section-title h2 { margin: 0; font-size: 18px; font-weight: 700; }
.section-title .link { color: var(--blue); font-weight: 600; font-size: 15px; }
.panel { background: var(--card); border-radius: var(--r-md); padding: 16px; }
.muted { color: var(--mute); }
.small { font-size: 14px; }

.btn {
  height: 52px; padding: 0 20px; border-radius: 14px; font-weight: 700; font-size: 17px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--blue); color: #fff;
}
.btn:active { transform: scale(.98); }
.btn.block { width: 100%; }
.btn.tag { background: var(--tag); color: var(--tag-ink); }
.btn.ghost { background: var(--blue-soft); color: var(--blue-deep); }
.btn.green { background: var(--green); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Нүүр ---------- */
.today {
  background: var(--card); border-radius: var(--r-lg); padding: 20px; margin-top: 4px;
  display: grid; gap: 4px;
}
.today .label { font-size: 15px; color: var(--mute); }
.today .big { font-family: var(--display); font-weight: 700; font-size: 38px; line-height: 1.1; letter-spacing: -0.03em; }
.today .row { display: flex; gap: 18px; margin-top: 10px; font-size: 15px; color: var(--ink-2); }
.today .row b { font-family: var(--display); font-weight: 500; color: var(--ink); }
.spark { display: flex; align-items: flex-end; gap: 6px; height: 56px; margin-top: 14px; }
.spark i { flex: 1; background: var(--blue-soft); border-radius: 4px 4px 2px 2px; min-height: 3px; position: relative; }
.spark i.on { background: var(--blue); }
.spark-labels { display: flex; gap: 6px; font-size: 11px; color: var(--mute); }
.spark-labels span { flex: 1; text-align: center; }

.alerts { display: grid; gap: 8px; }
.alert {
  display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center;
  background: var(--card); border-radius: var(--r-md); padding: 10px 12px; text-align: left; width: 100%;
}
.alert .thumb { width: 48px; height: 48px; border-radius: 10px; }
.alert .name { font-weight: 600; line-height: 1.25; }
.alert .meta { font-size: 13px; color: var(--mute); }
.pill { font-size: 13px; font-weight: 700; padding: 4px 9px; border-radius: 999px; background: var(--red-soft); color: var(--red); white-space: nowrap; }
.pill.ok { background: var(--green-soft); color: var(--green); }
.pill.warn { background: #FFF0C7; color: #7A5600; }

.feed { display: grid; background: var(--card); border-radius: var(--r-md); overflow: hidden; }
.feed-row { display: grid; grid-template-columns: 34px 1fr auto auto; gap: 10px; align-items: center; padding: 12px 14px; border-top: 1px solid #EEF1F6; }
.feed-row:first-child { border-top: 0; }
.feed-row .sign { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-family: var(--display); font-weight: 700; }
.feed-row .sign.sale { background: #FFF0C7; color: #7A5600; }
.feed-row .sign.in { background: var(--green-soft); color: var(--green); }
.feed-row .sign.adjust { background: var(--blue-soft); color: var(--blue-deep); }
.feed-row .t { line-height: 1.25; }
.feed-row .t small { display: block; color: var(--mute); font-size: 13px; }
.feed-row .amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.undo-btn { font-size: 13px; font-weight: 700; color: var(--blue); padding: 8px 4px; }

.empty { text-align: center; padding: 34px 18px; background: var(--card); border-radius: var(--r-lg); }
.empty h3 { margin: 0 0 6px; font-size: 19px; }
.empty p { margin: 0 0 18px; color: var(--mute); }
.empty .btns { display: grid; gap: 10px; }

/* ---------- Бараа ---------- */
.search { position: relative; display: block; margin: 4px 0 12px; }
.search input {
  width: 100%; height: 50px; border-radius: 14px; border: 1.5px solid var(--line); background: #fff;
  padding: 0 14px 0 44px; font-size: 16px;
}
.search svg { position: absolute; left: 14px; top: 14px; width: 22px; height: 22px; fill: none; stroke: var(--mute); stroke-width: 2; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.card { background: var(--card); border-radius: var(--r-md); overflow: hidden; display: flex; flex-direction: column; }
.card .ph { position: relative; aspect-ratio: 5 / 4; overflow: hidden; display: block; width: 100%; }
.card .ph img, .card .ph .noimg { width: 100%; height: 100%; object-fit: cover; }
.card .stock-badge {
  position: absolute; left: 8px; top: 8px; padding: 3px 8px; border-radius: 8px;
  background: rgba(19,32,58,.78); color: #fff; font-size: 12px; font-weight: 700;
}
.card .stock-badge.low { background: var(--red); }
.card .info { padding: 10px 10px 4px; }
.card .nm { font-weight: 600; font-size: 15px; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card .pr { font-family: var(--display); font-weight: 500; font-size: 15px; margin-top: 2px; }

/* Хэмжээний шошго: дарахад шууд −1 / +1 */
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px 12px; }
.chip {
  min-width: 52px; min-height: 52px; flex: 1 0 52px; max-width: 100%;
  border-radius: 10px; padding: 5px 6px 4px;
  display: grid; justify-items: center; align-content: center; line-height: 1.05;
  background: var(--tag); color: var(--tag-ink);
  box-shadow: 0 3px 0 var(--tag-deep);
  position: relative;
}
.chip::before { /* шошгоны нүх */
  content: ""; position: absolute; top: 5px; left: 50%; width: 5px; height: 5px; margin-left: -2.5px;
  border-radius: 50%; background: rgba(58,42,0,.25);
}
.chip .l { font-size: 12px; font-weight: 700; margin-top: 6px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .q { font-family: var(--display); font-weight: 700; font-size: 19px; }
.chip:active { transform: translateY(3px); box-shadow: 0 0 0 var(--tag-deep); }
.chip.zero { background: #E7EAF0; color: #9AA2B5; box-shadow: 0 3px 0 #CDD3DE; }
.chip.low { background: #FFB4A8; color: #5B1010; box-shadow: 0 3px 0 #E07D6D; }
.is-add-mode .chip { background: var(--green-soft); color: var(--green); box-shadow: 0 3px 0 #9CD8BA; }
.is-add-mode .chip::before { background: rgba(20,138,86,.25); }
.chip.flash { animation: flash .45s ease-out; }
@keyframes flash { 0% { transform: scale(1.12); } 100% { transform: scale(1); } }

.noimg { display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 42px; color: rgba(255,255,255,.95); }
.thumb.noimg { font-size: 20px; }

/* ---------- Тайлан ---------- */
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: #fff; border-radius: 14px; padding: 4px; margin: 4px 0 14px; }
.seg button { height: 42px; border-radius: 10px; font-weight: 600; font-size: 14px; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: var(--card); border-radius: var(--r-md); padding: 14px; }
.kpi.wide { grid-column: 1 / -1; }
.kpi .k { font-size: 14px; color: var(--mute); }
.kpi .v { font-family: var(--display); font-weight: 700; font-size: 22px; letter-spacing: -0.02em; line-height: 1.2; margin-top: 2px; }
.kpi.wide .v { font-size: 32px; }
.kpi .d { font-size: 13px; font-weight: 600; margin-top: 4px; }
.kpi .d.up { color: var(--green); }
.kpi .d.down { color: var(--red); }

.chart { background: var(--card); border-radius: var(--r-md); padding: 14px 10px 8px; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .cap { font-size: 13px; color: var(--mute); padding: 0 6px 8px; }

.rank { background: var(--card); border-radius: var(--r-md); overflow: hidden; }
.rank-row { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border-top: 1px solid #EEF1F6; }
.rank-row:first-child { border-top: 0; }
.rank-row .thumb { width: 44px; height: 44px; border-radius: 10px; }
.rank-row .bar { height: 6px; border-radius: 3px; background: var(--blue-soft); margin-top: 6px; overflow: hidden; }
.rank-row .bar i { display: block; height: 100%; background: var(--blue); border-radius: 3px; }
.rank-row .nm { font-weight: 600; line-height: 1.25; }
.rank-row .sm { font-size: 13px; color: var(--mute); }
.rank-row .r { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.rank-row .r small { display: block; font-weight: 500; color: var(--mute); font-size: 12px; }

.note { background: var(--blue-soft); color: var(--blue-deep); border-radius: var(--r-md); padding: 14px; font-size: 15px; }

/* ---------- Тохиргоо ---------- */
.list { background: var(--card); border-radius: var(--r-md); overflow: hidden; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; text-align: left; padding: 15px 16px; border-top: 1px solid #EEF1F6; font-size: 16px; }
.list-row:first-child { border-top: 0; }
.list-row .r { color: var(--mute); font-size: 15px; text-align: right; }
a.list-row { color: inherit; text-decoration: none; }
.list-row.danger { color: var(--red); font-weight: 600; }
.plan { display: grid; gap: 4px; padding: 14px 16px; border-top: 1px solid #EEF1F6; }
.plan:first-child { border-top: 0; }
.plan .p { font-family: var(--display); font-weight: 700; }

/* ---------- Доороос гарах цонх ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(19,32,58,.5); animation: fade .2s ease-out; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto;
  max-height: 92vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); border-radius: 24px 24px 0 0;
  padding: 10px 16px calc(20px + var(--safe-b));
  animation: up .25s cubic-bezier(.2,.8,.2,1);
}
.sheet::before { content: ""; display: block; width: 44px; height: 5px; border-radius: 3px; background: #C3CAD8; margin: 0 auto 12px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.sheet h2 { margin: 0 0 4px; font-size: 21px; line-height: 1.25; }
.sheet .lead { margin: 0 0 16px; color: var(--mute); }
.sheet-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; margin-top: 18px; position: sticky; bottom: calc(-20px - var(--safe-b)); background: var(--bg); padding: 10px 0 calc(20px + var(--safe-b)); margin-bottom: calc(-20px - var(--safe-b)); }
.sheet-actions.one { grid-template-columns: 1fr; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.field input, .field select {
  height: 52px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; padding: 0 14px; font-size: 17px; width: 100%;
}
.field input:focus { border-color: var(--blue); outline: none; }
.field .hint { font-size: 13px; color: var(--mute); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.with-btn { display: grid; grid-template-columns: 1fr 52px; gap: 8px; }
.icon-btn { height: 52px; border-radius: 12px; background: var(--blue-soft); color: var(--blue-deep); display: grid; place-items: center; }
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.photo-pick { display: grid; grid-template-columns: 112px 1fr; gap: 12px; align-items: center; margin-bottom: 16px; }
.photo-pick .ph { width: 112px; height: 112px; border-radius: 16px; overflow: hidden; background: #fff; border: 2px dashed var(--line); display: grid; place-items: center; color: var(--mute); }
.photo-pick .ph img { width: 100%; height: 100%; object-fit: cover; }
.photo-pick .btns { display: grid; gap: 8px; }
.photo-pick .btn { height: 48px; font-size: 15px; }

.presets { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; scrollbar-width: none; }
.presets button { flex: none; height: 40px; padding: 0 14px; border-radius: 999px; background: #fff; border: 1.5px solid var(--line); font-weight: 600; font-size: 14px; }
.presets button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

.vrows { display: grid; gap: 8px; }
.vrow { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; background: #fff; border-radius: 12px; padding: 6px 6px 6px 14px; }
.vrow input.vl { border: 0; height: 44px; font-weight: 700; font-size: 17px; background: transparent; min-width: 0; width: 100%; }
.vrow input.vl:focus { outline: none; }
.step { display: grid; grid-template-columns: 48px 64px 48px; align-items: center; }
.step button { width: 48px; height: 48px; border-radius: 12px; background: var(--bg); font-family: var(--display); font-size: 22px; font-weight: 700; }
.step input { width: 64px; height: 48px; text-align: center; border: 0; font-family: var(--display); font-weight: 700; font-size: 20px; background: transparent; }
.step input:focus { outline: none; background: var(--blue-soft); border-radius: 8px; }
.vrow .rm { width: 32px; height: 32px; color: var(--mute); font-size: 18px; }
.add-v { margin-top: 8px; height: 46px; width: 100%; border-radius: 12px; border: 1.5px dashed var(--line); color: var(--blue); font-weight: 700; }

/* Дэлгэрэнгүй цонх */
.detail-head { display: grid; grid-template-columns: 88px 1fr; gap: 14px; align-items: center; margin-bottom: 16px; }
.detail-head .thumb { width: 88px; height: 88px; border-radius: 16px; }
.detail-head .pr { font-family: var(--display); font-weight: 700; font-size: 20px; }
.detail-head .meta { font-size: 14px; color: var(--mute); }
.qty-grid { display: grid; gap: 8px; }
.qty-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; background: #fff; border-radius: 14px; padding: 8px 8px 8px 16px; }
.qty-row .lbl { font-weight: 700; font-size: 17px; }
.qty-row .lbl small { display: block; font-weight: 500; font-size: 13px; color: var(--mute); }
.qty-row .step input { pointer-events: none; }
.big-sell { height: 64px; font-size: 19px; }

/* ---------- Сканнер ---------- */
.scanner { position: fixed; inset: 0; z-index: 60; background: #0A1022; color: #fff; display: grid; grid-template-rows: auto 1fr auto; }
.scan-head { display: flex; justify-content: space-between; align-items: center; padding: calc(var(--safe-t) + 12px) 16px 12px; }
.scan-head p { margin: 0; font-weight: 700; font-size: 18px; }
.scan-close { width: 48px; height: 48px; border-radius: 14px; background: rgba(255,255,255,.12); color: #fff; font-size: 20px; }
.scan-cam { position: relative; overflow: hidden; display: grid; place-items: center; }
.scan-cam video { width: 100% !important; height: 100% !important; object-fit: cover; }
.scan-foot { padding: 14px 16px calc(16px + var(--safe-b)); display: grid; gap: 12px; }
.scan-foot p { margin: 0; text-align: center; font-size: 15px; color: #C7CFE6; min-height: 1.45em; }
.scan-foot p.hit { color: var(--tag); font-weight: 700; font-size: 17px; }
.scan-manual { display: grid; grid-template-columns: 1fr 72px; gap: 8px; }
.scan-manual input { height: 50px; border-radius: 12px; border: 0; padding: 0 14px; font-size: 17px; color: var(--ink); }
.scan-manual button { height: 50px; border-radius: 12px; background: var(--tag); color: var(--tag-ink); font-weight: 700; }

/* ---------- Мэдэгдэл ---------- */
.toast {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--tabs-h) + var(--safe-b) + 44px); z-index: 70;
  max-width: 536px; margin: 0 auto;
  background: var(--ink); color: #fff; border-radius: 14px; padding: 12px 12px 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-weight: 500; transform: translateY(20px); opacity: 0; pointer-events: none; transition: .2s;
}
.toast.show { transform: none; opacity: 1; pointer-events: auto; }
.toast.err { background: var(--red); }
.toast button { color: var(--tag); font-weight: 700; padding: 8px 10px; white-space: nowrap; }

/* ---------- Нэвтрэх ---------- */
.auth { min-height: 100vh; padding: calc(var(--safe-t) + 32px) 20px 32px; max-width: 440px; margin: 0 auto; display: grid; align-content: start; gap: 6px; }
.auth .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.auth .brand .boot-mark { width: 48px; height: 48px; }
.auth .brand .boot-mark::after { animation: none; }
.auth .brand b { font-family: var(--display); font-size: 26px; letter-spacing: -0.03em; }
.auth h1 { font-size: 26px; line-height: 1.2; margin: 0 0 6px; }
.auth .lead { color: var(--mute); margin: 0 0 22px; }
.auth .switch { margin-top: 16px; text-align: center; color: var(--mute); }
.auth .switch button { color: var(--blue); font-weight: 700; }
.pin input { letter-spacing: .5em; font-family: var(--display); }

@media (min-width: 420px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}


/* ============================================================
   v2: нэвтрэх хуудас, салбар, эрх, QPay
   ============================================================ */
#auth { min-height: 100vh; background: var(--bg); }
.auth-hero { background: var(--blue); color: #fff; padding: calc(var(--safe-t) + 36px) 20px 0; }
.auth-in { max-width: 440px; margin: 0 auto; }
.auth-hero .brand { display: flex; align-items: center; gap: 14px; margin: 0; }
.logo-mark { width: 60px; height: 60px; border-radius: 16px; display: block; box-shadow: 0 0 0 2px rgba(255,255,255,.25); }
.auth-hero .brand b { font-family: var(--display); font-size: 32px; letter-spacing: -0.03em; }
.tagline { margin: 14px 0 26px; color: #DCE4FF; font-size: 17px; max-width: 30ch; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.auth-tabs button { height: 52px; border-radius: 14px 14px 0 0; font-weight: 700; font-size: 17px; color: #DCE4FF; background: rgba(0,0,0,.18); }
.auth-tabs button[aria-selected="true"] { background: var(--bg); color: var(--ink); }
.auth { min-height: auto; padding: 22px 20px 40px; gap: 4px; }
.auth h1 { margin-top: 6px; }
.auth .note { margin-bottom: 14px; }
.auth .switch a { color: var(--blue); font-weight: 600; }

.branch-pill {
  margin-top: 8px; display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px 0 8px; border-radius: 999px;
  background: rgba(255,255,255,.16); color: #fff; font-weight: 600; font-size: 14px;
}
.branch-pill svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.branch-row { gap: 8px; }
.br-pick { text-align: left; flex: 1; line-height: 1.3; }
.plain-input { height: 52px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; padding: 0 14px; font-size: 16px; width: 100%; }

.sub-card { background: var(--card); border-radius: var(--r-lg); padding: 18px; display: grid; gap: 4px; border: 2px solid transparent; }
.sub-card.soon { border-color: var(--tag); }
.sub-card.over { border-color: var(--red); }
.sc-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sc-plan { font-family: var(--display); font-weight: 700; font-size: 18px; }
.sc-date { color: var(--mute); margin-bottom: 12px; }

.plan-list { display: grid; gap: 8px; margin-bottom: 14px; }
.plan-opt {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: left;
  background: #fff; border-radius: 14px; padding: 14px 16px; border: 2px solid var(--line);
}
.plan-opt[aria-pressed="true"] { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.po-name { font-weight: 700; font-size: 16px; line-height: 1.25; }
.po-name small, .po-price small { display: block; font-weight: 500; font-size: 13px; color: var(--mute); }
.po-price { font-family: var(--display); font-weight: 700; font-size: 17px; text-align: right; white-space: nowrap; }
.alt-pay { margin-top: 18px; background: #fff; border-radius: 14px; padding: 14px 16px; }
.alt-pay summary { font-weight: 600; cursor: pointer; }
.alt-pay .list { background: var(--bg); }

.banks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.bank { display: grid; justify-items: center; gap: 6px; padding: 10px 6px; background: #fff; border-radius: 14px; text-decoration: none; color: var(--ink); font-size: 12px; font-weight: 600; text-align: center; line-height: 1.2; }
.bank img { width: 44px; height: 44px; border-radius: 12px; object-fit: contain; }
.qr-box { background: #fff; border-radius: 18px; padding: 16px; display: grid; place-items: center; }
.qr-box img { width: min(260px, 70vw); height: auto; image-rendering: pixelated; }
.pay-status { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 14px; color: var(--ink-2); font-weight: 500; text-align: center; }
.pay-status.ok { color: var(--green); font-weight: 700; }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--blue-soft); border-top-color: var(--blue); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.pay-done { text-align: center; padding: 10px 0 0; }
.pd-mark { width: 72px; height: 72px; border-radius: 22px; margin: 0 auto 14px; display: grid; place-items: center; background: var(--green); color: #fff; font-size: 38px; font-weight: 700; }

/* ============================================================
   v3: барааны төрөл
   ============================================================ */
.cat-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-chip {
  height: 44px; padding: 0 14px 0 10px; border-radius: 12px; background: #fff; border: 1.5px solid var(--line);
  font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; gap: 6px;
}
.cat-chip .ci { font-size: 20px; line-height: 1; }
.cat-chip[aria-checked="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.cat-chip.add { border-style: dashed; color: var(--blue); padding: 0 14px; }
.newcat { background: #fff; border-radius: 16px; padding: 14px; border: 2px solid var(--blue-soft); }
.newcat .field:last-of-type { margin-bottom: 8px; }
.newcat .presets { margin-bottom: 8px; }
.icon-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-pick button { width: 44px; height: 44px; border-radius: 12px; background: var(--bg); font-size: 22px; border: 2px solid transparent; }
.icon-pick button[aria-pressed="true"] { border-color: var(--blue); background: var(--blue-soft); }
.nc-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }
.nc-actions .btn { height: 48px; font-size: 16px; }
.vrow.single { grid-template-columns: 1fr auto; }
.vl-static { font-weight: 600; color: var(--ink-2); }
.vrow { grid-template-columns: 1fr auto auto; }
.vrow .rm { width: 32px; height: 40px; color: var(--mute); font-size: 16px; }

.cat-filter { display: flex; gap: 8px; overflow-x: auto; margin: -2px -16px 12px; padding: 0 16px 2px; scrollbar-width: none; }
.cat-filter::-webkit-scrollbar { display: none; }
.cat-filter button { flex: none; height: 40px; padding: 0 12px; border-radius: 999px; background: #fff; font-weight: 600; font-size: 14px; white-space: nowrap; border: 1.5px solid var(--line); }
.cat-filter button b { font-weight: 700; color: var(--mute); margin-left: 2px; }
.cat-filter button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.cat-filter button[aria-pressed="true"] b { color: #C9D1E4; }
.card .clr { font-size: 13px; color: var(--mute); margin-top: 1px; }

.cat-share { padding: 14px; }
.share-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; gap: 2px; margin-bottom: 12px; }
.share-bar i { display: block; height: 100%; min-width: 3px; }
.share-row { display: grid; grid-template-columns: 12px 1fr auto auto 44px; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid #EEF1F6; font-size: 15px; }
.share-row:nth-child(2) { border-top: 0; }
.share-row .dot { width: 12px; height: 12px; border-radius: 4px; }
.share-row .sn { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-row .sq { color: var(--mute); font-size: 13px; }
.share-row .sv { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.share-row .sp { color: var(--mute); font-size: 13px; text-align: right; }
