:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --ink: #1d252d;
  --muted: #69727d;
  --line: #d8dee6;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --amber: #a16207;
  --blue: #2563eb;
  --green: #15803d;
  --red: #b91c1c;
}

.shortage-comparison-panel { max-height: min(86vh, 820px); overflow: auto; }
.shortage-comparison-summary strong { border-radius: 10px; background: #f1f5f9; padding: 10px 12px; }
.comparison-shortage-row { background: #fff1f2; }
.comparison-shortage-row strong { color: #b42318; }

* {
  box-sizing: border-box;
}

html,
body {
  /* Headquarters is an app-like workspace: keep scrolling, but never zoom the UI. */
  touch-action: pan-x pan-y;
}

button,
a,
input,
select,
textarea,
summary,
label,
[role="button"] {
  touch-action: manipulation;
}

body {
  background: var(--bg);
  color: var(--ink);
  display: grid;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  grid-template-columns: 248px minmax(0, 1fr);
  margin: 0;
  min-height: 100vh;
}

.admin-login-shell {
  align-items: center;
  background: linear-gradient(180deg, #f8fafc 0%, #e8eef5 100%);
  display: flex;
  grid-column: 1 / -1;
  justify-content: center;
  min-height: 100vh;
  padding: max(18px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.admin-login-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.14);
  display: grid;
  gap: 16px;
  max-width: 100%;
  padding: 24px;
  width: 420px;
}

.eyebrow {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

button,
input,
select {
  font: inherit;
}

.sidebar {
  background: #151b23;
  color: #f8fafc;
  padding: 20px 16px;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
}

.sidebar-close-button {
  display: none;
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
  margin-bottom: 28px;
}

.brand > div {
  min-width: 0;
}

.brand strong {
  display: block;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.brand-mark {
  align-items: center;
  background: var(--accent);
  border-radius: 6px;
  display: inline-flex;
  font-weight: 700;
  height: 36px;
  justify-content: center;
  width: 36px;
}

.brand small {
  color: #aeb8c4;
  display: block;
  margin-top: 2px;
}

nav {
  display: grid;
  gap: 6px;
}

.nav-button {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: #d7dde5;
  cursor: pointer;
  padding: 10px 12px;
  text-align: left;
}

.nav-icon,
.nav-copy small {
  display: none;
}

.nav-copy strong {
  font-weight: 400;
}

.nav-button.active,
.nav-button:hover {
  background: #26313d;
  color: #ffffff;
}

.mobile-sidebar-session {
  display: none;
}

.dashboard-shortcuts,
.dashboard-metrics-title {
  display: none;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.topbar-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 17px;
}

.topbar p {
  color: var(--muted);
  margin-top: 6px;
}

.icon-button,
button {
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--accent-ink);
  cursor: pointer;
  min-height: 36px;
  padding: 8px 12px;
}

.icon-button {
  font-size: 20px;
  line-height: 1;
  width: 40px;
}

button.secondary {
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
}

button.primary-action {
  background: var(--blue);
  border-color: var(--blue);
}

button.danger {
  background: var(--red);
  border-color: var(--red);
  color: #ffffff;
}

button.danger.secondary {
  background: #ffffff;
  border-color: #fecaca;
  color: var(--red);
}

.link-button {
  background: transparent;
  border: 0;
  color: var(--blue);
  min-height: auto;
  padding: 0;
  text-align: left;
  text-decoration: underline;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.notice {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 6px;
  color: #065f46;
  margin-bottom: 16px;
  padding: 10px 12px;
}

.notice.error {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--red);
}

#notice {
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.2);
  left: 50%;
  margin: 0;
  max-width: min(720px, calc(100vw - 32px));
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  transform: translateX(-50%);
  width: max-content;
  z-index: 1100;
}

#purchase-adjustment-save-status {
  margin: 0;
}

.purchase-shortage-panel {
  max-height: calc(100dvh - 56px);
  overflow-y: auto;
}

#purchase-shortage-form {
  padding: 0 20px 20px;
}

.shortage-impact-note {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  color: #9a3412;
  line-height: 1.5;
  padding: 11px 12px;
}

.shortage-status-summary {
  color: #b45309;
  font-size: 12px;
  font-weight: 700;
  margin-top: 5px;
}

.hidden {
  display: none !important;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.settings-grid {
  align-items: start;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr);
}

.settings-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 18px;
  min-width: 0;
  padding: 22px;
}

.settings-card label {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

.settings-card input {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 42px;
  padding: 9px 11px;
  width: 100%;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
}

.settings-preview {
  align-content: center;
  min-height: 190px;
}

.settings-preview strong {
  font-size: 22px;
  overflow-wrap: anywhere;
}

.settings-admin-card {
  grid-column: 1 / -1;
}

@media (min-width: 1181px) {
  #settings-view {
    min-width: 0;
  }

  #settings-view .settings-grid {
    grid-template-areas:
      "system appearance"
      "admins admins";
    grid-template-columns: minmax(0, 1.75fr) minmax(320px, 0.8fr);
  }

  #company-settings-form {
    grid-area: system;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #company-settings-form > div:first-child,
  #company-settings-form > fieldset,
  #company-settings-form > details,
  #company-settings-form > p,
  #company-settings-form > .settings-actions {
    grid-column: 1 / -1;
  }

  #personal-language-form {
    align-self: start;
    grid-area: auto;
  }

  #settings-view .settings-preview {
    align-content: start;
    grid-area: auto;
    min-height: 0;
  }

  #settings-view .settings-admin-card {
    grid-area: admins;
  }
}

.admin-users-table {
  min-width: 980px;
}

.admin-permissions-cell {
  max-width: 360px;
  line-height: 1.6;
}

.permission-fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0;
  padding: 14px;
}

.permission-fieldset legend {
  font-size: 13px;
  font-weight: 700;
  padding: 0 6px;
}

.permissions-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 8px;
}

.permission-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.permission-tools button {
  min-height: 32px;
  padding: 6px 10px;
}

.permission-option {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  gap: 9px;
  min-height: 42px;
  padding: 8px 10px;
}

.permission-option input {
  min-height: auto;
  width: auto;
}

#admin-user-form .permission-option input[type="checkbox"] {
  flex: 0 0 18px;
  height: 18px !important;
  margin: 0;
  min-height: 18px !important;
  padding: 0;
  width: 18px !important;
}

#admin-user-form .permission-option span {
  line-height: 1.35;
  min-width: 0;
  overflow-wrap: anywhere;
}

.permission-fieldset.is-super-admin {
  background: #f8fafc;
}

#admin-user-form .password-input-row {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.metrics {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.metric strong {
  display: block;
  font-size: 28px;
  margin-top: 8px;
}

.metric span {
  color: var(--muted);
}

.toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.toolbar.compact {
  margin: 14px 0;
}

input,
select,
textarea {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 36px;
  padding: 7px 10px;
}

textarea {
  resize: vertical;
}

label {
  color: #344050;
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}

.table-wrap,
.detail-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}

table {
  border-collapse: collapse;
  min-width: 760px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f2f5f8;
  color: #4b5563;
  font-size: 13px;
  font-weight: 700;
}

tr:last-child td {
  border-bottom: 0;
}

.status {
  border-radius: 999px;
  display: inline-block;
  font-size: 12px;
  padding: 4px 8px;
}

.status.submitted,
.status.draft {
  background: #fff7ed;
  color: var(--amber);
}

.status.batched,
.status.generated,
.status.purchasing {
  background: #eff6ff;
  color: var(--blue);
}

.status.confirmed,
.status.issued,
.status.ordered,
.status.completed,
.status.active {
  background: #ecfdf5;
  color: var(--green);
}

.status.inactive,
.status.discontinued,
.status.void,
.status.cancelled,
.status.rejected {
  background: #f3f4f6;
  color: #4b5563;
}

.status.orderable {
  background: #ecfdf5;
  color: var(--green);
}

.status.voting {
  background: #fff7ed;
  color: var(--amber);
}

.launch-status-line {
  margin-top: 6px;
}

.launch-vote-progress {
  line-height: 1.45;
  max-width: 190px;
}

.split {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(440px, 0.9fr) minmax(360px, 1.1fr);
}

.detail-panel {
  padding: 16px;
}

.detail-empty {
  color: var(--muted);
  padding: 24px 0;
}

.batch-supplier-summary {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  color: #166534;
  line-height: 1.5;
  margin: 12px 0 4px;
  padding: 10px 12px;
}

.summary-item {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}

.summary-head {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.allocation-list {
  color: #3f4b57;
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.allocation-row {
  display: flex;
  justify-content: space-between;
}

.segments {
  background: #e9edf2;
  border-radius: 7px;
  display: flex;
  padding: 3px;
}

.segment {
  background: transparent;
  border: 0;
  color: #344050;
  min-height: 32px;
}

.segment.active {
  background: #ffffff;
  color: var(--ink);
}

.products-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.product-card {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: 72px 1fr;
  min-height: 108px;
  padding: 12px;
}

.product-card img {
  background: #eef2f6;
  border-radius: 6px;
  height: 72px;
  object-fit: cover;
  width: 72px;
}

.product-meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.badge {
  border-radius: 999px;
  display: inline-block;
  font-size: 12px;
  margin-top: 8px;
  padding: 4px 8px;
}

.badge.supplier_direct {
  background: #ecfeff;
  color: #155e75;
}

.badge.own_warehouse {
  background: #fef3c7;
  color: #92400e;
}

.products-toolbar {
  align-items: stretch;
}

.products-toolbar input {
  min-width: min(420px, 100%);
}

.hq-product-search-control {
  display: grid;
  flex: 1 1 100%;
  gap: 8px;
  max-width: 100%;
  width: 100%;
}

.hq-product-search-row { display: grid !important; gap: 8px; grid-template-columns: minmax(0, 1fr) auto; width: 100%; }
.hq-product-search-row input { min-width: 0; width: 100%; }
.hq-screen-keyboard-toggle { min-width: 86px; padding-left: 8px; padding-right: 8px; white-space: nowrap; }
.hq-screen-keyboard {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .12);
  display: grid;
  gap: 10px;
  padding: 12px;
  width: 100%;
}
.hq-screen-keyboard p { color: var(--muted); font-size: 13px; margin: 0; }
.hq-screen-keyboard-keys { display: grid; gap: 6px; grid-template-columns: repeat(10, minmax(36px, 1fr)); }
.hq-screen-keyboard-keys button { min-height: 44px; padding: 6px 2px; }
.hq-screen-keyboard-actions { display: grid; gap: 8px; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.hq-screen-keyboard-actions button { min-height: 44px; padding-left: 6px; padding-right: 6px; }

#missing-upc-filter.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #ffffff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .16);
}

@media (max-width: 560px) {
  .hq-product-search-row { grid-template-columns: minmax(0, 1fr) 82px; }
  .hq-screen-keyboard-toggle { font-size: 13px; min-width: 0; width: 82px; }
  .hq-screen-keyboard-keys { gap: 4px; grid-template-columns: repeat(8, minmax(28px, 1fr)); }
  .hq-screen-keyboard-keys button { font-size: 13px; min-height: 40px; }
  .hq-screen-keyboard-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.product-supplier-stack {
  display: grid;
  gap: 4px;
}

.product-supplier-stack span {
  overflow-wrap: anywhere;
}

.product-mobile-suppliers {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  margin-top: 10px;
  padding: 9px;
}

.product-mobile-suppliers > strong {
  color: #334155;
  display: block;
  font-size: 12px;
  margin-bottom: 5px;
}

.product-mobile-suppliers > div {
  align-items: flex-start;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 5px;
  justify-content: space-between;
  padding: 6px 0;
}

.product-mobile-suppliers > div:first-of-type {
  border-top: 0;
}

.product-mobile-suppliers span {
  color: #0f172a;
  font-size: 12px;
  font-weight: 700;
}

.product-mobile-suppliers small {
  color: #64748b;
  font-size: 10px;
  text-align: right;
}

.supplier-offer-manager-list {
  display: grid;
  gap: 12px;
  margin: 16px 0;
}

.supplier-offer-manager-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, .55fr) minmax(150px, .45fr);
  gap: 12px;
  align-items: end;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
}

.supplier-offer-manager-row > div,
.supplier-offer-manager-row label {
  display: grid;
  gap: 6px;
}

.supplier-offer-manager-row small { color: var(--muted); }

@media (max-width: 700px) {
  .supplier-offer-manager-row { grid-template-columns: 1fr; }
}

.batch-classification-panel { max-width: 1040px; }
.batch-classification-list { display: grid; gap: 14px; margin: 14px 0; }
.batch-classification-card {
  align-items: start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  display: grid;
  gap: 16px;
  grid-template-columns: 112px minmax(0, 1fr);
  padding: 16px;
}
.batch-classification-card > img {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  height: 112px;
  object-fit: contain;
  width: 112px;
}
.batch-classification-main,
.batch-classification-name { display: grid; gap: 6px; min-width: 0; }
.batch-classification-name strong { font-size: 18px; line-height: 1.3; }
.batch-classification-name span,
.batch-classification-name small { color: var(--muted); }
.batch-classification-selects { display: grid; gap: 8px; margin-top: 10px; }
.batch-classification-selects label { display: grid; gap: 5px; }
.batch-classification-selects select { width: 100%; }
.batch-classification-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  grid-column: 1 / -1;
}
.batch-classification-feedback { color: var(--muted); font-weight: 700; }

@media (max-width: 700px) {
  #batch-classification-modal .modal-panel {
    height: auto;
    max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    width: 100%;
  }
  #batch-classification-modal .modal-header,
  #batch-classification-modal .modal-actions { flex: 0 0 auto; }
  #batch-classification-modal .batch-classification-list {
    min-height: 0;
    overflow-y: auto;
  }
  .batch-classification-card { gap: 12px; grid-template-columns: 88px minmax(0, 1fr); padding: 12px; }
  .batch-classification-card > img { height: 88px; width: 88px; }
  .batch-classification-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .batch-classification-actions button { min-width: 0; width: 100%; }
  .batch-classification-feedback { grid-column: 1 / -1; }
}

.product-inactive-controls {
  align-items: stretch;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.product-column-picker {
  position: relative;
}

.product-column-picker > summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  height: 100%;
  list-style: none;
  white-space: nowrap;
}

.product-column-picker > summary::-webkit-details-marker {
  display: none;
}

.product-column-picker-menu {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 16px 34px rgb(15 23 42 / 18%);
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  max-height: min(520px, 70vh);
  min-width: 360px;
  overflow-y: auto;
  padding: 14px;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 30;
}

.product-column-picker-menu label {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 8px;
  min-height: 34px;
}

.product-column-picker-menu input {
  min-width: auto;
}

.product-column-picker-actions {
  border-top: 1px solid var(--line);
  display: flex;
  grid-column: 1 / -1;
  justify-content: flex-end;
  padding-top: 10px;
}

@media (max-width: 720px) {
  .product-column-picker {
    width: 100%;
  }

  .product-column-picker > summary {
    min-height: 44px;
    width: 100%;
  }

  .product-column-picker-menu {
    grid-template-columns: 1fr;
    left: 0;
    min-width: 0;
    right: auto;
    width: min(100%, 360px);
  }
}

.product-pagination {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: space-between;
  margin-top: 12px;
  padding: 12px 14px;
}

.product-pagination-summary {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.product-pagination-controls,
.product-pagination-controls label {
  align-items: center;
  display: flex;
  gap: 8px;
}

.product-pagination-controls {
  flex-wrap: wrap;
}

.product-pagination-controls select {
  min-width: 72px;
}

.product-page-jump input {
  min-width: 68px;
  width: 68px;
}

.product-pagination button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.batch-list-column {
  min-width: 0;
}

.list-pagination {
  margin-bottom: 12px;
}

.product-supplier-filter {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 9px;
  display: flex;
  gap: 9px;
  padding: 5px 7px 5px 12px;
}

.product-supplier-filter span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.product-supplier-filter select {
  border: 0;
  min-width: 190px;
}

.product-origin-filter-row {
  display: grid;
  flex: 1 1 100%;
  gap: 8px;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-width: 0;
  width: 100%;
}

.product-origin-filter-row .product-supplier-filter,
.product-origin-filter-row select {
  min-width: 0;
  width: 100%;
}

.product-category-filter-panel {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 9px;
  display: grid;
  flex: 1 1 100%;
  gap: 7px;
  grid-column: 1 / -1;
  min-width: 0;
  padding: 8px 10px 10px;
  width: 100%;
}

.product-category-filter-title,
.product-category-field-title {
  color: #344050;
  font-size: 13px;
  font-weight: 800;
}

.product-category-filter-cascade {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.product-category-filter-cascade label,
.product-category-cascade label {
  min-width: 0;
}

.product-category-filter-cascade select {
  min-width: 0;
  width: 100%;
}

.inventory-summary-panel {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 14px;
  padding: 14px;
}

.inventory-summary-heading {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 12px;
}

.inventory-summary-heading h2 {
  font-size: 17px;
  margin: 0;
}

.inventory-summary-heading p {
  color: var(--muted);
  font-size: 12px;
  margin: 0;
}

.inventory-metrics {
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
}

.inventory-metric {
  min-width: 0;
  padding: 12px;
}

.inventory-metric strong {
  font-size: 21px;
  overflow-wrap: anywhere;
}

.inventory-metric small,
.product-calculation {
  color: var(--muted);
  display: block;
  font-size: 11px;
  line-height: 1.4;
  margin-top: 5px;
}

.positive-value {
  color: var(--green) !important;
}

.negative-value {
  color: var(--red) !important;
}

.pending-value {
  color: var(--amber);
}

.toolbar-spacer {
  flex: 1 1 auto;
}

.products-table {
  min-width: 1380px;
}

.products-table .product-name-cell {
  min-width: 280px;
  width: 28%;
}

.products-table [data-product-column="image"] {
  min-width: 112px;
  width: 112px;
}

.products-table .product-management-image {
  border-radius: 10px;
  height: 96px;
  object-fit: contain;
  width: 96px;
}

.product-mobile-summary {
  display: none;
}

.product-name-primary,
.product-name-secondary {
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.product-name-primary {
  color: var(--ink);
  font-weight: 600;
}

.product-name-secondary {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.supplier-purchase-table {
  min-width: 1180px;
}

.supplier-table {
  min-width: 920px;
}

.table-image {
  background: #eef2f6;
  border-radius: 6px;
  height: 52px;
  object-fit: cover;
  width: 52px;
}

body.image-preview-open {
  overflow: hidden;
}

.image-preview-trigger {
  cursor: zoom-in;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.image-preview-trigger:hover,
.image-preview-trigger:focus-visible {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.28);
  outline: none;
  transform: scale(1.04);
}

.image-preview-modal {
  align-items: center;
  background: rgba(15, 23, 42, 0.88);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  position: fixed;
  z-index: 1000;
}

.image-preview-content {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 100%;
  max-width: 100%;
}

.image-preview-large {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
  max-height: calc(100dvh - 110px);
  max-width: min(92vw, 1200px);
  object-fit: contain;
  touch-action: pinch-zoom;
}

.image-preview-caption {
  color: #ffffff;
  font-size: 14px;
  margin: 0;
  max-width: min(92vw, 900px);
  text-align: center;
}

.image-preview-close {
  align-items: center;
  background: rgba(255, 255, 255, 0.96);
  border: 0;
  border-radius: 999px;
  color: #111827;
  display: inline-flex;
  font-size: 30px;
  height: 48px;
  justify-content: center;
  line-height: 1;
  min-height: 48px;
  padding: 0;
  position: absolute;
  right: max(18px, env(safe-area-inset-right));
  top: max(18px, env(safe-area-inset-top));
  width: 48px;
}

.product-image-controls {
  align-items: stretch;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.field-help {
  color: var(--muted);
  display: block;
  font-size: 12px;
  line-height: 1.5;
  margin-top: 6px;
}

.invoice-option {
  align-items: flex-start;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: row;
  gap: 12px;
  padding: 14px;
}

.invoice-option input {
  flex: 0 0 auto;
  height: 20px;
  margin-top: 2px;
  width: 20px;
}

#supplier-purchase-form .invoice-option input {
  flex: 0 0 20px;
  width: 20px;
}

#supplier-purchase-form .invoice-option > span {
  flex: 1 1 auto;
  min-width: 0;
}

.invoice-option span,
.invoice-option small {
  display: block;
}

.invoice-option small {
  color: var(--muted);
  margin-top: 4px;
}

.invoice-price-input {
  min-width: 110px;
  width: 100%;
}

.audit-log-data {
  background: #0f172a;
  border-radius: 10px;
  color: #e2e8f0;
  font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  margin: 0;
  max-height: 420px;
  overflow: auto;
  padding: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

.product-image-preview {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 12px;
  margin-top: 10px;
  padding: 10px;
}

.product-image-preview img {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  height: 112px;
  object-fit: contain;
  width: 112px;
}

.product-image-preview span {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.product-image-controls button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.action-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 190px;
}

.store-order-note-cell {
  max-width: 260px;
  min-width: 180px;
}

.store-order-note-cell > span {
  display: -webkit-box;
  line-height: 1.45;
  overflow: hidden;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.store-order-note-detail {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 12px;
}

.store-order-note-detail > span {
  color: #92400e;
}

.store-order-note-detail > strong {
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.modal {
  align-items: flex-start;
  background: rgba(15, 23, 42, 0.48);
  display: flex;
  inset: 0;
  justify-content: center;
  overflow: auto;
  padding: 28px 16px;
  position: fixed;
  z-index: 10;
}

.modal.hidden {
  display: none;
}

.modal-panel {
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.24);
  max-width: 100%;
  width: 720px;
}

.modal-panel.wide {
  width: 1040px;
}

#supplier-purchase-modal .modal-panel {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 32px);
  overflow: hidden;
  width: min(920px, calc(100vw - 32px));
}

#supplier-purchase-modal #supplier-purchase-form {
  align-content: start;
  overflow-y: auto;
}

.supplier-purchase-header-actions {
  align-items: center;
  display: flex;
  flex-shrink: 0;
  gap: 10px;
}

.supplier-purchase-top-save {
  min-height: 36px;
  padding: 7px 18px;
}

.modal-panel.product-import-panel {
  max-height: calc(100dvh - 56px);
  overflow-y: auto;
  width: min(1180px, calc(100vw - 32px));
}

.product-import-upload {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(260px, 1fr) auto;
  padding: 18px 18px 4px;
}

.product-import-upload label { display: grid; gap: 7px; }
.product-import-table-wrap { margin: 0 18px; max-height: 48vh; }
.product-import-table { min-width: 960px; }
.product-import-row-error { background: #fff1f2; }
.product-import-row-update { background: #fffbeb; }
.product-import-panel > .form-error,
.product-import-panel > section { margin-left: 18px; margin-right: 18px; }

.import-stat-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(6, minmax(110px, 1fr));
  margin-bottom: 12px;
  margin-top: 12px;
}

.import-stat { background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.import-stat span, .import-stat strong { display: block; }
.import-stat span { color: var(--muted); font-size: 12px; }
.import-stat strong { font-size: 20px; margin-top: 4px; }
.import-errors { color: var(--red); font-size: 12px; white-space: normal; }
.import-warnings { color: #92400e; font-size: 12px; white-space: normal; }

.modal-panel.small {
  width: 420px;
}

.purchase-adjustment-panel {
  max-height: calc(100dvh - 56px);
  overflow-y: auto;
}

.purchase-adjustment-search-field {
  display: grid;
  gap: 6px;
  margin: 18px 0 4px;
}

.purchase-adjustment-search-field span {
  color: var(--ink);
  font-weight: 700;
}

.purchase-adjustment-search-field input {
  width: 100%;
}

#purchase-adjustment-form,
.purchase-adjustment-items {
  display: grid;
  gap: 16px;
}

#purchase-adjustment-form {
  padding: 0 20px 20px;
}

.purchase-add-product {
  align-items: end;
  background: #f7f9fb;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: grid;
  gap: 10px 12px;
  grid-template-columns: minmax(260px, 1fr) auto;
  padding: 14px 16px;
}

.purchase-add-product .field-help {
  grid-column: 1 / -1;
  margin: 0;
}

.purchase-adjustment-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.purchase-adjustment-card.is-new {
  border-color: #8fb4ee;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.08);
}

.purchase-adjustment-product-name {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 5px 9px;
}

.purchase-adjustment-product-summary {
  align-items: center;
  display: flex;
  gap: 14px;
  min-width: 0;
}

.purchase-adjustment-product-details {
  min-width: 0;
}

.purchase-adjustment-product-image,
.purchase-adjustment-product-image-placeholder {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  flex: 0 0 88px;
  height: 88px;
  object-fit: contain;
  width: 88px;
}

.purchase-adjustment-product-image {
  cursor: zoom-in;
}

.purchase-adjustment-product-image-placeholder {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  justify-content: center;
}

.purchase-adjustment-product-spec strong {
  color: var(--text);
}

.purchase-adjustment-special {
  align-items: center;
  background: #fff7e6;
  border: 1px solid #f2c66d;
  border-radius: 7px;
  color: #7c4a03;
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  gap: 5px 10px;
  margin-top: 8px;
  padding: 7px 9px;
}

.purchase-adjustment-special > b {
  background: #d97706;
  border-radius: 999px;
  color: #fff;
  padding: 2px 7px;
}

.purchase-adjustment-special > strong {
  color: #b45309;
}

.purchase-adjustment-special-note {
  border-top: 1px dashed #e5b85d;
  flex-basis: 100%;
  padding-top: 5px;
  white-space: pre-wrap;
}

.purchase-adjustment-product-name span {
  color: var(--muted);
  flex-basis: 100%;
  font-size: 14px;
}

.purchase-adjustment-product-name em {
  background: #e8f1ff;
  border-radius: 999px;
  color: #245da8;
  font-size: 12px;
  font-style: normal;
  padding: 3px 8px;
}

.purchase-adjustment-card-head,
.purchase-reserve-row {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 14px 16px;
}

.purchase-adjustment-card-head {
  background: #f7f9fb;
}

.purchase-adjustment-card-head h3,
.purchase-adjustment-card-head p {
  margin: 0;
}

.purchase-adjustment-card-head p,
.purchase-allocation-row small {
  color: var(--muted);
  display: block;
  margin-top: 4px;
}

.purchase-allocation-head,
.purchase-allocation-row {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(180px, 1fr) 100px 130px;
  padding: 10px 16px;
}

.purchase-allocation-head {
  background: #eef2f6;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.purchase-allocation-row {
  border-top: 1px solid var(--line);
}

.purchase-allocation-row input,
.purchase-reserve-row input {
  width: 100%;
}

.purchase-reserve-row {
  border-top: 1px solid var(--line);
}

.purchase-reserve-row label {
  max-width: 220px;
}

.purchase-adjustment-total {
  display: grid;
  justify-items: end;
}

.purchase-adjustment-total span {
  color: #2f6b45;
  font-size: 13px;
}

.purchase-adjustment-total.purchase-shortfall span,
.purchase-shortfall {
  color: var(--danger);
}

.detail-drawer {
  background: rgba(15, 23, 42, 0.28);
  inset: 0;
  position: fixed;
  z-index: 9;
}

.detail-drawer.hidden {
  display: none;
}

.detail-drawer-panel {
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 48px rgba(15, 23, 42, 0.18);
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
  margin-left: auto;
  max-width: 100%;
  overflow: hidden;
  width: min(1180px, 86vw);
}

.detail-drawer-header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 16px 18px;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel);
}

.detail-drawer-header p {
  color: var(--muted);
  margin-top: 4px;
}

.detail-state {
  padding: 24px;
}

.detail-state.error {
  color: var(--red);
}

.order-detail-content {
  overflow: auto;
  padding: 18px;
}

.print-title {
  display: none;
}

.detail-summary {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.detail-summary > div,
.detail-totals {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.detail-summary span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-bottom: 4px;
}

.detail-summary strong {
  font-size: 14px;
}

.detail-table-wrap {
  max-height: none;
}

.order-items-table {
  min-width: 1380px;
}

.order-detail-footer {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin-top: 16px;
}

.order-change-history-section {
  margin-top: 18px;
}

.order-change-history-section h3 {
  margin: 0 0 10px;
}

.order-change-history {
  display: grid;
  gap: 8px;
}

.order-change-entry {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.order-change-entry div {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
}

.order-change-entry span,
.order-change-entry p {
  color: var(--muted);
  font-size: 12px;
  margin-top: 5px;
}

.detail-totals {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.return-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.modal-header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 16px 18px;
}

.close-modal {
  min-height: 32px;
  padding: 0;
  width: 32px;
}

.form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 18px;
}

.nested-grid {
  padding: 0;
}

.form-section {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
  padding-top: 14px;
}

.form-section h3 {
  font-size: 15px;
  margin: 0;
}

.form-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  color: var(--red);
  padding: 10px 12px;
}

.password-input-row {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr auto;
}

.inline-actions {
  justify-content: flex-start;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
}

.full-span {
  grid-column: 1 / -1;
}

.inline-field-row {
  align-items: stretch;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.summary-strip {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.summary-strip span,
.purchase-item-card {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.supplier-allocation-panel {
  grid-column: 1 / -1;
  display: grid;
  gap: 0.65rem;
  padding: 0.85rem;
  border: 1px solid var(--border-color, #d9e1e7);
  border-radius: 12px;
  background: #f8fbfd;
}

.supplier-allocation-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.2fr) minmax(110px, 0.6fr) minmax(180px, 1fr);
  gap: 0.7rem;
  align-items: end;
}

.supplier-allocation-row span,
.supplier-allocation-row small {
  display: block;
}

@media (max-width: 720px) {
  .supplier-allocation-row { grid-template-columns: 1fr; }
}

.purchase-items {
  display: grid;
  gap: 12px;
}

.purchase-item-card {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(220px, 1.4fr) repeat(5, minmax(110px, 1fr)) auto;
  align-items: end;
}

.purchase-item-meta {
  color: var(--muted);
  font-size: 12px;
  grid-column: 1 / -1;
}

.line-total {
  align-self: center;
  white-space: nowrap;
}

.pending-price {
  color: var(--amber);
  font-weight: 700;
}

.required {
  color: var(--red);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 4px;
}

.supplier-layout {
  display: grid;
  gap: 0;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
}

.supplier-form {
  align-content: start;
  border-right: 1px solid var(--line);
  grid-template-columns: 1fr;
}

.supplier-table-wrap {
  border: 0;
  border-radius: 0 0 8px 0;
  max-height: 620px;
}

.mobile-home-button,
.sidebar-backdrop {
  display: none;
}

/* Large desktop displays need a roomier density than laptops.  Keep this as
   real layout sizing (instead of CSS zoom) so tables, drawers and modals still
   use the full viewport without becoming blurry or overflowing horizontally. */
@media (min-width: 1441px) and (pointer: fine) {
  body {
    font-size: 17px;
    grid-template-columns: 292px minmax(0, 1fr);
  }

  .sidebar {
    padding: 28px 20px;
  }

  .brand {
    gap: 14px;
    margin-bottom: 34px;
  }

  .brand-mark {
    border-radius: 8px;
    font-size: 18px;
    height: 44px;
    width: 44px;
  }

  .brand strong {
    font-size: 18px;
  }

  .brand small {
    font-size: 14px;
    margin-top: 4px;
  }

  nav {
    gap: 8px;
  }

  .nav-button {
    border-radius: 8px;
    font-size: 17px;
    min-height: 48px;
    padding: 12px 15px;
  }

  .workspace {
    padding: 34px;
  }

  .topbar {
    margin-bottom: 24px;
  }

  h1 {
    font-size: 34px;
  }

  h2 {
    font-size: 21px;
  }

  .topbar p {
    font-size: 17px;
    margin-top: 8px;
  }

  .icon-button,
  button {
    border-radius: 8px;
    min-height: 44px;
    padding: 10px 15px;
  }

  .icon-button {
    font-size: 23px;
    width: 48px;
  }

  .metrics {
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  }

  .metric {
    border-radius: 10px;
    min-height: 122px;
    padding: 21px;
  }

  .metric span {
    font-size: 17px;
  }

  .metric strong {
    font-size: 36px;
    margin-top: 11px;
  }

  input,
  select,
  textarea {
    border-radius: 8px;
    font-size: 17px;
    min-height: 44px;
    padding: 9px 12px;
  }

  label,
  th {
    font-size: 15px;
  }

  th,
  td {
    padding: 14px 15px;
  }

  .status {
    font-size: 14px;
    padding: 5px 10px;
  }

  .table-wrap,
  .detail-panel,
  .settings-card {
    border-radius: 10px;
  }
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

@media (min-width: 901px) and (max-width: 1180px) and (orientation: landscape) {
  body {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .sidebar {
    padding: 18px 12px;
  }

  .workspace {
    padding: 18px;
  }

  .split {
    grid-template-columns: 1fr;
  }

  .detail-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .products-toolbar {
    align-items: stretch;
  }

  .products-toolbar input {
    flex: 1 1 100%;
    min-width: 0;
  }
}

@media (max-width: 1180px), (max-width: 1400px) and (pointer: coarse) {
  .dashboard-shortcuts {
    display: grid;
    gap: 14px;
    margin-bottom: 22px;
  }

  .dashboard-home-header {
    align-items: center;
    background: #ffffff;
    border: 1px solid #e7ebf0;
    border-radius: 18px;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 14px;
  }

  .dashboard-home-header .launcher-language-control {
    display: grid;
    flex: 0 0 auto;
    font-size: 12px;
    font-weight: 700;
    gap: 5px;
    margin-left: auto;
    min-width: 148px;
  }

  .dashboard-home-header .launcher-language-control select {
    background: #ffffff;
    min-height: 44px;
    padding: 8px 10px;
  }

  .dashboard-home-brand {
    align-items: center;
    display: flex;
    gap: 12px;
    min-width: 0;
  }

  .dashboard-home-brand > div {
    display: grid;
    gap: 4px;
    min-width: 0;
  }

  .dashboard-home-brand strong {
    font-size: 18px;
    line-height: 1.25;
    overflow-wrap: anywhere;
  }

  .dashboard-home-brand #dashboard-admin-user-label {
    color: var(--muted);
    font-size: 12px;
  }

  .dashboard-home-logout {
    background: #fee2e2;
    border: 0;
    color: var(--red);
    flex: 0 0 auto;
    font-weight: 700;
    min-height: 44px;
    padding: 8px 14px;
  }

  .dashboard-shortcut-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-shortcut-grid .dashboard-shortcut {
    align-content: start;
    background: #ffffff;
    border: 1px solid #e7ebf0;
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.07);
    color: var(--ink);
    display: grid;
    gap: 10px;
    min-height: 132px;
    padding: 18px;
    text-align: left;
  }

  .dashboard-shortcut-grid .dashboard-shortcut.active,
  .dashboard-shortcut-grid .dashboard-shortcut.active:hover {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
  }

  .dashboard-shortcut-grid .dashboard-shortcut:hover {
    background: #ffffff;
    color: var(--ink);
  }

  .dashboard-shortcut .nav-icon {
    align-items: center;
    background: #eef2ff;
    border-radius: 12px;
    display: inline-flex;
    font-size: 22px;
    height: 44px;
    justify-content: center;
    width: 44px;
  }

  .dashboard-shortcut.active .nav-icon {
    background: rgba(255, 255, 255, 0.2);
  }

  .dashboard-shortcut .nav-copy {
    display: grid;
    gap: 4px;
  }

  .dashboard-shortcut .nav-copy strong {
    font-size: 17px;
    font-weight: 700;
    line-height: 1.25;
  }

  .dashboard-shortcut .nav-copy small {
    color: var(--muted);
    display: block;
    font-size: 12px;
    line-height: 1.4;
  }

  .dashboard-shortcut.active .nav-copy small {
    color: #dbeafe;
  }

  .dashboard-shortcut-grid .dashboard-shortcut-logout,
  .dashboard-shortcut-grid .dashboard-shortcut-logout:hover {
    background: #fee2e2;
    border-color: #fecaca;
    color: #b91c1c;
  }

  .dashboard-shortcut-logout .nav-icon {
    background: rgba(255, 255, 255, 0.65);
  }

  .dashboard-mobile-session {
    align-items: center;
    background: #ffffff;
    border: 1px solid #e7ebf0;
    border-radius: 16px;
    display: grid;
    gap: 8px 12px;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 12px 14px;
  }

  .dashboard-mobile-session span {
    color: var(--muted);
    font-size: 13px;
    overflow-wrap: anywhere;
  }

  .dashboard-mobile-session button {
    background: #fee2e2;
    border: 0;
    color: var(--red);
    font-weight: 700;
    min-height: 42px;
    padding: 8px 14px;
  }

  .dashboard-metrics-title {
    display: block;
    margin: 0 0 12px;
  }
}

@media (max-width: 599px) {
  .dashboard-home-logout {
    display: none;
  }

  .dashboard-home-header .launcher-language-control {
    min-width: 132px;
  }
}

@media (max-width: 1180px), (max-width: 1400px) and (pointer: coarse) {
  body.home-launcher-open .topbar,
  body.home-launcher-open .mobile-home-button {
    display: none;
  }

  body.home-launcher-open .workspace {
    padding-top: calc(16px + env(safe-area-inset-top));
  }

  body.home-launcher-open .dashboard-shortcuts {
    margin-bottom: 0;
  }
}

@media (max-width: 1180px) and (orientation: portrait), (max-width: 900px) {
  body {
    display: block;
  }

  .mobile-home-button {
    background: #ffffff;
    border-color: var(--line);
    color: var(--ink);
    display: inline-flex;
    left: max(12px, env(safe-area-inset-left));
    min-height: 44px;
    padding: 8px 13px;
    position: fixed;
    top: max(10px, env(safe-area-inset-top));
    z-index: 14;
  }

  .sidebar {
    background: #f6f8fb;
    color: var(--ink);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    height: 100dvh;
    left: 0;
    max-width: min(100vw, 720px);
    overflow: hidden;
    padding: calc(18px + env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
    position: fixed;
    top: 0;
    transform: translateX(-100%);
    transition: transform 180ms ease;
    width: 100%;
    z-index: 13;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-open .mobile-home-button {
    opacity: 0;
    pointer-events: none;
  }

  .sidebar-header {
    align-items: center;
    gap: 16px;
  }

  .sidebar .brand {
    color: var(--ink);
    margin-bottom: 18px;
  }

  .sidebar .brand small {
    color: var(--muted);
  }

  .sidebar-close-button {
    align-items: center;
    align-self: flex-start;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--ink);
    display: inline-flex;
    flex: 0 0 44px;
    font-size: 26px;
    height: 44px;
    justify-content: center;
    min-height: 44px;
    padding: 0;
  }

  .sidebar-backdrop {
    background: rgba(15, 23, 42, 0.38);
    display: block;
    inset: 0;
    position: fixed;
    z-index: 12;
  }

  .sidebar-backdrop.hidden {
    display: none;
  }

  .sidebar-nav {
    align-content: start;
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow-y: auto;
    padding: 2px 2px 18px;
  }

  .sidebar-nav .nav-button {
    align-content: start;
    background: #ffffff;
    border: 1px solid #e7ebf0;
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.07);
    color: var(--ink);
    display: grid;
    gap: 10px;
    min-height: 132px;
    padding: 18px;
    text-align: left;
  }

  .sidebar-nav .nav-button.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
  }

  .sidebar-nav .nav-button:hover {
    color: var(--ink);
  }

  .sidebar-nav .nav-button.active:hover {
    color: #ffffff;
  }

  .nav-icon {
    align-items: center;
    background: #eef2ff;
    border-radius: 12px;
    display: inline-flex;
    font-size: 22px;
    height: 44px;
    justify-content: center;
    width: 44px;
  }

  .nav-button.active .nav-icon {
    background: rgba(255, 255, 255, 0.2);
  }

  .nav-copy {
    display: grid;
    gap: 4px;
  }

  .nav-copy strong {
    font-size: 17px;
    font-weight: 700;
    line-height: 1.25;
  }

  .nav-copy small {
    color: var(--muted);
    display: block;
    font-size: 12px;
    line-height: 1.4;
  }

  .nav-button.active .nav-copy small {
    color: #dbeafe;
  }

  .workspace {
    padding: calc(64px + env(safe-area-inset-top)) 16px 24px;
  }

  .topbar {
    align-items: flex-start;
    gap: 12px;
  }

  .topbar > div {
    min-width: 0;
  }

  h1 {
    font-size: 22px;
  }

  .topbar p {
    font-size: 13px;
  }

  button,
  .icon-button,
  input,
  select,
  textarea {
    font-size: 16px;
    min-height: 44px;
  }

  .toolbar,
  .products-toolbar,
  .modal-actions,
  .detail-actions,
  .order-detail-footer,
  .detail-totals {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar > *,
  .products-toolbar > *,
  .products-toolbar input,
  .products-toolbar button,
  .products-toolbar select,
  .segments {
    max-width: 100%;
    width: 100%;
  }

  .segments {
    overflow-x: auto;
  }

  .product-supplier-filter {
    align-items: stretch;
    flex-direction: column;
    padding: 10px 12px 12px;
  }

  .product-supplier-filter select {
    border: 1px solid var(--line);
    min-width: 0;
    width: 100%;
  }

  .split,
  .form-grid,
  .supplier-layout,
  .detail-summary {
    grid-template-columns: 1fr;
  }

  .supplier-form {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .modal {
    align-items: stretch;
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }

  .modal-panel,
  .modal-panel.small,
  .modal-panel.wide {
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    width: 100%;
  }

  .modal-header {
    background: #ffffff;
    position: sticky;
    top: 0;
    z-index: 2;
  }

  .form-grid,
  .return-form,
  .supplier-layout {
    overflow-y: auto;
  }

  .modal-actions {
    background: #ffffff;
    bottom: 0;
    position: sticky;
    z-index: 2;
  }

  .password-input-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  #admin-user-form .password-input-row {
    grid-template-columns: 1fr;
  }

  .permissions-grid {
    grid-template-columns: 1fr;
  }

  .inline-field-row {
    grid-template-columns: 1fr;
  }
  .product-image-controls {
    grid-template-columns: 1fr;
  }

  .product-image-controls button {
    width: 100%;
  }

  .product-image-preview {
    align-items: flex-start;
    flex-direction: column;
  }

  .summary-strip,
  .purchase-item-card {
    grid-template-columns: 1fr;
  }

  .detail-drawer-panel {
    height: 100dvh;
    width: 100vw;
  }
}

@media (max-width: 1180px) {
  .product-category-filter-cascade .category-filter-pending { display: none; }

  .product-type-buttons [data-filter="supplier_direct"] {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .product-filter-buttons {
    background: transparent;
    border-radius: 0;
    display: grid;
    gap: 8px;
    overflow: visible;
    padding: 0;
  }

  .product-type-buttons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .product-type-buttons .segment:first-child {
    grid-column: 1 / -1;
  }

  .product-launch-buttons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .product-filter-buttons .segment {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(15, 23, 42, 0.07);
    color: var(--ink);
    font-weight: 700;
    min-height: 52px;
    min-width: 0;
    padding: 7px 8px;
    width: 100%;
  }

  .product-filter-buttons .segment.active {
    background: var(--blue);
    border-color: var(--blue);
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2);
  }
}

@media (max-width: 767px) {
  .product-filter-buttons .segment {
    min-height: 52px;
  }

  .product-import-upload,
  .import-stat-grid { grid-template-columns: 1fr 1fr; }
  .product-import-upload > * { grid-column: 1 / -1; }
}

@media (max-width: 1180px) {
  #dashboard-view #metrics {
    gap: 10px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #dashboard-view #metrics .metric {
    border-radius: 14px;
    box-shadow: 0 3px 8px rgba(15, 23, 42, 0.06);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 112px;
    padding: 14px;
  }

  #dashboard-view #metrics .metric span {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
  }

  #dashboard-view #metrics .metric strong {
    color: var(--ink);
    font-size: 30px;
    line-height: 1;
    margin-top: 12px;
  }
}

@media (max-width: 767px) {
  #dashboard-view #metrics {
    gap: 9px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #dashboard-view #metrics .metric {
    min-height: 104px;
    padding: 12px;
  }

  #dashboard-view #metrics .metric span {
    font-size: 13px;
  }

  #dashboard-view #metrics .metric strong {
    font-size: 28px;
  }
}

@media (max-width: 1180px) and (orientation: portrait), (max-width: 900px) {
  .topbar {
    align-items: center;
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(0, 1fr) auto;
    margin-bottom: 12px;
    min-height: 48px;
    padding-left: 58px;
  }

  .topbar h1 {
    font-size: 22px;
    line-height: 1.2;
  }

  .topbar p,
  #admin-user-label,
  #admin-logout-button {
    display: none;
  }

  .topbar-actions {
    flex-wrap: nowrap;
    gap: 0;
  }

  .topbar-actions #refresh-button {
    min-height: 44px;
    width: 44px;
  }

  .mobile-sidebar-session {
    align-items: center;
    background: #ffffff;
    border: 1px solid #e7ebf0;
    border-radius: 16px;
    display: grid;
    gap: 8px 12px;
    grid-template-columns: minmax(0, 1fr) auto;
    margin-top: 0;
    padding: 12px 14px;
  }

  .mobile-sidebar-session span {
    color: var(--muted);
    font-size: 13px;
    overflow-wrap: anywhere;
  }

  .mobile-sidebar-session button {
    background: #fee2e2;
    border: 0;
    color: var(--red);
    font-weight: 700;
    min-height: 42px;
    padding: 8px 14px;
    width: auto;
  }

  .mobile-filter-toolbar {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mobile-filter-toolbar > * {
    min-width: 0;
    width: 100%;
  }

  .mobile-filter-toolbar > input:first-child,
  .supplier-purchase-toolbar #supplier-purchase-delivery-filter,
  .supplier-purchase-toolbar #add-supplier-purchase-batch-button,
  .store-orders-toolbar #order-status {
    grid-column: 1 / -1;
  }

  #purchase-batch-detail-view .detail-panel:has(#batch-detail.detail-empty) {
    display: none;
  }
}

@media (min-width: 600px) and (max-width: 1180px) and (orientation: portrait),
  (min-width: 600px) and (max-width: 900px) {
  .sidebar-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sidebar-nav .nav-button {
    min-height: 142px;
  }
}

@media (max-width: 767px), (min-width: 768px) and (max-width: 1180px) and (orientation: portrait) {
  .product-pagination,
  .product-pagination-controls {
    align-items: stretch;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .product-pagination-summary,
  .product-pagination-controls label:first-child {
    grid-column: 1 / -1;
  }

  .product-page-jump {
    justify-content: center;
  }

  .compact-mobile-table tbody {
    display: grid;
    gap: 10px;
  }

  .compact-mobile-table tr {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 3px 12px rgba(15, 23, 42, 0.06);
    display: grid;
    gap: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0;
    padding: 10px;
    position: relative;
  }

  .compact-mobile-table td {
    display: block;
    min-width: 0;
    padding: 7px 8px;
    width: auto;
  }

  .compact-mobile-table td::before {
    color: #64748b;
    letter-spacing: 0.02em;
  }

  .compact-mobile-table td:nth-child(1),
  .store-orders-table td:nth-child(2) {
    font-size: 16px;
    font-weight: 800;
  }

  .compact-mobile-table td::before {
    display: block;
    font-size: 11px;
    margin-bottom: 4px;
  }

  .compact-mobile-table .status {
    justify-self: start;
    width: auto;
  }

  .compact-mobile-table .action-cell {
    background: #f8fafc;
    border-radius: 9px;
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding-top: 10px;
  }

  .compact-mobile-table .action-cell::before {
    display: none;
  }

  .compact-mobile-table .action-cell button {
    font-size: 14px;
    min-width: 0;
    width: 100%;
  }

  .compact-mobile-table .action-cell button:disabled {
    display: none;
  }

  .compact-mobile-table .empty-state-row {
    display: block;
    grid-column: 1 / -1;
    padding: 0;
  }

  .compact-mobile-table .empty-state-row td {
    color: var(--muted);
    padding: 24px 16px;
    text-align: center;
  }

  .compact-mobile-table .empty-state-row td::before {
    display: none;
  }

  .mobile-empty-state {
    align-items: center;
    display: grid;
    gap: 8px;
    justify-items: center;
  }

  .mobile-empty-state span {
    color: var(--muted);
    font-size: 13px;
  }

  .mobile-empty-state button {
    margin-top: 4px;
  }

  .stores-table tr {
    grid-template-areas:
      "code status"
      "name name"
      "address address"
      "contact phone"
      "actions actions";
  }

  .stores-table td:nth-child(1) { grid-area: code; }
  .stores-table td:nth-child(2) { grid-area: name; }
  .stores-table td:nth-child(3) { grid-area: address; }
  .stores-table td:nth-child(4) { grid-area: contact; }
  .stores-table td:nth-child(5) { grid-area: phone; }
  .stores-table td:nth-child(6) { grid-area: status; }
  .stores-table td:nth-child(7) { grid-area: actions; }
  .stores-table td:nth-child(4):empty,
  .stores-table td:nth-child(5):empty {
    display: none;
  }

  .stores-table .action-cell {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .purchase-orders-table tr {
    grid-template-areas:
      "number status"
      "supplier supplier"
      "delivery quantity"
      "actions actions";
  }

  .purchase-orders-table td:nth-child(1) { grid-area: number; }
  .purchase-orders-table td:nth-child(2) { grid-area: supplier; }
  .purchase-orders-table td:nth-child(3) { grid-area: delivery; }
  .purchase-orders-table td:nth-child(4) { grid-area: quantity; }
  .purchase-orders-table td:nth-child(5) { grid-area: status; }
  .purchase-orders-table td:nth-child(6) { grid-area: actions; }
  .purchase-orders-table .action-cell button:disabled { display: none; }

  .purchase-orders-table td:nth-child(2),
  .purchase-batches-table td:nth-child(5),
  .supplier-purchase-table td:nth-child(3),
  .store-invoices-table td:nth-child(2),
  .store-orders-table td:nth-child(3) {
    background: #f8fafc;
    border: 1px solid #edf1f5;
    border-radius: 8px;
    margin: 3px 0;
  }

  .purchase-batches-table tr {
    grid-template-areas:
      "batch status"
      "suppliers suppliers"
      "stores sku"
      "quantity created"
      "actions actions";
  }

  .purchase-batches-table td:nth-child(1) { grid-area: batch; }
  .purchase-batches-table td:nth-child(2) { grid-area: stores; }
  .purchase-batches-table td:nth-child(3) { grid-area: sku; }
  .purchase-batches-table td:nth-child(4) { grid-area: quantity; }
  .purchase-batches-table td:nth-child(5) { grid-area: suppliers; }
  .purchase-batches-table td:nth-child(6) { grid-area: status; }
  .purchase-batches-table td:nth-child(7) { grid-area: created; }
  .purchase-batches-table td:nth-child(8) { grid-area: actions; }

  .supplier-purchase-table tr {
    grid-template-areas:
      "batch status"
      "supplier supplier"
      "date delivery"
      "sku quantity"
      "amount invoice"
      "creator creator"
      "actions actions";
  }

  .supplier-purchase-table td:nth-child(1) { grid-area: batch; }
  .supplier-purchase-table td:nth-child(2) { grid-area: date; }
  .supplier-purchase-table td:nth-child(3) { grid-area: supplier; }
  .supplier-purchase-table td:nth-child(4) { grid-area: sku; }
  .supplier-purchase-table td:nth-child(5) { grid-area: quantity; }
  .supplier-purchase-table td:nth-child(6) { grid-area: amount; }
  .supplier-purchase-table td:nth-child(7) { grid-area: delivery; }
  .supplier-purchase-table td:nth-child(8) { grid-area: status; }
  .supplier-purchase-table td:nth-child(9) { grid-area: invoice; }
  .supplier-purchase-table td:nth-child(10) { grid-area: creator; }
  .supplier-purchase-table td:nth-child(11) { grid-area: actions; }

  .store-invoices-table tr:not(.empty-state-row) {
    grid-template-areas:
      "invoice status"
      "store store"
      "purchase source"
      "date total"
      "sku quantity"
      "actions actions";
  }

  .store-invoices-table td:nth-child(1) { grid-area: invoice; }
  .store-invoices-table td:nth-child(2) { grid-area: store; }
  .store-invoices-table td:nth-child(3) { grid-area: purchase; }
  .store-invoices-table td:nth-child(4) { grid-area: source; }
  .store-invoices-table td:nth-child(5) { grid-area: date; }
  .store-invoices-table td:nth-child(6) { grid-area: sku; }
  .store-invoices-table td:nth-child(7) { grid-area: quantity; }
  .store-invoices-table td:nth-child(8) { grid-area: total; }
  .store-invoices-table td:nth-child(9) { grid-area: status; }
  .store-invoices-table td:nth-child(10) { grid-area: actions; }

  .store-orders-table tr {
    grid-template-areas:
      "order order"
      "store date"
      "sku quantity"
      "supplier supplier"
      "status submitter"
      "note note"
      "actions actions";
    padding-top: 12px;
  }

  .store-orders-table td:nth-child(1) { grid-area: selection; }
  .store-orders-table td:nth-child(2) { grid-area: order; }
  .store-orders-table td:nth-child(3) { grid-area: store; }
  .store-orders-table td:nth-child(4) { grid-area: date; }
  .store-orders-table td:nth-child(5) { grid-area: sku; }
  .store-orders-table td:nth-child(6) { grid-area: quantity; }
  .store-orders-table td:nth-child(7) { grid-area: supplier; }
  .store-orders-table td:nth-child(8) { grid-area: status; }
  .store-orders-table td:nth-child(9) { grid-area: submitter; }
  .store-orders-table td:nth-child(10) { grid-area: note; }
  .store-orders-table td:nth-child(11) { grid-area: actions; }

  .store-orders-table td:nth-child(2) {
    padding-right: 44px;
  }

  .store-orders-table .selection-cell {
    padding: 0;
    position: absolute;
    right: 12px;
    top: 12px;
    width: 28px;
    z-index: 1;
  }

  .store-orders-table .selection-cell:empty {
    display: none;
  }

  .store-orders-table .selection-cell::before,
  .store-orders-table .selection-cell:empty::after {
    display: none;
  }

  .store-orders-table .selection-cell input {
    height: 24px;
    min-height: 0;
    width: 24px;
  }

  .store-orders-table .store-order-note-cell {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    margin-top: 4px;
  }

  #purchase-batch-detail-view .detail-panel {
    border-radius: 14px;
    scroll-margin-top: 12px;
  }

  #purchase-batch-detail-view .detail-panel > h2 {
    font-size: 18px;
    margin-top: 0;
  }

  #purchase-batch-detail-view .detail-panel .toolbar.compact {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 10px;
    display: grid;
    gap: 8px;
    padding: 10px;
  }

  #purchase-batch-detail-view .summary-item {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 10px;
    margin-top: 10px;
    padding: 12px;
  }

  #purchase-batch-detail-view .allocation-row {
    background: #f8fafc;
    border-radius: 6px;
    gap: 12px;
    padding: 7px 9px;
  }
}

/* Order details use a dense, purpose-built card layout on phones and iPad.
   The generic responsive table stacks every cell into a full-width row, which
   makes large store orders needlessly long and leaves most of each row empty. */
@media (max-width: 767px), (min-width: 768px) and (max-width: 1180px) and (orientation: portrait) {
  body.order-detail-open .mobile-home-button {
    display: none;
  }

  .detail-drawer-header {
    min-height: 72px;
    padding: max(14px, env(safe-area-inset-top)) 18px 14px;
  }

  .detail-drawer-header h2 {
    font-size: 20px;
    line-height: 1.25;
    margin: 0;
  }

  .detail-drawer-header p {
    font-size: 13px;
    margin: 3px 0 0;
  }

  .order-detail-content {
    padding: 14px;
  }

  #order-detail-summary {
    gap: 8px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 14px;
  }

  #order-detail-summary > div {
    border-radius: 10px;
    min-height: 64px;
    padding: 9px 11px;
  }

  #order-detail-summary > .full-span {
    grid-column: 1 / -1;
    min-height: 0;
  }

  #order-detail-summary span {
    font-size: 11px;
    margin-bottom: 3px;
  }

  #order-detail-summary strong {
    display: block;
    font-size: 14px;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }

  .detail-table-wrap {
    overflow: visible;
  }

  .detail-table-wrap .order-items-table,
  .detail-table-wrap .order-items-table tbody {
    display: block;
    min-width: 0;
    width: 100%;
  }

  .detail-table-wrap .order-items-table tbody {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-table-wrap .order-items-table .order-item-card {
    background: #ffffff;
    border: 1px solid #dbe3ec;
    border-radius: 14px;
    box-shadow: 0 3px 12px rgba(15, 23, 42, 0.06);
    display: grid;
    gap: 0;
    grid-template-areas:
      "image name name"
      "image sku upc"
      "category category supplier"
      "fulfillment fulfillment fulfillment"
      "unit spec quantity"
      "price total note";
    grid-template-columns: 76px minmax(0, 1fr) minmax(0, 1fr);
    margin: 0;
    overflow: hidden;
    padding: 10px;
  }

  .detail-table-wrap .order-items-table .order-item-card > td {
    border: 0;
    display: block;
    min-width: 0;
    padding: 7px 8px;
    text-align: left;
    width: auto;
  }

  .detail-table-wrap .order-items-table .order-item-card > td::before {
    color: #64748b;
    content: attr(data-label);
    display: block;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 3px;
  }

  .detail-table-wrap .order-item-image { grid-area: image; }
  .detail-table-wrap .order-item-name { grid-area: name; }
  .detail-table-wrap .order-item-sku { grid-area: sku; }
  .detail-table-wrap .order-item-upc { grid-area: upc; }
  .detail-table-wrap .order-item-category { grid-area: category; }
  .detail-table-wrap .order-item-supplier { grid-area: supplier; }
  .detail-table-wrap .order-item-fulfillment { grid-area: fulfillment; }
  .detail-table-wrap .order-item-unit { grid-area: unit; }
  .detail-table-wrap .order-item-spec { grid-area: spec; }
  .detail-table-wrap .order-item-quantity { grid-area: quantity; }
  .detail-table-wrap .order-item-price { grid-area: price; }
  .detail-table-wrap .order-item-total { grid-area: total; }
  .detail-table-wrap .order-item-note { grid-area: note; }

  .detail-table-wrap .order-item-image::before {
    display: none !important;
  }

  .detail-table-wrap .order-item-image .table-image {
    background: #f8fafc;
    border-radius: 10px;
    height: 66px;
    object-fit: contain;
    width: 66px;
  }

  .detail-table-wrap .order-item-name strong {
    font-size: 15px;
    line-height: 1.35;
  }

  .detail-table-wrap .order-item-fulfillment,
  .detail-table-wrap .order-item-note {
    background: #f8fafc;
    border-radius: 8px;
  }

  .detail-table-wrap .order-item-quantity strong,
  .detail-table-wrap .order-item-total strong {
    color: var(--ink);
    font-size: 16px;
  }
}

@media (max-width: 767px) {
  #order-detail-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-table-wrap .order-items-table tbody {
    grid-template-columns: 1fr;
  }

  .detail-table-wrap .order-items-table .order-item-card {
    grid-template-areas:
      "image name name"
      "image sku upc"
      "category category supplier"
      "fulfillment fulfillment fulfillment"
      "unit spec quantity"
      "price total note";
  }
}

@media (min-width: 768px) and (max-width: 1180px) and (orientation: portrait) {
  .compact-mobile-table tbody {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #purchase-batches-view .split {
    grid-template-columns: 1fr;
  }

  #purchase-batch-detail-view .detail-panel {
    grid-column: 1 / -1;
  }
}

@media (min-width: 768px) and (max-width: 1180px) and (orientation: portrait) {
  .workspace {
    padding-left: 18px;
    padding-right: 18px;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar,
  .products-toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .products-toolbar input,
  .toolbar-spacer {
    grid-column: 1 / -1;
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 767px), (min-width: 768px) and (max-width: 1180px) and (orientation: portrait) {
  .table-wrap {
    background: transparent;
    border: 0;
    overflow: visible;
  }

  .table-wrap table {
    min-width: 0;
  }

  .table-wrap thead {
    display: none;
  }

  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap td {
    display: block;
    width: 100%;
  }

  .table-wrap tr {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
    padding: 8px 0;
  }

  .table-wrap td {
    align-items: flex-start;
    border-bottom: 0;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 8px 12px;
    word-break: break-word;
  }

  .table-wrap td::before {
    color: var(--muted);
    content: attr(data-label);
    flex: 0 0 112px;
    font-size: 12px;
    font-weight: 700;
  }

  .table-wrap td:empty::after {
    content: "-";
  }

  .action-cell {
    min-width: 0;
  }

  .action-cell button {
    flex: 1 1 120px;
  }

  .products-table tr {
    border-radius: 12px;
    padding: 0;
  }

  .products-table td:not(.product-mobile-summary):not(.action-cell) {
    display: none;
  }

  .products-table .product-mobile-summary {
    display: block;
    padding: 14px;
  }

  .products-table .product-mobile-summary::before,
  .products-table .action-cell::before {
    display: none;
  }

  .product-mobile-head {
    align-items: flex-start;
    display: grid;
    gap: 12px;
    grid-template-columns: 128px minmax(0, 1fr);
  }

  .product-mobile-head .product-management-image {
    border-radius: 12px;
    height: 128px;
    object-fit: contain;
    width: 128px;
  }

  .product-mobile-title {
    min-width: 0;
  }

  .product-mobile-title strong,
  .product-mobile-title > span {
    display: block;
    line-height: 1.38;
    overflow-wrap: anywhere;
  }

  .product-mobile-title strong {
    font-size: 17px;
  }

  .product-mobile-title > span {
    color: var(--muted);
    font-size: 12px;
    margin-top: 4px;
  }

  .product-mobile-statuses {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
  }

  .product-mobile-stock {
    align-items: center;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 8px;
    color: #047857;
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    padding: 7px 9px;
  }

  .product-mobile-stock span {
    font-size: 12px;
    font-weight: 700;
  }

  .product-mobile-stock strong {
    color: #047857;
    font-size: 17px;
    line-height: 1;
  }

  .product-mobile-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
  }

  .product-mobile-tags span {
    background: #f1f5f9;
    border-radius: 999px;
    color: #475569;
    font-size: 11px;
    padding: 5px 8px;
  }

  .product-mobile-details {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 12px 0 0;
  }

  .product-mobile-details > div {
    background: #f8fafc;
    border: 1px solid #eef2f7;
    border-radius: 8px;
    min-width: 0;
    padding: 8px 9px;
  }

  .product-mobile-details dt {
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    margin-bottom: 3px;
  }

  .product-mobile-details dd {
    font-size: 13px;
    line-height: 1.35;
    margin: 0;
    overflow-wrap: anywhere;
  }

  .product-mobile-details .product-calculation {
    font-size: 10px;
  }

  .products-table .action-cell {
    background: #f8fafc;
    border-top: 1px solid var(--line);
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 10px 14px 14px;
  }
}

@media (max-width: 767px) {
  .image-preview-modal {
    padding: max(64px, calc(env(safe-area-inset-top) + 56px)) 12px max(16px, env(safe-area-inset-bottom));
  }

  .image-preview-large {
    max-height: calc(100dvh - 130px);
    max-width: 96vw;
  }

  .workspace {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .mobile-filter-toolbar {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 3px 10px rgba(15, 23, 42, 0.05);
    margin-bottom: 12px;
    padding: 10px;
  }

  .store-invoice-toolbar #store-invoice-search,
  .store-invoice-toolbar #store-invoice-store-filter {
    grid-column: 1 / -1;
  }

  #supplier-purchase-modal,
  #store-invoice-modal,
  #purchase-adjustment-modal,
  #purchase-shortage-modal {
    padding: 0;
  }

  #supplier-purchase-modal .modal-panel,
  #store-invoice-modal .modal-panel,
  #purchase-adjustment-modal .modal-panel,
  #purchase-shortage-modal .modal-panel {
    border-radius: 0;
    height: 100dvh;
    max-height: 100dvh;
  }

  #supplier-purchase-modal .modal-header,
  #store-invoice-modal .modal-header,
  #purchase-adjustment-modal .modal-header,
  #purchase-shortage-modal .modal-header {
    padding: calc(12px + env(safe-area-inset-top)) 14px 12px;
  }

  #supplier-purchase-modal .form-grid,
  #store-invoice-modal .form-grid {
    padding: 14px;
  }

  #supplier-purchase-modal .purchase-item-card {
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 12px;
  }

  #supplier-purchase-modal .purchase-item-card > label:first-child,
  #supplier-purchase-modal .purchase-item-meta,
  #supplier-purchase-modal .supplier-allocation-panel {
    grid-column: 1 / -1;
  }

  #supplier-purchase-modal .purchase-item-card > label:nth-of-type(6) {
    grid-column: 1 / -1;
  }

  #supplier-purchase-modal .line-total {
    align-self: center;
    font-size: 15px;
  }

  #supplier-purchase-modal [data-remove-purchase-item] {
    width: 100%;
  }

  #store-invoice-modal .form-section {
    min-width: 0;
  }

  #store-invoice-modal .table-wrap tr {
    border-radius: 10px;
  }

  #store-invoice-modal .invoice-price-input {
    max-width: 150px;
    width: 100%;
  }

  #store-invoice-modal .modal-actions,
  #supplier-purchase-modal .modal-actions {
    border-top: 1px solid var(--line);
    margin: 0 -14px -14px;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  }

  .topbar {
    min-height: 48px;
    padding-left: 58px;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  .inventory-summary-panel {
    padding: 12px;
  }

  .inventory-summary-heading {
    display: block;
    margin-bottom: 10px;
  }

  .inventory-summary-heading h2 {
    font-size: 18px;
  }

  .inventory-summary-heading p {
    line-height: 1.45;
    margin-top: 5px;
  }

  .inventory-metrics {
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .inventory-metric {
    min-height: 112px;
    padding: 10px;
  }

  .inventory-metric span {
    font-size: 12px;
    line-height: 1.3;
  }

  .inventory-metric strong {
    font-size: 20px;
    margin-top: 5px;
  }

  .inventory-metric small {
    font-size: 10px;
  }

  .products-table tr {
    border-radius: 12px;
    padding: 0;
  }

  .products-table td:not(.product-mobile-summary):not(.action-cell) {
    display: none;
  }

  .products-table .product-mobile-summary {
    display: block;
    padding: 14px;
  }

  .products-table .product-mobile-summary::before,
  .products-table .action-cell::before {
    display: none;
  }

  .product-mobile-head {
    align-items: flex-start;
    display: grid;
    gap: 12px;
    grid-template-columns: 112px minmax(0, 1fr);
  }

  .product-mobile-head .product-management-image {
    border-radius: 10px;
    height: 112px;
    object-fit: contain;
    width: 112px;
  }

  .product-mobile-title {
    min-width: 0;
  }

  .product-mobile-title strong,
  .product-mobile-title > span {
    display: block;
    line-height: 1.38;
    overflow-wrap: anywhere;
  }

  .product-mobile-title strong {
    font-size: 17px;
  }

  .product-mobile-title > span {
    color: var(--muted);
    font-size: 12px;
    margin-top: 4px;
  }

  .product-mobile-statuses {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
  }

  .product-mobile-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
  }

  .product-mobile-tags span {
    background: #f1f5f9;
    border-radius: 999px;
    color: #475569;
    font-size: 11px;
    padding: 5px 8px;
  }

  .product-mobile-details {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 12px 0 0;
  }

  .product-mobile-details > div {
    background: #f8fafc;
    border: 1px solid #eef2f7;
    border-radius: 8px;
    min-width: 0;
    padding: 8px 9px;
  }

  .product-mobile-details dt {
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    margin-bottom: 3px;
  }

  .product-mobile-details dd {
    font-size: 13px;
    line-height: 1.35;
    margin: 0;
    overflow-wrap: anywhere;
  }

  .product-mobile-details .product-calculation {
    font-size: 10px;
  }

  .products-table .action-cell {
    background: #f8fafc;
    border-top: 1px solid var(--line);
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 10px 14px 14px;
  }

  .products-table .action-cell button {
    font-size: 14px;
    min-width: 0;
    padding-left: 8px;
    padding-right: 8px;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .settings-card {
    padding: 16px;
  }

  .purchase-allocation-head {
    display: none;
  }

  .purchase-add-product {
    grid-template-columns: 1fr;
  }

  .purchase-add-product .field-help {
    grid-column: auto;
  }

  .purchase-allocation-row {
    grid-template-columns: 1fr 72px 90px;
    padding: 12px;
  }

  .purchase-adjustment-card-head,
  .purchase-reserve-row {
    align-items: stretch;
    display: grid;
  }

  .purchase-adjustment-product-summary {
    align-items: flex-start;
  }

  .purchase-adjustment-product-image,
  .purchase-adjustment-product-image-placeholder {
    flex-basis: 72px;
    height: 72px;
    width: 72px;
  }

  .purchase-adjustment-total {
    justify-items: start;
  }

  .table-wrap td {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr);
  }

  .table-wrap td::before {
    flex-basis: auto;
  }

  .detail-summary > div,
  .detail-totals {
    min-width: 0;
  }
}

@media (max-width: 767px), (min-width: 768px) and (max-width: 1180px) and (orientation: portrait) {
  body .topbar {
    align-items: center;
  }

  .table-wrap .compact-mobile-table tbody {
    display: grid;
  }

  .table-wrap .compact-mobile-table tr {
    display: grid;
  }

  .table-wrap .compact-mobile-table td {
    display: block;
    width: auto;
  }

  .table-wrap .compact-mobile-table .action-cell {
    display: grid;
  }
}

@media (min-width: 768px) and (max-width: 1180px) and (orientation: portrait) {
  .table-wrap .compact-mobile-table tbody {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media print {
  body {
    display: block;
    background: #ffffff;
  }

  .sidebar,
  .workspace,
  .no-print,
  .modal,
  #notice {
    display: none !important;
  }

  .detail-drawer,
  .detail-drawer-panel,
  .order-detail-content {
    background: #ffffff;
    box-shadow: none;
    display: block !important;
    height: auto;
    inset: auto;
    overflow: visible;
    padding: 0;
    position: static;
    width: 100%;
  }

  .print-title {
    display: block;
    margin-bottom: 16px;
  }

  .detail-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .table-wrap {
    border: 0;
    overflow: visible;
  }

  table,
  .order-items-table {
    min-width: 0;
    width: 100%;
  }

  th,
  td {
    font-size: 11px;
    padding: 6px;
  }

  .table-image {
    height: 36px;
    width: 36px;
  }

  .order-detail-footer {
    display: block;
  }
}

.weekly-specials-list { display: grid; gap: 12px; margin-top: 14px; }
.weekly-special-card { align-items: center; background: #fff; border: 1px solid #dbe3ec; border-radius: 12px; display: grid; gap: 16px; grid-template-columns: 88px minmax(0, 1fr) auto; padding: 14px; }
.weekly-special-card > img { border-radius: 9px; height: 82px; object-fit: contain; width: 82px; }
.weekly-special-heading { align-items: flex-start; display: flex; justify-content: space-between; }
.weekly-special-heading h3 { margin: 3px 0; }
.weekly-special-supplier { color: #0f766e; font-size: 12px; font-weight: 800; }
.weekly-special-details { align-items: center; display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 8px; }
.weekly-special-price { color: #c2410c; font-size: 24px; }
.weekly-special-regular { color: #7b8794; text-decoration: line-through; }
.weekly-special-details b { background: #fff1e6; border-radius: 999px; color: #b42318; padding: 5px 10px; }
.weekly-special-actions { display: flex; gap: 7px; }
.weekly-special-expiry { background: #eef2f6; border-radius: 6px; padding: 5px 8px; }
.weekly-special-expiry.warning, .weekly-special-expiry.product-warning { background: #fff4ce; color: #854d0e; }
.weekly-special-expiry.urgent, .weekly-special-expiry.expired, .weekly-special-expiry.product-urgent, .weekly-special-expiry.product-expired { background: #fee2e2; color: #b42318; }
.weekly-special-expiry.product { background: #e8f4ff; color: #175cd3; }
.expiry-center-panel { background: #fff; border: 1px solid #dbe3ec; border-radius: 14px; margin-top: 28px; padding: 18px; }
.expiry-alert-metrics { margin: 14px 0; }
.expiry-alert-list { display: grid; gap: 8px; margin-top: 12px; }
.expiry-alert-row { align-items: center; border-left: 6px solid #22c55e; border-radius: 8px; box-shadow: 0 0 0 1px #e2e8f0; display: grid; gap: 12px; grid-template-columns: minmax(0, 1.5fr) minmax(180px, 1fr) auto; padding: 12px; }
.warehouse-expiry-panel { margin: 18px 0; }
.warehouse-expiry-panel .expiry-alert-row { grid-template-columns: minmax(0, 1.5fr) minmax(180px, 1fr) auto auto; }
.expiry-alert-row > div { display: grid; gap: 3px; }
.expiry-alert-row span { color: #667085; font-size: 12px; }
.expiry-alert-row.warning { border-left-color: #f59e0b; }
.expiry-alert-row.urgent, .expiry-alert-row.expired { border-left-color: #dc2626; background: #fff7f7; }
.expiry-alert-row.expired > b, .expiry-alert-row.urgent > b { color: #b42318; }
.weekly-special-store-scope { border: 1px solid #dbe3ec; border-radius: 8px; padding: 12px; }
@media (max-width: 760px) {
  .weekly-special-card { align-items: start; grid-template-columns: 64px minmax(0, 1fr); }
  .weekly-special-card > img { height: 60px; width: 60px; }
  .weekly-special-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .expiry-alert-row { grid-template-columns: 1fr; }
  .warehouse-expiry-panel .expiry-alert-row { grid-template-columns: 1fr; }
}

.home-shortcut-settings { border: 1px solid var(--line); border-radius: 12px; margin: 0; padding: 14px; }
.home-shortcut-settings legend { font-weight: 700; padding: 0 6px; }
.home-shortcut-settings > .form-grid { margin-top: 12px; padding: 0; }
.home-shortcut-options { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 12px; }
.home-shortcut-options label { align-items: center; display: flex; gap: 8px; }
.home-shortcut-options input { height: 18px; min-height: 0; width: 18px; }

@media (max-width: 1180px), (max-width: 1400px) and (pointer: coarse) {
  html.home-launcher-open,
  body.home-launcher-open { height: 100%; max-height: 100%; overflow: hidden; overscroll-behavior: none; }
  body.home-launcher-open { inset: 0; position: fixed; touch-action: none; width: 100%; }
  body.home-launcher-open .workspace { height: 100dvh; max-width: none; overflow: hidden; padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
  body.home-launcher-open #home-view,
  body.home-launcher-open .dashboard-shortcuts { height: 100%; min-height: 0; }
  body.home-launcher-open .dashboard-shortcuts { grid-template-rows: auto minmax(0, 1fr); }
  body.home-launcher-open .dashboard-home-header { min-height: 0; padding: clamp(7px, 1.4dvh, 14px); }
  body.home-launcher-open .dashboard-shortcut-grid { grid-auto-rows: minmax(96px, 1fr); grid-template-columns: repeat(2, minmax(0, 1fr)); min-height: 0; overflow-y: auto; touch-action: pan-y; }
  body.home-launcher-open .dashboard-shortcut-grid .dashboard-shortcut { gap: clamp(2px, 0.7dvh, 8px); min-height: 0; overflow: hidden; padding: clamp(7px, 1.4dvh, 16px); }
  body.home-launcher-open .dashboard-shortcut .nav-icon { font-size: clamp(16px, 2.4dvh, 22px); height: clamp(28px, 4.3dvh, 44px); width: clamp(28px, 4.3dvh, 44px); }
  body.home-launcher-open .dashboard-shortcut .nav-copy strong { font-size: clamp(13px, 1.9dvh, 17px); }
  body.home-launcher-open .dashboard-shortcut .nav-copy small { font-size: clamp(9px, 1.3dvh, 12px); line-height: 1.2; }
}

@media (max-width: 599px) {
  .dashboard-home-logout { display: inline-flex; font-size: 12px; min-height: 34px; padding: 5px 9px; }
}

@media (max-height: 720px) and (max-width: 599px) {
  body.home-launcher-open .dashboard-home-brand #dashboard-admin-user-label,
  body.home-launcher-open .dashboard-shortcut .nav-copy small,
  body.home-launcher-open .dashboard-home-header .launcher-language-control span { display: none; }
  body.home-launcher-open .dashboard-home-header .launcher-language-control { min-width: 104px; }
  body.home-launcher-open .dashboard-home-header .launcher-language-control select { min-height: 34px; padding: 4px 6px; }
}

@media (max-width: 1180px), (max-width: 1400px) and (pointer: coarse) {
  .dashboard-home-header { box-shadow: 0 6px 20px rgba(15, 23, 42, 0.06); }
  .dashboard-home-brand { flex: 1 1 auto; overflow: hidden; }
  .dashboard-home-brand .brand-mark { border-radius: 11px; flex: 0 0 40px; height: 40px; width: 40px; }
  .dashboard-home-brand strong,
  .dashboard-home-brand #dashboard-admin-user-label { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .launcher-header-actions { align-items: center; background: #f4f6f9; border: 1px solid #e2e8f0; border-radius: 12px; display: flex; flex: 0 0 auto; gap: 4px; padding: 3px; }
  .dashboard-home-header .launcher-language-toggle { background: transparent; border: 0; border-radius: 9px; color: #1d4ed8; font-size: 13px; font-weight: 800; min-height: 34px; padding: 5px 10px; width: 82px; }
  .dashboard-home-header .dashboard-home-logout { background: #ffffff; border: 0; border-radius: 9px; color: #b42318; font-size: 12px; min-height: 34px; padding: 5px 9px; }
}

@media (max-width: 420px) {
  .dashboard-home-header { gap: 7px; }
  .dashboard-home-brand { gap: 8px; }
  .dashboard-home-brand .brand-mark { flex-basis: 34px; height: 34px; width: 34px; }
  .dashboard-home-brand strong { font-size: 15px; }
  .dashboard-home-brand #dashboard-admin-user-label { font-size: 10px; }
  .dashboard-home-header .launcher-language-toggle { font-size: 12px; width: 68px; }
}

/* Fit the launcher to the visible screen even if the previous page was zoomed.
   All overrides disappear when leaving Home, including on logout. */
@media (max-width: 1180px), (max-width: 1400px) and (pointer: coarse) {
  body.home-launcher-open.home-viewport-fitted {
    display: block;
    inset: auto;
    left: var(--home-screen-x);
    top: var(--home-screen-y);
    width: var(--home-screen-width);
    max-width: none;
    height: var(--home-screen-height);
    min-height: 0;
    max-height: none;
    transform: scale(var(--home-screen-scale));
    transform-origin: top left;
  }
  body.home-launcher-open.home-viewport-fitted .sidebar { display: none; }
  body.home-launcher-open.home-viewport-fitted .workspace {
    width: 100%;
    height: var(--home-screen-height);
    min-height: 0;
  }
  body.home-launcher-open.home-viewport-fitted .dashboard-shortcut-grid { overflow-y: auto; touch-action: pan-y; }
}

.mobile-settings-launcher,
.mobile-settings-back { display: none; }

@media (max-width: 1180px) {
  #settings-view.active:not(.mobile-settings-detail-open) .settings-grid { display: none; }
  #settings-view.mobile-settings-detail-open .mobile-settings-launcher { display: none; }
  #settings-view .mobile-settings-launcher { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #settings-view .mobile-settings-card { align-content: start; background: #ffffff; border: 1px solid #e7ebf0; border-radius: 18px; box-shadow: 0 8px 24px rgba(15, 23, 42, 0.07); color: var(--ink); display: grid; gap: 10px; min-height: 132px; padding: 18px; text-align: left; }
  #settings-view .mobile-settings-card .nav-copy { display: grid; gap: 4px; }
  #settings-view .mobile-settings-card strong { font-size: 17px; line-height: 1.25; }
  #settings-view .mobile-settings-card small { color: var(--muted); font-size: 12px; line-height: 1.4; }
  #settings-view.mobile-settings-detail-open .mobile-settings-back { display: inline-flex; margin-bottom: 12px; }
  #settings-view.mobile-settings-detail-open .settings-grid { display: grid; grid-template-columns: 1fr; }
  #settings-view.mobile-settings-detail-open [data-mobile-settings-panel] { display: none !important; }
  #settings-view.mobile-settings-detail-open [data-mobile-settings-panel].mobile-settings-panel-active:not(.hidden) { display: grid !important; }
}

@media (min-width: 768px) and (max-width: 1180px) {
  #settings-view .mobile-settings-launcher { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  #upc-supplement-modal .modal-panel { height: 100dvh; max-height: 100dvh; width: 100%; }
  #upc-supplement-modal .modal-actions { background: #fff; bottom: 0; padding: 12px; position: sticky; z-index: 3; }
}
 .image-preview-grid { display:grid; gap:12px; grid-template-columns:repeat(auto-fit,minmax(140px,1fr)); margin:14px 0; }
 .image-preview-grid img { border:1px solid var(--line); border-radius:10px; height:150px; object-fit:contain; width:100%; }
.warehouse-dispatch-matrix { min-width: 1180px; }
.warehouse-dispatch-matrix th { white-space: nowrap; }
.warehouse-dispatch-matrix td { vertical-align: middle; }
.warehouse-dispatch-matrix .matrix-quantity-input { min-width: 84px; width: 100%; }

.product-category-field { display: grid; gap: 6px; min-width: 0; }
.product-category-cascade { display: grid; gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); min-width: 0; }
.product-category-cascade select { width: 100%; min-width: 0; }
.product-category-cascade button { grid-column: 1 / -1; }

@media (max-width: 900px) {
  .product-category-filter-cascade { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  #products-view .products-toolbar { gap: 8px; }
  #products-view .hq-product-search-control,
  #products-view .hq-product-search-row { min-width: 0; width: 100%; }
  #products-view .hq-product-search-row { display: grid !important; grid-template-columns: minmax(0, 1fr) 72px; }
  #products-view .hq-product-search-row > input,
  #products-view .hq-product-search-row > button { grid-column: auto; margin: 0; min-width: 0; width: 100%; }
  #products-view .hq-screen-keyboard-toggle { font-size: 13px; padding-left: 4px; padding-right: 4px; }
  #products-view .hq-screen-keyboard { min-width: 0; overflow: hidden; padding: 8px; }
  #products-view .hq-screen-keyboard-keys { grid-template-columns: repeat(10, minmax(0, 1fr)); }
  #products-view .hq-screen-keyboard-keys button { font-size: 12px; min-width: 0; padding-left: 1px; padding-right: 1px; }
  #products-view .hq-screen-keyboard-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #products-view .product-origin-filter-row {
    display: grid !important;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #products-view .product-origin-filter-row .product-supplier-filter {
    display: grid;
    gap: 6px;
    grid-template-columns: minmax(0, 1fr);
    min-width: 0;
    padding: 8px;
    width: 100%;
  }
  #products-view .product-origin-filter-row .product-supplier-filter span {
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #products-view .product-origin-filter-row select { min-width: 0; width: 100%; }
  .product-category-filter-cascade { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .product-category-cascade { grid-template-columns: 1fr; }
  .product-category-cascade button { grid-column: auto; }
}

/* Dedicated headquarters bulk classification editor. */
#bulk-classification-view .bc-control-panel,
#bulk-classification-view .bc-save-panel,
#bulk-classification-view .bc-selection-panel,
#bulk-classification-view .bc-batch-panel {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 14px;
}
#bulk-classification-view .bc-control-panel { padding: 14px; }
#bulk-classification-view .bc-mode-panel {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  margin-bottom: 12px;
}
#bulk-classification-view .bc-mode-field,
#bulk-classification-view .bc-primary label,
#bulk-classification-view .bc-advanced label {
  display: grid;
  gap: 5px;
  min-width: 0;
}
#bulk-classification-view .bc-mode-field > span,
#bulk-classification-view .bc-primary label,
#bulk-classification-view .bc-advanced label {
  color: #344050;
  font-size: 13px;
  font-weight: 700;
}
#bulk-classification-view #bc-mode-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
#bulk-classification-view .bc-primary {
  align-items: end;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(280px, 1.6fr) repeat(4, minmax(135px, 1fr));
}
#bulk-classification-view .bc-search-row {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
  min-width: 0;
}
#bulk-classification-view .bc-search-row input { min-width: 0; width: 100%; }
#bulk-classification-view .bc-more-filters {
  border-top: 1px solid #e7ebf0;
  margin: 12px -14px -14px;
  padding: 0 14px;
}
#bulk-classification-view .bc-more-filters summary { padding: 12px 0; }
#bulk-classification-view .bc-save-panel { margin-top: 10px; padding: 10px 12px; }
#bulk-classification-view .bc-save-toolbar { margin: 0; }
#bulk-classification-view #bc-status {
  color: #334155;
  margin-left: auto;
}
#bulk-classification-view .bc-selection-panel,
#bulk-classification-view .bc-batch-panel {
  margin: 10px 0;
  padding: 0 12px;
}
#bulk-classification-view .bc-selection-panel > summary,
#bulk-classification-view .bc-batch-panel > summary { padding: 12px 0; }
#bulk-classification-view select { min-width: 130px; max-width: 240px; }
#bulk-classification-view td { vertical-align: middle; }
#bulk-classification-view .table-wrap { overflow-x: auto; }
#bulk-classification-view table { min-width: 1150px; }
#bulk-classification-view dialog { border: 1px solid #d8e0e8; border-radius: 16px; padding: 24px; max-width: min(640px, 90vw); color: inherit; }
#bulk-classification-view dialog::backdrop { background: rgba(15, 23, 42, .55); }
#bc-category form { display: grid; gap: 14px; }
#bc-category label { display: grid; gap: 6px; }
#bc-status { font-weight: 600; }

#bulk-classification-view .bc-primary { display:flex; flex-wrap:wrap; gap:12px; align-items:end; }
#bulk-classification-view .bc-primary > input { flex:1; min-width:220px; }
#bulk-classification-view .bc-primary label { display:flex; flex-direction:column; gap:4px; }
#bulk-classification-view .bc-primary select { width:180px; }
#bulk-classification-view .bc-advanced { display:grid; grid-template-columns:repeat(auto-fit,minmax(160px,1fr)); gap:12px; padding:12px 0; }
#bulk-classification-view .bc-advanced label { display:flex; flex-direction:column; gap:4px; }
#bulk-classification-view details { margin:12px 0; }
#bulk-classification-view summary { cursor:pointer; color:var(--primary,#0f766e); padding:8px 0; font-weight:600; }
#bulk-classification-view .toolbar { display:flex !important; flex-direction:row !important; flex-wrap:wrap; gap:8px; align-items:center; }
#bulk-classification-view .toolbar button { width:auto !important; min-height:36px; padding:7px 12px; }
#bulk-classification-view table { min-width:850px; width:100%; table-layout:fixed; }
#bulk-classification-view th:first-child { width:100px; }
#bulk-classification-view th:nth-child(2) { width:250px; }
#bulk-classification-view th:nth-child(n+3) { width:125px; }
#bulk-classification-view td { padding:8px; }
#bulk-classification-view td:first-child > input { display:block; margin-bottom:8px; }
#bulk-classification-view .table-image { width:90px; height:100px; object-fit:contain; }
#bulk-classification-view td select { width:100%; min-width:0; max-width:none; }
#bulk-classification-view td button { font-size:12px; padding:5px 7px; min-height:28px; width:auto !important; }
#bulk-classification-view td strong { display:block; font-size:16px; }
#bulk-classification-view .inline-actions { display:flex; flex-wrap:wrap; gap:4px; margin:6px 0; }
#bulk-classification-view .bc-primary button { width:auto !important; }

/* Phone editor: each product has its own visible category controls. */
@media (max-width: 767px), (min-width: 768px) and (max-width: 1180px) and (orientation: portrait), (max-width: 1400px) and (pointer: coarse) {
  #bulk-classification-view { min-width:0; }
  #bulk-classification-view .bc-control-panel { padding:12px; }
  #bulk-classification-view .bc-mode-panel { grid-template-columns:minmax(0,1fr); gap:7px; margin-bottom:10px; }
  #bulk-classification-view .bc-mode-field { grid-template-columns:90px minmax(0,1fr); align-items:center; }
  #bulk-classification-view .bc-mode-field select { max-width:none; width:100%; }
  #bulk-classification-view #bc-mode-note { background:#f8fafc; border-radius:8px; padding:8px 10px; }
  #bulk-classification-view .bc-primary { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:8px; }
  #bulk-classification-view .bc-search-row { grid-column:1 / -1; grid-template-columns:minmax(0,1fr) 88px; }
  #bulk-classification-view .bc-primary > label:first-of-type { grid-column:auto; }
  #bulk-classification-view .bc-primary select,
  #bulk-classification-view .bc-advanced select,
  #bulk-classification-view #bc-batch select { min-width:0; max-width:none; width:100%; }
  #bulk-classification-view .bc-primary label { min-width:0; }
  #bulk-classification-view .bc-primary button { align-self:end; min-height:44px; }
  #bulk-classification-view .toolbar button { min-height:44px; }
  #bulk-classification-view .bc-more-filters { margin:10px -12px -12px; padding:0 12px; }
  #bulk-classification-view .bc-save-panel { padding:10px; }
  #bulk-classification-view .bc-save-toolbar { display:grid !important; grid-template-columns:minmax(0,1fr) minmax(0,1fr); }
  #bulk-classification-view .bc-save-toolbar button { width:100% !important; }
  #bulk-classification-view #bc-status { grid-column:1 / -1; margin:0; order:-1; }
  #bulk-classification-view .bc-advanced { grid-template-columns:repeat(2,minmax(0,1fr)); }
  #bulk-classification-view #bc-batch { display:grid !important; grid-template-columns:repeat(2,minmax(0,1fr)); }
  #bulk-classification-view #bc-batch label { min-width:0; }
  #bulk-classification-view #bc-batch > span { grid-column:1 / -1; }
  #bulk-classification-view .table-wrap { overflow:visible; border:0; background:transparent; }
  #bulk-classification-view table { display:block; min-width:0; width:100%; }
  #bulk-classification-view thead { display:none; }
  #bulk-classification-view tbody { display:grid; gap:12px; }
  #bulk-classification-view tr { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:10px; padding:12px; border:1px solid #d8e0e8; border-radius:12px; background:#fff; }
  #bulk-classification-view td { display:block; width:auto; padding:0; border:0; min-width:0; overflow-wrap:anywhere; }
  #bulk-classification-view td:first-child { grid-column:1 / -1; grid-row:1; display:flex; justify-content:flex-start; align-items:center; gap:10px; }
  #bulk-classification-view td:first-child::before { display:none; }
  #bulk-classification-view td:nth-child(2) { grid-column:1 / -1; grid-row:2; }
  #bulk-classification-view td:first-child > input { display:inline-block; vertical-align:top; width:22px; height:22px; margin:0 8px 0 0; }
  #bulk-classification-view td:first-child button { vertical-align:top; }
  #bulk-classification-view .table-image { width:70px; height:80px; }
  #bulk-classification-view td[data-label]::before { content:attr(data-label); display:block; font-weight:600; margin-bottom:5px; font-size:13px; }
  #bulk-classification-view td select { min-height:44px; font-size:16px; }
  #bulk-classification-view td button { min-height:40px; font-size:13px; padding:7px 9px; }
  #bulk-classification-view dialog { padding:16px; max-width:calc(100vw - 24px); max-height:90dvh; overflow:auto; }
}

@media (max-width: 767px) {
  body.bulk-classification-open .workspace {
    padding-top: calc(10px + env(safe-area-inset-top));
  }
  body.bulk-classification-open .topbar {
    gap: 6px;
    margin-bottom: 10px;
    min-height: 44px;
    padding-left: 102px;
  }
  body.bulk-classification-open .topbar h1 { font-size: 20px; }
  #bulk-classification-view .bc-control-panel,
  #bulk-classification-view .bc-save-panel,
  #bulk-classification-view .bc-selection-panel,
  #bulk-classification-view .bc-batch-panel { border-radius: 12px; }
  #bulk-classification-view .bc-selection-panel,
  #bulk-classification-view .bc-batch-panel { margin: 8px 0; }
}

/* Keep product actions below the last category, with comfortable touch targets. */
#bulk-classification-view .bc-product-actions { display:grid; grid-template-columns:minmax(0,1fr); gap:8px; margin-top:12px; }
#bulk-classification-view td .bc-product-actions button,
#bulk-classification-view td .bc-product-copy { width:100% !important; min-width:0; min-height:44px; padding:10px 12px; font-size:15px; white-space:nowrap; word-break:normal; }
#bulk-classification-view td .bc-product-save { min-height:52px !important; font-size:18px !important; font-weight:700; }
#bulk-classification-view td .bc-product-copy { margin-top:8px; }
@media (max-width: 767px), (min-width: 768px) and (max-width: 1180px) and (orientation: portrait), (max-width: 1400px) and (pointer: coarse) {
  #bulk-classification-view td.bc-last-classification { grid-column:1 / -1; }
  #bulk-classification-view .bc-product-actions { grid-template-columns:repeat(2,minmax(0,1fr)); }
  #bulk-classification-view .bc-product-save { grid-column:1 / -1; }
}

/* Tablet editor: product identity on the left, category controls on the right. */
@media (min-width:768px) and (max-width:1180px) and (orientation:portrait), (min-width:768px) and (max-width:1400px) and (pointer:coarse) {
  #bulk-classification-view tr { grid-template-columns:minmax(220px, .8fr) minmax(0, 1.6fr); align-items:start; gap:10px 20px; }
  #bulk-classification-view td:first-child { grid-column:1; grid-row:1; }
  #bulk-classification-view td:nth-child(2) { grid-column:1; grid-row:2 / 5; align-self:start; }
  #bulk-classification-view td:nth-child(3) { grid-column:2; grid-row:1; }
  #bulk-classification-view td:nth-child(4) { grid-column:2; grid-row:2; }
  #bulk-classification-view td:nth-child(5) { grid-column:2; grid-row:3; }
  #bulk-classification-view td.bc-last-classification { grid-column:2; grid-row:4; }
  #bulk-classification-view .table-image { width:110px; height:120px; }
  #bulk-classification-view td:first-child { align-self:start; }
  #bulk-classification-view td strong { font-size:17px; line-height:1.45; }
  #bulk-classification-view .bc-product-actions { margin-top:10px; }
}

/* Invoice navigation has its own visual hierarchy, independent of the sidebar. */
.billing-hub-view .panel {
  max-width: 1100px;
}

.billing-hub-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 18px;
}

.billing-hub-view .billing-hub-card {
  align-content: start;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 2px 4px rgba(29, 37, 45, 0.025);
  color: var(--ink);
  display: grid;
  gap: 16px 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 164px;
  padding: 20px;
  text-align: left;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.billing-hub-view .billing-hub-card:hover {
  background: #f8fcfb;
  border-color: #83b7b0;
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.08);
}

.billing-hub-view .billing-hub-card:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.billing-hub-view .billing-hub-card .nav-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #e9f4f1;
  color: #0f766e;
}

.billing-hub-view .billing-hub-card[data-view="store-monthly-statements"] .nav-icon {
  background: #eef1fa;
  color: #5368a2;
}

.billing-hub-view .billing-hub-card[data-view="scanned-invoices"] .nav-icon,
.billing-hub-view .billing-hub-card[data-view="warehouse-invoices"] .nav-icon {
  background: #f1f4f8;
  color: #536779;
}

.billing-hub-card .nav-icon svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.billing-card-arrow {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  color: #7e8c98;
  font-size: 20px;
  font-weight: 400;
}

.billing-hub-card:hover .billing-card-arrow {
  color: var(--accent);
}

.billing-hub-card .nav-copy {
  display: grid;
  grid-column: 1 / -1;
  min-width: 0;
  gap: 6px;
}

.billing-hub-card .nav-copy strong {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
}

.billing-hub-card .nav-copy small {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

@media (prefers-reduced-motion: reduce) {
  .billing-hub-view .billing-hub-card { transition: none; }
}

/* Action labels are shown only on desktop; touch layouts retain their existing cards. */
.billing-card-action {
  display: none;
}

@media (min-width: 768px) and (hover: hover) and (pointer: fine) {
  .billing-hub-view .billing-hub-card {
    align-content: stretch;
    grid-template-rows: auto 1fr auto;
    min-height: 224px;
    transition: background 180ms, border-color 180ms, box-shadow 180ms, transform 180ms;
  }

  .billing-hub-card .billing-card-arrow {
    display: none;
  }

  .billing-hub-card .nav-copy {
    align-content: start;
  }

  .billing-hub-view .billing-hub-card:hover,
  .billing-hub-view .billing-hub-card:focus-visible {
    background: #f4fbf9;
    border-color: #218577;
    box-shadow: 0 5px 16px #164f3f12;
    color: var(--ink);
    transform: translateY(-2px);
  }

  .billing-hub-card .billing-card-action {
    align-items: center;
    align-self: end;
    grid-column: 1 / -1;
    color: #147c71;
    display: flex;
    font-size: 14px;
    font-weight: 600;
    gap: 8px;
    margin-top: 8px;
  }

  .billing-action-arrow {
    display: inline-block;
    transition: transform 180ms;
  }

  .billing-hub-card:hover .billing-action-arrow,
  .billing-hub-card:focus-visible .billing-action-arrow {
    transform: translateX(4px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .billing-hub-card,
  .billing-action-arrow {
    transition: none;
  }
  .billing-hub-card:hover,
  .billing-hub-card:focus-visible,
  .billing-hub-card:hover .billing-action-arrow,
  .billing-hub-card:focus-visible .billing-action-arrow {
    transform: none;
  }
}

.billing-page-view {
  min-width: 0;
}

.billing-back-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin-bottom: 16px;
}

.billing-back-button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.billing-page-view .monthly-statement-panel {
  margin-bottom: 0;
}

.billing-page-view .mobile-filter-toolbar label {
  align-content: start;
  display: grid;
  gap: 6px;
}

@media (max-width: 1180px), (max-width: 1400px) and (pointer: coarse) {
  .billing-hub-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .billing-page-view .panel {
    padding: 16px;
  }

  .billing-page-view .table-wrap {
    max-width: 100%;
  }

  .billing-page-view .mobile-filter-toolbar {
    align-items: end;
  }
}

@media (max-width: 767px) {
  .billing-hub-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .billing-hub-view .billing-hub-card {
    align-items: center;
    grid-template-columns: 40px minmax(0, 1fr) 16px;
    gap: 12px;
    min-height: 100px;
    padding: 16px;
  }

  .billing-hub-card .nav-copy {
    grid-column: 2;
    grid-row: 1;
  }

  .billing-card-arrow {
    grid-column: 3;
  }

  .billing-hub-card .nav-copy strong {
    font-size: 15px;
  }

  .billing-page-view .mobile-filter-toolbar {
    grid-template-columns: minmax(0, 1fr);
  }

  .billing-page-view .mobile-filter-toolbar > *,
  .billing-page-view .mobile-filter-toolbar button {
    grid-column: 1;
    width: 100%;
  }

  .billing-page-view .panel {
    border-radius: 12px;
    padding: 12px;
  }

  .billing-page-view .inline-header h2 {
    font-size: 19px;
  }

  .billing-page-view .compact-mobile-table .action-cell {
    grid-column: 1 / -1;
  }
}

/* Compact tablet controls without reducing touch target sizes. */
@media (min-width:768px) and (max-width:1180px) and (orientation:portrait), (min-width:768px) and (max-width:1400px) and (pointer:coarse) {
  #bulk-classification-view .bc-primary { grid-template-columns:repeat(5,minmax(0,1fr)); align-items:end; }
  #bulk-classification-view .bc-primary > input { grid-column:1 / 3; }
  #bulk-classification-view .bc-primary > label:first-of-type { grid-column:3 / 5; }
  #bulk-classification-view .bc-primary button { width:100% !important; }
  #bulk-classification-view details { margin:4px 0; }
  #bulk-classification-view summary { padding:6px 0; }
  #bulk-classification-view tr { gap:8px 16px; }
  #bulk-classification-view td:first-child { grid-row:1 / 3; }
  #bulk-classification-view td:nth-child(2) { grid-row:3 / 5; }
  #bulk-classification-view td[data-label] { display:grid; grid-template-columns:76px minmax(0,1fr); gap:8px; align-items:center; }
  #bulk-classification-view td[data-label]::before { margin:0; }
  #bulk-classification-view .bc-product-actions { grid-column:1 / -1; grid-template-columns:repeat(4,minmax(0,1fr)); margin-top:2px; gap:6px; }
  #bulk-classification-view .bc-product-save { grid-column:auto; }
  #bulk-classification-view td .bc-product-save { min-height:44px !important; font-size:16px !important; }
  #bulk-classification-view td .bc-product-actions button { padding:8px 6px; font-size:14px; }
  #bulk-classification-view td .bc-product-copy { grid-column:1 / -1; margin-top:0; }
}
.scanned-invoice-filters { grid-template-columns: repeat(4, minmax(150px, 1fr)); }
.scanned-invoice-summary { display: flex; gap: 12px; flex-wrap: wrap; margin: 12px 0; }
.scanned-invoice-summary > span { padding: 10px 14px; border-radius: 12px; background: #f2f6fa; }
.scanned-invoice-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; align-items: start; }
.warehouse-invoice-upload-form { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(320px, 1.5fr); gap: 14px; align-items: start; }
.warehouse-new-supplier { margin: 12px 0; border: 1px solid #dbe4ee; border-radius: 12px; background: #f8fafc; }
.warehouse-new-supplier > summary { padding: 12px 14px; cursor: pointer; color: #087f72; font-weight: 700; }
.warehouse-new-supplier-form { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)) auto; gap: 10px; align-items: end; padding: 0 14px 14px; }
.invoice-folder { min-width: 0; border: 0; background: transparent; overflow: visible; }
.invoice-folder[open] { grid-column: 1 / -1; }
.invoice-folder > summary { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 150px; padding: 14px 8px; cursor: pointer; list-style: none; border: 1px solid transparent; border-radius: 16px; background: transparent; text-align: center; transition: background .16s ease, border-color .16s ease, transform .16s ease; }
.invoice-folder > summary:hover { border-color: #cfe4ef; background: #f2f9fc; transform: translateY(-2px); }
.invoice-folder[open] > summary { width: min(100%, 170px); border-color: #cfe4ef; background: #f2f9fc; }
.invoice-folder > summary::-webkit-details-marker { display: none; }
.invoice-folder-heading { display: flex; flex-direction: column; align-items: center; min-width: 0; gap: 10px; }
.invoice-folder-heading > span:last-child { display: grid; min-width: 0; gap: 3px; }
.invoice-folder-heading strong { display: -webkit-box; overflow: hidden; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-height: 1.25; }
.invoice-folder-heading small { color: #6b7e8d; font-size: 12px; font-weight: 500; }
.invoice-folder-icon { position: relative; flex: 0 0 58px; width: 76px; height: 58px; border: 1px solid #2198cf; border-radius: 7px 9px 9px 9px; background: linear-gradient(180deg, #56c8f3 0%, #2faadf 100%); box-shadow: inset 0 2px 0 rgba(255,255,255,.45), 0 5px 10px rgba(18,110,158,.22); }
.invoice-folder-icon::before { position: absolute; left: 4px; top: -9px; width: 34px; height: 13px; border: 1px solid #2198cf; border-bottom: 0; border-radius: 7px 7px 0 0; background: #52c5f0; content: ''; }
.invoice-folder-icon::after { position: absolute; left: 4px; right: 4px; top: 5px; height: 3px; border-radius: 999px; background: rgba(255,255,255,.55); content: ''; }
.invoice-folder[open] > summary .invoice-folder-icon { background: linear-gradient(180deg, #6bd4f7 0%, #36b4e7 100%); }
.invoice-folder-count { padding: 4px 8px; border-radius: 999px; background: #e9f5fb; color: #17678e; font-size: 12px; font-weight: 700; white-space: nowrap; }
.invoice-folder-children { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-top: 8px; padding: 16px; border: 1px solid #dce9ef; border-radius: 16px; background: #f8fbfd; }
.invoice-archive-month > summary, .invoice-archive-week > summary { min-height: 142px; }
.invoice-archive-month .invoice-folder-icon, .invoice-archive-week .invoice-folder-icon { transform: scale(.9); }
.invoice-folder-files { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 8px; padding: 12px; border: 1px solid #dce9ef; border-radius: 14px; background: #fbfcfd; }
.invoice-browser-toolbar { display: flex; align-items: center; gap: 14px; grid-column: 1 / -1; min-height: 66px; padding: 10px 12px; border: 1px solid #dce7ed; border-radius: 14px; background: #fff; }
.invoice-browser-toolbar > div { display: grid; min-width: 0; gap: 3px; }
.invoice-browser-toolbar strong { font-size: 18px; overflow-wrap: anywhere; }
.invoice-browser-toolbar small { color: #64748b; overflow-wrap: anywhere; }
.invoice-browser-back { flex: 0 0 auto; }
.invoice-browser-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; grid-column: 1 / -1; align-items: start; min-height: 180px; padding: 16px; border: 1px solid #dce9ef; border-radius: 16px; background: #f8fbfd; }
.invoice-browser-folder, .invoice-browser-document { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; min-width: 0; min-height: 154px; padding: 13px 8px; border: 1px solid transparent; border-radius: 16px; background: transparent; color: #142433; text-align: center; box-shadow: none; }
.invoice-browser-folder:hover, .invoice-browser-document:hover { border-color: #cfe4ef; background: #eef8fc; color: #142433; transform: translateY(-2px); }
.invoice-browser-folder strong, .invoice-browser-document strong { display: -webkit-box; overflow: hidden; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-height: 1.25; }
.invoice-browser-folder small, .invoice-browser-document small { color: #607788; font-size: 12px; }
.invoice-browser-document { background: #fff; border-color: #dfe8ee; }
.invoice-document-icon { display: grid; place-items: center; width: 62px; height: 76px; border: 1px solid #aebdca; border-radius: 5px; background: linear-gradient(145deg, #fff 0 78%, #e8eef3 79%); color: #3d6f8b; font-size: 34px; box-shadow: 0 5px 10px rgba(49,74,90,.13); }
.invoice-browser-invoice-page { display: grid; grid-column: 1 / -1; gap: 16px; }
.invoice-browser-week-page { display: grid; grid-column: 1 / -1; gap: 22px; }
.invoice-browser-week-summary { display: grid; gap: 3px; padding: 13px 15px; border: 1px solid #cfe2eb; border-radius: 13px; background: #edf8fc; }
.invoice-browser-week-summary small { color: #587080; }
.invoice-browser-invoice-page { padding: 16px; border: 1px solid #d9e4ea; border-radius: 16px; background: #fff; }
.invoice-browser-invoice-page > h3 { margin: 0; padding-bottom: 10px; border-bottom: 1px solid #e4ebef; }
.invoice-original-preview { padding: 14px; border: 1px solid #dce5ed; border-radius: 14px; background: #f5f8fa; }
.invoice-original-preview h3 { margin: 0 0 12px; }
.invoice-original-pages { display: grid; gap: 18px; }
.invoice-original-pages figure { margin: 0; padding: 10px; border: 1px solid #d8e2e8; border-radius: 12px; background: #fff; text-align: center; }
.invoice-original-pages figure { scroll-margin-top: 22px; transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease; }
.invoice-original-pages figure.invoice-page-highlight { border-color: #0f8d83; background: #f0fbf9; box-shadow: 0 0 0 4px rgba(15,141,131,.18); }
.invoice-original-pages img { display: block; width: 100%; height: auto; max-height: none; border-radius: 7px; object-fit: contain; }
.invoice-original-pages iframe { display: block; width: 100%; min-height: 78vh; border: 0; border-radius: 7px; background: #fff; }
.invoice-original-pages figcaption { margin-top: 8px; color: #526879; font-weight: 700; }
.scanned-admin-list { display: grid; gap: 10px; }
.scanned-admin-card { padding: 13px; border: 1px solid #dce5ed; border-radius: 12px; background: #fff; }
.scanned-admin-card.needs_review, .scanned-admin-card.processing { border-color: #f2c56b; background: #fffdf5; }
.scanned-admin-card.reupload_requested { border-color: #f3a0a0; background: #fff8f8; }
.scanned-admin-card-main, .scanned-admin-facts, .scanned-admin-files { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.scanned-admin-facts { justify-content: flex-start; margin: 8px 0; color: #475569; }
.scanned-admin-facts span { padding: 5px 9px; background: #f1f5f9; border-radius: 999px; }
.scanned-admin-file { display: inline-flex; text-decoration: none; }
.scanned-invoice-review { display: grid; grid-template-columns: minmax(180px, 1.4fr) minmax(150px, .8fr) minmax(180px, 1.4fr) auto auto; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid #e5e7eb; }
.invoice-profile-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-top: 12px; }
.invoice-profile-list article { display: grid; gap: 4px; padding: 12px; border: 1px solid #dde5ed; border-radius: 12px; background: #fff; }
.invoice-profile-list article span, .invoice-profile-list article small { color: #64748b; }
.invoice-profile-modal-panel { max-height: calc(100dvh - 56px); overflow: hidden; }
.invoice-profile-modal-body { padding: 18px; overflow-y: auto; }
.invoice-profile-new-supplier { margin-bottom: 14px; padding: 12px 14px; border: 1px solid #cbdbe8; border-radius: 12px; background: #f8fbfd; }
.invoice-profile-new-supplier summary { color: #087f74; font-weight: 800; cursor: pointer; }
.invoice-profile-new-supplier-form { display: grid; grid-template-columns: minmax(240px, 1fr) auto; gap: 10px; align-items: end; margin-top: 12px; }
.invoice-profile-new-supplier-form label { display: grid; gap: 6px; }
.invoice-profile-new-supplier .product-meta { margin: 8px 0 0; }
.invoice-profile-sample-form { display: grid; grid-template-columns: minmax(200px, .8fr) minmax(260px, 1.4fr) auto; gap: 10px; align-items: center; }
@media (max-width: 900px) {
  .scanned-invoice-filters, .scanned-invoice-review { grid-template-columns: 1fr 1fr; }
  .scanned-invoice-review button { width: 100%; }
  .warehouse-invoice-upload-form { grid-template-columns: 1fr; }
  .warehouse-new-supplier-form { grid-template-columns: 1fr 1fr; }
  .invoice-profile-sample-form, .invoice-profile-new-supplier-form { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .scanned-invoice-filters, .scanned-invoice-review { grid-template-columns: 1fr; }
  .scanned-invoice-groups, .invoice-folder-children { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .invoice-folder > summary { min-height: 132px; padding: 11px 5px; }
  .invoice-folder[open] > summary { width: calc(50% - 5px); }
  .invoice-folder-heading { gap: 7px; }
  .invoice-folder-heading small { font-size: 11px; }
  .invoice-folder-icon { flex-basis: 50px; width: 66px; height: 50px; }
  .invoice-folder-icon::before { top: -8px; width: 29px; height: 11px; }
  .invoice-folder-count { padding: 4px 7px; font-size: 12px; }
  .invoice-folder-children { padding: 10px; }
  .invoice-archive-month > summary, .invoice-archive-week > summary { min-height: 128px; }
  .invoice-folder-files { grid-column: 1 / -1; }
  .invoice-browser-toolbar { align-items: flex-start; flex-direction: column; }
  .invoice-browser-back { width: 100%; }
  .invoice-browser-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; min-height: 140px; padding: 10px; }
  .invoice-browser-folder, .invoice-browser-document { min-height: 138px; padding-inline: 5px; }
  .invoice-document-icon { width: 54px; height: 66px; }
  .invoice-original-preview { padding: 8px; }
  .invoice-browser-invoice-page { padding: 8px; }
  .invoice-original-pages figure { padding: 5px; }
  .invoice-original-pages iframe { min-height: 68vh; }
  .scanned-admin-card { padding: 11px; }
  .warehouse-new-supplier-form { grid-template-columns: 1fr; }
}

#purchase-batches-view .split { grid-template-columns: minmax(0, 1fr); }
#back-to-purchase-batches { margin-bottom: 16px; }

.batch-demand-scroll { overflow-x: auto; }
.batch-demand-table { width: 100%; min-width: 760px; border-collapse: collapse; }
.batch-demand-table th, .batch-demand-table td { padding: 12px; vertical-align: top; border-bottom: 1px solid var(--line); }
.batch-demand-table th { white-space: nowrap; background: #f8fafc; }
.batch-demand-table .batch-number { white-space: nowrap; text-align: right; }
.batch-demand-table .table-image { width: 64px; height: 64px; object-fit: contain; }
.batch-store-details { margin-top: 8px; font-size: 13px; min-width: 190px; }
.batch-store-details summary { cursor: pointer; color: var(--primary); }

.batch-demand-table .batch-column-hidden { display: none !important; }
#batch-column-options:not(.hidden) { display: flex; flex-wrap: wrap; gap: 12px 20px; padding: 14px; background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; margin-top: 10px; }
#batch-column-options label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
#batch-column-options input { width: auto; }

/* Compact order review: essential values stay visible, metadata expands on demand. */
#order-detail-drawer #order-detail-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
#order-detail-summary .order-overview,
#order-detail-summary .order-metrics,
#order-detail-summary .order-more-info {
  background: #f8fafc;
  border: 1px solid #dbe3ec;
  border-radius: 10px;
  min-width: 0;
  padding: 12px;
}
#order-detail-summary .order-overview-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
#order-detail-summary .order-overview-heading > strong { font-size: 18px; overflow-wrap: anywhere; }
#order-detail-summary .order-overview p { color: #64748b; font-size: 13px; margin: 5px 0 0; }
#order-detail-summary .order-overview span { display: inline-block; margin: 0; }
#order-detail-summary .order-batch-link { border-top: 1px solid #e2e8f0; margin-top: 9px; padding-top: 8px; font-size: 13px; overflow-wrap: anywhere; }
#order-detail-summary .order-batch-link button { font-size: inherit; text-align: left; }
#order-detail-summary .order-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(110px, 1.4fr); padding: 10px 0; }
#order-detail-summary .order-metrics > div { min-width: 0; padding: 0 10px; border-right: 1px solid #dbe3ec; }
#order-detail-summary .order-metrics > div:last-child { border: 0; }
#order-detail-summary .order-metrics strong { display: block; font-size: 19px; line-height: 1.3; }
#order-detail-summary .order-metrics span { display: block; color: #64748b; font-size: 11px; margin: 3px 0 0; }
#order-detail-summary .order-metric-amount strong { color: #2563eb; }
#order-detail-summary .order-more-info { padding: 0; }
#order-detail-summary summary,
#order-detail-drawer .order-change-history-section > summary { cursor: pointer; padding: 12px; font-weight: 700; font-size: 14px; }
#order-detail-summary summary span { display: inline; color: #64748b; font-size: 12px; font-weight: 400; margin-left: 8px; }
#order-detail-summary .order-info-body { padding: 0 12px 10px; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
#order-detail-summary .order-info-body p { margin: 6px 0; }
#order-detail-summary .order-attention { background: #fff7ed; border: 1px solid #fed7aa; border-radius: 8px; padding: 10px 12px; margin: 0; font-size: 13px; overflow-wrap: anywhere; }
#order-detail-drawer .order-change-history-section { border: 1px solid #dbe3ec; border-radius: 10px; margin-top: 12px; }
#order-detail-drawer .order-change-history { padding: 0 12px 12px; }
#order-detail-drawer .order-items-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 8px; }
#order-detail-drawer .order-items-toolbar h3 { font-size: 16px; margin: 0; }
#order-detail-drawer #order-expand-all { display: none; font-size: 12px; padding: 7px 10px; min-height: 36px; }
#order-detail-drawer .order-item-search { display: block; margin: 0 0 10px; }
#order-detail-drawer .order-item-search > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
#order-detail-drawer .order-item-search input { width: 100%; min-height: 40px; margin: 0; font-size: 14px; }
#order-detail-drawer .order-item-toggle,
#order-detail-drawer .order-compact-unit { display: none; }
#order-detail-drawer .order-item-card[hidden] { display: none !important; }
@media screen and (max-width: 1180px) {
  #order-detail-drawer .detail-drawer-panel { width: 100%; height: 100dvh; }
  #order-detail-drawer .detail-drawer-header { min-height: 56px; padding: 10px 14px; gap: 8px; }
  #order-detail-drawer .detail-drawer-header h2 { font-size: 17px; line-height: 1.3; margin: 0; overflow-wrap: anywhere; }
  #order-detail-drawer .detail-drawer-header p { display: none; }
  #order-detail-drawer .detail-drawer-header button { flex-shrink: 0; width: 38px; height: 38px; min-height: 38px; padding: 0; }
  #order-detail-drawer .order-detail-content { padding: 12px; }
  #order-detail-drawer #order-expand-all { display: inline-block; }
  #order-detail-drawer .detail-table-wrap { border: 0; overflow: visible; }
  #order-detail-drawer .order-items-table,
  #order-detail-drawer .order-items-table tbody { display: block; width: 100%; min-width: 0; }
  #order-detail-drawer .order-items-table thead { display: none; }
  #order-detail-drawer .order-items-table tbody { display: grid; grid-template-columns: 1fr; gap: 10px; }
  #order-detail-drawer .order-items-table .order-item-card {
    display: grid; grid-template-columns: 60px minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "image name name" "image spec spec" "image fulfillment fulfillment" "price quantity total" "note note note" "toggle toggle toggle" "sku upc upc" "category supplier supplier" "unit unit unit";
    gap: 0; background: white; border: 1px solid #dbe3ec; border-radius: 10px; box-shadow: none; margin: 0; padding: 10px;
  }
  #order-detail-drawer .order-item-card > td { display: block; border: 0; min-width: 0; width: auto; text-align: left; padding: 3px 4px; font-size: 13px; overflow-wrap: anywhere; }
  #order-detail-drawer .order-items-table .order-item-card > td::before { content: attr(data-label); display: block; color: #64748b; font-size: 10px; line-height: 1.25; margin: 0 0 2px; font-weight: 400; }
  #order-detail-drawer .order-items-table .order-item-image { grid-area: image; padding: 0 6px 4px 0; }
  #order-detail-drawer .order-item-image .table-image { width: 52px; height: 60px; object-fit: contain; border-radius: 6px; }
  #order-detail-drawer .order-items-table .order-item-name { grid-area: name; padding-top: 0; }
  #order-detail-drawer .order-item-name strong { font-size: 14px; line-height: 1.4; }
  #order-detail-drawer .order-items-table .order-item-spec { grid-area: spec; font-size: 12px; color: #64748b; }
  #order-detail-drawer .order-compact-unit { display: inline; }
  #order-detail-drawer .order-items-table .order-item-fulfillment { grid-area: fulfillment; background: none; padding-top: 0; padding-bottom: 7px; font-size: 11px; color: #64748b; }
  #order-detail-drawer .order-item-price { grid-area: price; }
  #order-detail-drawer .order-item-quantity { grid-area: quantity; }
  #order-detail-drawer .order-items-table .order-item-total { grid-area: total; text-align: right; }
  #order-detail-drawer .order-item-total strong,
  #order-detail-drawer .order-item-quantity strong { font-size: 16px; color: #14283f; }
  #order-detail-drawer .order-items-table .order-item-note { grid-area: note; background: #f8fafc; border-radius: 5px; margin-top: 5px; }
  #order-detail-drawer .order-item-note.has-note::before { display: inline; margin-right: 6px; }
  #order-detail-drawer .order-items-table .order-item-toggle { display: block; grid-area: toggle; padding: 0; text-align: right; }
  #order-detail-drawer .order-item-toggle button { min-height: 36px; padding: 6px 0 0 10px; font-size: 12px; }
  #order-detail-drawer .order-item-image::before,
  #order-detail-drawer .order-item-name::before,
  #order-detail-drawer .order-item-spec::before,
  #order-detail-drawer .order-item-fulfillment::before,
  #order-detail-drawer .order-item-toggle::before { display: none !important; }
  #order-detail-drawer .order-items-table .order-item-sku { grid-area: sku; }
  #order-detail-drawer .order-items-table .order-item-upc { grid-area: upc; }
  #order-detail-drawer .order-items-table .order-item-category { grid-area: category; }
  #order-detail-drawer .order-items-table .order-item-supplier { grid-area: supplier; }
  #order-detail-drawer .order-items-table .order-item-unit { grid-area: unit; }
  #order-detail-drawer .order-item-card:not(.is-expanded) > .order-item-sku,
  #order-detail-drawer .order-item-card:not(.is-expanded) > .order-item-upc,
  #order-detail-drawer .order-item-card:not(.is-expanded) > .order-item-category,
  #order-detail-drawer .order-item-card:not(.is-expanded) > .order-item-supplier,
  #order-detail-drawer .order-item-card:not(.is-expanded) > .order-item-unit,
  #order-detail-drawer .order-item-card:not(.is-expanded) > .order-item-note:not(.has-note) { display: none; }
  #order-detail-drawer .order-item-card.is-expanded > .order-item-sku,
  #order-detail-drawer .order-item-card.is-expanded > .order-item-upc { border-top: 1px solid #e2e8f0; padding-top: 8px; }
  #order-detail-drawer .order-detail-footer { display: grid; gap: 10px; margin-top: 12px; padding-bottom: env(safe-area-inset-bottom); }
  #order-detail-drawer .detail-totals { gap: 6px 12px; font-size: 12px; padding: 10px; }
  #order-detail-drawer .order-footer-amount { color: #2563eb; }
  #order-detail-drawer .detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }
  #order-detail-drawer .detail-actions button { width: auto; flex: 1 1 auto; min-height: 40px; font-size: 13px; }
}
@media screen and (min-width: 768px) and (max-width: 1180px) {
  #order-detail-drawer .order-items-table tbody { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}
@media screen and (max-width: 380px) {
  #order-detail-summary .order-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 8px; }
  #order-detail-summary .order-metric-amount { grid-column: 1 / -1; border-top: 1px solid #dbe3ec; padding-top: 8px; }
  #order-detail-summary .order-metric-amount strong, #order-detail-summary .order-metric-amount span { display: inline; margin-right: 6px; }
}

/* Purchase shortages use the same product and allocation cards as adjustments. */
.purchase-shortage-toolbar .field-help { margin: 0; }
.purchase-shortage-toolbar .purchase-adjustment-search-field { margin: 12px 0 8px; }
.purchase-shortage-card.is-selected { border-color: var(--primary, #0f766e); }
.purchase-shortage-card .purchase-adjustment-product-details { overflow-wrap: anywhere; }
.purchase-shortage-card [data-handle-shortage] { flex-shrink: 0; }
.purchase-shortage-editor { border: 0; border-top: 1px solid var(--line); margin: 0; min-width: 0; padding: 16px; background: #f7fbfa; }
.purchase-shortage-editor legend { float: left; width: 100%; margin-bottom: 12px; font-weight: 700; }
.purchase-shortage-editor label { gap: 6px; }
.purchase-shortage-editor .required { display: inline; }
.purchase-shortage-editor .modal-actions { margin-top: 0; }
.purchase-shortage-empty-allocations { padding: 0 16px; }
.purchase-shortage-handled { padding: 10px 16px; background: #fff7ed; color: #9a3412; overflow-wrap: anywhere; }
#purchase-shortage-form > .modal-actions { position: sticky; bottom: -20px; background: #fff; padding: 14px 0 calc(34px + env(safe-area-inset-bottom, 0px)); margin: 0; border-top: 1px solid var(--line); z-index: 1; }
#purchase-shortage-save-status { margin: 0; }
@media (max-width: 640px) {
  .purchase-shortage-card .purchase-shortage-allocation-row { display: grid; grid-template-columns: minmax(0, 1fr) 70px 80px; gap: 8px; padding: 10px 12px; }
  .purchase-shortage-card .purchase-reserve-row { align-items: flex-start; flex-direction: column; gap: 8px; }
  .purchase-shortage-card .purchase-adjustment-total { text-align: left; justify-items: start; }
  .purchase-shortage-editor { padding: 12px; }
  #purchase-shortage-form > .modal-actions { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; }
  #purchase-shortage-form > .modal-actions button { padding: 12px 10px; }
}

[data-scanned-archive-order][aria-pressed="true"] { background: #0f766e; color: white; border-color: #0f766e; }

.invoice-department-filters {
  display: flex;
  grid-column: 1 / -1;
  flex-flow: row nowrap;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  margin: 12px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.invoice-department-filters > button { flex: 0 0 auto; width: auto; white-space: nowrap; }
[data-scanned-department][aria-pressed="true"] { background: #0f766e; color: white; border-color: #0f766e; }

/* Keep invoice management controls together above the document browser. */
:is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-invoice-admin-panel { display: grid; gap: 16px; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-archive-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-archive-header h2 { margin: 0 0 5px; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-archive-header p { margin: 0; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-archive-header .inline-actions { display: flex; gap: 8px; flex-wrap: wrap; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-invoice-filters { display: grid; grid-template-columns: minmax(130px, .8fr) minmax(220px, 2fr) minmax(150px, 1fr) minmax(170px, 1fr); align-items: end; gap: 12px; width: 100%; margin: 0; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-invoice-filters label { grid-column: auto; display: grid; gap: 6px; min-width: 0; font-size: 13px; color: #607080; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-invoice-filters :is(select, input) { width: 100%; min-width: 0; height: 42px; margin: 0; color: #1e293b; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-archive-meta { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid #e2e8f0; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-archive-order { display: flex; align-items: center; flex-wrap: nowrap; gap: 6px; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-archive-order span { font-size: 13px; white-space: nowrap; color: #607080; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-archive-order button { white-space: nowrap; min-height: 38px; padding: 8px 12px; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-invoice-summary { margin: 0; gap: 8px; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-invoice-summary > span { padding: 7px 10px; font-size: 13px; border-radius: 8px; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-invoice-groups { grid-template-columns: minmax(0, 1fr); gap: 12px; min-width: 0; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .invoice-browser-toolbar { margin: 0; padding: 8px 0; border: 0; background: transparent; min-height: 0; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .invoice-department-filters { margin: 0; padding-bottom: 4px; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .invoice-browser-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); background: transparent; padding: 0; border: 0; gap: 12px; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .invoice-browser-folder { background: #fff; border: 1px solid #dfe8ee; min-height: 140px; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .invoice-browser-folder:hover { border-color: #7ac6c0; background: #f1faf9; }
@media (max-width: 1000px) {
  :is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-invoice-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  :is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-invoice-admin-panel { gap: 12px; }
  :is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-archive-header { align-items: flex-start; gap: 10px; }
  :is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-archive-header .inline-actions { width: 100%; }
  :is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-archive-order button { padding: 8px; font-size: 13px; }
  :is(#scanned-invoices-view, #warehouse-invoices-view) .invoice-browser-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

:is(#scanned-invoices-view, #warehouse-invoices-view) .invoice-initial-filters { display: flex; grid-column: 1 / -1; flex-flow: row nowrap; align-items: center; gap: 5px; min-width: 0; width: 100%; overflow-x: auto; padding: 4px 0 8px; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .invoice-initial-filters > span { flex: 0 0 auto; margin-right: 5px; font-size: 13px; color: #607080; white-space: nowrap; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .invoice-initial-filters > button { flex: 0 0 auto; min-width: 32px; width: auto; min-height: 34px; padding: 6px 9px; white-space: nowrap; font-size: 13px; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .invoice-initial-filters > button[aria-pressed="true"] { background: #0f766e; color: #fff; border-color: #0f766e; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .invoice-initial-filters > button:disabled { opacity: .35; cursor: default; }

#invoice-profile-modal .invoice-company-filter-bar { display: flex; flex-flow: row nowrap; gap: 8px; min-width: 0; overflow-x: auto; padding: 4px 0; }
#invoice-profile-modal .invoice-company-filter-bar > button { flex: 0 0 auto; white-space: nowrap; width: auto; }
#invoice-profile-modal .invoice-company-filter-bar > button[aria-pressed="true"] { background: #0f766e; border-color: #0f766e; color: #fff; }

/* One scrollable toolbar keeps filtering, order and totals aligned. */
:is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-archive-controls { display: flex; align-items: flex-end; gap: 16px; width: 100%; min-width: 0; overflow-x: auto; padding-bottom: 14px; border-bottom: 1px solid #e2e8f0; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-archive-controls .scanned-invoice-filters { flex: 1 0 580px; width: auto; grid-template-columns: 100px minmax(180px, 1fr) 120px 150px; gap: 10px; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-archive-controls .scanned-archive-meta { flex: 0 0 auto; flex-wrap: nowrap; align-items: flex-end; gap: 12px; padding: 0; border: 0; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-archive-controls .scanned-archive-order { display: grid; grid-template-columns: repeat(2, auto); gap: 6px; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-archive-controls .scanned-archive-order > span { grid-column: 1 / -1; font-size: 13px; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-archive-controls .scanned-archive-order > button { height: 42px; min-height: 42px; padding: 8px 10px; font-size: 13px; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-archive-controls .scanned-invoice-summary { flex-wrap: nowrap; align-items: center; height: 42px; white-space: nowrap; gap: 6px; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-archive-controls .scanned-invoice-summary > span { padding: 6px 8px; font-size: 12px; }
:is(#scanned-invoices-view, #warehouse-invoices-view) :is(#scanned-invoice-month-filter, #warehouse-invoice-month-filter) { display: block; appearance: none; -webkit-appearance: none; box-sizing: border-box; height: 42px; min-height: 42px; padding: 8px 10px; line-height: 24px; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-archive-controls .scanned-invoice-filters { padding: 0; border: 0; background: transparent; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-archive-controls .scanned-invoice-filters :is(input, select) { min-height: 42px; height: 42px; }

#invoice-profile-modal .invoice-company-field { display: grid; gap: 6px; min-width: 0; }
#invoice-profile-modal #invoice-department-company[hidden] { display: none !important; }
#invoice-profile-modal #invoice-company-picker { width: 100%; min-height: 44px; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

:is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-archive-controls .scanned-invoice-filters { flex: 0 0 auto; grid-template-columns: 150px 260px 160px 180px; gap: 12px; }
:is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-archive-controls .scanned-archive-meta { flex: 1 0 auto; justify-content: space-between; }
[data-warehouse-archive-order][aria-pressed="true"], [data-warehouse-department][aria-pressed="true"] { background: #0f766e; color: #fff; border-color: #0f766e; }
.invoice-trash-icon { display: block; flex: 0 0 76px; width: 76px; height: 76px; object-fit: contain; margin: -9px 0; }
.invoice-shell .invoice-trash-icon { margin: 3px 0; }

.invoice-trash-actions { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin: 8px 0 18px; }
.invoice-trash-actions button { flex: 0 0 auto; }
.invoice-late-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; padding: 16px; margin: 18px 0; border: 1px solid #dce7ed; border-radius: 12px; background: #fff; }
.invoice-late-toolbar:empty { display: none; }
.invoice-late-toolbar.has-pending { border-color: #efc978; background: #fffbeb; }
.invoice-late-heading { display: grid; gap: 5px; }
.invoice-late-heading small { color: #64748b; }
.invoice-late-heading strong > span { display: inline-block; min-width: 24px; text-align: center; border-radius: 20px; background: #b45309; color: #fff; margin-left: 6px; padding: 2px 7px; }
[data-invoice-late-filter][aria-pressed="true"] { background: #0f766e; border-color: #0f766e; color: white; }
.invoice-late-badge { display: inline-block; padding: 5px 9px; border-radius: 6px; background: #fff0ce; color: #92400e; font-weight: 600; }
.invoice-late-badge.accounted { background: #e3f4ee; color: #16634e; }
.invoice-late-details { margin: 10px 0; padding: 12px; border-radius: 9px; background: #fffbeb; }
.invoice-accounting-history { margin: 8px 0; }
.invoice-late-list td { vertical-align: top; }
.invoice-late-list .inline-actions { gap: 8px; }

.invoice-late-toolbar .inline-actions, .invoice-late-list .inline-actions, .invoice-late-details > .inline-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.invoice-adjustment-editor { margin-top: 18px; padding: 14px; border: 1px solid #b8d9d4; border-radius: 10px; background: #fff; }
.invoice-adjustment-editor > summary { color: #0f766e; font-weight: 700; cursor: pointer; padding: 6px 0; }
.invoice-adjustment-editor > summary strong { display: inline-block; margin-left: 16px; }
.invoice-adjustment-editor form { display: grid; gap: 14px; min-width: 0; }
.invoice-adjustment-editor input:not([type="checkbox"]) { box-sizing: border-box; min-width: 90px; width: 100%; }
.invoice-adjustment-editor td:first-child input { min-width: 170px; }
.invoice-adjustment-editor input[readonly] { background: #f1f5f9; color: #64748b; }
.invoice-adjustment-editor textarea { width: 100%; min-height: 65px; box-sizing: border-box; }
.invoice-adjustment-fees { display: flex; flex-wrap: wrap; align-items: end; gap: 14px; }
.invoice-adjustment-fees label { display: grid; gap: 5px; flex: 0 1 230px; }
.invoice-adjustment-totals { padding: 12px; background: #edf7f5; border-radius: 8px; font-weight: 700; }
.invoice-adjustment-history { margin-top: 14px; }
.invoice-adjustment-history article { padding: 10px 0; border-bottom: 1px solid #e2e8f0; }
@media (max-width: 767px) { .invoice-adjustment-editor td input { min-width: 0 !important; } .invoice-adjustment-editor > summary strong { display: block; margin-left: 0; margin-top: 5px; } }

.invoice-adjustment-editor td label { display: inline-flex; align-items: center; gap: 6px; }
.invoice-adjustment-editor input[type="checkbox"] { width: 18px; height: 18px; min-width: 18px; padding: 0; margin: 0; flex: 0 0 18px; }

.invoice-late-modal-panel { width: min(1500px, 96vw); }
.invoice-late-modal-body { padding: 18px 22px; }
.invoice-late-modal-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.invoice-late-modal-selects { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.invoice-late-modal-selects label { display: grid; gap: 5px; flex: 1 1 180px; min-width: 0; }
.invoice-late-modal-selects :is(select,input) { width: 100%; box-sizing: border-box; min-width: 0; }
@media (max-width: 767px) { .invoice-late-modal-body { padding: 12px; } }

[data-late-folder-order][aria-pressed="true"] { background: #0f766e; border-color: #0f766e; color: white; }

/* The overflow menu scrolls as a regular page, independently of the fitted home launcher. */
#more-product-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 16px; }
#more-products-view .inline-header { flex-wrap: wrap; }
#more-products-view .inline-header > .nav-button { width: auto; }
#more-product-grid .dashboard-shortcut { min-height: 132px; }
@media (min-width: 1181px) {
  #more-product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.permissions-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.permission-module { min-width: 0; border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 8px; }
.permission-module legend { font-weight: 700; padding: 0 6px; }
.permission-group-toggle { display: flex; align-items: center; gap: 8px; font-weight: 700; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.permission-group-toggle input { width: 18px; min-height: 0; height: 18px; }
.permission-denied { display: none !important; }
@media (max-width: 599px) { .permissions-grid { grid-template-columns: minmax(0, 1fr); } }

#more-products-view .inline-header > .nav-button { color: var(--ink); background: #fff; border: 1px solid var(--line); }

#admin-user-modal { z-index: 20; }

/* Keep the preview and language controls together, without a stretched empty grid row. */
.settings-appearance-stack { display: contents; }
.settings-brand-preview { display: flex; align-items: start; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #f8fafc; }
.settings-brand-preview label { flex: 1; min-width: 0; }
.settings-brand-preview strong { font-size: 17px; }
.settings-brand-preview .brand-mark { flex-shrink: 0; }
.settings-preview-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.settings-preview-tags span { border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; font-size: 12px; background: #f8fafc; }
.settings-navigation-preview { border-top: 1px solid var(--line); padding-top: 14px; }
.settings-markup-details summary { cursor: pointer; font-weight: 700; }
.settings-markup-details summary .field-help { display: block; margin: 6px 0 0; font-weight: 400; }
.settings-markup-details > .product-meta { margin-top: 12px; }
@media (min-width: 1181px) {
  #settings-view .settings-appearance-stack { display: grid; grid-area: appearance; gap: 18px; align-content: start; min-width: 0; }
  #settings-view .settings-preview { min-height: 0; }
  #company-settings-form .home-shortcut-options { gap: 8px 14px; }
}
#more-product-grid .dashboard-shortcut { display: grid; align-content: start; gap: 12px; background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
#more-product-grid .dashboard-shortcut:hover { background: #f0fdfa; color: var(--ink); }
#more-product-grid .nav-icon { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: 12px; background: #e7f5f2; color: #087f74; }
#more-product-grid .nav-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; }
#more-product-grid .nav-copy { display: grid; gap: 6px; }
#more-product-grid .nav-copy strong { font-size: 17px; font-weight: 700; }
#more-product-grid .nav-copy small { display: block; color: var(--muted); font-size: 13px; }

.settings-desktop-tabs { display: none; }
.admin-users-table td { vertical-align: middle; }
.admin-permissions-cell > span { display: block; white-space: nowrap; }
.admin-permission-detail-button { background: none; border: 0; color: var(--blue); padding: 4px 0; min-height: 0; font-size: 13px; }
.admin-permission-details-content { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 20px; }
.admin-permission-detail-group { border: 1px solid var(--line); border-radius: 10px; padding: 14px; min-width: 0; }
.admin-permission-detail-group h3 { margin: 0 0 10px; font-size: 15px; }
.admin-permission-detail-group ul { margin: 0; padding-left: 20px; line-height: 1.8; font-size: 14px; }
#admin-permission-details-modal { z-index: 20; }
@media (max-width: 599px) { .admin-permission-details-content { grid-template-columns: minmax(0, 1fr); padding: 14px; } }
@media (min-width: 1181px) and (pointer: fine), (min-width: 1401px) {
  .settings-desktop-tabs { display: flex; gap: 6px; padding: 6px; margin-bottom: 18px; background: #e9eef1; border-radius: 12px; width: fit-content; }
  .settings-desktop-tabs button { background: transparent; color: var(--muted); border: 0; border-radius: 8px; padding: 10px 18px; }
  .settings-desktop-tabs button.active { background: #fff; color: var(--accent); box-shadow: 0 2px 6px #17252a12; font-weight: 700; }
  #settings-view[data-desktop-settings-tab=system] [data-desktop-settings-content=display],
  #settings-view[data-desktop-settings-tab=system] .settings-preview,
  #settings-view[data-desktop-settings-tab=display] [data-desktop-settings-content=system],
  #settings-view[data-desktop-settings-tab=display] #personal-language-form,
  #settings-view:not([data-desktop-settings-tab=admins]) #admin-users-section { display: none; }
  #settings-view[data-desktop-settings-tab=admins] #company-settings-form,
  #settings-view[data-desktop-settings-tab=admins] .settings-appearance-stack { display: none; }
  #settings-view[data-desktop-settings-tab=admins] .settings-grid { display: block; }
  #admin-users-section .inline-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
  #admin-users-section .inline-header h2 { margin: 0; }
  #admin-users-section .inline-header p { margin: 6px 0 0; }
  .admin-users-table { min-width: 880px; }
  .admin-users-table th, .admin-users-table td { padding: 14px 12px; }
}

.settings-desktop-tabs:not(:has(button:not(.hidden))) { display: none; }
