/* CrateFlow WMS — self-contained stylesheet. No CDN dependency on purpose:
   warehouse floor terminals are often on restricted or offline networks. */

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #0f172a;
  background: #f8fafc;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
table { border-collapse: collapse; width: 100%; }
h1, h2, h3, h4 { margin: 0; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

/* ---------------------------- Layout shell ---------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
}
.sidebar-brand {
  height: 64px; flex-shrink: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px; border-bottom: 1px solid #e2e8f0;
}
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: #4f46e5; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.brand-name { font-size: 14px; font-weight: 700; line-height: 1.2; }
.brand-sub { font-size: 12px; color: #94a3b8; line-height: 1.2; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; margin-bottom: 2px; border-radius: 8px;
  font-size: 14px; font-weight: 500; color: #475569;
}
.nav-item:hover { background: #f1f5f9; }
.nav-item.active { background: #eef2ff; color: #4338ca; }
.nav-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; opacity: .55; }

.sidebar-footer {
  padding: 16px; border-top: 1px solid #e2e8f0; flex-shrink: 0;
  font-size: 12px; color: #94a3b8;
}

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 64px; flex-shrink: 0; background: #fff; border-bottom: 1px solid #e2e8f0;
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
}
.topbar h1 { font-size: 18px; font-weight: 600; }
.main-content { flex: 1; padding: 24px; overflow-y: auto; }
.content-narrow { max-width: 1160px; }

/* ------------------------------- Grid/flex ------------------------------- */
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

/* --------------------------------- Cards --------------------------------- */
.card { background: #fff; border: 1px solid #e2e8f0; border-radius: 16px; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
a.card { transition: box-shadow .12s, border-color .12s; text-decoration: none; }
a.card:hover { box-shadow: 0 4px 14px rgba(15,23,42,.08); border-color: #cbd5e1; }
.card-pad { padding: 20px; }

.stat-card { display: flex; align-items: flex-start; gap: 14px; padding: 20px; }
.stat-icon {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.tone-indigo  { background: #eef2ff; color: #4f46e5; }
.tone-emerald { background: #ecfdf5; color: #059669; }
.tone-amber   { background: #fffbeb; color: #d97706; }
.tone-red     { background: #fef2f2; color: #dc2626; }
.tone-blue    { background: #eff6ff; color: #2563eb; }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 13px; color: #64748b; margin-top: 3px; }
.stat-sub { font-size: 12px; color: #94a3b8; margin-top: 3px; }

/* -------------------------------- Buttons -------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 14px; font-weight: 500; padding: 9px 15px; border-radius: 8px;
  border: 1px solid transparent; cursor: pointer; background: none; line-height: 1.2;
}
.btn-primary { background: #4f46e5; color: #fff; }
.btn-primary:hover { background: #4338ca; }
.btn-secondary { background: #fff; color: #334155; border-color: #cbd5e1; }
.btn-secondary:hover { background: #f8fafc; }
.btn-ghost { background: none; color: #475569; }
.btn-ghost:hover { background: #f1f5f9; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-subtle { background: #eef2ff; color: #4338ca; }
.btn-subtle:hover { background: #e0e7ff; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }

/* --------------------------------- Badges --------------------------------- */
.badge {
  display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 500; border: 1px solid transparent; white-space: nowrap;
}
.badge-slate   { background: #f1f5f9; color: #334155; border-color: #e2e8f0; }
.badge-amber   { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.badge-blue    { background: #dbeafe; color: #1d4ed8; border-color: #bfdbfe; }
.badge-violet  { background: #ede9fe; color: #6d28d9; border-color: #ddd6fe; }
.badge-emerald { background: #d1fae5; color: #047857; border-color: #a7f3d0; }
.badge-red     { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.badge-orange  { background: #ffedd5; color: #c2410c; border-color: #fed7aa; }
.badge-indigo  { background: #e0e7ff; color: #4338ca; border-color: #c7d2fe; }

/* --------------------------------- Forms --------------------------------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 500; color: #475569; margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; font-size: 14px; padding: 9px 12px; border: 1px solid #cbd5e1;
  border-radius: 8px; font-family: inherit; background: #fff; color: #0f172a;
}
.input:focus { outline: none; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
textarea.input { resize: vertical; }
.input-sm { width: auto; display: inline-block; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #475569; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 12px; }
@media (max-width: 600px) { .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; } }

/* --------------------------------- Tables --------------------------------- */
.table-wrap { overflow-x: auto; }
table.data th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: #64748b; background: #f8fafc; padding: 11px 16px; font-weight: 600;
  border-bottom: 1px solid #e2e8f0;
}
table.data td { padding: 12px 16px; font-size: 14px; border-bottom: 1px solid #f1f5f9; color: #334155; }
table.data tr:last-child td { border-bottom: none; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover { background: #f8fafc; }
.text-right { text-align: right; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.muted { color: #94a3b8; }
.small { font-size: 12px; }

/* -------------------------------- Filters -------------------------------- */
.filter-chip {
  padding: 7px 13px; border-radius: 8px; font-size: 12px; font-weight: 500;
  border: 1px solid #e2e8f0; background: #fff; color: #475569;
}
.filter-chip.active { background: #4f46e5; color: #fff; border-color: #4f46e5; }
.filter-chip .count { opacity: .7; }

/* ------------------------------ Status stepper ------------------------------ */
.stepper { display: flex; align-items: center; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: #cbd5e1; white-space: nowrap; }
.step.done { color: #4f46e5; }
.step-dot { width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1; }
.step.done .step-dot { background: #4f46e5; }
.step-line { flex: 1; min-width: 20px; height: 1px; background: #e2e8f0; }
.step-line.done { background: #4f46e5; }

/* ------------------------------- Toggle switch ------------------------------- */
.toggle { position: relative; width: 40px; height: 22px; border-radius: 999px; border: none; cursor: pointer; background: #e2e8f0; padding: 0; flex-shrink: 0; }
.toggle.on { background: #10b981; }
.toggle .knob { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.toggle.on .knob { transform: translateX(18px); }

/* --------------------------------- Barcode --------------------------------- */
.barcode { display: flex; align-items: flex-end; height: 48px; }
.bc-bar { display: inline-block; height: 100%; background: #0f172a; }
.bc-gap { display: inline-block; height: 60%; background: transparent; }

/* ------------------------------- Progress bars ------------------------------- */
.progress-track { width: 100%; height: 8px; background: #f1f5f9; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: #6366f1; border-radius: 999px; }

/* -------------------------------- Alert boxes -------------------------------- */
.alert { border-radius: 12px; padding: 14px 16px; font-size: 14px; }
.alert-success { background: #ecfdf5; border: 1px solid #a7f3d0; color: #047857; }
.alert-error   { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }

/* -------------------------------- Misc utility -------------------------------- */
.empty-note { text-align: center; color: #94a3b8; font-size: 14px; padding: 32px 0; }
.divider { border: none; border-top: 1px dashed #e2e8f0; margin: 12px 0; }
.avatar-sq { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.link-action { color: #4f46e5; font-size: 12px; font-weight: 500; }
.link-action:hover { text-decoration: underline; }
.section-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.opacity-60 { opacity: .6; }

/* -------------------------------- Print label -------------------------------- */
.label-sheet {
  border: 2px dashed #cbd5e1; border-radius: 14px; padding: 20px; max-width: 420px; margin: 0 auto;
}
.dispatch-note-sheet { border: 1px solid #e2e8f0; border-radius: 14px; overflow: hidden; max-width: 640px; margin: 0 auto; }
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .print-sheet { border: none !important; box-shadow: none !important; margin: 0 !important; max-width: none !important; }
}
