* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f5f5f5;
    color: #1a1a1a;
    line-height: 1.6;
}

    margin-left: 0;
    padding: 0;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.content-header h1 {
    font-size: 32px;
    font-weight: 700;
    color: #000;
}

.content-header p {
    color: #666;
    margin-top: 5px;
}

/* Cards */
.card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 30px;
    overflow: hidden;
}

.card-header {
    padding: 20px 30px;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: #000;
}

.card-body {
    padding: 30px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: #fff;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    font-size: 40px;
    width: 70px;
    height: 70px;
    background: #f5f5f5;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-info h3 {
    font-size: 28px;
    font-weight: 700;
    color: #000;
}

.stat-info p {
    color: #666;
    font-size: 14px;
    margin-top: 5px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.form-group input,
.form-group textarea,
.form-group select,
.form-select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #d5d5d5;
    border-radius: 8px;
    font-size: 15px;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #000;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.form-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.btn-primary {
    background: #000;
    color: #fff;
}

.btn-primary:hover {
    background: #333;
}

.btn-secondary {
    background: #f5f5f5;
    color: #333;
}

.btn-secondary:hover {
    background: #e5e5e5;
}

.btn-danger {
    background: #dc3545;
    color: #fff;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-success {
    background: #28a745;
    color: #fff;
}

.btn-success:hover {
    background: #218838;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
}

.btn-block {
    width: 100%;
    text-align: center;
}

/* Login */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f5f5f5 0%, #e5e5e5 100%);
    padding: 20px;
}

.login-box {
    background: #fff;
    padding: 50px;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 480px;
}

.login-box h1 {
    font-size: 28px;
    font-weight: 700;
    color: #000;
    text-align: center;
    margin-bottom: 10px;
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: #f5f5f5;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background: #000;
    color: #fff;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Alerts */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* View toggle - pill switcher */
.view-toggle {
    display: flex;
    align-items: center;
    background: #f0f0f0;
    border-radius: 10px;
    padding: 4px;
    gap: 2px;
    border: 1px solid #e5e5e5;
}

.view-toggle-btn {
    background: transparent;
    border: none;
    border-radius: 7px;
    padding: 7px 14px;
    cursor: pointer;
    color: #999;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    white-space: nowrap;
}

.view-toggle-btn svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    transition: all 0.2s;
}

.view-toggle-btn:hover {
    color: #333;
    background: rgba(0,0,0,0.05);
}

.view-toggle-btn.active {
    background: #fff;
    color: #000;
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
    font-weight: 600;
}

/* Inmuebles Grid - Modo Mosaico (default) */
.inmuebles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
    transition: all 0.3s ease;
}

/* Modo Lista - refinado */
.inmuebles-grid.list-view {
    grid-template-columns: 1fr;
    gap: 12px;
}

/* MÓVIL: imagen chica arriba, info compacta abajo */
.inmuebles-grid.list-view .inmueble-card {
    flex-direction: column;
    height: auto;
    border-radius: 10px;
}

.inmuebles-grid.list-view .inmueble-image,
.inmuebles-grid.list-view .inmueble-image-gallery {
    width: 100%;
    min-width: 100%;
    height: 120px;
    border-radius: 10px 10px 0 0;
}

.inmuebles-grid.list-view .inmueble-image img,
.inmuebles-grid.list-view .inmueble-image-gallery img {
    object-fit: cover;
    width: 100%;
    height: 100%;
}

.inmuebles-grid.list-view .inmueble-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.inmuebles-grid.list-view .inmueble-header {
    flex: unset;
    padding: 8px 12px 4px;
    border-bottom: none;
    display: flex;
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.inmuebles-grid.list-view .inmueble-header h3 {
    font-size: 13px;
    font-weight: 600;
    color: #1a1a1a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.inmuebles-grid.list-view .inmueble-header h3 a {
    color: inherit;
    text-decoration: none;
}

.inmuebles-grid.list-view .inmueble-price {
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.inmuebles-grid.list-view .inmueble-body {
    flex: unset;
    padding: 2px 12px 6px;
    border-left: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.inmuebles-grid.list-view .inmueble-details {
    gap: 2px 12px;
    flex-wrap: wrap;
    font-size: 0.75rem;
}

.inmuebles-grid.list-view .inmueble-description {
    display: none;
}

.inmuebles-grid.list-view .custom-fields {
    display: none;
}

.inmuebles-grid.list-view .inmueble-footer {
    border-top: 1px solid #333;
    border-left: none;
    padding: 6px 12px;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    min-width: unset;
}

.inmuebles-grid.list-view .inmueble-footer .btn-sm {
    font-size: 0.75rem;
    padding: 4px 10px;
}

.inmuebles-grid.list-view .inmueble-footer .btn-lead {
    font-size: 0.75rem !important;
    padding: 4px 10px !important;
}

/* ESCRITORIO: fila horizontal */
@media (min-width: 769px) {
    .inmuebles-grid.list-view .inmueble-card {
        flex-direction: row;
        height: 140px;
    }
    .inmuebles-grid.list-view .inmueble-image,
    .inmuebles-grid.list-view .inmueble-image-gallery {
        width: 200px;
        min-width: 200px;
        height: 100%;
        border-radius: 10px 0 0 10px;
    }
    .inmuebles-grid.list-view .inmueble-content {
        flex-direction: row;
        align-items: stretch;
    }
    .inmuebles-grid.list-view .inmueble-header {
        flex: 1.2;
        flex-direction: column;
        flex-wrap: nowrap;
        padding: 18px 22px;
        border-bottom: none;
        justify-content: center;
        gap: 6px;
    }
    .inmuebles-grid.list-view .inmueble-header h3 {
        font-size: 15px;
    }
    .inmuebles-grid.list-view .inmueble-price {
        font-size: 17px;
    }
    .inmuebles-grid.list-view .inmueble-body {
        flex: 2;
        padding: 18px 20px;
        border-left: 1px solid #f0f0f0;
        justify-content: center;
    }
    .inmuebles-grid.list-view .inmueble-details {
        font-size: 0.875rem;
        gap: 8px 20px;
    }
    .inmuebles-grid.list-view .inmueble-footer {
        border-top: none;
        border-left: 1px solid #e8e8e8;
        padding: 0 14px;
        flex-direction: column;
        align-items: stretch;
        justify-content: center;
        min-width: 120px;
        gap: 6px;
    }
    .inmuebles-grid.list-view .inmueble-footer .btn-sm {
        width: 100%;
        justify-content: center;
        padding: 7px 10px;
        font-size: 0.78rem;
        font-weight: 600;
        border-radius: 7px;
        gap: 5px;
    }
    .inmuebles-grid.list-view .inmueble-footer .btn-sm svg {
        width: 12px;
        height: 12px;
        flex-shrink: 0;
    }
    /* Editar — outline sutil */
    .inmuebles-grid.list-view .inmueble-footer .btn-edit {
        background: transparent;
        color: #555;
        border: 1.5px solid #ddd !important;
    }
    .inmuebles-grid.list-view .inmueble-footer .btn-edit:hover {
        background: #111 !important;
        color: #fff !important;
        border-color: #111 !important;
    }
    /* Eliminar — rojo sólido */
    .inmuebles-grid.list-view .inmueble-footer .btn-danger {
        background: #dc2626;
        color: #fff;
        border: none !important;
    }
    .inmuebles-grid.list-view .inmueble-footer .btn-danger:hover {
        background: #b91c1c !important;
    }
    /* Lead — outline acento */
    .inmuebles-grid.list-view .inmueble-footer .btn-lead {
        background: transparent !important;
        color: #9c3030 !important;
        border: 1.5px solid #9c3030 !important;
        font-size: 0.78rem !important;
        padding: 7px 10px !important;
    }
    .inmuebles-grid.list-view .inmueble-footer .btn-lead:hover {
        background: #9c3030 !important;
        color: #fff !important;
    }
}

.inmueble-card {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
}

.inmueble-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.inmueble-image {
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: #f5f5f5;
}

.inmueble-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.inmueble-card:hover .inmueble-image img {
    transform: scale(1.05);
}

/* Galería de imágenes */
.inmueble-image-gallery {
    width: 100%;
    height: 200px;
    position: relative;
    overflow: hidden;
    background: #f5f5f5;
}

.inmueble-image-gallery .gallery-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.inmueble-image-gallery .gallery-img.active {
    opacity: 1;
}

.gallery-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    padding: 10px 15px;
    font-size: 24px;
    cursor: pointer;
    z-index: 10;
    transition: background 0.2s;
    border-radius: 4px;
}

.gallery-btn:hover {
    background: rgba(0, 0, 0, 0.9);
}

.gallery-prev {
    left: 10px;
}

.gallery-next {
    right: 10px;
}

.gallery-indicators {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 10;
}

.gallery-indicators .indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: all 0.3s;
}

.gallery-indicators .indicator:hover {
    background: rgba(255, 255, 255, 0.8);
}

.gallery-indicators .indicator.active {
    background: white;
    width: 12px;
    height: 12px;
}

.inmueble-content {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.inmueble-header {
    padding: 20px;
    border-bottom: 1px solid #e5e5e5;
}

.inmueble-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #000;
    margin-bottom: 8px;
}

.inmueble-header h3 a {
    color: #000;
    text-decoration: none;
    transition: color 0.2s;
}

.inmueble-header h3 a:hover {
    color: #9c3030;
}

.inmueble-price {
    font-size: 24px;
    font-weight: 700;
    color: #000;
}

.inmueble-body {
    padding: 20px;
}

.inmueble-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 15px;
}

.detail-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #666;
}

.inmueble-description {
    color: #666;
    font-size: 14px;
    margin-top: 15px;
    line-height: 1.5;
}

.custom-fields {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e5e5e5;
    font-size: 14px;
}

.custom-field-item {
    margin-top: 8px;
}

.field-name {
    font-weight: 500;
    color: #666;
}

.field-value {
    color: #000;
    margin-left: 5px;
}

.inmueble-footer {
    padding: 12px 16px;
    border-top: 1px solid #e5e5e5;
    display: flex;
    gap: 8px;
    align-items: stretch;
    justify-content: flex-end;
    margin-top: auto;
}

.inmueble-footer .btn-sm {
    flex: 0 0 auto;
    justify-content: center;
    padding: 8px 14px;
    font-size: .82rem;
    font-weight: 600;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: filter .15s, transform .1s;
    white-space: nowrap;
}
.inmueble-footer .btn-sm:hover { filter: brightness(1.1); transform: translateY(-1px); }
.inmueble-footer .btn-sm:active { transform: translateY(0); }

/* Botón editar */
.btn-edit {
    background: #f0f0f0;
    color: #333;
    border: 1px solid #e0e0e0 !important;
    display: inline-flex;
    align-items: center;
}
.btn-edit:hover {
    background: #222 !important;
    color: #fff !important;
    border-color: #222 !important;
}

.btn-danger {
    display: inline-flex;
    align-items: center;
}

/* Botón Lead */
.btn-lead {
    background: #fff;
    color: #555;
    border: 1.5px solid #ddd !important;
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}
.btn-lead:hover {
    background: #f5f5f5 !important;
    color: #333 !important;
}

/* Edit images section */
.images-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.images-section-header label {
    margin-bottom: 0 !important;
}

.images-count-badge {
    background: #f0f0f0;
    color: #666;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 20px;
    border: 1px solid #e5e5e5;
}

.images-section-hint {
    font-size: 13px;
    color: #999;
    margin-bottom: 14px;
}

/* Grilla unificada */
.edit-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.edit-image-item {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid #e8e8e8;
    aspect-ratio: 4 / 3;
    cursor: pointer;
    transition: border-color 0.2s, opacity 0.2s, transform 0.15s;
    background: #f5f5f5;
}

.edit-image-item:hover {
    border-color: #ccc;
    transform: translateY(-1px);
}

.edit-image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: filter 0.2s;
}

.edit-image-item:hover img {
    filter: brightness(0.88);
}

/* Estado eliminado */
.edit-image-item.removed {
    border-color: #dc3545;
    opacity: 0.55;
}

.edit-image-item.removed img {
    filter: grayscale(60%);
}

/* Overlay al hover y al marcar */
.edit-image-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(220, 53, 69, 0.45);
    align-items: center;
    justify-content: center;
    z-index: 2;
    pointer-events: none;
}

.edit-image-delete-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.edit-image-item:hover .edit-image-overlay:not([style*="flex"]) {
    display: flex;
    background: rgba(0,0,0,0.35);
}

/* Badge "Guardada" / "Nueva" */
.edit-image-badge {
    position: absolute;
    bottom: 7px;
    left: 7px;
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 4px;
    backdrop-filter: blur(4px);
    letter-spacing: 0.2px;
    z-index: 3;
}

.edit-image-badge svg circle {
    fill: #4ade80;
}

.new-badge svg circle {
    fill: #60a5fa;
}

/* Botón agregar */
.edit-image-add {
    aspect-ratio: 4 / 3;
    border: 2px dashed #d5d5d5;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    color: #aaa;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    background: #fafafa;
}

.edit-image-add small {
    font-size: 11px;
    color: #bbb;
    font-weight: 400;
}

.edit-image-add:hover {
    border-color: #999;
    color: #555;
    background: #f5f5f5;
}

.edit-image-add:hover svg {
    stroke: #555;
}

/* Botón agregar por URL */
.url-toggle-btn {
    background: none;
    border: none;
    color: #666;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.15s;
}

.url-toggle-btn:hover {
    color: #000;
}

/* Table */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #e5e5e5;
}

.table th {
    background: #f8f8f8;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.table td {
    color: #666;
    font-size: 14px;
}

/* Utilities */
.text-muted {
    color: #999;
}

.badge {
    display: inline-block;
    padding: 4px 12px;
    background: #f5f5f5;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state p {
    color: #999;
    margin-bottom: 20px;
    font-size: 16px;
}

/* Two Column Layout */
.two-column-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.plantilla-item {
    padding: 20px;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.plantilla-info h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 10px;
}

.plantilla-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.field-badge {
    display: inline-block;
    padding: 4px 10px;
    background: #f5f5f5;
    border-radius: 4px;
    font-size: 12px;
    color: #666;
}

.filters-form .form-actions {
    justify-content: flex-end;
}

/* Responsive */
@media (max-width: 1024px) {
    .two-column-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding: 20px;
    }

    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .inmuebles-grid {
        grid-template-columns: 1fr;
    }

    /* ── MOSAICO MOBILE: 2 columnas compactas ── */
    .inmuebles-grid:not(.list-view) {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    .inmuebles-grid:not(.list-view) .inmueble-image,
    .inmuebles-grid:not(.list-view) .inmueble-image-gallery {
        height: 120px;
    }
    .inmuebles-grid:not(.list-view) .inmueble-header {
        padding: 8px 10px;
    }
    .inmuebles-grid:not(.list-view) .inmueble-header h3 {
        font-size: 11px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .inmuebles-grid:not(.list-view) .inmueble-price {
        font-size: 12px;
        margin-top: 2px;
    }
    .inmuebles-grid:not(.list-view) .inmueble-body {
        display: none; /* ocultar detalles en mobile mosaico */
    }
    .inmuebles-grid:not(.list-view) .inmueble-footer {
        padding: 8px;
        gap: 4px;
        flex-direction: column;
        justify-content: flex-end;
        margin-top: auto;
    }
    .inmuebles-grid:not(.list-view) .inmueble-footer .btn-sm {
        width: 100%;
        padding: 6px 4px;
        font-size: 0.72rem;
        border-radius: 6px;
        justify-content: center;
    }
    .inmuebles-grid:not(.list-view) .inmueble-footer .btn-sm svg {
        display: none; /* ocultar íconos SVG en tarjetas chicas */
    }
    .inmuebles-grid:not(.list-view) .inmueble-footer .btn-lead {
        width: 100%;
        padding: 6px 4px !important;
        font-size: 0.72rem !important;
        border-radius: 6px;
        justify-content: center;
    }

    .login-box {
        padding: 30px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .form-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}
/* ==========================
   RESET
========================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #f5f7fa;
  color: #1e1e1e;
}

/* ==========================
   HEADER
========================== */
.header {
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  padding: 16px 20px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.menu-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background 0.2s;
  min-width: 50px;
  min-height: 50px;
}

.menu-toggle:hover {
  background: #e2e8f0;
}

.menu-toggle:active {
  transform: scale(0.95);
}

.hamburger {
  width: 28px;
  height: 24px;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hamburger span {
  width: 100%;
  height: 4px;
  background: #1e1e1e;
  border-radius: 3px;
  transition: all 0.3s ease;
}

.menu-toggle.active .hamburger span:nth-child(1) {
  transform: translateY(10px) rotate(45deg);
}

.menu-toggle.active .hamburger span:nth-child(2) {
  opacity: 0;
}

.menu-toggle.active .hamburger span:nth-child(3) {
  transform: translateY(-10px) rotate(-45deg);
}

.header-title {
  font-size: 18px;
  font-weight: 600;
  color: #1e1e1e;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #9c3030 0%, #7a2323 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
}

/* ==========================

/* ==========================
   SIDEBAR
========================== */
:root {
  --sidebar-w: 260px;
  --sidebar-collapsed-w: 64px;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: #fff;
  box-shadow: 2px 0 10px rgba(0,0,0,.1);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Desktop: siempre visible, colapso via width */
  transition: width 0.28s cubic-bezier(0.4,0,0.2,1);
}

/* ── Header del sidebar ── */
.sidebar-header {
  padding: 18px 14px 14px;
  border-bottom: 1px solid #e2e8f0;
  background: linear-gradient(135deg, #9c3030 0%, #7a2323 100%);
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
  min-height: 70px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.sidebar-brand-icon {
  font-size: 20px;
  flex-shrink: 0;
  line-height: 1;
  width: 24px;
  text-align: center;
}

.sidebar-brand-text {
  font-size: 17px;
  font-weight: 700;
  overflow: hidden;
  white-space: nowrap;
  transition: opacity 0.2s, max-width 0.28s;
  max-width: 200px;
}

.sidebar-username {
  font-size: 12px;
  opacity: 0.85;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  padding-left: 34px;
  transition: opacity 0.15s;
}

/* ── Botón colapsar (desktop only) ── */
.sidebar-collapse-btn {
  display: none;
  align-items: center;
  justify-content: flex-end;
  padding: 6px 16px;
  gap: 6px;
  background: none;
  border: none;
  border-bottom: 1px solid #e2e8f0;
  cursor: pointer;
  color: #9c3030;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  transition: background 0.15s;
  flex-shrink: 0;
  width: 100%;
}

.sidebar-collapse-btn:hover {
  background: #fdf2f2;
}

.collapse-icon {
  font-size: 10px;
  transition: transform 0.28s;
  display: inline-block;
}

/* ── Nav links ── */
.nav-menu {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 8px;
}

.nav-menu ul {
  list-style: none;
}

.nav-menu li {
  margin-bottom: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: #4a5568;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: 10px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.nav-link:hover {
  background: #f7fafc;
  color: #1e1e1e;
}

.nav-link.active {
  background: #edf2f7;
  color: #9c3030;
  font-weight: 600;
}

.nav-link .icon {
  font-size: 19px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
  line-height: 1;
}

.nav-text {
  overflow: hidden;
  transition: opacity 0.18s, max-width 0.28s;
  max-width: 200px;
  flex: 1;
}

.nav-divider {
  height: 1px;
  background: #e2e8f0;
  margin: 8px 4px;
}

.nav-link.logout { color: #e53e3e; }
.nav-link.logout:hover { background: #fff5f5; }

/* ── Tooltips en modo colapsado ── */
.nav-link::after {
  content: attr(data-tooltip);
  position: fixed;
  left: calc(var(--sidebar-collapsed-w) + 10px);
  background: #070404;
  color: #fff;
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  z-index: 9999;
  box-shadow: 0 4px 14px rgba(0,0,0,.3);
  transition: opacity 0.15s;
  transform: translateY(-50%);
}

/* ==========================
   OVERLAY (mobile only)
========================== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1050;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}
.overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ==========================
   MAIN CONTENT
========================== */
.main-content {
  padding: 80px 24px 24px;
}

/* ==========================
   DESKTOP — sidebar siempre visible + collapse
========================== */
@media (min-width: 769px) {
  .sidebar-collapse-btn { display: flex; }
  .menu-toggle { display: none !important; }
  .overlay { display: none !important; }

  /* sidebar siempre visible en desktop */
  .sidebar {
    transform: none !important;
  }

  .header {
    margin-left: var(--sidebar-w);
    transition: margin-left 0.28s cubic-bezier(0.4,0,0.2,1);
  }

  .main-content {
    margin-left: var(--sidebar-w);
    padding: 80px 32px 32px;
    transition: margin-left 0.28s cubic-bezier(0.4,0,0.2,1);
  }

  /* Estado colapsado */
  html.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-w);
  }

  html.sidebar-collapsed .sidebar-brand-text,
  html.sidebar-collapsed .sidebar-username {
    opacity: 0;
    max-width: 0;
  }

  html.sidebar-collapsed .nav-text {
    opacity: 0;
    max-width: 0;
  }

  html.sidebar-collapsed .nav-link {
    justify-content: center;
    padding: 10px 0;
  }

  html.sidebar-collapsed .sidebar-collapse-btn {
    justify-content: center;
    padding: 6px 0;
  }

  html.sidebar-collapsed .nav-link:hover::after {
    opacity: 1;
  }

  html.sidebar-collapsed .header {
    margin-left: var(--sidebar-collapsed-w);
  }

  html.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-w);
  }
}

/* Mobile — drawer */
@media (max-width: 768px) {
  .sidebar {
    width: min(var(--sidebar-w), 85vw);
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1) !important;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .header { margin-left: 0 !important; }
  .main-content { margin-left: 0 !important; padding: 70px 16px 16px; }
}

@media (max-width: 480px) {
  .header-title { font-size: 16px; }
  .main-content { padding: 66px 12px 12px; }
}

/* ── Hamburger ── */
.hamburger {
  width: 26px;
  height: 19px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.hamburger span {
  width: 100%;
  height: 3px;
  background: #1e1e1e;
  display: block;
  border-radius: 2px;
  transition: all 0.3s;
}
.menu-toggle {
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.menu-toggle.active .hamburger span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.menu-toggle.active .hamburger span:nth-child(2) { opacity: 0; }
.menu-toggle.active .hamburger span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

}

/* ==========================
   THEME SWITCH TOGGLE
========================== */
.theme-switch {
  cursor: pointer;
  display: flex;
  align-items: center;
}

.theme-switch-track {
  width: 64px;
  height: 32px;
  background: #e2e8f0;
  border-radius: 999px;
  position: relative;
  transition: background 0.3s ease;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.12);
}

.theme-switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  background: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  font-size: 14px;
  line-height: 1;
}

body.dark-mode .theme-switch-track,
html.dark-mode .theme-switch-track {
  background: #9c3030;
}

body.dark-mode .theme-switch-thumb,
html.dark-mode .theme-switch-thumb {
  transform: translateX(32px);
  background: #070404;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

/* ==========================
   DARK MODE — VARIABLES BASE
========================== */
body.dark-mode,
html.dark-mode body {
  background: #000000 !important;
  color: #e2e8f0 !important;
}

/* Header */
body.dark-mode .header,
html.dark-mode .header {
  background: #070404 !important;
  border-bottom-color: #1e1e1e !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3) !important;
}

body.dark-mode .header-title,
html.dark-mode .header-title {
  color: #e2e8f0 !important;
}

body.dark-mode .hamburger span,
html.dark-mode .hamburger span {
  background: #e2e8f0 !important;
}

body.dark-mode .menu-toggle:hover,
html.dark-mode .menu-toggle:hover {
  background: #1e1e1e !important;
}

/* Sidebar */
body.dark-mode .sidebar,
html.dark-mode .sidebar {
  background: #070404 !important;
  box-shadow: 2px 0 10px rgba(0,0,0,0.4) !important;
}

body.dark-mode .sidebar-header,
html.dark-mode .sidebar-header {
  background: linear-gradient(135deg, #7a2323 0%, #5c1a1a 100%) !important;
  border-bottom-color: #1e1e1e !important;
}

body.dark-mode .nav-menu a,
html.dark-mode .nav-menu a {
  color: #a0aec0 !important;
}

body.dark-mode .nav-menu a:hover,
html.dark-mode .nav-menu a:hover {
  background: #1e1e1e !important;
  color: #e2e8f0 !important;
}

body.dark-mode .nav-menu a.active,
html.dark-mode .nav-menu a.active {
  background: #2d1f1f !important;
  color: #9c3030 !important;
}

body.dark-mode .nav-divider,
html.dark-mode .nav-divider {
  background: #1e1e1e !important;
}

/* Main content */
body.dark-mode .main-content,
html.dark-mode .main-content {
  background: #000000 !important;
}

body.dark-mode .content-header h1,
html.dark-mode .content-header h1 {
  color: #e2e8f0 !important;
}

body.dark-mode .content-header p,
html.dark-mode .content-header p {
  color: #a0aec0 !important;
}

/* Cards */
body.dark-mode .card,
html.dark-mode .card {
  background: #070404 !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3) !important;
}

body.dark-mode .card-header,
html.dark-mode .card-header {
  border-bottom-color: #1e1e1e !important;
}

body.dark-mode .card-header h2,
html.dark-mode .card-header h2 {
  color: #e2e8f0 !important;
}

/* Stats */
body.dark-mode .stat-card,
html.dark-mode .stat-card {
  background: #070404 !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3) !important;
}

body.dark-mode .stat-icon,
html.dark-mode .stat-icon {
  background: #1e1e1e !important;
}

body.dark-mode .stat-info h3,
html.dark-mode .stat-info h3 {
  color: #e2e8f0 !important;
}

body.dark-mode .stat-info p,
html.dark-mode .stat-info p {
  color: #a0aec0 !important;
}

/* Forms */
body.dark-mode .form-group label,
html.dark-mode .form-group label {
  color: #cbd5e0 !important;
}

body.dark-mode .form-group input,
body.dark-mode .form-group textarea,
body.dark-mode .form-group select,
body.dark-mode .form-select,
html.dark-mode .form-group input,
html.dark-mode .form-group textarea,
html.dark-mode .form-group select,
html.dark-mode .form-select {
  background: #1e1e1e !important;
  border-color: #4a5568 !important;
  color: #e2e8f0 !important;
}

body.dark-mode .form-group input::placeholder,
body.dark-mode .form-group textarea::placeholder,
html.dark-mode .form-group input::placeholder,
html.dark-mode .form-group textarea::placeholder {
  color: #718096 !important;
}

body.dark-mode .form-group input:focus,
body.dark-mode .form-group textarea:focus,
body.dark-mode .form-group select:focus,
html.dark-mode .form-group input:focus,
html.dark-mode .form-group textarea:focus,
html.dark-mode .form-group select:focus {
  border-color: #9c3030 !important;
}

/* Buttons */
body.dark-mode .btn-secondary,
html.dark-mode .btn-secondary {
  background: #1e1e1e !important;
  color: #e2e8f0 !important;
}

body.dark-mode .btn-secondary:hover,
html.dark-mode .btn-secondary:hover {
  background: #4a5568 !important;
}

body.dark-mode .btn-edit,
html.dark-mode .btn-edit {
  background: #1e1e1e !important;
  color: #e2e8f0 !important;
  border-color: #4a5568 !important;
}

body.dark-mode .btn-lead,
html.dark-mode .btn-lead {
  background: #1e1e1e !important;
  color: #a0aec0 !important;
  border-color: #4a5568 !important;
}
body.dark-mode .btn-lead:hover,
html.dark-mode .btn-lead:hover {
  background: #3a4a60 !important;
  color: #e2e8f0 !important;
}

body.dark-mode .tab-btn,
html.dark-mode .tab-btn {
  background: #1e1e1e !important;
  color: #a0aec0 !important;
}

body.dark-mode .tab-btn.active,
html.dark-mode .tab-btn.active {
  background: #9c3030 !important;
  color: #fff !important;
}

/* Tables */
body.dark-mode .table th,
html.dark-mode .table th {
  background: #1e1e1e !important;
  color: #cbd5e0 !important;
}

body.dark-mode .table td,
html.dark-mode .table td {
  color: #a0aec0 !important;
  border-bottom-color: #1e1e1e !important;
}

/* Inmueble cards */
body.dark-mode .inmueble-card,
html.dark-mode .inmueble-card {
  background: #070404 !important;
  border-color: #ff0000 !important;
}

body.dark-mode .inmueble-header,
html.dark-mode .inmueble-header {
  border-bottom-color: #1e1e1e !important;
}

body.dark-mode .inmueble-header h3,
body.dark-mode .inmueble-header h3 a,
html.dark-mode .inmueble-header h3,
html.dark-mode .inmueble-header h3 a {
  color: #e2e8f0 !important;
}

body.dark-mode .inmueble-price,
html.dark-mode .inmueble-price {
  color: #e2e8f0 !important;
}

body.dark-mode .inmueble-footer,
html.dark-mode .inmueble-footer {
  border-top-color: #1e1e1e !important;
  border-left-color: #1e1e1e !important;
}

@media (min-width: 769px) {
    body.dark-mode .inmuebles-grid.list-view .inmueble-footer .btn-edit,
    html.dark-mode .inmuebles-grid.list-view .inmueble-footer .btn-edit {
        background: transparent !important;
        color: #a0aec0 !important;
        border-color: #4a5568 !important;
    }
    body.dark-mode .inmuebles-grid.list-view .inmueble-footer .btn-edit:hover,
    html.dark-mode .inmuebles-grid.list-view .inmueble-footer .btn-edit:hover {
        background: #e2e8f0 !important;
        color: #111 !important;
        border-color: #e2e8f0 !important;
    }
    body.dark-mode .inmuebles-grid.list-view .inmueble-footer .btn-lead,
    html.dark-mode .inmuebles-grid.list-view .inmueble-footer .btn-lead {
        color: #f87171 !important;
        border-color: #f87171 !important;
    }
    body.dark-mode .inmuebles-grid.list-view .inmueble-footer .btn-lead:hover,
    html.dark-mode .inmuebles-grid.list-view .inmueble-footer .btn-lead:hover {
        background: #f87171 !important;
        color: #fff !important;
    }
}

body.dark-mode .inmueble-body,
html.dark-mode .inmueble-body {
  border-left-color: #1e1e1e !important;
}

body.dark-mode .detail-item,
html.dark-mode .detail-item {
  color: #a0aec0 !important;
}

body.dark-mode .inmueble-description,
html.dark-mode .inmueble-description {
  color: #a0aec0 !important;
}

body.dark-mode .custom-fields,
html.dark-mode .custom-fields {
  border-top-color: #1e1e1e !important;
}

body.dark-mode .field-name,
html.dark-mode .field-name {
  color: #a0aec0 !important;
}

body.dark-mode .field-value,
html.dark-mode .field-value {
  color: #e2e8f0 !important;
}

body.dark-mode .inmueble-image,
body.dark-mode .inmueble-image-gallery,
html.dark-mode .inmueble-image,
html.dark-mode .inmueble-image-gallery {
  background: #1e1e1e !important;
}

/* View toggle */
body.dark-mode .view-toggle,
html.dark-mode .view-toggle {
  background: #1e1e1e !important;
  border-color: #4a5568 !important;
}

body.dark-mode .view-toggle-btn,
html.dark-mode .view-toggle-btn {
  color: #718096 !important;
}

body.dark-mode .view-toggle-btn:hover,
html.dark-mode .view-toggle-btn:hover {
  color: #e2e8f0 !important;
  background: rgba(255,255,255,0.05) !important;
}

body.dark-mode .view-toggle-btn.active,
html.dark-mode .view-toggle-btn.active {
  background: #070404 !important;
  color: #e2e8f0 !important;
}

/* Alerts */
body.dark-mode .alert-success,
html.dark-mode .alert-success {
  background: #1c3a2a !important;
  color: #68d391 !important;
  border-color: #2f6848 !important;
}

body.dark-mode .alert-error,
html.dark-mode .alert-error {
  background: #3a1c1c !important;
  color: #ff0000 !important;
  border-color: #6b2020 !important;
}

/* Badges */
body.dark-mode .badge,
body.dark-mode .field-badge,
body.dark-mode .images-count-badge,
html.dark-mode .badge,
html.dark-mode .field-badge,
html.dark-mode .images-count-badge {
  background: #1e1e1e !important;
  color: #a0aec0 !important;
  border-color: #4a5568 !important;
}

/* Images edit */
body.dark-mode .edit-image-item,
html.dark-mode .edit-image-item {
  border-color: #4a5568 !important;
  background: #1e1e1e !important;
}

body.dark-mode .edit-image-add,
html.dark-mode .edit-image-add {
  border-color: #4a5568 !important;
  color: #718096 !important;
  background: #070404 !important;
}

body.dark-mode .edit-image-add:hover,
html.dark-mode .edit-image-add:hover {
  border-color: #9c3030 !important;
  color: #e2e8f0 !important;
  background: #1e1e1e !important;
}

/* Plantillas */
body.dark-mode .plantilla-item,
html.dark-mode .plantilla-item {
  border-color: #ff0000 !important;
  background: #070404 !important;
}

body.dark-mode .plantilla-info h3,
html.dark-mode .plantilla-info h3 {
  color: #e2e8f0 !important;
}

/* Generic text */
body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode h4,
html.dark-mode h1,
html.dark-mode h2,
html.dark-mode h3,
html.dark-mode h4 {
  color: #e2e8f0 !important;
}

body.dark-mode p,
html.dark-mode p {
  color: #a0aec0 !important;
}

body.dark-mode small,
body.dark-mode .form-text,
body.dark-mode .text-muted,
html.dark-mode small,
html.dark-mode .form-text,
html.dark-mode .text-muted {
  color: #718096 !important;
}

body.dark-mode hr,
html.dark-mode hr {
  border-color: #ff0000 !important;
}

body.dark-mode .empty-state p,
html.dark-mode .empty-state p {
  color: #718096 !important;
}

/* Color pickers */
body.dark-mode .color-preview,
html.dark-mode .color-preview {
  border-color: #4a5568 !important;
}

body.dark-mode #combined_preview *,
html.dark-mode #combined_preview * {
  /* Leave as-is, it has inline styles */
}

/* Input type color */
body.dark-mode input[type="color"],
html.dark-mode input[type="color"] {
  border-color: #4a5568 !important;
  background: #1e1e1e !important;
}
/* ==========================
   DARK MODE — nuevos elementos sidebar
========================== */
body.dark-mode .sidebar-collapse-btn,
html.dark-mode .sidebar-collapse-btn {
  border-color: #ff0000 !important;
  color: #ff0000 !important;
  background: transparent !important;
}
body.dark-mode .sidebar-collapse-btn:hover,
html.dark-mode .sidebar-collapse-btn:hover {
  background: #1e1e1e !important;
}
body.dark-mode .nav-link::after,
html.dark-mode .nav-link::after {
  background: #e2e8f0 !important;
  color: #070404 !important;
  box-shadow: 0 4px 14px rgba(0,0,0,.5) !important;
}