/* ===== CSS Variables ===== */
:root {
  --color-bg: #f5f5f5;
  --color-surface: #ffffff;
  --color-primary: #e67e22;
  --color-primary-dark: #d35400;
  --color-text: #2c3e50;
  --color-text-muted: #7f8c8d;
  --color-border: #e0e0e0;
  --color-success: #27ae60;
  --color-danger: #e74c3c;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.14);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body { font-family: var(--font); background: var(--color-bg); color: var(--color-text); line-height: 1.6; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
input, select, button, textarea { font-family: inherit; font-size: inherit; }

/* ===== Layout ===== */
.container {
  margin: 0 auto;
  padding: 0 16px;
}

.main-content {
  padding: 24px 0 48px;
}

/* ===== Notifications ===== */
.notification {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  font-size: 0.9rem;
  position: sticky;
  top: 56px;
  z-index: 99;
}
.notification-error {
  background: #fef2f2;
  border-bottom: 1px solid #fecaca;
  color: #b91c1c;
}
.notification-close {
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}

/* ===== Header ===== */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.logo {
  display: inline-flex;
  align-items: center;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-link {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.nav-link:hover, .nav-link.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  overflow: hidden;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 20px 0;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-weight: 500;
  cursor: pointer;
  border: none;
  line-height: 1;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  text-align: center;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }

.btn-secondary {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover { background: #f0f0f0; }

.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: #c0392b; }

.btn-sm { padding: 6px 12px; font-size: 0.85rem; }

.btn-google {
  background: #fff;
  color: #333;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow);
  width: 100%;
  justify-content: center;
  padding: 12px 24px;
  font-size: 1rem;
}
.btn-google:hover { box-shadow: var(--shadow-hover); }

.btn-load-more {
  width: 100%;
  max-width: 320px;
  justify-content: center;
}

.btn-telegram { justify-content: center; }

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
  justify-content: flex-end;
}

/* ===== Card ===== */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ===== Favorite button ===== */
.realty-card { position: relative; }

.favorite-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s, background 0.15s;
  padding: 0;
}
.favorite-btn:hover { transform: scale(1.1); background: #fff; }
.favorite-btn svg path {
  fill: none;
  stroke: #bbb;
  stroke-width: 2;
  transition: fill 0.15s, stroke 0.15s;
}
.favorite-btn.is-favorite svg path { fill: #e74c3c; stroke: #e74c3c; }

/* Кнопка на странице детали (с текстом) */
.favorite-btn-detail {
  position: static;
  width: auto;
  height: auto;
  border-radius: var(--radius);
  padding: 10px 16px;
  gap: 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}
.favorite-btn-detail:hover { transform: none; background: #f0f0f0; }
.favorite-btn-detail.is-favorite { border-color: #e74c3c; color: #e74c3c; }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
  background: #ecf0f1;
  color: var(--color-text);
}
.badge-region { background: #f0f0f0; color: #555; font-weight: 500; }
.badge-district { background: #eaf4fb; color: #2980b9; }
.badge-type { background: #fef9e7; color: #d68910; }
.badge-beds { background: #eafaf1; color: #27ae60; }
.badge-price { background: #fdf2f8; color: #8e44ad; }

/* Plan badges */
.badge-plan-free {
  background: #f0f0f0;
  color: #7f8c8d;
  font-size: 0.68rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-weight: 600;
}
.badge-plan-pro {
  background: linear-gradient(135deg, #f7e8b0, #f0c850);
  color: #7a5d00;
  font-size: 0.68rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-weight: 700;
}
.badge-auto-renewal-active {
  background: #e8f5e9;
  color: #2e7d32;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
}
.badge-auto-renewal-cancelled {
  background: #fff3e0;
  color: #e65100;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
}
.pricing-cancelled-note {
  color: #e65100;
  font-size: 0.85rem;
  margin: 0.5rem 0;
}
.plan-badge-header {
  padding: 1px 6px;
  font-size: 0.6rem;
  line-height: 1;
  border-radius: 4px;
  flex-shrink: 0;
}
@media (max-width: 360px) {
  .plan-badge-header { display: none; }
}

/* ===== Region tabs ===== */
.region-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.region-tab {
  padding: 4px 12px;
  border: 1px solid #ddd;
  border-radius: 16px;
  background: #f8f8f8;
  color: #555;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.region-tab:hover {
  background: #eee;
  border-color: #bbb;
}
.region-tab.active {
  background: #2980b9;
  color: #fff;
  border-color: #2980b9;
}

/* ===== Filter toggle (mobile only) ===== */
.btn-filter-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;

  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.15s;
}
.btn-filter-toggle:hover { background: #f0f0f0; }

.filter-description {
  display: none;
  font-size: 12px;
  color: var(--color-text-secondary);
  text-align: right;
  margin-bottom: 8px;
}

.filter-description:empty { display: none; }

.btn-filter-close {
  display: none;
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  font-size: 1.1rem;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.15s;
}
.btn-filter-close:hover { background: #f0f0f0; }

/* ===== Nav hamburger menu (mobile only) ===== */
.nav-menu-checkbox { display: none; }

.nav-hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  transition: background 0.15s;
}
.nav-hamburger-btn:hover { background: #f0f0f0; }

.nav-hamburger-icon,
.nav-hamburger-icon::before,
.nav-hamburger-icon::after {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--color-text);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}
.nav-hamburger-icon { position: relative; }
.nav-hamburger-icon::before,
.nav-hamburger-icon::after {
  content: '';
  position: absolute;
  left: 0;
}
.nav-hamburger-icon::before { top: -6px; }
.nav-hamburger-icon::after  { top: 6px; }

.nav-menu-checkbox:checked ~ .header-inner .header-nav .nav-hamburger-btn .nav-hamburger-icon {
  background: transparent;
}
.nav-menu-checkbox:checked ~ .header-inner .header-nav .nav-hamburger-btn .nav-hamburger-icon::before {
  transform: translateY(6px) rotate(45deg);
}
.nav-menu-checkbox:checked ~ .header-inner .header-nav .nav-hamburger-btn .nav-hamburger-icon::after {
  transform: translateY(-6px) rotate(-45deg);
}

.filters-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 149;
}
.filters-backdrop.active { display: block; }

/* ===== Page layout (index) ===== */
.page-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 768px) {
  .page-layout { grid-template-columns: 1fr; }
}

/* ===== Filters panel ===== */
.filters-panel {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 72px - 24px);
  overflow-y: auto;
}

.filters-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--color-text);
}

.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.form-group select,
.form-group input[type="text"],
.form-group input[type="number"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: #fff;
  color: var(--color-text);
  transition: border-color 0.15s;
  -webkit-appearance: none;
}

/* Убираем стрелочки у number inputs — Chrome/Safari/Edge */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Убираем стрелочки у number inputs — Firefox */
input[type="number"] {
  -moz-appearance: textfield;
}

.form-group select:focus,
.form-group input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.price-range {
  display: flex;
  align-items: center;
  gap: 8px;
}
.price-range input { width: 0; flex: 1; }
.price-range span { color: var(--color-text-muted); }

.price-hint {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.filters-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.filters-actions .btn { justify-content: center; }

/* ===== Cards grid ===== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

/* ===== Realty card ===== */
.realty-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s;
}
.realty-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}
.card-link {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.card-image {
  position: relative;
  aspect-ratio: 4/3;
  overflow: hidden;
  background: #ecf0f1;
}
.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}
.realty-card:hover .card-image img { transform: scale(1.03); }

.card-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.card-body { padding: 12px 14px 14px; }

.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.card-price { margin-bottom: 4px; }
.price-idr,
.price-main {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text);
}
.price-usd {
  display: block;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.price-usd-hint {
  display: block;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 4px;
  min-height: 1em;
}

.card-date {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

/* ===== Load more ===== */
.load-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 24px;
}

/* ===== Empty state ===== */
.empty-state {
  grid-column: 1/-1;
  text-align: center;
  padding: 48px 24px;
  color: var(--color-text-muted);
}

.hint-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: #fff8f0;
  border: 1px solid #fde3c4;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.85rem;
  color: var(--color-text);
  line-height: 1.4;
}
.listings > .hint-banner {
  margin-bottom: 16px;
}
.hint-banner a {
  color: var(--color-primary);
  font-weight: 600;
  white-space: nowrap;
}
.hint-banner a:hover {
  text-decoration: underline;
}

/* ===== Detail page ===== */
.detail-page {
  max-width: 800px;
  margin: 0 auto;
}

.back-link {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--color-primary);
  font-size: 0.9rem;
}
.back-link:hover { text-decoration: underline; }

.gallery {
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 24px;
  background: #ecf0f1;
}
#gallery-media-wrap {
  width: 100%;
  height: 100%;
}
.gallery-main img,
.gallery-main video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}
.gallery-placeholder {
  height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
}
.gallery-thumbs {
  display: flex;
  gap: 6px;
  padding: 8px;
  background: #f0f0f0;
  overflow-x: auto;
}
.gallery-thumb {
  width: 72px;
  height: 54px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s;
  flex-shrink: 0;
  border: 2px solid transparent;
}
.gallery-thumb:hover, .gallery-thumb.active {
  opacity: 1;
  border-color: var(--color-primary);
}

/* Gallery nav arrows */
.gallery-main {
  position: relative;
  height: 420px;
}
.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  padding: 0;
  user-select: none;
}
.gallery-nav:hover { background: rgba(0, 0, 0, 0.65); }
.gallery-prev { left: 10px; }
.gallery-next { right: 10px; }

/* Lightbox */
.lightbox-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.lightbox-overlay.active {
  display: flex;
  animation: lightbox-in 0.15s ease;
}
@keyframes lightbox-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  cursor: pointer;
}
.lightbox-inner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 95vw;
  max-height: 90vh;
}
.lightbox-inner img,
.lightbox-inner video {
  max-width: 95vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 4px;
  display: block;
}
.lightbox-close {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1001;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  padding: 0;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.3); }
.lightbox-counter {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.85rem;
  z-index: 1001;
  pointer-events: none;
}
.lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1001;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  padding: 0;
  user-select: none;
}
.lightbox-nav:hover { background: rgba(255, 255, 255, 0.3); }
.lb-prev { left: 16px; }
.lb-next { right: 16px; }

.detail-content {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.detail-attrs {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.attr-row {
  display: flex;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
}
.attr-row:last-child { border-bottom: none; }
.attr-label {
  width: 140px;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  flex-shrink: 0;
}
.attr-value { font-weight: 500; }
.price-usd-detail {
  display: block;
  font-size: 0.82rem;
  color: var(--color-text-muted);
  font-weight: 400;
}

.raw-text-block h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.raw-text {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  white-space: pre-wrap;
  font-size: 0.9rem;
  line-height: 1.7;
  max-height: 400px;
  overflow-y: auto;
}

/* ===== Login page ===== */
.login-page {
  display: flex;
  justify-content: center;
  padding: 48px 0;
}
.login-card {
  width: 100%;
  max-width: 400px;
  padding: 40px 32px;
  text-align: center;
}
.login-logo { margin-bottom: 12px; display: flex; justify-content: center; }
.login-desc {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-bottom: 28px;
  line-height: 1.5;
}
.login-back { margin-top: 20px; font-size: 0.85rem; color: var(--color-text-muted); }
.login-back a { color: var(--color-primary); }
.login-back a:hover { text-decoration: underline; }

/* ===== Profile page ===== */
.profile-page {
  max-width: 720px;
  margin: 0 auto;
}
.profile-page h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 24px;
}

.profile-section {
  margin-bottom: 32px;
}
.profile-section.card { padding: 24px; }
.profile-section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-header h2 { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }

.profile-field {
  margin-bottom: 16px;
}
.profile-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 30px;
}
.profile-field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.field-value { font-weight: 500; }

.field-edit-row {
  display: flex;
  gap: 8px;
}
.field-edit-row input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: #fff;
}
.field-edit-row input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.field-status {
  margin-top: 6px;
  font-size: 0.82rem;
}
.field-status.success { color: var(--color-success); }
.field-status.error { color: var(--color-danger); }

.profile-divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 16px 0 12px;
}
.profile-actions { margin-top: 8px; }

/* ===== Saved filter card ===== */
.saved-filter-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  margin-bottom: 10px;
  flex-wrap: wrap;
  overflow: visible;  /* переопределяет .card overflow:hidden, иначе тултипы обрезаются */
}
.sub-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}
.sub-stats {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}
.sub-stats-zero {
  color: #e74c3c;
}
.sub-preview-stats {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  margin-top: 6px;
}
.sub-preview-stats-zero {
  color: #e74c3c;
}
.sub-channels {
  display: flex;
  gap: 6px;
}
.channel-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #ecf0f1;
  color: var(--color-text-muted);
}
.channel-badge.active.channel-tg { background: #e8f4fd; color: #2980b9; }
.channel-badge.active.channel-email { background: #eafaf1; color: #27ae60; }

/* ===== Saved filter form ===== */
.saved-filter-form {
  padding: 20px;
  margin-bottom: 20px;
}
.saved-filter-form h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.range-row input {
  flex: 1;
  width: 0;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
}
.range-row span { color: var(--color-text-muted); }

.notify-switcher {
  display: inline-flex;
  border-radius: 8px;
  border: 1px solid #d1d5db;
}
.notify-switcher > :first-child {
  border-radius: 8px 0 0 8px;
}
.notify-switcher > :last-child {
  border-radius: 0 8px 8px 0;
}
/* Кнопка внутри span-обёртки (когда Telegram disabled) */
.notify-option-wrapper:last-child .notify-option {
  border-radius: 0 8px 8px 0;
}
.notify-option {
  padding: 6px 20px;
  border: none;
  cursor: pointer;
  background: #e5e7eb;
  color: #6b7280;
  font-size: 14px;
  font-family: inherit;
  transition: background 0.2s, color 0.2s;
}
.notify-option.active {
  background: #22c55e;
  color: #fff;
  font-weight: 500;
}
.notify-option:first-child { border-right: 1px solid #d1d5db; }

.notify-option-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  position: relative;
}
.notify-option-wrapper {
  position: relative;
}
.notify-option-wrapper.label-with-tooltip {
  text-decoration: underline dotted var(--color-text-muted, #999);
  text-underline-offset: 3px;
}
[data-tooltip].notify-option-wrapper::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  right: auto;
  transform: none;
  background: #1f2937;
  color: #fff;
  font-size: 0.78rem;
  padding: 5px 8px;
  border-radius: 5px;
  white-space: normal;
  max-width: 260px;
  text-align: left;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
  z-index: 10;
}
[data-tooltip].notify-option-wrapper:hover::after {
  opacity: 1;
}

/* ===== Label tooltip ===== */
[data-tooltip].label-with-tooltip {
  position: relative;
  cursor: default;
  width: fit-content;
  text-decoration: underline dotted var(--color-text-muted, #999);
  text-underline-offset: 3px;
}
[data-tooltip].label-with-tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  right: auto;
  transform: none;
  background: rgba(0,0,0,0.78);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 400;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: normal;
  width: max-content;
  max-width: 260px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
  z-index: 10;
}
[data-tooltip].label-with-tooltip:hover::after {
  opacity: 1;
}

/* ===== Toggle switch ===== */
.toggle-switch {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}
.toggle-switch input[type="checkbox"] {
  display: none;
}
.toggle-slider {
  display: block;
  width: 42px;
  height: 24px;
  background: #d1d5db;
  border-radius: 12px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
  cursor: pointer;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform 0.2s;
}
.toggle-switch input[type="checkbox"]:checked + .toggle-slider {
  background: #22c55e;
}
.toggle-switch input[type="checkbox"]:checked + .toggle-slider::after {
  transform: translateX(18px);
}
#notify-channel-selector {
  display: flex;
  align-items: center;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* ===== Error page ===== */
.error-page {
  text-align: center;
  padding: 80px 24px;
}
.error-page h1 {
  font-size: 5rem;
  font-weight: 800;
  color: var(--color-primary);
  margin-bottom: 12px;
}
.error-page p { color: var(--color-text-muted); margin-bottom: 24px; }

/* ===== Privacy Policy Page ===== */
.privacy-policy-page {
  max-width: 720px;
  margin: 0 auto;
}
.privacy-policy-page h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.privacy-policy-page h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 32px 0 12px;
}
.privacy-policy-page h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 20px 0 8px;
}
.privacy-policy-page p {
  line-height: 1.7;
  margin-bottom: 12px;
  text-align: justify;
}
.privacy-policy-page ul {
  margin: 8px 0 16px 24px;
}
.privacy-policy-page li {
  line-height: 1.7;
  margin-bottom: 6px;
  text-align: justify;
}
.privacy-policy-page a {
  color: var(--color-primary);
}
.privacy-policy-page a:hover {
  text-decoration: underline;
}
.policy-meta {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 20px !important;
  text-align: left !important;
}

/* TOC */
.policy-toc {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin: 20px 0 32px;
}
.policy-toc h2 {
  font-size: 1rem;
  margin: 0 0 12px;
}
.policy-toc ol {
  margin: 0;
  padding-left: 20px;
}
.policy-toc li {
  margin-bottom: 4px;
  font-size: 0.9rem;
  text-align: left;
}
.policy-toc a {
  color: var(--color-text);
}
.policy-toc a:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

/* Definitions list */
.policy-definitions {
  margin: 12px 0;
}
.policy-definitions dt {
  font-weight: 600;
  margin-top: 16px;
}
.policy-definitions dd {
  color: var(--color-text-muted);
  line-height: 1.7;
  margin: 4px 0 0 0;
  text-align: justify;
}

/* ===== Cookie Policy Page ===== */
.cookie-policy-page {
  max-width: 720px;
  margin: 0 auto;
}
.cookie-policy-page h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 24px;
}
.cookie-policy-page h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 28px 0 12px;
}
.cookie-policy-page p {
  line-height: 1.7;
  margin-bottom: 12px;
  text-align: justify;
}
.cookie-policy-page a {
  color: var(--color-primary);
}
.cookie-policy-page a:hover {
  text-decoration: underline;
}
.cookie-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 20px;
  font-size: 0.9rem;
}
.cookie-table th,
.cookie-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
}
.cookie-table th {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.cookie-table code {
  background: var(--color-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
}

/* ===== Cookie Consent Banner ===== */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.1);
  padding: 16px;
  animation: cookie-banner-in 0.3s ease;
}
@keyframes cookie-banner-in {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.cookie-banner__content {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.cookie-banner__content p {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--color-text);
  flex: 1;
  min-width: 200px;
}
.cookie-banner__buttons {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}
.cookie-banner__buttons .btn {
  min-width: 110px;
  justify-content: center;
  font-size: 0.9rem;
}
@media (max-width: 600px) {
  .cookie-banner__content {
    flex-direction: column;
    text-align: center;
  }
  .cookie-banner__buttons {
    width: 100%;
  }
  .cookie-banner__buttons .btn {
    flex: 1;
  }
}

.cookie-settings-link {
  color: var(--color-text-muted);
  font-size: 0.82rem;
  transition: color 0.15s;
}
.cookie-settings-link:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

/* ===== Utility ===== */
.hidden { display: none !important; }

/* ===== Mobile ===== */
@media (max-width: 480px) {
  .cards-grid { grid-template-columns: 1fr; }
  .attr-label { width: 100px; }
  .saved-filter-card { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 768px) {
  .btn-filter-toggle { display: flex; }
  .btn-filter-close { display: flex; align-items: center; justify-content: center; }
  .filter-description:not(:empty) { display: block; }

  .nav-hamburger-btn { display: flex; }

  .nav-links { display: none; }

  .nav-menu-checkbox:checked ~ .header-inner .header-nav .nav-links {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow);
    padding: 8px 16px 12px;
    gap: 0;
    z-index: 10;
  }

  .nav-menu-checkbox:checked ~ .header-inner .header-nav .nav-links .nav-link {
    padding: 12px 0;
    font-size: 0.95rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    border-top: none;
  }
  .nav-menu-checkbox:checked ~ .header-inner .header-nav .nav-links .nav-link:last-child {
    border-bottom: none;
  }

  .nav-menu-checkbox:checked ~ .header-inner .header-nav .nav-links .btn {
    margin-top: 8px;
    align-self: flex-start;
  }

  .filters-panel {
    display: none;
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 150;
    border-radius: 0;
    overflow-y: auto;
    padding: 48px 20px 20px;
    box-shadow: none;
  }
  .filters-panel.filters-open { display: block; }
}

/* Connection status badge (Telegram, Email, etc.) */
.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
}
.connection-status .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: currentColor;
}
.connection-status.cs-connected {
  background: #eafaf1;
  color: #27ae60;
}
.connection-status.cs-disconnected {
  background: #fef9f0;
  color: #e67e22;
}
.connection-status.cs-inactive {
  background: #f5f5f5;
  color: #7f8c8d;
}

/* Telegram widget */
.tg-badge-active {
  color: var(--color-success);
  font-weight: 500;
}
.tg-link-box {
  margin-top: 8px;
  padding: 12px 16px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tg-link-box.hidden { display: none; }
.tg-expire-hint { font-size: 0.85em; }

/* --- Disabled create-saved-filter button wrapper --- */
.sub-btn-disabled-wrapper {
  position: relative;
  display: inline-block;
}
.sub-btn-disabled-wrapper [data-tooltip],
[data-tooltip].sub-btn-disabled-wrapper {
  position: relative;
}
[data-tooltip].sub-btn-disabled-wrapper::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.78);
  color: #fff;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
  z-index: 10;
}
[data-tooltip].sub-btn-disabled-wrapper:hover::after {
  opacity: 1;
}
.btn-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* --- Paused saved filter badge --- */
.badge-paused {
  background: #f39c12;
  color: #fff;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}
[data-tooltip].badge-paused {
  position: relative;
  cursor: default;
}
[data-tooltip].badge-paused::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.78);
  color: #fff;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
  z-index: 10;
}
[data-tooltip].badge-paused:hover::after {
  opacity: 1;
}

/* --- Удалённые объявления --- */
.deleted-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(180, 30, 30, 0.82);
  color: #fff;
  text-align: center;
  font-weight: 600;
  font-size: 13px;
  padding: 6px 0;
  letter-spacing: 0.4px;
  pointer-events: none;
}

.realty-card.is-deleted .card-link {
  pointer-events: none;
  cursor: default;
}
.realty-card.is-deleted {
  opacity: 0.75;
}

.deleted-banner {
  background: #c0392b;
  color: #fff;
  text-align: center;
  font-weight: 600;
  font-size: 15px;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
}

/* ===== View mode toggle ===== */
.listings-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 8px;
}

.listings-stat {
  background: #fff8f0;
  border: 1px solid #fde3c4;
  border-radius: 14px;
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-primary-dark);
  white-space: nowrap;
}

.view-toggle {
  display: flex;
  align-items: stretch;
  height: 36px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  box-sizing: border-box;
}

.view-btn {
  background: transparent;
  border: none;
  border-right: 1px solid var(--color-border);
  padding: 0 8px;
  cursor: pointer;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  box-sizing: border-box;
}

.view-btn:first-child {
  border-radius: 5px 0 0 5px;
}

.view-btn:last-child {
  border-right: none;
  border-radius: 0 5px 5px 0;
}

.view-btn:hover {
  background: var(--color-bg-hover, #f5f5f5);
  color: var(--color-primary);
}

.view-btn.active {
  background: var(--color-primary);
  color: #fff;
}

/* ===== Элементы карточки, скрытые в grid-режиме ===== */
.card-title,
.card-raw-text,
.card-actions {
  display: none;
}

.card-actions {
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 8px;
  position: relative;
  z-index: 2;
}

.btn-sm {
  font-size: 0.85rem;
  padding: 6px 14px;
}

.btn-telegram {
  background: #2ca5e0;
  color: #fff;
  border: none;
}

.btn-telegram:hover {
  background: #1a8fc0;
  color: #fff;
}

/* ===== List mode ===== */
.cards-grid.list-mode {
  grid-template-columns: 1fr;
  gap: 12px;
}

.cards-grid.list-mode .realty-card {
  display: flex;
  flex-direction: row;
  min-height: 220px;
  max-height: 260px;
  overflow: hidden;
}

.cards-grid.list-mode .card-image {
  width: 320px;
  min-width: 320px;
  aspect-ratio: unset;
  height: 260px;
  flex-shrink: 0;
  overflow: hidden;
}

.cards-grid.list-mode .card-body {
  display: flex;
  flex-direction: column;
  padding: 14px 16px;
  min-width: 0;
  flex: 1;
}

.cards-grid.list-mode .card-title {
  display: none;
}

.cards-grid.list-mode .card-price {
  display: block;
  flex-shrink: 0;
  margin-bottom: 8px;
}

.cards-grid.list-mode .card-date {
  display: block;
  flex-shrink: 0;
}

.cards-grid.list-mode .card-raw-text {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 8px;
  line-height: 1.5;
}

.cards-grid.list-mode .card-actions {
  display: flex;
  margin-top: auto;
}

.cards-grid.list-mode .favorite-btn {
  right: calc(100% - 320px + 8px);
}

/* List mode mobile: вертикальная раскладка */
@media (max-width: 600px) {
  .cards-grid.list-mode .realty-card {
    flex-direction: column;
    max-height: none;
  }

  .cards-grid.list-mode .card-image {
    width: 100%;
    min-width: unset;
    height: 200px;
    aspect-ratio: unset;
  }

  .cards-grid.list-mode .favorite-btn {
    right: 8px;
  }
}

/* ===== Pricing Page ===== */
.pricing-page {
  max-width: 940px;
  margin: 0 auto;
  padding: 24px 0;
}

.pricing-page h1 {
  text-align: center;
  margin-bottom: 32px;
}

.pricing-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 600px) {
  .pricing-cards {
    grid-template-columns: 1fr;
  }
}

.pricing-card {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.pricing-card-dimmed {
  opacity: 0.75;
}

.pricing-card-dimmed .pricing-card-header h2 {
  color: var(--color-text-muted);
}

.pricing-card-dimmed .pricing-price {
  color: var(--color-text-muted);
}

.pricing-card-pro {
  border-color: var(--color-success);
}

.pricing-card-header {
  text-align: center;
}

.pricing-card-header h2 {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.pricing-price {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
}

.pricing-period {
  font-weight: 400;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.pricing-features {
  list-style: none;
  width: 100%;
}

.pricing-features li {
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.95rem;
}

.pricing-features li:last-child {
  border-bottom: none;
}

.pricing-current-badge {
  display: inline-block;
  background: var(--color-success);
  color: #fff;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
}

.pricing-badge-muted {
  background: #bbb;
}

.pricing-renews {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  text-align: center;
}

.pricing-error {
  color: #e74c3c;
  font-size: 0.875rem;
  text-align: center;
  margin-top: 0.5rem;
  min-height: 1.25rem;
}

/* ===== Anonymous CTA Banner ===== */
.anon-cta-banner {
  background: linear-gradient(135deg, var(--color-primary), #f39c12);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.95rem;
}
.anon-cta-banner .btn {
  background: #fff;
  color: var(--color-primary);
  font-weight: 600;
  padding: 6px 16px;
}
.anon-cta-banner .btn:hover {
  background: #f0f0f0;
}
.anon-banner-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  opacity: 0.7;
  line-height: 1;
}
.anon-banner-close:hover { opacity: 1; }

/* ===== Auth Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-card {
  background: var(--color-surface);
  padding: 32px;
  border-radius: var(--radius);
  max-width: 400px;
  width: 90%;
  text-align: center;
}
.modal-card h3 {
  margin-bottom: 12px;
}
.modal-card p {
  color: var(--color-text-muted);
  margin-bottom: 20px;
  font-size: 0.95rem;
}
.modal-close {
  float: right;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-text-muted);
  line-height: 1;
}
.modal-close:hover { color: var(--color-text); }

/* ===== Locked Buttons ===== */
.btn-locked {
  opacity: 0.6;
}
.btn-locked::after {
  content: '\01F512';
  font-size: 0.7em;
  margin-left: 4px;
}

/* ===== Locked Raw Text Placeholder ===== */
.raw-text-block-locked .raw-text-placeholder {
  background: var(--color-bg);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}
.raw-text-block-locked .raw-text-placeholder p {
  color: var(--color-text-muted);
  margin-bottom: 12px;
}
