/* ===================== Product sets ===================== */
.sets-strip { margin-bottom: 14px; }
.set-row { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 8px; scroll-snap-type: x mandatory; }
.set-card { flex: 0 0 172px; scroll-snap-align: start; border: 1px solid var(--line); background: linear-gradient(180deg, #fff, #f7f7ff); border-radius: 12px; padding: 8px; text-align: left; cursor: pointer; font: inherit; color: var(--text); display: grid; gap: 4px; align-content: start; transition: border-color .15s, box-shadow .15s; }
.set-card:hover { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.set-card:active { transform: scale(.98); }
.set-card .im { height: 72px; border-radius: 8px; background: #f1f3f8; display: grid; place-items: center; overflow: hidden; font-size: 26px; }
.set-card .im img { max-width: 100%; max-height: 72px; object-fit: contain; }
.set-card .nm { font-weight: 650; font-size: 12.5px; line-height: 1.25; }
.set-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.set-big { cursor: pointer; transition: box-shadow .15s; }
.set-big:hover { box-shadow: var(--shadow-lg); }
.set-big.off { opacity: .55; }
.set-ic { width: 52px; height: 40px; border-radius: 8px; background: #f1f3f8; display: grid; place-items: center; overflow: hidden; flex: none; font-size: 20px; }
.set-ic img { max-width: 100%; max-height: 100%; object-fit: contain; }
.set-ol { margin: 0; padding-left: 18px; display: grid; gap: 3px; }
.set-edit-row { display: grid; grid-template-columns: minmax(0, 1fr) 80px 34px 34px; gap: 6px; margin-bottom: 6px; align-items: center; }
.form-grid.set-head { grid-template-columns: 2fr 1fr; }

/* ===================== Orders / dispatch ===================== */
.order-acts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.order-acts .btn { height: auto; min-height: 40px; white-space: normal; padding: 8px; line-height: 1.2; }
.order-won { border-color: #bfe8cf; }
.doc-list { border: 1px solid var(--line2); border-radius: 10px; }
.disp-list { display: grid; gap: 8px; margin-top: 8px; }
.disp-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fcfcfe; display: grid; gap: 3px; }
.disp-ReadytoDispatch, .disp-Readytodispatch { background: var(--gray-l); color: var(--gray); }
.disp-Dispatched { background: var(--blue-l); color: var(--blue); }
.disp-Intransit { background: var(--amber-l); color: var(--amber); }
.disp-Delivered { background: var(--green-l); color: var(--green); }
.disp-Installed { background: #dcfce7; color: #166534; }
.alert.green-a { background: #f3fbf6; border-color: #cdeed9; } .alert.green-a .n { color: var(--green); }
.alert.blue, .alert.amber, .alert.gray, .alert.green-a { cursor: default; }
.qd-words { font-style: italic; margin: 6px 0 12px; font-size: 12px; }
.qd-sign-row { display: flex; justify-content: space-between; gap: 20px; align-items: flex-end; flex-wrap: wrap; }
.qd-sign.accept { align-items: center; text-align: center; min-width: 200px; }
.qd-sign.accept div { border-bottom: 1px solid #999; width: 200px; }

.bulk-bar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--primary-l); border-bottom: 1px solid var(--line2); }
.bulk-bar[hidden] { display: none; }

/* checkbox column */
.tbl .ck { width: 34px; padding-right: 0; }
.tbl .ck input { width: 18px; height: 18px; cursor: pointer; }

/* install button in sidebar */
.install-btn { margin: 0 8px 10px; background: rgba(99,102,241,.18); color: #fff; border: 1px solid rgba(255,255,255,.12); }
.install-btn:hover { background: rgba(99,102,241,.3); }

.steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.only-mob { display: none !important; }
@media (max-width: 640px) {
  .only-mob { display: inline-flex !important; }
  .filters.fcoll > label:not(.q) { display: none; }
  .filters.fcoll #fExport { display: none; }
}
.msearch { display: none; }

/* ===================== Bottom tab bar (phones / tablets) ===================== */
.bnav { display: none; }
@media (max-width: 860px) { .msearch { display: inline-flex; margin-left: auto; } }
@media (max-width: 860px) {
  .bnav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; background: rgba(255,255,255,.97); backdrop-filter: blur(8px); border-top: 1px solid var(--line);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); justify-content: space-around; box-shadow: 0 -4px 16px rgba(0,0,0,.06); }
  .bnav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; color: var(--muted); font-size: 10.5px; font-weight: 650; padding: 5px 0 3px; position: relative; border-radius: 10px; min-width: 0; }
  .bnav a i { font-style: normal; font-size: 19px; line-height: 1.15; }
  .bnav a.active { color: var(--primary); }
  .bnav a.bplus { flex: 0 0 64px; }
  .bnav a.bplus i { width: 48px; height: 48px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 26px; margin-top: -20px; box-shadow: 0 6px 16px rgba(79,70,229,.45); }
  .bbadge { position: absolute; top: 1px; left: calc(50% + 6px); background: var(--red); color: #fff; font-size: 10px; font-weight: 700; border-radius: 99px; padding: 0 5px; line-height: 16px; }
  .view { padding-bottom: 96px; }
  .sticky-bar { bottom: calc(60px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .top .btn.primary { display: none; }
  .top { padding-top: calc(10px + env(safe-area-inset-top)); }
  .toasts { bottom: calc(78px + env(safe-area-inset-bottom)); left: 12px; right: 12px; }
  .toast { max-width: none; }
  input, select, textarea { font-size: 16px; } /* stops iPhone zooming into fields */
  .side { padding-top: calc(16px + env(safe-area-inset-top)); }
}

/* ===================== Phones ===================== */
@media (max-width: 640px) {
  /* tables become cards */
  table.tbl.stack thead { display: none; }
  table.tbl.stack, table.tbl.stack tbody { display: block; }
  table.tbl.stack tr { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 10px; padding: 12px 14px; border-bottom: 1px solid var(--line2); }
  table.tbl.stack td { display: block; border: 0; padding: 0; flex: 1 1 100%; min-width: 0; max-width: none !important; }
  table.tbl.stack td.mi { flex: 0 0 auto; }
  table.tbl.stack td.hm, table.tbl.stack .hm { display: none; }
  table.tbl.stack td.ck { flex: 0 0 auto; order: -1; width: auto; }
  table.tbl.stack .right { text-align: left; }
  table.tbl.stack .nowrap { white-space: normal; }
  table.tbl.stack .t1 { font-size: 15px; }
  table.tbl.stack br { display: none; }

  .view { padding: 12px 12px 96px; }
  .card-h { flex-wrap: wrap; padding: 12px 14px; }
  .card-b { padding: 14px; }
  .filters { padding: 12px; gap: 8px; }
  .filters > * { flex: 1 1 calc(50% - 8px); }
  .filters .q { flex: 1 1 100%; }
  .filters .btns { flex: 1 1 100%; }
  .filters .btns .btn { flex: 1; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -12px 14px; padding: 0 12px 2px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .tabs { margin: 0 -12px 14px; padding: 0 8px; }
  .d-head { gap: 10px; }
  .d-head h2 { font-size: 18px; }
  .d-acts { width: 100%; }
  .d-acts .btn { flex: 1 1 auto; }
  .status-steps { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; max-width: 100%; scrollbar-width: none; }
  .status-steps::-webkit-scrollbar { display: none; }
  html, body { overflow-x: clip; } /* safety net: never let anything widen the phone screen (clip keeps the sticky header working) */
  .status-steps button { flex: none; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { font-size: 12px; margin-top: 8px; }
  .modal-bg { padding: 0; align-items: end; }
  .modal { max-height: 92vh; border-radius: 18px 18px 0 0; max-width: none; }
  .modal.wide { max-width: none; }
  .modal-f { padding-bottom: calc(14px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .modal-f .btn { flex: 1 1 auto; }
  .sticky-bar .btn { flex: 1 1 auto; }
  .sticky-bar .sp { display: none; }
  .row.sb > div:last-child { width: 100%; }
  .row.sb > div:last-child select { flex: 1; }
  .alert { padding: 12px; gap: 10px; }
  .alert .n { font-size: 22px; }
  .alert small { display: none; }
  .li { padding: 11px 14px; }
  .li .acts .btn { height: 32px; min-width: 34px; }
  .form-grid.set-head { grid-template-columns: 1fr; }
  .bulk-bar { flex-wrap: wrap; }
  .bulk-bar select { flex: 1 1 100%; }
  .set-grid { grid-template-columns: 1fr; }
  .set-card { flex-basis: 150px; }
  .prod-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .pcard .im { height: 100px; }
  .pick-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .pick .im { height: 60px; }
  .bitem { padding: 10px; gap: 8px; }
  .term-row { grid-template-columns: minmax(0, 1fr) 34px; }
  .qdoc-wrap { padding: 10px 4px; margin: 0 -12px; border-radius: 0; }
  .board { grid-auto-columns: 82vw; scroll-snap-type: x mandatory; }
  .lane { scroll-snap-align: start; }
  .preview-bar .btn { flex: 1 1 auto; }
  .print-bar { flex-wrap: wrap; }
}
