:root {
  --bg: #FFFFFF; --ink: #1C1C21; --muted: #6F6F78; --muted2: #55555D;
  --tile: #F3F3F5; --line: #ECECEF; --field: #D6D6DC;
  --btn: #26262B; --btn-ink: #FFFFFF;
  --green-bg: #E4F4E4; --green: #1E4A23; --green2: #2E5E33;
  --purple-bg: #DCCBF8; --purple: #3C2370;
  --blue-bg: #CDE7F8; --blue: #13466B;
  --orange-bg: #F9E3C8; --orange: #6B3A06; --orange-line: #F0C48E; --orange-tint: #FFF8EF;
  --red-bg: #FBE5E2; --red: #7A2318;
  --bar: #CDE7F8; --bar-hi: #2F7DB5;
  --safe: env(safe-area-inset-bottom, 0px);
}
[data-theme="dark"] {
  --bg: #17171A; --ink: #F2F2F5; --muted: #A0A0AA; --muted2: #B8B8C1;
  --tile: #232328; --line: #2E2E35; --field: #44444C;
  --btn: #F2F2F5; --btn-ink: #17171A;
  --green-bg: #1F3A23; --green: #C3EBC6; --green2: #A9DBAD;
  --purple-bg: #3A2E55; --purple: #E2D4FA;
  --blue-bg: #1D3A50; --blue: #D3EAF9;
  --orange-bg: #4A3218; --orange: #F9DDB8; --orange-line: #7A5426; --orange-tint: #2A2118;
  --red-bg: #4A2320; --red: #F7CCC6;
  --bar: #2B4A63; --bar-hi: #6BB2E4;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: Manrope, system-ui, -apple-system, sans-serif; font-size: 16px; line-height: 1.35; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

#view { padding: 20px 16px calc(180px + var(--safe)); max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
body.no-tabs #view { padding-bottom: calc(110px + var(--safe)); }

/* типографика */
.h1 { font-size: 24px; font-weight: 800; margin: 0; }
.h2 { font-size: 18px; font-weight: 700; margin: 0; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
.center { text-align: center; }

/* блоки */
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile { background: var(--tile); border-radius: 20px; padding: 16px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.tile .val { font-size: 24px; font-weight: 800; letter-spacing: -0.4px; overflow-wrap: anywhere; }
.tile.green { background: var(--green-bg); color: var(--green); }
.tile.green .muted { color: var(--green2); }
.tile.red { background: var(--red-bg); color: var(--red); }
.tile.red .muted { color: var(--red); }
.card { border: 1px solid var(--line); border-radius: 20px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.card.soft { background: var(--tile); border: none; }
.card.dark { background: var(--btn); color: var(--btn-ink); border: none; }
.card.warn { background: var(--orange-tint); border-color: var(--orange-line); }
.note { background: var(--orange-bg); color: var(--orange); border-radius: 14px; padding: 10px 14px; font-size: 14px; font-weight: 600; }
.note.blue { background: var(--blue-bg); color: var(--blue); }

/* строки-ссылки */
.row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--tile); border-radius: 18px; text-decoration: none; border: none; width: 100%; text-align: left; }
.row .grow { flex-grow: 1; font-weight: 600; min-width: 0; }
.chev { width: 20px; height: 20px; stroke: var(--muted); stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* плашки */
.chip { display: inline-block; font-size: 13px; font-weight: 700; border-radius: 10px; padding: 5px 10px; white-space: nowrap; }
.chip.purple { background: var(--purple-bg); color: var(--purple); }
.chip.blue { background: var(--blue-bg); color: var(--blue); }
.chip.green { background: var(--green-bg); color: var(--green); }
.chip.orange { background: var(--orange-bg); color: var(--orange); }
.chip.red { background: var(--red-bg); color: var(--red); }
.chip.gray { background: var(--line); color: var(--muted2); }

/* фильтры и сегменты */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.fchip { height: 38px; padding: 0 14px; border-radius: 19px; border: none; background: var(--tile); font-size: 14px; font-weight: 600; white-space: nowrap; flex-shrink: 0; }
.fchip.on { background: var(--btn); color: var(--btn-ink); font-weight: 700; }
.seg { display: flex; gap: 4px; background: var(--tile); border-radius: 14px; padding: 4px; }
.seg button { flex: 1; height: 40px; border: none; border-radius: 11px; background: transparent; font-size: 14px; font-weight: 600; color: var(--muted2); }
.seg button.on { background: var(--bg); color: var(--ink); font-weight: 800; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.opts { display: flex; gap: 6px; }
.opts button { flex: 1; height: 42px; border: none; border-radius: 12px; background: var(--tile); font-size: 14px; font-weight: 600; }
.opts button.on { background: var(--btn); color: var(--btn-ink); font-weight: 700; }

/* товары */
.item { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 18px; text-decoration: none; }
.item.warn { border-color: var(--orange-line); background: var(--orange-tint); }
.thumb { width: 46px; height: 46px; border-radius: 12px; background: var(--tile); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.thumb svg { width: 22px; height: 22px; stroke: var(--muted); stroke-width: 1.8; fill: none; stroke-linejoin: round; }
.item .info { display: flex; flex-direction: column; gap: 3px; flex-grow: 1; min-width: 0; }
.item .name { font-size: 15px; font-weight: 700; }
.item .right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; }
.plus { font-size: 15px; font-weight: 800; color: var(--green); white-space: nowrap; }
.plus.low { color: var(--orange); }
.plus.neg { color: var(--red); }

/* поля */
.search { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 14px; background: var(--tile); border-radius: 16px; color: var(--muted); }
.search input { border: none; background: transparent; outline: none; flex-grow: 1; font-size: 16px; color: var(--ink); min-width: 0; }
.line { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 46px; }
.line .lbl { font-size: 15px; color: var(--muted2); }
.line .v { font-size: 15px; font-weight: 700; white-space: nowrap; }
.field { width: 130px; height: 44px; border: 1.5px solid var(--field); border-radius: 12px; background: var(--bg); font-size: 16px; font-weight: 700; text-align: right; padding: 0 12px; outline: none; }
.field:focus, .wide:focus { border-color: var(--ink); }
.wide { width: 100%; height: 52px; border: 1.5px solid var(--field); border-radius: 14px; background: var(--bg); font-size: 16px; padding: 0 14px; outline: none; }
.label { font-size: 14px; font-weight: 700; }
.sep { height: 1px; background: var(--line); }
.caps { font-size: 12px; font-weight: 700; color: var(--muted2); text-transform: uppercase; letter-spacing: 0.4px; padding-top: 6px; }

/* кнопки */
.pill { position: fixed; left: 16px; right: 16px; bottom: calc(100px + var(--safe)); height: 56px; border-radius: 28px; border: none; background: var(--btn); color: var(--btn-ink); font-size: 17px; font-weight: 700; max-width: 528px; margin: 0 auto; z-index: 5; }
body.no-tabs .pill { bottom: calc(20px + var(--safe)); }
.pill:disabled { opacity: 0.5; }
.btn { height: 48px; border-radius: 24px; border: none; background: var(--btn); color: var(--btn-ink); font-size: 16px; font-weight: 700; padding: 0 20px; }
.btn.light { background: var(--tile); color: var(--ink); }
.btn.full { width: 100%; }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: none; background: var(--tile); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.icon-btn svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.switch { width: 52px; height: 32px; border-radius: 16px; border: none; background: var(--field); position: relative; padding: 0; flex-shrink: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 13px; background: #FFFFFF; transition: left .15s; }
.switch[aria-checked="true"] { background: var(--btn); }
[data-theme="dark"] .switch[aria-checked="true"] { background: #7BC67E; }
.switch[aria-checked="true"]::after { left: 23px; }

/* график */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 150px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; min-width: 0; height: 100%; }
.bar i { display: block; width: 100%; background: var(--bar); border-radius: 8px; min-height: 4px; }
.bar.hi i { background: var(--bar-hi); }
.bar b { font-size: 12px; font-weight: 700; color: var(--muted2); white-space: nowrap; }
.bar span { font-size: 11px; color: var(--muted); text-align: center; line-height: 1.2; }

/* профиль */
.avatar { width: 88px; height: 88px; border-radius: 50%; text-decoration: none; overflow: hidden; flex-shrink: 0; background: var(--purple-bg); color: var(--purple); font-size: 36px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.set { display: flex; align-items: center; gap: 12px; min-height: 54px; border: none; border-bottom: 1px solid var(--line); background: none; width: 100%; text-align: left; padding: 0 2px; text-decoration: none; }
.set .grow { flex-grow: 1; font-size: 16px; font-weight: 600; }
.set .v { font-size: 14px; color: var(--muted2); }
.editor { display: flex; flex-direction: column; gap: 10px; padding: 12px 0 14px; border-bottom: 1px solid var(--line); }

/* меню снизу */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--bg); border-top: 1px solid var(--line); display: flex; justify-content: space-around; padding: 8px 4px calc(8px + var(--safe)); z-index: 6; }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 12px; color: var(--muted); text-decoration: none; width: 68px; padding: 2px 0; }
.tabbar a.on { color: var(--ink); font-weight: 700; }
.tabbar svg { width: 26px; height: 26px; stroke: currentColor; stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }
body.no-tabs .tabbar { display: none; }

/* выбор заказов и накладные */
.card.picked { border-color: var(--ink); }
.check { width: 36px; height: 36px; border-radius: 10px; border: 2px solid var(--field); background: var(--bg); display: flex; align-items: center; justify-content: center; flex-shrink: 0; padding: 0; }
.check svg { width: 22px; height: 22px; stroke: transparent; stroke-width: 2.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.check.on { background: var(--btn); border-color: var(--btn); }
.check.on svg { stroke: var(--btn-ink); }
.stepper { display: flex; align-items: center; gap: 4px; background: var(--tile); border-radius: 12px; padding: 3px; }
.stepper button { width: 36px; height: 36px; border: none; border-radius: 9px; background: var(--bg); font-size: 20px; font-weight: 700; }
.stepper b { min-width: 28px; text-align: center; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }

/* прочее */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(170px + var(--safe)); background: var(--btn); color: var(--btn-ink); padding: 12px 18px; border-radius: 14px; font-size: 15px; font-weight: 600; z-index: 10; max-width: calc(100% - 32px); text-align: center; }
.skeleton { height: 90px; border-radius: 20px; background: var(--tile); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.empty { text-align: center; padding: 28px 12px; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.step { display: flex; gap: 14px; align-items: flex-start; }
.num { width: 32px; height: 32px; border-radius: 16px; font-size: 15px; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.err { color: var(--red); font-size: 14px; font-weight: 600; }

/* остатки и свой срок */
.stepper input { width: 64px; height: 36px; border: none; background: transparent; font-size: 17px; font-weight: 800; text-align: center; color: var(--ink); outline: none; padding: 0; }
.stepper.big button { width: 44px; height: 44px; font-size: 22px; }
.more { display: flex; align-items: center; justify-content: space-between; padding-top: 8px; border-top: 1px solid var(--line); font-size: 15px; font-weight: 700; text-decoration: none; }

/* путь заказа */
.tl { display: flex; flex-direction: column; }
.tl .st { display: flex; gap: 12px; position: relative; padding-bottom: 16px; }
.tl .st:last-child { padding-bottom: 0; }
.tl .st::before { content: ""; position: absolute; left: 10px; top: 24px; bottom: 0; width: 2px; background: var(--line); }
.tl .st:last-child::before { display: none; }
.tl .st.done::before { background: var(--ink); }
.tl .dot { width: 22px; height: 22px; border-radius: 11px; border: 2px solid var(--field); background: var(--bg); flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.tl .done .dot { background: var(--ink); border-color: var(--ink); }
.tl .done .dot svg { width: 14px; height: 14px; stroke: var(--bg); stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.tl .now .dot { background: var(--blue-bg); border-color: var(--bar-hi); box-shadow: 0 0 0 4px var(--blue-bg); }
.tl .t { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tl .t b { font-size: 15px; }
.tl .st:not(.done):not(.now) .t b { color: var(--muted); font-weight: 600; }

.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* переключатель магазинов */
.store-btn { display: flex; align-items: center; gap: 4px; border: none; background: none; padding: 0; text-align: left; min-width: 0; }
.store-btn .h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.store-btn svg { width: 22px; height: 22px; stroke: var(--ink); stroke-width: 2.4; fill: none; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.sheet-back { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 20; display: flex; align-items: flex-end; }
.sheet { background: var(--bg); width: 100%; max-width: 560px; margin: 0 auto; border-radius: 24px 24px 0 0; padding: 20px 16px calc(24px + var(--safe)); display: flex; flex-direction: column; gap: 10px; max-height: 85vh; overflow-y: auto; }

/* списки как в Kaspi */
.row.big { padding: 18px 16px; }
.list-card { border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.lrow { display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 0 16px; text-decoration: none; border-bottom: 1px solid var(--line); font-size: 16px; }
.lrow:last-child { border-bottom: none; }
.lrow .grow { flex-grow: 1; font-weight: 600; }
.lrow b { font-size: 17px; }
.c-orange { color: #D9822B; } .c-red { color: #D64535; }

/* фильтры и массовые изменения */
.fpanel { display: flex; flex-direction: column; gap: 12px; }
.wrapchips { display: flex; flex-wrap: wrap; gap: 8px; }
.item .check { width: 30px; height: 30px; border-radius: 8px; }
.bulkbar { display: flex; gap: 8px; align-items: center; }
.fpanel .fchip, .fpanel .opts button, .fpanel .btn.light { background: var(--bg); }
.fpanel .fchip.on, .fpanel .opts button.on { background: var(--btn); color: var(--btn-ink); }

/* вопросы и ответы */
.faq { border-bottom: 1px solid var(--line); }
.faq:last-child { border-bottom: none; }
.faq summary { list-style: none; padding: 16px; font-size: 16px; font-weight: 700; cursor: pointer; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 22px; line-height: 1; color: var(--muted); }
.faq[open] summary::after { content: "−"; }
.faq p { margin: 0; padding: 0 16px 16px; font-size: 15px; line-height: 1.45; color: var(--muted2); }
