/* ==========================================================================
   RENTAL PROPERTY HUB
   Fully responsive: 280 · 380 · 480 · 640 · 720 · 1024 · 1440 · 1920+
   ========================================================================== */

/* ==========================================================================
   0. GLOBAL HARDENING
   ========================================================================== */
.rental-modal,
.rental-detail-modal,
.rental-apply-modal {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.rental-modal :where(h1, h2, h3, h4, p, span, small, strong, label, a, div, li),
.rental-detail-modal :where(h1, h2, h3, h4, p, span, small, strong, label, a, div, li),
.rental-apply-modal :where(h1, h2, h3, h4, p, span, small, strong, label, a, div, li) {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.rental-modal img,
.rental-detail-modal img,
.rental-apply-modal img {
    max-width: 100%;
    height: auto;
}

/* ---------- Root modal ---------- */
.rental-modal {
    position: fixed;
    inset: 0;
    z-index: 10030;
    background: rgba(10, 20, 30, 0.6);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
    padding-top: max(20px, env(safe-area-inset-top, 20px));
    padding-left: max(20px, env(safe-area-inset-left, 20px));
    padding-right: max(20px, env(safe-area-inset-right, 20px));
    padding-bottom: max(20px, env(safe-area-inset-bottom, 20px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.rental-modal[hidden] { display: none; }

.rental-container {
    width: min(1280px, 100%);
    margin: auto;
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    overscroll-behavior: contain;
}

/* ---------- Header ---------- */
.rental-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 16px 22px;
    background: linear-gradient(135deg, #0f2a5c 0%, #1e40af 60%, #3b82f6 100%);
    color: #fff;
    flex: 0 0 auto;
}
.rental-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    min-width: 0;
    flex: 1 1 auto;
}
.rental-header-title > span:first-of-type {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.rental-header-title i { font-size: 1.15rem; flex-shrink: 0; }
.rental-badge {
    background: #facc15;
    color: #78350f;
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    padding: 3px 8px;
    border-radius: 999px;
    margin-left: 4px;
    flex-shrink: 0;
}
.rental-header .window-close-btn {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: none;
    font-size: 1.4rem;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    line-height: 1;
    display: grid;
    place-items: center;
    transition: background 0.15s ease;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.rental-header .window-close-btn:hover { background: rgba(255, 255, 255, 0.3); }

/* ---------- Banner ---------- */
.rental-banner {
    display: flex;
    gap: 14px;
    align-items: center;
    padding: 16px 22px;
    background: linear-gradient(90deg, #eff6ff 0%, #f0f9ff 100%);
    border-bottom: 1px solid #dbeafe;
    flex: 0 0 auto;
}
.rental-banner-icon {
    font-size: 2rem;
    line-height: 1;
    background: #fff;
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.12);
    flex-shrink: 0;
}
.rental-banner-text { min-width: 0; flex: 1; }
.rental-banner-text h3 { margin: 0 0 2px; font-size: 1.05rem; color: #0f2a5c; }
.rental-banner-text p { margin: 0; font-size: 0.85rem; color: #475569; line-height: 1.45; }

/* ---------- Tabs ---------- */
.rental-tabs {
    display: flex;
    gap: 4px;
    padding: 0 18px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    overflow-x: auto;
    overflow-y: hidden;
    flex: 0 0 auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
}
.rental-tabs::-webkit-scrollbar { display: none; }

.rental-tab {
    flex: 0 0 auto;
    padding: 12px 14px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
    white-space: nowrap;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.rental-tab:hover { color: #1e40af; }
.rental-tab.active { color: #1e40af; border-bottom-color: #1e40af; }
.rental-tab:active { transform: scale(0.97); }

.rental-tab-count {
    background: #e2e8f0;
    color: #475569;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 999px;
    min-width: 20px;
    text-align: center;
}
.rental-tab.active .rental-tab-count { background: #1e40af; color: #fff; }

/* ---------- Panels ---------- */
.rental-panel {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 18px 22px;
    display: none;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}
.rental-panel.active { display: block; }
.rental-panel::-webkit-scrollbar { width: 10px; }
.rental-panel::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; }

/* ---------- Filters ---------- */
.rental-filters {
    display: grid;
    gap: 8px;
    grid-template-columns: 2fr repeat(4, minmax(0, 1fr)) auto;
    margin-bottom: 12px;
}
.rental-filter-search {
    position: relative;
    display: flex;
    align-items: center;
    min-width: 0;
}
.rental-filter-search i {
    position: absolute;
    left: 12px;
    color: #94a3b8;
    font-size: 0.85rem;
    pointer-events: none;
}
.rental-filter-search input {
    width: 100%;
    min-width: 0;
    padding: 10px 12px 10px 34px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font-size: 0.85rem;
    outline: none;
    background: #fff;
    font-family: inherit;
}
.rental-filter-search input:focus {
    border-color: #1e40af;
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}
.rental-select {
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #fff;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    min-width: 0;
    max-width: 100%;
    font-family: inherit;
    text-overflow: ellipsis;
    color: #334155;
}
.rental-select:focus { border-color: #1e40af; }

.rental-filter-clear {
    padding: 10px 14px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #475569;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    white-space: nowrap;
    font-family: inherit;
    touch-action: manipulation;
}
.rental-filter-clear:hover { background: #e2e8f0; }

/* ---------- Price row ---------- */
.rental-price-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    background: #f8fafc;
    border-radius: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: #475569;
}
.rental-price-row label { font-weight: 600; flex-shrink: 0; }
.rental-price-row input[type="range"] {
    flex: 1 1 140px;
    min-width: 0;
    accent-color: #1e40af;
}
.rental-price-value {
    font-weight: 700;
    color: #1e40af;
    min-width: 110px;
    text-align: right;
}
.rental-check {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    color: #334155;
    user-select: none;
    flex-shrink: 0;
}
.rental-check input { accent-color: #1e40af; width: 16px; height: 16px; }

/* ---------- Results head ---------- */
.rental-results-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e2e8f0;
    flex-wrap: wrap;
}
.rental-results-head h4 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.rental-results-count {
    background: #eff6ff;
    color: #1e40af;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
    flex-shrink: 0;
}

/* ---------- Grid & cards ---------- */
.rental-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
    min-width: 0;
}

.rental-card-listing {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    display: flex;
    flex-direction: column;
    position: relative;
    min-width: 0;
}
.rental-card-listing:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
    border-color: #bfdbfe;
}
.rental-card-listing:focus-visible {
    outline: 3px solid #fbbf24;
    outline-offset: 2px;
}

.rental-card-media {
    aspect-ratio: 4 / 3;
    background: #e2e8f0;
    position: relative;
    overflow: hidden;
}
.rental-card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.35s;
}
.rental-card-listing:hover .rental-card-media img { transform: scale(1.06); }
.rental-card-media-placeholder {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    color: #94a3b8;
    font-size: 2.2rem;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
}

.rental-card-fav {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    color: #94a3b8;
    font-size: 1rem;
    display: grid;
    place-items: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: color 0.15s ease, transform 0.15s ease;
    z-index: 2;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.rental-card-fav:hover { transform: scale(1.1); }
.rental-card-fav.active { color: #ef4444; }

.rental-card-type-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(15, 42, 92, 0.85);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    max-width: calc(100% - 60px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rental-card-body {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
    min-width: 0;
}
.rental-card-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.rental-card-loc {
    font-size: 0.78rem;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.rental-card-meta {
    display: flex;
    gap: 10px;
    font-size: 0.75rem;
    color: #475569;
    margin-top: 2px;
    flex-wrap: wrap;
}
.rental-card-meta span { display: inline-flex; align-items: center; gap: 4px; }
.rental-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 8px;
    gap: 6px;
    flex-wrap: wrap;
}
.rental-card-price {
    font-weight: 800;
    color: #1e40af;
    font-size: 1rem;
    white-space: nowrap;
}
.rental-card-price small {
    color: #64748b;
    font-weight: 500;
    font-size: 0.7rem;
}
.rental-card-pill {
    font-size: 0.66rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    background: #d1fae5;
    color: #047857;
    white-space: nowrap;
}
.rental-card-pill.furnished { background: #fef3c7; color: #b45309; }

/* ---------- Applications list ---------- */
.rental-apps-list { display: flex; flex-direction: column; gap: 10px; }
.rental-app-row {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px;
    background: #fff;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-start;
    min-width: 0;
}
.rental-app-row h4 {
    margin: 0 0 4px;
    font-size: 0.95rem;
    color: #0f172a;
}
.rental-app-row p {
    margin: 0;
    font-size: 0.8rem;
    color: #64748b;
}
.rental-app-badge {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}
.rental-app-badge.pending { background: #fef3c7; color: #b45309; }
.rental-app-badge.approved { background: #d1fae5; color: #047857; }
.rental-app-badge.declined { background: #fee2e2; color: #b91c1c; }
.rental-app-badge.reviewing { background: #dbeafe; color: #1e40af; }

/* ---------- Landlord panel ---------- */
.rental-landlord-auth {
    display: grid;
    place-items: center;
    padding: 30px 20px;
}
.rental-landlord-auth-card {
    max-width: 400px;
    width: 100%;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 28px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
    min-width: 0;
}
.rental-landlord-auth-card i {
    font-size: 2.2rem;
    color: #1e40af;
    margin-bottom: 12px;
}
.rental-landlord-auth-card h3 { margin: 0 0 6px; font-size: 1.15rem; }
.rental-landlord-auth-card p {
    margin: 0 0 18px;
    color: #64748b;
    font-size: 0.88rem;
    line-height: 1.5;
}
.rental-landlord-auth-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}
.rental-landlord-auth-actions .rental-btn { flex: 1 1 140px; min-width: 0; }

.rental-landlord-hello {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #eff6ff;
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 0.88rem;
    color: #1e40af;
    font-weight: 600;
    flex-wrap: wrap;
}
.rental-landlord-hello i { font-size: 1.2rem; flex-shrink: 0; }
.rental-landlord-hello > span { flex: 1 1 auto; min-width: 0; }
.rental-landlord-logout {
    margin-left: auto;
    background: #fff;
    border: 1px solid #cbd5e1;
    padding: 5px 12px;
    border-radius: 8px;
    font-size: 0.78rem;
    cursor: pointer;
    color: #475569;
    font-weight: 600;
    font-family: inherit;
    min-height: 32px;
    flex-shrink: 0;
    touch-action: manipulation;
}
.rental-landlord-logout:hover { background: #f1f5f9; }

.rental-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 18px;
    margin-bottom: 16px;
    min-width: 0;
}
.rental-card h3 {
    margin: 0 0 14px;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #0f172a;
    flex-wrap: wrap;
}

/* ---------- Forms ---------- */
.rental-form { display: flex; flex-direction: column; gap: 12px; }
.rental-form-row { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.rental-form-row.three { grid-template-columns: 1fr 1fr 1fr; }
.rental-form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}
.rental-form-group label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #334155;
}
.rental-form-group input,
.rental-form-group select,
.rental-form-group textarea {
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    font-size: 0.85rem;
    outline: none;
    background: #fff;
    width: 100%;
    max-width: 100%;
    font-family: inherit;
    min-height: 42px;
    color: #0f172a;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
}
.rental-form-group input:focus,
.rental-form-group select:focus,
.rental-form-group textarea:focus {
    border-color: #1e40af;
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}
.rental-form-group textarea { resize: vertical; min-height: 70px; }

.rental-checkbox-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 8px 0;
}
.rental-form-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    flex-wrap: wrap;
}
.rental-form-actions > * { flex: 1 1 auto; }

/* ---------- Buttons ---------- */
.rental-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    font-family: inherit;
    min-height: 42px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-width: 0;
}
.rental-btn-primary { background: #1e40af; color: #fff; }
.rental-btn-primary:hover { background: #1e3a8a; }
.rental-btn-primary:active { transform: translateY(1px) scale(0.98); }
.rental-btn-outline {
    background: #fff;
    color: #334155;
    border-color: #cbd5e1;
}
.rental-btn-outline:hover { background: #f1f5f9; }
.rental-btn-outline:active { transform: scale(0.98); }
.rental-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* ---------- Empty states ---------- */
.rental-empty {
    text-align: center;
    padding: 40px 20px;
    color: #64748b;
    display: none;
}
.rental-empty.show,
.rental-empty:not([hidden]):not([style*="display: none"]) { display: block; }
.rental-empty i {
    font-size: 2.4rem;
    color: #cbd5e1;
    margin-bottom: 10px;
    display: block;
}
.rental-empty p {
    margin: 0 0 4px;
    font-weight: 600;
    color: #334155;
    font-size: 0.95rem;
}
.rental-empty small { color: #94a3b8; font-size: 0.8rem; }
.rental-empty.small { padding: 20px; }
.rental-empty.small i { font-size: 1.6rem; }

/* ---------- Footer ---------- */
.rental-footer {
    flex: 0 0 auto;
    padding: 12px 22px;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    text-align: center;
}
.rental-footer-note {
    font-size: 0.75rem;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
    line-height: 1.5;
}
.rental-footer-note i { color: #10b981; }

/* ---------- Status ---------- */
.rental-status {
    padding: 10px 14px;
    border-radius: 9px;
    font-size: 0.85rem;
    background: #d1fae5;
    color: #047857;
    border: 1px solid #6ee7b7;
}
.rental-status.error {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fca5a5;
}

/* ==========================================================================
   RENTAL PROPERTY DETAIL MODAL
   ========================================================================== */
.rental-detail-modal {
    position: fixed;
    inset: 0;
    z-index: 10040;
    background: rgba(10, 20, 30, 0.7);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
    padding-top: max(20px, env(safe-area-inset-top, 20px));
    padding-left: max(20px, env(safe-area-inset-left, 20px));
    padding-right: max(20px, env(safe-area-inset-right, 20px));
    padding-bottom: max(20px, env(safe-area-inset-bottom, 20px));
    overflow-y: auto;
    overscroll-behavior: contain;
}
.rental-detail-modal[hidden] { display: none; }

.rental-detail-container {
    width: min(860px, 100%);
    margin: auto;
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    overscroll-behavior: contain;
}

.rental-detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
    flex: 0 0 auto;
}
.rental-detail-back {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #475569;
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 0.95rem;
    flex-shrink: 0;
    touch-action: manipulation;
}
.rental-detail-back:hover { background: #f1f5f9; }
.rental-detail-back:active { transform: scale(0.94); }

.rental-detail-header-text { flex: 1; min-width: 0; }
.rental-detail-type {
    font-size: 0.68rem;
    font-weight: 800;
    color: #1e40af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
}
.rental-detail-header-text h2 {
    margin: 2px 0 0;
    font-size: 1.1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rental-detail-header .window-close-btn {
    background: #f1f5f9;
    border: none;
    font-size: 1.4rem;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    color: #64748b;
    line-height: 1;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    touch-action: manipulation;
}
.rental-detail-header .window-close-btn:hover { background: #e2e8f0; }

.rental-detail-body {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 22px 22px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}
.rental-detail-body::-webkit-scrollbar { width: 10px; }
.rental-detail-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; }

.rental-detail-hero {
    aspect-ratio: 16 / 9;
    border-radius: 14px;
    overflow: hidden;
    background: #e2e8f0;
    margin: 16px 0;
    position: relative;
}
.rental-detail-hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rental-detail-hero-placeholder {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    color: #94a3b8;
    font-size: 3rem;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
}

.rental-detail-price-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.rental-detail-price { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.rental-detail-amount { font-size: 1.8rem; font-weight: 800; color: #1e40af; }
.rental-detail-per { color: #64748b; font-size: 0.9rem; }
.rental-detail-fav-btn {
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #475569;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
    min-height: 40px;
    flex-shrink: 0;
    touch-action: manipulation;
}
.rental-detail-fav-btn.active {
    color: #ef4444;
    border-color: #fca5a5;
    background: #fef2f2;
}
.rental-detail-fav-btn.active i { font-weight: 900; }

.rental-detail-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}
.rental-chip {
    background: #f1f5f9;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.78rem;
    color: #334155;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.rental-detail-section { margin-bottom: 20px; }
.rental-detail-section h3 {
    margin: 0 0 8px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 8px;
}
.rental-detail-section h3 i { color: #1e40af; }
.rental-detail-address,
.rental-detail-desc {
    color: #475569;
    font-size: 0.88rem;
    line-height: 1.6;
    margin: 0;
    white-space: pre-line;
}

.rental-detail-amenities {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(160px, 100%), 1fr));
    gap: 8px;
}
.rental-amenity {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: #334155;
    background: #f8fafc;
    padding: 8px 12px;
    border-radius: 9px;
    border: 1px solid #e2e8f0;
    min-width: 0;
}
.rental-amenity i { color: #10b981; flex-shrink: 0; }

.rental-detail-landlord {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8fafc;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    min-width: 0;
}
.rental-landlord-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #1e40af;
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}
.rental-landlord-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rental-landlord-info strong { font-size: 0.92rem; color: #0f172a; }
.rental-landlord-info span { font-size: 0.78rem; color: #64748b; }

.rental-detail-costs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}
.rental-cost-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #f8fafc;
    border-radius: 9px;
    border: 1px solid #e2e8f0;
    font-size: 0.85rem;
    gap: 10px;
    min-width: 0;
}
.rental-cost-row span:first-child { color: #64748b; }
.rental-cost-row span:last-child { font-weight: 700; color: #0f172a; }

.rental-detail-actions {
    padding: 14px 22px;
    padding-bottom: max(14px, env(safe-area-inset-bottom, 14px));
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 8px;
    flex: 0 0 auto;
    flex-wrap: wrap;
}
.rental-detail-actions .rental-btn { flex: 1 1 140px; min-width: 0; }

/* ==========================================================================
   RENTAL APPLY MODAL
   ========================================================================== */
.rental-apply-modal {
    position: fixed;
    inset: 0;
    z-index: 10050;
    background: rgba(10, 20, 30, 0.7);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
    padding-top: max(20px, env(safe-area-inset-top, 20px));
    padding-left: max(20px, env(safe-area-inset-left, 20px));
    padding-right: max(20px, env(safe-area-inset-right, 20px));
    padding-bottom: max(20px, env(safe-area-inset-bottom, 20px));
    overflow-y: auto;
    overscroll-behavior: contain;
}
.rental-apply-modal[hidden] { display: none; }

.rental-apply-container {
    width: min(680px, 100%);
    margin: auto;
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    overscroll-behavior: contain;
}

.rental-apply-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 16px 22px;
    background: #1e40af;
    color: #fff;
    flex: 0 0 auto;
}
.rental-apply-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.05rem;
    font-weight: 700;
    min-width: 0;
}
.rental-apply-title > span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rental-apply-header .window-close-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.3rem;
    cursor: pointer;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    touch-action: manipulation;
}
.rental-apply-header .window-close-btn:hover { background: rgba(255, 255, 255, 0.3); }

.rental-apply-property-bar {
    padding: 10px 22px;
    background: #eff6ff;
    border-bottom: 1px solid #dbeafe;
    font-size: 0.82rem;
    color: #1e40af;
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    flex-wrap: wrap;
}
.rental-apply-property-bar strong {
    overflow-wrap: anywhere;
}

.rental-apply-body {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 18px 22px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}
.rental-apply-body::-webkit-scrollbar { width: 10px; }
.rental-apply-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; }

.rental-apply-section { margin-bottom: 20px; }
.rental-apply-section h3 {
    margin: 0 0 10px;
    font-size: 0.92rem;
    color: #0f172a;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}
.rental-apply-section h3 i { color: #1e40af; }
.rental-apply-section .rental-form-row { margin-bottom: 10px; }

.rental-apply-actions {
    padding: 14px 22px;
    padding-bottom: max(14px, env(safe-area-inset-bottom, 14px));
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 8px;
    flex: 0 0 auto;
    flex-wrap: wrap;
}
.rental-apply-actions .rental-btn { flex: 1 1 140px; min-width: 0; }

/* ==========================================================================
   RESPONSIVE BREAKPOINTS
   ========================================================================== */

/* ---------- ≤ 1024px : small laptops / large tablets ---------- */
@media (max-width: 1024px) {
    .rental-filters { grid-template-columns: 1fr 1fr 1fr; }
    .rental-filter-search { grid-column: 1 / -1; }
    .rental-filter-clear { grid-column: 1 / -1; justify-content: center; }

    .rental-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
    }
}

/* ---------- ≤ 820px : tablets ---------- */
@media (max-width: 820px) {
    .rental-container,
    .rental-detail-container,
    .rental-apply-container { max-width: 100%; }

    .rental-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
    }

    .rental-form-row.three { grid-template-columns: 1fr 1fr; }
    .rental-form-row.three > .rental-form-group:last-child { grid-column: 1 / -1; }
}

/* ---------- ≤ 720px : phones — full-bleed modals ---------- */
@media (max-width: 720px) {
    .rental-modal,
    .rental-detail-modal,
    .rental-apply-modal {
        padding: 0;
        padding-left: env(safe-area-inset-left, 0px);
        padding-right: env(safe-area-inset-right, 0px);
    }

    .rental-container,
    .rental-detail-container,
    .rental-apply-container {
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
        width: 100%;
        margin: 0;
    }

    /* Safe-area top padding for notched phones */
    .rental-header,
    .rental-detail-header,
    .rental-apply-header {
        padding-top: calc(16px + env(safe-area-inset-top, 0px));
    }

    .rental-filters { grid-template-columns: 1fr 1fr; }
    .rental-filter-search { grid-column: 1 / -1; }
    .rental-filter-clear { grid-column: 1 / -1; }

    .rental-form-row,
    .rental-form-row.three { grid-template-columns: 1fr; }
    .rental-form-row.three > .rental-form-group:last-child { grid-column: auto; }

    .rental-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(180px, 100%), 1fr));
    }
    .rental-detail-costs { grid-template-columns: 1fr; }

    .rental-banner { padding: 14px; gap: 12px; }
    .rental-banner-icon { width: 46px; height: 46px; font-size: 1.6rem; }

    .rental-panel { padding: 14px; }
    .rental-detail-body { padding: 0 14px 14px; }
    .rental-apply-body { padding: 14px; }

    .rental-card { padding: 14px; }

    /* Price row items break */
    .rental-price-row { gap: 10px; padding: 12px; }
    .rental-price-row label { flex: 1 1 100%; }
    .rental-price-row input[type="range"] { flex: 1 1 100%; }
    .rental-price-value { flex: 1 1 100%; text-align: left; min-width: 0; }
    .rental-check { flex: 1 1 calc(50% - 5px); }

    /* Detail hero */
    .rental-detail-hero { aspect-ratio: 4 / 3; max-height: 280px; }

    /* Actions stack */
    .rental-detail-actions,
    .rental-apply-actions {
        flex-direction: column-reverse;
    }
    .rental-detail-actions .rental-btn,
    .rental-apply-actions .rental-btn { width: 100%; flex: 1 1 auto; }

    /* Touch targets ≥ 44px */
    .rental-btn,
    .rental-detail-fav-btn,
    .rental-detail-back,
    .rental-header .window-close-btn,
    .rental-apply-header .window-close-btn { min-height: 44px; }
    .rental-detail-back,
    .rental-header .window-close-btn,
    .rental-apply-header .window-close-btn { width: 44px; height: 44px; }

    .rental-card-fav { width: 40px; height: 40px; font-size: 1.05rem; }
}

/* ---------- ≤ 480px : small phones ---------- */
@media (max-width: 480px) {
    /* Grid → 1 column */
    .rental-grid { grid-template-columns: 1fr; }

    /* Tabs: icon-only */
    .rental-tab span:not(.rental-tab-count) { display: none; }
    .rental-tab {
        min-width: 60px;
        padding: 11px 8px;
        flex: 1 1 0;
        gap: 4px;
        justify-content: center;
    }
    .rental-tab i { font-size: 1.05rem; }

    /* Filters: single column */
    .rental-filters { grid-template-columns: 1fr; }
    .rental-select { width: 100%; }

    /* Buttons tighten */
    .rental-btn {
        padding: 10px 14px;
        font-size: 0.78rem;
        min-height: 42px;
    }

    /* Header */
    .rental-header-title { font-size: 0.95rem; gap: 8px; }
    .rental-badge { font-size: 0.55rem; padding: 2px 7px; }

    /* Banner stacks */
    .rental-banner {
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }

    /* Detail */
    .rental-detail-amount { font-size: 1.4rem; }
    .rental-detail-header-text h2 { font-size: 0.95rem; }
    .rental-detail-type { font-size: 0.6rem; }
    .rental-detail-hero { aspect-ratio: 4 / 3; max-height: 220px; border-radius: 10px; }

    /* Landlord auth card */
    .rental-landlord-auth-card { padding: 22px 18px; }
    .rental-landlord-auth-actions { flex-direction: column; }
    .rental-landlord-auth-actions .rental-btn { width: 100%; flex: 1 1 auto; }

    /* Applications */
    .rental-app-row { padding: 12px; }

    /* Footer */
    .rental-footer-note { font-size: 0.68rem; }
}

/* ---------- ≤ 380px : very small phones ---------- */
@media (max-width: 380px) {
    .rental-tab {
        min-width: 50px;
        padding: 10px 5px;
    }
    .rental-tab i { font-size: 0.95rem; }
    .rental-tab-count { font-size: 0.55rem; padding: 1px 6px; min-width: 18px; }

    .rental-form-group input,
    .rental-form-group select,
    .rental-form-group textarea,
    .rental-select,
    .rental-filter-search input {
        padding: 8px 10px;
        min-height: 40px;
    }

    .rental-btn {
        padding: 9px 12px;
        font-size: 0.75rem;
        min-height: 40px;
    }

    .rental-card-title { font-size: 0.88rem; }
    .rental-card-price { font-size: 0.92rem; }

    .rental-header { padding: 12px 14px; }
    .rental-panel { padding: 12px; }
    .rental-detail-body { padding: 0 12px 12px; }
    .rental-apply-body { padding: 12px; }
    .rental-card { padding: 12px; }
}

/* ---------- ≤ 280px : ultra-compact (embedded webviews) ---------- */
@media (max-width: 280px) {
    .rental-tab {
        min-width: 42px;
        padding: 9px 4px;
    }
    .rental-tab-count { display: none; }

    .rental-header-title { font-size: 0.85rem; }
    .rental-badge { display: none; }

    .rental-banner-icon { width: 40px; height: 40px; font-size: 1.3rem; }

    .rental-btn {
        padding: 8px 10px;
        font-size: 0.7rem;
    }
}

/* ---------- Short landscape phones ---------- */
@media (max-height: 500px) and (orientation: landscape) {
    .rental-modal,
    .rental-detail-modal,
    .rental-apply-modal {
        align-items: flex-start;
        padding: 8px;
    }

    .rental-container,
    .rental-detail-container,
    .rental-apply-container {
        max-height: calc(100vh - 16px);
        max-height: calc(100dvh - 16px);
    }

    .rental-header { padding: 8px 14px; }
    .rental-banner { padding: 8px 14px; }
    .rental-tab { padding: 8px 12px; }
    .rental-panel { padding: 10px 14px; }
    .rental-detail-body { padding: 0 14px 10px; }
    .rental-apply-body { padding: 10px 14px; }
    .rental-detail-hero { aspect-ratio: 16 / 9; max-height: 200px; }
    .rental-footer { padding: 6px 14px; }

    /* Reclaim vertical space in the header */
    .rental-header,
    .rental-detail-header,
    .rental-apply-header {
        padding-top: 8px;
    }
}

/* ---------- Large desktops (≥ 1441px) ---------- */
@media (min-width: 1441px) {
    .rental-container { width: min(1400px, 100%); }
    .rental-detail-container { width: min(960px, 100%); }
    .rental-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
        gap: 20px;
    }
    .rental-card-title { font-size: 1.02rem; }
    .rental-card-price { font-size: 1.08rem; }
}

/* ---------- Ultra-wide (≥ 1921px) ---------- */
@media (min-width: 1921px) {
    .rental-container { width: min(1600px, 100%); }
    .rental-detail-container { width: min(1080px, 100%); }
    .rental-apply-container { width: min(760px, 100%); }

    .rental-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
        gap: 22px;
    }
    .rental-card-body { padding: 16px 18px; }
    .rental-card-title { font-size: 1.1rem; }
    .rental-card-price { font-size: 1.15rem; }

    .rental-btn {
        padding: 12px 22px;
        font-size: 0.95rem;
        min-height: 48px;
    }
}

/* ==========================================================================
   TOUCH + POINTER HARDENING
   ========================================================================== */
@media (hover: none), (pointer: coarse) {
    /* No hover lift on touch — it sticks after tap */
    .rental-card-listing:hover {
        transform: none;
        box-shadow: none;
        border-color: #e2e8f0;
    }
    .rental-card-listing:active { transform: scale(0.98); }

    .rental-card-fav:hover { transform: none; }
    .rental-card-fav:active { transform: scale(0.92); }

    .rental-btn-primary:hover { background: #1e40af; }
    .rental-btn-outline:hover { background: #fff; }

    /* Prevent iOS Safari auto-zoom on focus.
       Any focused field under 16px triggers a zoom. */
    .rental-form-group input,
    .rental-form-group select,
    .rental-form-group textarea,
    .rental-select,
    .rental-filter-search input {
        font-size: 16px;
    }
}

/* ==========================================================================
   REDUCED MOTION
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    .rental-modal,
    .rental-detail-modal,
    .rental-apply-modal,
    .rental-container,
    .rental-detail-container,
    .rental-apply-container,
    .rental-card-listing,
    .rental-card-listing .rental-card-media img,
    .rental-card-fav,
    .rental-btn,
    .rental-tab,
    .rental-detail-back {
        animation: none !important;
        transition: none !important;
        transform: none !important;
    }
}

/* ==========================================================================
   PRINT
   ========================================================================== */
@media print {
    .rental-modal,
    .rental-detail-modal,
    .rental-apply-modal { display: none !important; }
}