:root {
  --red: #AA151B;
  --red-dark: #8a1015;
  --yellow: #F1BF00;
  --yellow-soft: #fff3c4;
  --bg: #fffbf0;
  --paper: #ffffff;
  --ink: #2a1a14;
  --muted: #7a6a5f;
  --line: #eadfc4;
  --green: #1f7a3d;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--red); }
img { max-width: 100%; display: block; }
h1 { font-size: 1.6rem; margin: .4em 0 .5em; line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 1em 0 .4em; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.main { padding-top: 12px; padding-bottom: 40px; min-height: 60vh; }
.narrow { max-width: 680px; margin: 0 auto; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.inline { display: inline; margin: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
[hidden] { display: none !important; }

/* flaga: czerwień - żółć - czerwień */
.flagbar { display: flex; height: 10px; }
.flagbar i { display: block; flex: 1; background: var(--red-dark); }
.flagbar i:nth-child(2) { flex: 2; background: var(--yellow); }
.site-header { background: var(--red); color: #fff; border-bottom: 4px solid var(--yellow); }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
.logo { color: #fff; text-decoration: none; font-weight: 800; font-size: 1.25rem; letter-spacing: .2px; }
.logo small { font-weight: 500; opacity: .8; font-size: .8rem; margin-left: 4px; }
.nav { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.nav a, .nav .linkbtn { color: #fff; text-decoration: none; font-weight: 600; padding: 4px 2px; border-bottom: 2px solid transparent; }
.nav a:hover, .nav a.on { border-bottom-color: var(--yellow); }
.badge { background: var(--yellow); color: var(--red-dark); border-radius: 999px; padding: 0 7px; font-size: .8rem; font-weight: 800; margin-left: 2px; }
.site-footer { background: #2a1a14; color: #e9dcc5; padding: 20px 0; font-size: .9rem; }
.site-footer a { color: var(--yellow); }
.site-footer p { margin: .3em 0; }
.site-footer .muted { color: #a99a87; }

/* przyciski i formularze */
.btn { display: inline-block; background: var(--red); color: #fff; border: 2px solid var(--red); border-radius: var(--radius); padding: 9px 16px; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; text-align: center; }
.btn:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn.ghost { background: transparent; color: var(--red); }
.btn.ghost:hover { background: var(--yellow-soft); }
.btn.alt { background: var(--yellow); border-color: var(--yellow); color: #3b2a00; }
.btn.alt:hover { background: #dba900; border-color: #dba900; }
.btn.danger { background: #b3261e; border-color: #b3261e; }
.btn.small { padding: 5px 10px; font-size: .9rem; white-space: nowrap; }
.btn.big { padding: 13px 20px; font-size: 1.05rem; }
.btn.block { display: block; width: 100%; margin-top: 10px; }
.btn[disabled] { opacity: .55; cursor: wait; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--red); cursor: pointer; text-decoration: underline; }
.danger-text { color: #b3261e; }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1.5px solid #d9ccae; border-radius: 8px; padding: 9px 10px; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--yellow); border-color: var(--red); }
input[type=checkbox], input[type=radio] { width: auto; }
label { display: block; font-weight: 600; font-size: .92rem; margin: 10px 0; }
label input, label select, label textarea { margin-top: 4px; font-weight: 400; }
label.check, label.choice { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; }
label.choice { border: 1.5px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #fff; align-items: center; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); margin: 0 0 14px; padding: 6px 14px 12px; }
legend { font-weight: 800; padding: 0 6px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.four { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.err { color: #b3261e; font-weight: 600; font-size: .85rem; display: block; margin-top: 3px; }
.err-box, .notice.err-box { background: #fde8e6; border-color: #f4b4ae; }
.notice { background: var(--yellow-soft); border: 1px solid #ecd37a; border-radius: 8px; padding: 10px 12px; }
.notice.ok { background: #e6f4ea; border-color: #b6dcc0; }
.tag { display: inline-block; background: var(--yellow-soft); border: 1px solid #ecd37a; border-radius: 999px; padding: 0 9px; font-size: .78rem; font-weight: 700; }
.tag.available { background: #e6f4ea; border-color: #b6dcc0; color: var(--green); }
.tag.reserved { background: #fff0d6; }
.tag.sold, .tag.st-cancelled { background: #eee; border-color: #ccc; color: #555; }
.tag.hid { background: #eee; }
.tag.st-pending_payment { background: #fff0d6; }
.tag.st-paid { background: #dbeafe; border-color: #a9c7f2; }
.tag.st-shipped { background: #e6f4ea; border-color: #b6dcc0; }

/* katalog */
.hero { background: linear-gradient(135deg, var(--red), var(--red-dark)); color: #fff; border-radius: 14px; padding: 18px 20px; margin: 10px 0 16px; border-bottom: 5px solid var(--yellow); }
.hero h1 { margin-top: 0; }
.hero p { margin: .3em 0; max-width: 60ch; }
.promo { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.promo li { background: rgba(255,255,255,.14); border-radius: 999px; padding: 3px 12px; font-size: .92rem; }
.promo li.free { background: var(--yellow); color: #3b2a00; font-weight: 600; }
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 8px; margin-bottom: 8px; }
.count { margin: 4px 0 10px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.card .cover { display: block; aspect-ratio: 2 / 3; background: #f3ead2; }
.card .cover img { width: 100%; height: 100%; object-fit: cover; }
.nocover { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; min-height: 80px; font-size: 2.2rem; background: #f3ead2; }
.card-body { padding: 10px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.card h2 { font-size: 1rem; margin: 0; line-height: 1.25; }
.card h2 a { color: var(--ink); text-decoration: none; }
.card h2 a:hover { color: var(--red); }
.author { color: var(--muted); margin: 0; font-size: .9rem; }
.meta { margin: 2px 0; }
.buy { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 6px; padding-top: 6px; }
.price { font-weight: 800; color: var(--red-dark); font-size: 1.1rem; white-space: nowrap; }
.price.huge { font-size: 2rem; margin: 6px 0; }
.pager { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin: 24px 0; }
.pager a { padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; text-decoration: none; font-weight: 700; }
.pager a.on { background: var(--red); border-color: var(--red); color: #fff; }
.empty { text-align: center; padding: 40px 10px; background: #fff; border: 1px dashed #d9ccae; border-radius: var(--radius); }

/* strona książki */
.crumbs { margin: 4px 0; }
.book { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 28px; align-items: start; }
.gallery .big { width: 100%; border-radius: var(--radius); border: 1px solid var(--line); background: #f3ead2; }
.gallery .nocover.big { aspect-ratio: 2 / 3; font-size: 4rem; }
.thumbs { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.thumb { border: 2px solid var(--line); border-radius: 8px; padding: 0; background: #fff; cursor: pointer; width: 70px; height: 90px; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.big-author { font-size: 1.15rem; }
.specs { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 16px 0; padding: 12px 14px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.specs dt { color: var(--muted); }
.specs dd { margin: 0; font-weight: 600; }
.desc p { margin: .5em 0; }

/* koszyk i zamówienie */
.cart-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.cart-row { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-bottom: 8px; }
.cart-img { width: 64px; height: 90px; border-radius: 6px; overflow: hidden; background: #f3ead2; display: block; }
.cart-img img { width: 100%; height: 100%; object-fit: cover; }
.cart-price { text-align: right; font-weight: 800; color: var(--red-dark); }
.summary { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; position: sticky; top: 12px; }
.summary h2 { margin-top: 0; }
.line { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; }
.line.small { font-size: .88rem; }
.line.total { font-weight: 800; font-size: 1.15rem; border-top: 2px solid var(--yellow); margin-top: 6px; padding-top: 8px; }
.line.green { color: var(--green); font-weight: 700; }
.nudge { background: var(--yellow-soft); border-radius: 8px; padding: 8px 10px; font-size: .92rem; margin: 10px 0; }
table.plain { width: 100%; border-collapse: collapse; margin: 8px 0; }
table.plain td { padding: 7px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
td.r { text-align: right; white-space: nowrap; padding-left: 12px; }
.legal h2 { margin-top: 1.4em; }
.legal li { margin: .35em 0; }

/* panel admina */
.admin-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.admin-top h1 { margin: 0; }
.alist { display: flex; flex-direction: column; gap: 8px; }
.arow { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; color: inherit; text-decoration: none; }
.arow.orow { grid-template-columns: 1fr auto; }
.arow.hidden-row { opacity: .6; }
.athumb { width: 56px; height: 76px; border-radius: 6px; overflow: hidden; background: #f3ead2; display: block; }
.athumb img { width: 100%; height: 100%; object-fit: cover; }
.aprice { font-weight: 800; color: var(--red-dark); text-align: right; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.tabs a { padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff; text-decoration: none; font-weight: 700; font-size: .9rem; }
.tabs a.on { background: var(--red); color: #fff; border-color: var(--red); }
.isbnrow { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; }
.lookup { margin-top: 10px; }
.cand { display: grid; grid-template-columns: 60px 1fr auto; gap: 10px; align-items: center; background: #fff8e0; border: 1px solid #ecd37a; border-radius: 8px; padding: 8px; margin-top: 8px; }
.cand img, .cand .nocover { width: 60px; height: 84px; object-fit: cover; border-radius: 4px; min-height: 0; font-size: 1.4rem; }
.photos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pslot { background: #fff8e0; border: 2px dashed #d9b84a; border-radius: 10px; padding: 12px; text-align: center; margin: 0; }
.pslot input { font-size: .85rem; padding: 6px; }
.pname { display: block; color: var(--green); font-weight: 700; min-height: 1.2em; }
.curphotos { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.cph { width: 120px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px; font-size: .8rem; }
.cph img { width: 100%; aspect-ratio: 2/3; object-fit: cover; border-radius: 4px; }
.cph-actions { display: flex; justify-content: space-between; gap: 4px; margin-top: 4px; }
.pub { color: var(--green); } .priv { color: #b3261e; }
.stickybar { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 14px 0 10px; display: flex; gap: 10px; flex-wrap: wrap; z-index: 5; }
.danger-zone { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.big-code { font-size: 1.4rem; letter-spacing: 1px; }
.scanner { position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.scanner-box { background: #fff; border-radius: 12px; padding: 12px; width: 100%; max-width: 480px; }
.scanner video { width: 100%; border-radius: 8px; background: #000; max-height: 60vh; }
.login { margin-top: 30px; }
.hidden-row .ainfo { text-decoration: none; }

/* toasty i okno potwierdzenia */
#toasts { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 460px); pointer-events: none; }
.toast { pointer-events: auto; background: #1f7a3d; color: #fff; padding: 12px 16px; border-radius: 10px; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.25); transition: opacity .35s, transform .35s; cursor: pointer; }
.toast.error { background: #b3261e; }
.toast.out { opacity: 0; transform: translateY(-8px); }
.modal { position: fixed; inset: 0; background: rgba(30,15,10,.55); z-index: 90; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-box { background: #fff; border-radius: 14px; padding: 20px; width: 100%; max-width: 420px; border-top: 6px solid var(--yellow); box-shadow: 0 12px 40px rgba(0,0,0,.35); }
.modal-box p { margin: 0 0 16px; font-size: 1.05rem; font-weight: 600; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

@media (max-width: 760px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .filters input[type=search] { grid-column: 1 / -1; }
  .filters .btn { grid-column: 1 / -1; }
  .book, .cart-layout { grid-template-columns: 1fr; }
  .summary { position: static; }
  .two { grid-template-columns: 1fr; }
  .four { grid-template-columns: 1fr 1fr; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .isbnrow { grid-template-columns: 1fr 1fr; }
  .isbnrow input { grid-column: 1 / -1; }
  h1 { font-size: 1.35rem; }
}
