:root {
  font:
    15px/1.5 "Asap",
    system-ui,
    sans-serif;
  color: #172b4d;
  background: #f5f7fb;
  --accent: #2563eb;
  --line: #e2e8f0;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select,
textarea {
  font: inherit;
}
button {
  border: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 7px;
  cursor: pointer;
}
button:hover {
  filter: brightness(0.92);
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
.secondary {
  background: #f1f5f9;
  color: #172b4d;
}
.danger {
  background: #a93636;
}
input,
select,
textarea {
  padding: 9px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #172b4d;
  max-width: 100%;
}
input[type="number"] {
  width: 105px;
}
input[type="checkbox"] {
  width: auto;
}
textarea {
  width: 100%;
  min-height: 75px;
}
label {
  display: grid;
  gap: 5px;
  margin: 12px 0;
}
header {
  background: #13213a;
  color: white;
  padding: 18px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
}
header strong {
  font-size: 23px;
  letter-spacing: 2px;
}
header span {
  font-size: 13px;
  color: #cbd5e1;
}
nav {
  display: flex;
  gap: 8px;
  padding: 12px 28px;
  background: white;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
nav button {
  background: transparent;
  color: #52627a;
  white-space: nowrap;
}
nav button.active {
  background: #eff6ff;
  color: var(--accent);
}
main {
  max-width: 1500px;
  margin: 0 auto;
  padding: 28px;
}
h1 {
  font-size: 28px;
  line-height: 1.2;
  margin: 0 0 8px;
}
h2 {
  font-size: 20px;
  margin-top: 0;
}
p {
  color: #64748b;
}
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 20px 0;
}
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
  margin-bottom: 20px;
}
.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin: 25px 0;
}
.metric strong {
  display: block;
  font-size: 30px;
}
.metric span {
  color: #64748b;
  font-size: 13px;
}
.table-wrap {
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
  font-size: 14px;
}
th {
  text-align: left;
  background: #f8fafc;
  font-size: 12px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
th,
td {
  padding: 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
}
td.name {
  white-space: normal;
  min-width: 230px;
}
td small {
  display: block;
  color: #64748b;
}
td button {
  padding: 5px 10px;
  font-size: 12px;
}
.badge {
  display: inline-block;
  background: #eff6ff;
  color: #1d4ed8;
  border-radius: 5px;
  padding: 3px 7px;
  font-size: 12px;
  margin: 2px;
}
.warn {
  background: #fff0ce;
  color: #8a5c12;
}
.error {
  background: #fbe3df;
  color: #9c3126;
}
.muted {
  color: #64748b;
}
.login {
  max-width: 430px;
  margin: 12vh auto;
  padding: 30px;
}
.login button {
  width: 100%;
  margin-top: 12px;
}
.login .brand {
  color: var(--accent);
  font-weight: 800;
  font-size: 28px;
  letter-spacing: 3px;
}
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.notice {
  padding: 12px 16px;
  background: #fdf2d9;
  border: 1px solid #eddaac;
  border-radius: 8px;
  margin: 14px 0;
}
dialog {
  border: 1px solid var(--line);
  border-radius: 12px;
  width: min(1150px, 95vw);
  max-height: 90vh;
  padding: 24px;
}
dialog::backdrop {
  background: #13213a66;
}
.close {
  float: right;
  margin-bottom: 15px;
}
#modal-content {
  clear: both;
}
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  max-width: min(550px, 90vw);
  z-index: 100;
  background: #1e3a5f;
  color: white;
  border-radius: 8px;
  padding: 14px 20px;
  display: none;
  box-shadow: 0 5px 30px #0002;
}
#toast.visible {
  display: block;
}
pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 12px;
  max-width: 600px;
}
a {
  color: var(--accent);
}
.empty {
  text-align: center;
  padding: 35px;
  color: #64748b;
}
.steps {
  color: #64748b;
  font-size: 13px;
}
.full {
  width: 100%;
}
.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
}
footer {
  font-size: 12px;
  color: #64748b;
  padding: 24px 0;
}
@media (max-width: 760px) {
  header {
    padding: 16px;
  }
  header span {
    display: none;
  }
  main {
    padding: 16px;
  }
  nav {
    padding: 8px;
  }
  .metrics {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .grid {
    grid-template-columns: 1fr;
  }
  .card {
    padding: 16px;
  }
  h1 {
    font-size: 23px;
  }
  th,
  td {
    padding: 9px;
  }
}
@media print {
  body {
    background: white;
  }
  #app,
  #toast,
  #close-modal,
  .toolbar.actions {
    display: none !important;
  }
  dialog {
    position: static;
    max-height: none;
    width: 100%;
    border: 0;
    padding: 0;
  }
  dialog::backdrop {
    background: none;
  }
  input {
    border: 0;
    padding: 0;
  }
  table {
    white-space: normal;
  }
}
.bulk-panel {
  background: #f0f5ff;
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 20px;
}
.bulk-panel .actions {
  align-items: end;
}
.bulk-panel small {
  color: #64748b;
}
.edited-row {
  background: #fff9e9;
}
.product-error {
  color: #a93636;
  white-space: normal;
  min-width: 170px;
}
.product-name {
  display: block;
  width: 100%;
  min-width: 240px;
  margin-top: 6px;
}
.product-savebar {
  position: sticky;
  bottom: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  box-shadow: 0 -4px 20px #172b4d0a;
}
.product-savebar .muted {
  font-size: 12px;
}
@media (max-width: 760px) {
  .product-savebar {
    flex-wrap: wrap;
  }
  .bulk-panel .actions {
    align-items: start;
  }
}
.transfer-picker {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 16px;
  margin: 16px 0;
  background: #f8fafc;
}
.transfer-picker summary {
  font-weight: 650;
  cursor: pointer;
}
.transfer-picker input[type="search"] {
  width: min(420px, 100%);
}
.transfer-picker .table-wrap {
  max-height: 330px;
  overflow: auto;
}
.transfer-picker th {
  position: sticky;
  top: 0;
}
.transfer-picker input[type="checkbox"] {
  cursor: pointer;
}
.transfer-picker .toolbar > span {
  font-size: 13px;
  color: #64748b;
}
/* Keep the product settings layout independent of shared form and table rules. */
.product-management,
.product-management .product-workspace,
.product-management .product-workspace > * {
  min-width: 0;
  max-width: 100%;
}
.product-management label {
  margin: 0;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
}
.product-management button {
  min-height: 42px;
  white-space: normal;
  line-height: 1.35;
}
.product-filters {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  margin-bottom: 24px;
  align-items: end;
}
.product-filters input,
.product-filters select,
.product-management .bulk-settings-grid input {
  width: 100%;
  min-width: 0;
  height: 44px;
  font-weight: 400;
}
.product-management .bulk-panel {
  padding: 20px;
  border: 1px solid #e2e8f0;
}
.bulk-panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.bulk-panel-heading h2 {
  margin: 0 0 4px;
  font-size: 17px;
}
.bulk-panel-heading p,
.product-management .bulk-help {
  margin: 0;
  font-size: 13px;
  white-space: normal;
}
.selection-count {
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  overflow-wrap: anywhere;
  max-width: 100%;
}
.bulk-settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.7fr);
  align-items: end;
  gap: 16px;
}
.bulk-settings-grid > * {
  min-width: 0;
}
.bulk-settings-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.bulk-settings-actions button {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  overflow-wrap: anywhere;
}
.product-management .bulk-help {
  margin-top: 16px;
  color: #64748b;
}
.product-management .table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.product-management table {
  min-width: 1304px;
  table-layout: fixed;
  white-space: normal;
}
.product-management th:nth-child(1) {
  width: 44px;
}
.product-management th:nth-child(2) {
  width: 180px;
}
.product-management th:nth-child(3) {
  width: 320px;
}
.product-management th:nth-child(4),
.product-management th:nth-child(5) {
  width: 90px;
}
.product-management th:nth-child(6),
.product-management th:nth-child(7) {
  width: 150px;
}
.product-management th:nth-child(8) {
  width: 180px;
}
.product-management .product-sku {
  font-family: "Asap", system-ui, sans-serif;
  font-size: 12px;
  color: var(--muted, #64748b);
  overflow-wrap: anywhere;
  line-height: 1.6;
}
.product-management textarea.product-name {
  box-sizing: border-box;
  display: block;
  margin: 0;
  padding: 10px 12px;
  min-height: 68px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: inherit;
  font: inherit;
  line-height: 1.5;
  resize: vertical;
}
.product-management textarea.product-name:focus {
  outline: 2px solid #2563eb;
  outline-offset: 1px;
}
.product-management tbody td {
  vertical-align: top;
}
.product-management .product-name,
.product-management td input[type="number"] {
  width: 100%;
  min-width: 0;
}
.product-management .product-error {
  min-width: 0;
  overflow-wrap: anywhere;
}
.product-management td:nth-child(4),
.product-management td:nth-child(5) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.product-management .product-savebar {
  z-index: 5;
  gap: 16px;
  flex-wrap: wrap;
  bottom: 12px;
}
.product-savebar > div:first-child {
  min-width: 0;
  flex: 1 1 280px;
}
.product-management .product-savebar .actions {
  flex: 0 0 auto;
}
@media (max-width: 1050px) {
  .bulk-settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .bulk-settings-actions {
    grid-column: 1 / -1;
  }
}
@media (max-width: 640px) {
  .product-filters {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .product-management .bulk-panel {
    padding: 16px;
  }
  .bulk-settings-grid,
  .bulk-settings-actions {
    grid-template-columns: 1fr;
  }
  .product-management .product-savebar {
    bottom: 0;
    padding: 16px;
  }
  .product-management .product-savebar .actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    flex-basis: 100%;
  }
}
.product-management {
  width: 100%;
  max-width: 1500px;
}

/* Keep source management usable without horizontal scrolling on phones. */
.source-management,
.source-layout > *,
.source-item > div {
  min-width: 0;
}
.source-management {
  width: 100%;
  max-width: 1200px;
}
.source-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}
.source-layout .card {
  margin: 0;
}
.source-heading p {
  margin: 8px 0 20px;
}
.source-editor {
  align-self: start;
  scroll-margin-top: 16px;
}
.source-management input,
.source-management select,
.source-management button {
  width: 100%;
  min-height: 44px;
  min-width: 0;
}
.source-management input,
.source-management select {
  font-size: 16px;
}
.source-management input[readonly] {
  background: #f5f7fb;
  color: #52627a;
}
.source-help {
  font-size: 13px;
  margin: 16px 0;
}
.source-form-actions,
.source-filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}
.source-list-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.source-list-heading h2 {
  margin: 0;
}
.source-filters {
  margin: 16px 0;
}
.source-filters label {
  margin: 0;
}
.source-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.source-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}
.source-item h3 {
  margin: 0 0 8px;
  font-size: 15px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.source-location {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  background: #f1f5f9;
  color: #2563eb;
  font-size: 13px;
}
.source-management .source-item button {
  width: auto;
  min-width: 52px;
}
@media (min-width: 600px) {
  .source-filters {
    grid-template-columns: minmax(0, 1fr) minmax(0, 180px);
  }
  .source-form-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (min-width: 1000px) {
  .source-layout {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.4fr);
    gap: 24px;
  }
}
@media (max-width: 760px) {
  header {
    flex-wrap: wrap;
  }
  header > div {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  nav {
    display: none;
  }
  button {
    min-height: 44px;
  }
  input:not([type="checkbox"]),
  select,
  textarea {
    font-size: 16px;
  }
}

/* Primary actions stay within thumb reach on phones. */
.mobile-bottom-nav {
  display: none;
}
.mobile-menu {
  width: min(480px, 100%);
  max-width: 100%;
  max-height: 85dvh;
  margin: auto auto 0;
  border-radius: 20px 20px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
}
.mobile-menu-heading,
.history-event-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.mobile-menu-heading h2 {
  margin: 0;
}
.mobile-menu-links {
  display: grid;
  gap: 8px;
  margin-top: 20px;
}
.mobile-menu-links button {
  display: flex;
  justify-content: space-between;
  text-align: left;
  min-height: 52px;
}
.mobile-menu-links button.active {
  background: #2563eb;
  color: #fff;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.product-history h2,
.history-sku {
  overflow-wrap: anywhere;
}
.history-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(125px, 1fr));
  gap: 10px;
  margin: 20px 0;
}
.history-summary > div {
  display: grid;
  gap: 4px;
  padding: 12px;
  background: #eff6ff;
  border-radius: 8px;
}
.history-summary strong {
  font-size: 22px;
}
.history-summary span,
.history-meta {
  font-size: 13px;
  color: #64748b;
}
.product-history select {
  width: 100%;
  min-height: 44px;
}
.history-events {
  list-style: none;
  padding: 0;
  margin: 16px 0;
}
.history-event {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
  overflow-wrap: anywhere;
}
.history-event-heading {
  align-items: start;
  flex-wrap: wrap;
}
.history-qty {
  font-weight: 700;
  color: var(--accent);
}
.history-route {
  color: #172b4d;
  font-weight: 600;
  margin: 10px 0;
}
.history-balances {
  display: grid;
  gap: 8px;
  background: #f5f7fb;
  padding: 12px;
  border-radius: 8px;
}
.history-balances > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.history-balances small {
  display: inline;
}
.product-management .product-history-button {
  display: block;
  margin-top: 10px;
  font-family: "Asap", system-ui, sans-serif;
}
@media (max-width: 760px) {
  #app:has(.mobile-bottom-nav) {
    padding-bottom: calc(78px + env(safe-area-inset-bottom));
  }
  .mobile-bottom-nav {
    position: fixed;
    z-index: 20;
    inset: auto 0 0;
    display: flex;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: #fff;
    border-top: 1px solid var(--line);
    box-shadow: 0 -4px 16px #172b4d0a;
  }
  .mobile-bottom-nav button {
    flex: 1;
    min-width: 0;
    min-height: 60px;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 4px;
    padding: 6px 2px;
    background: transparent;
    color: #64748b;
    font-size: 12px;
  }
  .mobile-bottom-nav svg {
    width: 23px;
    height: 23px;
  }
  .mobile-bottom-nav .active {
    background: #eff6ff;
    color: var(--accent);
    font-weight: 700;
  }
  .product-management .product-savebar {
    bottom: calc(78px + env(safe-area-inset-bottom));
  }
  #toast {
    bottom: calc(90px + env(safe-area-inset-bottom));
    right: 16px;
  }
  dialog:not(.mobile-menu) {
    width: calc(100% - 16px);
    max-width: calc(100% - 16px);
    max-height: 92dvh;
    padding: 16px;
  }
}
@media print {
  .mobile-bottom-nav,
  .mobile-menu {
    display: none !important;
  }
}

.mobile-menu-settings {
  margin-top: 20px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.mobile-menu-settings summary {
  padding: 12px 4px;
  min-height: 48px;
  font-weight: 600;
  cursor: pointer;
}
.mobile-menu-settings p {
  font-size: 13px;
  margin: 0 0 12px;
}
.mobile-menu-settings .mobile-menu-links {
  margin-top: 0;
}

/* Desktop navigation shares the same task groups as the phone menu. */
.app-shell {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  align-items: start;
  min-height: calc(100dvh - 80px);
}
.app-shell > main {
  width: 100%;
  min-width: 0;
  align-self: start;
}
.desktop-sidebar {
  display: block;
  position: sticky;
  top: 0;
  max-height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 12px;
  background: #fff;
  border: 0;
  border-right: 1px solid var(--line);
}
.sidebar-group {
  margin-bottom: 24px;
}
.sidebar-title {
  margin: 0 12px 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #64748b;
  text-transform: uppercase;
}
.desktop-sidebar button {
  display: block;
  width: 100%;
  min-height: 44px;
  margin: 3px 0;
  padding: 10px 12px;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.4;
}
.desktop-sidebar button.active {
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}
.sidebar-settings {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.sidebar-settings summary {
  padding: 12px;
  min-height: 44px;
  color: #52627a;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.sidebar-settings-links {
  margin-top: 6px;
}
@media (min-width: 761px) and (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 200px minmax(0, 1fr);
  }
  .app-shell > main {
    padding: 20px;
  }
}
@media (max-width: 760px) {
  .app-shell {
    display: block;
  }
  .desktop-sidebar {
    display: none;
  }
}

/* Blue accents and a quiet shell keep dense warehouse screens readable. */
.app-header {
  min-height: 76px;
  padding: 14px 28px;
  background: #fff;
  color: #172b4d;
  border-bottom: 1px solid var(--line);
}
.app-brand,
.app-account {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.app-header .app-brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 12px;
  background: #2563eb;
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  box-shadow: 0 3px 8px #2563eb1a;
}
.app-brand strong {
  font-size: 18px;
  letter-spacing: 1px;
}
.app-header .app-brand strong span {
  display: inline;
  color: #64748b;
  font-size: 16px;
  font-weight: 500;
}
.app-brand small,
.account-details small {
  display: block;
  color: #64748b;
  font-size: 12px;
  margin-top: 2px;
}
.app-header .account-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: #1d4ed8;
  background: #eff6ff;
  font-size: 14px;
  font-weight: 700;
}
.app-header .account-details strong {
  display: block;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  letter-spacing: 0;
}
.app-header .account-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: #52627a;
  margin-left: 8px;
}
.app-header .account-logout span {
  display: inline;
  color: inherit;
  font-size: 13px;
}
.account-logout svg,
.desktop-sidebar button svg,
.sidebar-footer svg {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
}
.app-shell {
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: calc(100dvh - 76px);
}
.desktop-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 28px 16px 18px;
  min-height: calc(100dvh - 76px);
}
.sidebar-title {
  font-size: 10px;
  letter-spacing: 1.2px;
  color: #7b879b;
  margin: 0 12px 10px;
}
.sidebar-group {
  margin-bottom: 26px;
}
.desktop-sidebar button {
  display: flex;
  align-items: center;
  gap: 11px;
  border-radius: 9px;
  color: #52627a;
  min-height: 45px;
  font-size: 13px;
  font-weight: 500;
  transition:
    background 120ms ease,
    color 120ms ease;
}
.desktop-sidebar button svg {
  color: #8491a5;
}
.desktop-sidebar button:hover {
  background: #f5f7fb;
  color: #172b4d;
  filter: none;
}
.desktop-sidebar button.active {
  background: #eff6ff;
  color: #1d4ed8;
  box-shadow: none;
  font-weight: 650;
}
.desktop-sidebar button.active svg {
  color: #2563eb;
}
.sidebar-current-dot {
  flex: 0 0 5px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #2563eb;
  margin-left: auto;
}
.sidebar-settings {
  border-top: 1px solid #edf1f7;
}
.sidebar-settings summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  list-style: none;
  color: #64748b;
  font-size: 12px;
}
.sidebar-settings summary::-webkit-details-marker {
  display: none;
}
.sidebar-settings summary svg {
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
  transition: transform 120ms ease;
}
.sidebar-settings[open] summary svg {
  transform: rotate(90deg);
}
.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 36px 8px 0;
}
.sidebar-footer-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #f1f5f9;
  color: #94a3b8;
}
.sidebar-footer strong,
.sidebar-footer div > span {
  display: block;
  font-size: 10px;
  font-weight: 500;
  color: #64748b;
}
.sidebar-footer div > span {
  color: #94a3b8;
  margin-top: 3px;
}
.app-shell > main {
  padding: 28px 32px;
}
button:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 3px;
}
@media (min-width: 761px) and (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 208px minmax(0, 1fr);
  }
  .app-shell > main {
    padding: 24px;
  }
  .desktop-sidebar {
    padding-inline: 12px;
  }
}
@media (max-width: 760px) {
  .app-header {
    padding: 12px 16px;
    min-height: 68px;
    gap: 8px;
    flex-wrap: nowrap;
  }
  .app-header .app-brand-mark {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
    border-radius: 10px;
    font-size: 19px;
  }
  .app-brand,
  .app-account {
    gap: 8px;
  }
  .app-brand strong {
    font-size: 15px;
  }
  .app-header .app-brand strong span {
    font-size: 13px;
  }
  .app-brand small {
    font-size: 10px;
  }
  .app-header .account-avatar,
  .account-details small,
  .app-header .account-logout span {
    display: none;
  }
  .app-header .account-details strong {
    max-width: 80px;
    font-size: 12px;
  }
  .app-header .account-logout {
    padding: 9px;
    margin: 0;
    min-width: 40px;
    min-height: 44px;
  }
  .app-shell > main {
    padding: 20px 16px;
  }
  .desktop-sidebar {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .desktop-sidebar button,
  .sidebar-settings summary svg {
    transition: none;
  }
}

/* Transfer forms keep one set of fields across desktop and phone layouts. */
.transfer-select-all {
  display: none;
}
.transfer-card-select label {
  margin: 0;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.transfer-card-select label > span {
  display: none;
}
.transfer-primary-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px solid var(--line);
}
.transfer-primary-actions > span {
  margin-right: auto;
  font-size: 13px;
  color: #64748b;
}
.transfer-secondary-actions {
  margin: 20px 0;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.transfer-secondary-actions summary {
  cursor: pointer;
  padding: 10px 0;
  font-weight: 600;
}
.transfer-secondary-actions .actions {
  margin-top: 12px;
}
@media (max-width: 760px) {
  dialog.transfer-dialog {
    inset: 0;
    margin: 0;
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
    padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
    overflow-y: auto;
  }
  .transfer-dialog #close-modal {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #f1f5f9;
    min-height: 44px;
  }
  .transfer-dialog h2 {
    font-size: 21px;
    overflow-wrap: anywhere;
  }
  .transfer-dialog input:not([type="checkbox"]),
  .transfer-dialog select,
  .transfer-dialog textarea {
    width: 100%;
    min-width: 0;
    min-height: 48px;
    font-size: 16px;
  }
  .transfer-responsive .table-wrap {
    overflow: visible;
  }
  .transfer-responsive table,
  .transfer-responsive tbody {
    display: block;
    min-width: 0;
    white-space: normal;
  }
  .transfer-responsive thead {
    display: none;
  }
  .transfer-responsive tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
  }
  .transfer-responsive td {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0;
    min-width: 0;
    border: 0;
    overflow-wrap: anywhere;
  }
  .transfer-responsive td[data-label]::before {
    content: attr(data-label);
    color: #64748b;
    font-size: 12px;
    line-height: 1.5;
  }
  .transfer-responsive td.transfer-card-title,
  .transfer-responsive td.transfer-card-action,
  .transfer-responsive td.transfer-note,
  .transfer-responsive td.transfer-quantity,
  .transfer-responsive td.empty {
    grid-column: 1 / -1;
    min-width: 0;
  }
  .transfer-card-title strong {
    font-size: 15px;
    line-height: 1.5;
  }
  .transfer-responsive td button {
    min-height: 44px;
    font-size: 14px;
    width: 100%;
  }
  .transfer-responsive td input[type="number"] {
    font-size: 18px;
  }
  .transfer-card-select {
    grid-column: 1 / -1;
  }
  .transfer-card-select label > span {
    display: inline;
    font-size: 13px;
  }
  .transfer-dialog input[type="checkbox"] {
    width: 22px;
    height: 22px;
    accent-color: var(--accent);
  }
  .transfer-pick-row:has(input:checked) {
    background: #eff6ff;
    border-color: #93b4fa;
  }
  #transfer-picker-results {
    display: flex;
    flex-direction: column;
  }
  .transfer-select-all {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    font-size: 13px;
    order: -1;
  }
  .transfer-picker {
    padding: 12px;
  }
  .transfer-picker .toolbar {
    margin: 12px 0;
  }
  .transfer-picker .toolbar > input,
  .transfer-picker .toolbar > label,
  .transfer-picker .toolbar > .actions {
    width: 100%;
  }
  .transfer-picker .actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    gap: 8px;
  }
  .transfer-picker .actions button {
    padding: 10px;
    font-size: 14px;
  }
  .transfer-picker .transfer-responsive .table-wrap {
    max-height: 45dvh;
    overflow-y: auto;
    overflow-x: hidden;
  }
  .transfer-picker .transfer-responsive tbody tr {
    padding: 12px;
  }
  .transfer-primary-actions {
    position: sticky;
    bottom: calc(-16px - env(safe-area-inset-bottom));
    z-index: 3;
    margin: 20px -16px -16px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: #fff;
    box-shadow: 0 -6px 20px #172b4d0a;
    gap: 8px;
  }
  .transfer-primary-actions > span {
    width: 100%;
  }
  .transfer-primary-actions button {
    flex: 1;
    min-height: 48px;
    padding-inline: 12px;
  }
  .transfer-secondary-actions .actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .transfer-management > .toolbar .actions {
    width: 100%;
  }
  .transfer-management #new-transfer {
    flex: 1;
  }
}
@media print {
  .transfer-primary-actions,
  .transfer-secondary-actions,
  .transfer-select-all {
    display: none !important;
  }
}
.transfer-list-filters {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 12px;
}
.transfer-list-filters label {
  margin: 0;
}
.transfer-list-filters input,
.transfer-list-filters select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
}
@media (max-width: 760px) {
  .transfer-list-filters {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Counting uses native form cards instead of changing table layout on phones. */
dialog.counting-dialog[open] {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 52px minmax(0, 1fr);
  width: min(800px, calc(100vw - 32px));
  height: min(900px, 90dvh);
  max-height: 90dvh;
  padding: 0;
  overflow: hidden;
  border-radius: 16px;
  background: #f5f7fb;
}
.counting-dialog::before {
  content: "Điều chuyển";
  grid-area: 1 / 1;
  align-self: center;
  padding-left: 20px;
  font-size: 14px;
  font-weight: 600;
  color: #52627a;
}
.counting-dialog #close-modal {
  grid-area: 1 / 1;
  justify-self: end;
  align-self: center;
  position: static;
  float: none;
  width: auto;
  min-height: 36px;
  margin: 0 12px;
  padding: 7px 12px;
  font-size: 13px;
  background: #e9eef6;
}
.counting-dialog #modal-content {
  grid-area: 2 / 1;
  clear: none;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 20px 20px;
  overscroll-behavior: contain;
}
.counting-header {
  padding: 12px 0 20px;
  min-width: 0;
}
.counting-eyebrow {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.1px;
  margin: 0 0 8px;
  color: #64748b;
}
.counting-header h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.counting-route {
  margin: 10px 0;
  color: #172b4d;
  font-size: 14px;
  line-height: 1.6;
}
.counting-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  font-size: 12px;
  color: #64748b;
  overflow-wrap: anywhere;
}
.counting-reason {
  margin: 12px 0 0;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.counting-guide {
  padding: 14px;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  background: #eff6ff;
  font-size: 13px;
}
.counting-guide strong {
  color: #1d4ed8;
}
.counting-guide p {
  margin: 6px 0 0;
  line-height: 1.6;
}
.counting-help {
  margin: 10px 0 18px;
  font-size: 13px;
  color: #64748b;
}
.counting-help summary,
.counting-note summary {
  min-height: 44px;
  padding: 12px 0;
  cursor: pointer;
}
.counting-help p {
  margin-top: 0;
}
.counting-items {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}
.counting-card {
  min-width: 0;
  padding: 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.counting-card-heading {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.counting-index {
  display: grid;
  place-items: center;
  width: 26px;
  min-height: 26px;
  border-radius: 8px;
  font-size: 12px;
  color: #64748b;
  background: #f1f5f9;
}
.counting-card-status {
  font-size: 11px;
  color: #94a3b8;
}
.counting-card h3 {
  margin: 0 0 6px;
  font-size: 16px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.counting-sku {
  margin: 0;
  font-size: 12px;
  color: #64748b;
  overflow-wrap: anywhere;
}
.counting-planned {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
  padding: 12px;
  border-radius: 8px;
  background: #f5f7fb;
}
.counting-planned > span {
  color: #64748b;
  font-size: 12px;
}
.counting-planned strong {
  font-size: 20px;
  line-height: 1.2;
  color: #172b4d;
}
.counting-planned small {
  font-size: 11px;
  font-weight: 400;
  color: #64748b;
}
.counting-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}
.counting-fields label {
  min-width: 0;
  margin: 0;
  gap: 7px;
  font-size: 13px;
  font-weight: 500;
  color: #52627a;
}
.counting-dialog .counting-fields input {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 50px;
  padding: 12px;
  font-size: 18px;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}
.counting-fields input::placeholder {
  font-size: 14px;
  color: #94a3b8;
}
.counting-fields input:disabled {
  background: #f5f7fb;
  opacity: 1;
  color: #52627a;
}
.counting-note {
  margin-top: 12px;
  font-size: 12px;
  color: #64748b;
}
.counting-note textarea {
  width: 100%;
  min-width: 0;
  font-size: 16px;
  resize: vertical;
}
.counting-card.is-filled .counting-card-status {
  color: #2563eb;
}
.counting-card.is-mismatched {
  border-color: #e7bd66;
}
.counting-card.is-mismatched .counting-card-status {
  color: #8a5c12;
}
.counting-dialog .transfer-secondary-actions {
  margin: 18px 0 0;
  border-top: 0;
  font-size: 13px;
}
.counting-dialog .transfer-primary-actions {
  position: sticky;
  bottom: 0;
  margin: 12px 0 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 -4px 20px #172b4d0a;
}
.counting-dialog .transfer-primary-actions > span {
  width: 100%;
  font-size: 12px;
}
.counting-dialog .transfer-primary-actions button {
  flex: 1 1 140px;
  min-width: 0;
  min-height: 48px;
}
@media screen and (min-width: 761px) {
  dialog.counting-dialog[open] {
    width: min(1040px, calc(100vw - 48px));
  }
  .counting-card {
    display: grid;
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 2fr);
    grid-template-areas:
      "heading heading"
      "name name"
      "sku sku"
      "planned fields"
      "note note";
    column-gap: 20px;
  }
  .counting-card-heading {
    grid-area: heading;
  }
  .counting-card h3 {
    grid-area: name;
  }
  .counting-sku {
    grid-area: sku;
  }
  .counting-planned {
    grid-area: planned;
    align-self: end;
    min-height: 50px;
    margin: 16px 0 0;
  }
  .counting-fields {
    grid-area: fields;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
    margin-top: 16px;
  }
  .counting-note {
    grid-area: note;
  }
}
@media (max-width: 760px) {
  dialog.counting-dialog[open] {
    inset: 0;
    margin: 0;
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }
  .counting-dialog #modal-content {
    padding: 4px 16px calc(16px + env(safe-area-inset-bottom));
  }
  .counting-dialog::before {
    padding-left: 16px;
  }
  .counting-card {
    padding: 16px;
  }
}
@media print {
  dialog.counting-dialog[open] {
    display: block;
    height: auto;
    max-height: none;
    width: 100%;
    overflow: visible;
    background: #fff;
  }
  .counting-dialog::before,
  .counting-guide,
  .counting-help,
  .counting-card-status {
    display: none;
  }
  .counting-dialog #modal-content {
    overflow: visible;
    padding: 0;
  }
  .counting-items {
    grid-template-columns: minmax(0, 1fr);
  }
  .counting-card {
    break-inside: avoid;
  }
}

.transfer-suggestions {
  padding: 18px;
  margin: 16px 0;
  border: 1px solid #cfe0ff;
  border-radius: 12px;
  background: #f0f5ff;
}
.transfer-suggestions h3 {
  margin: 0 0 8px;
  font-size: 16px;
}
.transfer-suggestions p,
.transfer-suggestions > small {
  font-size: 13px;
  line-height: 1.6;
  color: #52627a;
}
.transfer-suggestion-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 14px 0;
}
.transfer-suggestions summary {
  padding: 10px 0;
  min-height: 44px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
#transfer-suggestions-list {
  padding: 0;
  margin: 0 0 12px;
  list-style: none;
  max-height: 320px;
  overflow-y: auto;
}
#transfer-suggestions-list li {
  padding: 12px 0;
  border-top: 1px solid #dbe5f6;
  overflow-wrap: anywhere;
}
#transfer-suggestions-list strong,
#transfer-suggestions-list small {
  display: block;
}
#transfer-suggestions-list p {
  margin: 6px 0 0;
}
.transfer-stock-badge {
  display: inline-block;
  max-width: 100%;
  width: fit-content;
  margin-top: 6px;
  padding: 3px 8px;
  border-radius: 5px;
  background: #fff0ce;
  color: #8a5c12;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.5;
  white-space: normal;
}
.counting-sku .transfer-stock-badge {
  display: block;
}
@media (max-width: 760px) {
  .transfer-suggestions {
    padding: 14px;
  }
  .transfer-suggestion-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }
  .transfer-suggestion-actions button {
    min-height: 48px;
    width: 100%;
    white-space: normal;
  }
}
