:root {
  --ink: #172033;
  --muted: #64748b;
  --line: #e5e9f2;
  --paper: #f5f7fb;
  --panel: #ffffff;
  --blue: #2563eb;
  --teal: #0f766e;
  --rose: #b42318;
  --amber: #b54708;
  --navy: #0f3f5f;
  --soft-blue: #eff6ff;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
  color: var(--ink);
  background: var(--paper);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.auth-screen { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: var(--paper); }
.auth-card { width: min(430px, 100%); display: grid; gap: 14px; padding: 28px; background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 18px 50px rgba(15,23,42,.12); }
.auth-card h1 { font-size: 26px; margin: 0; }
.auth-card > div:not(.brand) { display: grid; gap: 12px; }
.auth-brand { margin-bottom: 6px; }
.auth-error { min-height: 20px; color: var(--rose); font-weight: 700; }
.sidebar {
  background: rgba(245,247,251,.96);
  color: var(--ink);
  border-right: 1px solid var(--line);
  padding: 24px 18px;
  min-height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.mark {
  width: 42px; height: 42px; display: grid; place-items: center;
  border: 1px solid #dbe3ec; background: #fff; color: var(--blue); font-weight: 800; border-radius: 12px;
}
.brand span { display: block; color: #94a3b8; font-size: 12px; }
nav { display: grid; gap: 8px; }
button, select, input, textarea {
  font: inherit;
}
button, .button-link {
  border: 0;
  background: var(--blue);
  color: #fff;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
button:hover, .button-link:hover { transform: translateY(-1px); box-shadow: 0 5px 14px rgba(16,42,67,.14); }
button:active, .button-link:active { transform: translateY(0); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .button-link:focus-visible { outline: 3px solid rgba(42,157,143,.3); outline-offset: 2px; }
.button-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
button.secondary { background: var(--teal); }
button.danger { background: var(--rose); }
button.ghost { background: #e9eef4; color: var(--ink); }
.nav {
  text-align: left;
  background: transparent;
  color: #64748b;
  border-left: 0;
  border-radius: 12px;
}
.nav:hover { background: #fff; color: var(--ink); box-shadow: none; transform: none; }
.nav.active { background: var(--blue); color: #fff; box-shadow: 0 6px 16px rgba(37,99,235,.2); }
.sync-card {
  margin-top: auto;
  border: 1px solid var(--line);
  padding: 12px;
  border-radius: 8px;
  display: grid;
  gap: 10px;
}
main { padding: 28px clamp(18px, 3vw, 42px); min-width: 0; max-width: 1600px; width: 100%; }
.app-header { background: rgba(255,255,255,.82); border: 1px solid var(--line); border-radius: 16px; padding: 22px; box-shadow: 0 10px 30px rgba(15,23,42,.045); }
header {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(320px, 560px);
  gap: 18px;
  align-items: end;
}
h1, h2, p { margin: 0; }
h1 { font-size: clamp(24px, 3vw, 34px); letter-spacing: -.02em; }
h2 { font-size: 16px; margin-bottom: 14px; }
header p, .hint { color: var(--muted); }
.eyebrow { color: var(--teal); font-size: 11px; font-weight: 800; letter-spacing: .12em; margin-bottom: 4px; }
.scanner { display: flex; gap: 8px; background: #f3f8fa; border: 1px solid #d7e7eb; border-radius: 8px; padding: 6px; }
.scanner input { border-color: transparent; background: transparent; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 6px;
  min-height: 38px;
  padding: 8px 10px;
}
textarea { min-height: 76px; resize: vertical; }
label { display: grid; gap: 6px; color: var(--muted); font-weight: 700; }
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
  margin: 22px 0;
}
.metrics div, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.metrics div { border-top: 3px solid var(--teal); box-shadow: 0 3px 12px rgba(16,42,67,.04); }
.metrics div:nth-child(2) { border-top-color: var(--amber); }
.metrics div:nth-child(3) { border-top-color: var(--blue); }
.metrics div:nth-child(4) { border-top-color: var(--rose); }
.metrics span { color: var(--muted); display: block; }
.metrics strong { font-size: 28px; }
.tab { display: none; }
.tab.active { display: block; }
.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 16px;
}
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.section-heading h2 { margin: 0 0 3px; font-size: 20px; }
.section-heading input { max-width: 330px; }
.panel { display: grid; gap: 12px; align-content: start; }
.panel > h2 { color: var(--navy); }
.panel { box-shadow: 0 10px 30px rgba(15,23,42,.045); }
.wide { min-width: 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.compact { gap: 4px; }
.row.compact button { min-height: 30px; padding: 0 9px; }
.grid.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid.four { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.basket { display: grid; gap: 8px; min-height: 120px; }
.basket.empty { color: var(--muted); place-items: center; border: 1px dashed var(--line); border-radius: 8px; }
.chip, .list-item {
  border: 1px solid var(--line);
  background: #fbfcfe;
  border-radius: 7px;
  padding: 10px;
}
.chip { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.toolbar { display: flex; gap: 10px; margin-bottom: 12px; align-items: center; flex-wrap: wrap; }
.toolbar > input { flex: 1 1 240px; }
.toolbar > select { width: 160px; }
.toolbar .button-link { min-height: 38px; }
.bulk-hint { color: var(--muted); background: #eef6f8; border: 1px solid #d5e9ee; border-radius: 6px; padding: 10px 12px; margin-bottom: 12px; }
.count-input { width: 86px; min-height: 32px; padding: 5px 7px; }
.table-wrap {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  max-height: 62vh;
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; background: #edf4f7; z-index: 1; }
.low { color: var(--amber); font-weight: 800; }
.out { color: var(--rose); font-weight: 800; }
.positive { color: var(--teal); font-weight: 800; }
.empty-cell { text-align: center; color: var(--muted); padding: 34px; }
.list { display: grid; gap: 10px; max-height: 62vh; overflow: auto; }
.list-item header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.list-item small, .muted { color: var(--muted); }
.lines { margin-top: 8px; color: var(--muted); }
.status { display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 8px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.status-in_transit { color: #176b87; background: #e6f4f8; }
.status-delivered, .status-partially_returned { color: #8a5a08; background: #fff4d8; }
.status-returned, .status-cancelled { color: #18705f; background: #e5f6f1; }
.status-lost { color: #8f1d3a; background: #ffe8ed; }
.status-open { color: #8a5a08; background: #fff4d8; }
.return-guide { display: grid; gap: 4px; padding: 12px; background: var(--soft-blue); border-left: 4px solid var(--teal); color: var(--navy); }
.return-guide span { color: var(--muted); }
.return-outstanding { padding: 12px; border: 1px solid var(--line); border-radius: 7px; background: #fbfcfe; }
.return-scanner { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.return-summary { color: var(--muted); font-size: 13px; min-height: 20px; }
.mini-remove { min-height: 24px; padding: 0 6px; margin-left: 6px; background: transparent; color: var(--rose); font-size: 12px; }
.mini-remove:hover { background: #fff0f3; box-shadow: none; }
.settings { max-width: 720px; }
.staff-panel { margin-top: 16px; }
.staff-list { display: grid; gap: 8px; margin-top: 4px; }
.staff-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 7px; background: #fbfcfe; }
.staff-row small { display: block; color: var(--muted); }
.check { display: flex; grid-template-columns: auto 1fr; align-items: center; flex-direction: row; }
.check input { width: auto; }
#toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #0f3f5f;
  color: white;
  box-shadow: 0 12px 28px rgba(16,42,67,.2);
  transform: translateY(80px);
  opacity: 0;
  transition: .2s ease;
}
#toast.show { transform: translateY(0); opacity: 1; }
dialog {
  border: 0;
  border-radius: 8px;
  padding: 0;
  width: min(680px, calc(100vw - 28px));
  box-shadow: 0 24px 80px rgba(16,42,67,.28);
}
dialog::backdrop { background: rgba(16,42,67,.35); }
.dialog-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  background: #fff;
}
.dialog-card header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}
.basket-preview {
  min-height: 48px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.basket-preview span {
  background: #eef6f8;
  border: 1px solid #d5e9ee;
  border-radius: 6px;
  padding: 6px 8px;
}
dialog[open] { animation: dialog-in .16s ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: translateY(0) scale(1); } }
@media (max-width: 900px) {
  body { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 5; }
  nav { grid-template-columns: repeat(2, 1fr); }
  header, .workspace, .metrics, .grid.two { grid-template-columns: 1fr; }
  .grid.four { grid-template-columns: repeat(2, 1fr); }
  .chip { align-items: stretch; flex-direction: column; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .section-heading input { max-width: none; }
  .toolbar > select, .toolbar .button-link, .toolbar button { width: 100%; }
  .return-scanner { grid-template-columns: 1fr; }
}
