:root {
  --bg: #f6f1e9;
  --surface: #fffdf9;
  --ink: #2c2218;
  --muted: #7c6f5f;
  --line: #e6ddcf;
  --brand: #7a4f24;
  --brand-dark: #5e3d1c;
  --accent: #b67a3a;
  --green: #3f7d4e;
  --amber: #c08a2a;
  --red: #b1483a;
  --shadow: 0 6px 24px rgba(60, 40, 18, 0.10);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); }

/* --- topbar --- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 14px 22px;
  background: rgba(255, 253, 249, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 20px; letter-spacing: -0.02em;
  color: var(--brand-dark); text-decoration: none;
}
.brand .logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--brand-dark));
  display: grid; place-items: center; color: #fff; font-size: 16px;
}
.nav { margin-left: auto; display: flex; gap: 6px; }
.nav a {
  padding: 8px 14px; border-radius: 999px; text-decoration: none;
  color: var(--muted); font-weight: 600; font-size: 14px; white-space: nowrap;
}
.nav a.active, .nav a:hover { background: var(--brand); color: #fff; }

/* --- vyhledávání v záhlaví: lupa vpravo od jazyků; klik rozbalí pole --- */
.topsearch { display: flex; align-items: center; gap: 2px; }
.topsearch input {
  width: 0; min-width: 0; padding: 0; border: 1px solid transparent; border-radius: 999px;
  background: var(--surface); font-size: 14px; font-family: inherit; color: var(--ink);
  transition: width .2s, padding .2s;
}
.topsearch button {
  background: none; border: none; cursor: pointer; line-height: 0;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 6px; border-radius: 999px; color: var(--brand-dark);
}
.topsearch button:hover { background: var(--line); }
.topbar.search-open .nav { display: none; }
.topbar.search-open .topsearch { flex: 1; max-width: 460px; margin-left: auto; }
.topbar.search-open .topsearch input { width: 100%; padding: 9px 14px; border-color: var(--line); }

/* --- appnav: administrace – tlačítka podle délky slova, stejný okraj i mezery;
   velikost písma i mezery dopočítá appnav.js tak, aby to vyplnilo šířku záhlaví --- */
.appnav {
  flex: 1; min-width: 0; overflow: hidden;
  display: flex; flex-wrap: nowrap; justify-content: center;
  align-items: center; gap: 8px;
}
.appnav a {
  flex: 0 0 auto; text-align: center;
  padding: 0.5em 0.9em; border-radius: 999px; text-decoration: none;
  color: var(--muted); font-weight: 700; white-space: nowrap;
  font-size: 16px; /* výchozí; appnav.js dopočítá maximum */
}
.appnav a.active, .appnav a:hover { background: var(--brand); color: #fff; }
@media (max-width: 520px) {
  .topbar:has(.appnav) { padding: 12px 10px; }
}

@media (max-width: 430px) {
  .topbar { padding: 12px 22px; gap: 6px; } /* stejný levý okraj jako obsah (.wrap) → Woodvia zarovnané */
  .nav { gap: 2px; }
  .nav a { padding: 8px 7px; font-size: 13px; }
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 26px 22px 80px; }
.page-narrow { max-width: 720px; }

h1 { font-size: 28px; letter-spacing: -0.02em; margin: 6px 0 4px; }
.lead { color: var(--muted); margin: 0 0 22px; }

/* --- filtry --- */
.filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 22px;
}
.chip {
  border: 1px solid var(--line); background: var(--surface);
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--muted);
}
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }
/* dřeviny i kvalita = spojené segmentové skupiny (bez mezer mezi tlačítky);
   kvalita navíc vycentrovaná doprostřed mezery mezi dřevinami a filtrem „jen dostupné" */
#woodChips, #qualityChips.seg { display: inline-flex; gap: 0; flex-wrap: wrap; }
#qualityChips.seg { margin: 0 auto; }
/* na užších displejích, kde se řada filtrů zalomí, zarovnat trojici kvality doleva (ne na střed) */
@media (max-width: 640px) { #qualityChips.seg { margin: 0; } }
#woodChips .chip, #qualityChips.seg .chip { border-radius: 0; }
#woodChips .chip:first-child, #qualityChips.seg .chip:first-child { border-top-left-radius: 999px; border-bottom-left-radius: 999px; }
#woodChips .chip:last-child, #qualityChips.seg .chip:last-child { border-top-right-radius: 999px; border-bottom-right-radius: 999px; }
#woodChips .chip + .chip, #qualityChips.seg .chip + .chip { border-left: none; }
.filters input[type=search] {
  flex: 1; min-width: 180px; padding: 9px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); font-size: 14px;
}

/* --- grid karet --- */
.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; cursor: pointer;
  box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s;
  display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(60,40,18,.16); }
.card .thumb { aspect-ratio: 4/3; background: #ece3d4; position: relative; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .body { padding: 12px 14px 16px; }
.card .catno { font-size: 12px; color: var(--muted); font-weight: 700; letter-spacing: .03em; }
.card .wood { font-weight: 700; font-size: 17px; margin: 2px 0; }
.card .dims { font-size: 13px; color: var(--muted); }
.card .price { margin-top: 8px; font-weight: 800; font-size: 18px; color: var(--brand-dark); }

.badge {
  position: absolute; top: 10px; left: 10px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; color: #fff;
}
.badge.available { background: var(--green); }
.badge.reserved { background: var(--amber); }
.badge.sold { background: var(--red); }
.tag-wet, .tag-dry {
  position: absolute; bottom: 10px; right: 10px;
  padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: rgba(0,0,0,.55); color: #fff;
}

/* --- modal detail --- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(30,20,10,.55);
  display: none; align-items: center; justify-content: center; z-index: 40; padding: 16px;
}
.modal-bg.open { display: flex; }
.modal {
  background: var(--surface); border-radius: 18px; max-width: 880px; width: 100%;
  max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-grid { display: grid; grid-template-columns: 1.1fr 1fr; }
@media (max-width: 720px){ .modal-grid { grid-template-columns: 1fr; } }
.gallery { background: #ece3d4; }
.gallery .main img { width: 100%; display: block; aspect-ratio: 4/3; object-fit: cover; }
.gallery .ph-toggle { display: flex; gap: 6px; padding: 10px; }
.gallery .ph-toggle button {
  flex: 1; padding: 7px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; font-weight: 600; cursor: pointer; font-size: 13px;
}
.gallery .ph-toggle button.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.gallery .thumbs { display: flex; gap: 6px; padding: 0 10px 10px; flex-wrap: wrap; }
.gallery .thumbs img { width: 56px; height: 44px; object-fit: cover; border-radius: 6px; cursor: pointer; border: 2px solid transparent; }
.gallery .thumbs img.active { border-color: var(--brand); }
.detail { padding: 22px 24px; }
.detail h2 { margin: 0 0 2px; font-size: 22px; }
.spec { list-style: none; padding: 0; margin: 16px 0; }
.spec li { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.spec li span:first-child { color: var(--muted); }
.spec li span:last-child { font-weight: 600; }
.note-box { background: #f4ecdd; border-radius: 10px; padding: 10px 12px; font-size: 14px; color: #5e4f3a; }
.bundle { margin-top: 10px; font-size: 13px; color: var(--accent); font-weight: 600; }

/* --- lišta alternativ pod detailem (stejná dřevina / cross-sell u vyprodaných) --- */
.alt-wrap { border-top: 1px solid var(--line); padding: 16px 24px 20px; }
.alt-head { font-weight: 700; font-size: 15px; margin-bottom: 12px; }
.alt-row { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.alt-card { flex: 0 0 150px; scroll-snap-align: start; cursor: pointer; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); transition: transform .12s, box-shadow .12s; }
.alt-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.alt-card .thumb { aspect-ratio: 4/3; background: #ece3d4; position: relative; }
.alt-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.alt-card .thumb .badge { top: 6px; left: 6px; padding: 2px 7px; font-size: 10px; }
.alt-card .b { padding: 8px 10px 10px; }
.alt-card .c { font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: .03em; }
.alt-card .w { font-weight: 700; font-size: 14px; margin: 1px 0; }
.alt-card .d { font-size: 12px; color: var(--muted); }
.alt-card .p { font-weight: 800; font-size: 14px; color: var(--brand-dark); margin-top: 4px; }

/* --- formuláře --- */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
input, select, textarea {
  width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; font-size: 15px; font-family: inherit; color: var(--ink);
}
textarea { min-height: 70px; resize: vertical; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.radio-row { display: flex; gap: 10px; }
.radio-row label {
  flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 10px;
  text-align: center; cursor: pointer; font-weight: 600; background: #fff;
}
.radio-row input { display: none; }
.radio-row input:checked + span { color: var(--brand); }
.radio-row label:has(input:checked) { border-color: var(--brand); background: #f6ecdd; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--brand); color: #fff; border: none; border-radius: 10px;
  padding: 13px 20px; font-size: 15px; font-weight: 700; cursor: pointer; width: 100%;
}
.btn:hover { background: var(--brand-dark); }
.btn.secondary { background: #fff; color: var(--brand); border: 1px solid var(--line); }
.btn.danger { background: #fff; color: var(--red); border: 1px solid var(--line); width: auto; padding: 7px 12px; font-size: 13px; }
.btn-sm { width: auto; padding: 7px 12px; font-size: 13px; }

.photo-drop {
  border: 2px dashed var(--line); border-radius: 12px; padding: 16px; text-align: center;
  background: #fffdfa;
}
.photo-drop .previews { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.photo-drop .previews img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px;
  font-weight: 600; box-shadow: var(--shadow); z-index: 60; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

.empty { text-align: center; color: var(--muted); padding: 60px 20px; }

/* --- admin --- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 14px; margin-bottom: 26px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat .n { font-size: 26px; font-weight: 800; color: var(--brand-dark); }
.stat .l { font-size: 13px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { background: #f1e8d8; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
td select { width: auto; padding: 5px 8px; font-size: 13px; }
.pill { padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; color: #fff; }
.pill.available { background: var(--green); }
.pill.reserved { background: var(--amber); }
.pill.sold { background: var(--red); }
.pill.active { background: var(--green); }
.pill.expired, .pill.cancelled { background: var(--muted); }
.section-title { margin: 32px 0 12px; font-size: 18px; }
