:root {
  --bakk-orange: #1e70b8;
  --bakk-orange-dark: #155a92;
  --bakk-orange-light: #a9cce8;
  --gray-900: #041337;
  --gray-800: #3d3d3d;
  --gray-700: #555555;
  --gray-600: #6b6b6b;
  --gray-400: #a8a8a8;
  --gray-200: #e2e2e2;
  --gray-100: #ececec;
  --gray-50: #f6f6f6;
  --bg: #fafafa;
  --card: #ffffff;
  --danger: #c0392b;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 14px rgba(0,0,0,.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.12);
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--gray-800);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--bakk-orange-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { color: var(--gray-900); margin: 0 0 12px; }
h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 600; }
h3 { font-size: 17px; font-weight: 600; }

.muted { color: var(--gray-600); }
.small { font-size: 13px; }
.mt-12 { margin-top: 12px; }
.req { color: var(--danger); }

/* TOPBAR */
.topbar {
  background: var(--gray-900);
  color: #fff;
  border-bottom: 3px solid var(--bakk-orange);
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-logo { height: 28px; display: block; }
.brand-text { font-size: 18px; font-weight: 600; letter-spacing: .3px; color: #fff; }
.topnav { display: flex; align-items: center; gap: 14px; }
.navlink { color: #e9e9e9; font-size: 14px; padding: 6px 10px; border-radius: var(--radius-sm); }
.navlink:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.navlink-muted { color: var(--gray-400); }

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  background: rgba(255,255,255,.06);
  border-radius: 999px;
  font-size: 13px;
}
.user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bakk-orange);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}
.user-name { color: #fff; }

/* PAGE */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  width: 100%;
  flex: 1;
}

.hero { margin-bottom: 28px; }
.hero h1 { margin-bottom: 6px; }

.back-link { display: inline-block; margin-bottom: 16px; color: var(--gray-600); font-size: 14px; }

/* ─────────────────────────────────────────────────────────────
   MARKETPLACE - layout w stylu Allegro (sidebar + main)
   ───────────────────────────────────────────────────────────── */
.market {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px 24px 64px;
  width: 100%;
  flex: 1;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 28px;
  align-items: start;
}
.market-sidebar {
  position: sticky;
  top: 16px;
  background: var(--card);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow-sm);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}
.filter-group + .filter-group { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--gray-100); }
.filter-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--gray-700);
  margin: 0 0 10px;
}
.filter-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; }
.filter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--gray-800);
  cursor: pointer;
  font-family: inherit;
  transition: background .12s ease, color .12s ease;
}
.filter-item:hover { background: var(--gray-50); }
.filter-item.is-active {
  background: var(--bakk-orange);
  color: #fff;
  font-weight: 600;
}
.filter-item.is-active .filter-count { background: rgba(255,255,255,.25); color: #fff; }
.filter-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-600);
  background: var(--gray-100);
  padding: 2px 7px;
  border-radius: 999px;
  min-width: 22px;
  text-align: center;
}
.filter-select {
  width: 100%;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: #fff;
  font-family: inherit;
  font-size: 13px;
  color: var(--gray-800);
  cursor: pointer;
}
.filter-select:focus { outline: none; border-color: var(--bakk-orange); box-shadow: 0 0 0 3px rgba(30,112,184,.15); }

.market-main { min-width: 0; }
.market-head {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.market-title h1 { margin-bottom: 4px; }
.market-title p { margin: 0; }

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 360px;
}
.search-icon {
  position: absolute;
  left: 12px;
  color: var(--gray-600);
  pointer-events: none;
}
#search-input {
  flex: 1;
  padding: 10px 14px 10px 38px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: #fff;
  font-family: inherit;
  font-size: 14px;
  color: var(--gray-900);
  width: 100%;
}
#search-input:focus { outline: none; border-color: var(--bakk-orange); box-shadow: 0 0 0 3px rgba(30,112,184,.15); }

.market-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--gray-700);
  padding: 8px 2px 16px;
  border-bottom: 1px solid var(--gray-100);
  margin-bottom: 16px;
}
#results-count { font-weight: 700; color: var(--gray-900); }
.active-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bakk-orange);
  color: #fff;
  padding: 3px 6px 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.active-filter-clear {
  background: rgba(255,255,255,.25);
  border: none;
  color: #fff;
  width: 18px; height: 18px;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.active-filter-clear:hover { background: rgba(255,255,255,.4); }

/* TAG PILLS na kartach */
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}
.tag-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-700);
  background: var(--gray-100);
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: .2px;
}

@media (max-width: 880px) {
  .market { grid-template-columns: 1fr; }
  .market-sidebar { position: relative; top: 0; max-height: none; }
  .filter-list { flex-direction: row; flex-wrap: wrap; }
  .filter-item { width: auto; }
}

/* GRID + CARD */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  box-shadow: var(--shadow-sm);
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--bakk-orange);
  text-decoration: none;
}
.card-media {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.card-media img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.card-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--bakk-orange-light), var(--bakk-orange));
  color: #fff;
  font-size: 48px;
  font-weight: 700;
}
.card-body { padding: 16px 18px 6px; flex: 1; }
.card-title { color: var(--gray-900); }
.card-desc {
  margin: 6px 0 0;
  color: var(--gray-700);
  font-size: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-foot {
  padding: 10px 18px 16px;
  display: flex;
  justify-content: flex-end;
}
.link-arrow {
  color: var(--bakk-orange-dark);
  font-weight: 600;
  font-size: 14px;
}

/* DETAIL PAGE - nowa struktura */
.detail-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 24px 64px;
  width: 100%;
  flex: 1;
}
.detail-card {
  background: var(--card);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.detail-hero {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 28px;
  padding: 28px 28px 24px;
  border-bottom: 1px solid var(--gray-100);
  align-items: center;
}
.detail-hero-media {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.detail-hero-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-hero-body h1 { margin: 6px 0 4px; font-size: 26px; }
.detail-host { word-break: break-all; margin: 0 0 18px; }
.detail-tags { margin-bottom: 4px; }
.tag-pill-link { text-decoration: none; }
.tag-pill-link:hover { background: var(--bakk-orange); color: #fff; text-decoration: none; }
.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-lg { padding: 12px 22px; font-size: 15px; }

.detail-section { padding: 24px 28px; border-bottom: 1px solid var(--gray-100); }
.detail-section:last-of-type { border-bottom: none; }
.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--bakk-orange-dark);
  margin: 0 0 12px;
}
.detail-description { font-size: 15.5px; line-height: 1.7; color: var(--gray-800); white-space: pre-wrap; margin: 0; }

.detail-meta { padding: 14px 28px; background: var(--gray-50); border-top: 1px solid var(--gray-100); }
.empty-inline { padding: 24px; }

/* GALLERY */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.gallery-item {
  display: block;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  cursor: zoom-in;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.gallery-item:hover { transform: scale(1.02); border-color: var(--bakk-orange); box-shadow: var(--shadow-md); text-decoration: none; }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* LIGHTBOX */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(20,20,20,.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 32px 48px;
}
.lightbox[hidden] { display: none; }
.lightbox-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  box-shadow: 0 8px 40px rgba(0,0,0,.5);
  border-radius: 4px;
}
.lightbox-close, .lightbox-nav {
  position: absolute;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  color: #fff;
  font-size: 26px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  line-height: 1;
  padding: 0;
  transition: background .12s ease;
}
.lightbox-close:hover, .lightbox-nav:hover { background: rgba(255,255,255,.25); }
.lightbox-close { top: 16px; right: 16px; }
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }
.lightbox-prev, .lightbox-next { top: 50%; transform: translateY(-50%); }
.lightbox-counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,.85);
  font-size: 13px;
  background: rgba(0,0,0,.4);
  padding: 4px 12px;
  border-radius: 999px;
}

/* ADMIN - URL or HTML upload */
.url-or-html {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  background: var(--gray-50);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.url-or-html legend {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
  padding: 0 6px;
}
.url-or-html > .hint {
  font-size: 12.5px;
  margin: 0 0 4px;
  color: var(--gray-700);
}
.url-or-html code {
  background: var(--gray-100);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}

/* ADMIN - screens manage */
.screens-current { border: 1px solid var(--gray-200); border-radius: var(--radius-sm); padding: 14px; background: var(--gray-50); }
.screens-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 8px; }
.screen-thumb {
  display: block;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
}
.screen-thumb img { width: 100%; aspect-ratio: 16/10; object-fit: cover; display: block; }
.screen-remove {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--danger);
  background: #fff;
  border-top: 1px solid var(--gray-100);
}
.screen-thumb:has(input:checked) { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(192,57,43,.12); }

@media (max-width: 720px) {
  .detail-hero { grid-template-columns: 1fr; }
  .detail-hero-media { max-width: 100%; }
  .lightbox-close, .lightbox-nav { width: 36px; height: 36px; font-size: 22px; }
}

/* EMPTY */
.empty {
  text-align: center;
  padding: 64px 24px;
  background: var(--card);
  border: 1px dashed var(--gray-200);
  border-radius: var(--radius);
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  line-height: 1;
  transition: background .12s ease, border-color .12s ease, color .12s ease, transform .12s ease;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--bakk-orange); color: #fff; }
.btn-primary:hover { background: var(--bakk-orange-dark); }
.btn-secondary { background: var(--card); color: var(--gray-800); border-color: var(--gray-200); }
.btn-secondary:hover { background: var(--gray-50); }
.btn-danger { background: var(--card); color: var(--danger); border-color: #f1c6c1; }
.btn-danger:hover { background: #fdecea; }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* LOGIN */
.login-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background: linear-gradient(180deg, var(--gray-50) 0%, var(--bg) 100%);
}
.login-card {
  background: var(--card);
  border: 1px solid var(--gray-200);
  border-top: 4px solid var(--bakk-orange);
  border-radius: var(--radius);
  padding: 36px 32px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.login-logo { height: 38px; margin-bottom: 16px; }

/* FORM */
.form { display: flex; flex-direction: column; gap: 14px; text-align: left; margin-top: 16px; }
.form-wide { max-width: 720px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--gray-800); font-weight: 600; }
.form input[type=text],
.form input[type=email],
.form input[type=url],
.form input[type=file],
.form textarea {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 400;
  font-family: inherit;
  background: #fff;
  color: var(--gray-900);
  width: 100%;
}
.form input:focus, .form textarea:focus {
  outline: none;
  border-color: var(--bakk-orange);
  box-shadow: 0 0 0 3px rgba(30,112,184,.15);
}
.form .hint { font-size: 12px; color: var(--gray-600); font-weight: 400; }
.form .checkbox { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }

.current-image {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--gray-50);
}
.current-image img { max-width: 220px; max-height: 140px; display: block; margin: 6px 0 10px; border-radius: 4px; }

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin: 8px 0;
}
.alert-error { background: #fdecea; border: 1px solid #f1c6c1; color: var(--danger); }
.alert ul { margin: 0; padding-left: 18px; }

/* ADMIN TABLE */
.admin-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}
.table-wrap {
  overflow-x: auto;
  background: var(--card);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--gray-100); vertical-align: top; }
.table th { background: var(--gray-50); color: var(--gray-700); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.table tr:last-child td { border-bottom: none; }
.td-thumb img, .td-thumb .thumb-placeholder {
  width: 56px; height: 40px; object-fit: cover; border-radius: 4px; display: block;
}
.thumb-placeholder {
  background: linear-gradient(135deg, var(--bakk-orange-light), var(--bakk-orange));
  color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.td-desc { max-width: 360px; color: var(--gray-700); }
.td-url a { word-break: break-all; }
.td-meta { font-size: 13px; color: var(--gray-700); white-space: nowrap; }
.th-actions, .td-actions { text-align: right; white-space: nowrap; }
.td-actions .btn + .btn, .td-actions .btn + form, .td-actions form + .btn { margin-left: 6px; }

/* FOOTER */
.footer {
  background: var(--gray-900);
  color: var(--gray-400);
  padding: 14px 24px;
  margin-top: auto;
}
.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}
.badge { background: var(--bakk-orange); color: #fff; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; letter-spacing: .5px; }
.badge-warn { background: var(--bakk-orange-dark); }

.error-card {
  background: var(--card);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 36px;
  max-width: 640px;
  margin: 32px auto;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

@media (max-width: 640px) {
  .topbar-inner { flex-direction: column; align-items: flex-start; gap: 10px; }
  .topnav { flex-wrap: wrap; }
  .detail-head { flex-direction: column; align-items: flex-start; }
  .admin-head { flex-direction: column; }
  .user-name { display: none; }
}
