/* ── Jaques WMS stylesheet ──────────────────────────────────────────────── */
:root {
  --brand:    #1a3a5c;
  --accent:   #2563eb;
  --bg:       #f1f5f9;
  --surface:  #ffffff;
  --text:     #1e293b;
  --muted:    #64748b;
  --border:   #e2e8f0;
  --success:  #16a34a;
  --error:    #dc2626;
  --warning:  #d97706;
  --radius:   8px;
  --shadow:   0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:0 4px 12px rgba(0,0,0,.10);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--accent); }
a:hover { text-decoration: underline; }

/* ── Staging banner ──────────────────────────────────────────────────────── */
.staging-banner {
  background: #c2410c;
  color: #fff;
  text-align: center;
  font-weight: 700;
  font-size: .9375rem;
  letter-spacing: .03em;
  padding: .5rem 1rem;
  border-bottom: 2px solid #7c2d12;
}

/* ── Nav ─────────────────────────────────────────────────────────────────── */
.nav {
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  height: 56px;
  gap: 0.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.0625rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
  margin-right: 0.75rem;
}
.nav-brand:hover { text-decoration: none; opacity: .9; }

/* logo sits in a white pill so the dark-text logo reads against the navy nav */
.nav-logo-pill {
  display: inline-flex;
  align-items: center;
  background: #fff;
  border-radius: 6px;
  padding: 3px 7px;
  line-height: 0;
  flex-shrink: 0;
}
.nav-logo {
  height: 32px;
  max-height: 40px;
  width: auto;          /* keep aspect ratio, never stretch */
  max-width: 120px;
  display: block;
}

.nav-links {
  display: flex;
  gap: 2px;
  flex: 1;
  flex-wrap: wrap;
}

.nav-link {
  color: rgba(255,255,255,.82);
  text-decoration: none;
  padding: 0 0.75rem;
  height: 44px;
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  font-size: .9375rem;
  transition: background .12s;
}
.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,.15);
  color: #fff;
  text-decoration: none;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
  white-space: nowrap;
}
.nav-username {
  font-size: .875rem;
  color: rgba(255,255,255,.70);
}

.badge {
  display: inline-block;
  background: rgba(255,255,255,.18);
  color: rgba(255,255,255,.9);
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 4px;
  vertical-align: middle;
}

/* ── Flash messages ──────────────────────────────────────────────────────── */
.flash {
  padding: .75rem 1.25rem;
  font-size: .9375rem;
  border-left: 4px solid transparent;
}
.flash-error   { background:#fef2f2; color:var(--error);   border-color:var(--error); }
.flash-success { background:#f0fdf4; color:var(--success); border-color:var(--success); }
.flash-warning { background:#fffbeb; color:var(--warning); border-color:var(--warning); }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
}

.page-header {
  margin-bottom: 1.5rem;
}
.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}
.page-sub {
  color: var(--muted);
  font-size: .9375rem;
  margin-top: .125rem;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }

.form-label {
  display: block;
  font-size: .875rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: .3rem;
}

.form-input,
.form-select {
  width: 100%;
  padding: .625rem .875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  color: var(--text);
  background: #fff;
  min-height: 48px;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
}
.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .625rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  min-height: 48px;
  transition: opacity .15s, background .15s;
  white-space: nowrap;
}
.btn:hover { opacity: .9; text-decoration: none; }
.btn:active { opacity: .8; }

.btn-primary  { background: var(--accent);  color: #fff; }
.btn-danger   { background: var(--error);   color: #fff; }
.btn-ghost    { background: var(--border);  color: var(--text); }
.btn-full     { width: 100%; }

/* ── Dashboard nav cards ─────────────────────────────────────────────────── */
.nav-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.nav-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.25rem 1.5rem;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: .375rem;
  border: 2px solid transparent;
  transition: border-color .15s, box-shadow .15s;
  min-height: 110px;
}
.nav-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}
.nav-card-icon  { font-size: 1.5rem; margin-bottom: .25rem; }
.nav-card-title { font-size: 1rem; font-weight: 600; }
.nav-card-desc  { font-size: .875rem; color: var(--muted); }

/* ── Login page ──────────────────────────────────────────────────────────── */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-wrap { width: 100%; max-width: 420px; padding: 1rem; }
.login-card { padding: 2rem 2rem 2.25rem; }
.login-header {
  text-align: center;
  margin-bottom: 1.75rem;
}
.login-logo  { font-size: 2.5rem; }
.login-title {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--brand);
  margin-top: .5rem;
}
.login-sub   { color: var(--muted); font-size: .9375rem; margin-top: .25rem; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
th {
  text-align: left;
  padding: .625rem .875rem;
  background: var(--bg);
  font-size: .8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
td {
  padding: .75rem .875rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

/* ── Screen-specific ────────────────────────────────────────────────────── */

/* Search */
.search-large {
  font-size: 1.125rem;
  min-height: 56px;
}

/* Tags / status badges */
.tag {
  display: inline-block;
  font-size: .75rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  vertical-align: middle;
  text-transform: capitalize;
}
.tag-success  { background:#dcfce7; color:#15803d; }
.tag-warning  { background:#fef9c3; color:#a16207; }
.tag-error    { background:#fee2e2; color:#b91c1c; }
.tag-muted    { background:#f1f5f9; color:#475569; }

/* Reason tags in ledger */
.tag-reason-goods_in        { background:#dbeafe; color:#1e40af; }
.tag-reason-adjustment      { background:#fef9c3; color:#a16207; }
.tag-reason-putaway         { background:#dcfce7; color:#15803d; }
.tag-reason-order_depletion { background:#fee2e2; color:#b91c1c; }
.tag-reason-replen          { background:#ede9fe; color:#6d28d9; }
.tag-reason-count_correction{ background:#fef3c7; color:#92400e; }
.tag-reason-fba_out         { background:#e0e7ff; color:#3730a3; }
.tag-reason-shuffle         { background:#f3f4f6; color:#374151; }
/* adjustment reasons */
.tag-reason-damage          { background:#fee2e2; color:#b91c1c; }
.tag-reason-missing         { background:#ffedd5; color:#c2410c; }
.tag-reason-correction      { background:#fef9c3; color:#a16207; }
.tag-reason-qc_check        { background:#e0f2fe; color:#0369a1; }
.tag-reason-parts           { background:#cffafe; color:#0e7490; }
.tag-reason-sample          { background:#fce7f3; color:#be185d; }
.tag-reason-found           { background:#dcfce7; color:#15803d; }
.tag-reason-picking         { background:#ede9fe; color:#6d28d9; }

/* Table cell helpers */
.code-cell   { font-family: monospace; font-size: .9375rem; white-space: nowrap; }
.num-cell    { font-variant-numeric: tabular-nums; font-weight: 600; }
.action-cell { white-space: nowrap; }
.small-text  { font-size: .875rem; }
.nowrap      { white-space: nowrap; }
.btn-sm      { min-height: 36px; padding: .25rem .75rem; font-size: .875rem; }

/* Qty colour in history */
.qty-pos { color: var(--success); }
.qty-neg { color: var(--error); }

/* Expand rows */
.exp-row td   { padding: 0; border-bottom: none; }
.exp-cell     { padding: 0 !important; }
.pallet-expand { background: #f8fafc; border-top: 1px solid var(--border); }
.pallet-table  { width: 100%; font-size: .875rem; }
.pallet-table th { background: #f1f5f9; font-size: .75rem; }
.pallet-table td, .pallet-table th { padding: .5rem .875rem; }
.pallet-table tr:last-child td { border-bottom: none; }

/* Row states in location view */
.row-blocked td { background: #fef2f2 !important; color: #b91c1c; }
.row-empty   td { color: var(--muted); }

/* Aisle picker */
.aisle-picker {
  display: flex;
  flex-wrap: wrap;
  gap: .375rem;
  padding: .25rem 0;
}
.aisle-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: .375rem .75rem;
  border-radius: 6px;
  font-size: .875rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  min-width: 52px;
  min-height: 44px;
  justify-content: center;
  transition: background .12s, border-color .12s;
}
.aisle-btn:hover     { background: #e2e8f0; text-decoration: none; }
.aisle-btn.active    { background: var(--accent); color: #fff; border-color: var(--accent); }
.aisle-units { font-size: .75rem; font-weight: 400; opacity: .75; }

/* Filter bar */
.filter-bar { padding: 1rem 1.25rem; }
.filter-row { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.filter-group { min-width: 140px; }
.filter-btn-group { display: flex; gap: .5rem; align-items: flex-end; padding-bottom: .0625rem; }

/* Empty state */
.empty-state {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: .9375rem;
}

/* Pallet detail */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: start;
}
.card-stack { display: flex; flex-direction: column; gap: 1rem; }
.section-title {
  font-size: .875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin-bottom: .875rem;
}
.detail-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .375rem 1rem;
  font-size: .9375rem;
}
.detail-list dt { color: var(--muted); font-size: .875rem; white-space: nowrap; }
.detail-list dd { margin: 0; }

.form-row-inline { display: flex; gap: 1rem; }
.flex-1 { flex: 1; }

@media (max-width: 768px) {
  .detail-grid { grid-template-columns: 1fr; }
  .form-row-inline { flex-direction: column; }
}

/* code link */
.code-link {
  font-family: monospace;
  font-size: .9375rem;
  color: var(--accent);
  text-decoration: none;
}
.code-link:hover { text-decoration: underline; }

/* ── Utility ─────────────────────────────────────────────────────────────── */
.text-muted  { color: var(--muted); }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }

/* ── Admin ───────────────────────────────────────────────────────────────── */
.nav-divider {
  display: inline-block;
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,.25);
  margin: 0 .25rem;
  vertical-align: middle;
}

.row-retired td { color: var(--muted) !important; background: #f8fafc !important; }

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem .75rem;
  padding: .375rem 0;
}
.check-label {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  font-size: .9375rem;
  cursor: pointer;
  min-height: 36px;
  padding: 0 .5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  user-select: none;
}
.check-label:hover { background: var(--bg); }
.check-label input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }

.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  padding: .25rem 0;
}
.radio-label {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  font-size: .9375rem;
  cursor: pointer;
  min-height: 44px;
  padding: 0 .875rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  user-select: none;
  transition: background .12s, border-color .12s;
}
.radio-label:hover { background: var(--bg); }
.radio-label input[type="radio"] { width: 18px; height: 18px; cursor: pointer; }

.show-filter {
  display: flex;
  flex-wrap: wrap;
  gap: .375rem;
}

.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

.danger-zone {
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  background: #fff5f5;
}
.danger-zone .section-title { color: var(--error); }

.btn-warning { background: var(--warning); color: #fff; }

.form-hint {
  font-size: .8125rem;
  color: var(--muted);
  margin-top: .25rem;
}

.error-list {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
  padding: .75rem 1rem;
  margin-bottom: 1rem;
}
.error-list li {
  color: var(--error);
  font-size: .9375rem;
  margin-left: 1.25rem;
}

/* ── Calculated pallet weight ────────────────────────────────────────────── */
.weight-warn { color: var(--error); font-weight: 700; }

.slot-summary {
  padding: .625rem .875rem;
  font-size: .875rem;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  background: #f1f5f9;
}

/* ── Pallet detail action row + panels ───────────────────────────────────── */
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
.action-row .btn { flex: 1; min-width: 140px; }

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}
.panel-cancel {
  font-size: .875rem;
  color: var(--muted);
  text-decoration: none;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
}
.panel-cancel:hover { color: var(--error); text-decoration: none; }

/* ── Update Stock panel (segmented controls, state lines) ────────────────── */
.seg-row {
  display: flex;
  gap: .375rem;
  flex-wrap: wrap;
}
.seg-btn {
  flex: 1;
  min-width: 90px;
  min-height: 44px;
  padding: 0 .875rem;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  font-size: .9375rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.seg-btn:hover { background: var(--bg); }
.seg-btn.seg-active { background: var(--accent); color: #fff; border-color: var(--accent); }

.us-current {
  background: var(--bg);
  border-radius: var(--radius);
  padding: .625rem .875rem;
  font-weight: 600;
  margin-bottom: 1rem;
}
.us-preview {
  min-height: 1.5em;
  margin: 1rem 0;
  font-weight: 600;
  font-size: 1.0625rem;
}
.us-preview-pos { color: var(--success); }
.us-preview-neg { color: var(--error); }
.us-preview-bad { color: var(--error); }

/* ── Sortable table headers ──────────────────────────────────────────────── */
.sort-link {
  color: var(--muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-height: 32px;
}
.sort-link:hover { color: var(--accent); text-decoration: none; }
.sort-link.sort-active { color: var(--accent); }

/* ── Location confirmation box ───────────────────────────────────────────── */
.loc-confirm {
  margin-top: .375rem;
  padding: .5rem .75rem;
  border-radius: var(--radius);
  font-size: .875rem;
  line-height: 1.5;
}
.loc-confirm-ok  { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.loc-confirm-bad { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; font-weight: 600; }

/* ── Goods-in autocomplete ───────────────────────────────────────────────── */
.suggest-wrap { position: relative; }
.suggest-list {
  position: absolute;
  top: 2px;
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-height: 320px;
  overflow-y: auto;
}
.suggest-item {
  display: flex;
  align-items: center;
  gap: .625rem;
  width: 100%;
  padding: .75rem .875rem;
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  font-size: .9375rem;
  min-height: 48px;
}
.suggest-item:last-child { border-bottom: none; }
.suggest-item:hover, .suggest-item:focus { background: var(--bg); outline: none; }
.suggest-desc {
  color: var(--muted);
  font-size: .875rem;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.suggest-empty {
  padding: .75rem .875rem;
  color: var(--muted);
  font-size: .875rem;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .nav-links { display: none; }   /* collapsed on phone; fine on iPad */
  .nav-cards { grid-template-columns: 1fr 1fr; }
  .nav-logo  { height: 24px; }    /* shrink logo so the nav doesn't crowd */
  .nav-brand { font-size: .95rem; margin-right: .375rem; }
}
@media (max-width: 420px) {
  .nav-brand-text { display: none; }  /* very narrow: logo alone carries the brand */
}
