:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #182230;
  --muted: #64748b;
  --line: #d9e1ea;
  --strong: #0f6b63;
  --strong-dark: #0b514b;
  --accent: #9a5b13;
  --danger: #b91c1c;
  --ok: #15803d;
  --shadow: 0 10px 28px rgba(16, 24, 40, 0.07);
  --focus: 0 0 0 3px rgba(15, 107, 99, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, #f8fafc 0, var(--bg) 260px),
    var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

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

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select {
  min-height: 44px;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  color: #fff;
  background: var(--strong);
  cursor: pointer;
  font-weight: 700;
  transition: background 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

button:hover {
  background: var(--strong-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
  transform: none;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

button:active {
  transform: translateY(1px);
}

button.ghost {
  color: var(--text);
  background: #e8eef4;
}

button.ghost:hover {
  background: #dbe4ec;
}

button.warn {
  background: var(--accent);
}

button.danger {
  background: var(--danger);
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  color: #e5edf5;
  background: #17212c;
  overflow: auto;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  color: #fff;
  background: var(--strong);
  font-weight: 800;
  letter-spacing: 0;
}

.brand h1 {
  margin: 0;
  font-size: 17px;
}

.brand p {
  margin: 3px 0 0;
  color: #a7b4c2;
  font-size: 13px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

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

.field small {
  color: var(--muted);
  font-size: 12px;
}

.sidebar .field span {
  color: #b6c3d1;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  background: #fff;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #b7c4d2;
}

.date-window-input {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto;
  align-items: stretch;
}

.date-window-input input {
  border-radius: 6px 0 0 6px;
}

.date-window-input span {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 6px 6px 0;
  background: var(--panel-soft);
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
}

textarea {
  min-height: 78px;
  resize: vertical;
}

nav {
  display: grid;
  gap: 6px;
  margin-top: 18px;
}

.nav-button {
  width: 100%;
  justify-content: flex-start;
  color: #d9e3ee;
  background: transparent;
  text-align: left;
  border: 1px solid transparent;
}

.nav-button:hover,
.nav-button.active {
  color: #fff;
  background: #243446;
  border-color: #33475d;
}

.nav-button.active {
  box-shadow: inset 3px 0 0 var(--strong);
}

.sidebar-note {
  display: grid;
  gap: 5px;
  margin-top: 22px;
  padding: 12px;
  border: 1px solid #334255;
  border-radius: 8px;
  color: #c8d5e1;
  font-size: 13px;
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 28px;
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--strong);
  font-weight: 700;
  font-size: 13px;
}

.topbar h2 {
  margin: 0;
  font-size: 25px;
}

.content {
  display: grid;
  min-width: 0;
  gap: 18px;
  padding: 24px 28px 42px;
}

.stats-grid,
.form-grid,
.split-grid {
  display: grid;
  gap: 14px;
}

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

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

.split-grid {
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.65fr);
}

.panel,
.stat,
.table-wrap {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 20px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-header h3,
.stat h3 {
  margin: 0;
}

.panel-header p,
.stat p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.stat {
  padding: 16px;
}

.stat h3 {
  color: #334155;
  font-size: 14px;
}

.stat strong {
  display: block;
  margin-top: 10px;
  color: var(--strong-dark);
  font-size: 30px;
  line-height: 1;
}

.table-wrap {
  overflow: auto;
}

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

.split-grid table {
  min-width: 0;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #344256;
  background: #edf2f7;
  font-size: 13px;
  font-weight: 800;
}

tbody tr:nth-child(even) td {
  background: #fbfdff;
}

tbody tr:hover td {
  background: #f3f8f7;
}

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

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  color: #123;
  background: #e2e8f0;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.tag.ok {
  color: #14532d;
  background: #dcfce7;
}

.tag.warn {
  color: #7c2d12;
  background: #ffedd5;
}

.tag.danger {
  color: #7f1d1d;
  background: #fee2e2;
}

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

.helper {
  color: var(--muted);
  font-size: 13px;
}

.notice {
  margin: 0 0 14px;
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  padding: 10px 12px;
  color: #7c2d12;
  background: #fff7ed;
  font-size: 14px;
}

.notice.success {
  border-left-color: var(--strong);
  color: #14532d;
  background: #f0fdf4;
}

.notice.error {
  border-left-color: #b91c1c;
  color: #991b1b;
  background: #fef2f2;
}

.sku {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 800;
}

.thumb {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
}

.zoomable-thumb {
  transition: transform 0.16s ease, box-shadow 0.16s ease;
  transform-origin: left top;
}

.zoomable-thumb:hover {
  position: relative;
  z-index: 4;
  transform: scale(3);
  box-shadow: var(--shadow);
}

.image-preview {
  width: 132px;
  height: 132px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.inline-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

.mail-form {
  grid-template-columns: minmax(200px, 1fr) auto;
}

.mail-form [data-email-status] {
  grid-column: 1 / -1;
  margin: 0 0 12px;
}

.inbound-mail-form {
  grid-template-columns: minmax(220px, 1fr) auto auto;
}

.inbound-mail-form [data-gate-status] {
  grid-column: 1 / -1;
  margin: 0 0 12px;
  overflow-wrap: anywhere;
}

.lifecycle-mail-form {
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) auto auto;
}

.inventory-preferences-form {
  grid-template-columns: minmax(200px, 1fr) minmax(240px, 1.2fr) auto;
  margin: 12px 0 24px;
  padding: 20px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.inventory-preferences-form .check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.inventory-preferences-form input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.inventory-preferences-form .helper,
.inventory-preferences-form [data-preference-status] {
  grid-column: 1 / -1;
  margin: 0;
  overflow-wrap: anywhere;
}

.public-card .notice {
  overflow-wrap: anywhere;
}

.return-form {
  grid-template-columns: repeat(3, minmax(150px, 1fr)) minmax(260px, 1.2fr) auto;
}

.return-form .date-field {
  min-width: 260px;
}

.inline-form button {
  align-self: end;
  margin-bottom: 12px;
  white-space: nowrap;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 36px;
  color: var(--muted);
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #fff;
  background: var(--muted);
  font-weight: 800;
}

.empty-state h3 {
  margin: 0;
  color: var(--text);
}

.empty-state p {
  margin: 0;
}

.hidden {
  display: none !important;
}

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(circle at top, rgba(15, 107, 99, 0.10), transparent 32rem),
    var(--bg);
}

.login-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 26px;
  background: #fff;
  box-shadow: var(--shadow);
}

.public-card {
  width: min(880px, 100%);
}

.public-lookup-form {
  display: grid;
  grid-template-columns: minmax(180px, 0.75fr) minmax(240px, 1.25fr) auto;
  align-items: end;
  gap: 12px;
  margin-bottom: 16px;
}

.public-lookup-form button {
  margin-bottom: 12px;
  white-space: nowrap;
}

.guide-card {
  width: min(920px, 100%);
}

.guide-intro {
  margin-bottom: 18px;
}

.guide-intro h2 {
  margin: 0;
  font-size: 24px;
}

.guide-intro p,
.guide-section p,
.guide-section li {
  color: var(--text);
  font-size: 16px;
  line-height: 1.7;
}

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

.guide-step {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  min-height: 142px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel-soft);
}

.guide-step > strong {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: #fff;
  background: var(--strong);
  font-size: 18px;
}

.guide-step h3 {
  margin: 0 0 6px;
  font-size: 17px;
}

.guide-step p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
}

.guide-section {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.guide-section h3 {
  margin: 0 0 8px;
}

.guide-section ul {
  margin: 0;
  padding-left: 1.2em;
}

.login-links {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  font-size: 14px;
}

.login-links a {
  display: block;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--strong-dark);
  font-weight: 700;
  text-decoration: none;
}

.login-links a:hover {
  border-color: rgba(15, 107, 99, 0.36);
  background: #eef8f6;
  text-decoration: none;
}

.login-brand {
  color: var(--text);
  margin-bottom: 22px;
}

.login-brand p {
  color: var(--muted);
}

.form-error {
  margin: 0 0 12px;
  color: var(--danger);
  font-size: 14px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 6px;
    scrollbar-width: thin;
  }

  .nav-button {
    width: auto;
    flex: 0 0 auto;
    white-space: nowrap;
  }

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

  .inline-form,
  .public-lookup-form {
    grid-template-columns: 1fr;
  }

  .public-lookup-form button {
    margin-bottom: 0;
  }

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

/* Keep transfer references and the completion form readable when scrolling. */
.transfer-table table { min-width: 1500px; }
.inbound-table table { min-width: 1680px; }
.inbound-table th, .inbound-table td:nth-child(4), .inbound-table td:nth-child(5), .inbound-table button { white-space: nowrap; }
.inbound-table td:nth-child(3) { min-width: 180px; }
.transfer-table th { white-space: nowrap; }
.transfer-table form[data-form="transfer-complete"] { min-width: 220px; }
.transfer-table form[data-form="transfer-complete"] button { white-space: nowrap; }

/* Warehouse task lists keep essential fields visible; details carry long forms. */
.task-workbench { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.task-workbench.has-detail { grid-template-columns: minmax(260px, .8fr) minmax(0, 1.2fr); }
.task-list, .task-detail { min-width: 0; overflow-wrap: anywhere; }
.task-row { display: grid; grid-template-columns: minmax(100px, .8fr) minmax(140px, 1.3fr) minmax(120px, 1fr) minmax(130px, 1fr) auto; align-items: start; gap: 14px; padding: 16px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); font-size: 14px; }
.task-row.is-selected { border-color: var(--strong); box-shadow: inset 4px 0 var(--strong); }
.task-identity span { display: block; margin-top: 5px; color: var(--muted); }
.task-subject > div, .task-status > div, .task-times > div + div { margin-top: 6px; }
.task-times { color: var(--muted); font-size: 12px; }
.task-warning { color: #854c0d; background: #fff3df; padding: 6px 8px; border-radius: 4px; }
.task-workbench.has-detail .task-row { grid-template-columns: minmax(0, 1fr) auto; }
.task-workbench.has-detail .task-subject, .task-workbench.has-detail .task-times { grid-column: 1 / -1; }
.task-workbench.has-detail .task-status { grid-column: 1; }
.task-workbench.has-detail .task-row > button { grid-column: 2; grid-row: 1; }
.task-detail { align-self: start; padding: 0 20px 20px; scroll-margin-top: 120px; }
.task-detail[hidden] { display: none; }
.task-detail-heading { display: flex; justify-content: space-between; align-items: start; gap: 12px; position: sticky; top: 110px; z-index: 2; background: var(--panel); padding: 16px 0; border-bottom: 1px solid var(--line); }
.task-detail-heading h3 { margin: 0; }
.task-detail-heading button { flex-shrink: 0; }
.task-detail .task-fields { display: grid; grid-template-columns: minmax(80px, .7fr) minmax(0, 1.3fr); gap: 10px 16px; font-size: 14px; margin: 16px 0; }
.task-fields dt { color: var(--muted); }
.task-fields dd { margin: 0; white-space: pre-wrap; }
.task-detail .panel { padding: 16px 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; box-shadow: none; }
.task-detail .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.task-detail [data-action="cancel-inbound-process"] { display: none; }
.task-detail input, .task-detail textarea, .task-detail select { min-width: 0; max-width: 100%; }
.task-detail .actions { flex-wrap: wrap; }
.task-image { width: 120px; height: 120px; object-fit: contain; margin-top: 14px; }
.task-operation, .task-history { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 16px; }
.task-history summary, .task-create summary, .task-detail details > summary { cursor: pointer; min-height: 44px; padding: 10px 0; }
.task-feedback { color: var(--strong-dark); white-space: pre-wrap; }
.task-feedback:empty { display: none; }
@media (max-width: 1200px) {
  .task-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; }
  .task-times { grid-column: 2; }
}
@media (max-width: 740px) {
  .task-workbench.has-detail { grid-template-columns: minmax(0, 1fr); }
  .task-workbench.has-detail .task-list { display: none; }
  .task-row { grid-template-columns: minmax(0, 1fr) auto; }
  .task-row .task-subject, .task-row .task-times { grid-column: 1 / -1; }
  .task-row .task-status { grid-column: 1; }
  .task-row > button { grid-column: 2; grid-row: 1; }
  .task-detail .form-grid, .task-detail .task-fields { grid-template-columns: minmax(0, 1fr); }
  .task-fields dd { margin-bottom: 8px; }
  .task-detail { padding: 0 14px 14px; }
}

.mail-preview { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; padding: 12px; background: #f3f6fa; border-radius: 8px; }
.mail-form details { width: 100%; }

.mail-dialog { width: min(520px, calc(100vw - 40px)); border: 1px solid #d8e2ec; border-radius: 14px; padding: 24px; color: #173047; box-shadow: 0 20px 60px #17304733; }
.mail-dialog::backdrop { background: #17304766; }
.mail-dialog p { overflow-wrap: anywhere; }

.public-mail-fields input[type="checkbox"] { width: auto; margin-right: 8px; }
.public-mail-fields p { font-size: 14px; line-height: 1.6; }
