/* ═══════════════════════════════════════════════════════
   CoreAuto Design System — Dark Automotive Theme
   ═══════════════════════════════════════════════════════ */

:root {
  --bg:           #080e1a;
  --bg-card:      #0f1929;
  --bg-surface:   #131f30;
  --bg-surface2:  #1a2840;
  --border:       rgba(255,255,255,0.08);
  --border-focus: #3b82f6;
  --accent:       #3b82f6;
  --accent-hover: #2563eb;
  --accent-green: #22c55e;
  --accent-red:   #ef4444;
  --text:         #e2e8f0;
  --text-muted:   #64748b;
  --text-dim:     #94a3b8;
  --radius-sm:    8px;
  --radius-md:    14px;
  --radius-lg:    20px;
  --shadow:       0 4px 24px rgba(0,0,0,0.5);
}

*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] {
  display: none !important;
}

html { scroll-behavior: smooth; }

body {
  font-family: system-ui,-apple-system,"Segoe UI",sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.5;
}

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

img { display: block; max-width: 100%; }

/* ── Layout ─────────────────────────────────────────── */

#app {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

/* ── Header ─────────────────────────────────────────── */

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 0;
  background: rgba(8,14,26,0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}

.app-header-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.header-brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.menu-toggle-btn {
  font-size: 1rem;
  padding-inline: 12px;
}

.app-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.app-title {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 15%, #93c5fd 45%, #3b82f6 75%, #22d3ee 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

.brand-link:not(.brand-link--current):hover {
  opacity: 0.86;
}

.brand-logo {
  display: block;
  width: min(270px, 44vw);
  height: auto;
}

.theme-toggle-btn {
  width: 44px;
  height: 40px;
  padding: 6px;
  justify-content: center;
}

.theme-icon {
  width: 28px;
  height: 28px;
  filter: invert(1);
}

.app-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.top-nav-link {
  color: var(--text-dim);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.78rem;
  transition: all 0.15s ease;
}

.top-nav-link:hover {
  text-decoration: none;
  border-color: var(--border);
  color: var(--text);
}

.top-nav-link--active {
  background: var(--bg-surface2);
  border-color: var(--border);
  color: var(--text);
}

.side-menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(2, 6, 23, 0.5);
  backdrop-filter: blur(3px);
  display: flex;
  justify-content: flex-start;
}

.side-menu-overlay[hidden] {
  display: none !important;
}

.side-menu {
  width: min(360px, 88vw);
  height: 100%;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow);
}

.side-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.side-menu-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.side-menu-links a {
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--bg-surface);
}

.side-menu-links a:hover {
  border-color: var(--accent);
}

/* ── Main ────────────────────────────────────────────── */

.app-main {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

/* ── Buttons ─────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  background: none;
  color: var(--text);
}

.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: default; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 12px rgba(59,130,246,0.35);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 0 18px rgba(59,130,246,0.5);
}

.btn-secondary {
  background: var(--bg-surface2);
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-dim);
}
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--text-dim); }

.btn-danger {
  background: rgba(239,68,68,0.12);
  border-color: rgba(239,68,68,0.4);
  color: #fca5a5;
}
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,0.22); }

.btn-favorite {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-dim);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-favorite:hover { border-color: #f472b6; color: #f9a8d4; }

/* ── Inputs ──────────────────────────────────────────── */

input, textarea, select {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 8px 12px;
  font-size: 0.85rem;
  background: var(--bg-surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
input:focus, textarea:focus { border-color: var(--border-focus); box-shadow: 0 0 0 2px rgba(59,130,246,0.2); }
textarea { resize: vertical; border-radius: var(--radius-sm); }
input[type="checkbox"] { width: auto; }

/* ── Filters ─────────────────────────────────────────── */

.filters-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 18px;
  border: 1px solid var(--border);
}

.hero-banner {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(120% 90% at 90% 0%, rgba(59,130,246,0.25) 0%, rgba(59,130,246,0) 60%),
    linear-gradient(160deg, var(--bg-card) 0%, var(--bg-surface) 100%);
  padding: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.hero-content {
  min-width: 0;
}

.hero-title {
  font-size: 1.35rem;
  line-height: 1.2;
  margin-bottom: 6px;
}

.hero-subtitle {
  font-size: 0.9rem;
  color: var(--text-dim);
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(95px, 1fr));
  gap: 10px;
}

.hero-stat {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.02);
  padding: 8px 10px;
  text-align: center;
}

.hero-stat span {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
}

.hero-stat small {
  color: var(--text-muted);
  font-size: 0.72rem;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.8rem;
}
.field span { color: var(--text-dim); font-weight: 500; }

.filters-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* ── Cards grid ──────────────────────────────────────── */

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* ── Card ────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.55);
  border-color: rgba(59,130,246,0.35);
}

.card-image {
  position: relative;
  padding-top: 58%;
  background: var(--bg-surface);
  overflow: hidden;
}
.card-image img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}
.card:hover .card-image img { transform: scale(1.04); }

.card-no-photo {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.card-photo-count {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
}

.card-body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  min-width: 0;
  flex: 1;
}

.card-price {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent-green);
  white-space: nowrap;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.pill {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-surface2);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-dim);
}

.card-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.card-footer { margin-top: auto; }

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.card-detail-btn { font-size: 0.8rem; padding: 6px 14px; }

/* ── Admin section ───────────────────────────────────── */

.admin-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 18px;
  border: 1px solid rgba(59,130,246,0.25);
  box-shadow: 0 0 24px rgba(59,130,246,0.07);
}

.admin-card-header { margin-bottom: 12px; }
.admin-card-subtitle { font-size: 0.8rem; color: var(--text-muted); margin-top: 3px; }

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
  align-items: end;
}

.admin-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.admin-note { grid-column: 1/-1; font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

.admin-photo-field input[type="file"] {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.admin-photo-hint {
  grid-column: auto;
  margin-top: 6px;
}

.admin-photo-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.admin-photo-preview img {
  width: 88px;
  height: 66px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid rgba(55, 65, 81, 0.8);
  background: rgba(15, 23, 42, 0.95);
}

/* ── Listing detail page ─────────────────────────────── */

.listing-gallery {
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

.gallery-main {
  position: relative;
  width: 100%;
  padding-top: 52%;
  background: var(--bg-surface);
  overflow: hidden;
}

.gallery-main-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.gallery-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.55);
  color: #fff;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  z-index: 2;
  backdrop-filter: blur(4px);
}
.gallery-arrow:hover { background: rgba(59,130,246,0.75); }
.gallery-arrow--prev { left: 12px; }
.gallery-arrow--next { right: 12px; }

.gallery-thumbs {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.gallery-thumb {
  width: 72px;
  height: 52px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 2px solid transparent;
  flex-shrink: 0;
  transition: border-color 0.15s, opacity 0.15s;
  opacity: 0.7;
}
.gallery-thumb:hover { opacity: 1; }
.gallery-thumb--active { border-color: var(--accent); opacity: 1; }

.gallery-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.gallery-thumb-add {
  width: 72px;
  height: 52px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  border: 2px dashed var(--border);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.gallery-thumb-add:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(59, 130, 246, 0.08);
}

.gallery-thumb-add:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.listing-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.listing-title { font-size: 1.6rem; font-weight: 700; line-height: 1.25; }

.listing-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.listing-price-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

.listing-price {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--accent-green);
  white-space: nowrap;
}

.listing-specs-section,
.listing-desc-section,
.listing-contact-section {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 18px 20px;
  margin-bottom: 16px;
}

.listing-specs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.spec-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.spec-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.spec-value { font-size: 0.95rem; font-weight: 600; color: var(--text); }

.listing-desc { font-size: 0.9rem; color: var(--text-dim); line-height: 1.65; white-space: pre-wrap; }

.listing-contact-card {
  display: block;
}

.listing-contact-links {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
}

.contact-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.contact-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.contact-value {
  display: block;
  font-size: 0.92rem;
  color: var(--text);
  line-height: 1.4;
  text-decoration: none;
}

.contact-email-link,
.contact-phone-link {
  color: var(--text);
}

.contact-email-link:hover,
.contact-phone-link:hover,
.contact-telegram-link:hover {
  color: var(--accent);
}

.contact-telegram-link {
  color: var(--accent);
}

.catalog-control-mobile {
  display: none;
}

.catalog-autocomplete {
  position: relative;
}

.catalog-autocomplete-list {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 220px;
  overflow-y: auto;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.catalog-autocomplete-list li {
  padding: 8px 12px;
  font-size: 0.85rem;
  cursor: pointer;
}

.catalog-autocomplete-list li:hover,
.catalog-autocomplete-list li[aria-selected="true"] {
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent);
}

@media (max-width: 680px) {
  .catalog-control-desktop {
    display: none;
  }

  .catalog-control-mobile {
    display: block;
  }
}

.contact-call-btn { font-size: 0.95rem; padding: 10px 22px; }

/* ── Listing page layout inspired by marketplace style ───────────────── */

.listing-page-main {
  margin-top: 16px;
}

.listing-top {
  margin-bottom: 10px;
}

.listing-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.listing-admin-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.listing-inactive-badge,
.card-inactive-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.card-inactive {
  opacity: 0.92;
}

.card-inactive .card-image {
  position: relative;
}

.card-inactive-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  left: auto;
  z-index: 2;
}

.listing-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
  gap: 18px;
  align-items: start;
}

.listing-left-col {
  min-width: 0;
}

.listing-right-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 78px;
}

.listing-info-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 16px 14px;
  box-shadow: var(--shadow);
}

.listing-fav-btn {
  width: 100%;
  margin-top: 10px;
  margin-bottom: 10px;
}

.listing-spec-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.spec-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--border);
}

.spec-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.spec-row .spec-label {
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.86rem;
}

.spec-row .spec-value {
  text-align: right;
  font-size: 0.95rem;
}

/* ── Empty / Not found ───────────────────────────────── */

.empty-state {
  padding: 40px 20px;
  text-align: center;
  border-radius: var(--radius-lg);
  border: 1px dashed var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── Toasts ──────────────────────────────────────────── */

#toasts {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--bg-surface2);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text);
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease;
}
.toast-success { border-color: var(--accent-green); color: #86efac; }
.toast-error   { border-color: var(--accent-red);   color: #fca5a5; }
.toast-info    { border-color: var(--accent);        color: #93c5fd; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Auth controls ───────────────────────────────────── */

#authControls { display: flex; gap: 8px; align-items: center; }
#authControls button { white-space: nowrap; }
#profileSection { display: flex; gap: 8px; align-items: center; }
#profileSection[hidden] { display: none !important; }

#authControls {
  gap: 6px;
}

#profileName,
.profile-name-link {
  font-size: 0.78rem;
  color: var(--text-dim);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.profile-name-link:hover {
  color: var(--accent);
  border-bottom-color: rgba(59, 130, 246, 0.45);
  text-decoration: none;
}

/* ── Auth modal ──────────────────────────────────────── */

.auth-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.auth-modal-overlay[hidden] { display: none !important; }

.auth-modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow);
}
.auth-modal[hidden] { display: none !important; }

.edit-listing-modal {
  max-width: 820px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

.edit-listing-heading {
  margin: 0 0 16px;
  font-size: 1.25rem;
}

.edit-listing-form { gap: 14px; }

.edit-listing-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.edit-listing-wide { grid-column: 1 / -1; }

.edit-listing-active {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.edit-listing-active input { width: auto; }

.edit-listing-photos-field { min-width: 0; }

.edit-listing-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.edit-photo-item {
  position: relative;
}

.edit-photo-delete {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: #dc2626;
  color: #fff;
  font-size: 19px;
  line-height: 20px;
  cursor: pointer;
}

@media (max-width: 720px) {
  .edit-listing-modal {
    width: calc(100% - 20px);
    max-height: calc(100vh - 20px);
    padding: 20px;
  }

  .edit-listing-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 480px) {
  .edit-listing-grid { grid-template-columns: 1fr; }
  .edit-listing-wide { grid-column: auto; }
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.auth-form[hidden] { display: none !important; }
.auth-form h2 { font-size: 1.2rem; margin-bottom: 4px; }

#authSwitchMode {
  margin-top: 14px;
}

#authCloseBtn {
  margin-top: 10px;
}

.contacts-modal {
  max-width: 520px;
}

.contacts-static {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  color: var(--text-dim);
  font-size: 0.88rem;
}

.contacts-static a {
  color: var(--accent);
}

#contactsModalOverlay {
  z-index: 1300;
}

.contacts-close-btn {
  margin-top: 14px;
}

/* ── List section ────────────────────────────────────── */

.list-section {}

.listings-load-more {
  display: flex;
  justify-content: center;
  margin-top: 1.25rem;
}

.listing-tabs {
  display: flex;
  gap: 6px;
  margin: 0 0 16px;
  padding: 4px;
  width: fit-content;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-surface);
}

.listing-tabs[hidden] { display: none !important; }

.listing-tab {
  border: 0;
  border-radius: 9px;
  padding: 8px 16px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  cursor: pointer;
}

.listing-tab.is-active {
  background: var(--accent);
  color: #fff;
}

.app-footer {
  border-top: 1px solid var(--border);
  margin-top: 28px;
  padding-top: 14px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.app-footer-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.app-footer a {
  color: var(--text-dim);
}

/* ── Legal documents ─────────────────────────────────── */

.legal-page {
  align-items: center;
}

.legal-document {
  width: min(100%, 860px);
  padding: clamp(20px, 4vw, 42px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.legal-document-header {
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.legal-eyebrow {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.legal-document h1 {
  font-size: clamp(1.6rem, 4vw, 2.35rem);
  line-height: 1.2;
}

.legal-document h2 {
  margin-bottom: 12px;
  color: var(--text);
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  line-height: 1.35;
}

.legal-document section {
  padding-top: 26px;
}

.legal-document p,
.legal-document li {
  color: var(--text-dim);
  font-size: 0.94rem;
  line-height: 1.75;
}

.legal-document p + p {
  margin-top: 12px;
}

.legal-document ul {
  margin: 10px 0 14px;
  padding-left: 24px;
}

.legal-document li + li {
  margin-top: 5px;
}

.legal-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
  margin-top: 20px;
}

.legal-meta div {
  min-width: 0;
}

.legal-meta dt {
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.legal-meta dd {
  margin-top: 2px;
  overflow-wrap: anywhere;
  color: var(--text-dim);
  font-size: 0.88rem;
}

.legal-history {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 12px;
  padding: 12px 14px;
  color: var(--text-dim);
  font-size: 0.88rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

@media (max-width: 560px) {
  .legal-meta {
    grid-template-columns: 1fr;
  }

  .legal-history {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

/* ── Responsive ──────────────────────────────────────── */

@media (min-width: 901px) {
  .hero-banner {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .hero-stats {
    width: min(100%, 520px);
  }
}

@media (max-width: 680px) {
  #app { padding-inline: 10px; }

  .cards-grid { grid-template-columns: 1fr; }

  .filters-grid { grid-template-columns: 1fr 1fr; }

  .listing-hero { flex-direction: column; }
  .listing-price-block { align-items: flex-start; }
  .listing-title { font-size: 1.25rem; }
  .listing-price { font-size: 1.45rem; }

  .gallery-main { padding-top: 65%; }

  .app-header {
    width: 100%;
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .app-header-main {
    position: relative;
    width: 100%;
    min-height: 48px;
    justify-content: center;
    padding-inline: 52px;
  }

  .app-header-main > .menu-toggle-btn {
    position: absolute;
    left: 0;
  }

  .header-brand-row {
    width: 100%;
    justify-content: center;
  }

  .header-brand-row > .btn {
    display: none;
  }

  .brand-logo {
    width: min(230px, 62vw);
  }

  #authControls {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    padding-bottom: 2px;
  }

  .hero-banner {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-stats {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 440px) {
  .filters-grid { grid-template-columns: 1fr; }

  .top-nav {
    width: 100%;
  }

  .top-nav-link {
    flex: 1 1 calc(50% - 6px);
    text-align: center;
  }

  .hero-stats {
    grid-template-columns: 1fr;
  }
}

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

  .listing-right-col {
    position: static;
  }
}

/* ── Optional light theme ─────────────────────────────────────────────── */

body.theme-light {
  --bg: #f2f4f7;
  --bg-card: #ffffff;
  --bg-surface: #f8fafc;
  --bg-surface2: #eef2f7;
  --border: rgba(15, 23, 42, 0.14);
  --text: #0f172a;
  --text-muted: #64748b;
  --text-dim: #334155;
  --shadow: 0 6px 24px rgba(15, 23, 42, 0.1);
}

body.theme-light .app-header {
  background: rgba(242, 244, 247, 0.92);
}

body.theme-light .app-title {
  background: linear-gradient(135deg, #0f172a 15%, #1d4ed8 60%, #0ea5e9 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

body.theme-light .theme-icon {
  filter: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.listing-breadcrumbs {
  margin-bottom: 12px;
  font-size: 0.88rem;
  color: var(--text-dim);
}

.breadcrumb-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.breadcrumb-list li:not(:last-child)::after {
  content: "›";
  margin-left: 8px;
  color: var(--text-muted);
}

.breadcrumb-list a {
  color: var(--accent);
  text-decoration: none;
}

.breadcrumb-list a:hover {
  text-decoration: underline;
}

.listing-related-section {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.related-block .section-title {
  margin-bottom: 10px;
}

.related-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.related-link {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  text-decoration: none;
  font-size: 0.92rem;
}

.related-link:hover {
  border-color: rgba(59, 130, 246, 0.35);
  color: var(--accent);
}
