:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1d2330;
  --muted: #667085;
  --border: #e3e6eb;
  --accent: #2357c6;
  --accent-soft: #e8eefb;
  --ok: #157a3c;
  --ok-soft: #e3f4e9;
  --warn: #9a5b00;
  --warn-soft: #fdf1dc;
  --bad: #b42318;
  --bad-soft: #fde8e7;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

header.top {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
header.top .inner {
  max-width: 1400px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
}
header.top .brand { font-weight: 700; font-size: 16px; color: var(--text); }
header.top nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
header.top nav a {
  padding: 6px 12px; border-radius: 6px; color: var(--text);
}
header.top nav a.active, header.top nav a:hover { background: var(--accent-soft); text-decoration: none; }
header.top .user { color: var(--muted); display: flex; gap: 12px; align-items: center; }
header.top .user form { margin: 0; }

main { max-width: 1400px; margin: 0 auto; padding: 20px 16px 48px; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 28px 0 10px; }
.muted { color: var(--muted); }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px; margin-bottom: 16px;
}
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.stat .value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .label { color: var(--muted); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: #fafbfc; font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.best td { background: var(--ok-soft); }
tr.unavailable td { color: var(--muted); }

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }

form.inline { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
form p { margin: 0 0 12px; }
label { display: block; font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=number], input[type=password], input[type=file], select {
  font: inherit; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); min-width: 0; max-width: 100%;
}
input[name=q] { width: 420px; }
.helptext { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
button, .button {
  font: inherit; font-weight: 600; padding: 7px 16px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
}
button.link { background: none; border: 0; color: var(--accent); padding: 0; font-weight: 400; }
a.button { display: inline-block; text-decoration: none; }
select.supplier-select { max-width: 280px; font-size: 13px; padding: 3px 5px; }

.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { padding: 10px 14px; border-radius: 8px; background: var(--ok-soft); color: var(--ok); }
.messages li.error { background: var(--bad-soft); color: var(--bad); }
.errorlist { color: var(--bad); margin: 4px 0; padding-left: 18px; }

.summary { display: flex; gap: 24px; flex-wrap: wrap; align-items: baseline; }
.summary .big { font-size: 20px; font-weight: 700; }
pre.msg { white-space: pre-wrap; margin: 0; font: inherit; max-width: 640px; }
.pagination { margin-top: 12px; display: flex; gap: 12px; }

main.wide { max-width: none; }
.grid-table td, .grid-table th { padding: 4px 6px; font-size: 13px; }
.grid-table th { white-space: normal; line-height: 1.25; }
.grid-table input, .grid-table select { padding: 3px 5px; font-size: 13px; }
.grid-table input.w-num { width: 76px; }
.grid-table select { max-width: 150px; }
.grid-table td.stack > input, .grid-table td.stack > select { display: block; margin-bottom: 3px; }
.grid-table td.order-cell { min-width: 260px; max-width: 420px; }
tr.shortage td { background: var(--warn-soft); }
/* LT pardavimų spalvos (kaip Excel'yje) */
tr.lt-invoiced td, .legend.lt-invoiced { background: #d8efc3; }
tr.lt-informed td, .legend.lt-informed { background: #cdeefc; }
tr.lt-cancelled td, tr.lt-returned td, .legend.lt-cancelled { background: #e2e4e8; color: var(--muted); }
tr.lt-issue td, .legend.lt-issue { background: #fbd5d2; }
.legend { padding: 1px 8px; border-radius: 4px; margin-left: 6px; color: var(--text); }
.inline-check { display: inline-flex; gap: 4px; align-items: center; font-weight: 400; font-size: 12px; margin-top: 3px; }
tr.inactive td { background: #e9ebef; color: var(--muted); }
tr.inactive td a, tr.inactive td strong { color: var(--muted); }
tr.inactive input, tr.inactive select { background: #f3f4f6; color: var(--muted); }
.nowrap { white-space: nowrap; }
td.neg { color: var(--bad); }
button.secondary { background: var(--surface); color: var(--accent); }

.card.alert { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.card.alert-soft { border-color: var(--bad); border-width: 2px; }
.big.neg { color: var(--bad); }
tr.alert td { background: var(--bad-soft); }
.note { margin-top: 4px; color: var(--warn); }
.badge.status-new { background: var(--accent-soft); color: var(--accent); }
.badge.status-ordered { background: var(--warn-soft); color: var(--warn); }
.badge.status-received { background: #efe7fb; color: #6b3fc0; }
.badge.status-shipped { background: var(--ok-soft); color: var(--ok); }
.badge.status-cancelled, .badge.status-returned { background: #eef0f3; color: var(--muted); }

h2.courier { border-bottom: 2px solid var(--text); padding-bottom: 4px; }
h3 { font-size: 15px; margin: 16px 0 8px; }
.big-name { font-size: 15px; }
strong.sku { font-size: 15px; letter-spacing: .2px; }
.pack-line + .pack-line { margin-top: 6px; }
.cancel-flag { margin-top: 4px; font-weight: 800; color: #fff; background: var(--bad); padding: 2px 8px;
  border-radius: 4px; display: inline-block; letter-spacing: .3px; }
.wh-codes { margin-top: 3px; font-size: 12px; color: var(--accent); }
.badge.status-awaiting_pack { background: #e6f3fb; color: #1d6a96; }
.badge.status-shortage { background: var(--bad-soft); color: var(--bad); }
table.packer tr.same-package td { border-top: 0; }
.print-only { display: none; }

.login-box { max-width: 360px; margin: 80px auto; }

@media print {
  header.top, .no-print, .messages { display: none !important; }
  .print-only { display: table-cell; }
  .check-col { width: 24px; font-size: 18px; }
  table.packer td, table.packer th { border-bottom: 1px solid #999; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .table-wrap { border: 0; }
  table.packing tr { page-break-inside: avoid; }
  a { color: inherit; }
}
.login-box input { width: 100%; }

@media (max-width: 640px) {
  input[name=q] { width: 100%; }
  form.inline > p { width: 100%; }
}
