/* Админ-панель склада ИОЛ. Работает с телефона и компьютера. */
:root {
  --bg: #f4f6f8; --card: #fff; --text: #1d2733; --muted: #6b7785; --line: #e2e7ec;
  --brand: #0b6e8a; --brand-2: #e6f3f6; --ok: #1e7f4f; --ok-bg: #e5f5ec;
  --warn: #9a6200; --warn-bg: #fff4dc; --err: #b42318; --err-bg: #fdecea;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.top { background: #0f2a36; color: #fff; position: sticky; top: 0; z-index: 10; }
.top-in { display: flex; align-items: center; gap: 12px; padding: 0 16px; min-height: 52px; max-width: 1280px; margin: 0 auto; }
.brand { font-weight: 700; color: #fff; white-space: nowrap; }
.nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: #cfe3ea; padding: 15px 10px; white-space: nowrap; font-size: 14px; }
.nav a.on, .nav a:hover { color: #fff; text-decoration: none; box-shadow: inset 0 -3px 0 #4fc3dc; }
.me { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #cfe3ea; white-space: nowrap; }
.me button { background: transparent; border: 1px solid #45606c; color: #fff; padding: 4px 10px; }
main { max-width: 1280px; margin: 0 auto; padding: 20px 16px 60px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: block; color: var(--text); }
.kpi b { display: block; font-size: 26px; line-height: 1.1; }
.kpi span { color: var(--muted); font-size: 13px; }
.kpi.alert { border-color: #f0b4ae; background: var(--err-bg); }
.cols { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; }
tr:hover td { background: #fafcfd; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; background: var(--brand-2); color: var(--brand); white-space: nowrap; }
.badge.pending, .badge.needs_owner, .badge.reserved, .badge.inspection, .badge.returned { background: var(--warn-bg); color: var(--warn); }
.badge.new { background: #e8eefc; color: #2948a8; }
.badge.picked, .badge.issued, .badge.available, .badge.restocked { background: var(--ok-bg); color: var(--ok); }
.badge.rejected, .badge.cancelled, .badge.written_off, .badge.owner_denied, .badge.blocked { background: var(--err-bg); color: var(--err); }
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 12px; background: var(--ok-bg); color: var(--ok); border: 1px solid #b9e2c9; }
.flash.err { background: var(--err-bg); color: var(--err); border-color: #f0b4ae; }
form.inline { display: inline; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 12px; }
.filters label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
label.check { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid #cad3db; border-radius: 8px; background: #fff; color: var(--text); max-width: 100%; }
input[type=checkbox] { width: 18px; height: 18px; }
textarea { width: 100%; min-height: 80px; }
input.wide, select.wide { width: 100%; }
button, .btn { font: inherit; cursor: pointer; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--brand); background: var(--brand); color: #fff; display: inline-block; }
.btn:hover { text-decoration: none; filter: brightness(1.08); }
button.ghost, .btn.ghost { background: #fff; color: var(--brand); }
button.danger { background: var(--err); border-color: var(--err); }
button.small, .btn.small { padding: 4px 10px; font-size: 13px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pager { display: flex; gap: 8px; margin-top: 12px; }
.login { max-width: 360px; margin: 10vh auto; }
.code { font-family: ui-monospace, monospace; background: #f1f4f6; padding: 2px 6px; border-radius: 6px; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }
.test-ok { color: var(--ok); } .test-err { color: var(--err); }
@media (max-width: 760px) {
  .top-in { flex-wrap: wrap; gap: 0 12px; padding-top: 6px; }
  .brand { flex: 1; }
  .nav { order: 3; flex-basis: 100%; flex-wrap: wrap; padding-bottom: 4px; }
  .nav a { padding: 6px 8px; border-radius: 6px; }
  .nav a.on { box-shadow: none; background: #24485a; }
}
@media (max-width: 600px) {
  .row > *, .filters > * { min-width: 0; max-width: 100%; }
  label.field select { width: 100%; }
  .me span { display: none; }
  th, td { padding: 7px 6px; }
  h1 { font-size: 19px; }
}

/* ---------- диаграммы (чистый HTML/CSS, без внешних библиотек) ---------- */
.hbars { display: grid; gap: 6px; }
.hbar { display: grid; grid-template-columns: minmax(110px, 34%) 1fr; gap: 10px; align-items: center; font-size: 13px; }
.hbar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { background: #eef2f5; border-radius: 6px; height: 22px; position: relative; overflow: hidden; }
.hbar .fill { background: #8fcbd9; height: 100%; border-radius: 6px; min-width: 2px; }
.hbar .val { position: absolute; left: 8px; top: 2px; font-size: 12px; color: #12323e; white-space: nowrap; }
.hbar .fill.alt { background: #b9dfe7; }
.vbars { display: flex; align-items: flex-end; gap: 8px; height: 190px; padding-top: 18px; border-bottom: 1px solid var(--line); }
.vbar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; }
.vbar .col { width: 70%; max-width: 54px; background: var(--brand); border-radius: 6px 6px 0 0; min-height: 2px; position: relative; }
.vbar .col span { position: absolute; top: -17px; left: 50%; transform: translateX(-50%); font-size: 11px; white-space: nowrap; color: var(--muted); }
.vlabels { display: flex; gap: 8px; margin-top: 4px; }
.vlabels div { flex: 1; text-align: center; font-size: 12px; color: var(--muted); min-width: 0; }
.heat td.cell { text-align: center; font-variant-numeric: tabular-nums; }
.legend-note { font-size: 12px; color: var(--muted); margin-top: 6px; }
.badge.urgent { background: var(--err-bg); color: var(--err); }
.badge.buy { background: var(--warn-bg); color: var(--warn); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.excess, .badge.dead { background: #eef0f3; color: #4a5562; }
.badge.paid { background: var(--ok-bg); color: var(--ok); }
.badge.partial { background: var(--warn-bg); color: var(--warn); }
.badge.unpaid { background: var(--err-bg); color: var(--err); }
.debt { color: var(--err); font-weight: 600; }
.prepaid { color: var(--ok); font-weight: 600; }
