:root {
    --primary: #0084ff;          /* Нейтральный синий Avito */
    --primary-hover: #0066cc;
    --bg: #f0f2f5;
    --surface: #ffffff;
    --border: #e0e0e0;
    --text: #212121;
    --text-muted: #6b7280;
    --shadow: 0 2px 12px rgba(0,0,0,0.09);
    --shadow-hover: 0 6px 24px rgba(0,0,0,0.13);
    --radius: 10px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 15px;
}

/* ── HEADER ─────────────────────────────────── */
header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--primary);
    display: flex;
    align-items: center;
    padding: 0 20px;
    height: 60px;
    gap: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.18);
}

.logo {
    flex: 1 1 0;
    min-width: 0;
}

.logo a {
    color: #fff;
    text-decoration: none;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.contract-link a {
    display: inline-flex;
    align-items: center;
    background: rgba(255,255,255,0.18);
    color: #fff;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 22px;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    border: 1.5px solid rgba(255,255,255,0.45);
    transition: background 0.18s;
}

.contract-link a:hover { background: rgba(255,255,255,0.3); }

@media (max-width: 520px) {
    header { padding: 0 12px; gap: 8px; }
    .logo a { font-size: 13px; }
    .contract-link a { font-size: 12px; padding: 6px 10px; }
}

/* ── MAIN CONTAINER ──────────────────────────── */
main {
    max-width: 1120px;
    margin: 0 auto;
    padding: 28px 16px 48px;
}

/* ── OBJECT CARD ─────────────────────────────── */
.object-item {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 32px;
    overflow: hidden;
    transition: box-shadow 0.2s;
}
.object-item:hover { box-shadow: var(--shadow-hover); }

.object-title-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}

.object-title-bar h2 {
    font-size: 22px;
    font-weight: 700;
    color: #1a1e24;
    letter-spacing: -0.3px;
    line-height: 1.3;
    margin: 0;
}

.reserved-badge {
    background: #f59e0b;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
    white-space: nowrap;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.object-body {
    display: flex;
}

/* ── GALLERY ─────────────────────────────────── */
.gallery-wrap {
    flex: 0 0 55%;
    min-width: 0;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.main-media {
    position: relative;
    background: #111;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    flex-shrink: 0;
}

.main-media-inner {
    width: 100%;
    height: 100%;
}

.main-media-inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    cursor: zoom-in;
}

.main-media-inner video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background: #000;
}

/* ── GALLERY ARROWS ──────────────────────────── */
.gallery-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    background: rgba(0,0,0,0.45);
    color: #fff;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background 0.18s;
    user-select: none;
    -webkit-user-select: none;
    padding: 0;
    padding-bottom: 2px;
}
.gallery-arrow:hover { background: rgba(0,0,0,0.72); }
.gallery-arrow.prev { left: 8px; }
.gallery-arrow.next { right: 8px; }

/* ── MEDIA CONTROLS BAR ──────────────────────── */
.media-controls {
    position: absolute;
    bottom: 8px;
    left: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    z-index: 10;
    pointer-events: none;
}

.media-counter {
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    padding: 3px 9px;
    border-radius: 10px;
    pointer-events: none;
}

/* ── DOWNLOAD ICON ───────────────────────────── */
.download-icon {
    width: 30px;
    height: 30px;
    background-color: rgba(0,0,0,0.55);
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    flex-shrink: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='7 10 12 15 17 10'/%3E%3Cline x1='12' y1='15' x2='12' y2='3'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 15px 15px;
    transition: background-color 0.18s;
    border: none;
}
.download-icon:hover { background-color: rgba(0,0,0,0.8); }

/* ── THUMBNAILS ──────────────────────────────── */
.thumbnails {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px;
    background: #f5f6f8;
    border-top: 1px solid var(--border);
    flex: 1;
    align-content: flex-start;
}

.thumbnail {
    width: 58px;
    height: 44px;
    cursor: pointer;
    border-radius: 4px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: border-color 0.15s, opacity 0.15s;
    flex-shrink: 0;
}
.thumbnail:hover { border-color: #90b8e8; opacity: 0.92; }
.thumbnail.active { border-color: var(--primary); }

.thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.thumb-video {
    width: 58px;
    height: 44px;
    cursor: pointer;
    border-radius: 4px;
    overflow: hidden;
    border: 2px solid transparent;
    background: #222;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: border-color 0.15s;
}
.thumb-video:hover { border-color: #90b8e8; }
.thumb-video.active { border-color: var(--primary); }

.thumb-video-icon {
    width: 18px;
    height: 18px;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ffffff'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* ── OBJECT INFO ─────────────────────────────── */
.object-info {
    flex: 1;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.object-price {
    font-size: 24px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.2;
}

.object-desc {
    font-size: 14px;
    color: #444;
    line-height: 1.75;
    margin-bottom: 4px;
}

/* Новая сетка для характеристик — 30% / 70% */
.details-grid {
    display: grid;
    grid-template-columns: 30% 70%;
    gap: 6px 10px;
    align-items: baseline;
    margin: 8px 0;
}

.dl-label {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    word-break: break-word;
}

.dl-value {
    color: var(--text);
    font-weight: 500;
    font-size: 14px;
    word-break: break-word;
}

/* Кнопки */
.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0 4px;
}

.pdf-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fc;
    color: #1e3a8a;
    border: 1px solid #bdd3f0;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
}
.pdf-btn:hover { background: #e2edfc; border-color: var(--primary); }

.btn-download-all {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #e8f1fb;
    color: var(--primary);
    border: 1px solid #a8c8f0;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s;
}
.btn-download-all:hover { background: #cde0f5; }

.btn-download-all::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%230084ff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='7 10 12 15 17 10'/%3E%3Cline x1='12' y1='15' x2='12' y2='3'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    flex-shrink: 0;
}


.plot-card {
    background: #f8fafc;
    border-radius: 10px;
    padding: 14px;
    border: 1px solid #e2e8f0;
    transition: box-shadow 0.15s;
}
.plot-card:hover {
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    border-color: #cbd5e1;
}
.cadastral-number {
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 10px;
    font-size: 15px;
}
.plot-detail {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 13px;
}
.plot-detail .label {
    color: var(--text-muted);
    font-weight: 500;
}
.plot-detail .value {
    font-weight: 600;
    color: #1e293b;
}
.plot-location {
    font-size: 12px;
    color: #64748b;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #cbd5e1;
    line-height: 1.4;
}
/* Убираем кнопку "Позвонить" — теперь только в шапке */

/* ── RESPONSIVE ──────────────────────────────── */
@media (max-width: 768px) {
    .object-body { flex-direction: column; }
    .gallery-wrap { flex: none; border-right: none; border-bottom: 1px solid var(--border); }
    .object-title-bar { padding: 14px 16px; }
    .object-title-bar h2 { font-size: 20px; }
    .details-grid { grid-template-columns: 30% 70%; } /* сохраняем пропорции */
    .dl-label { font-size: 13px; }
    .dl-value { font-size: 13px; }
}

@media (max-width: 480px) {
    main { padding: 16px 8px 40px; }
    .object-title-bar h2 { font-size: 18px; }
    .object-info { padding: 16px 14px; }
    .object-price { font-size: 20px; }
    .details-grid { grid-template-columns: 35% 65%; } /* чуть больше подписи */
}

/* ── MODAL ───────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.92);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}
.modal-overlay.open { display: flex; }

#modal-media {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 95vw;
    max-height: 90vh;
}

#modal-media img {
    max-width: 95vw;
    max-height: 88vh;
    object-fit: contain;
    border-radius: 4px;
    display: block;
}

#modal-media video {
    max-width: 95vw;
    max-height: 88vh;
    display: block;
    border-radius: 4px;
}

.modal-close {
    position: fixed;
    top: 14px;
    right: 14px;
    background: rgba(255,255,255,0.18);
    color: #fff;
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    font-size: 26px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    transition: background 0.18s;
    line-height: 1;
}
.modal-close:hover { background: rgba(255,255,255,0.32); }

.modal-arrow {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.14);
    color: #fff;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    transition: background 0.18s;
    padding-bottom: 2px;
}
.modal-arrow:hover { background: rgba(255,255,255,0.28); }
.modal-arrow.prev { left: 12px; }
.modal-arrow.next { right: 12px; }

.modal-counter {
    position: fixed;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 13px;
    padding: 5px 14px;
    border-radius: 14px;
    z-index: 10001;
    white-space: nowrap;
}

.no-media-ph {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    font-size: 14px;
    background: #f5f5f5;
}