:root {
  --paper: #f7f4ed;
  --ink: #182321;
  --muted: #64706b;
  --line: #d8d1c4;
  --field: #fffdf8;
  --cedar: #274c43;
  --cedar-2: #37695d;
  --copper: #b96233;
  --gold: #d4a017;
  --danger: #b3261e;
  --shadow: 0 18px 50px rgba(24, 35, 33, 0.12);
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.workspace {
  background: rgba(255, 253, 248, 0.92);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  width: clamp(280px, 52vw, 640px);
  height: auto;
  flex: 0 1 auto;
  object-fit: contain;
}

.brand-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--copper);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.16;
}

.maker {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.access-control-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin: 18px 0;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--field);
}

.access-control-option input {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.access-control-option span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.tab,
.button {
  border: 1px solid var(--cedar);
  background: var(--field);
  color: var(--cedar);
  min-height: 40px;
  padding: 0 14px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
}

.tab.active,
.button.primary {
  background: var(--cedar);
  color: #ffffff;
}

.button.warn {
  border-color: var(--copper);
  color: var(--copper);
}

button:disabled,
.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.view {
  display: none;
  padding: 24px;
}

.view.active {
  display: block;
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}

.panel {
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.82);
  border-radius: 8px;
  padding: 18px;
}

.span-4 {
  grid-column: span 4;
}

.span-8 {
  grid-column: span 8;
}

.span-12 {
  grid-column: span 12;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  color: var(--ink);
  padding: 0 10px;
}

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

.item-picker {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 140px minmax(120px, 180px) auto;
  gap: 12px;
  align-items: end;
}

.search-box {
  position: relative;
}

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

.item-search-actions {
  display: flex;
  gap: 8px;
  align-items: end;
  flex-wrap: wrap;
}

.item-scan-button,
.item-photo-button {
  min-width: 96px;
  white-space: nowrap;
}

.suggestions {
  position: absolute;
  z-index: 20;
  width: 100%;
  top: calc(100% + 6px);
  left: 0;
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  box-shadow: var(--shadow);
}

.suggestion {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}

.suggestion:hover {
  background: rgba(212, 160, 23, 0.15);
}

.suggestion[aria-selected="true"] {
  background: rgba(45, 212, 191, 0.2);
  outline: 2px solid #5eead4;
  outline-offset: -2px;
}

.item-scanner-dialog {
  width: min(560px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid #4e7595;
  border-radius: 8px;
  background: #0d1c30;
  color: #f3f8fc;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.52);
  overscroll-behavior: contain;
}

.item-scanner-dialog::backdrop {
  background: rgba(2, 8, 18, 0.78);
  backdrop-filter: blur(3px);
}

.item-scanner-content {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 16px;
}

.item-scanner-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  margin: -16px -16px 0;
  padding: 16px;
  border-bottom: 1px solid #34536f;
  background: #0d1c30;
}

.item-scanner-header h3,
.item-scanner-header p {
  margin: 0;
}

.item-scanner-reader {
  width: 100%;
  min-height: clamp(160px, 42dvh, 320px);
  max-height: 52dvh;
  overflow: hidden;
  border: 1px solid #34536f;
  border-radius: 6px;
  background: #020b16;
}

.item-scanner-reader :is(video, canvas, img) {
  display: block;
  max-width: 100% !important;
  max-height: 52dvh !important;
  object-fit: contain;
}

.material-card-dialog {
  width: min(920px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid #4e7595;
  border-radius: 8px;
  background: #0d1c30;
  color: #f3f8fc;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.52);
  overscroll-behavior: contain;
}

.material-card-dialog::backdrop {
  background: rgba(2, 8, 18, 0.78);
  backdrop-filter: blur(3px);
}

.material-card-content {
  display: grid;
  gap: 16px;
  min-width: 0;
  padding: 16px;
}

.material-card-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  margin: -16px -16px 0;
  padding: 16px;
  border-bottom: 1px solid #34536f;
  background: #0d1c30;
}

.material-card-header :is(h3, p) {
  margin: 0;
}

.material-card-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 16px;
}

.material-card-photo-panel,
.material-card-result-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
}

.material-card-preview-frame {
  display: grid;
  min-height: min(280px, 38dvh);
  place-items: center;
  overflow: hidden;
  border: 1px solid #34536f;
  border-radius: 6px;
  background: #020b16;
}

.material-card-preview {
  display: block;
  width: 100%;
  max-height: 52dvh;
  object-fit: contain;
}

.material-card-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.material-card-actions #recognize-material-card {
  grid-column: 1 / -1;
}

.material-card-recognized-text {
  max-width: 100%;
  max-height: 180px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid #34536f;
  border-radius: 6px;
  background: #061221;
  color: #d9e8f5;
  font-family: Consolas, "Courier New", monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.material-card-candidates {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.material-card-candidate {
  display: grid;
  width: 100%;
  min-width: 0;
  gap: 4px;
  padding: 12px;
  text-align: left;
  overflow-wrap: anywhere;
  border: 1px solid #416783;
  border-radius: 6px;
  background: #112944;
  color: #f3f8fc;
  cursor: pointer;
}

.material-card-candidate:is(:hover, :focus-visible) {
  border-color: #19e6d2;
  background: #153751;
  outline: none;
}

.material-card-candidate-name {
  color: #f3f8fc;
  font-weight: 700;
}

.material-card-candidate-meta,
.material-card-empty {
  margin: 0;
  color: #b8ccdc;
}

@media (max-width: 760px), (max-height: 520px) {
  .material-card-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .material-card-preview-frame {
    min-height: min(180px, 28dvh);
  }

  .material-card-preview {
    max-height: 32dvh;
  }
}

.submission-confirmation-dialog {
  width: min(860px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--cedar-2);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(24, 35, 33, 0.3);
  overscroll-behavior: contain;
}

.submission-confirmation-dialog::backdrop {
  background: rgba(24, 35, 33, 0.72);
  backdrop-filter: blur(3px);
}

.submission-confirmation-body {
  display: grid;
  gap: 16px;
  min-width: 0;
  padding: 20px;
}

.submission-dialog-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  background: inherit;
}

.submission-dialog-header :is(h3, p),
.submission-success-state :is(h3, p) {
  margin: 0;
}

.submission-summary-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.submission-summary-meta > div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
}

.submission-summary-meta span {
  color: var(--muted);
  font-size: 13px;
}

.submission-summary-totals {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding: 10px 12px;
  border-left: 4px solid var(--cedar);
  background: rgba(39, 76, 67, 0.08);
}

.submission-summary-lines {
  display: grid;
  gap: 8px;
  max-height: min(38dvh, 360px);
  overflow: auto;
  overscroll-behavior: contain;
}

.submission-summary-line {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
}

.submission-summary-line > div {
  display: grid;
  gap: 3px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.submission-warning {
  padding: 12px;
  border: 1px solid #b6871d;
  border-radius: 6px;
  background: #fff8df;
  color: #5d4509;
}

.submission-warning.danger {
  border-color: var(--danger);
  background: #fff0ef;
  color: #7e1c17;
}

.submission-warning :is(p, ul) {
  margin: 6px 0 0;
}

.submission-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--cedar-2);
  border-radius: 6px;
  background: rgba(55, 105, 93, 0.1);
  color: var(--cedar);
}

.submission-progress-spinner {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  border: 3px solid rgba(39, 76, 67, 0.22);
  border-top-color: var(--cedar);
  border-radius: 50%;
  animation: submission-progress-spin 0.8s linear infinite;
}

.submission-confirmation-actions,
.submission-success-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.submission-confirmation-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin: 0 -4px -4px;
  padding: 12px 4px 4px;
  border-top: 1px solid var(--line);
  background: #0d1c30;
}

.submission-confirmation-actions .button {
  min-width: min(100%, 240px);
  margin-left: auto;
}

.submission-success-state {
  display: grid;
  gap: 18px;
}

@keyframes submission-progress-spin {
  to {
    transform: rotate(360deg);
  }
}

.code {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-weight: 800;
  color: var(--cedar);
}

code {
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(39, 76, 67, 0.08);
  font-family: "Cascadia Mono", Consolas, monospace;
}

.selected-item {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: rgba(255, 253, 248, 0.7);
  color: var(--muted);
}

.stock-warning {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(185, 28, 28, 0.35);
  border-radius: 6px;
  background: rgba(254, 226, 226, 0.78);
  color: #b91c1c;
  font-weight: 800;
  animation: stock-warning-blink 1s step-end infinite;
}

.stock-warning strong,
.stock-warning span {
  display: block;
}

.stock-warning.muted,
.stock-warning.error {
  animation: none;
}

@keyframes stock-warning-blink {
  50% {
    opacity: 0.28;
  }
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.report-section summary {
  cursor: pointer;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  list-style-position: inside;
}

.report-section[open] summary {
  margin-bottom: 12px;
}

.storage-area-filter {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.storage-area-filter-label {
  color: var(--ink);
  font-weight: 800;
}

.storage-area-filter-picker {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 253, 248, 0.7);
}

.storage-area-filter-picker > summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  cursor: pointer;
  list-style: none;
  color: var(--ink);
  font-weight: 800;
}

.storage-area-filter-picker > summary::-webkit-details-marker {
  display: none;
}

.storage-area-filter-picker > summary::after {
  content: "+";
  margin-left: auto;
  color: var(--accent);
  font-size: 20px;
  line-height: 1;
}

.storage-area-filter-picker[open] > summary::after {
  content: "−";
}

.storage-area-filter-menu {
  display: grid;
  gap: 10px;
  padding: 0 12px 12px;
  border-top: 1px solid var(--line);
}

.storage-area-filter-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding-top: 10px;
}

.storage-area-filter-toolbar input {
  min-width: 0;
}

.storage-area-filter-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.storage-area-filter-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.62);
  cursor: pointer;
}

.storage-area-filter-option input {
  width: 18px;
  min-width: 18px;
  height: 18px;
  margin: 0;
}

.storage-area-filter-option span,
.storage-area-filter-option small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.storage-area-filter-option small {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.storage-area-filter-empty {
  margin: 0;
  color: var(--muted);
}

.empty-state {
  margin: 0;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: rgba(255, 253, 248, 0.65);
  color: var(--muted);
}

.qty-cell {
  max-width: 120px;
}

.storage-area-cell {
  max-width: 160px;
}

.line-table .line-action-cell {
  white-space: nowrap;
}

.admin-inline-editor-row > td {
  padding: 0;
  background: rgba(255, 253, 248, 0.86);
}

.inline-admin-editor {
  padding: 16px;
  border-top: 2px solid rgba(39, 76, 67, 0.28);
}

.admin-submission-preview-row > td {
  padding-top: 0;
  background: rgba(248, 251, 247, 0.74);
}

.admin-submission-item-preview {
  display: grid;
  gap: 6px;
  padding: 8px 0 12px;
}

.admin-submission-preview-item {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(180px, 1fr) minmax(90px, 130px) minmax(80px, 120px);
  gap: 8px;
  align-items: center;
  font-size: 0.92rem;
  color: var(--muted);
}

.item-admin-section > summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  cursor: pointer;
  list-style: none;
}

.item-admin-section > summary::-webkit-details-marker {
  display: none;
}

.item-admin-section > summary::after {
  content: "+";
  margin-left: auto;
  color: var(--accent);
  font-size: 24px;
  line-height: 1;
}

.item-admin-section[open] > summary::after {
  content: "−";
}

.item-admin-section-title {
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
}

.item-admin-section-content {
  padding-top: 12px;
}

.cross-storage-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.cross-storage-controls label,
.cross-storage-controls input {
  min-width: 0;
}

.cross-storage-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.cross-storage-item {
  min-width: 0;
  border: 1px solid #416783;
  border-radius: 6px;
  background: #0d1c30;
  overflow: clip;
}

.cross-storage-item > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 52px;
  padding: 12px;
  cursor: pointer;
  list-style: none;
}

.cross-storage-item > summary::-webkit-details-marker {
  display: none;
}

.cross-storage-item > summary::after {
  content: "+";
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  margin-left: 4px;
  color: #65f1df;
  font-size: 22px;
}

.cross-storage-item[open] > summary::after {
  content: "−";
}

.cross-storage-item-summary,
.cross-storage-item-identity,
.cross-storage-item-totals {
  min-width: 0;
}

.cross-storage-item-identity,
.cross-storage-item-totals {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  align-items: center;
  overflow-wrap: anywhere;
}

.cross-storage-item-totals {
  grid-column: 2;
  grid-row: 1;
  justify-content: flex-end;
  padding-right: 28px;
  white-space: nowrap;
}

.cross-storage-count,
.cross-storage-kind {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid #3f8f91;
  border-radius: 999px;
  background: #103a4b;
  color: #c8fff7 !important;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.cross-storage-consolidate-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 12px;
  min-width: 0;
  margin: 0 12px 12px;
  padding: 12px;
  border: 1px solid #3f8f91;
  border-left: 3px solid #65f1df;
  border-radius: 6px;
  background: #0e2a40;
}

.cross-storage-consolidate-copy,
.cross-storage-consolidate-form,
.cross-storage-consolidate-form label,
.cross-storage-consolidate-form input {
  min-width: 0;
}

.cross-storage-consolidate-copy strong {
  color: #d8f8ff;
}

.cross-storage-consolidate-copy p {
  margin: 6px 0 0;
  color: #9fc0cf;
  font-size: 0.84rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.cross-storage-consolidate-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: 10px;
  align-items: end;
}

.cross-storage-consolidate-form label {
  display: grid;
  gap: 6px;
}

.cross-storage-consolidate-form input {
  width: 100%;
}

.cross-storage-consolidate-actions {
  display: flex;
  min-width: 0;
}

.cross-storage-consolidate-actions .button {
  width: 100%;
  white-space: normal;
}

.cross-storage-consolidate-form > .status {
  grid-column: 1 / -1;
  margin: 0;
}

.cross-storage-area-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: 8px;
  padding: 0 12px 12px;
}

@media (max-width: 720px) {
  .cross-storage-consolidate-panel {
    grid-template-columns: minmax(0, 1fr);
  }
}

.cross-storage-area-card {
  min-width: 0;
  border: 1px solid #31536e;
  border-radius: 6px;
  background: #112944;
  overflow-wrap: anywhere;
}

.cross-storage-area-heading,
.cross-storage-location {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  padding: 10px;
}

.cross-storage-area-heading {
  border-bottom: 1px solid #31536e;
}

.cross-storage-area-heading > span {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
  min-width: 0;
}

.cross-storage-location + .cross-storage-location {
  border-top: 1px solid rgba(65, 103, 131, 0.55);
}

.cross-storage-location span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.cross-storage-area-heading > strong,
.cross-storage-location > strong {
  flex: 0 0 auto;
  white-space: nowrap;
}

.cross-storage-source-lines {
  border-top: 1px solid #31536e;
  background: #0d2138;
}

.cross-storage-source-lines > summary,
.cross-storage-source-line > summary {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
  padding: 10px;
  cursor: pointer;
  list-style: none;
}

.cross-storage-source-lines > summary::-webkit-details-marker,
.cross-storage-source-line > summary::-webkit-details-marker {
  display: none;
}

.cross-storage-source-lines > summary::after,
.cross-storage-source-line > summary::after {
  content: "+";
  flex: 0 0 auto;
  margin-left: auto;
  color: #65f1df;
  font-size: 20px;
  line-height: 1;
}

.cross-storage-source-lines[open] > summary::after,
.cross-storage-source-line[open] > summary::after {
  content: "−";
}

.cross-storage-source-lines > summary span {
  color: #d8f8ff;
  font-weight: 800;
}

.cross-storage-source-lines > summary small {
  min-width: 0;
  color: #8fb8ca;
  overflow-wrap: anywhere;
}

.cross-storage-source-results {
  min-width: 0;
  padding: 0 10px 10px;
}

.cross-storage-source-results > .empty-state,
.cross-storage-source-results > .status {
  margin: 0;
}

.cross-storage-source-list {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.cross-storage-source-line {
  min-width: 0;
  border: 1px solid #31536e;
  border-radius: 5px;
  background: #102a45;
  overflow: clip;
}

.cross-storage-source-line > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

.cross-storage-source-line > summary::after {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
}

.cross-storage-source-document,
.cross-storage-source-values {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  align-items: center;
  min-width: 0;
  overflow-wrap: anywhere;
}

.cross-storage-source-document small {
  color: #9fc0cf;
}

.cross-storage-source-document,
.cross-storage-source-values {
  grid-column: 1;
  justify-content: flex-start;
}

.cross-storage-source-document {
  grid-row: 1;
}

.cross-storage-source-values {
  grid-row: 2;
  color: #d8f8ff;
}

.cross-storage-source-values strong {
  white-space: nowrap;
}

.cross-storage-source-editor {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: 10px;
  min-width: 0;
  padding: 10px;
  border-top: 1px solid #31536e;
  background: #0c1d31;
}

.cross-storage-source-editor > * {
  min-width: 0;
}

.cross-storage-source-editor label {
  display: grid;
  align-content: start;
  gap: 6px;
}

.cross-storage-source-editor input {
  width: 100%;
  min-width: 0;
}

.cross-storage-source-note,
.cross-storage-source-actions,
.cross-storage-source-editor > .status {
  grid-column: 1 / -1;
  margin: 0;
}

.cross-storage-source-note {
  color: #9fc0cf;
  font-size: 0.84rem;
  line-height: 1.45;
}

.cross-storage-source-readonly {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid #31536e;
  border-radius: 4px;
  background: #091827;
  color: #d8f8ff;
  overflow-wrap: anywhere;
}

.cross-storage-source-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-search-submission-list,
.admin-search-line-list {
  display: grid;
  min-width: 0;
}

.admin-search-submission-list {
  gap: 12px;
}

.admin-search-submission-card {
  min-width: 0;
  border: 1px solid #416783;
  border-radius: 8px;
  background: #0d1c30;
  box-shadow: 0 12px 28px rgba(2, 10, 20, 0.18);
  overflow: clip;
}

.admin-search-submission-header,
.admin-search-line-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 12px 14px;
}

.admin-search-submission-header {
  border-bottom: 1px solid #416783;
  background: #112944;
}

.admin-search-submission-meta {
  display: grid;
  gap: 3px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.admin-search-submission-meta strong {
  font-size: 1rem;
}

.admin-search-submission-meta span,
.admin-search-line-heading span {
  color: #9fc0cf;
  font-size: 0.84rem;
}

.admin-search-submission-download {
  flex: 0 0 auto;
  white-space: nowrap;
}

.admin-search-submission-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.admin-search-inline-editor {
  margin: 0 12px 12px;
}

.admin-search-line-heading {
  padding-block: 9px;
  border-bottom: 1px solid rgba(65, 103, 131, 0.72);
  background: #0d2138;
}

.admin-search-line-heading > * {
  min-width: 0;
  overflow-wrap: anywhere;
}

.admin-search-line-list {
  gap: 10px;
  padding: 12px;
}

.admin-search-line-card {
  display: grid;
  grid-template-columns: minmax(180px, 1.15fr) minmax(280px, 1fr) auto;
  grid-template-areas:
    "identity fields actions"
    "note note note"
    "status status status";
  gap: 10px 14px;
  align-items: start;
  min-width: 0;
  padding: 12px;
  border: 1px solid #31536e;
  border-radius: 6px;
  background: #102a45;
}

.admin-search-line-card > *,
.admin-search-line-identity,
.admin-search-line-fields,
.admin-search-line-fields label {
  min-width: 0;
}

.admin-search-line-identity {
  display: grid;
  grid-area: identity;
  align-content: start;
  gap: 4px;
  overflow-wrap: anywhere;
}

.admin-search-line-number {
  width: fit-content;
  max-width: 100%;
  padding: 2px 7px;
  border: 1px solid #416783;
  border-radius: 999px;
  background: #091827;
  color: #8ff7e8 !important;
  font-size: 0.75rem;
  font-weight: 800;
}

.admin-search-line-identity small {
  color: #9fc0cf !important;
}

.admin-search-line-fields {
  display: grid;
  grid-area: fields;
  grid-template-columns: minmax(100px, 0.65fr) minmax(170px, 1fr);
  gap: 10px;
}

.admin-search-line-fields label {
  display: grid;
  align-content: start;
  gap: 6px;
}

.admin-search-line-fields input {
  width: 100%;
  min-width: 0;
}

.admin-search-line-note,
.admin-search-line-card > .status {
  margin: 0;
  overflow-wrap: anywhere;
}

.admin-search-line-note {
  grid-area: note;
  color: #9fc0cf !important;
  font-size: 0.82rem;
  line-height: 1.45;
}

.admin-search-line-actions {
  display: grid;
  grid-area: actions;
  gap: 8px;
  align-self: end;
}

.admin-search-line-actions .button {
  width: 100%;
  min-width: 116px;
  white-space: nowrap;
}

.admin-search-line-card > .status {
  grid-area: status;
}

#admin-submission-status:empty,
#admin-clear-status:empty,
.admin-search-line-card > .status:empty {
  display: none;
}

.duplicate-audit {
  margin-top: 16px;
}

.duplicate-group {
  margin-top: 14px;
  border: 1px solid rgba(190, 50, 42, 0.32);
  border-radius: 6px;
  background: rgba(255, 241, 238, 0.62);
  overflow-x: auto;
}

.duplicate-group-title {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid rgba(190, 50, 42, 0.22);
}

.duplicate-row {
  background: rgba(255, 226, 220, 0.82);
}

.duplicate-row:hover {
  background: rgba(255, 211, 202, 0.92);
}

.option-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 14px;
}

.option-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.option-table input {
  min-width: 110px;
}

.option-table .actions {
  min-width: 150px;
}

.option-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 4px 8px 4px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
}

.option-pill button {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--field);
}

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

th {
  background: var(--cedar);
  color: #ffffff;
  font-size: 13px;
}

.summary-pivot-table {
  min-width: max-content;
}

.summary-pivot-table th:nth-child(1),
.summary-pivot-table td:nth-child(1) {
  min-width: 130px;
}

.summary-pivot-table th:nth-child(2),
.summary-pivot-table td:nth-child(2) {
  min-width: 180px;
}

.summary-pivot-table th:nth-child(n + 5),
.summary-pivot-table td:nth-child(n + 5) {
  min-width: 120px;
  text-align: right;
  white-space: nowrap;
}

/* QUERY_RESULT_SCROLL_SURFACE: keep every row and wide column reachable. */
.report-table-scroll {
  width: 100%;
  max-width: 100%;
  max-height: min(70vh, 720px);
  overflow: auto !important;
  overscroll-behavior: contain;
  scrollbar-gutter: stable both-edges;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
}

.report-table-scroll > table {
  width: max-content;
  min-width: 100%;
}

#transactions-table > table {
  min-width: 1180px;
}

.report-table-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 3;
}

.report-table-scroll:focus-visible {
  outline: 3px solid var(--copper);
  outline-offset: 2px;
}

.status {
  min-height: 24px;
  color: var(--cedar);
  font-weight: 700;
}

.status.error {
  color: var(--danger);
}

.status.warning {
  color: var(--copper);
}

.pdf-preview {
  width: 100%;
  min-height: 72vh;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
}

.pdf-preview.empty-state {
  display: grid;
  place-items: center;
}

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

@media (max-width: 1180px) {
  .item-entry-workbench > :is(.item-metadata, .item-picker-workbench) {
    grid-column: span 12;
  }
}

@media (min-width: 1181px) and (max-width: 1280px) {
  .item-search-field-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .item-search-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .item-scan-button,
  .item-photo-button {
    width: 100%;
    min-width: 0;
    white-space: normal;
  }
}

@media (max-width: 860px) {
  .app-shell {
    padding: 10px;
  }

  .topbar {
    align-items: center;
  }

  .brand {
    align-items: center;
    gap: 10px;
  }

  .brand-logo {
    width: min(100%, 420px);
  }

  .brand-copy {
    min-width: 0;
  }

  .view {
    padding: 16px;
  }

  .item-picker {
    grid-template-columns: 1fr;
  }

  .section-heading {
    align-items: stretch;
  }

  .section-heading .button {
    width: 100%;
  }

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

  .span-4,
  .span-8,
  .span-12 {
    grid-column: span 12;
  }

  table {
    display: block;
    overflow-x: auto;
  }

  #recent-submissions td:has(a[href]) {
    position: sticky;
    right: 0;
    z-index: 2;
    background: var(--item-surface-raised);
    box-shadow: -10px 0 12px rgba(5, 9, 20, 0.42);
  }

  #recent-submissions td:has(a[href]) a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    min-width: 44px;
  }

  .responsive-lines {
    display: block;
    border-collapse: separate;
    background: transparent;
    overflow: visible;
  }

  .responsive-lines thead {
    display: none;
  }

  .responsive-lines tbody {
    display: grid;
    gap: 12px;
  }

  .responsive-lines tr {
    display: grid;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--field);
    overflow: hidden;
  }

  .responsive-lines td {
    display: grid;
    grid-template-columns: minmax(82px, 34%) minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
  }

  .responsive-lines td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
  }

  .responsive-lines td:last-child {
    border-bottom: 0;
  }

  .responsive-lines .qty-cell,
  .responsive-lines .storage-area-cell {
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  .responsive-lines .line-action-cell {
    display: block;
  }

  .responsive-lines .line-action-cell::before {
    display: none;
  }

  .responsive-lines .line-action-cell .button {
    width: 100%;
  }

  .pdf-preview {
    min-height: 62vh;
  }
}

.print-frame {
  position: fixed;
  width: 0;
  height: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

/* Aceternity UI layer */
:root {
  --paper: #f6f8fb;
  --ink: #16202e;
  --muted: #60717d;
  --line: #dbe5e7;
  --field: #ffffff;
  --cedar: #0f766e;
  --cedar-2: #0a5c56;
  --copper: #a45f10;
  --shadow: 0 18px 45px rgba(14, 33, 45, 0.08);
}

body {
  background: var(--paper);
}

.workspace,
.panel,
.selected-item,
.suggestions,
.modal,
.document-preview,
.table-card {
  border-color: var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.panel {
  position: relative;
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: rgba(15, 118, 110, 0.48);
}

.button.primary {
  border-color: var(--cedar);
  background: var(--cedar-2);
  box-shadow: 0 12px 22px rgba(15, 118, 110, 0.16);
}

.button {
  border-radius: 8px;
}

.button:not(.primary):hover {
  border-color: var(--cedar);
  background: #e4f7f3;
  color: var(--cedar-2);
}

input,
select {
  border-color: #b9cdd0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
}

input:focus,
select:focus {
  border-color: var(--cedar);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
  outline: none;
}

.status {
  border-radius: 999px;
}

/* Tech industry Aceternity layer */
:root {
  --paper: #f5f8fb;
  --ink: #111c2d;
  --muted: #607083;
  --line: #cfdae5;
  --field: #ffffff;
  --cedar: #00a6b2;
  --cedar-2: #007d8c;
  --copper: #d99012;
  --gold: #2f6fed;
  --shadow: 0 18px 46px rgba(7, 18, 33, 0.12);
  font-variant-numeric: tabular-nums;
}

body {
  background: #eef4f8;
}

.topbar {
  background: #0b2436;
  color: #eef9fb;
  border-color: rgba(159, 180, 199, 0.34);
  box-shadow: 0 18px 50px rgba(6, 18, 33, 0.18);
}

.topbar h1,
.topbar .maker,
.topbar .eyebrow {
  color: #eef9fb;
}

.workspace,
.panel,
.selected-item,
.suggestions,
.modal,
.document-preview,
.table-card {
  background: #f7fbfc;
  border-color: rgba(159, 180, 199, 0.5);
}

.panel::before {
  height: 2px;
  background: var(--cedar);
}

.button.primary {
  background: var(--cedar-2);
  box-shadow: 0 12px 24px rgba(0, 166, 178, 0.2);
}

.button:not(.primary):hover {
  background: #e8fbfd;
  color: #006f7b;
}

table th,
.responsive-lines th {
  background: #edf5f8;
  color: #24364b;
  font-size: 12px;
  text-transform: uppercase;
}

/* Aceternity command deck skin */
:root {
  color-scheme: dark;
  --lh-bg: #050914;
  --lh-bg-2: #071322;
  --lh-panel: rgba(8, 17, 31, 0.78);
  --lh-panel-strong: rgba(10, 24, 42, 0.92);
  --lh-card: rgba(12, 27, 47, 0.82);
  --lh-text: #edf7ff;
  --lh-muted: #91a7bd;
  --lh-line: rgba(111, 229, 255, 0.2);
  --lh-line-strong: rgba(111, 229, 255, 0.38);
  --lh-accent: #19e6d2;
  --lh-blue: #4f8cff;
  --lh-amber: #f3b44b;
  --lh-danger: #ff6b6b;
  --lh-shadow: 0 24px 70px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --paper: var(--lh-bg);
  --ink: var(--lh-text);
  --muted: var(--lh-muted);
  --line: var(--lh-line);
  --field: rgba(4, 12, 24, 0.78);
  --cedar: var(--lh-accent);
  --cedar-2: #0d8ea0;
  --copper: var(--lh-amber);
  --gold: var(--lh-blue);
  --shadow: var(--lh-shadow);
}

html,
body {
  background: var(--lh-bg) !important;
  color: var(--lh-text) !important;
}

body {
  position: relative;
  background: var(--lh-bg) !important;
}

.app-shell,
.workspace,
.view,
.modal {
  position: relative;
  z-index: 1;
}

:is(.topbar, .workspace, .panel, .selected-item, .suggestions, .modal, .document-preview, .table-card, .duplicate-group, .line-card, .preview-card) {
  background: #0d1c30 !important;
  border-color: var(--lh-line) !important;
  color: var(--lh-text) !important;
  box-shadow: none !important;
}

:is(.workspace, .panel, .selected-item, .modal, .document-preview, .table-card, .duplicate-group, .line-card, .preview-card)::before {
  background: var(--lh-accent) !important;
  box-shadow: none;
}

:is(h1, h2, h3, strong, label, .brand-copy) {
  color: var(--lh-text) !important;
}

:is(p, small, .maker, .muted, .helper) {
  color: var(--lh-muted) !important;
}

:is(input, select, textarea) {
  background: rgba(4, 12, 24, 0.78) !important;
  border-color: var(--lh-line) !important;
  color: var(--lh-text) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

:is(input, select, textarea):focus {
  border-color: var(--lh-accent) !important;
  box-shadow: 0 0 0 3px rgba(25, 230, 210, 0.14) !important;
  outline: none;
}

::placeholder {
  color: rgba(145, 167, 189, 0.76);
}

select option {
  background: #08111f;
  color: var(--lh-text);
}

:is(.button.primary, button[type="submit"]) {
  border-color: rgba(25, 230, 210, 0.5) !important;
  background: #19e6d2 !important;
  color: #031018 !important;
  box-shadow: 0 16px 34px rgba(25, 230, 210, 0.22) !important;
}

.item-workbench .tab.active {
  border-color: rgba(25, 230, 210, 0.5) !important;
  background: #19e6d2 !important;
  color: #031018 !important;
}

:is(.button:not(.primary), .tab:not(.active), .icon-button) {
  background: rgba(10, 24, 42, 0.64) !important;
  border-color: var(--lh-line) !important;
  color: var(--lh-text) !important;
}

:is(.button:not(.primary), .tab:not(.active), .icon-button):hover {
  background: rgba(25, 230, 210, 0.12) !important;
  border-color: var(--lh-line-strong) !important;
  color: #ffffff !important;
}

:is(.status, .badge, .chip, .pill) {
  background: rgba(25, 230, 210, 0.12) !important;
  border-color: rgba(25, 230, 210, 0.28) !important;
  color: #bffdf5 !important;
}

:is(table th, .responsive-lines th) {
  background: rgba(25, 230, 210, 0.1) !important;
  color: #c8f8ff !important;
  border-color: var(--lh-line) !important;
}

:is(table td, table tr) {
  border-color: var(--lh-line) !important;
}

@media (max-width: 760px) {
  :is(.topbar, .brand, .grid, .line-grid, .field-row, .form-row, .button-row) {
    grid-template-columns: 1fr !important;
    flex-direction: column;
    align-items: stretch !important;
    height: auto !important;
    min-height: 0 !important;
  }

  :is(.app-shell, .view, .workspace) {
    width: 100% !important;
    padding-left: 14px !important;
    padding-right: 14px !important;
  }

  .item-workspace .tabs {
    width: 100%;
  }

  .item-workspace .tabs > .tab {
    width: 100%;
  }
}

/* The confirmation dialog lives inside the dark item workbench and must not inherit light card surfaces. */
.item-entry-workbench .submission-confirmation-dialog {
  background: #0d1c30 !important;
  color: #edf7ff !important;
}

.item-entry-workbench .submission-summary-meta > div,
.item-entry-workbench .submission-summary-line {
  background: #10243d;
  border-color: #416783;
}

.item-entry-workbench .submission-summary-meta span,
.item-entry-workbench .submission-summary-line span {
  color: #c8d8e7 !important;
}

.item-entry-workbench .submission-summary-totals,
.item-entry-workbench .submission-progress {
  background: #102b3d;
  border-color: #3b8e91;
  color: #e8fffb;
}

.item-entry-workbench .submission-warning {
  background: #33270d;
  border-color: #f3b44b;
  color: #ffe5ae;
}

.item-entry-workbench .submission-warning.danger {
  background: #35191e;
  border-color: #ff8f8f;
  color: #ffe0e0;
}

.item-entry-workbench .submission-warning :is(strong, p, li) {
  color: inherit !important;
}

/* Contrast hardening for item records, duplicate audit and document output. */
:root {
  --lh-readable-muted: #bccdde;
  --lh-readable-disabled: #c1d0de;
}

:is(table, .line-card, .duplicate-group, .document-preview, .selected-item) {
  color: var(--lh-text) !important;
}

table tbody tr {
  background: rgba(5, 15, 29, 0.86) !important;
}

table tbody tr:nth-child(even) {
  background: rgba(10, 25, 43, 0.9) !important;
}

:is(table td, .responsive-lines td::before, .line-card small, .duplicate-group small) {
  color: var(--lh-text) !important;
}

:is(.maker, .muted, .helper, .responsive-lines td::before, .line-card small, .duplicate-group small) {
  color: var(--lh-readable-muted) !important;
}

:is(.status.error, .status.warning) {
  background: rgba(255, 107, 107, 0.16) !important;
  color: #ffd9d9 !important;
}

button:disabled,
.button:disabled,
.icon-button:disabled {
  opacity: 1 !important;
  background: rgba(30, 43, 59, 0.92) !important;
  border-color: rgba(148, 163, 184, 0.36) !important;
  color: var(--lh-readable-disabled) !important;
}

/* LIHONG_UI_FOUNDATION: a solid, movement-first inventory workbench. */
:root {
  --item-surface: #0d1c30;
  --item-surface-raised: #10243d;
  --item-control: #f7fbfc;
  --item-control-text: #10233a;
  --item-control-placeholder: #52697a;
  --item-border: #31536f;
  --item-muted: #b8cadb;
}

.item-workbench {
  background: #050914;
}

.item-workspace {
  background: #050914 !important;
  border-color: var(--item-border) !important;
  box-shadow: none !important;
}

.item-workspace .topbar {
  background: #081627 !important;
  border-color: var(--item-border) !important;
}

.item-entry-workbench {
  align-items: start;
}

.item-metadata,
.item-picker-workbench,
.item-submission-stage,
.item-recent-activity,
.item-admin-section,
.item-admin-auth,
.item-admin-settings,
.item-document-controls,
.item-document-workbench .panel,
.report-control-deck {
  background: var(--item-surface) !important;
  border-color: var(--item-border) !important;
  border-radius: 6px !important;
  box-shadow: none !important;
}

.item-picker-workbench,
.item-submission-stage {
  background: var(--item-surface-raised) !important;
}

.item-submission-stage {
  border-color: #19e6d2 !important;
}

.item-workbench .empty-state {
  border-color: #416783 !important;
  background: #0a1b2f !important;
  color: #d8e7f3 !important;
}

.item-entry-workbench .item-recent-activity {
  max-height: 500px;
  overflow: auto;
}

.item-entry-workbench .stock-warning {
  border-color: #d96c78 !important;
  background: #3b1722 !important;
  color: #ffe1e1 !important;
  animation: none;
}

.item-entry-workbench .stock-warning :is(strong, span) {
  color: inherit !important;
}

.stock-area-candidates {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.stock-area-candidates:empty {
  display: none;
}

.stock-area-candidates > p {
  margin: 0;
}

.stock-area-candidate {
  flex: 1 1 180px;
  min-width: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 10px 12px;
  border: 1px solid #52708a;
  border-radius: 6px;
  background: #0d1c30;
  color: #e7f2fa;
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.stock-area-candidate.selected,
.stock-area-candidate:hover:not(:disabled),
.stock-area-candidate:focus-visible {
  border-color: #19e6d2;
  background: #143c49;
  color: #ffffff;
}

.stock-area-candidate:disabled {
  color: #9db2c2;
  cursor: not-allowed;
}

:is(.item-entry-workbench, .item-admin-workbench, .item-document-workbench, .report-control-deck) :is(input, select, textarea) {
  color-scheme: light;
  background: var(--item-control) !important;
  border-color: #6f8fa5 !important;
  color: var(--item-control-text) !important;
  caret-color: var(--item-control-text);
}

:is(.item-entry-workbench, .item-admin-workbench, .item-document-workbench, .report-control-deck) :is(input, textarea)::placeholder {
  color: var(--item-control-placeholder) !important;
  opacity: 1;
}

:is(.item-entry-workbench, .item-admin-workbench, .item-document-workbench, .report-control-deck) select option {
  background: #ffffff !important;
  color: var(--item-control-text) !important;
}

:is(.item-entry-workbench, .item-admin-workbench, .item-document-workbench, .report-control-deck) :is(input, select, textarea):disabled {
  background: #dfe7ec !important;
  color: #42576a !important;
  opacity: 1;
}

:is(.item-entry-workbench, .item-admin-workbench, .item-document-workbench, .report-control-deck) input:-webkit-autofill {
  -webkit-text-fill-color: var(--item-control-text) !important;
  -webkit-box-shadow: 0 0 0 1000px var(--item-control) inset !important;
}

:is(.item-entry-workbench, .item-admin-workbench, .item-document-workbench, .report-control-deck) :is(p, small, .muted, .helper) {
  color: var(--item-muted) !important;
}

:is(.item-entry-workbench, .item-admin-workbench, .item-document-workbench, .report-control-deck) :is(h1, h2, h3, strong, label) {
  color: #f3f8fc !important;
}

:is(.item-admin-workbench, .report-control-deck) .storage-area-filter-picker {
  background: var(--item-surface-raised);
  border-color: var(--item-border);
}

:is(.item-admin-workbench, .report-control-deck) .storage-area-filter-menu {
  border-color: var(--item-border);
}

:is(.item-admin-workbench, .report-control-deck) .storage-area-filter-picker > summary,
:is(.item-admin-workbench, .report-control-deck) .storage-area-filter-label,
.item-admin-workbench .item-admin-section-title {
  color: #f3f8fc !important;
}

:is(.item-admin-workbench, .report-control-deck) .storage-area-filter-option {
  background: var(--item-surface);
  border-color: var(--item-border);
}

:is(.item-admin-workbench, .report-control-deck) :is(.storage-area-filter-option small, .storage-area-filter-empty) {
  color: var(--item-muted) !important;
}

.item-workbench :is(button, a, input, select, textarea):focus-visible {
  outline: 3px solid #f3b44b;
  outline-offset: 2px;
}

/* Search results are mounted on the document layer so no workbench panel can clip them. */
.suggestions.item-search-portal,
.suggestions.storage-area-search-portal {
  position: fixed !important;
  z-index: 1000 !important;
  color-scheme: light;
  box-sizing: border-box;
  max-width: calc(100vw - 24px);
  overflow: auto !important;
  overscroll-behavior: contain;
  scrollbar-gutter: stable both-edges;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
  border: 1px solid #6f8fa5 !important;
  border-radius: 6px !important;
  background: #f7fbfc !important;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.46) !important;
}

.suggestions.item-search-portal .suggestion,
.suggestions.storage-area-search-portal .suggestion {
  width: max-content;
  min-width: 100%;
  max-width: none;
  border-bottom: 1px solid #c6d6df;
  background: #ffffff !important;
  color: #10233a !important;
  line-height: 1.45;
}

.suggestions.item-search-portal .suggestion:last-child,
.suggestions.storage-area-search-portal .suggestion:last-child {
  border-bottom: 0;
}

.suggestions.item-search-portal .suggestion:hover,
.suggestions.item-search-portal .suggestion:focus-visible,
.suggestions.item-search-portal .suggestion[aria-selected="true"],
.suggestions.storage-area-search-portal .suggestion:hover,
.suggestions.storage-area-search-portal .suggestion:focus-visible,
.suggestions.storage-area-search-portal .suggestion[aria-selected="true"] {
  background: #d9eef2 !important;
  color: #10233a !important;
}

.suggestions.item-search-portal .code {
  color: #005f68 !important;
  font-weight: 800;
}

.suggestions.storage-area-search-portal .suggestion {
  width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

.storage-area-empty {
  margin: 0;
  padding: 12px;
  background: #ffffff;
  color: #42576a !important;
  line-height: 1.5;
}

/* Management records use the same readable contrast as the operational tables. */
.item-admin-workbench :is(p, span, small, td, th, label, summary, .empty-state) {
  color: #d8e7f3 !important;
}

.item-admin-workbench :is(h1, h2, h3, strong, .code) {
  color: #f3f8fc !important;
}

.item-admin-workbench :is(a:not(.button), .status:not(.error), .admin-submission-preview-item) {
  color: #bffdf5 !important;
}

.item-admin-workbench :is(.option-pill, .admin-submission-item-preview, .duplicate-group, .duplicate-audit, .inline-admin-editor) {
  border-color: #416783 !important;
  background: #112944 !important;
  color: #e7f2fa !important;
}

.item-admin-workbench :is(.admin-inline-editor-row, .admin-submission-preview-row) > td {
  background: #0d1c30 !important;
  color: #d8e7f3 !important;
}

.item-admin-workbench .inline-admin-editor .line-table tbody td {
  background: #081627 !important;
  color: #d8e7f3 !important;
}

.item-admin-workbench .option-pill button {
  border-color: #ff8f8f !important;
  background: #3b1722 !important;
  color: #ffe1e1 !important;
}

/* Keep repeated record actions readable and large enough for touch input. */
.item-workbench :is(#recent-submissions, #transactions-table, #admin-submissions, .duplicate-group) a[href*="/download/"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  white-space: nowrap;
}

.item-admin-workbench .option-pill {
  min-height: 44px;
}

.item-admin-workbench .option-pill button {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  margin: -4px -8px -4px 0;
}

@media (max-width: 760px) {
  :is(button, a.button, [role="button"], input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select, textarea) {
    min-height: 44px;
    max-width: 100%;
  }

  .item-admin-workbench .option-table {
    display: block;
    width: 100%;
    overflow: visible;
    background: transparent;
  }

  .item-admin-workbench .option-table thead {
    display: none;
  }

  .item-admin-workbench .option-table tbody {
    display: grid;
    gap: 10px;
  }

  .item-admin-workbench .option-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--item-border);
    border-radius: 6px;
    background: var(--item-surface-raised) !important;
  }

  .item-admin-workbench .option-table td {
    display: block;
    min-width: 0;
    padding: 0;
    border: 0;
  }

  .item-admin-workbench .option-table input {
    width: 100%;
    min-width: 0;
  }

  .item-admin-workbench .option-table .actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
  }

  .item-admin-workbench .option-table .actions .button {
    width: 100%;
    min-width: 0;
  }

  .cross-storage-controls,
  .cross-storage-item > summary {
    grid-template-columns: minmax(0, 1fr);
  }

  .cross-storage-controls .button {
    width: 100%;
  }

  .cross-storage-item > summary::after {
    grid-column: 1;
    grid-row: 1 / span 2;
    justify-self: end;
  }

  .cross-storage-item-identity,
  .cross-storage-item-totals {
    grid-column: 1;
    justify-content: flex-start;
    padding-right: 28px;
    white-space: normal;
  }

  .cross-storage-item-identity {
    grid-row: 1;
  }

  .cross-storage-item-totals {
    grid-row: 2;
  }

  .cross-storage-area-heading,
  .cross-storage-location {
    align-items: flex-start;
  }

  .cross-storage-source-line > summary,
  .cross-storage-source-editor {
    grid-template-columns: minmax(0, 1fr);
  }

  .cross-storage-source-line > summary::after {
    grid-column: 1;
    grid-row: 1 / span 2;
    justify-self: end;
  }

  .cross-storage-source-document,
  .cross-storage-source-values {
    grid-column: 1;
    justify-content: flex-start;
    padding-right: 28px;
  }

  .cross-storage-source-values {
    grid-row: 2;
  }

  .cross-storage-source-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .cross-storage-source-actions .button {
    width: 100%;
    min-width: 0;
    white-space: normal;
  }

  .admin-search-submission-header,
  .admin-search-line-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-search-submission-download {
    width: 100%;
  }

  .admin-search-submission-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }

  .admin-search-submission-actions .button {
    width: 100%;
    min-width: 0;
    white-space: normal;
  }

  .admin-search-line-card,
  .admin-search-line-fields {
    grid-template-columns: minmax(0, 1fr);
  }

  .admin-search-line-card {
    grid-template-areas:
      "identity"
      "fields"
      "note"
      "actions"
      "status";
  }

  .admin-search-line-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-search-line-actions .button {
    min-width: 0;
    min-height: 44px;
    white-space: normal;
  }
}

/* Keep touch devices usable even when the browser requests a desktop-sized viewport. */
@media (hover: none) and (pointer: coarse) {
  .item-entry-workbench {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .item-entry-workbench > :is(.item-metadata, .item-picker-workbench, .item-submission-stage, .item-recent-activity) {
    grid-column: 1 / -1 !important;
    min-width: 0;
  }

  .item-picker {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .item-picker > * {
    min-width: 0;
  }

  .item-picker #add-line {
    width: 100%;
    white-space: normal;
  }
}

/* LIHONG_RESPONSIVE_GUARD_20260810 */
:where(.workspace, .topbar, .tabs, .panel, .grid, .item-entry-workbench, .item-picker, .item-submission-stage, .item-admin-workbench, .item-document-workbench, .actions, .report-table-scroll, .suggestions) > * {
  min-width: 0;
}

:where(.panel, .status, .empty-state, .selected-item, .suggestion, td, th, label, summary) {
  overflow-wrap: anywhere;
}

:where(img, svg, iframe, .pdf-preview) {
  max-width: 100%;
}

.actions {
  flex-wrap: wrap;
}

.report-table-scroll {
  max-width: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable both-edges;
  -webkit-overflow-scrolling: touch;
}

:where(.modal, [role="dialog"], dialog) {
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

@media (max-width: 760px) {
  .tabs {
    align-items: stretch;
  }

  .tabs :where(button, .tab) {
    min-width: 0;
    white-space: normal;
  }

  .actions > :where(.button, button, a) {
    min-width: 0;
    white-space: normal;
  }

  .item-search-field-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .item-search-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .item-scan-button,
  .item-photo-button {
    width: 100%;
    min-width: 0;
    white-space: normal;
  }

  .material-card-header {
    grid-template-columns: minmax(0, 1fr);
  }

  .material-card-header .button {
    width: 100%;
    min-width: 0;
  }

  .submission-confirmation-body {
    padding: 14px;
  }

  .submission-dialog-header,
  .submission-summary-line {
    grid-template-columns: minmax(0, 1fr);
  }

  .submission-dialog-header .button,
  .submission-confirmation-actions .button,
  .submission-success-actions > * {
    width: 100%;
    min-width: 0;
    margin: 0;
    white-space: normal;
  }

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

@media (max-height: 480px) {
  .item-scanner-dialog {
    max-height: calc(100dvh - 12px);
  }

  .item-scanner-content {
    gap: 8px;
    padding: 10px;
  }

  .item-scanner-header {
    margin: -10px -10px 0;
    padding: 10px;
  }

  .item-scanner-reader {
    min-height: 120px;
    max-height: 38dvh;
  }

  .item-scanner-reader :is(video, canvas, img) {
    max-height: 38dvh !important;
  }

  .submission-confirmation-dialog {
    max-height: calc(100dvh - 12px);
  }

  .submission-confirmation-body {
    gap: 10px;
    padding: 10px;
  }

  .submission-summary-lines {
    max-height: 34dvh;
  }
}

@media (max-width: 420px) {
  .submission-summary-meta {
    grid-template-columns: minmax(0, 1fr);
  }

  .admin-search-line-actions {
    grid-template-columns: minmax(0, 1fr);
  }
}

.storage-area-editor {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.nonstandard-storage-badge,
.storage-area-reselection {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  padding: 3px 7px;
  border: 1px solid currentColor;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

/* Item entry workflow: one DOM form, all regions on desktop and guarded steps on mobile. */
:root {
  --mobile-form-bar-height: 76px;
}

.mobile-step-header,
.mobile-form-navigation {
  display: none;
}

.item-form-step {
  min-width: 0;
}

.mobile-step-error:empty {
  display: none;
}

.item-entry-workbench .item-recent-activity {
  max-height: none;
  overflow: visible;
}

.item-recent-activity > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
  cursor: pointer;
  list-style: none;
}

.item-recent-activity > summary::-webkit-details-marker {
  display: none;
}

.item-recent-activity:not([open]) > :not(summary) {
  display: none;
}

.item-recent-activity > summary::after {
  content: "+";
  flex: 0 0 auto;
  color: #bffdf5;
  font-size: 24px;
  line-height: 1;
}

.item-recent-activity[open] > summary::after {
  content: "−";
}

.item-recent-activity > summary :is(strong, p) {
  margin: 0;
}

.item-recent-activity > summary p {
  margin-top: 4px;
}

.recent-submissions-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.recent-submissions-scroll {
  max-width: 100%;
  margin-top: 10px;
  overflow-x: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable both-edges;
  -webkit-overflow-scrolling: touch;
}

.recent-submissions-scroll table {
  min-width: 760px;
}

@media (max-width: 760px) {
  .storage-area-filter-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .storage-area-filter-toolbar input {
    grid-column: 1 / -1;
  }

  .storage-area-filter-toolbar .button {
    width: 100%;
    min-width: 0;
  }

  .storage-area-filter-options {
    grid-template-columns: minmax(0, 1fr);
  }

  #form-view {
    padding-bottom: calc(var(--mobile-form-bar-height) + env(safe-area-inset-bottom) + 24px) !important;
  }

  .mobile-step-header {
    display: grid;
    gap: 8px;
    margin-bottom: 12px;
    padding: 12px 14px;
    border: 1px solid var(--item-border);
    border-radius: 6px;
    background: #0d1c30;
  }

  .mobile-step-header > div:first-child {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .mobile-step-header span {
    color: #bffdf5;
    font-size: 13px;
    font-weight: 800;
  }

  .mobile-step-header strong {
    color: #f3f8fc;
    font-size: 16px;
  }

  .mobile-step-header p {
    margin: 0;
    color: var(--item-muted) !important;
    font-size: 13px;
  }

  .mobile-step-progress {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .mobile-step-progress span {
    height: 4px;
    border-radius: 2px;
    background: #31536f;
  }

  .mobile-step-progress span.active {
    background: #19e6d2;
  }

  .item-entry-workbench {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .item-entry-workbench > :is(.item-form-step, .item-recent-activity) {
    grid-column: 1 / -1 !important;
    min-width: 0;
  }

  .item-entry-workbench .item-form-step {
    display: none;
  }

  .item-entry-workbench[data-active-form-step="1"] [data-form-step="1"],
  .item-entry-workbench[data-active-form-step="2"] [data-form-step="2"],
  .item-entry-workbench[data-active-form-step="3"] [data-form-step="3"] {
    display: block;
  }

  .item-entry-workbench[data-active-form-step="1"] .item-recent-activity,
  .item-entry-workbench[data-active-form-step="2"] .item-recent-activity {
    display: none;
  }

  .item-submission-stage .section-heading {
    align-items: stretch;
  }

  .item-submission-stage .section-heading > .actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .item-submission-stage .section-heading > .actions #submit-form {
    grid-column: 1 / -1;
  }

  .mobile-form-navigation {
    position: fixed;
    z-index: 900;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
    gap: 10px;
    min-height: var(--mobile-form-bar-height);
    padding: 12px max(14px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    border-top: 1px solid #31536f;
    background: rgba(5, 15, 29, 0.98);
    box-shadow: 0 -12px 28px rgba(0, 0, 0, 0.36);
  }

  .mobile-form-action-status {
    grid-column: 1 / -1;
    margin: 0;
    padding: 8px 10px;
    border: 1px solid #d75b5b;
    border-radius: 4px;
    background: #351a24;
    color: #fff1f1;
    font-size: 13px;
    line-height: 1.35;
  }

  .mobile-form-navigation .button {
    width: 100%;
    min-width: 0;
    min-height: 48px;
    margin: 0;
    white-space: normal;
  }

  .item-scanner-dialog,
  .submission-confirmation-dialog {
    max-height: calc(100dvh - 12px);
  }

  .item-scanner-content,
  .submission-confirmation-body {
    max-height: calc(100dvh - 12px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

@media (max-width: 760px) and (max-height: 480px) {
  :root {
    --mobile-form-bar-height: 64px;
  }

  .mobile-step-header {
    grid-template-columns: minmax(0, 1fr) minmax(120px, 0.7fr);
    align-items: center;
    gap: 6px 12px;
    padding: 8px 10px;
  }

  .mobile-step-header > div:first-child {
    grid-column: 1;
  }

  .mobile-step-header p {
    display: none;
  }

  .mobile-step-progress {
    grid-column: 2;
  }

  .mobile-form-navigation {
    min-height: var(--mobile-form-bar-height);
    padding-top: 8px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }

  .mobile-form-navigation .button {
    min-height: 44px;
  }
}

.nonstandard-storage-badge {
  background: rgba(243, 180, 75, 0.14);
  color: #ffd58a !important;
}

.storage-area-reselection {
  background: rgba(255, 107, 107, 0.16);
  color: #ffd9d9 !important;
}

.storage-area-manager,
.storage-area-table {
  min-width: 0;
  max-width: 100%;
}

.storage-area-active-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.storage-area-active-toggle input {
  flex: 0 0 auto;
}

@media (max-width: 760px) {
  .storage-area-table .storage-area-active-toggle {
    min-height: 44px;
  }

  .storage-area-table .actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

