* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text-main);
}

.hidden {
    display: none;
}

.page {
    max-width: 900px;
    margin: 24px auto;
    padding: 24px;
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    border-bottom: 1px solid var(--border-soft);
    padding-bottom: 16px;
    margin-bottom: 16px;
}

header .logo {
    max-width: 160px;
}

header .logo img {
    max-width: 350px;
    height: 80px;
    display: block;
}

header .agency {
    text-align: right;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

header .agency strong {
    font-size: 15px;
    color: var(--text-main);
}

/* HERO FOTOS: principal + 4 miniaturas */
.hero {
    display: grid;
    grid-template-columns: minmax(0, 2.1fr) minmax(0, 1.4fr);
    gap: 12px;
    margin-bottom: 12px;
}

.hero-main-photo {
    border-radius: 14px;
    overflow: hidden;
    background: #000;
}

.hero-main-photo img {
    width: 100%;
    height: 360px;
    object-fit: cover;
    display: block;
}

.hero-thumbs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, 1fr);
    gap: 8px;
}

.thumb {
    border-radius: 10px;
    overflow: hidden;
    background: #000;
}

.thumb img {
    width: 100%;
    height: 170px;
    object-fit: cover;
    display: block;
}

.hero-info {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
    align-items: baseline;
}

.hero-main {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.hero-title {
    font-size: 22px;
    font-weight: 700;
}

.hero-location {
    font-size: 14px;
    color: var(--text-muted);
}

.hero-price-block {
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.price-main {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
}

.price-secondary {
    font-size: 13px;
    color: var(--text-muted);
}

.code-pill {
    align-self: flex-end;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid #fecaca;
}

.section {
    padding: 14px 0;
    border-top: 1px solid var(--border-soft);
}

.section:first-of-type {
    border-top: none;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 24px;
    font-size: 13px;
    color: #374151;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    border-bottom: 1px dashed #e5e7eb;
    padding: 3px 0;
}

.detail-label {
    font-weight: 500;
}

.detail-value {
    text-align: right;
}

.description {
    font-size: 14px;
    color: #374151;
    line-height: 1.7;
    white-space: pre-line;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 12px;
}

.chip {
    padding: 4px 10px;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #dbeafe;
}

.location-block {
    font-size: 14px;
    color: #374151;
    margin-bottom: 10px;
}

/* Bloque de mapa */
.map-wrapper {
    margin-top: 4px;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    background: #e5e7eb;
}

.map-wrapper img {
    width: 100%;
    height: 260px;
    object-fit: cover;
    display: block;
}

.map-note {
    margin-top: 4px;
    font-size: 11px;
    color: #9ca3af;
}

.contact-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    font-size: 13px;
    color: #374151;
}

.contact-box {
    padding: 12px;
    border-radius: 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    align-items: center;
}

.contact-avatar {
    width: 56px;
    height: 56px;
    border-radius: 999px;
    overflow: hidden;
    background: #e5e7eb;
}

.contact-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.contact-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.contact-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.contact-box a {
    color: #2563eb;
    text-decoration: none;
}

.note {
    margin-top: 10px;
    font-size: 11px;
    color: #9ca3af;
    line-height: 1.5;
}

/* Multimedia */
.media-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    font-size: 12px;
}

.media-card {
    padding: 10px;
    border-radius: 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.media-label {
    font-weight: 600;
    font-size: 13px;
}

.media-desc {
    color: #6b7280;
    font-size: 12px;
}

.media-btn {
    margin-top: 2px;
    align-self: flex-start;
    padding: 4px 10px;
    border-radius: 999px;
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.media-btn:visited {
    color: #fff;
}

/* Responsive */
@media (max-width: 720px) {
    .page {
        margin: 0;
        border-radius: 0;
        box-shadow: none;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    header .agency {
        text-align: left;
    }

    .hero {
        grid-template-columns: minmax(0, 1fr);
    }

    .hero-main-photo img {
        height: 260px;
    }

    .hero-thumbs {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        grid-auto-rows: 80px;
    }

    .thumb img {
        height: 80px;
    }

    .hero-info {
        flex-direction: column;
        align-items: flex-start;
    }

    .hero-price-block {
        align-items: flex-start;
        text-align: left;
    }

    .contact-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .map-wrapper img {
        height: 220px;
    }

    .media-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Impresión A4 */
@media print {
    body {
        background: #ffffff;
    }

    .page {
        margin: 0;
        border-radius: 0;
        box-shadow: none;
    }

    @page {
        size: A4;
        margin: 1.5cm;
    }
}
