/* ============================================================
   VanguardOS — Clean Light Glassmorphism (iOS 15 / visionOS feel)
   - Page: soft light-grey gradient (#F5F5F7). Panels: frosted white glass
     (rgba(238,240,242,.65) + blur(24px) saturate(150%) + hairline white edge + wide soft shadow)
   - Text #1D1D1F. NO sidebar on phones / NO tables: bottom tab bar + cards only
   - Every tappable element >= 48px (buttons 52px, inputs 54px)
   ============================================================ */
:root {
  /* "Ginseng Mist": neutral grey ground (low glare, not white, not black) + navy primary + ginseng-gold accent.
     --indigo / --indigo-h keep their names (used everywhere) but now carry the petrol primary. */
  --bg: #DFE1E5; --bg-outer: #DFE1E5; --bg-card: #EEF0F2; --bg-solid: rgba(244,245,247,.97); --bg-hover: rgba(90,100,120,.11); --border: rgba(28,34,48,.17);
  --glass-bg: #EEF0F2; --glass-blur: blur(14px) saturate(120%); --glass-border: 1px solid rgba(28,34,48,.13); --glass-shadow: inset 0 1px 0 rgba(255,255,255,.55), 0 6px 20px rgba(28,34,48,.07);
  --indigo: #1E3A5F; --indigo-h: #152C49; --emerald: #22B573; --emerald-d: #047857; --amber: #C98A12; --red: #D6334A;
  --gold: #C98A12;
  /* Latin letters + digits come from Inter, Thai from Noto Sans Thai (the browser picks per character).
     To go back to the old look: --font: 'Prompt', sans-serif, and load Prompt instead in the layouts' Google Fonts link. */
  --font: 'Inter', 'Noto Sans Thai', system-ui, sans-serif;
  --txt: #1B1F27; --txt-sec: #404754; --txt-muted: #5A6270;
  --shell-w: 600px; --tab-h: 68px; --safe-b: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
html, body { min-height: 100%; font-family: var(--font); color: var(--txt); font-size: 15px; line-height: 1.6; background-color: var(--bg); }
/* the blur needs something to blur: pale colour washes fixed behind everything */
body { -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none;
  background-image: radial-gradient(60% 50% at 6% 0%, rgba(30,58,95,.10) 0%, transparent 70%), radial-gradient(55% 45% at 100% 14%, rgba(201,138,18,.07) 0%, transparent 70%), linear-gradient(180deg, #E3E5E9 0%, #D8DBE0 100%);
  background-attachment: fixed; }
a { text-decoration: none; color: inherit; }
button, input, select, textarea { font-family: inherit; }

/* ---------- APP SHELL ---------- */
.app-shell { max-width: var(--shell-w); margin: 0 auto; min-height: 100vh; background: transparent; }
.app-header { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 58px; padding: 0 18px; padding-top: env(safe-area-inset-top, 0px); background: rgba(238,240,242,.72); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); border-bottom: 1px solid rgba(28,34,48,.12); }
.app-title { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-shop { font-size: 12px; color: var(--txt-sec); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46%; }
.app-main { padding: 22px 18px calc(var(--tab-h) + var(--safe-b) + 28px); }

/* ---------- BOTTOM TAB BAR ---------- */
.tabbar { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: var(--shell-w); z-index: 100; display: flex; height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b); background: rgba(238,240,242,.78); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); border-top: 1px solid rgba(28,34,48,.12); }
.tab { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--txt-muted); font-size: 11px; font-weight: 500; transition: color .15s; }
.tab i { font-size: 21px; }
.tab span { white-space: nowrap; }
.tab:active { background: var(--bg-hover); }
.tab.active { color: var(--indigo); font-weight: 600; }
.tab-primary i { display: flex; align-items: center; justify-content: center; width: 52px; height: 52px; margin-top: -22px; border-radius: 50%; background: var(--indigo); color: #fff; font-size: 22px; box-shadow: 0 6px 18px rgba(30,58,95,.32); border: 4px solid rgba(238,240,242,.9); }
.tab-primary.active i { background: var(--emerald); box-shadow: 0 6px 18px rgba(16,185,129,.32); }
.tab-primary { color: var(--txt-sec); }

/* ---------- PAGE HEADER ---------- */
.page-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.page-title { font-size: 21px; font-weight: 700; }
.page-title::after { content: ""; display: block; width: 28px; height: 3px; margin-top: 6px; border-radius: 2px; background: var(--gold); }
.page-sub { font-size: 13px; color: var(--txt-muted); margin-top: 3px; line-height: 1.5; }
.section-label { font-size: 12px; font-weight: 600; color: var(--txt-muted); text-transform: uppercase; letter-spacing: 1px; margin: 28px 4px 12px; }

/* ---------- CARDS ---------- */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 20px; padding: 22px; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.card-title { font-size: 15px; font-weight: 600; }
.m-card { display: block; background: var(--bg-card); border: 1px solid var(--border); border-radius: 20px; padding: 20px; margin-bottom: 14px; transition: border-color .15s, transform .1s; }
a.m-card:active { transform: scale(.985); border-color: var(--indigo); }
.m-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.m-row + .m-row { margin-top: 8px; }
.m-title { font-weight: 600; font-size: 15px; }
.m-sub { font-size: 12px; color: var(--txt-muted); line-height: 1.5; }
.m-amount { font-size: 18px; font-weight: 700; }
.m-amount.pos { color: var(--emerald-d); }
.kv { display: flex; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px dashed rgba(28,34,48,.16); font-size: 14px; }
.kv:last-child { border-bottom: none; }
.kv > span:first-child { color: var(--txt-muted); }
.kv.total { font-weight: 700; font-size: 17px; }
.empty-state { text-align: center; padding: 48px 16px; color: var(--txt-muted); }
.empty-state i { font-size: 40px; opacity: .4; display: block; margin-bottom: 12px; }
details.card > summary { cursor: pointer; font-weight: 600; list-style: none; min-height: 28px; display: flex; align-items: center; gap: 8px; }
details.card[open] > summary { margin-bottom: 16px; }
details.card > summary::-webkit-details-marker { display: none; }

/* profile + menu */
.profile-card { display: flex; align-items: center; gap: 16px; }
.user-avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--indigo); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 22px; flex-shrink: 0; }
.menu-card { display: flex; align-items: center; gap: 16px; min-height: 64px; padding: 14px 18px; margin-bottom: 10px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; }
.menu-card:active { background: var(--bg-hover); border-color: var(--indigo); }
.menu-icon { width: 42px; height: 42px; border-radius: 12px; background: rgba(30,58,95,.18); color: var(--indigo); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.menu-text { flex: 1; font-weight: 500; font-size: 15px; }
.menu-arrow { color: var(--txt-muted); font-size: 13px; }

/* ---------- STATS ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 24px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; padding: 18px 16px; }
.stat-label { font-size: 12px; color: var(--txt-muted); font-weight: 500; margin-bottom: 8px; }
.stat-value { font-size: 24px; font-weight: 700; }
.stat-sub { font-size: 12px; color: var(--txt-muted); margin-top: 4px; }
.stat-indigo { border-left: 4px solid var(--indigo); } .stat-emerald { border-left: 4px solid var(--emerald); }
.stat-amber { border-left: 4px solid var(--amber); } .stat-red { border-left: 4px solid var(--red); }
.quick-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 20px; }
.quick-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 104px; padding: 16px 10px; border-radius: 18px; background: var(--bg-card); border: 1px solid var(--border); font-weight: 500; font-size: 14px; text-align: center; }
.quick-btn i { font-size: 26px; color: var(--indigo); }
.quick-btn:active { transform: scale(.97); }
.quick-btn.primary { background: rgba(30,58,95,.18); border-color: rgba(30,58,95,.55); }
.wallet-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.wallet-item { background: var(--bg-hover); border: 1px solid var(--border); border-radius: 14px; padding: 16px; }
.wallet-label { font-size: 12px; color: var(--txt-muted); margin-bottom: 6px; line-height: 1.4; }
.wallet-amount { font-size: 20px; font-weight: 700; }

/* ---------- BADGES ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 11px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-indigo { background: rgba(30,58,95,.2); color: #152C49; } .badge-emerald { background: rgba(16,185,129,.2); color: #047857; }
.badge-amber { background: rgba(245,158,11,.2); color: #B45309; } .badge-red { background: rgba(239,68,68,.2); color: #C5221F; }
.badge-gray { background: rgba(100,116,139,.2); color: var(--txt-muted); }

/* factory dashboard — sales by province / district */
.geo-sum { cursor: pointer; list-style: none; }
.geo-sum::-webkit-details-marker { display: none; }
.geo-card { transition: border-color .15s; }
.geo-card[open] { border-color: var(--indigo); }
.geo-top { border-color: rgba(245,158,11,.55); }
.geo-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.geo-rank { flex: none; width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; background: rgba(30,58,95,.2); color: #152C49; }
.geo-top .geo-rank { background: var(--amber); color: #1F1300; }
.geo-rank-na { background: rgba(100,116,139,.2); color: var(--txt-muted); }
.geo-chev { font-size: 10px; margin-left: 4px; transition: transform .15s; }
.geo-card[open] .geo-chev { transform: rotate(180deg); }
.geo-bar { height: 6px; border-radius: 4px; background: var(--bg-hover); overflow: hidden; margin-top: 8px; }
.geo-bar > div { height: 100%; border-radius: 4px; }
.geo-bar-sm { height: 4px; margin: 5px 0 4px; }
.geo-body { margin-top: 12px; padding-top: 4px; border-top: 1px solid var(--border); }
.geo-label { margin: 12px 0 8px; font-size: 12px; font-weight: 600; color: var(--txt-sec); letter-spacing: .02em; }
.geo-label i { margin-right: 4px; color: var(--amber); }
.geo-dist { display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; margin-bottom: 6px; border-radius: 12px; background: rgba(90,100,120,.08); }
.geo-dist-main { flex: 1; min-width: 0; }
.geo-dist-name { font-weight: 600; font-size: 14px; }
.geo-dist-amt { font-weight: 700; font-size: 14px; color: #047857; }
.geo-medal { flex: none; width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; background: rgba(100,116,139,.25); color: var(--txt-sec); }
.geo-medal-1 { background: #F59E0B; color: #1F1300; }
.geo-medal-2 { background: #CBD5E1; color: #0F172A; }
.geo-medal-3 { background: #D97706; color: #1F1300; }
.geo-na { background: transparent; border: 1px dashed var(--border); }
.geo-na .geo-dist-name, .geo-na .geo-dist-amt { color: var(--txt-muted); font-weight: 600; }
.tier-vip { background: rgba(245,158,11,.25); color: #B45309; border: 1px solid rgba(245,158,11,.4); }
.tier-s { background: rgba(30,58,95,.25); color: #152C49; border: 1px solid rgba(30,58,95,.4); }
.tier-a { background: rgba(16,185,129,.25); color: #047857; border: 1px solid rgba(16,185,129,.4); }
.tier-b { background: rgba(100,116,139,.2); color: var(--txt-muted); }

/* ---------- BUTTONS (fat-finger friendly: min 52px) ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 14px 22px; border-radius: 14px; font-size: 16px; font-weight: 600; cursor: pointer; border: none; transition: transform .1s, background .15s; }
.btn:active { transform: scale(.97); }
.btn-sm { min-height: 48px; padding: 12px 18px; font-size: 15px; }
.btn-lg { min-height: 58px; padding: 16px 26px; font-size: 17px; }
.btn-primary { background: var(--indigo); color: #fff; } .btn-primary:active { background: var(--indigo-h); }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--txt); }
.btn-emerald { background: var(--emerald); color: #fff; }
.btn-danger { background: rgba(239,68,68,.15); color: #C5221F; border: 1.5px solid rgba(239,68,68,.45); }
.btn-block { display: flex; width: 100%; margin-top: 12px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.py-3 { padding-top: 1rem; padding-bottom: 1rem; }

/* ---------- FORMS (inputs 54px, 16px font = no iOS zoom) ---------- */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 14px; font-weight: 500; color: var(--txt-sec); margin-bottom: 8px; }
.form-control, .form-control-lg, .tier-select { width: 100%; min-height: 54px; padding: 14px 16px; background: var(--bg-hover); border: 1.5px solid var(--border); border-radius: 14px; color: var(--txt); font-size: 16px; outline: none; transition: border-color .15s; }
.form-control-lg { min-height: 58px; font-size: 17px; }
textarea.form-control { min-height: 96px; resize: vertical; }
.form-control:focus, .tier-select:focus { border-color: var(--indigo); }
.form-control::placeholder { color: var(--txt-muted); }
.form-check { display: flex; align-items: center; gap: 12px; min-height: 52px; }
.form-check-input { width: 26px; height: 26px; accent-color: var(--indigo); flex-shrink: 0; }
.grid-2, [style*="grid-template-columns:1fr 1fr"] { display: grid; grid-template-columns: 1fr !important; gap: 0; }
.alert { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 14px; margin-bottom: 16px; font-size: 14px; line-height: 1.5; }
.alert[hidden] { display: none; }
.alert-success { background: rgba(16,185,129,.15); border: 1px solid rgba(16,185,129,.3); color: #047857; }
.alert-error { background: rgba(239,68,68,.15); border: 1px solid rgba(239,68,68,.3); color: #C5221F; }
.validation-summary-valid { display: none; }   /* nothing wrong: no red box (the tag helper only adds -errors when there is an error) */
.validation-summary-errors ul { list-style: none; }
.validation-summary-errors { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.3); border-radius: 12px; padding: 12px 16px; color: #C5221F; font-size: 14px; margin-bottom: 16px; }
.field-validation-error { color: #C5221F; font-size: 13px; margin-top: 6px; display: block; }

/* ---------- CHIPS (filters) ---------- */
.chips { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 14px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; display: inline-flex; align-items: center; min-height: 44px; padding: 10px 20px; border-radius: 24px; border: 1.5px solid var(--border); font-size: 14px; color: var(--txt-sec); background: var(--bg-card); }
.chip.active { background: var(--indigo); border-color: var(--indigo); color: #fff; font-weight: 600; }

/* ---------- PRODUCTS / ORDER ENTRY ---------- */
.prod-card { background: var(--bg-card); border: 1.5px solid var(--border); border-radius: 18px; padding: 18px; margin-bottom: 12px; }
.prod-card.selected { border-color: var(--emerald-d); box-shadow: 0 0 0 1px rgba(16,185,129,.4); }
.prod-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.prod-name { font-weight: 600; font-size: 15px; line-height: 1.4; }
.prod-sku { font-size: 11px; color: var(--txt-muted); margin-top: 2px; }
.prod-price { text-align: right; flex-shrink: 0; }
.prod-price .big { font-size: 20px; font-weight: 700; }
.prod-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 12px; color: var(--txt-muted); }
.prod-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; gap: 12px; }
.qty-step { display: inline-flex; align-items: center; border: 1.5px solid var(--border); border-radius: 14px; overflow: hidden; }
.qty-step button { width: 54px; height: 54px; background: var(--bg-hover); border: none; color: var(--txt); font-size: 24px; cursor: pointer; }
.qty-step button:active { background: var(--indigo); }
.qty-step input { width: 64px; height: 54px; text-align: center; background: var(--bg); border: none; color: var(--txt); font-size: 18px; font-weight: 600; -moz-appearance: textfield; }
.qty-step input::-webkit-outer-spin-button, .qty-step input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
/* product line with several forms: the card opens a bottom sheet of big variant rows */
.fam-card.selected { border-color: var(--emerald-d); box-shadow: 0 0 0 1px rgba(16,185,129,.4); }
.fam-pick { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 54px; font-size: 16px; }
.fam-count { background: var(--emerald); color: #fff; border-radius: 12px; padding: 2px 10px; font-size: 13px; font-weight: 700; }
.sheet { margin: auto auto 0; width: 100%; max-width: 640px; max-height: 85vh; padding: 0; border: 0; border-radius: 22px 22px 0 0; background: var(--bg-card); color: var(--txt); overflow: hidden; }
.sheet::backdrop { background: rgba(29,29,31,.28); }
.sheet-inner { padding: 18px 18px calc(18px + var(--safe-b)); max-height: 85vh; overflow-y: auto; }
.sheet-title { font-size: 17px; font-weight: 700; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.var-row { border: 1.5px solid var(--border); border-radius: 16px; padding: 14px; margin-bottom: 10px; }
.var-row.selected { border-color: var(--emerald-d); }
.sticky-bar { position: sticky; bottom: calc(var(--tab-h) + var(--safe-b) + 10px); z-index: 40; background: var(--bg-card); border: 1.5px solid var(--indigo); border-radius: 20px; padding: 16px; margin-top: 16px; box-shadow: 0 8px 32px rgba(0,0,0,.08); }
.sum-line { display: flex; justify-content: space-between; font-size: 13px; color: var(--txt-sec); padding: 3px 0; }
/* picked products, listed on the summary bar next to the submit button */
.cart-list { max-height: 24vh; overflow-y: auto; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px dashed var(--border); }
.cart-title { font-size: 12px; font-weight: 600; color: var(--txt-muted); margin-bottom: 4px; }
.cart-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto 28px; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; }
.cart-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--txt); }
.cart-qty { color: var(--txt-muted); font-size: 12px; white-space: nowrap; }
.cart-total { font-weight: 600; white-space: nowrap; min-width: 62px; text-align: right; }
.cart-del { width: 28px; height: 28px; border: none; border-radius: 50%; background: var(--bg-hover); color: var(--txt-sec); font-size: 16px; line-height: 1; cursor: pointer; }
.cart-del:active { background: var(--red); color: #fff; }
@media (min-width: 1024px) { .cart-list { max-height: 34vh; } }
.sum-total { font-size: 20px; font-weight: 700; color: var(--txt); }
.tier-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.tier-cell { background: var(--bg-hover); border-radius: 10px; padding: 8px 4px; text-align: center; font-size: 11px; color: var(--txt-muted); }
.tier-cell b { display: block; font-size: 13px; color: var(--txt); }

/* ---------- seller head preview (profile pages) ---------- */
.paper { background: #fff; color: #111827; border-radius: 12px; padding: 18px; font-size: 13px; line-height: 1.55; }
.paper .seller .name { font-size: 17px; font-weight: 700; }
.paper .seller .logo { display: block; max-height: 56px; max-width: 200px; margin-bottom: 6px; object-fit: contain; }
.paper .seller div { color: #374151; }
.paper .paper-doc { margin-top: 12px; padding-top: 10px; border-top: 2px solid #111827; font-weight: 700; text-align: right; }
.brand-logo { height: 26px; width: auto; max-width: 110px; object-fit: contain; vertical-align: middle; margin-right: 8px; background: #fff; border-radius: 6px; padding: 2px 4px; }
.shop-brand .brand-logo { height: 34px; max-width: 140px; }

/* ---------- INVOICE (document: div rows, no tables; prints cleanly) ---------- */
.invoice { background: #fff; color: #111; padding: 22px; border-radius: 12px; font-size: 13px; line-height: 1.6; }
.invoice h1 { font-size: 19px; margin-bottom: 2px; }
.invoice hr { border: none; border-top: 1px solid #ccc; margin: 14px 0; }
.inv-party { margin-bottom: 12px; }
.inv-line { padding: 10px 0; border-bottom: 1px solid #ddd; }
.inv-line .calc { display: flex; justify-content: space-between; color: #555; font-size: 12px; }
.inv-sum { display: flex; justify-content: space-between; padding: 6px 0; }
.inv-sum.grand { font-weight: 700; font-size: 16px; border-top: 2px solid #111; margin-top: 6px; padding-top: 10px; }
.invoice .voided { color: #c00; font-weight: 700; border: 2px solid #c00; padding: 2px 10px; display: inline-block; transform: rotate(-6deg); margin-top: 6px; }
@media print {
  .no-print, .app-header, .tabbar { display: none !important; }
  html, body, .app-shell { background: #fff !important; border: none; }
  .app-main { padding: 0; } .invoice { padding: 0; }
}

/* ---------- DATA SOVEREIGNTY / COMING SOON ---------- */
.ds-shield { background: rgba(16,185,129,.08); border: 1px solid rgba(16,185,129,.25); border-radius: 16px; padding: 16px; display: flex; align-items: flex-start; gap: 14px; }
.ds-shield-icon { font-size: 24px; color: var(--emerald-d); }
.ds-shield-text { font-size: 13px; color: var(--txt-sec); line-height: 1.7; }
.ds-shield-title { font-size: 14px; font-weight: 600; color: var(--emerald-d); margin-bottom: 2px; }
.coming-soon-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 55vh; gap: 16px; text-align: center; }
.coming-soon-icon { font-size: 56px; color: var(--indigo); opacity: .4; }
.coming-soon-title { font-size: 20px; font-weight: 600; }
.coming-soon-sub { font-size: 14px; color: var(--txt-muted); }

/* ---------- LOGIN / REGISTER (standalone pages) ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px 16px; background: transparent; }
.login-box { width: 100%; max-width: 440px; }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo-icon { display: flex; align-items: center; justify-content: center; width: 68px; height: 68px; margin: 0 auto; border-radius: 20px; font-size: 30px; color: #F3E7C8; background: linear-gradient(145deg, #2F5486, #152C49); box-shadow: 0 8px 22px rgba(21,44,73,.28), inset 0 1px 0 rgba(255,255,255,.2); }
.login-logo-title { font-size: 26px; font-weight: 700; margin-top: 8px; }
.login-logo-sub { font-size: 13px; color: var(--txt-muted); }
.login-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 22px; padding: 26px 22px; }
.login-title { font-size: 19px; font-weight: 600; margin-bottom: 22px; }
.demo-section { margin-top: 26px; }
.demo-title { font-size: 11px; color: var(--txt-muted); text-align: center; margin-bottom: 12px; letter-spacing: .5px; text-transform: uppercase; }
.demo-buttons { display: flex; flex-direction: column; gap: 10px; }
.demo-btn { width: 100%; min-height: 60px; padding: 12px 16px; border-radius: 14px; border: 1.5px solid var(--border); background: var(--bg-hover); color: var(--txt-sec); font-size: 14px; cursor: pointer; display: flex; align-items: center; gap: 14px; }
.demo-btn:active { border-color: var(--indigo); }
.demo-btn .demo-icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.demo-factory { background: rgba(30,58,95,.25); color: #152C49; } .demo-merchant { background: rgba(16,185,129,.25); color: #047857; } .demo-affiliate { background: rgba(245,158,11,.25); color: #B45309; }

/* ---------- WIDE SCREENS: still a phone-like column, never stretched along X ---------- */
@media (min-width: 700px) {
  .app-shell { box-shadow: none; }
}

/* ---------- PRODUCT THUMBNAILS / PROMO / STARS / GALLERY / MEDIA ---------- */
.thumb-wrap { position: relative; flex-shrink: 0; width: 84px; height: 84px; border-radius: 14px; overflow: hidden; background: var(--bg-hover); display: block; }
.thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-empty { display: flex; align-items: center; justify-content: center; color: var(--txt-muted); font-size: 28px; }
.promo-flag { position: absolute; top: 6px; left: 6px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 8px; }
.prod-head { gap: 12px; }
.prod-info { flex: 1; min-width: 0; }
.prod-info .prod-name { display: block; }
.was { text-decoration: line-through; color: var(--txt-muted); font-size: 13px; }
.price-now { font-size: 26px; font-weight: 700; }
.price-promo { color: #C5221F; }
.stars { display: inline-flex; align-items: center; gap: 2px; color: #FBBF24; font-size: 12px; margin-top: 4px; }
.stars .fa-regular { color: var(--txt-muted); }
.stars .m-sub { margin-left: 6px; }
.stars.lg { font-size: 20px; gap: 4px; }
.gallery .g-main, .gallery .g-empty { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 20px; background: var(--bg-hover); display: block; }
.gallery .g-empty { display: flex; align-items: center; justify-content: center; font-size: 64px; color: var(--txt-muted); }
.g-strip { display: flex; gap: 10px; overflow-x: auto; margin-top: 12px; padding-bottom: 6px; scrollbar-width: none; }
.g-thumb { flex: 0 0 68px; height: 68px; border-radius: 12px; object-fit: cover; border: 2.5px solid transparent; cursor: pointer; }
.g-thumb.active { border-color: var(--indigo); }
.media-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 14px; }
.media-item { background: var(--bg-hover); border-radius: 16px; overflow: hidden; border: 1px solid var(--border); position: relative; }
.media-item img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block; }
.media-item .badge { position: absolute; top: 8px; left: 8px; }
.media-actions { padding: 10px; display: grid; gap: 8px; }
.media-actions .btn { min-height: 46px; padding: 10px; font-size: 14px; margin-top: 0; }
.upload-status { font-size: 13px; color: var(--txt-sec); text-align: center; min-height: 20px; margin-top: 8px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.star-input { display: flex; flex-direction: row-reverse; justify-content: flex-end; gap: 4px; margin-bottom: 14px; }
.star-input input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.star-input label { font-size: 40px; color: var(--txt-muted); cursor: pointer; padding: 4px 6px; line-height: 1; }
.star-input input:checked ~ label, .star-input label:hover, .star-input label:hover ~ label { color: #FBBF24; }
.star-input input:focus-visible + label { outline: 2px solid var(--indigo); border-radius: 8px; }
.review { padding: 14px 0; border-bottom: 1px dashed rgba(28,34,48,.16); }
.review:last-child { border-bottom: none; }

/* ============================================================
   LISTS · PAGER · DESKTOP / 4K LAYOUT
   Phones: bottom tab bar + one column + infinite scroll.
   >=1024px: left sidebar + multi-column card grids + numbered pager.
   ============================================================ */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 18px; align-items: start; }
.card-grid > .m-card, .card-grid > .prod-card, .card-grid > .card { margin-bottom: 0; }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 20px; margin: 22px 0 6px; padding-top: 16px; border-top: 1px solid var(--border); }
.pager-info { font-size: 13px; color: var(--txt-muted); }
.pager-nav, .pager-size { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pg { display: inline-flex; align-items: center; justify-content: center; min-width: 46px; height: 46px; padding: 0 12px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--bg-card); color: var(--txt); font-size: 14px; font-weight: 500; }
a.pg:hover { border-color: var(--indigo); }
.pg.active { background: var(--indigo); border-color: var(--indigo); color: #fff; font-weight: 700; }
.pg-gap { border: none; background: transparent; min-width: 24px; padding: 0; color: var(--txt-muted); }
.pager-size .pg { min-width: 42px; height: 40px; font-size: 13px; }
.inf-info { display: none; text-align: center; font-size: 12px; color: var(--txt-muted); margin: 14px 0 6px; }
.load-more { margin-top: 6px; }
.inf .pager { display: none; }
.inf .inf-info { display: block; }

/* order entry: product list + summary */
.order-layout { display: block; }

/* tablets / desktops */
.sidebar { display: none; }
@media (min-width: 1024px) {
  /* body keeps the fixed gradient */
  .tabbar { display: none; }
  .app-frame { padding-left: 264px; }
  .sidebar { display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; width: 264px; z-index: 120; background: var(--bg-card); border-right: 1px solid var(--border); overflow-y: auto; }
  .sb-brand { display: flex; align-items: center; gap: 12px; padding: 22px 22px 18px; font-size: 18px; font-weight: 700; border-bottom: 1px solid var(--border); }
  .sb-brand i { color: var(--indigo); font-size: 24px; }
  .sb-user { display: flex; align-items: center; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--border); }
  .sb-user .user-avatar { width: 42px; height: 42px; font-size: 17px; }
  .sb-nav { flex: 1; padding: 14px 12px; }
  .sb-link { display: flex; align-items: center; gap: 14px; min-height: 48px; padding: 0 16px; margin-bottom: 4px; border-radius: 12px; color: var(--txt-sec); font-size: 15px; font-weight: 500; }
  .sb-link i { width: 20px; text-align: center; font-size: 16px; }
  .sb-link:hover { background: var(--bg-hover); color: var(--txt); }
  .sb-link.active { background: rgba(30,58,95,.2); color: #152C49; font-weight: 600; }
  .sb-foot { padding: 14px 16px 18px; border-top: 1px solid var(--border); }
  .app-shell { max-width: none; margin: 0; border: none; box-shadow: none; background: transparent; }
  .app-header { height: 64px; padding: 0 40px; }
  .app-title { font-size: 20px; }
  .app-shop { max-width: 60%; font-size: 13px; }
  .app-main { max-width: 1680px; margin: 0 auto; padding: 32px 40px 64px; }
  .page-title { font-size: 26px; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
  .quick-actions { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
  .wallet-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
  .grid-2, [style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr 1fr !important; gap: 0 18px; }
  .card { padding: 24px; }
  .two-col { display: grid; grid-template-columns: 1fr; gap: 28px; align-items: start; }
  .detail-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 36px; align-items: start; }
  .detail-grid > .detail-media { position: sticky; top: 92px; }
  .edit-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
  .order-layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 0 28px; align-items: start; }
  .order-layout > * { grid-column: 1; }
  .order-layout > .sticky-bar { grid-column: 2; grid-row: 1 / span 4; position: sticky; top: 92px; bottom: auto; margin-top: 0; }
  .sticky-bar { box-shadow: none; }
  .btn-block { max-width: 100%; }
  .page-body-narrow { max-width: 760px; }
}
@media (min-width: 1280px) { .two-col { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
@media (min-width: 1900px) { .app-main { max-width: 1900px; } .card-grid { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); } }
/* 4K monitors (3840 css px at 100% scaling): scale the whole UI so text stays comfortably readable */
@media (min-width: 2400px) { html { zoom: 1.25; } }
@media (min-width: 3200px) { html { zoom: 1.5; } }

/* rating summary */
.rating-summary { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.rs-avg { text-align: center; min-width: 110px; }
.rs-num { font-size: 46px; font-weight: 700; line-height: 1; margin-bottom: 6px; }
.rs-bars { flex: 1; min-width: 200px; }
.rs-row { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--txt-muted); margin: 5px 0; }
.rs-row > span:first-child { width: 34px; white-space: nowrap; } .rs-row i { color: #FBBF24; font-size: 10px; }
.rs-track { flex: 1; height: 8px; background: var(--bg-hover); border-radius: 6px; overflow: hidden; }
.rs-fill { height: 100%; background: #FBBF24; border-radius: 6px; }
.rs-n { width: 28px; text-align: right; }

/* ============================================================
   PUBLIC STOREFRONT (walk-in visitors / SEO)
   ============================================================ */
/* storefront shares the page gradient */
.shop-header { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 clamp(14px, 3vw, 40px); height: 64px; background: rgba(238,240,242,.72); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); border-bottom: 1px solid rgba(28,34,48,.12); }
.shop-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; white-space: nowrap; }
.shop-nav { display: flex; gap: 8px; }
.shop-main { max-width: 1500px; margin: 0 auto; padding: 24px clamp(14px, 3vw, 40px) 60px; }
.shop-hero { text-align: center; padding: 32px 8px 30px; }
.shop-hero h1 { font-size: clamp(26px, 4vw, 40px); margin-bottom: 10px; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 18px; }
.shop-card { display: block; background: var(--bg-card); border: 1px solid var(--border); border-radius: 18px; overflow: hidden; transition: transform .15s, border-color .15s; }
.shop-card:hover { border-color: var(--indigo); transform: translateY(-2px); }
.shop-card-main { display: block; }
.var-list { border-top: 1px solid var(--border); padding: 6px 10px 10px; }
.var-item { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 6px; border-radius: 12px; }
.var-item:hover { background: var(--bg-hover); }
.var-thumb { width: 44px; height: 44px; border-radius: 10px; overflow: hidden; background: var(--bg-hover); display: flex; align-items: center; justify-content: center; color: var(--txt-muted); }
.var-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.var-name { font-size: 14px; font-weight: 500; line-height: 1.35; }
.var-price { text-align: right; font-size: 14px; white-space: nowrap; }
.var-price .was { display: block; font-size: 11px; }
.shop-img { position: relative; aspect-ratio: 1 / 1; background: var(--bg-hover); }
.shop-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shop-body { padding: 14px 16px 18px; }
.shop-name { font-size: 15px; font-weight: 600; line-height: 1.4; margin-bottom: 6px; min-height: 42px; }
.shop-footer { border-top: 1px solid var(--border); padding: 26px 20px; text-align: center; color: var(--txt-muted); font-size: 13px; }
.breadcrumb { font-size: 13px; color: var(--txt-muted); margin-bottom: 16px; }
.breadcrumb a { color: var(--txt-sec); }
@media (min-width: 1900px) { .shop-main { max-width: 1900px; } .shop-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); } }
@media (min-width: 1024px) { .shop-main .detail-grid > .detail-media { top: 88px; } }

/* payment slips + storefront ordering */
.slip { display: flex; gap: 14px; align-items: flex-start; padding: 12px 0; border-bottom: 1px dashed rgba(28,34,48,.16); }
.slip:last-of-type { border-bottom: none; }
.slip-img { width: 96px; height: 128px; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); background: var(--bg-hover); display: block; }
body.shop .sticky-bar { bottom: 12px; }
@media (min-width: 1024px) { body.shop .order-layout > .sticky-bar { top: 88px; } }

/* product lines (families) */
.fam-chips, .variant-chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 6px 0 4px; }
.variant-chips { gap: 8px; margin: 12px 0; }

.qr-box { display: inline-block; width: 220px; max-width: 70vw; background: #fff; padding: 8px; border-radius: 12px; }
.qr-box svg { display: block; width: 100%; height: auto; }

/* ---------- SCROLLBARS: thin, rounded, translucent ---------- */
:root { color-scheme: light; }                                  /* native scrollbars, form controls and pickers follow the light theme */
* { scrollbar-width: thin; scrollbar-color: rgba(28,34,48,.32) transparent; }   /* Chrome 121+, Edge, Firefox */
@supports not (scrollbar-color: auto) {                          /* older Chrome / Safari */
  *::-webkit-scrollbar { width: 10px; height: 10px; }
  *::-webkit-scrollbar-track { background: transparent; }
  *::-webkit-scrollbar-thumb { background: rgba(28,34,48,.32); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
  *::-webkit-scrollbar-thumb:hover { background: rgba(28,34,48,.5); background-clip: content-box; }
  *::-webkit-scrollbar-corner { background: transparent; }
}
.sidebar { scrollbar-color: rgba(28,34,48,.18) transparent; }               /* menu list: even quieter until it is used */
.sidebar:hover { scrollbar-color: rgba(28,34,48,.32) transparent; }
.chips, .g-strip { scrollbar-width: none; }                      /* horizontal strips stay hidden (swipe) */
/* Thai address widget: line + postcode / subdistrict / district / province with a pick list */
.addr { position: relative; }
.addr > .form-control { margin-bottom: 8px; }
.addr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.addr-hint { margin-top: 6px; font-size: 12px; color: var(--txt-muted); }
.addr-grid select.form-control:disabled { opacity: .55; }
.addr-list { position: absolute; left: 0; right: 0; z-index: 60; margin-top: 2px; max-height: 260px; overflow-y: auto; background: var(--bg-card); border: 1px solid var(--indigo); border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.12); }
.addr-list[hidden] { display: none; }
.addr-item { padding: 10px 12px; font-size: 14px; color: var(--txt-sec); cursor: pointer; border-bottom: 1px solid var(--border); }
.addr-item:last-child { border-bottom: 0; }
.addr-item b { color: var(--txt); margin-right: 6px; }
.addr-item:hover, .addr-item.on { background: var(--bg-hover); color: var(--txt); }

/* ============================================================
   GLASS SURFACES — one place that turns every panel into frosted glass.
   Later in the file than the layout rules on purpose, so it wins at equal specificity.
   ============================================================ */
.card, .m-card, .stat-card, .quick-btn, .menu-card, .prod-card, .login-card, .shop-card, .media-item, .sidebar, .pg, .chip, .demo-btn, .paper-card {
  background: var(--glass-bg); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border: var(--glass-border); box-shadow: var(--glass-shadow);
}
.sidebar { background: rgba(238,240,242,.7); border-width: 0 1px 0 0; border-color: rgba(28,34,48,.12); box-shadow: 0 8px 32px rgba(0,0,0,.04); }
/* floating layers need a firmer pane so text underneath never shows through */
.sheet, .addr-list, .sticky-bar { background: var(--bg-solid); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); border: var(--glass-border); box-shadow: 0 8px 32px rgba(0,0,0,.08); color: var(--txt); }
.sticky-bar { border-color: rgba(30,58,95,.45); }
.addr-list { border-color: rgba(30,58,95,.45); }
/* tiles that sit INSIDE a glass card: a quiet tint, no second blur */
.wallet-item, .tier-cell, .geo-dist, .var-row { background: rgba(90,100,120,.08); border: 1px solid rgba(238,240,242,.6); box-shadow: none; }
.geo-na { background: transparent; border: 1px dashed rgba(28,34,48,.25); }
.var-row { border: 1.5px solid rgba(28,34,48,.14); }
.var-row.selected, .prod-card.selected, .fam-card.selected { border-color: var(--emerald); }
.stat-card, .stat-card[class*="stat-"] { border-left-width: 1px; position: relative; overflow: hidden; }
.stat-card::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 4px; border-radius: 0 4px 4px 0; background: var(--indigo); }
.stat-emerald::before { background: var(--emerald); } .stat-amber::before { background: var(--amber); } .stat-red::before { background: var(--red); }
a.m-card:active, .menu-card:active { border-color: rgba(30,58,95,.5); background: rgba(238,240,242,.85); }
.quick-btn.primary { background: rgba(30,58,95,.10); border-color: rgba(30,58,95,.4); }
.pg.active, .chip.active { background: var(--indigo); border-color: var(--indigo); box-shadow: 0 4px 14px rgba(30,58,95,.3); }
.geo-card[open] { border-color: rgba(30,58,95,.45); }
.geo-top { border-color: rgba(245,160,11,.6); }
.tab.active { color: var(--indigo); }
.sb-link:hover { background: rgba(90,100,120,.1); }
.sb-link.active { background: rgba(30,58,95,.12); color: var(--indigo-h); }

/* inputs: white glass wells with a hairline edge */
.form-control, .form-control-lg, .tier-select { background: rgba(238,240,242,.7); border: 1.5px solid rgba(28,34,48,.18); color: var(--txt); box-shadow: inset 0 1px 2px rgba(0,0,0,.03); }
.form-control:focus, .tier-select:focus { border-color: var(--indigo); box-shadow: 0 0 0 4px rgba(30,58,95,.16); background: #F5F6F8; }
.qty-step { background: rgba(238,240,242,.7); }
.qty-step input { background: transparent; }
.qty-step button { background: rgba(90,100,120,.1); }
.qty-step button:active { background: var(--indigo); color: #fff; }

/* buttons */
.btn-primary { box-shadow: 0 6px 18px rgba(30,58,95,.28); }
.btn-emerald { background: #1FA463; box-shadow: 0 6px 18px rgba(31,164,99,.25); }
.btn-outline { background: rgba(238,240,242,.55); border-color: rgba(28,34,48,.22); }
.btn-danger { background: rgba(229,56,74,.1); border-color: rgba(229,56,74,.4); }

/* status colours tuned for a light ground (text darker, tint lighter) */
.badge-indigo { background: rgba(30,58,95,.13); } .badge-emerald { background: rgba(31,164,99,.14); }
.badge-amber { background: rgba(245,160,11,.17); } .badge-red { background: rgba(229,56,74,.12); }
.badge-gray { background: rgba(90,100,120,.14); color: var(--txt-sec); }
.alert-success { background: rgba(31,164,99,.12); border-color: rgba(31,164,99,.3); }
.alert-error, .validation-summary-errors { background: rgba(229,56,74,.09); border-color: rgba(229,56,74,.3); }
.ds-shield { background: rgba(31,164,99,.08); border-color: rgba(31,164,99,.25); }
.price-promo { color: var(--red); }
.m-amount.pos, .geo-dist-amt { color: var(--emerald-d); }
.geo-label i, .stars { color: #F5A00B; }
.geo-medal { background: rgba(90,100,120,.18); }
.geo-medal-1 { background: #F5A00B; color: #3A2600; } .geo-medal-2 { background: #C7C7CC; color: #1D1D1F; } .geo-medal-3 { background: #D98A3D; color: #2B1600; }
.geo-top .geo-rank { background: #F5A00B; color: #3A2600; }
.tier-vip { background: rgba(245,160,11,.2); border-color: rgba(245,160,11,.45); }
.tier-s { background: rgba(30,58,95,.10); border-color: rgba(30,58,95,.35); }
.tier-a { background: rgba(31,164,99,.16); border-color: rgba(31,164,99,.35); }
.tier-b { background: rgba(90,100,120,.14); color: var(--txt-sec); }
.demo-factory { background: rgba(30,58,95,.10); color: var(--indigo-h); } .demo-merchant { background: rgba(31,164,99,.16); } .demo-affiliate { background: rgba(245,160,11,.2); }
.menu-icon { background: rgba(30,58,95,.12); }
.user-avatar { background: linear-gradient(135deg, #3B5F8F, #1E3A5F); color: #fff; }
.thumb-wrap, .gallery .g-main, .gallery .g-empty, .slip-img, .shop-img { background: rgba(90,100,120,.1); }
.rs-track { background: rgba(90,100,120,.16); }
.geo-bar { background: rgba(90,100,120,.16); }
.pager { border-top-color: rgba(28,34,48,.14); }
.geo-body { border-top-color: rgba(28,34,48,.14); }
.demo-section .demo-btn { color: var(--txt-sec); }

/* browsers without backdrop-filter: make the glass a little more opaque so it stays legible */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root { --glass-bg: rgba(238,240,242,.9); --bg-solid: rgba(238,240,242,.97); }
  .app-header, .tabbar, .shop-header, .sidebar { background: rgba(238,240,242,.96); }
}
@media print { .card, .m-card { background: #fff; backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: none; } body { background: #fff !important; } }

/* ============================================================
   AUTO DARK MODE — follows the user's OS (Windows / macOS / iOS / Android) via prefers-color-scheme.
   No toggle, nothing to configure. Dark is a soft charcoal (not pure black) with lifted cards, so it stays roomy.
   Receipts, invoices and QR boxes (.paper / .invoice / .qr-box) stay white on purpose: they are documents.
   ============================================================ */
@media screen and (prefers-color-scheme: dark) {
  :root { color-scheme: dark;
    --bg: #26272A; --bg-outer: #26272A; --bg-card: #161718; --bg-solid: rgba(22,23,24,.98); --bg-hover: rgba(255,255,255,.08); --border: rgba(255,255,255,.09);
    --glass-bg: #161718; --glass-border: 1px solid rgba(255,255,255,.06); --glass-shadow: none;
    --indigo: #7FA6E8; --indigo-h: #A9C3F0; --emerald: #34C98A; --emerald-d: #4ADE9F; --amber: #E0A32A; --red: #F0586B; --gold: #E0A32A;
    --txt: #E3E3E3; --txt-sec: #C4C7C5; --txt-muted: #9AA0A6; }
  body { background-image: none; background-color: #26272A; }
  * { scrollbar-color: rgba(255,255,255,.28) transparent; }

  /* bars */
  .app-header, .shop-header { background: rgba(38,39,42,.92); border-bottom-color: rgba(255,255,255,.08); }
  .tabbar { background: rgba(24,25,26,.97); border-top-color: rgba(255,255,255,.08); }
  .sidebar { background: #1B1C1E; border-color: rgba(255,255,255,.08); box-shadow: none; }
  .tab-primary i { border-color: #1B1C1E; }

  /* filled primary controls: a mid blue so white text keeps its contrast (the light --indigo is for text/borders) */
  .btn-primary, .chip.active, .pg.active, .user-avatar, .tab-primary i, .qty-step button:active { background: #3F6CB5; border-color: #3F6CB5; color: #fff; }
  .btn-primary { box-shadow: 0 6px 18px rgba(0,0,0,.35); }
  .btn-primary:active { background: #345C9E; }
  .user-avatar { background: linear-gradient(135deg, #5B86CC, #3F6CB5); }
  .pg.active, .chip.active { box-shadow: 0 4px 14px rgba(0,0,0,.35); }

  /* forms */
  .form-control, .form-control-lg, .tier-select, .qty-step { background: #2A2B2F; border-color: transparent; box-shadow: none; }
  .form-control:focus, .tier-select:focus { background: #323338; border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(127,166,232,.22); }
  .qty-step button { background: rgba(255,255,255,.07); }
  .btn-outline { background: transparent; border-color: rgba(255,255,255,.22); }
  .btn-danger { background: rgba(240,88,107,.14); color: #FF8A98; border-color: rgba(240,88,107,.45); }

  /* tiles + surfaces inside cards */
  .wallet-item, .tier-cell, .geo-dist, .var-row { background: rgba(255,255,255,.05); border-color: transparent; }
  .var-row { border-color: rgba(255,255,255,.12); }
  .geo-na { border-color: rgba(255,255,255,.2); }
  a.m-card:active, .menu-card:active { background: rgba(255,255,255,.06); border-color: rgba(127,166,232,.5); }
  .sticky-bar, .addr-list { border-color: rgba(127,166,232,.4); box-shadow: 0 8px 32px rgba(0,0,0,.5); }
  .sheet, .addr-list { box-shadow: 0 12px 40px rgba(0,0,0,.5); }
  .sheet::backdrop { background: rgba(0,0,0,.55); }
  .geo-card[open] { border-color: rgba(127,166,232,.45); }
  .thumb-wrap, .gallery .g-main, .gallery .g-empty, .slip-img, .shop-img { background: rgba(255,255,255,.06); }
  .rs-track, .geo-bar { background: rgba(255,255,255,.12); }
  .geo-medal { background: rgba(255,255,255,.14); }
  .kv, .review, .slip { border-bottom-color: rgba(255,255,255,.12); }
  .pager, .geo-body { border-top-color: rgba(255,255,255,.1); }

  /* tinted badges / status: lighter text on a tinted dark ground */
  .badge-indigo, .geo-rank, .tier-s, .demo-factory, .sb-link.active, .menu-icon { background: rgba(127,166,232,.16); color: #A9C3F0; }
  .tier-s { border-color: rgba(127,166,232,.4); }
  .badge-emerald, .tier-a, .demo-merchant { background: rgba(52,201,138,.16); color: #4ADE9F; }
  .badge-amber, .tier-vip, .demo-affiliate { background: rgba(224,163,42,.18); color: #F0C060; }
  .badge-red { background: rgba(240,88,107,.16); color: #FF8A98; }
  .geo-top .geo-rank { background: #E0A32A; color: #2A1B00; }
  .alert-success { background: rgba(52,201,138,.12); border-color: rgba(52,201,138,.3); color: #4ADE9F; }
  .alert-error, .validation-summary-errors { background: rgba(240,88,107,.12); border-color: rgba(240,88,107,.32); color: #FF8A98; }
  .field-validation-error, .price-promo { color: #FF8A98; }
  .ds-shield { background: rgba(52,201,138,.08); border-color: rgba(52,201,138,.25); }
  .sb-link:hover { background: rgba(255,255,255,.06); }
}

/* ---------- in-app confirm dialog (replaces the browser/OS confirm box) ---------- */
.confirm-back { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(0,0,0,.5); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.confirm-back[hidden] { display: none; }
.confirm-box { width: 100%; max-width: 400px; padding: 22px 20px 18px; border-radius: 20px; background: var(--bg-solid); color: var(--txt); border: 1px solid var(--border); box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.confirm-msg { font-size: 16px; line-height: 1.6; font-weight: 500; margin-bottom: 18px; white-space: pre-line; }
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions .btn { flex: 1; margin: 0; min-height: 48px; }
.btn-danger-solid { background: var(--red); color: #fff; }