:root {
  --blue: #0B5CAD; --blue-d: #08407A; --blue-l: #E8F1FB; --ink: #14202E; --mut: #5B6776; --line: #DDE3EA;
  --bg: #F3F6F9; --card: #fff; --green: #1F9D55; --amber: #B36B00; --amber-bg: #FFF4DC; --red: #C8202F; --red-bg: #FDECEE;
  --r: 14px; --shadow: 0 1px 2px rgba(20,32,46,.06), 0 4px 14px rgba(20,32,46,.06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
.boot { padding: 80px 20px; text-align: center; color: var(--mut); }
[hidden] { display: none !important; }

/* кнопки */
.btn { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 14px; font-weight: 600; min-height: 42px; }
.btn:hover { border-color: #b9c4d0; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-d); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--blue); padding: 8px 10px; min-height: 36px; }
.btn.small { padding: 6px 10px; min-height: 34px; font-size: 14px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, .seg button:focus-visible, .tab:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(11,92,173,.35); outline-offset: 1px; }

/* вход */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login form { width: 100%; max-width: 380px; background: var(--card); border-radius: 18px; padding: 26px 22px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; }
.brand img { width: 34px; height: 34px; }
.brand small { display: block; font-weight: 500; font-size: 12px; color: var(--mut); }
label.f { display: grid; gap: 5px; font-size: 13px; color: var(--mut); font-weight: 600; }
label.f input, label.f select, label.f textarea, .search { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; font-size: 16px; color: var(--ink); font-weight: 400; min-height: 44px; }
label.f textarea { min-height: 70px; resize: vertical; }
.err { background: var(--red-bg); color: var(--red); border-radius: 10px; padding: 10px 12px; font-size: 14px; }

/* каркас */
.top { position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 1px solid var(--line); }
.top-row { display: flex; align-items: center; gap: 10px; padding: 8px 14px; max-width: 1400px; margin: 0 auto; }
.top-row .brand { font-size: 17px; margin-right: auto; }
.top-row .brand img { width: 28px; height: 28px; }
.who { font-size: 13px; color: var(--mut); max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs { display: flex; gap: 4px; padding: 0 10px; max-width: 1400px; margin: 0 auto; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: none; padding: 10px 12px; font-weight: 600; color: var(--mut); border-bottom: 3px solid transparent; white-space: nowrap; }
.tab.on { color: var(--blue); border-bottom-color: var(--blue); }
.layout { max-width: 1400px; margin: 0 auto; padding: 14px 12px 96px; display: grid; gap: 16px; }
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; }
.card h2 { font-size: 17px; margin-bottom: 12px; }
.stack { display: grid; gap: 14px; }
.muted { color: var(--mut); font-size: 13px; }

/* форма подбора */
.q { display: grid; gap: 7px; }
.q > span { font-size: 13px; font-weight: 700; color: var(--mut); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.seg button { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 6px; font-weight: 600; min-height: 44px; line-height: 1.2; }
.seg button small { display: block; font-weight: 500; font-size: 11.5px; color: var(--mut); }
.seg button.on { background: var(--blue-l); border-color: var(--blue); color: var(--blue-d); }
.seg button.on small { color: var(--blue-d); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.step { display: inline-grid; grid-template-columns: 40px minmax(44px, auto) 40px; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: #fff; overflow: hidden; }
.step button { border: 0; background: #F3F6F9; height: 40px; font-size: 20px; font-weight: 700; color: var(--blue-d); }
.step input { border: 0; width: 100%; min-width: 44px; text-align: center; font-weight: 700; font-size: 16px; padding: 0 2px; height: 40px; background: #fff; -moz-appearance: textfield; }
.step input::-webkit-outer-spin-button, .step input::-webkit-inner-spin-button { -webkit-appearance: none; }
.step.sm { grid-template-columns: 32px minmax(40px, auto) 32px; }
.step.sm button, .step.sm input { height: 34px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.check input { width: 20px; height: 20px; accent-color: var(--blue); }

.scen { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.scen-item { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; background: #fff; }
.scen-item.on { border-color: var(--blue); background: var(--blue-l); }
.scen-item b { font-size: 14.5px; }
.scen-item small { grid-column: 1; color: var(--mut); font-size: 12.5px; }
.scen-item .ctl { grid-row: 1 / span 2; grid-column: 2; }
.scen-item.none { opacity: .55; }

/* строки комплекта и товаров */
.row { display: grid; grid-template-columns: 56px 1fr; gap: 10px 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.row:first-of-type { border-top: 0; }
.thumb { width: 56px; height: 56px; border-radius: 10px; background: #EEF2F6; display: grid; place-items: center; overflow: hidden; color: #9AA6B2; font-weight: 800; font-size: 13px; border: 0; padding: 0; }
.thumb img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.row .slot { font-size: 12px; font-weight: 800; color: var(--blue-d); text-transform: uppercase; letter-spacing: .03em; }
.row .name { border: 0; background: none; padding: 0; text-align: left; font-weight: 600; display: block; overflow-wrap: anywhere; }
.row .name:hover { color: var(--blue); }
.row .note { font-size: 13px; color: var(--mut); }
.warn { font-size: 13px; color: var(--amber); background: var(--amber-bg); border-radius: 8px; padding: 5px 8px; margin-top: 4px; display: inline-block; }
.row .foot { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row .foot .sum { margin-left: auto; font-weight: 800; white-space: nowrap; }
.row .foot .unit { font-size: 13px; color: var(--mut); white-space: nowrap; }
.row.off { opacity: .6; }
.stock { font-size: 12.5px; color: var(--green); font-weight: 600; }
.stock.low { color: var(--amber); }
.total { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 12px; border-top: 2px solid var(--ink); margin-top: 4px; font-weight: 800; font-size: 18px; }
.notes { font-size: 13px; color: var(--mut); padding-left: 18px; margin: 10px 0 0; display: grid; gap: 4px; }
.kit-actions { display: grid; gap: 8px; margin-top: 12px; }

/* каталог */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; white-space: nowrap; font-size: 13.5px; font-weight: 600; }
.chip.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.price { font-weight: 800; white-space: nowrap; }

/* заказ */
.cart-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--blue); color: #fff; border: 0; width: 100%; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); display: flex; justify-content: space-between; font-weight: 700; font-size: 16px; box-shadow: 0 -4px 16px rgba(20,32,46,.18); }
.cart { display: none; }
.cart.open { display: block; position: fixed; inset: 0; z-index: 40; background: var(--bg); overflow-y: auto; padding: 12px 12px 30px; }
.cart-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cart-head h2 { margin: 0; }
.cart .close { display: inline-flex; }
.line { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.line:first-of-type { border-top: 0; }
.line .name { border: 0; background: none; padding: 0; text-align: left; font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.line .x { border: 0; background: none; color: var(--mut); font-size: 20px; line-height: 1; padding: 2px 6px; }
.line .ctl { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; }
.line .ctl .sum { margin-left: auto; font-weight: 800; white-space: nowrap; }
.empty { text-align: center; color: var(--mut); padding: 26px 10px; }
.status { font-size: 12.5px; font-weight: 700; border-radius: 999px; padding: 3px 10px; background: var(--blue-l); color: var(--blue-d); white-space: nowrap; }
.order { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.order:first-of-type { border-top: 0; }
.order .c { grid-column: 1 / -1; font-size: 13px; color: var(--mut); overflow-wrap: anywhere; }

/* окна */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(20,32,46,.5); display: grid; align-items: end; }
.sheet { background: #fff; border-radius: 18px 18px 0 0; max-height: 92dvh; display: grid; grid-template-rows: auto 1fr auto; width: 100%; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.sheet-head h3 { font-size: 16px; margin-right: auto; }
.sheet-body { overflow-y: auto; padding: 12px 16px; overscroll-behavior: contain; }
.sheet-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.big-img { width: 100%; max-height: 300px; object-fit: contain; background: #fff; border-radius: 12px; border: 1px solid var(--line); margin-bottom: 12px; }
.desc { white-space: pre-line; font-size: 14px; color: #33414F; margin-top: 10px; }
.pick { display: grid; grid-template-columns: 48px 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; }
.pick:first-of-type { border-top: 0; }
.pick .thumb { width: 48px; height: 48px; }
.pick.cur { background: var(--blue-l); border-radius: 10px; padding: 10px 8px; }
.pick b { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; display: block; }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 80; max-width: 92vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%); }

/* компьютер: заказ всегда справа */
@media (min-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1fr) 400px; align-items: start; padding-bottom: 30px; }
  .layout.wide { grid-template-columns: minmax(0, 1fr) 400px; }
  .main-cols { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 16px; align-items: start; }
  .cart, .cart.open { display: block; position: sticky; top: 104px; inset: auto; z-index: 1; background: none; padding: 0; max-height: calc(100dvh - 120px); overflow-y: auto; }
  .cart .close, .cart-bar { display: none; }
  .modal { align-items: center; justify-items: center; padding: 20px; }
  .sheet { max-width: 640px; border-radius: 18px; max-height: 86dvh; }
  .toast { bottom: 30px; }
  .row { grid-template-columns: 64px 1fr auto; }
  .row .thumb { width: 64px; height: 64px; }
  .row .foot { grid-column: 3; flex-direction: column; align-items: flex-end; justify-content: center; }
  .row .foot .sum { margin-left: 0; }
  .row .foot .btns { display: flex; gap: 4px; }
  .tabs { padding: 0 14px; }
}
@media (min-width: 1000px) and (max-width: 1250px) { .main-cols { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* страницы заказа */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: var(--bg); border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.steps button { border: 0; background: none; border-radius: 9px; padding: 8px 4px; font-weight: 600; font-size: 13px; color: var(--mut); display: grid; justify-items: center; gap: 2px; min-height: 44px; }
.steps button i { font-style: normal; width: 22px; height: 22px; border-radius: 50%; background: #AEB9C5; color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 800; }
.steps button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.steps button.on i { background: var(--blue); }
.cost-head, .cost-row { display: grid; grid-template-columns: 1fr 62px 62px 62px; gap: 6px; font-size: 12.5px; padding: 7px 0; border-top: 1px solid var(--line); }
.cost-head { border-top: 0; font-weight: 700; color: var(--mut); }
.cost-head span:not(:first-child), .cost-row span:not(:first-child) { text-align: right; white-space: nowrap; }
.cost-row span:first-child { overflow-wrap: anywhere; }
.sums { display: grid; gap: 6px; background: var(--bg); border-radius: 12px; padding: 12px; }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.kv.big { font-size: 17px; padding: 6px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.kv.pos b { color: var(--green); }
.kv.neg b { color: var(--red); }

/* печать */
#print { display: none; }
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; }
  body > *:not(#print) { display: none !important; }
  #print { display: block; color: #000; font-size: 11pt; }
  .doc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; border-bottom: 2px solid #0B5CAD; padding-bottom: 10px; margin-bottom: 14px; font-size: 10pt; }
  .doc-logo { font-size: 22pt; font-weight: 800; color: #0B5CAD; line-height: 1; margin-bottom: 4px; }
  .doc-title { font-size: 15pt; font-weight: 700; text-align: right; }
  .doc-info { margin-bottom: 14px; border-collapse: collapse; }
  .doc-info th { text-align: left; font-weight: 600; color: #444; padding: 2px 14px 2px 0; vertical-align: top; white-space: nowrap; }
  .doc-info td { padding: 2px 0; }
  .doc-items { width: 100%; border-collapse: collapse; }
  .doc-items th, .doc-items td { border: 1px solid #999; padding: 5px 7px; vertical-align: top; }
  .doc-items th { background: #EEF2F6; font-size: 10pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .doc-items .r { text-align: right; white-space: nowrap; }
  .doc-items tr { break-inside: avoid; }
  .doc-total td { font-weight: 800; font-size: 12pt; }
  .doc-sign { display: flex; justify-content: space-between; margin-top: 40px; }
  .doc-note { margin-top: 14px; font-size: 10pt; color: #444; }
}

/* главный экран */
.home { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; }
.home-btn { display: grid; grid-template-columns: 56px 1fr; gap: 14px; align-items: center; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 16px; padding: 18px 16px; min-height: 96px; }
.home-btn:hover { border-color: var(--blue); box-shadow: var(--shadow); }
.home-btn:focus-visible { outline: 3px solid rgba(11,92,173,.35); outline-offset: 1px; }
.home-btn i { font-style: normal; width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 24px; background: var(--blue); }
.home-btn i.m-smart { background: #1F9D55; }
.home-btn i.m-pc { background: #6B4BC4; }
.home-btn i.m-pos { background: #C2570C; }
.home-btn b { display: block; font-size: 17px; }
.home-btn small { color: var(--mut); font-size: 13.5px; }
.crumb { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.crumb h1 { font-size: 20px; }

/* каталог плиткой, шаблоны, WhatsApp */
.view-seg { grid-auto-columns: auto; }
.view-seg button { min-height: 36px; padding: 6px 12px; font-size: 13.5px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: grid; gap: 6px; align-content: start; background: #fff; grid-template-rows: auto 1fr auto auto; }
.tile .thumb { width: 100%; height: 120px; }
.tile .name { border: 0; background: none; padding: 0; text-align: left; font-weight: 600; font-size: 13.5px; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.tile-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; flex-wrap: wrap; }
.more { margin-top: 12px; }
.btn.wa { background: #1DAA61; border-color: #1DAA61; color: #fff; }
.btn.wa:hover { background: #17894E; }
.tpl-actions { display: flex; gap: 6px; }
.home-btn i.m-manual { background: #14202E; }
