:root {
  --bg: #eef3f8;
  --surface: #ffffff;
  --surface-soft: #f6f8fb;
  --ink: #101113;
  --muted: #667085;
  --line: #d6dde6;
  --black: #050505;
  --primary: #f97316;
  --primary-strong: #c2410c;
  --primary-soft: #fff3e8;
  --accent: #0ea5e9;
  --accent-strong: #075985;
  --accent-soft: #e7f6ff;
  --success: #166534;
  --warning: #c2410c;
  --danger: #b91c1c;
  --info: #0f6fb5;
  --radius: 8px;
  --shadow: 0 12px 28px rgba(5, 5, 5, .08);
}

* { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #f8fafc 0, var(--bg) 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

button, input, select, textarea {
  font: inherit;
}

a { color: var(--accent-strong); }

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.4rem clamp(1rem, 4vw, 2.5rem);
  background: var(--black);
  color: white;
  border-bottom: 4px solid var(--primary);
  box-shadow: 0 12px 28px rgba(5, 5, 5, .16);
  position: sticky;
  top: 0;
  z-index: 20;
}

h1, h2, h3 { margin: 0; line-height: 1.1; }
h1 { font-size: clamp(1.8rem, 4vw, 3rem); }
h2 { font-size: clamp(1.35rem, 3vw, 2rem); }
h3 { font-size: 1.05rem; }

.app-header h1 { color: white; white-space: nowrap; }

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.brand-logo {
  width: clamp(150px, 18vw, 250px);
  height: 70px;
  object-fit: contain;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
}

.eyebrow {
  color: var(--muted);
  text-transform: uppercase;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 .35rem;
}

.app-header .eyebrow { color: var(--primary); }

.header-actions {
  display: flex;
  gap: .7rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.session-box {
  display: flex;
  align-items: center;
  gap: .45rem;
  color: #cbd5e1;
  font-size: .82rem;
  font-weight: 800;
}

.session-box[hidden] { display: none; }

.sync-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: .35rem .6rem;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: var(--radius);
  color: #dbeafe;
  background: rgba(14, 165, 233, .14);
  font-size: .78rem;
  font-weight: 850;
  white-space: nowrap;
}
.sync-badge[data-mode="server"] {
  color: #bbf7d0;
  background: rgba(22, 101, 52, .22);
}
.sync-badge[data-mode="error"] {
  color: #fecaca;
  background: rgba(185, 28, 28, .24);
}

.pwa-install-btn[hidden] { display: none; }

.role-switcher {
  display: grid;
  gap: .25rem;
  font-weight: 700;
  color: #cbd5e1;
  font-size: .78rem;
}

.app-shell {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 1rem;
  padding: clamp(1rem, 3vw, 2rem);
  max-width: 1600px;
  margin: 0 auto;
}

.tabs {
  display: grid;
  gap: .45rem;
  align-self: start;
  position: sticky;
  top: 7rem;
}

.tab {
  border: 1px solid transparent;
  background: rgba(255, 255, 255, .78);
  color: var(--muted);
  padding: .85rem 1rem;
  text-align: left;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 800;
  transition: .16s ease;
}
.tab:hover, .tab.active {
  background: var(--black);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 8px 20px rgba(5,5,5,.12);
}

.view { min-width: 0; }

.card {
  background: rgba(255, 255, 255, .92);
  border: 1px solid rgba(219, 227, 239, .88);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1rem, 2vw, 1.35rem);
}

.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.kpi {
  display: grid;
  gap: .45rem;
  min-height: 135px;
}
.kpi strong { font-size: clamp(2rem, 6vw, 3.4rem); line-height: 1; }
.kpi span { color: var(--muted); font-weight: 700; }
.kpi.warning { border-color: rgba(249,115,22,.38); background: #fff7ed; }
.kpi.danger { border-color: rgba(185,28,28,.35); background: #fff1f2; }
.kpi.success { border-color: rgba(22,101,52,.3); background: #f0fdf4; }
.kpi.info { border-color: rgba(14,165,233,.32); background: var(--accent-soft); }

.toolbar {
  display: flex;
  gap: .7rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.toolbar-left, .toolbar-right {
  display: flex;
  gap: .55rem;
  flex-wrap: wrap;
  align-items: center;
}
.toolbar-actions {
  display: flex;
  gap: .55rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

.btn {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .72rem .95rem;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 850;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 42px;
  line-height: 1.15;
  text-align: center;
  touch-action: manipulation;
  overflow-wrap: anywhere;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(15,23,42,.08); }
.btn.primary { background: var(--primary); color: var(--black); border-color: var(--primary); }
.btn.secondary { background: var(--accent-soft); color: var(--accent-strong); border-color: rgba(14,165,233,.32); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.danger { color: var(--danger); border-color: rgba(185,28,28,.25); }
.btn.small { padding: .45rem .62rem; min-height: 36px; border-radius: var(--radius); font-size: .86rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: white;
  cursor: pointer;
  font-size: 1.4rem;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  border-radius: var(--radius);
  padding: .7rem .8rem;
  outline: none;
  min-height: 44px;
  font-size: 16px;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(249,115,22,.16);
}
label {
  display: grid;
  gap: .35rem;
  color: var(--muted);
  font-weight: 800;
  font-size: .84rem;
}
label input, label select, label textarea { color: var(--ink); font-weight: 600; }
.input-with-button { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .35rem; }
.location-field {
  display: grid;
  gap: .55rem;
}
.location-generator {
  display: grid;
  grid-template-columns: .8fr .8fr .8fr auto;
  gap: .45rem;
  align-items: end;
  padding: .65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}
.location-generator label { gap: .25rem; }
.location-generator input {
  min-height: 36px;
  text-align: center;
  text-transform: uppercase;
}
.location-generator .btn { min-height: 36px; white-space: nowrap; }

.table-wrap {
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 0;
  table-layout: fixed;
}
th, td {
  padding: .62rem .68rem;
  border-bottom: 1px solid #edf2f7;
  text-align: left;
  vertical-align: middle;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: normal;
}
td {
  font-size: .84rem;
  line-height: 1.35;
}
th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: 0;
  white-space: normal;
  line-height: 1.25;
}
tr:hover td { background: #fafafa; }
tr.low td { background: #fff7ed; }
tr.zero td { background: #fff1f2; }
td.actions { white-space: normal; }
.table-wrap input,
.table-wrap select,
.table-wrap textarea {
  min-width: 0;
  padding-inline: .55rem;
}
.table-wrap .badge {
  max-width: 100%;
  white-space: normal;
  text-align: center;
  justify-content: center;
}
.table-wrap td.actions .btn {
  width: 100%;
  margin: .12rem 0;
}
.table-wrap td.actions .table-cell-value {
  display: grid;
  gap: .25rem;
}
.table-cell-value {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.products-table td[data-label="Zdjecie"] { width: 64px; }
.products-table td[data-label="Produkt"] { width: 14%; }
.products-table td[data-label="Kategoria"] { width: 9%; }
.products-table td[data-label="Kod"] { width: 9%; }
.products-table td[data-label="Lokalizacja"] { width: 8%; }
.products-table td[data-label="Stan"],
.products-table td[data-label="Minimum"],
.products-table td[data-label="Zamówiono"] { width: 6.5%; }
.products-table td[data-label="Status"] { width: 10%; }
.products-table td[data-label="Cena netto / brutto"] { width: 9%; }
.products-table td[data-label="Dostawcy"] { width: 11%; }
.products-table td[data-label="Akcje"] { width: 94px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .25rem .55rem;
  font-size: .78rem;
  font-weight: 900;
  background: white;
  color: var(--muted);
  white-space: nowrap;
}
.badge.success { color: var(--success); border-color: rgba(22,101,52,.25); background: #f0fdf4; }
.badge.warning { color: var(--warning); border-color: rgba(249,115,22,.3); background: #fff7ed; }
.badge.danger { color: var(--danger); border-color: rgba(185,28,28,.25); background: #fff1f2; }
.badge.info { color: var(--info); border-color: rgba(29,78,216,.25); background: #eff6ff; }

.muted { color: var(--muted); }
.small-text { font-size: .86rem; }
.section-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.section-title p { margin: .35rem 0 0; color: var(--muted); }

.modal {
  border: none;
  padding: 0;
  background: transparent;
  width: min(920px, calc(100vw - 1.2rem));
}
.modal::backdrop { background: rgba(15, 23, 42, .62); backdrop-filter: blur(4px); }
.modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: clamp(1rem, 2vw, 1.4rem);
  border: 1px solid var(--line);
  box-shadow: 0 30px 70px rgba(0,0,0,.22);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .8rem;
}
.full { grid-column: 1 / -1; }
.product-photo-field {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 1rem;
  align-items: center;
  padding: .85rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}
.product-photo-preview {
  width: 150px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: white;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 850;
  text-align: center;
  padding: 0;
  cursor: pointer;
}
.product-photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.product-photo-actions {
  display: flex;
  gap: .55rem;
  align-items: center;
  flex-wrap: wrap;
}
.product-photo-actions p { width: 100%; margin: 0; }
.photo-zoom-card {
  max-width: min(940px, 96vw);
}
.photo-zoom-card img {
  width: 100%;
  max-height: 76vh;
  object-fit: contain;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: white;
}
.product-thumb {
  width: 58px;
  height: 58px;
  object-fit: cover;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: white;
}
.product-thumb.empty {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 850;
  text-align: center;
}
.shopping-order-form {
  display: grid;
  gap: .85rem;
}
.shopping-list-table th,
.shopping-list-table td {
  vertical-align: top;
}
.shopping-list-table input {
  min-width: 120px;
}
.shopping-list-table input[type="checkbox"] {
  width: auto;
  min-width: 0;
}
.shopping-list-table td:nth-child(2) {
  min-width: 180px;
}
.shopping-order-summary {
  margin-top: .2rem;
}
.purchase-edit-table th,
.purchase-edit-table td {
  vertical-align: top;
}
.purchase-edit-table input,
.purchase-edit-table select {
  min-width: 130px;
}
.purchase-edit-table td:first-child {
  min-width: 180px;
}
.purchase-edit-table td:last-child {
  min-width: 220px;
}
.modal-actions {
  display: flex;
  gap: .6rem;
  align-items: center;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.spacer { flex: 1; }

#scannerVideo {
  width: 100%;
  max-height: 420px;
  background: #0f172a;
  border-radius: var(--radius);
  display: block;
  object-fit: cover;
}
.scanner-fallback {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: .7rem;
  align-items: end;
  margin-top: 1rem;
}

.supplier-offer-row {
  padding: .8rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .03);
}

#quickProjectScanPanel {
  margin: .75rem 0;
}

.status-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: .55rem;
}
.status-card {
  padding: .85rem;
  border-radius: var(--radius);
  background: var(--surface-soft);
  border: 1px solid var(--line);
}
.status-card strong { display: block; font-size: 1.45rem; }
.status-card span { color: var(--muted); font-weight: 700; font-size: .82rem; }

.list {
  display: grid;
  gap: .55rem;
}
.list-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .85rem;
  background: white;
}
.list-item p { margin: .25rem 0 0; color: var(--muted); }
.purchase-draft-list .empty-state {
  padding: .9rem;
}
.purchase-draft-item {
  align-items: center;
}
.purchase-draft-item p {
  color: var(--ink);
}

.report-box {
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius);
  padding: 1rem;
  background: #fff;
}
.report-total {
  text-align: right;
  font-size: 1.25rem;
  font-weight: 950;
}
.report-accordion-list {
  display: grid;
  gap: .8rem;
  margin-top: 1rem;
}
.report-accordion {
  padding: 0;
  overflow: hidden;
}
.report-accordion > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.15rem;
  cursor: pointer;
  list-style: none;
  background: var(--surface);
  user-select: none;
}
.report-accordion > summary::-webkit-details-marker { display: none; }
.report-accordion > summary:hover { background: var(--surface-soft); }
.report-accordion > summary:focus-visible {
  outline: 3px solid rgba(249, 115, 22, .3);
  outline-offset: -3px;
}
.report-accordion > summary > span:first-child {
  display: grid;
  gap: .22rem;
}
.report-accordion > summary strong { font-size: 1.02rem; }
.report-accordion > summary small {
  color: var(--muted);
  font-size: .82rem;
}
.report-accordion-icon {
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--primary-strong);
  background: var(--primary-soft);
  font-size: 1.35rem;
  font-weight: 900;
  transition: transform .18s ease;
}
.report-accordion[open] .report-accordion-icon { transform: rotate(180deg); }
.report-accordion-body {
  display: grid;
  gap: .8rem;
  padding: 1rem;
  border-top: 1px solid var(--line);
  background: #fbfcfe;
}
.report-accordion-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .45rem;
}
.report-controls {
  align-items: end;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.print-report {
  display: grid;
  gap: 1rem;
}
.print-report-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 3px solid var(--primary);
  padding-bottom: .9rem;
}
.print-report-title {
  display: grid;
  gap: .25rem;
}
.print-report-logo {
  width: 150px;
  max-height: 64px;
  object-fit: contain;
}
.report-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .6rem;
}
.report-meta div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .7rem;
  background: var(--surface-soft);
}
.report-meta span {
  display: block;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 800;
  text-transform: uppercase;
}
.report-meta strong {
  display: block;
  margin-top: .25rem;
  font-size: 1.05rem;
}
.report-subtitle {
  color: var(--muted);
  margin: .25rem 0 0;
}

.label-builder {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 1rem;
}
.label-sheet {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  min-height: 360px;
}
.labels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: .65rem;
}
.label-preview {
  border: 1px solid #111827;
  width: 250px;
  aspect-ratio: 5 / 3;
  padding: 10px;
  background: white;
  display: grid;
  align-content: space-between;
  overflow: hidden;
  page-break-inside: avoid;
}
.label-preview h4 { margin: 0; font-size: 15px; line-height: 1.12; max-height: 34px; overflow: hidden; }
.label-preview p { margin: 2px 0 0; font-size: 11px; line-height: 1.1; }
.label-preview svg { display: block; width: 100%; height: 42px; }
.label-code p { text-align: center; letter-spacing: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label-format-80x50 .label-preview { width: 320px; aspect-ratio: 8 / 5; padding: 14px; }
.label-format-80x50 .label-preview h4 { font-size: 19px; max-height: 43px; }
.label-format-80x50 .label-preview p { font-size: 13px; }
.label-format-80x50 .label-preview svg { height: 58px; }
.label-format-40x25 .label-preview { width: 220px; aspect-ratio: 8 / 5; padding: 7px; }
.label-format-40x25 .label-preview h4 { font-size: 12px; line-height: 1.05; max-height: 25px; }
.label-format-40x25 .label-code p { font-size: 9px; }
.label-format-40x25 .label-preview svg { height: 36px; }
.print-hint {
  display: grid;
  gap: .25rem;
  padding: .75rem;
  border: 1px solid rgba(14,165,233,.28);
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: .9rem;
  font-weight: 750;
}
.print-hint strong { color: var(--ink); }

.toast-host {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: grid;
  gap: .6rem;
  z-index: 100;
}
.toast {
  background: var(--black);
  color: white;
  border-radius: var(--radius);
  border-top: 3px solid var(--primary);
  padding: .85rem 1rem;
  box-shadow: var(--shadow);
  max-width: 360px;
  font-weight: 800;
}

.empty-state {
  padding: 2rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius);
  background: #fff;
}

.login-card {
  max-width: 520px;
  margin: clamp(2rem, 7vw, 5rem) auto;
}

.login-card form {
  display: grid;
  gap: .8rem;
  margin-top: 1rem;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: .55rem;
  color: var(--ink);
}

.inline-check input { width: auto; }

.user-role-guide { margin-top: 1rem; }

.user-table td,
.user-table th {
  white-space: normal;
}

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 1fr; }
  .tabs {
    position: static;
    display: flex;
    overflow-x: auto;
    padding-bottom: .35rem;
  }
  .tab { white-space: nowrap; }
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .status-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .label-builder { grid-template-columns: 1fr; }
  .report-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .table-wrap {
    overflow: visible;
    max-width: none;
    margin: 0;
    border: 0;
    background: transparent;
  }
  .responsive-table,
  .responsive-table tbody {
    display: block;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    table-layout: auto;
  }
  .responsive-table thead {
    display: none;
  }
  .responsive-table tbody {
    display: grid;
    gap: .75rem;
  }
  .responsive-table tbody tr {
    display: block;
    width: 100%;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 6px 16px rgba(15, 23, 42, .06);
  }
  .responsive-table tbody tr.low { border-color: rgba(249, 115, 22, .42); }
  .responsive-table tbody tr.zero { border-color: rgba(185, 28, 28, .38); }
  .responsive-table tbody td,
  .products-table tbody td {
    display: grid;
    grid-template-columns: minmax(7.25rem, 38%) minmax(0, 1fr);
    gap: .7rem;
    align-items: center;
    width: auto;
    min-height: 44px;
    padding: .62rem .72rem;
    font-size: .9rem;
    background: transparent;
  }
  .products-table tbody td[data-label] { width: auto; }
  .responsive-table tbody td:last-child { border-bottom: 0; }
  .responsive-table tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: .7rem;
    font-weight: 900;
    line-height: 1.25;
    text-transform: uppercase;
    overflow-wrap: anywhere;
  }
  .responsive-table tbody td.table-wide-cell {
    display: block;
  }
  .responsive-table tbody td.table-wide-cell::before { display: none; }
  .responsive-table tbody td.actions {
    display: grid;
    align-items: start;
  }
  .responsive-table tbody td.actions .table-cell-value {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: .4rem;
  }
  .responsive-table tbody td.actions .table-cell-value .btn {
    flex: 1 1 105px;
    width: auto;
    margin: 0;
  }
  .responsive-table tbody td .table-cell-value > input,
  .responsive-table tbody td .table-cell-value > select,
  .responsive-table tbody td .table-cell-value > textarea {
    width: 100%;
  }
  .responsive-table .product-thumb {
    width: 58px;
    height: 58px;
  }
}

@media (max-width: 720px) {
  body { background: var(--bg); }
  .app-header {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    gap: .75rem;
    padding: .8rem .75rem;
    border-bottom-width: 3px;
  }
  .app-header h1 { font-size: 1.55rem; }
  .app-header .eyebrow { font-size: .68rem; }
  .brand-lockup {
    align-items: center;
    gap: .65rem;
    width: 100%;
  }
  .brand-logo {
    width: 118px;
    height: 50px;
    flex: 0 0 auto;
  }
  .header-actions {
    justify-content: flex-start;
    width: 100%;
    gap: .5rem;
  }
  .header-actions > * { flex: 1 1 150px; }
  .header-actions .btn,
  .header-actions select {
    min-height: 40px;
  }
  .session-box {
    width: 100%;
    justify-content: space-between;
  }
  .sync-badge {
    justify-content: center;
    text-align: center;
    white-space: normal;
  }
  .app-shell {
    gap: .75rem;
    padding: .65rem .6rem calc(1rem + env(safe-area-inset-bottom));
  }
  .tabs {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
    margin: -.65rem -.6rem 0;
    padding: .55rem .6rem;
    background: rgba(238, 243, 248, .9);
    box-shadow: 0 8px 18px rgba(5, 5, 5, .08);
  }
  .tab {
    min-height: 40px;
    padding: .58rem .72rem;
    font-size: .9rem;
    text-align: center;
    white-space: normal;
  }
  .view { min-width: 0; }
  .card {
    padding: .85rem;
    box-shadow: 0 8px 20px rgba(5, 5, 5, .06);
  }
  .grid { gap: .75rem; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .kpi { min-height: 96px; }
  .kpi strong { font-size: 2rem; }
  .section-title {
    display: grid;
    gap: .75rem;
  }
  .toolbar-actions {
    width: 100%;
    justify-content: stretch;
  }
  .toolbar-actions .btn {
    flex: 1 1 145px;
  }
  .form-grid { grid-template-columns: 1fr; }
  .location-generator { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .location-generator .btn { grid-column: 1 / -1; }
  .product-photo-field { grid-template-columns: 1fr; }
  .product-photo-preview { width: 100%; max-width: 220px; }
  .product-photo-actions .btn { flex: 1 1 150px; }
  .input-with-button {
    grid-template-columns: 1fr;
  }
  .status-row { grid-template-columns: 1fr 1fr; }
  .list-item {
    display: grid;
    gap: .7rem;
  }
  .list-item > div:last-child {
    width: 100%;
    justify-content: flex-start;
  }
  .list-item .btn {
    flex: 1 1 92px;
  }
  .product-thumb {
    width: 48px;
    height: 48px;
  }
  .modal {
    width: calc(100vw - .75rem);
    max-height: calc(100dvh - .75rem);
  }
  .modal-card {
    max-height: calc(100dvh - .75rem);
    overflow: auto;
    overscroll-behavior: contain;
    padding: .9rem;
  }
  .modal-head {
    align-items: flex-start;
    gap: .7rem;
  }
  .modal-actions {
    align-items: stretch;
  }
  .modal-actions .spacer { display: none; }
  .modal-actions .btn { flex: 1 1 120px; }
  #scannerVideo {
    max-height: 42dvh;
    min-height: 220px;
  }
  .scanner-fallback { grid-template-columns: 1fr; }
  .scanner-fallback .btn { width: 100%; }
  .toolbar { align-items: stretch; }
  .toolbar-left, .toolbar-right { width: 100%; }
  .toolbar input, .toolbar select, .toolbar button, .toolbar .btn { flex: 1 1 150px; }
  .report-controls { grid-template-columns: 1fr; }
  .print-report-header { display: grid; }
  .print-report-logo { width: 132px; }
  .report-meta { grid-template-columns: 1fr; }
  .report-box { padding: .8rem; }
  .report-total { text-align: left; font-size: 1.1rem; }
  .report-accordion > summary { padding: .85rem; }
  .report-accordion-body { padding: .65rem; }
  .report-accordion-actions {
    justify-content: stretch;
  }
  .report-accordion-actions .btn {
    flex: 1 1 130px;
  }
  .label-sheet {
    min-height: 220px;
    padding: .75rem;
  }
  .labels-grid {
    grid-template-columns: 1fr;
  }
  .label-preview {
    min-height: 112px;
  }
  .toast-host {
    left: .6rem;
    right: .6rem;
    bottom: calc(.6rem + env(safe-area-inset-bottom));
  }
  .toast {
    max-width: none;
    width: 100%;
  }
  .empty-state { padding: 1.1rem; }
}

@media (max-width: 430px) {
  .app-header h1 { font-size: 1.38rem; }
  .brand-logo {
    width: 104px;
    height: 44px;
  }
  .header-actions > * { flex-basis: 100%; }
  .tabs {
    gap: .35rem;
    padding-block: .45rem;
  }
  .tab {
    min-height: 38px;
    padding: .5rem .62rem;
    font-size: .86rem;
  }
  .card { padding: .75rem; }
  .status-row { grid-template-columns: 1fr; }
  .toolbar-actions .btn,
  .product-photo-actions .btn,
  .modal-actions .btn {
    flex-basis: 100%;
  }
  .location-generator {
    grid-template-columns: 1fr;
  }
  .location-generator .btn { grid-column: auto; }
  #scannerVideo { min-height: 190px; }
  table { min-width: 680px; }
}

@media print {
  body * { visibility: hidden !important; }
  #printArea, #printArea * { visibility: visible !important; }
  #printArea {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    border: 0;
    box-shadow: none;
    padding: 0;
  }
  .label-sheet { border: 0; padding: 0; }
  body.printing-labels #printArea { width: var(--label-print-width); }
  body.printing-labels .labels-grid { display: block; }
  body.printing-labels .label-preview {
    box-sizing: border-box;
    width: var(--label-print-width);
    height: var(--label-print-height);
    min-height: 0;
    aspect-ratio: auto;
    border: 0;
    margin: 0;
    page-break-after: always;
    break-after: page;
  }
  body.printing-labels .label-preview:last-child { page-break-after: auto; break-after: auto; }
  body.printing-labels .label-format-50x30 .label-preview { padding: 2mm; }
  body.printing-labels .label-format-80x50 .label-preview { padding: 3mm; }
  body.printing-labels .label-format-40x25 .label-preview { padding: 1.5mm; }
  body.printing-labels .label-preview h4 { color: #000; }
  body.printing-labels .label-preview svg { fill: #000; }
  .no-print { display: none !important; }
  .print-report {
    color: #111;
    font-size: 10pt;
  }
  .print-report .table-wrap {
    border-radius: 0;
    overflow: visible;
  }
  .print-report table {
    min-width: 0;
    font-size: 9pt;
  }
  .print-report th,
  .print-report td {
    padding: 5pt 6pt;
  }
  .print-report-header {
    page-break-after: avoid;
  }
  .report-meta {
    grid-template-columns: repeat(4, 1fr);
  }
}
