/* Apple Store ERP — веб-версія. Світла тема, адаптивна верстка (ПК / планшет / телефон). */

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fafafc;
  --border: #e3e3e8;
  --border-strong: #d2d2d7;
  --text: #1d1d1f;
  --text-2: #424245;
  --muted: #6e6e73;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-press: #0062c4;
  --accent-soft: #e8f1fd;
  --select: #dcebff;
  --success: #1e7f3c;
  --success-bg: #e6f4ea;
  --success-btn: #248a3d;
  --danger: #c5221f;
  --danger-bg: #fce8e6;
  --warning: #9a5b00;
  --warning-bg: #fef4dc;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .04);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --topbar-h: 56px;
  --bottomnav-h: 62px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body.modal-open { overflow: hidden; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 16px; }
a { color: var(--accent); text-decoration: none; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos-val { color: var(--success); }
.neg-val { color: var(--danger); }
.grey { color: #8e8e93; }
.spacer { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.nowrap-row { flex-wrap: nowrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 14px; }
.hidden { display: none !important; }

/* ---------- Верхня панель ---------- */
.topwrap { position: sticky; top: 0; z-index: 30; }
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 16px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; white-space: nowrap; }
.brand img { width: 28px; height: 28px; border-radius: 7px; }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 7px 12px; border-radius: 8px; color: var(--text-2); white-space: nowrap; font-weight: 500;
}
.nav a:hover { background: #ebebf0; }
.nav a.active { background: var(--accent-soft); color: var(--accent-press); }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--border); color: var(--text-2);
  font-size: 12.5px; white-space: nowrap;
}
.chip b { color: var(--text); }
.rate-chip {
  border: none; cursor: pointer; font: inherit; font-weight: 600; white-space: nowrap;
  padding: 6px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-press);
}
.rate-chip:disabled { cursor: default; }
.user-btn { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 13px; flex: none;
}

/* ---------- Сторінка ---------- */
.page { padding: 16px; max-width: 1600px; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.page-head h1 { margin-right: auto; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }
.card-title { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-title h2 { margin-right: auto; }
.section-gap { height: 12px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .grow { flex: 1; min-width: 200px; }
.summary-line { color: var(--muted); margin-top: 10px; font-size: 13px; }
.summary-line b { color: var(--text); }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 7px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; user-select: none;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #f0f0f3; }
.btn:active { background: #e5e5ea; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-press); }
.btn-success { background: var(--success-btn); border-color: var(--success-btn); color: #fff; font-weight: 600; }
.btn-success:hover { background: #2a9a45; }
.btn-success:disabled { background: #a8d5b5; border-color: #a8d5b5; opacity: 1; }
.btn-danger { color: var(--danger); }
.btn-link { border-color: transparent; background: transparent; color: var(--accent); padding: 4px 6px; min-height: 0; }
.btn-link:hover { background: var(--accent-soft); }
.btn-big { min-height: 50px; font-size: 16px; border-radius: 12px; }
.btn-block { width: 100%; }
.icon-btn {
  border: none; background: transparent; font-size: 18px; width: 36px; height: 36px; border-radius: 50%;
  cursor: pointer; color: var(--muted); display: grid; place-items: center; flex: none;
}
.icon-btn:hover { background: #f0f0f3; color: var(--text); }
.icon-btn.danger { color: var(--danger); }

/* ---------- Поля вводу ---------- */
.input, select.input, textarea.input {
  width: 100%; min-height: 36px; padding: 7px 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit;
  outline: none; transition: border-color .12s, box-shadow .12s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 113, 227, .15); }
.input:disabled, .input[readonly] { background: var(--bg); color: var(--muted); }
.input.money { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
select.input {
  appearance: none; -webkit-appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236e6e73' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
textarea.input { min-height: 70px; resize: vertical; }
.input.w-auto { width: auto; }
.scan-wrap { display: flex; gap: 8px; align-items: stretch; flex: 1; min-width: 220px; }
.scan-input {
  flex: 1; min-width: 0; min-height: 46px; padding: 9px 14px;
  border: 2px solid var(--accent); border-radius: 10px; background: #fbfdff;
  font: inherit; font-size: 16px; outline: none;
}
.scan-input:focus { box-shadow: 0 0 0 4px rgba(0, 113, 227, .15); }
.cam-btn { min-width: 46px; font-size: 18px; padding: 0 12px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label, .field-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 3px 0; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.check.req { font-weight: 600; }

/* ---------- Повідомлення ---------- */
.note { padding: 8px 12px; border-radius: var(--radius-sm); font-size: 13.5px; }
.note-ok { background: var(--success-bg); color: var(--success); }
.note-error { background: var(--danger-bg); color: var(--danger); }
.note-warn { background: var(--warning-bg); color: var(--warning); }
.note-info { background: var(--accent-soft); color: var(--accent-press); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-ok { background: var(--success-bg); color: var(--success); }
.badge-error { background: var(--danger-bg); color: var(--danger); }
.badge-warn { background: var(--warning-bg); color: var(--warning); }
.badge-info { background: var(--accent-soft); color: var(--accent-press); }
.badge-grey { background: #f0f0f3; color: var(--muted); }

.toasts { position: fixed; z-index: 100; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px;
  max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 11px 14px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0, 0, 0, .15); font-weight: 500;
  background: var(--text); color: #fff; animation: toast-in .18s ease-out; }
.toast-error { background: var(--danger); }
.toast-ok { background: #1f2a1f; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Таблиці ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.tbl th {
  position: sticky; top: 0; z-index: 1; background: var(--bg); color: var(--text-2); font-weight: 600;
  text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
  cursor: pointer; user-select: none;
}
.tbl th.num { text-align: right; }
.tbl th .arrow { color: var(--muted); font-size: 11px; margin-left: 3px; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid #f0f0f3; vertical-align: middle; }
.tbl tbody tr:nth-child(even) td { background: var(--surface-2); }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr.clickable:hover td { background: #f2f7ff; }
.tbl tbody tr.selected td { background: var(--select) !important; }
.tbl tbody tr.dim td { color: #8e8e93; }
.tbl td.ellipsis { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl .chk { width: 36px; text-align: center; cursor: default; }
.tbl .chk input { width: 17px; height: 17px; accent-color: var(--accent); }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.more { padding: 10px; text-align: center; }

.cards { display: flex; flex-direction: column; gap: 8px; }
.rcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
  display: flex; gap: 10px; align-items: flex-start;
}
.rcard.clickable { cursor: pointer; }
.rcard.clickable:active { background: #f2f7ff; }
.rcard.selected { border-color: var(--accent); background: #f5f9ff; }
.rcard .rc-main { flex: 1; min-width: 0; }
.rcard .rc-title { font-weight: 600; font-size: 15px; display: flex; gap: 8px; justify-content: space-between; }
.rcard .rc-title .rc-right { font-variant-numeric: tabular-nums; white-space: nowrap; }
.rcard .rc-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.rcard .rc-grid { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin-top: 6px; font-size: 13px; }
.rcard .rc-grid span:nth-child(odd) { color: var(--muted); }
.rcard input[type=checkbox] { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); }

/* ---------- Вкладки ---------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin-bottom: 12px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  border: 1px solid transparent; background: transparent; padding: 7px 14px; border-radius: 9px;
  font: inherit; font-weight: 500; color: var(--text-2); cursor: pointer; white-space: nowrap;
}
.tabs button:hover { background: #ebebf0; }
.tabs button.active { background: var(--surface); border-color: var(--border); color: var(--accent); font-weight: 600; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.kpi .k-title { color: var(--muted); font-size: 12.5px; }
.kpi .k-value { font-size: 22px; font-weight: 650; letter-spacing: -.02em; margin-top: 2px; }
.kpi .k-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ---------- Модальні вікна ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .32);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  animation: fade-in .12s ease-out;
}
@keyframes fade-in { from { opacity: 0; } }
.modal {
  background: var(--bg); border-radius: 16px; width: min(560px, 100%); max-height: calc(100vh - 32px);
  display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); overflow: hidden;
}
.modal.wide { width: min(980px, 100%); }
.modal.xwide { width: min(1320px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; background: var(--surface);
  border-bottom: 1px solid var(--border); }
.modal-head h3 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 16px; overflow: auto; flex: 1 1 auto; min-height: 0; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding: 12px 16px;
  background: var(--surface); border-top: 1px solid var(--border); }

/* ---------- Каса ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 12px; align-items: start; }
.pos-pay { position: sticky; top: calc(var(--topbar-h) + 12px); }
.total-big { font-size: 34px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.pay-grid { display: grid; grid-template-columns: 120px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.pay-grid .hint { grid-column: 2 / 4; margin-top: -4px; }
.sum-grid { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; font-size: 15px; }
.sum-grid b { font-size: 17px; font-variant-numeric: tabular-nums; text-align: right; }
.cart-item { display: grid; grid-template-columns: minmax(0, 1fr) 140px 36px; gap: 10px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid #f0f0f3; }
.cart-item:last-child { border-bottom: none; }
.cart-item .ci-title { font-weight: 600; }
.cart-item .ci-sub { color: var(--muted); font-size: 12.5px; }
.ti-item { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface-2); }
.ti-item .ti-main { flex: 1; min-width: 0; }
.checkout-bar { display: none; }

/* ---------- Картка пристрою ---------- */
.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 6px 12px; }
.kv > span:nth-child(odd) { color: var(--muted); }
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item { display: grid; grid-template-columns: 110px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid #f0f0f3; }
.tl-item:last-child { border-bottom: none; }
.tl-item .tl-kind { font-weight: 600; }

/* ---------- Графіки ---------- */
.chart-box { position: relative; width: 100%; }
.chart-legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5; background: var(--text); color: #fff; font-size: 12.5px;
  padding: 7px 10px; border-radius: 8px; white-space: nowrap; transform: translate(-50%, calc(-100% - 8px));
}
.hbars { display: flex; flex-direction: column; gap: 6px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 34%) 1fr; gap: 10px; align-items: center; font-size: 13px; }
.hbar .hb-label { text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .hb-track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hbar .hb-fill { height: 18px; border-radius: 0 4px 4px 0; background: #2a78d6; min-width: 2px; flex: none; }
.hbar .hb-val { color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; font-size: 12.5px; }

/* ---------- Вхід ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(400px, 100%); }
.login-card .logo { width: 64px; height: 64px; border-radius: 16px; display: block; margin: 0 auto 10px; }

/* ---------- Нижня навігація (телефон) ---------- */
.bottomnav { display: none; }
.sheet-back { position: fixed; inset: 0; z-index: 45; background: rgba(0, 0, 0, .3); }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 46; background: var(--surface);
  border-radius: 18px 18px 0 0; padding: 10px 12px calc(14px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .15); animation: sheet-in .18s ease-out;
}
@keyframes sheet-in { from { transform: translateY(30px); opacity: .5; } }
.sheet a, .sheet button.sheet-item {
  display: flex; align-items: center; gap: 12px; padding: 13px 10px; border-radius: 10px; color: var(--text);
  font: inherit; font-size: 16px; width: 100%; border: none; background: none; text-align: left; cursor: pointer;
}
.sheet a:active, .sheet button.sheet-item:active { background: var(--bg); }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--border-strong); margin: 0 auto 8px; }

/* ---------- Сканер камерою ---------- */
.cam-box { width: 100%; min-height: 260px; background: #000; border-radius: 12px; overflow: hidden; }

/* =========================================================================================
   Адаптація: планшет / телефон
   ========================================================================================= */
@media (max-width: 1100px) {
  .pos { grid-template-columns: minmax(0, 1fr) 380px; }
}

@media (max-width: 820px) {
  body { font-size: 15px; }
  .input, select.input, textarea.input, .scan-input { font-size: 16px; }   /* iOS не масштабує поле при фокусі */
  .topbar { height: 52px; padding: 0 12px; gap: 8px; }
  .topbar .nav, .topbar .user-name, .topbar .hide-mobile { display: none; }
  .brand span { display: none; }
  .page { padding: 12px 12px calc(var(--bottomnav-h) + 20px + env(safe-area-inset-bottom)); }
  .page-head h1 { font-size: 20px; }
  .card { padding: 14px; border-radius: 14px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 120px minmax(0, 1fr); }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi .k-value { font-size: 19px; }
  .toolbar > .input, .toolbar > select.input { flex: 1 1 140px; width: auto; }
  .modal-back { padding: 0; align-items: stretch; }
  .modal, .modal.wide, .modal.xwide { width: 100%; max-height: none; height: 100%; border-radius: 0; }
  .modal-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; }
  .pos { grid-template-columns: 1fr; }
  .pos-pay { position: static; }
  .pay-grid { grid-template-columns: 96px minmax(0, 1fr) auto; }
  .cart-item { grid-template-columns: minmax(0, 1fr) 120px 32px; }
  .checkout-bar {
    display: flex; position: fixed; left: 0; right: 0; bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
    z-index: 25; gap: 10px; align-items: center; padding: 10px 12px; background: rgba(255, 255, 255, .96);
    border-top: 1px solid var(--border); backdrop-filter: blur(10px);
  }
  .checkout-bar .total-small { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
  .pos-pay .desktop-checkout { display: none; }
  .page.with-checkout { padding-bottom: calc(var(--bottomnav-h) + 90px + env(safe-area-inset-bottom)); }
  .toasts { bottom: calc(var(--bottomnav-h) + 16px + env(safe-area-inset-bottom)); right: 12px; left: 12px; max-width: none; }
  .bottomnav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: rgba(255, 255, 255, .96); border-top: 1px solid var(--border); backdrop-filter: blur(12px);
  }
  .bottomnav a, .bottomnav button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--muted); font: inherit; font-size: 11px; border: none; background: none; cursor: pointer;
  }
  .bottomnav .bn-icon { font-size: 21px; line-height: 1; }
  .bottomnav .active { color: var(--accent); font-weight: 600; }
  .hbar { grid-template-columns: minmax(80px, 38%) 1fr; }
}

@media (min-width: 821px) {
  .only-mobile { display: none !important; }
}
@media (max-width: 820px) {
  .only-desktop { display: none !important; }
}

/* дві колонки: форма + журнал */
.split { display: grid; grid-template-columns: minmax(0, 520px) minmax(0, 1fr); gap: 12px; align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }


/* фільтр періоду */
.period { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

@media (max-width: 820px) {
  .card-title { flex-wrap: wrap; }
  .nowrap-row { flex-wrap: wrap !important; }
  .scan-wrap { flex: 1 1 100%; min-width: 0; }
  .period { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .period select { grid-column: 1 / -1; width: 100%; }
  .period input { width: 100%; }
  .toolbar { gap: 8px; }
  .toolbar .grow { min-width: 0; flex-basis: 100%; }
}

/* захист від горизонтального переповнення на телефоні */
.page { overflow-x: clip; }
.chart-box svg { display: block; max-width: 100%; height: auto; }


/* =========================================================================================
   Навігація як у настільній програмі: головні вкладки з емодзі + підвкладки розділу
   ========================================================================================= */
.user-chip { font-size: 13px; padding: 5px 12px; }
.maintabs {
  display: flex; gap: 6px; padding: 8px 16px; overflow-x: auto; scrollbar-width: none;
  background: rgba(245, 245, 247, .95); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
}
.maintabs::-webkit-scrollbar { display: none; }
.maintabs a {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  padding: 9px 20px; border-radius: 10px; border: 1px solid transparent;
  color: var(--text-2); font-size: 15px; font-weight: 500;
}
.maintabs a:hover:not(.active) { background: #ebebf0; }
.maintabs a.active { background: var(--surface); border-color: var(--border); color: var(--accent); font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04); }
.mt-icon { font-size: 18px; line-height: 1; }
.subtabs-wrap { max-width: 1600px; margin: 0 auto; padding: 12px 16px 0; }
.subtabs { margin-bottom: 0; }
.tabs a {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  border: 1px solid transparent; padding: 7px 14px; border-radius: 9px; font-weight: 500; color: var(--text-2);
}
.tabs a:hover:not(.active) { background: #ebebf0; }
.tabs a.active { background: var(--surface); border-color: var(--border); color: var(--accent); font-weight: 600; }
.st-icon { font-size: 15px; line-height: 1; }
.page-head h1 .h-icon { margin-right: 8px; }
.pos-pay { top: 130px; }

/* ПК: розділ видно з вкладок — заголовок сторінки не дублюємо */
@media (min-width: 821px) {
  .page-head { justify-content: flex-end; }
  .page-head h1 { display: none; }
}

/* Телефон: головні вкладки замінює нижнє меню, підвкладки — гортаються пальцем */
@media (max-width: 820px) {
  .maintabs { display: none; }
  .subtabs-wrap { padding: 10px 12px 0; }
  .subtabs { gap: 6px; }
  .subtabs a { background: var(--surface); border-color: var(--border); padding: 8px 14px; }
  .subtabs a.active { background: var(--accent); border-color: var(--accent); color: #fff; }
  .rate-chip { padding: 6px 10px; font-size: 13px; }
}

/* рядок сканування: поле + іконки в один рядок і на телефоні */
@media (max-width: 820px) {
  .scan-row { flex-wrap: nowrap !important; }
  .scan-row .scan-wrap { flex: 1 1 auto; }
  .scan-row > .btn { min-width: 46px; padding: 0 12px; font-size: 18px; }
  .card-title .btn { min-width: 42px; }
}

/* компактні рядки таблиць, як у настільній програмі */
.tbl td { white-space: nowrap; }

/* ---------- резервні копії ---------- */
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.row > .grow { flex: 1; min-width: 200px; }
.backup-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.backup-item { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.backup-item > div:first-child { min-width: 0; overflow-wrap: anywhere; }
.backup-chip { cursor: pointer; }
.update-bar { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; padding: 8px 16px;
  background: var(--accent-soft); color: var(--accent-press); font-weight: 600; text-align: center; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 6px 12px; font: inherit; cursor: pointer; color: var(--text-2); }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button.active { background: var(--accent); color: #fff; font-weight: 600; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.steps code, .cmd { background: #f5f5f7; padding: 2px 6px; border-radius: 6px; font-size: 13px; overflow-wrap: anywhere; }/* ---------- вибір курсу RULYA ---------- */
.rate-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.rate-option { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface); font: inherit; color: var(--text-2); }
.rate-option b { font-size: 20px; color: var(--text); }
.rate-option:hover { border-color: var(--accent); }
.rate-option.active { border: 2px solid var(--accent); background: var(--accent-soft); color: var(--accent-press); }
.rate-option.active b { color: var(--accent-press); }
.rate-option:disabled { opacity: .6; cursor: default; }/* ---------- контрагенти ---------- */
.client-hint { margin-top: 10px; padding: 8px 12px; border-radius: 10px; background: var(--success-bg); color: var(--text);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
/* ---------- простір «Сервіс»: власний колір, щоб не сплутати з магазинами ---------- */
html[data-ws="service"] { --accent: #c2410c; --accent-hover: #d9480f; --accent-press: #9a3412; --accent-soft: #fff1e6; }
html[data-ws="service"] .topbar { border-bottom: 3px solid #f97316; }
.ws-badge { margin-left: 8px; padding: 2px 8px; border-radius: 8px; background: #f97316; color: #fff; font-size: 12px; font-weight: 700; }
.ws-switch { margin-left: 12px; }
.ws-switch button { padding: 6px 10px; white-space: nowrap; }
@media (max-width: 820px) { .ws-switch { display: none; } }
.totals-kv { max-width: 420px; margin-left: auto; }
.debt-balance { font-size: 18px; font-weight: 600; }
.pick-item { text-align: left; cursor: pointer; font: inherit; width: 100%; }
.pick-item:hover { border-color: var(--accent); }

/* ---------- ПРРО Checkbox ---------- */
.rate-option b.small { font-size: 12px; font-weight: 500; color: var(--muted); }
.fiscal-test-bar { background: var(--accent-soft); color: var(--accent-press); border-radius: 10px; padding: 8px 12px;
  margin-bottom: 10px; font-size: 14px; }
.x-report { white-space: pre-wrap; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; margin: 0; }
.fiscal-modes { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 700px) { .fiscal-modes { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- каталог товарів і послуг ---------- */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-bottom: 10px; }
.crumbs button { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 4px 10px;
  cursor: pointer; font: inherit; color: var(--text); }
.crumbs button.active { border-color: var(--accent); color: var(--accent-press); background: var(--accent-soft); }
.crumbs span { color: var(--muted); }
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin-bottom: 12px; }
.folder-card { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 12px; background: var(--surface); cursor: pointer; }
.folder-card:hover { border-color: var(--accent); }
.folder-card > div { flex: 1; min-width: 0; }
.folder-icon { font-size: 22px; }
.pick-list { display: flex; flex-direction: column; gap: 6px; max-height: 55vh; overflow-y: auto; }
.pick-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; text-align: left;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer;
  font: inherit; color: var(--text); }
.pick-row:hover:not(:disabled) { border-color: var(--accent); }
.pick-row:disabled { opacity: .45; cursor: default; }
.qty-step { display: inline-flex; align-items: center; gap: 4px; }
.qty-step button { width: 30px; height: 30px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  cursor: pointer; font-size: 16px; color: var(--text); }
.qty-step b { min-width: 22px; text-align: center; }
.receipt-line { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface); flex-wrap: wrap; }
.receipt-line .grow { flex: 1; min-width: 160px; }
.return-line { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; align-items: center; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 10px; }
.return-line.off { opacity: .5; }
