* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f4f5f7;
    color: #1f2430;
}

.page-login {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-box {
    background: #fff;
    padding: 32px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
    width: 100%;
    max-width: 360px;
}

.login-box h1 {
    font-size: 20px;
    margin: 0 0 20px;
    text-align: center;
}

form label {
    display: block;
    font-size: 13px;
    margin-bottom: 4px;
    margin-top: 12px;
}

form input,
form select {
    width: 100%;
    padding: 10px;
    border: 1px solid #d0d3d9;
    border-radius: 6px;
    font-size: 14px;
}

form button {
    margin-top: 20px;
    padding: 10px 20px;
    background: #1d5fb0;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}

.link-button {
    color: #1d5fb0;
    text-decoration: underline;
}

.alert {
    padding: 10px;
    border-radius: 6px;
    font-size: 13px;
}

.alert-error {
    background: #fbe7e7;
    color: #a32d2d;
}

.alert-success {
    background: #eaf3de;
    color: #3b6d11;
}

.topbar {
    display: flex;
    flex-direction: column;
    background: #fff;
    padding: 12px 24px;
    border-bottom: 1px solid #e2e4e9;
}

.topbar-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.topbar-title {
    font-weight: 600;
}

.nav-toggle {
    display: none;
    background: none;
    border: 1px solid #d0d3d9;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    color: #1f2430;
}

.topbar-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    font-size: 14px;
}

.topbar-nav a {
    color: #1d5fb0;
    text-decoration: none;
    white-space: nowrap;
    margin-right: 4px;
}

.content {
    padding: 24px;
    max-width: 1000px;
    margin: 0 auto;
    overflow-x: hidden;
}

.card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    max-width: 100%;
    overflow-x: auto;
}

.card h2 {
    margin-top: 0;
    font-size: 16px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
    white-space: nowrap;
}

.data-table th {
    color: #6b7280;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 20px;
    max-width: 600px;
}

.form-grid button {
    grid-column: 1 / -1;
    width: fit-content;
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
    align-items: center;
}

.button-link {
    background: #1d5fb0;
    color: #fff;
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.filter-row select {
    width: auto;
}

.properties-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.property-card {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.property-photo img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
}

.no-photo {
    width: 100%;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #eee;
    color: #999;
    font-size: 13px;
}

.property-info {
    padding: 14px;
}

.property-info h3 {
    margin: 0 0 4px;
    font-size: 15px;
}

.property-ref {
    color: #6b7280;
    font-size: 12px;
    margin: 0 0 6px;
}

.property-info p {
    margin: 4px 0;
    font-size: 13px;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    background: #eef1f5;
    color: #374151;
    margin-top: 6px;
}

.badge-available, .badge-for_rent, .badge-for_sale { background: #eaf3de; color: #3b6d11; }
.badge-rented, .badge-sold, .badge-occupied { background: #e7edfb; color: #1d5fb0; }
.badge-unavailable, .badge-archived { background: #f0f0f0; color: #6b7280; }

.property-actions {
    margin-top: 10px;
    display: flex;
    gap: 12px;
    align-items: center;
}

.property-actions a {
    color: #1d5fb0;
    font-size: 13px;
    text-decoration: none;
}

.link-button-danger {
    background: none;
    border: none;
    color: #a32d2d;
    font-size: 13px;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
}

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

.photo-thumb img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 6px;
}

.hint {
    font-size: 13px;
    color: #6b7280;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.topbar-nav a.active {
    font-weight: 600;
    text-decoration: underline;
}

details summary {
    cursor: pointer;
    color: #1d5fb0;
    font-size: 13px;
}

.inline-payment-form {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    background: #f7f8fa;
    padding: 10px;
    border-radius: 6px;
}

.inline-payment-form label {
    font-size: 12px;
    margin: 0;
}

.inline-payment-form input,
.inline-payment-form select {
    width: auto;
    padding: 6px;
    font-size: 13px;
}

.inline-payment-form button {
    margin: 0;
    padding: 6px 12px;
    font-size: 13px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin: 20px 0;
}

.stat-box {
    background: #fff;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: #1d5fb0;
}

.stat-label {
    display: block;
    font-size: 12px;
    color: #6b7280;
    margin-top: 4px;
}

.alert-card {
    border-left: 4px solid #a32d2d;
}

.bar-chart {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bar-label {
    width: 70px;
    font-size: 12px;
    color: #6b7280;
    flex-shrink: 0;
}

.bar-track {
    flex: 1;
    background: #eef1f5;
    border-radius: 4px;
    height: 20px;
    overflow: hidden;
}

.bar-fill {
    background: #1d5fb0;
    height: 100%;
    border-radius: 4px;
}

.bar-value {
    width: 90px;
    text-align: right;
    font-size: 13px;
    flex-shrink: 0;
}

.big-number {
    font-size: 28px;
    font-weight: 700;
    color: #1d5fb0;
    margin: 0;
}

/* ============================================================
   RESPONSIVE MOBILE
   ============================================================ */
html {
    overflow-x: hidden;
}

body {
    overflow-x: hidden;
    max-width: 100vw;
}

img {
    max-width: 100%;
    height: auto;
}

@media (max-width: 768px) {
    .topbar {
        padding: 12px 16px;
    }

    .nav-toggle {
        display: block;
    }

    .topbar-nav {
        display: none;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        width: 100%;
        margin-top: 12px;
        padding-top: 12px;
        border-top: 1px solid #eee;
    }

    .topbar-nav.open {
        display: flex;
    }

    .topbar-nav a {
        margin-right: 0;
        padding: 4px 0;
    }

    .content {
        padding: 16px;
    }

    .card {
        padding: 16px;
    }

    .form-grid {
        grid-template-columns: 1fr;
        max-width: 100%;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 10px;
    }

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

    .photos-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    }

    .bar-label {
        width: 55px;
    }

    .bar-value {
        width: 70px;
        font-size: 12px;
    }

    .login-box {
        padding: 24px 20px;
    }
}

@media (max-width: 480px) {
    .topbar-title {
        font-size: 14px;
    }

    .topbar-nav {
        font-size: 13px;
        gap: 8px 12px;
    }

    h1 {
        font-size: 20px;
    }

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