:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --text: #262624;
  --text-muted: #6b6a66;
  --border: #e4e1da;
  --primary: #2f6f5e;
  --primary-dark: #24594b;
  --primary-light: #e7f1ee;
  --accent: #c9722b;
  --danger: #b3413a;
  --danger-light: #f7e6e4;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

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

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

h1, h2, h3 { line-height: 1.25; font-weight: 650; margin: 0 0 0.5em; }
h1 { font-size: 1.8rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
.muted { color: var(--text-muted); font-size: 0.9rem; }

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  gap: 20px;
  flex-wrap: wrap;
}
.logo {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 9px;
}
.logo span { color: var(--primary); }
.logo-mark { display: block; flex-shrink: 0; }
.main-nav {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 0.95rem;
}
.main-nav a { color: var(--text); }
.main-nav a.active { color: var(--primary-dark); font-weight: 600; }
.btn-add {
  background: var(--primary);
  color: #fff !important;
  padding: 8px 14px;
  border-radius: var(--radius);
  text-decoration: none !important;
}
.btn-add:hover { background: var(--primary-dark); }
.notif-link { position: relative; }
.badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 4px;
}
.nav-account { position: relative; }
.nav-username { cursor: default; font-weight: 600; }
.nav-account:hover .nav-dropdown,
.nav-account:focus-within .nav-dropdown { display: flex; }
.nav-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  flex-direction: column;
  min-width: 190px;
  padding: 6px;
  z-index: 60;
}
.nav-dropdown a, .nav-dropdown button {
  padding: 8px 10px;
  border-radius: 6px;
  text-align: left;
  background: none;
  border: none;
  font: inherit;
  color: var(--text);
  cursor: pointer;
}
.nav-dropdown a:hover, .nav-dropdown button:hover { background: var(--bg); text-decoration: none; }

/* Flash */
.flash {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin: 14px 0;
  font-size: 0.92rem;
}
.flash-error { background: var(--danger-light); color: var(--danger); border: 1px solid #e6c3c0; }
.flash-success { background: var(--primary-light); color: var(--primary-dark); border: 1px solid #cfe4dd; }

/* Buttons & forms */
.btn {
  display: inline-block;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.95rem;
}
.btn:hover { border-color: var(--primary); text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-small { padding: 5px 10px; font-size: 0.82rem; }

label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 0.9rem; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=tel], input[type=date], input[type=search], textarea, select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
textarea { resize: vertical; min-height: 120px; }
.field { margin-bottom: 16px; }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 160px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.checkbox-row input { width: auto; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.card-narrow { max-width: 440px; margin: 40px auto; }

/* Hero */
.hero {
  background: linear-gradient(135deg, var(--primary-light), var(--bg));
  padding: 48px 0;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.hero-grid { display: grid; grid-template-columns: 1fr; align-items: center; gap: 20px; }
.hero h1 { font-size: 2.1rem; margin-bottom: 8px; }
.hero-search { background: var(--surface); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-top: 20px; }
.hero-art { display: none; justify-self: center; }
.hero-art svg { width: 100%; height: auto; max-width: 360px; }
@media (min-width: 980px) {
  .hero-grid { grid-template-columns: minmax(0, 620px) 1fr; gap: 32px; }
  .hero-art { display: block; }
}
.district-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.district-chips a {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 20px;
  color: var(--text);
  font-size: 0.86rem;
}
.district-chips a:hover { border-color: var(--primary); text-decoration: none; }

/* Listing grid */
.listing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
  margin: 20px 0;
}
.listing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s;
}
.listing-card:hover { box-shadow: var(--shadow); }
.listing-card .thumb {
  height: 165px;
  background: var(--bg) center/cover no-repeat;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  position: relative;
}
.listing-card .thumb.no-photo {
  background: linear-gradient(150deg, var(--primary-light), var(--bg));
  flex-direction: column;
  gap: 6px;
}
.listing-card .thumb.no-photo svg { opacity: 0.55; }
.listing-card .thumb .type-tag {
  position: absolute; top: 8px; left: 8px;
  background: rgba(38,38,36,0.75); color: #fff;
  font-size: 0.72rem; padding: 3px 8px; border-radius: 12px;
}
.listing-card .body { padding: 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.listing-card .price { font-weight: 700; color: var(--primary-dark); font-size: 1.15rem; }
.listing-card .title { font-weight: 600; font-size: 0.98rem; }
.listing-card .meta { font-size: 0.82rem; color: var(--text-muted); }
.listing-card .commute-tag { font-size: 0.78rem; color: var(--primary-dark); background: var(--primary-light); padding: 2px 8px; border-radius: 10px; display: inline-block; width: fit-content; }

/* Search layout */
.search-layout { display: grid; grid-template-columns: 300px 1fr; gap: 24px; margin: 24px 0; align-items: start; }
.search-filters { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; position: sticky; top: 84px; }
.search-filters h3 { margin-top: 18px; }
.search-filters h3:first-child { margin-top: 0; }
.filter-heading { display: flex; align-items: center; gap: 7px; }
.filter-heading svg { color: var(--primary); flex-shrink: 0; }
.amenity-list { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
#search-map { height: 280px; border-radius: var(--radius); margin-bottom: 14px; border: 1px solid var(--border); }
.commute-point-status { font-size: 0.82rem; color: var(--text-muted); margin-top: 4px; }

/* Suwak zakresu cen (dwa uchwyty, bez zewnetrznych bibliotek) */
.price-range-display { font-weight: 600; font-size: 0.92rem; margin-bottom: 6px; }
.price-slider { position: relative; height: 28px; margin-bottom: 4px; }
.price-slider .track,
.price-slider .track-range {
  position: absolute;
  top: 12px;
  height: 4px;
  border-radius: 2px;
  pointer-events: none;
}
.price-slider .track { left: 0; right: 0; background: var(--border); }
.price-slider .track-range { background: var(--primary); }
.price-slider input[type=range] {
  position: absolute;
  top: 8px;
  left: 0;
  width: 100%;
  margin: 0;
  background: none;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}
.price-slider input[type=range]::-webkit-slider-runnable-track { -webkit-appearance: none; background: none; }
.price-slider input[type=range]::-moz-range-track { background: none; border: none; }
.price-slider input[type=range]::-webkit-slider-thumb {
  pointer-events: auto;
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--primary);
  cursor: pointer;
}
.price-slider input[type=range]::-moz-range-thumb {
  pointer-events: auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--primary);
  cursor: pointer;
}

@media (max-width: 860px) {
  .search-layout { grid-template-columns: 1fr; }
  .search-filters { position: static; }
}

/* Listing show page */
.listing-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; margin: 16px 0; }
.gallery img { width: 100%; height: 150px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.amenity-badges { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.amenity-badges span { background: var(--bg); border: 1px solid var(--border); padding: 4px 10px; border-radius: 14px; font-size: 0.84rem; }
#listing-map { height: 260px; border-radius: var(--radius); margin: 16px 0; border: 1px solid var(--border); }
.contact-box { background: var(--primary-light); border: 1px solid #cfe4dd; border-radius: var(--radius); padding: 16px; margin-top: 16px; }
.price-big { font-size: 1.6rem; font-weight: 700; color: var(--primary-dark); }

/* Status pills */
.status-pill { padding: 3px 10px; border-radius: 12px; font-size: 0.78rem; font-weight: 600; }
.status-active { background: var(--primary-light); color: var(--primary-dark); }
.status-hidden { background: #f1eee6; color: #8a6d2f; }
.status-archived { background: #eee; color: #666; }
.status-expired { background: var(--danger-light); color: var(--danger); }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--text-muted); font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.02em; }
.table-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.table-actions form { display: inline-flex; align-items: center; gap: 6px; }

/* Admin stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin: 20px 0; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat-card .num { font-size: 1.6rem; font-weight: 700; color: var(--primary-dark); }

/* Wykresy panelu admina (bez zewnetrznych bibliotek - paski CSS) */
.chart-bars { display: flex; flex-direction: column; gap: 10px; }
.chart-bar-row { display: grid; grid-template-columns: 110px 1fr 34px; align-items: center; gap: 10px; font-size: 0.86rem; }
.chart-bar-label { color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart-bar-track { background: var(--bg); border-radius: 6px; height: 12px; overflow: hidden; }
.chart-bar-fill { background: var(--primary); height: 100%; border-radius: 6px; min-width: 3px; }
.chart-bar-value { text-align: right; font-weight: 600; color: var(--text); }

.chart-columns { display: flex; align-items: flex-end; gap: 10px; height: 160px; padding-top: 20px; }
.chart-column { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.chart-column-value { font-size: 0.78rem; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
.chart-column-track { flex: 1; width: 100%; max-width: 34px; display: flex; align-items: flex-end; }
.chart-column-fill { width: 100%; background: var(--primary); border-radius: 5px 5px 0 0; min-height: 3px; }
.chart-column-label { margin-top: 6px; font-size: 0.74rem; color: var(--text-muted); text-transform: capitalize; }
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 760px) { .dashboard-grid { grid-template-columns: 1fr; } }

.log-view { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.8rem; max-height: 600px; overflow-y: auto; padding: 14px; }
.log-line { padding: 3px 0; border-bottom: 1px solid var(--border); white-space: pre-wrap; word-break: break-word; color: var(--text-muted); }
.log-line:last-child { border-bottom: none; }
.log-line-error { color: var(--danger); }

/* Footer */
.site-footer { border-top: 1px solid var(--border); margin-top: 60px; padding: 24px 0; color: var(--text-muted); font-size: 0.85rem; }
.footer-inner p { margin: 0 0 4px; }
.footer-links { display: flex; gap: 16px; margin-top: 8px; flex-wrap: wrap; }
.footer-links a { color: var(--text-muted); }

/* Strony prawne */
.legal-content h2 { font-size: 1.1rem; margin-top: 1.4em; }
.legal-content h2:first-child { margin-top: 0; }
.legal-content p, .legal-content ul { margin: 0 0 1em; }
.legal-content ul { padding-left: 1.3em; }
.legal-content li { margin-bottom: 0.4em; }

/* Utility */
.mt-0 { margin-top: 0; }
.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-illustration { margin-bottom: 6px; }
.tag-type { display: inline-block; padding: 2px 9px; border-radius: 10px; background: var(--bg); border: 1px solid var(--border); font-size: 0.78rem; }
