:root {
  /* Keto Vegan Living logo palette: blue #45B1E3 · green #76BE43 · purple #8C52A0 · deep green #0BA04A · brown #5D4E3B */
  --bg: #f6f8f4; --card: #ffffff; --ink: #1f2a1c; --muted: #66705f; --line: #e3e8de; --soft: #eef2ea;
  --brand: #43801f; --brand-ink: #ffffff; --brand-text: #3f7d1f; --brand-soft: #eaf5e1; --brand-bright: #76be43;
  --member: #7b4290; --member-soft: #f4ebf8; --link: #1a6fa0; --blue-soft: #e5f4fb;
  --sale: #c2410c; --sale-soft: #fdeee4; --danger: #b42318; --danger-soft: #fdecea; --warn: #9a5a06; --warn-soft: #fff4dc;
  --shadow: 0 1px 2px rgba(20,30,20,.06), 0 4px 16px rgba(20,30,20,.06);
  --radius: 14px; --tabh: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121612; --card: #1b211b; --ink: #e9efe6; --muted: #9ca898; --line: #2c352b; --soft: #232b22;
    --brand: #76be43; --brand-ink: #0f1d08; --brand-text: #8fd05f; --brand-soft: #22341a; --brand-bright: #76be43;
    --member: #c9a2dc; --member-soft: #33233d; --link: #6cc4ee; --blue-soft: #16303d;
    --sale: #ff8a4c; --sale-soft: #3a2418; --danger: #ff7b6e; --danger-soft: #3a1d1a; --warn: #f5b84a; --warn-soft: #3a2e16;
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); }
h2 { font-size: 18px; margin: 22px 0 10px; }
h3 { font-size: 15px; margin: 18px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* layout */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--safe-t)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.topbar-logo { height: 30px; width: auto; border-radius: 7px; background: #fff; padding: 2px 4px; flex: none; }
.topbar-logo + .topbar-title { font-size: 18px; }
.topbar-title { font-weight: 700; font-size: 20px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: 8px; }
.view { padding: 14px 16px calc(var(--tabh) + var(--safe-b) + 24px); max-width: 1180px; margin: 0 auto; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: center; gap: 4px;
  height: calc(var(--tabh) + var(--safe-b)); padding-bottom: var(--safe-b); background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.tabbar a { position: relative; flex: 1; max-width: 140px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600; }
.tabbar a.active { color: var(--brand-text); }
.tabbar svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar svg circle { fill: currentColor; stroke: none; }
.badge { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--sale); color: #fff;
  font-size: 11px; line-height: 18px; text-align: center; font-weight: 700; }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.big { min-height: 56px; font-size: 18px; border-radius: 14px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.icon-btn { width: 44px; height: 44px; padding: 0; border-radius: 12px; }
.icon-btn svg, .btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
input[type=text], input[type=search], input[type=number], input[type=password], input[type=email], input[type=tel], input[type=date], input[type=url], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); font-size: 16px; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 0; border-color: var(--brand); }
label.field { display: block; margin: 0 0 12px; }
label.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 5px; }
.hint { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 12px; }
@media (max-width: 520px) { .grid3 { grid-template-columns: 1fr 1fr; } }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 14px; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.switch:last-child { border-bottom: 0; }
.switch .lbl { flex: 1; }
.switch .lbl small { display: block; color: var(--muted); font-size: 13px; }
.toggle { position: relative; width: 51px; height: 31px; flex: none; }
.toggle input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; z-index: 1; cursor: pointer; }
.toggle i { position: absolute; inset: 0; border-radius: 16px; background: var(--line); transition: background .15s; }
.toggle i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.toggle input:checked + i { background: var(--brand); }
.toggle input:checked + i::after { transform: translateX(20px); }

.seg { display: flex; background: var(--soft); border-radius: 12px; padding: 3px; gap: 3px; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: 1 0 auto; border: 0; background: transparent; padding: 8px 12px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); padding: 7px 13px; border-radius: 20px; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 700; background: var(--soft); color: var(--muted); white-space: nowrap; }
.pill.sale { background: var(--sale-soft); color: var(--sale); }
.pill.ok { background: var(--brand-soft); color: var(--brand-text); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.card + .card { margin-top: 12px; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty b { display: block; color: var(--ink); font-size: 17px; margin-bottom: 6px; }
.search-row { display: flex; gap: 8px; margin-bottom: 10px; }
.search-row input { flex: 1; }

/* product grid */
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
@media (min-width: 900px) { .pgrid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); } }
.pcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); cursor: pointer; display: flex; flex-direction: column; text-align: left; padding: 0; }
.pcard:active { transform: scale(.985); }
.thumb { position: relative; aspect-ratio: 1; background: #fff; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.ph { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 28px; color: #fff; letter-spacing: .02em; }
.pcard .thumb .pill { position: absolute; top: 8px; left: 8px; }
.pcard .thumb .stock { position: absolute; top: 8px; right: 8px; left: auto; }
.pcard .info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.pcard .brand { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.pcard .name { font-weight: 600; font-size: 15px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pcard .size { font-size: 13px; color: var(--muted); }
.prices { margin-top: auto; padding-top: 6px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.prices .retail { font-weight: 700; }
.prices .was { text-decoration: line-through; color: var(--muted); font-size: 13px; }
.prices .mem { color: var(--member); font-weight: 700; font-size: 14px; }

/* list rows */
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); min-height: 60px; }
.li:last-child { border-bottom: 0; }
.li.tap { cursor: pointer; }
.li.tap:active { background: var(--soft); }
.li .t { width: 48px; height: 48px; border-radius: 10px; overflow: hidden; flex: none; background: #fff; border: 1px solid var(--line); }
.li .t img { width: 100%; height: 100%; object-fit: contain; }
.li .t .ph { font-size: 15px; }
.li .main { flex: 1; min-width: 0; }
.li .main .n { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .main .s { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .end { text-align: right; flex: none; }
.group-h { padding: 8px 12px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; background: var(--soft); border-bottom: 1px solid var(--line); }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; flex: none; background: var(--card); }
.stepper button { width: 40px; height: 40px; border: 0; background: transparent; font-size: 22px; font-weight: 600; cursor: pointer; color: var(--ink); }
.stepper button:active { background: var(--soft); }
.stepper input { width: 46px; height: 40px; border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); border-radius: 0; text-align: center; padding: 0; min-height: 0; font-weight: 700; }

/* checkout */
.co { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 860px) { .co { grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr); align-items: start; } .co .side { position: sticky; top: 76px; } }
.scanbar { display: flex; gap: 8px; }
.scanbar input { flex: 1; font-size: 17px; min-height: 50px; }
.scanbar .btn { min-height: 50px; }
.results { margin-top: 8px; }
.cart-line { display: grid; grid-template-columns: 48px 1fr auto; gap: 6px 12px; padding: 12px; border-bottom: 1px solid var(--line); align-items: center; }
.cart-line:last-child { border-bottom: 0; }
.cart-line .t { width: 48px; height: 48px; border-radius: 10px; overflow: hidden; background: #fff; border: 1px solid var(--line); }
.cart-line .t img { width: 100%; height: 100%; object-fit: contain; }
.cart-line .t .ph { font-size: 15px; }
.cart-line .n { font-weight: 600; line-height: 1.25; }
.cart-line .s { font-size: 13px; color: var(--muted); }
.cart-line .ctl { grid-column: 2 / 4; display: flex; align-items: center; gap: 10px; }
.cart-line .lt { text-align: right; }
.cart-line .lt .disc { color: var(--member); font-size: 13px; font-weight: 600; }
.totals .tr { display: flex; justify-content: space-between; padding: 5px 0; }
.totals .tr.disc { color: var(--member); font-weight: 600; }
.totals .tr.total { font-size: 24px; font-weight: 800; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; }
.saved { background: var(--member-soft); color: var(--member); border-radius: 10px; padding: 8px 12px; font-weight: 700; text-align: center; margin-top: 8px; }
.codechip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 6px 6px 12px; border-radius: 20px; background: var(--member-soft); color: var(--member); font-weight: 700; font-size: 14px; }
.codechip button { border: 0; background: transparent; color: inherit; font-size: 18px; width: 26px; height: 26px; border-radius: 13px; cursor: pointer; }
.msg { padding: 10px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 14px; margin-top: 8px; }
.pay { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pay .btn.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
#reader { width: 100%; border-radius: 14px; overflow: hidden; background: #000; }
#reader video { border-radius: 14px; }
.scanpanel { margin: 10px 0; }

/* sheet / modal */
.sheet-bg { position: fixed; inset: 0; z-index: 50; background: rgba(10,16,11,.42); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.sheet { width: 100%; max-width: 680px; max-height: calc(100dvh - 30px - var(--safe-t)); background: var(--bg); border-radius: 20px 20px 0 0; display: flex; flex-direction: column; animation: up .2s ease; box-shadow: 0 -8px 40px rgba(0,0,0,.2); }
@media (min-width: 760px) { .sheet-bg { align-items: center; } .sheet { border-radius: 20px; max-height: 90dvh; } .sheet.wide { max-width: 900px; } }
.sheet-h { display: flex; align-items: center; gap: 8px; padding: 12px 12px 10px 18px; border-bottom: 1px solid var(--line); }
.sheet-h .tt { flex: 1; font-weight: 700; font-size: 17px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-b { overflow-y: auto; padding: 16px 18px; -webkit-overflow-scrolling: touch; }
.sheet-f { padding: 12px 18px calc(12px + var(--safe-b)); border-top: 1px solid var(--line); display: flex; gap: 10px; }
.sheet-f .btn { flex: 1; }
@keyframes up { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* product detail */
.pd-top { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 640px) { .pd-top { grid-template-columns: 240px 1fr; } }
.pd-img { aspect-ratio: 1; background: #fff; border-radius: 14px; border: 1px solid var(--line); overflow: hidden; display: flex; align-items: center; justify-content: center; }
.pd-img img { width: 100%; height: 100%; object-fit: contain; padding: 10px; }
.pd-img .ph { font-size: 44px; }
.pd-brand { font-size: 13px; text-transform: uppercase; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.pd-name { font-size: 22px; font-weight: 800; line-height: 1.2; margin: 2px 0 4px; }
.pd-prices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.pd-prices .box { border-radius: 12px; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); }
.pd-prices .box.mem { background: var(--member-soft); border-color: transparent; color: var(--member); }
.pd-prices .box small { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; opacity: .8; }
.pd-prices .box b { font-size: 24px; }
.pd-sec { margin-top: 16px; }
.pd-sec h4 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.pd-sec p { margin: 0; white-space: pre-wrap; line-height: 1.5; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.stat small { display: block; font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.stat b { font-size: 22px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.tbl td.num, .tbl th.num { text-align: right; white-space: nowrap; }
.scroll-x { overflow-x: auto; }

.toast { position: fixed; left: 50%; bottom: calc(var(--tabh) + var(--safe-b) + 14px); transform: translateX(-50%) translateY(20px); z-index: 80;
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 600; max-width: calc(100% - 32px); opacity: 0; pointer-events: none; transition: all .2s; text-align: center; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.bad { background: var(--danger); color: #fff; }
.toast.good { background: var(--brand); color: var(--brand-ink); }

.login { max-width: 380px; margin: 12vh auto 0; text-align: center; }
.login .logo { width: 220px; max-width: 70%; height: auto; border-radius: 18px; margin: 0 auto 18px; display: block; background: #fff; padding: 6px; }
.progress { height: 8px; background: var(--soft); border-radius: 4px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--brand); width: 0; transition: width .2s; }
.menu .li { min-height: 56px; }
.menu .li svg { width: 24px; height: 24px; fill: none; stroke: var(--brand-text); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.chev { color: var(--muted); font-size: 20px; }

#printArea { display: none; }
@media print {
  body > #app, body > #sheetRoot, body > #toast { display: none !important; }
  #printArea { display: block !important; color: #000; font-size: 12px; }
  #printArea table { width: 100%; border-collapse: collapse; }
  #printArea th, #printArea td { border-bottom: 1px solid #ccc; padding: 4px; text-align: left; }
  #printArea h1 { font-size: 18px; } #printArea h2 { font-size: 14px; margin: 14px 0 4px; }
}

/* password with show/hide */
.pw { position: relative; }
.pw input { padding-right: 74px; }
.pw .eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: var(--blue-soft); color: var(--link); font-weight: 700; font-size: 14px; padding: 7px 10px; border-radius: 9px; cursor: pointer; }
.pwmsg { font-size: 13px; min-height: 18px; margin: -6px 0 10px; }
.pwmsg.ok { color: var(--brand-text); } .pwmsg.bad { color: var(--danger); }

/* logo-colored accents */
.tabbar a.active::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px;
  background: linear-gradient(90deg, #45b1e3 0 33%, #76be43 33% 66%, #8c52a0 66%); }
.pd-brand, .pcard .brand { color: var(--link); }
[hidden] { display: none !important; }
body.logged-out .topbar { display: none; }
