:root {
  --warehouse-ink: #173f35;
  --warehouse-paper: #f2efe7;
  --warehouse-card: #fffdf7;
  --warehouse-line: #c9c4b8;
  --warehouse-accent: #d95b41;
  --warehouse-safe: #246b57;
  --warehouse-warning: #9a5b18;
  --warehouse-shadow: 0 18px 45px rgba(23, 63, 53, 0.12);
}

* { box-sizing: border-box; }

html, body { max-width: 100%; overflow-x: hidden; }

.warehouse-body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--warehouse-ink);
  background:
    linear-gradient(rgba(23, 63, 53, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 63, 53, 0.035) 1px, transparent 1px),
    var(--warehouse-paper);
  background-size: 24px 24px;
  font-family: "Noto Sans TC", "PingFang HK", "Microsoft JhengHei", sans-serif;
}

.warehouse-shell { width: min(100%, 920px); margin: 0 auto; padding-bottom: calc(32px + env(safe-area-inset-bottom)); }

.warehouse-body.auth-locked .warehouse-header,
.warehouse-body.auth-locked .warehouse-actions,
.warehouse-body.auth-locked .warehouse-loading {
  display: none;
}

.warehouse-body.auth-locked .warehouse-main {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
}

.warehouse-body.auth-locked .warehouse-workspace {
  width: 100%;
  margin-top: 0;
}

.warehouse-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(16px + env(safe-area-inset-top)) 20px 16px;
  color: #fff;
  background: rgba(23, 63, 53, 0.97);
  backdrop-filter: blur(14px);
}

.warehouse-eyebrow, .warehouse-kicker { margin: 0 0 4px; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.15em; }
.warehouse-header h1 { margin: 0; font-size: clamp(1.25rem, 5vw, 1.8rem); }
.warehouse-header .header-actions { display: flex; align-items: flex-end; gap: 8px; flex-direction: column; }
.warehouse-network { padding: 6px 9px; border: 1px solid rgba(255,255,255,.3); border-radius: 999px; font-size: .75rem; white-space: nowrap; }
.warehouse-network.is-offline { color: #26170d; background: #ffd08a; border-color: #ffd08a; }
.warehouse-signout, .warehouse-home-button, .warehouse-manage-link { border: 0; border-bottom: 1px solid currentColor; padding: 3px 0; color: inherit; background: transparent; font: inherit; cursor: pointer; }
.warehouse-manage-link { font-size: .82rem; font-weight: 800; text-decoration: none; }
.warehouse-manage-link[hidden] { display: none; }

.warehouse-main { padding: 22px 16px; }
.warehouse-section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.warehouse-section-heading h2 { margin: 0; font-size: 1.15rem; }
.warehouse-kicker { color: var(--warehouse-accent); }
.warehouse-home-button { color: var(--warehouse-ink); font-weight: 700; }

.warehouse-action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.warehouse-action {
  min-width: 0;
  min-height: 132px;
  display: grid;
  align-content: space-between;
  gap: 4px;
  padding: 15px;
  border: 1px solid var(--warehouse-ink);
  border-radius: 3px;
  color: var(--warehouse-ink);
  text-align: left;
  background: var(--warehouse-card);
  box-shadow: 4px 4px 0 var(--warehouse-ink);
  cursor: pointer;
}
.warehouse-action[hidden] { display: none; }
.warehouse-action:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--warehouse-ink); }
.warehouse-action strong { font-size: clamp(1.25rem, 6vw, 1.65rem); }
.warehouse-action small { opacity: .72; }
.warehouse-action-number { justify-self: end; font: 800 .8rem/1 monospace; }
.warehouse-action.receive { border-top: 8px solid #4c8d78; }
.warehouse-action.issue { border-top: 8px solid var(--warehouse-accent); }
.warehouse-action.inventory { border-top: 8px solid #d1a13d; }
.warehouse-action.queue { border-top: 8px solid #5c6f7d; }
.warehouse-actions.is-compact .warehouse-action-grid { display: none; }

.warehouse-workspace { margin-top: 22px; }
.warehouse-loading, .warehouse-empty, .warehouse-disabled, .warehouse-notice {
  padding: 20px;
  border: 1px solid var(--warehouse-line);
  background: rgba(255, 253, 247, .82);
}
.warehouse-disabled { border-left: 7px solid var(--warehouse-warning); }

.warehouse-form { display: grid; gap: 16px; padding: 18px; border: 1px solid var(--warehouse-line); background: var(--warehouse-card); box-shadow: var(--warehouse-shadow); }
.warehouse-form h2 { margin: 0; }
.warehouse-form label { display: grid; gap: 7px; font-weight: 700; }
.warehouse-form input, .warehouse-form select, .warehouse-search {
  width: 100%;
  min-height: 50px;
  padding: 10px 12px;
  border: 1px solid #87847c;
  border-radius: 2px;
  color: #17241f;
  background: #fff;
  font: inherit;
}
.warehouse-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.warehouse-submit { min-height: 54px; border: 0; border-radius: 2px; padding: 12px 18px; color: white; background: var(--warehouse-ink); font: 800 1.05rem/1 inherit; cursor: pointer; }
.warehouse-submit:disabled { opacity: .55; }
.warehouse-form-status { min-height: 1.4em; margin: 0; font-weight: 700; }
.warehouse-form-status.is-error { color: #9d2f21; }
.warehouse-form-status.is-success { color: var(--warehouse-safe); }
.warehouse-receipt-capture, .warehouse-receipt-line { margin: 0; padding: 14px; border: 1px solid var(--warehouse-line); }
.warehouse-receipt-capture legend, .warehouse-receipt-line legend { padding: 0 7px; font-weight: 900; }
.warehouse-receipt-line { display: grid; gap: 12px; background: #f8f4e9; }
.warehouse-confirm-line { grid-template-columns: auto 1fr !important; align-items: center; }
.warehouse-confirm-line input { width: 24px; min-height: 24px; }
.warehouse-tag-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.warehouse-tag-create { display: grid; gap: 12px; }
.warehouse-tag-card { align-items: start; }
.warehouse-tag-card-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.warehouse-tag-template-editor { padding: 12px; border: 1px dashed var(--warehouse-line); }
.warehouse-tag-template-editor summary, .warehouse-tag-rebind summary { cursor: pointer; font-weight: 800; }
.warehouse-tag-rebind { grid-column: 1 / -1; }
.warehouse-tag-rebind select { width: 100%; min-height: 44px; margin: 6px 0; }
.warehouse-queue-resolution { grid-column: 1 / -1; display: grid; gap: 10px; padding-top: 10px; border-top: 1px dashed var(--warehouse-line); }
.warehouse-queue-resolution label { display: grid; gap: 5px; font-weight: 700; }
.warehouse-queue-resolution input, .warehouse-queue-resolution select { width: 100%; min-height: 44px; padding: 8px; font: inherit; }

.warehouse-inventory-toolbar { position: sticky; z-index: 10; top: 92px; padding: 10px 0; background: var(--warehouse-paper); }
.warehouse-inventory-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.warehouse-inventory-card { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--warehouse-line); background: var(--warehouse-card); }
.warehouse-inventory-card strong, .warehouse-inventory-card span { overflow-wrap: anywhere; }
.warehouse-inventory-card small { display: block; margin-top: 5px; color: #5a5a54; }
.warehouse-inventory-thumbnail, .warehouse-inventory-placeholder {
  width: 72px;
  height: 72px;
  border: 1px solid var(--warehouse-line);
  border-radius: 2px;
  background: #f4f1e8;
}
.warehouse-inventory-thumbnail { padding: 0; overflow: hidden; cursor: zoom-in; }
.warehouse-inventory-thumbnail img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.warehouse-inventory-placeholder { display: grid; place-items: center; color: #6f6b62; font-size: 0.75rem; font-weight: 800; }
.warehouse-inventory-placeholder[hidden] { display: none; }
.warehouse-inventory-details { min-width: 0; }
.warehouse-inventory-name {
  max-width: 100%;
  padding: 0;
  border: 0;
  color: var(--warehouse-ink);
  background: transparent;
  text-align: left;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 850;
  line-height: 1.35;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.warehouse-inventory-name:focus-visible, .warehouse-inventory-thumbnail:focus-visible { outline: 3px solid #d1a13d; outline-offset: 2px; }
.warehouse-quantity { align-self: center; text-align: right; font-size: 1.1rem; font-weight: 900; }

.warehouse-image-lightbox,
.warehouse-item-action-sheet {
  position: fixed;
  inset: 0;
  z-index: 1000;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: rgba(7, 20, 17, 0.78);
}
.warehouse-image-lightbox[hidden], .warehouse-item-action-sheet[hidden] { display: none; }
.warehouse-image-lightbox { display: grid; place-items: center; }
.warehouse-image-lightbox figure {
  position: relative;
  display: grid;
  gap: 10px;
  width: min(100%, 720px);
  max-height: 92vh;
  margin: 0;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  background: #fff;
}
.warehouse-image-lightbox img { width: 100%; max-height: 76vh; object-fit: contain; }
.warehouse-image-lightbox figcaption { color: var(--warehouse-ink); font-weight: 800; text-align: center; }
.warehouse-overlay-close {
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid currentColor;
  border-radius: 2px;
  color: var(--warehouse-ink);
  background: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}
.warehouse-image-lightbox .warehouse-overlay-close { position: absolute; z-index: 1; top: 20px; right: 20px; }
.warehouse-item-action-sheet { display: flex; align-items: flex-end; justify-content: center; }
.warehouse-item-action-sheet > section {
  width: min(100%, 560px);
  padding: 20px;
  border-top: 5px solid #d1a13d;
  background: var(--warehouse-card);
  box-shadow: 0 -18px 48px rgba(0, 0, 0, 0.25);
}
.warehouse-sheet-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.warehouse-sheet-heading h3 { margin: 4px 0 0; font-size: 1.2rem; }
.warehouse-sheet-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
.warehouse-sheet-actions .warehouse-submit[hidden] { display: none; }
.warehouse-sheet-empty { margin-bottom: 0; color: #6b3b23; font-weight: 800; }

.auth-screen { min-height: 55vh; display: grid; place-items: center; }
.auth-panel { max-width: 520px; width: 100%; }

@media (min-width: 680px) {
  .warehouse-main { padding: 30px 24px; }
  .warehouse-action-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .warehouse-action { min-height: 155px; }
}

@media (max-width: 420px) {
  .warehouse-header { align-items: flex-start; }
  .warehouse-form-row { grid-template-columns: 1fr; }
  .warehouse-inventory-card { grid-template-columns: 58px minmax(0, 1fr); gap: 10px; }
  .warehouse-inventory-thumbnail, .warehouse-inventory-placeholder { width: 58px; height: 58px; }
  .warehouse-quantity { grid-column: 2; justify-self: start; text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
.warehouse-operator-status {
  padding: 0.5rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.45);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 700;
}

.warehouse-operator-status.is-expiring {
  border-color: #ffd59a;
  background: #6f421d;
}

.warehouse-identity-methods {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.warehouse-operator-video {
  width: 100%;
  max-height: 22rem;
  background: #102a23;
  object-fit: cover;
}

.warehouse-device-context {
  display: grid;
  gap: 0.25rem;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(23, 63, 53, 0.18);
  border-radius: 0.8rem;
  background: rgba(23, 63, 53, 0.06);
}

.warehouse-device-context small {
  color: var(--muted, #58645f);
  line-height: 1.45;
}

.warehouse-device-registration {
  border-top: 1px solid rgba(23, 63, 53, 0.14);
  padding-top: 0.8rem;
}

.warehouse-device-registration summary {
  cursor: pointer;
  font-weight: 700;
}

.warehouse-device-registration form {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.warehouse-pin-entry {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--warehouse-line, #cfcbbf);
  background: #f8f6ef;
}

.warehouse-pin-entry[hidden],
.warehouse-operator-video[hidden] {
  display: none;
}

.warehouse-operator-confirm dl {
  display: grid;
  gap: 0.5rem;
  margin: 0;
}

.warehouse-operator-confirm dl div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--warehouse-line, #cfcbbf);
}

.warehouse-operator-confirm dt { color: #59645f; }
.warehouse-operator-confirm dd { margin: 0; font-weight: 700; }

@media (max-width: 640px) {
  .warehouse-identity-methods { grid-template-columns: 1fr; }
  .warehouse-operator-status { order: 3; width: 100%; text-align: center; }
}
