:root {
  --bg: #f5f6f8; --panel: #fff; --text: #1d2330; --muted: #667085; --line: #e3e6eb;
  --accent: #2456d6; --accent-soft: #e8eefc; --danger: #c0352b; --ok: #1f8a4c; --warn: #b7791f;
  --radius: 8px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/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; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
.mono, code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

header.top { background: #111827; color: #fff; }
header.top .inner { max-width: 1200px; margin: 0 auto; padding: .6rem 1rem; display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; align-items: center; }
header.top a { color: #d1d5db; }
header.top a:hover, header.top a.active { color: #fff; text-decoration: none; }
header.top .brand { color: #fff; font-weight: 700; letter-spacing: .02em; }
header.top nav { display: flex; flex-wrap: wrap; gap: .25rem 1rem; flex: 1; }
header.top form { margin: 0; }
header.top .user { display: flex; gap: .75rem; align-items: center; color: #9ca3af; font-size: .9rem; }
header.top button.link { background: none; border: 0; color: #d1d5db; cursor: pointer; padding: 0; font: inherit; }

main { max-width: 1200px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: 2fr 1fr; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }
.stats { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-bottom: 1rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem; }
.stat .n { font-size: 1.5rem; font-weight: 700; }
.stat .l { color: var(--muted); font-size: .85rem; }
.head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.head h1 { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.actions form { margin: 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 700; border-top: 2px solid var(--line); }
dl.props { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
dl.props dt { color: var(--muted); }
dl.props dd { margin: 0; }

.badge { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .8rem; font-weight: 600; background: #eef0f3; color: #394150; white-space: nowrap; }
.badge.available, .badge.approved, .badge.fulfilled { background: #e3f5ea; color: var(--ok); }
.badge.checked_out { background: var(--accent-soft); color: var(--accent); }
.badge.reserved, .badge.pending { background: #fdf3e1; color: var(--warn); }
.badge.in_repair, .badge.overdue, .badge.rejected { background: #fbe7e5; color: var(--danger); }
.badge.retired, .badge.cancelled { background: #eceef1; color: #6b7280; }

.btn, button { display: inline-block; background: var(--accent); color: #fff; border: 1px solid var(--accent); border-radius: 6px; padding: .4rem .85rem; font: inherit; font-size: .9rem; cursor: pointer; line-height: 1.4; }
.btn:hover, button:hover { filter: brightness(1.08); text-decoration: none; }
.btn.secondary, button.secondary { background: #fff; color: var(--text); border-color: var(--line); }
.btn.danger, button.danger { background: var(--danger); border-color: var(--danger); }
.btn.sm, button.sm { padding: .15rem .55rem; font-size: .8rem; }

form.stacked .field { margin-bottom: .9rem; }
form.stacked label { display: block; font-weight: 600; margin-bottom: .25rem; font-size: .9rem; }
form.stacked .check label { display: inline; font-weight: 600; }
input[type=text], input[type=email], input[type=number], input[type=date], input[type=password], input[type=search], input[type=file], select, textarea {
  width: 100%; padding: .45rem .6rem; border: 1px solid #cfd4dc; border-radius: 6px; font: inherit; background: #fff;
}
input[type=checkbox] { width: auto; }
textarea.mono { font-family: ui-monospace, monospace; font-size: .85rem; }
.form-cols { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.helptext { display: block; color: var(--muted); font-size: .8rem; margin-top: .2rem; }
ul.errorlist { list-style: none; margin: .25rem 0; padding: 0; color: var(--danger); font-size: .85rem; }
ul.errorlist.nonfield { background: #fbe7e5; padding: .5rem .75rem; border-radius: 6px; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; margin-bottom: 1rem; }
.filters > * { flex: 1 1 160px; }
.filters button { flex: 0 0 auto; }

.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { padding: .6rem .9rem; border-radius: 6px; margin-bottom: .4rem; background: var(--accent-soft); }
.messages li.success { background: #e3f5ea; color: #14532d; }
.messages li.error { background: #fbe7e5; color: #7f1d1d; }
.messages li.warning { background: #fdf3e1; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: .5rem 0 .5rem 1rem; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: .85rem; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.timeline .when { color: var(--muted); font-size: .8rem; }
.pagination { display: flex; gap: .75rem; align-items: center; margin-top: 1rem; }
.login { max-width: 380px; margin: 4rem auto; }
.empty { color: var(--muted); padding: .5rem 0; }

/* Printable label: 62mm x 29mm-ish tape, but readable on A4 too. */
.label-sheet { display: flex; justify-content: center; padding: 2rem 0; }
.label { display: flex; gap: 12px; align-items: center; border: 1px dashed #999; padding: 10px 14px; background: #fff; width: 90mm; }
.label .qr svg { width: 28mm; height: 28mm; display: block; }
.label .tag { font: 700 20px/1.1 ui-monospace, monospace; }
.label .meta { font-size: 11px; color: #333; }
@media print {
  header.top, .no-print, .messages { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }
  .label { border: 0; }
}
