:root {
  --ink: #0c0c0d;
  --red: #e1141e;
  --red-dark: #b80f17;
  --gold: #ffc107;
  --paper: #f5f4f1;
  --card: #fff;
  --line: #e4e2dc;
  --text: #17171a;
  --muted: #5b5b63;
  --ok: #157f3b;
  --ok-bg: #e7f6ec;
  --warn: #8a5a00;
  --warn-bg: #fff6dc;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); font-size: 17px; line-height: 1.45; }
a { color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-top: 1.2em; }
.muted { color: var(--muted); font-weight: normal; }
.small { font-size: 0.85rem; }
.pre { white-space: pre-wrap; }

/* Top bar */
.top { background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; font-size: 1.1rem; }
.brand em { font-style: normal; color: var(--gold); }
.mark { display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; line-height: 1; letter-spacing: -0.02em; width: 36px; height: 36px; border-radius: 8px; background: #000; border: 1px solid #333; font-weight: 900; }
.mark b { color: var(--red); }
.who { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; color: #ccc; margin: 0; }
.who .link { color: #fff; }
.nav { background: #1b1b1e; display: flex; gap: 4px; padding: 6px 10px; overflow-x: auto; position: sticky; top: 0; z-index: 5; }
.nav a { color: #ddd; text-decoration: none; padding: 10px 14px; border-radius: 8px; font-weight: 600; white-space: nowrap; }
.nav a.on { background: var(--red); color: #fff; }

.wrap { max-width: 1000px; margin: 0 auto; padding: 16px; }
.flash { background: var(--ok-bg); color: var(--ok); border: 1px solid #b9e3c7; padding: 10px 14px; border-radius: var(--radius); font-weight: 600; }
.flash.warnflash { background: var(--warn-bg); color: var(--warn); border-color: #f0dca0; }
.error { background: #fdecec; color: #a40e15; border: 1px solid #f3c2c4; padding: 10px 14px; border-radius: var(--radius); font-weight: 600; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 16px; border-radius: 10px; border: 1px solid #c9c7c0; background: #fff; color: var(--text); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--ink); }
.btn.red { background: var(--red); border-color: var(--red); color: #fff; }
.btn.red:hover { background: var(--red-dark); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.big { min-height: 54px; font-size: 1.05rem; padding: 10px 22px; }
.btn.small { min-height: 36px; padding: 4px 10px; font-size: 0.9rem; }
.btn.danger { color: #a40e15; border-color: #f3c2c4; }
.link { background: none; border: 0; padding: 4px; font: inherit; text-decoration: underline; cursor: pointer; color: inherit; }
.link.danger { color: #a40e15; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 16px; }
.actions form { margin: 0; }
.actions > * { flex: 1 1 140px; }
.actions > form .btn { width: 100%; }

/* Cards and tiles */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 16px; }
.card.narrow { max-width: 460px; margin: 24px auto; }
.card.warn { background: var(--warn-bg); border-color: #f0dca0; }
.card.ok { background: var(--ok-bg); border-color: #b9e3c7; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; text-decoration: none; display: flex; flex-direction: column; }
.tile strong { font-size: 2rem; line-height: 1.1; }
.tile strong.small { font-size: 1.3rem; padding: 0.3rem 0; }
.tile span { color: var(--muted); font-size: 0.9rem; }
a.tile:hover { border-color: var(--ink); }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.plain li:last-child { border-bottom: 0; }
.log li { font-size: 0.92rem; }

.head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.head h1 { margin: 0; }
.back { margin: 0 0 8px; }
.back a { color: var(--muted); }

/* Tabs and search */
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs a { flex: 1; text-align: center; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff; text-decoration: none; font-weight: 700; }
.tabs a.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.tabs b { display: inline-block; min-width: 1.6em; padding: 0 6px; border-radius: 99px; background: rgba(127,127,127,.18); font-size: 0.85rem; }
.search { display: flex; gap: 8px; margin-bottom: 14px; }
.search input { flex: 1; min-width: 0; }

/* Item list */
.list { display: grid; gap: 10px; }
.item { display: flex; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; text-decoration: none; }
.item:hover { border-color: var(--ink); }
.thumb { flex: 0 0 110px; height: 82px; border-radius: 8px; overflow: hidden; background: #eceae4; display: grid; place-items: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.nophoto { color: var(--muted); font-size: 0.8rem; }
.info { display: flex; flex-direction: column; min-width: 0; }
.info strong { overflow-wrap: anywhere; }
.info .muted { font-size: 0.88rem; }
.stockno { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.04em; color: var(--muted); }
.price { font-weight: 800; color: var(--red-dark); }
.price.big { font-size: 1.4rem; margin: 4px 0 0; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 16px 0 8px; }
.pager .btn { flex: 0 0 auto; }
.pager .btn.off { opacity: .35; pointer-events: none; }
.pageof { font-weight: 700; text-align: center; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; background: #fff; border: 1px dashed #cfccc4; border-radius: var(--radius); }
.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 0.8rem; font-weight: 700; background: #eee; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.sold { background: var(--ink); color: var(--gold); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.warntext { color: var(--warn); font-weight: 700; }

/* Forms */
.form { display: grid; gap: 14px; }
fieldset { border: 0; padding: 0; margin: 0 0 8px; }
legend { font-weight: 800; font-size: 1.1rem; margin-bottom: 8px; padding: 0; }
.grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
label { display: grid; gap: 4px; font-weight: 600; }
label > span i { color: var(--red); font-style: normal; }
label small { font-weight: normal; color: var(--muted); }
input, select, textarea { font: inherit; font-size: 16px; width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid #c9c7c0; border-radius: 10px; background: #fff; color: var(--text); }
textarea { min-height: 100px; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(225, 20, 30, .25); border-color: var(--red); }
label.bad input, label.bad select, label.bad textarea { border-color: var(--red); background: #fff6f6; }
.err { color: #a40e15; font-style: normal; font-size: 0.9rem; }
label.check { display: flex; align-items: center; gap: 10px; font-weight: 500; }
label.check input { width: 24px; min-height: 24px; height: 24px; flex: none; }
.formbar { display: flex; flex-wrap: wrap; gap: 10px; position: sticky; bottom: 0; background: #fff; padding: 10px 0 4px; }

/* Uploads */
.upload { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-top: 12px; }
.upload label:not(.filebtn) { flex: 1 1 220px; }
.filebtn { position: relative; overflow: hidden; display: inline-flex; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; min-height: 0; }
.upload.busy { opacity: .6; pointer-events: none; }
.uploadstatus { flex-basis: 100%; }
.gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.gallery figure { margin: 0; }
.gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; display: block; background: #eceae4; }
.gallery figcaption { display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; min-height: 34px; }
.gallery figcaption form { margin: 0; }
.docs { list-style: none; padding: 0; margin: 0; }
.docs li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.docs li a { font-weight: 700; }
.docs li form { margin: 0 0 0 auto; }

/* Facts */
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 0; }
.facts div { min-width: 0; }
.facts .wide { grid-column: 1 / -1; }
.facts dt { font-size: 0.8rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.soldbox { border-color: var(--ink); }
.dangerzone { margin: 24px 0; text-align: center; }

/* Admin */
.table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr.off td { color: var(--muted); }
.rowbtns { display: flex; flex-wrap: wrap; gap: 6px; }
.rowbtns form { margin: 0; }
.temp { font-family: ui-monospace, Consolas, monospace; font-size: 1.4rem; font-weight: 700; background: #fff; padding: 10px; border-radius: 8px; user-select: all; overflow-wrap: anywhere; }

@media (max-width: 640px) {
  .table thead { display: none; }
  .table tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 0; }
  .table td { display: block; border: 0; padding: 2px 0; }
  .who span { display: none; }
}
@media (min-width: 700px) {
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .grid { grid-template-columns: 1fr 1fr; }
  .grid .wide { grid-column: 1 / -1; }
  .gallery { grid-template-columns: repeat(4, 1fr); }
  .facts { grid-template-columns: repeat(3, 1fr); }
  .thumb { flex-basis: 150px; height: 108px; }
  .list { grid-template-columns: 1fr 1fr; }
}
