/* ── 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; }

/* ── 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 {
  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; }

.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; }

/* 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; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .nav-links { display: none; }   /* collapsed on phone; fine on iPad */
  .nav-cards { grid-template-columns: 1fr 1fr; }
}
