:root {
  --bg: #f4f6fa; --card: #fff; --ink: #18202e; --muted: #6b7486; --line: #e3e7ef;
  --accent: #2563eb; --accent-ink: #fff; --green: #15924a; --red: #d93a3a; --warn: #b7791f;
  --r: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

header { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: var(--card); border-bottom: 1px solid var(--line); }
.title { flex: 1; font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { border: 0; background: none; width: 40px; height: 40px; border-radius: 12px; font-size: 28px; line-height: 1;
  display: grid; place-items: center; position: relative; cursor: pointer; }
.icon-btn:active { background: var(--bg); }
.badge { position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--red); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.pill { border: 1px solid var(--line); background: var(--bg); border-radius: 20px; padding: 6px 12px; font-size: 13px; font-weight: 600; }

main { padding: 12px 12px 110px; max-width: 760px; margin: 0 auto; }
.loader, .empty { text-align: center; color: var(--muted); padding: 40px 10px; }
h2 { font-size: 20px; margin: 6px 2px 12px; }
h3 { font-size: 16px; margin: 18px 2px 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.search { display: flex; gap: 8px; margin-bottom: 12px; }
.search input { flex: 1; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: var(--card); outline: none; }
.search input:focus { border-color: var(--accent); }

.hero { background: linear-gradient(135deg, #1d4ed8, #3b82f6); color: #fff; border-radius: var(--r); padding: 16px; margin-bottom: 14px; }
.hero b { font-size: 18px; display: block; margin-bottom: 4px; }
.hero .small { opacity: .9; }

.cats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cat { background: var(--card); border-radius: var(--r); padding: 14px; border: 1px solid var(--line); cursor: pointer; min-height: 70px; }
.cat b { display: block; font-size: 15px; }
.cat span { color: var(--muted); font-size: 13px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { white-space: nowrap; border: 1px solid var(--line); background: var(--card); border-radius: 18px; padding: 7px 12px; font-size: 13px; cursor: pointer; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.frow { display: flex; align-items: center; gap: 8px; }
.flabel { font-size: 12px; color: var(--muted); width: 52px; flex: none; padding-bottom: 10px; }
.frow .chips { flex: 1; min-width: 0; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0,0,0,.18); margin-right: 6px; vertical-align: -2px; }
.props { display: grid; gap: 4px; margin: 8px 2px 10px; font-size: 13px; }
.props div { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line); padding: 3px 0; }
.props span { color: var(--muted); }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin: 0 2px 10px; }
.toolbar select { border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; background: var(--card); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.card { background: var(--card); border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); display: flex; flex-direction: column; cursor: pointer; }
.card .ph { aspect-ratio: 1; background: #fff; display: grid; place-items: center; }
.card .ph img { width: 100%; height: 100%; object-fit: contain; }
.noimg { color: #c3c9d4; font-size: 12px; text-align: center; }
.card .body { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card .brand { font-size: 12px; color: var(--muted); }
.card .name { font-size: 13px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; flex: 1; }
.price { font-weight: 800; font-size: 17px; }
.card .row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.add { border: 0; background: var(--accent); color: var(--accent-ink); width: 36px; height: 36px; border-radius: 12px; font-size: 22px; cursor: pointer; }
.add.in { background: var(--green); font-size: 15px; font-weight: 700; }
.stock { font-size: 12px; color: var(--green); }
.more { width: 100%; margin-top: 12px; }

.btn { border: 0; background: var(--accent); color: var(--accent-ink); border-radius: 14px; padding: 14px 16px; font-weight: 700; font-size: 16px; cursor: pointer; width: 100%; }
.btn.ghost { background: var(--card); color: var(--accent); border: 1px solid var(--line); }
.btn.green { background: var(--green); }
.btn.red { background: var(--red); }
.btn.sm { padding: 8px 12px; font-size: 14px; width: auto; border-radius: 10px; }
.btn:disabled { opacity: .5; }

.product .ph { background: #fff; border-radius: var(--r); aspect-ratio: 1; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); }
.product .ph img { width: 100%; height: 100%; object-fit: contain; }
.product h1 { font-size: 19px; margin: 12px 2px 6px; }
.product .meta { color: var(--muted); font-size: 13px; margin: 0 2px; }
.product .price { font-size: 26px; margin: 10px 2px; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.qty button { border: 0; background: none; width: 40px; height: 40px; font-size: 22px; cursor: pointer; }
.qty span { min-width: 34px; text-align: center; font-weight: 700; }
.buybar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); display: flex; gap: 10px; align-items: center; z-index: 9; }
.buybar .btn { flex: 1; }

.box { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; margin-bottom: 10px; }
.line { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.line:last-child { border-bottom: 0; }
.line .thumb { width: 56px; height: 56px; border-radius: 10px; background: #fff; border: 1px solid var(--line); flex: none; overflow: hidden; display: grid; place-items: center; }
.line .thumb img { width: 100%; height: 100%; object-fit: contain; }
.line .info { flex: 1; min-width: 0; }
.line .info .n { font-size: 13px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sum { display: flex; justify-content: space-between; margin: 4px 0; }
.sum.total { font-weight: 800; font-size: 18px; }

label.f { display: block; font-size: 13px; color: var(--muted); margin: 10px 2px 4px; }
.f-input, textarea.f-input, select.f-input { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--card); outline: none; }
.f-input:focus { border-color: var(--accent); }
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 10px; padding: 9px; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.err { color: var(--red); margin: 10px 2px; }

.status { display: inline-block; padding: 3px 8px; border-radius: 8px; font-size: 12px; font-weight: 700; background: #e8eefc; color: var(--accent); }
.status.done { background: #e3f5ea; color: var(--green); }
.status.cancelled { background: #fbe9e9; color: var(--red); }
.status.new { background: #fff3db; color: var(--warn); }

.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.owner { border: 1px dashed #93b4f5; background: #f2f6ff; }
.offer { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 14px; }
.brand-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.brand-row .b { flex: 1; }
.brand-row input { width: 74px; border: 1px solid var(--line); border-radius: 10px; padding: 7px; text-align: right; }
.switch { display: flex; align-items: center; gap: 8px; margin: 10px 2px; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: #18202e; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 50; max-width: 90%; }
.demo-note { font-size: 12px; color: var(--muted); text-align: center; margin: 14px 0; }
.fld { display: block; font-size: 12px; color: var(--muted); margin-top: 8px; }
.fld input, .fld textarea { display: block; width: 100%; box-sizing: border-box; margin-top: 4px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--card); color: var(--ink); font-size: 15px; outline: none; }
.fld input:focus, .fld textarea:focus { border-color: var(--accent); }
.box .btn { margin-top: 10px; }
.sup { cursor: pointer; }
