:root {
  --bg: #efe7d8;
  --bg-2: #e7dcc8;
  --ink: #1f1a14;
  --ink-soft: #6b5e4e;
  --line: #d3c4aa;
  --card: #fbf7ef;
  --card-2: #fffdf8;
  --accent: #b4451a;
  --accent-2: #8d3413;
  --good: #2f6a48;
  --warn: #a15c12;
  --bad: #9b2c2c;
  --chip: #efe2cc;
  --shadow: 0 10px 30px rgba(50, 32, 12, 0.08);
  --radius: 18px;
  --sans: "IBM Plex Sans", "Noto Sans", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 17px;
  background:
    radial-gradient(900px 400px at 0% 0%, #f4e4c8 0%, transparent 50%),
    var(--bg);
  color: var(--ink);
  letter-spacing: -0.01em;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
}
.menu-btn { min-width: 48px; min-height: 48px; font-size: 22px; }
.menu-bg {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(31,26,20,.4);
}
.menu-sheet {
  position: fixed; left: 0; top: 0; bottom: 0; width: min(300px, 86vw);
  z-index: 41; height: 100vh;
}
.tapnum {
  text-align: right;
  font-family: var(--mono);
  min-height: 48px;
  font-size: 20px;
}
.pad-modal { max-width: 360px; }
.pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.padk { min-height: 56px; font-size: 22px; }
.pad-val {
  font-family: var(--mono);
  font-size: 36px;
  text-align: right;
  padding: 8px 4px 16px;
}
.btn { min-height: 44px; }

.side {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  background: #f6edd9;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  padding: 4px 8px 10px;
}
.brand small {
  display: block;
  color: var(--ink-soft);
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.brand strong {
  display: block;
  font-size: 22px;
  line-height: 1.15;
  margin-top: 4px;
}

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav button {
  text-align: left;
  border: 0;
  background: transparent;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--ink-soft);
}
.nav button.active, .nav button:hover {
  background: #fff8ec;
  color: var(--ink);
}
.nav button.active { box-shadow: inset 3px 0 0 var(--accent); }

.side-foot {
  margin-top: auto;
  padding: 12px;
  border-radius: 14px;
  background: #efe0c4;
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.45;
}

.main { padding: 10px 16px 16px; min-width: 0; width: 100%; flex: 1; overflow: auto; }

.kassa-wrap {
  display: flex;
  align-items: stretch;
  gap: 0;
  overflow: hidden;
  height: 100%;
  min-height: 0;
}
.kassa-pane {
  min-width: 180px;
  flex: 0 0 auto;
  box-sizing: border-box;
  overflow: auto;
  max-height: calc(100vh - 118px);
}
.kassa-pane > b { display: block; margin-bottom: 10px; }
.kassa-pay {
  flex: 1 1 auto;
  width: auto !important;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  overflow: auto;
  gap: 4px;
}
.kassa-pay > b { margin-bottom: 4px; }
.kassa-pay .field { margin: 0 0 6px; }
.kassa-pay-foot { margin-top: auto; padding-top: 4px; }
.pay-go { width: 100%; margin: 0; min-height: 40px; font-size: 15px; }
.pay-go-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; margin-top: 8px; }
.kassa-split {
  flex: 0 0 10px;
  cursor: col-resize;
  background: linear-gradient(#d3c4aa, #d3c4aa) center / 2px 46% no-repeat;
  touch-action: none;
}
.kassa-split:hover { background-color: #ead9b8; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 0;
  flex-shrink: 0;
}
.top h1 { margin: 0; font-size: 20px; font-weight: 600; white-space: nowrap; }
.top p { margin: 2px 0 0; color: var(--ink-soft); font-size: 14px; }
.top-actions {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  flex: 1;
  justify-content: flex-end;
  overflow-x: auto;
}
.top-actions .btn { white-space: nowrap; flex-shrink: 0; padding: 8px 10px; }

.btn {
  border: 1px solid var(--line);
  background: var(--card);
  padding: 9px 13px;
  border-radius: 14px;
}
.btn:hover { filter: brightness(1.05); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: var(--accent-2); }
.btn.good { background: var(--good); border-color: var(--good); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { background: #f3d4d0; border-color: #e3b4ae; color: var(--bad); }

.top-actions .btn:nth-child(6n+1) { background: #f4d7b8; border-color: #e4c19a; }
.top-actions .btn:nth-child(6n+2) { background: #d7ead8; border-color: #b7d4ba; }
.top-actions .btn:nth-child(6n+3) { background: #d7e3f4; border-color: #b7c8e4; }
.top-actions .btn:nth-child(6n+4) { background: #ead7f0; border-color: #d4b8de; }
.top-actions .btn:nth-child(6n+5) { background: #f4e2b8; border-color: #e4ce96; }
.top-actions .btn:nth-child(6n+6) { background: #f3d4d0; border-color: #e3b4ae; }
.top-actions .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.top-actions .btn.good { background: var(--good); border-color: var(--good); color: #fff; }
.top-actions .btn.danger { background: #c45b4a; border-color: #c45b4a; color: #fff; }

.pay-methods .btn:nth-child(1) { background: #ffe08a; border-color: #e0c05a; }
.pay-methods .btn:nth-child(2) { background: #b8e0c8; border-color: #8fc8a6; }
.pay-methods .btn:nth-child(3) { background: #c5d4f4; border-color: #9db0e0; }
.pay-methods .btn.primary { color: #1f1a14; }

.period-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  padding: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.period-btn { border-radius: 14px; background: #efe2cc; }
.period-btn:nth-child(1) { background: #f4d7b8; border-color: #e4c19a; }
.period-btn:nth-child(2) { background: #d7ead8; border-color: #b7d4ba; }
.period-btn:nth-child(3) { background: #d7e3f4; border-color: #b7c8e4; }
.period-btn:nth-child(4) { background: #ead7f0; border-color: #d4b8de; }
.period-btn.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.period-date {
  border-radius: 14px !important;
  background: #fffdf8 !important;
  border: 1px solid var(--line) !important;
  min-height: 44px;
  padding: 8px 12px;
}

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: 1.4fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.stat .label { color: var(--ink-soft); font-size: 14px; }
.stat .value {
  font-family: var(--mono);
  font-size: 24px;
  margin-top: 6px;
}
.stat .sub { color: var(--ink-soft); font-size: 14px; margin-top: 4px; }
.stat.good .value { color: var(--good); }
.stat.warn .value { color: var(--warn); }
.stat.bad .value { color: var(--bad); }

.search-2 { display: grid; grid-template-columns: 1.4fr 0.8fr; gap: 8px; margin-bottom: 4px; }
.metrics-box { max-width: 480px; }
.search {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--card-2);
}

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line);
  background: var(--chip);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 15px;
}
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip-c0 { background: #f4d7b8; border-color: #e4c19a; }
.chip-c1 { background: #d7ead8; border-color: #b7d4ba; }
.chip-c2 { background: #d7e3f4; border-color: #b7c8e4; }
.chip-c3 { background: #ead7f0; border-color: #d4b8de; }
.chip-c4 { background: #f4e2b8; border-color: #e4ce96; }
.chip-c5 { background: #f3d4d0; border-color: #e3b4ae; }
.chip-c6 { background: #cfe8e2; border-color: #a9d0c6; }
.chip-c7 { background: #e4dcc8; border-color: #cfc3a6; }
.chip-c8 { background: #dde8c8; border-color: #c0d09a; }
.chip-c9 { background: #f0d5e4; border-color: #dcb0c8; }
.pie-wrap { display: flex; gap: 14px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.pie { width: 140px; height: 140px; flex: 0 0 140px; }
.pie-leg { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.leg { display: flex; align-items: center; gap: 8px; }
.leg i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.bar i.b0 { background: #b4451a; }
.bar i.b1 { background: #2f6a48; }
.bar i.b2 { background: #3d6ea8; }
.bar i.b3 { background: #a15c12; }
.bar i.b4 { background: #7a4ea3; }
.bar i.b5 { background: #c45b4a; }
.bar i.b6 { background: #2a9d8f; }
.bar i.b7 { background: #c9a227; }
.bar-lab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.list { display: flex; flex-direction: column; gap: 8px; max-height: 62vh; overflow: auto; }
.row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--card-2);
  border: 1px solid transparent;
}
.row:hover { border-color: var(--line); }
.row .meta { color: var(--ink-soft); font-size: 15px; }
.row .money { font-family: var(--mono); }
.tag {
  display: inline-block;
  font-size: 13px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #ead9b8;
}
.tag.low { background: #f3d7a4; }
.tag.zero { background: #f0c7c7; }

table { width: 100%; border-collapse: collapse; font-size: 17px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--ink-soft); font-weight: 500; font-size: 14px; }
td.num, th.num { text-align: right; font-family: var(--mono); }
td.bad { color: var(--bad); font-weight: 600; }
td.warn { color: var(--warn); }
.in-table select, .numin {
  width: 88px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}
.in-table select { width: 78px; }
tr.onrow td { background: #f3e2c4; }
.row.onrow { background: #fff3e4; outline: 2px solid var(--accent); }
.doc-list { max-height: 48vh; gap: 10px; }
.doc-card {
  grid-template-columns: minmax(0, 1.4fr) minmax(140px, 0.8fr) auto;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(0,0,0,.04);
}
.doc-card .money { text-align: right; font-size: 18px; font-weight: 700; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.field span { font-size: 15px; color: var(--ink-soft); }
.field input, .field select, .field textarea {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
}

.cart-lines { display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
.cart-line {
  display: grid;
  grid-template-columns: 1fr 90px 90px 28px;
  gap: 8px;
  align-items: center;
}
.cart-line input { width: 100%; padding: 8px; border-radius: 10px; border: 1px solid var(--line); }
.cart-head { margin: 8px 0 0; font-size: 14px; }
.cart-head > div:nth-child(2), .cart-head > div:nth-child(3) { text-align: center; }
.pay-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pay-methods {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin: 6px 0 8px;
}
.pay-methods .btn { width: 100%; min-width: 0; padding: 8px 6px; font-size: 14px; }
#cust { min-width: 0; width: 100%; }
.total-box {
  background: #1f1a14;
  color: #f6edd9;
  border-radius: 12px;
  padding: 10px 12px;
}
.total-box .big { font-family: var(--mono); font-size: 20px; }
.tapcard { cursor: pointer; }
.tapcard:hover { outline: 2px solid var(--accent); }
.kpi-line { font-size: 15px; margin-top: 6px; color: var(--ink-soft); overflow: hidden; }
.kpi-line b { color: var(--ink); float: right; font-family: var(--mono); }

.modal-bg {
  position: fixed; inset: 0;
  background: rgba(31, 26, 20, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 20;
}
.modal {
  width: min(720px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--card);
  border-radius: 20px;
  padding: 18px;
}

.receipt {
  width: 280px;
  margin: 0 auto;
  background: #fff;
  color: #111;
  padding: 16px;
  font-family: var(--mono);
  font-size: 12px;
}
.receipt h3 { text-align: center; margin: 0 0 8px; font-family: var(--sans); }
.muted { color: var(--ink-soft); }
.right { text-align: right; }
.flex { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; }
.hide { display: none !important; }

.formula {
  font-size: 15px;
  color: var(--ink-soft);
  padding: 10px 12px;
  background: #efe0c4;
  border-radius: 12px;
}

.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 140px 1fr 80px; gap: 8px; align-items: center; font-size: 15px; }
.bar {
  height: 10px;
  background: #eadcc3;
  border-radius: 99px;
  overflow: hidden;
}
.bar > i { display: block; height: 100%; background: var(--accent); }

.toast {
  position: fixed; left: 50%; top: 14px; transform: translateX(-50%);
  background: #1f1a14; color: #fff; padding: 10px 18px; border-radius: 12px;
  z-index: 200; font-size: 15px; max-width: min(720px, 90vw);
  line-height: 1.35; text-align: center; pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.toast.hide { display: none; }

.modal-cats {
  max-width: 720px;
  width: min(720px, 96vw);
  max-height: none;
  overflow: visible;
}
.cat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}
.cat-grid .btn { min-height: 40px; padding: 6px 8px; text-align: center; font-size: 15px; }

@media (max-width: 980px) {
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
  .main { padding: 12px; }
  .top { flex-direction: column; align-items: stretch; }
}

/* --- версия 2: индикатор связи с сервером --- */
.sync-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; padding: 2px 8px; border-radius: 999px; margin-left: 8px; white-space: nowrap; }
.sync-badge.ok { color: #1d6b34; }
.sync-badge.busy { color: #8a6a00; }
.sync-badge.off { color: #fff; background: #b3261e; font-weight: 600; }

/* --- Приход: аккуратная раскладка --- */
.btn.sm { padding: 6px 10px; font-size: 14px; min-height: 0; border-radius: 10px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--card-2); border-color: var(--line); }
.danger-txt { color: var(--bad); }
.linkbtn { border: 0; background: none; padding: 0 0 0 6px; color: var(--accent); cursor: pointer; font: inherit; font-size: 13px; text-decoration: underline; }
.warn { color: var(--warn); }
.good { color: var(--good); }

.inc-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.inc-tabs { display: inline-flex; background: var(--bg-2); border-radius: 12px; padding: 3px; gap: 2px; }
.inc-tab { border: 0; background: transparent; padding: 8px 16px; border-radius: 10px; font: inherit; font-size: 15px; color: var(--ink-soft); cursor: pointer; }
.inc-tab.on { background: var(--card-2); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(50,32,12,.12); }
.inc-count { display: inline-block; min-width: 22px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--chip); font-size: 13px; font-weight: 500; text-align: center; }
.inc-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.inc-tools .btn { background: var(--card); }

.inc-head { padding: 12px 14px 8px; margin-bottom: 10px; }
.inc-head.editing { outline: 2px solid var(--warn); }
.inc-head-grid { display: grid; grid-template-columns: 1.3fr 1.3fr 1fr; gap: 12px; }
.inc-head .field { margin-bottom: 6px; }
.inc-head .field span { font-size: 13px; }
.inc-head .field input { padding: 8px 10px; }
.inc-head .field input:disabled { background: var(--bg-2); color: var(--ink-soft); }
.inc-check { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; color: var(--ink-soft); cursor: pointer; }

.inc-work { height: calc(100vh - 290px); min-height: 360px; }
.inc-work .kassa-pane { max-height: none; height: 100%; display: flex; flex-direction: column; padding: 12px; }
.inc-hint { font-size: 13px; margin: 8px 0 6px; }
.inc-picklist { max-height: none; flex: 1; gap: 4px; }
.inc-picklist .row { padding: 7px 10px; border-radius: 10px; }
.inc-picklist .row b { font-weight: 500; font-size: 15px; }
.inc-picklist .row .meta { font-size: 12px; }
.inc-picklist .row .btn { padding: 4px 10px; min-height: 0; }
.inc-lines-scroll { flex: 1; overflow: auto; min-height: 0; }
.inc-lines .in-table { font-size: 15px; }
.inc-lines .in-table th { position: sticky; top: 0; background: var(--card); z-index: 1; font-size: 13px; }
.inc-lines .in-table td { padding: 6px 6px; }
.inc-lines .in-table td .meta { font-size: 12px; color: var(--ink-soft); }
.inc-lines .numin { width: 76px; padding: 5px 7px; text-align: right; font-family: var(--mono); }
.inc-lines .in-table select { width: 70px; padding: 5px 4px; }
.inc-empty { padding: 28px 10px !important; text-align: center; }
.inc-sum { display: grid; grid-template-columns: 1.4fr repeat(5, 1fr); gap: 1px; margin-top: 10px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.inc-sum > div { background: var(--card-2); padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.inc-sum span { font-size: 12px; line-height: 1.2; color: var(--ink-soft); }
.inc-sum > div { justify-content: space-between; }
.inc-pick .search { min-width: 0; }
.inc-sum b { font-family: var(--mono); font-size: 15px; white-space: nowrap; }
.inc-sum .inc-sum-main { background: #1f1a14; }
.inc-sum .inc-sum-main span { color: #cfc2aa; }
.inc-sum .inc-sum-main b { color: #f6edd9; font-size: 19px; }
.inc-sum .warn b { color: var(--warn); }
.inc-sum .good b { color: var(--good); }
.inc-sum .bad b { color: var(--bad); }

.inc-docs { padding: 12px 14px; }
.inc-filter { display: flex; gap: 8px; margin-bottom: 8px; }
.inc-select { min-width: 220px; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font: inherit; }
.inc-supinfo { font-size: 14px; color: var(--ink-soft); margin: 4px 2px 8px; }
.inc-doclist { max-height: calc(100vh - 250px); overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.inc-docrow { display: grid; grid-template-columns: 100px minmax(0, 1fr) 140px 150px 290px; gap: 12px; align-items: center; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--card-2); cursor: pointer; }
.inc-docrow:last-child { border-bottom: 0; }
.inc-docrow:hover { background: #fff; }
.inc-docrow.onrow { background: #fff3e4; outline: none; box-shadow: inset 3px 0 0 var(--accent); }
.inc-docrow .num { text-align: right; font-family: var(--mono); font-size: 15px; }
.inc-docrow .meta { font-size: 12px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inc-docrow .num .meta { font-family: var(--sans); }
.inc-dochead .num { font-family: var(--sans); font-size: 13px; }
.inc-dochead { position: sticky; top: 0; z-index: 1; background: var(--card); cursor: default; font-size: 13px; color: var(--ink-soft); padding-top: 7px; padding-bottom: 7px; }
.inc-dochead:hover { background: var(--card); }
.inc-date { display: flex; flex-direction: column; font-size: 14px; }
.inc-date span { font-size: 12px; color: var(--ink-soft); }
.inc-who b { font-weight: 600; }
.inc-acts { display: flex; gap: 2px; justify-content: flex-end; }

.sup-modal { width: min(620px, 100%); }
.sup-add { display: flex; gap: 8px; margin-bottom: 10px; }
.sup-list { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.sup-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 8px; align-items: center; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--card-2); }
.sup-row:last-child { border-bottom: 0; }
.sup-row input { border: 1px solid transparent; background: transparent; padding: 6px 8px; border-radius: 8px; font: inherit; min-width: 0; }
.sup-row input:hover, .sup-row input:focus { border-color: var(--line); background: #fff; }
.sup-row .muted { font-size: 13px; white-space: nowrap; }

@media (max-width: 980px) {
  .inc-head-grid { grid-template-columns: 1fr; }
  .inc-work { height: auto; flex-direction: column; overflow: visible; }
  .inc-work .kassa-pane { width: 100% !important; height: auto; }
  .inc-work .kassa-split { display: none; }
  .inc-picklist { max-height: 40vh; }
  .inc-lines-scroll { overflow-x: auto; }
  .inc-filter { flex-wrap: wrap; }
  .inc-filter .search, .inc-select { width: 100%; min-width: 0; }
  .inc-docrow > div:nth-child(4) { grid-column: 1 / -1; text-align: left; }
  .inc-sum { grid-template-columns: 1fr 1fr; }
  .inc-docrow { grid-template-columns: 1fr auto; }
  .inc-docrow .inc-date, .inc-dochead { display: none; }
  .inc-acts { grid-column: 1 / -1; justify-content: flex-start; }
}

/* ===== Мобильная версия ===== */
/* Кнопки в шапке: прокрутка начинается слева (раньше первые кнопки обрезались). */
.top-actions > :first-child { margin-left: auto; }
.top-actions { justify-content: flex-start; scrollbar-width: none; }
.top-actions::-webkit-scrollbar { display: none; }
/* Строки списков: все кнопки в одну строку, сколько бы их ни было */
.row { grid-template-columns: minmax(0, 1fr); grid-auto-flow: column; grid-auto-columns: auto; }
.m-tabs { display: none; }

@media (max-width: 900px) {
  /* Касса на телефоне: вкладки Поиск / Чек / Оплата вместо трёх колонок */
  .m-tabs { display: flex; gap: 4px; background: var(--bg-2); border-radius: 12px; padding: 3px; margin-bottom: 8px; position: sticky; top: 0; z-index: 5; }
  .m-tab { flex: 1; border: 0; background: transparent; padding: 10px 6px; border-radius: 10px; font: inherit; font-size: 15px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .m-tab.on { background: var(--card-2); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(50,32,12,.12); }
  .m-badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 13px; }
  .kassa-main { height: auto; overflow: visible; }
  .kassa-main .kassa-split { display: none; }
  .kassa-main .kassa-pane { display: none; width: 100% !important; max-height: none; min-width: 0; }
  .kassa-main.m-find .kp-find, .kassa-main.m-cart .kp-cart, .kassa-main.m-pay .kp-pay { display: flex; flex-direction: column; }
  .kassa-main .kp-find .list { max-height: none; }
  .kassa-main .cart-line { grid-template-columns: minmax(0, 1fr) 70px 80px 32px; }
}

@media (max-width: 760px) {
  body { font-size: 16px; }
  .main { padding: 8px 10px 16px; }
  .top { padding: 6px 10px 0; gap: 6px; }
  .top > .flex { width: 100%; }
  .top h1 { font-size: 18px; }
  .top p { font-size: 13px; }
  .top-actions { flex: 0 0 auto; width: 100%; padding-bottom: 2px; }
  .top-actions .btn { padding: 7px 10px; font-size: 14px; min-height: 38px; }
  .menu-btn { min-width: 44px; min-height: 44px; }
  .card { padding: 12px; border-radius: 14px; }
  /* Таблицы: листаются вбок внутри карточки, а не обрезаются */
  .main .card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { font-size: 15px; }
  th, td { padding: 7px 6px; }
  .stat .value { font-size: 22px; }
  .chip, .period-btn { font-size: 14px; }
  .modal-bg { padding: 8px; align-items: flex-end; }
  .modal { width: 100%; max-height: 92vh; border-radius: 18px 18px 12px 12px; padding: 14px; }
  .row { padding: 9px 10px; gap: 8px; }
  .row .meta { font-size: 13px; }
  /* iPhone не увеличивает страницу при вводе, если шрифт поля не меньше 16px */
  input, select, textarea { font-size: 16px; }
  .search-2 { grid-template-columns: 1fr 90px; }
  .pay-methods .btn { font-size: 13px; }
  .inc-tools .btn { font-size: 13px; }
}

@media (max-width: 980px) {
  .grid-4, .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 360px) {
  .grid-4, .grid-5 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .grid-4 .stat .value, .grid-5 .stat .value { font-size: 18px; letter-spacing: -0.5px; overflow-wrap: anywhere; }
  .stat { padding: 10px 12px; }
}

/* ---------- Сканер штрихкодов камерой ---------- */
.cam-wrap { position: relative; display: block; min-width: 0; }
.cam-wrap.grow { flex: 1 1 auto; }
.cam-wrap > input { width: 100%; padding-right: 50px; }
.cam-btn {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 36px; border: 0; border-radius: 9px;
  background: var(--accent); color: #fff; display: grid; place-items: center; cursor: pointer;
}
.cam-btn:active { transform: translateY(-50%) scale(.94); }
html.cam-open, html.cam-open body { overflow: hidden; }
.cam-bg {
  position: fixed; inset: 0; z-index: 10000; background: #000; color: #fff;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.cam-top { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; }
.cam-title { font-weight: 600; font-size: 17px; }
.cam-x { background: rgba(255,255,255,.14); color: #fff; border: 0; border-radius: 50%; width: 40px; height: 40px; font-size: 18px; }
.cam-view { position: relative; flex: 1 1 auto; overflow: hidden; }
.cam-view video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam-frame {
  position: absolute; left: 7%; right: 7%; top: 50%; height: 36%; transform: translateY(-50%);
  border: 3px solid rgba(255,255,255,.9); border-radius: 16px;
  box-shadow: 0 0 0 100vmax rgba(0,0,0,.38);
}
.cam-frame i { position: absolute; left: 6%; right: 6%; top: 50%; height: 2px; background: #ff4d3d; box-shadow: 0 0 8px #ff4d3d; }
.cam-frame.hit { animation: camHit .45s; }
.cam-frame.miss { animation: camMiss .6s; }
@keyframes camHit { 0% { border-color: #3ddc84; box-shadow: 0 0 0 100vmax rgba(0,80,30,.45); } 100% { } }
@keyframes camMiss { 0% { border-color: #ff4d3d; box-shadow: 0 0 0 100vmax rgba(90,0,0,.45); } 100% { } }
.cam-msg {
  position: absolute; left: 16px; right: 16px; bottom: 16px; text-align: center;
  background: rgba(0,0,0,.6); padding: 10px 12px; border-radius: 12px; font-size: 15px;
}
.cam-msg[hidden], .cam-last[hidden], .cam-tool[hidden] { display: none; }
.cam-last { margin: 8px 14px 0; padding: 10px 12px; border-radius: 12px; font-size: 16px; font-weight: 600; text-align: center; overflow-wrap: anywhere; }
.cam-last.ok { background: #1f6f43; }
.cam-last.bad { background: #8e2b22; }
.cam-bottom { display: flex; gap: 10px; align-items: center; padding: 12px 14px 16px; }
.cam-tool { width: 52px; height: 52px; border-radius: 50%; border: 0; background: rgba(255,255,255,.16); color: #fff; font-size: 22px; display: grid; place-items: center; flex: 0 0 auto; }
.cam-tool.on { background: #ffd54a; color: #222; }
.cam-done { flex: 1 1 auto; min-height: 52px; font-size: 17px; }

/* Окно продаж на компьютере: колонки тянутся до низа экрана, без пустой полосы снизу */
@media (min-width: 901px) {
  .main:has(> .kassa-main) { display: flex; flex-direction: column; overflow: hidden; padding-bottom: 10px; }
  .main > .kassa-main { flex: 1 1 auto; height: auto; min-height: 0; }
  .kassa-main .kassa-pane { max-height: none; }
}
@media (min-width: 901px) {
  .pay-go-2 { grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); }
  .pay-go { padding-left: 6px; padding-right: 6px; }
}
/* невысокий экран ноутбука: окно продаж компактнее, чтобы всё влезало без прокрутки */
@media (min-width: 901px) and (max-height: 820px) {
  .kassa-main .kassa-pane { padding: 10px 12px; }
  .kassa-main .kassa-pane > b { margin-bottom: 6px; }
  .kp-pay .field { margin-bottom: 6px; gap: 3px; }
  .kp-pay .field span { font-size: 13px; }
  .kp-pay .field input, .kp-pay .field select { padding-top: 6px; padding-bottom: 6px; }
  .kp-pay .btn { min-height: 36px; padding-top: 5px; padding-bottom: 5px; }
  .kp-pay .pay-methods { margin: 4px 0 6px; }
  .kp-pay .total-box { padding: 7px 10px; }
  .kp-pay .total-box .big { font-size: 18px; }
  .kp-pay .pay-go-2 { margin-top: 6px; gap: 6px; }
  .kp-find .search-2 .search, .kp-cart .cart-line input { padding-top: 6px; padding-bottom: 6px; }
}

/* Цифровая клавиатура в окне оплаты (для сенсорного экрана кассы) */
.numpad {
  display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: minmax(34px, 1fr); gap: 6px;
  flex: 1 1 auto; min-height: 124px; max-height: 300px; margin: 2px 0 6px;
}
.np-key {
  min-height: 0; padding: 0; font-family: var(--mono); font-size: 22px; font-weight: 600;
  background: var(--card-2); touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.np-key:active { background: var(--bg-2); transform: scale(.96); }
.np-back { color: var(--bad); }
@media (max-width: 900px) { .numpad { display: none; } }
/* совсем невысокий экран: две строки 1-5 ⌫ / 6-0 . */
@media (min-width: 901px) and (max-height: 700px) {
  .numpad { grid-template-columns: repeat(6, 1fr); grid-auto-rows: minmax(32px, 1fr); min-height: 70px; max-height: 110px; gap: 5px; }
  .np-key { font-size: 19px; }
  .np-key[data-np="1"] { order: 1; } .np-key[data-np="2"] { order: 2; } .np-key[data-np="3"] { order: 3; }
  .np-key[data-np="4"] { order: 4; } .np-key[data-np="5"] { order: 5; } .np-key[data-np="⌫"] { order: 6; }
  .np-key[data-np="6"] { order: 7; } .np-key[data-np="7"] { order: 8; } .np-key[data-np="8"] { order: 9; }
  .np-key[data-np="9"] { order: 10; } .np-key[data-np="0"] { order: 11; } .np-key[data-np="."] { order: 12; }
}
@media (min-width: 901px) and (max-height: 700px) {
  .kp-pay .pay-go-2 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kp-pay .pay-go { font-size: 13px; padding-left: 2px; padding-right: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
.np-key { display: grid; place-items: center; cursor: pointer; }
.np-key.down { background: var(--bg-2); transform: scale(.96); }
@media (min-width: 901px) { .kassa-main input.np-target { outline: 2px solid var(--accent); outline-offset: 1px; } }
/* на компьютере цифры набираются встроенной клавиатурой — кнопки ⌨ у полей оплаты не нужны, поля шире */
@media (min-width: 901px) { .kp-pay [data-pad] { display: none; } }
/* меню на невысоком экране прокручивается, нижние кнопки не уходят за край */
.menu-sheet { overflow-y: auto; height: 100%; max-height: 100dvh; }

/* Финансы: «Основные показатели» на всю ширину, по группам */
.metrics-box { max-width: none; }
.mb-head { margin-bottom: 10px; }
.mb-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.mb-group, .mb-hero { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--card-2); min-width: 0; }
.mb-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); margin-bottom: 6px; }
.mb-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 4px 0; font-size: 15px; color: var(--ink-soft); }
.mb-row + .mb-row { border-top: 1px dashed var(--line); }
.mb-row b { font-family: var(--mono); color: var(--ink); white-space: nowrap; }
.mb-hero { background: #1f1a14; border-color: #1f1a14; color: #f6edd9; display: flex; flex-direction: column; gap: 6px; }
.mb-hero.alt { background: var(--good); border-color: var(--good); color: #fff; }
.mb-label { font-size: 14px; opacity: .8; }
.mb-big { font-family: var(--mono); font-size: 24px; font-weight: 600; white-space: nowrap; }
.mb-hero .btn { align-self: flex-start; margin-top: auto; background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.25); color: inherit; font-size: 13px; }
.mb-hint { margin: 10px 0 0; }
@media (max-width: 760px) { .mb-big { font-size: 20px; } }
.mb-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1500px) { .mb-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 980px) { .mb-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .mb-grid { grid-template-columns: minmax(0, 1fr); } }
/* «Долги» убраны из показателей (есть отдельными карточками ниже): 5 блоков */
.mb-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1500px) { .mb-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } .mb-hero.alt { grid-column: span 2; } }
@media (max-width: 980px) { .mb-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .mb-hero.alt { grid-column: span 2; } }
@media (max-width: 560px) { .mb-grid { grid-template-columns: minmax(0, 1fr); } .mb-hero.alt { grid-column: auto; } }
/* 4 блока: кошелёк, склад, касса и доли, чистые активы */
.mb-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.mb-hero.alt { grid-column: auto; }
@media (max-width: 1100px) { .mb-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .mb-hero.alt { grid-column: auto; } }
@media (max-width: 560px) { .mb-grid { grid-template-columns: minmax(0, 1fr); } }
.silent-print { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.silent-print .btn { display: inline-block; text-decoration: none; color: inherit; margin-top: 4px; }
