:root {
  --bg: #f5f6f8; --card: #fff; --text: #1f2430; --muted: #6b7280; --line: #e3e6eb;
  --brand: #2453d4; --brand-dark: #1a3fa6;
  --green: #12805c; --green-bg: #e4f5ee; --orange: #a55a00; --orange-bg: #fff1dc;
  --red: #b42318; --red-bg: #fde8e6; --grey-bg: #eef0f3;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); }
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: 24px 0 10px; }
.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

header.top { display: flex; align-items: center; gap: 24px; background: #111827; color: #fff; padding: 0 24px; height: 54px; position: sticky; top: 0; z-index: 5; }
header.top .brand { color: #fff; font-weight: 700; font-size: 17px; }
header.top nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
header.top nav a { color: #cbd2dd; padding: 8px 12px; border-radius: 6px; white-space: nowrap; }
header.top nav a:hover, header.top nav a.active { background: #273244; color: #fff; text-decoration: none; }
header.top .user { color: #9aa4b2; white-space: nowrap; }
header.top .user a { color: #cbd2dd; }
main { max-width: 1280px; margin: 0 auto; padding: 24px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 18px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: block; color: inherit; }
a.stat:hover { border-color: var(--brand); text-decoration: none; }
.stat .num { font-size: 24px; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: 13px; }
.stat.red .num { color: var(--red); } .stat.orange .num { color: var(--orange); } .stat.green .num { color: var(--green); }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.toolbar input, .toolbar select { width: auto; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.head h1 { margin: 0; }

table { width: 100%; border-collapse: collapse; background: var(--card); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #fafbfc; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fafbff; }
td.num, th.num { text-align: right; white-space: nowrap; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.orange { background: var(--orange-bg); color: var(--orange); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.grey { background: var(--grey-bg); color: var(--muted); }

input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid #cfd4dc; border-radius: 7px; font: inherit; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bcd0ff; border-color: var(--brand); }
input[type=checkbox] { width: auto; }
textarea { min-height: 70px; }
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 12px; }
label input, label select, label textarea { margin-top: 4px; font-weight: 400; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }

.btn { display: inline-block; padding: 8px 14px; border-radius: 7px; border: 1px solid #cfd4dc; background: #fff; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--red); border-color: #f2b8b5; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
form.inline { display: inline; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; background: var(--green-bg); color: var(--green); }
.flash.err { background: var(--red-bg); color: var(--red); }
.flash.warn { background: var(--orange-bg); color: var(--orange); }
.pager { display: flex; gap: 10px; align-items: center; margin-top: 12px; color: var(--muted); }

body.center { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login { width: 360px; }
.items input { min-width: 70px; }
pre.log { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 8px; overflow-x: auto; font-size: 12px; }

@media (max-width: 760px) {
  header.top { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 8px; }
  main { padding: 14px; }
}
@media print {
  header.top, .no-print { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }
  .card { border: 0; }
}
